diff --git a/OOXML/XlsxFormat/Workbook/DefinedNames.cpp b/OOXML/XlsxFormat/Workbook/DefinedNames.cpp index bfaaa6090d..ce46f59928 100644 --- a/OOXML/XlsxFormat/Workbook/DefinedNames.cpp +++ b/OOXML/XlsxFormat/Workbook/DefinedNames.cpp @@ -54,6 +54,8 @@ namespace OOX } void CDefinedName::toXML(NSStringUtils::CStringBuilder& writer) const { + if (false == m_oRef.IsInit() && false == m_oName.IsInit()) return; + writer.WriteString(L"GetValue()); @@ -85,26 +87,32 @@ namespace OOX void CDefinedName::ReadAttributes(XLS::BaseObjectPtr& obj) { auto ptr = static_cast(obj.get()); - m_oComment = ptr->comment.value(); - // m_oCustomMenu = ptr->.value(); - m_oDescription = ptr->description.value(); - m_oFunction = ptr->fFunc; - m_oFunctionGroupId = ptr->fGrp; - m_oHelp = ptr->helpTopic.value(); - m_oHidden = ptr->fHidden; + + std::wstring ref = ptr->rgce.getAssembledFormula(); + + if (ref.empty()) return; // ??? + + m_oComment = ptr->comment.value(); + // m_oCustomMenu = ptr->.value(); + m_oDescription = ptr->description.value(); + m_oFunction = ptr->fFunc; + m_oFunctionGroupId = ptr->fGrp; + m_oHelp = ptr->helpTopic.value(); + + if (ptr->fHidden) + m_oHidden = ptr->fHidden; if(ptr->itab != 0xFFFFFFFF) m_oLocalSheetId = ptr->itab; - m_oName = ptr->name.value(); - m_oPublishToServer = ptr->fPublished; - m_oShortcutKey = std::to_wstring(ptr->chKey); - //m_oStatusBar = ; - m_oVbProcedure = ptr->fOB; - m_oWorkbookParameter = ptr->fWorkbookParam; - m_oXlm = ptr->fFutureFunction; - m_oRef = ptr->rgce.getAssembledFormula(); - + m_oName = ptr->name.value(); + m_oPublishToServer = ptr->fPublished; + m_oShortcutKey = std::to_wstring(ptr->chKey); + //m_oStatusBar = ; + m_oVbProcedure = ptr->fOB; + m_oWorkbookParameter = ptr->fWorkbookParam; + m_oXlm = ptr->fFutureFunction; + m_oRef = ref; } CDefinedNames::CDefinedNames(OOX::Document *pMain) : WritingElementWithChilds(pMain) diff --git a/OOXML/XlsxFormat/Worksheets/DataValidation.cpp b/OOXML/XlsxFormat/Worksheets/DataValidation.cpp index 751fcd4ede..b1c6b02242 100644 --- a/OOXML/XlsxFormat/Worksheets/DataValidation.cpp +++ b/OOXML/XlsxFormat/Worksheets/DataValidation.cpp @@ -102,72 +102,74 @@ namespace OOX toXML2(writer, false); } void CDataValidation::toXML2(NSStringUtils::CStringBuilder& writer, bool bExtendedWrite) const - { - std::wstring node_name = bExtendedWrite ? L"x14:dataValidation" : L"dataValidation"; + { + if (!m_oSqRef.IsInit()) return; - writer.WriteString(L"<" + node_name); + std::wstring node_name = bExtendedWrite ? L"x14:dataValidation" : L"dataValidation"; + + writer.WriteString(L"<" + node_name); if (bExtendedWrite) { if (false == m_oUuid.IsInit()) { m_oUuid = L"{" + XmlUtils::GenerateGuid() + L"}"; } - WritingStringNullableAttrString (L"xr:uid", m_oUuid, m_oUuid.get()); + WritingStringNullableAttrString(L"xr:uid", m_oUuid, m_oUuid.get()); } else { WritingStringNullableAttrString(L"sqref", m_oSqRef, m_oSqRef.get()); } - WritingStringNullableAttrString (L"type", m_oType, m_oType->ToString()); - WritingStringNullableAttrInt (L"allowBlank", m_oAllowBlank, m_oAllowBlank->GetValue()); - WritingStringNullableAttrEncodeXmlStringHHHH(L"error", m_oError, m_oError.get()); - WritingStringNullableAttrString (L"errorStyle", m_oErrorStyle, m_oErrorStyle->ToString()); - WritingStringNullableAttrEncodeXmlStringHHHH(L"errorTitle", m_oErrorTitle, m_oErrorTitle.get()); - WritingStringNullableAttrString (L"imeMode", m_oImeMode, m_oImeMode->ToString()); - WritingStringNullableAttrString (L"operator", m_oOperator, m_oOperator->ToString()); - WritingStringNullableAttrEncodeXmlStringHHHH(L"prompt", m_oPrompt, m_oPrompt.get()); - WritingStringNullableAttrEncodeXmlStringHHHH(L"promptTitle", m_oPromptTitle, m_oPromptTitle.get()); - WritingStringNullableAttrInt (L"showDropDown", m_oShowDropDown, m_oShowDropDown->GetValue()); - WritingStringNullableAttrInt (L"showErrorMessage",m_oShowErrorMessage,m_oShowErrorMessage->GetValue()); - WritingStringNullableAttrInt (L"showInputMessage",m_oShowInputMessage,m_oShowInputMessage->GetValue()); - writer.WriteString(L">"); + WritingStringNullableAttrString(L"type", m_oType, m_oType->ToString()); + WritingStringNullableAttrInt(L"allowBlank", m_oAllowBlank, m_oAllowBlank->GetValue()); + WritingStringNullableAttrEncodeXmlStringHHHH(L"error", m_oError, m_oError.get()); + WritingStringNullableAttrString(L"errorStyle", m_oErrorStyle, m_oErrorStyle->ToString()); + WritingStringNullableAttrEncodeXmlStringHHHH(L"errorTitle", m_oErrorTitle, m_oErrorTitle.get()); + WritingStringNullableAttrString(L"imeMode", m_oImeMode, m_oImeMode->ToString()); + WritingStringNullableAttrString(L"operator", m_oOperator, m_oOperator->ToString()); + WritingStringNullableAttrEncodeXmlStringHHHH(L"prompt", m_oPrompt, m_oPrompt.get()); + WritingStringNullableAttrEncodeXmlStringHHHH(L"promptTitle", m_oPromptTitle, m_oPromptTitle.get()); + WritingStringNullableAttrInt(L"showDropDown", m_oShowDropDown, m_oShowDropDown->GetValue()); + WritingStringNullableAttrInt(L"showErrorMessage", m_oShowErrorMessage, m_oShowErrorMessage->GetValue()); + WritingStringNullableAttrInt(L"showInputMessage", m_oShowInputMessage, m_oShowInputMessage->GetValue()); + writer.WriteString(L">"); - if (bExtendedWrite) - { - if (m_oFormula1.IsInit()) + if (bExtendedWrite) { - writer.WriteString(L""); + if (m_oFormula1.IsInit()) + { + writer.WriteString(L""); m_oFormula1->toXML2(writer, true); - writer.WriteString(L""); - } - if (m_oFormula2.IsInit()) - { - writer.WriteString(L""); + writer.WriteString(L""); + } + if (m_oFormula2.IsInit()) + { + writer.WriteString(L""); m_oFormula2->toXML2(writer, true); - writer.WriteString(L""); + writer.WriteString(L""); + } + if (m_oSqRef.IsInit()) + { + writer.WriteString(L"" + m_oSqRef.get() + L""); + } } - if (m_oSqRef.IsInit()) + else { - writer.WriteString(L"" + m_oSqRef.get() + L""); - } - } - else - { - if (m_oFormula1.IsInit()) - { - writer.WriteString(L""); + if (m_oFormula1.IsInit()) + { + writer.WriteString(L""); writer.WriteString(m_oFormula1->m_sText); - writer.WriteString(L""); - } - if (m_oFormula2.IsInit()) - { - writer.WriteString(L""); + writer.WriteString(L""); + } + if (m_oFormula2.IsInit()) + { + writer.WriteString(L""); writer.WriteString(m_oFormula2->m_sText); - writer.WriteString(L""); + writer.WriteString(L""); + } } + writer.WriteString(L""); } - writer.WriteString(L""); - } bool CDataValidation::IsExtended() { bool result1 = true, result2 = true;