This is an automated email from the ASF dual-hosted git repository. jimjag pushed a commit to branch odf-devel in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit 347053ad93b11a62be9f5f2d33d8d530b89a96d9 Author: Jim Jagielski <[email protected]> AuthorDate: Wed Oct 28 11:05:13 2026 -0400 xmloff: drop AOO extensions from field and section export in ODF 1.2 strict mode --- main/xmloff/source/text/XMLSectionExport.cxx | 16 +++++--- main/xmloff/source/text/txtflde.cxx | 59 ++++++++++++++++++++-------- 2 files changed, 54 insertions(+), 21 deletions(-) diff --git a/main/xmloff/source/text/XMLSectionExport.cxx b/main/xmloff/source/text/XMLSectionExport.cxx index e1151a8277..c82a82dff4 100644 --- a/main/xmloff/source/text/XMLSectionExport.cxx +++ b/main/xmloff/source/text/XMLSectionExport.cxx @@ -433,7 +433,10 @@ void XMLSectionExport::ExportRegularSectionStart( OUString sCond; aAny >>= sCond; enum XMLTokenEnum eDisplay = XML_TOKEN_INVALID; - if (sCond.getLength() > 0) + // strict ODF 1.2 has no form for the condition of a visible section (display="condition" means hidden) + const sal_Bool bStrict = GetExport().getDefaultVersion() == SvtSaveOptions::ODFVER_012; + const sal_Bool bIsVisible = *(sal_Bool*)xPropSet->getPropertyValue(sIsVisible).getValue(); + if (sCond.getLength() > 0 && !( bStrict && bIsVisible )) { OUString sQValue = GetExport().GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OOOW, @@ -443,7 +446,7 @@ void XMLSectionExport::ExportRegularSectionStart( // #97450# store hidden-status (of conditional sections only) aAny = xPropSet->getPropertyValue(sIsCurrentlyVisible); - if (! *(sal_Bool*)aAny.getValue()) + if (!bStrict && ! *(sal_Bool*)aAny.getValue()) { GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_IS_HIDDEN, XML_TRUE); @@ -1379,10 +1382,13 @@ void XMLSectionExport::ExportIndexTemplateElement( eElement = XML_INDEX_ENTRY_CHAPTER; break; case TOK_TTYPE_HYPERLINK_START: - eElement = XML_INDEX_ENTRY_LINK_START; + // strict ODF 1.2 allows the link tokens in table-of-content templates only + if ( aODFVersion != SvtSaveOptions::ODFVER_012 || TEXT_SECTION_TYPE_TOC == eType ) + eElement = XML_INDEX_ENTRY_LINK_START; break; case TOK_TTYPE_HYPERLINK_END: - eElement = XML_INDEX_ENTRY_LINK_END; + if ( aODFVersion != SvtSaveOptions::ODFVER_012 || TEXT_SECTION_TYPE_TOC == eType ) + eElement = XML_INDEX_ENTRY_LINK_END; break; case TOK_TTYPE_BIBLIOGRAPHY: if (bBibliographyDataOK) @@ -1502,7 +1508,7 @@ void XMLSectionExport::ExportIndexTemplateElement( } // #i21237# - if (bWithTabStopOK && ! bWithTabStop) + if (bWithTabStopOK && ! bWithTabStop && aODFVersion != SvtSaveOptions::ODFVER_012) { GetExport().AddAttribute(XML_NAMESPACE_STYLE, XML_WITH_TAB, diff --git a/main/xmloff/source/text/txtflde.cxx b/main/xmloff/source/text/txtflde.cxx index ca6836a27d..dd24e00166 100644 --- a/main/xmloff/source/text/txtflde.cxx +++ b/main/xmloff/source/text/txtflde.cxx @@ -278,6 +278,19 @@ inline Sequence<OUString> const GetStringSequenceProperty( +// strict ODF 1.2 has no place for AOO's attributes in ODF namespaces +static sal_Bool lcl_IsStrict( SvXMLExport& rExport ) +{ + return rExport.getDefaultVersion() == SvtSaveOptions::ODFVER_012; +} + +// office:currency is not allowed on text:variable-decl in ODF 1.2 +static void lcl_DropCurrency( SvXMLExport& rExport ) +{ + rExport.GetAttrList().RemoveAttribute( rExport.GetNamespaceMap().GetQNameByKey( + XML_NAMESPACE_OFFICE, GetXMLToken( XML_CURRENCY ) ) ); +} + // ODF 1.2 allows only some reference formats per element; the others show the same text static sal_Int16 lcl_GetValidReferencePart( sal_Int16 nPart, sal_Bool bSequence, sal_Bool bNote ) { @@ -1093,6 +1106,7 @@ void XMLTextFieldExport::ExportFieldHelper( Reference<XPropertySetInfo> xPropSetInfo(rPropSet->getPropertySetInfo()); OUString sPresentation = rTextField->getPresentation(sal_False); + const sal_Bool bStrict = lcl_IsStrict( GetExport() ); // process each field type switch (nToken) { @@ -1150,7 +1164,7 @@ void XMLTextFieldExport::ExportFieldHelper( sal_Bool bCmd = GetBoolProperty(sPropertyIsShowFormula, rPropSet); ProcessDisplay(sal_True, bCmd); // #i81766# for older versions export of the value-type - sal_Bool bExportValueType = !bCmd && ( GetExport().getExportFlags() & EXPORT_SAVEBACKWARDCOMPATIBLE ); + sal_Bool bExportValueType = !bCmd && !bStrict && ( GetExport().getExportFlags() & EXPORT_SAVEBACKWARDCOMPATIBLE ); // show style, unless name will be shown ProcessValueAndType(IsStringField(nToken, rPropSet), GetIntProperty(sPropertyNumberFormat, rPropSet), @@ -1172,18 +1186,23 @@ void XMLTextFieldExport::ExportFieldHelper( GetStringProperty(sPropertyHint , rPropSet)); ProcessDisplay(GetBoolProperty(sPropertyIsVisible, rPropSet), sal_False); - ProcessString(XML_FORMULA, XML_NAMESPACE_OOOW, - GetStringProperty(sPropertyContent, rPropSet), - sPresentation); + // text:formula and the office:*value attributes are not allowed on text:variable-input + if ( !bStrict ) + ProcessString(XML_FORMULA, XML_NAMESPACE_OOOW, + GetStringProperty(sPropertyContent, rPropSet), + sPresentation); ProcessValueAndType(IsStringField(nToken, rPropSet), GetIntProperty(sPropertyNumberFormat, rPropSet), GetStringProperty(sPropertyContent, rPropSet), sPresentation, GetDoubleProperty(sPropertyValue, rPropSet), - sal_True, sal_True, sal_True, + !bStrict, sal_True, sal_True, ! GetOptionalBoolProperty( sPropertyIsFixedLanguage, rPropSet, xPropSetInfo, sal_False ) ); + // office:currency is not allowed on text:variable-input either + if ( bStrict ) + lcl_DropCurrency( GetExport() ); ExportElement(XML_VARIABLE_INPUT, sPresentation); break; @@ -1265,10 +1284,13 @@ void XMLTextFieldExport::ExportFieldHelper( // text input field: description and string-value ProcessString(XML_DESCRIPTION, GetStringProperty(sPropertyHint, rPropSet)); - ProcessString(XML_HELP, - GetStringProperty(sPropertyHelp, rPropSet), true); - ProcessString(XML_HINT, - GetStringProperty(sPropertyTooltip, rPropSet), true); + if ( !bStrict ) // text:help and text:hint are not allowed on text:text-input + { + ProcessString(XML_HELP, + GetStringProperty(sPropertyHelp, rPropSet), true); + ProcessString(XML_HINT, + GetStringProperty(sPropertyTooltip, rPropSet), true); + } ExportElement(XML_TEXT_INPUT, sPresentation); break; @@ -1390,7 +1412,7 @@ void XMLTextFieldExport::ExportFieldHelper( sPresentation); sal_Int32 nDummy = 0; // MapPageNumberName need int ProcessString(XML_SELECT_PAGE, MapPageNumberName(rPropSet, nDummy)); - if( 0 == ( GetExport().getExportFlags() & EXPORT_SAVEBACKWARDCOMPATIBLE ) ) + if( bStrict || 0 == ( GetExport().getExportFlags() & EXPORT_SAVEBACKWARDCOMPATIBLE ) ) ExportElement(XML_PAGE_CONTINUATION, sPresentation); else ExportElement(XML_PAGE_CONTINUATION_STRING, sPresentation); @@ -1401,8 +1423,9 @@ void XMLTextFieldExport::ExportFieldHelper( ProcessString(XML_TABLE_NAME, GetStringProperty(sPropertyDataTableName, rPropSet)); ProcessCommandType(GetIntProperty(sPropertyDataCommandType, rPropSet)); - ProcessDisplay(GetBoolProperty(sPropertyIsVisible, rPropSet), - sal_False); + if ( !bStrict ) // text:display is not allowed on the database fields + ProcessDisplay(GetBoolProperty(sPropertyIsVisible, rPropSet), + sal_False); ExportDataBaseElement(XML_DATABASE_NAME, sPresentation, rPropSet, xPropSetInfo); break; @@ -1415,8 +1438,9 @@ void XMLTextFieldExport::ExportFieldHelper( GetInt16Property(sPropertyNumberingType,rPropSet)); ProcessInteger(XML_VALUE, GetIntProperty(sPropertySetNumber, rPropSet)); - ProcessDisplay(GetBoolProperty(sPropertyIsVisible, rPropSet), - sal_False); + if ( !bStrict ) + ProcessDisplay(GetBoolProperty(sPropertyIsVisible, rPropSet), + sal_False); ExportDataBaseElement(XML_DATABASE_ROW_NUMBER, sPresentation, rPropSet, xPropSetInfo); break; @@ -1464,8 +1488,9 @@ void XMLTextFieldExport::ExportFieldHelper( sEmpty, sEmpty, 0.0, // not used sal_False, sal_False, sal_True, sal_False); } - ProcessDisplay(GetBoolProperty(sPropertyIsVisible, rPropSet), - sal_False); + if ( !bStrict ) + ProcessDisplay(GetBoolProperty(sPropertyIsVisible, rPropSet), + sal_False); ExportDataBaseElement(XML_DATABASE_DISPLAY, sPresentation, xMaster, xMaster->getPropertySetInfo()); break; @@ -2073,6 +2098,8 @@ void XMLTextFieldExport::ExportFieldDeclarations( 0, sEmpty, sEmpty, 0.0, sal_False, sal_True, sal_False, sal_False); } + if ( lcl_IsStrict( GetExport() ) ) + lcl_DropCurrency( GetExport() ); ProcessString(XML_NAME, sVarName); ExportElement(XML_VARIABLE_DECL, sal_True);
