[Libreoffice-commits] core.git: xmloff/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Tue May 12 10:57:12 UTC 2020


 xmloff/source/chart/SchXMLExport.cxx           |   13 +++++++++++--
 xmloff/source/draw/sdxmlexp.cxx                |   12 +++++++++---
 xmloff/source/draw/shapeexport.cxx             |   16 +++++++++++++---
 xmloff/source/style/xmlnumfe.cxx               |   14 +++++++-------
 xmloff/source/text/XMLSectionExport.cxx        |    5 ++++-
 xmloff/source/text/XMLTextMasterPageExport.cxx |   20 ++++++++++++++++----
 xmloff/source/text/txtflde.cxx                 |   16 +++++++++++-----
 xmloff/source/text/txtparae.cxx                |   16 ++++++++++++----
 8 files changed, 83 insertions(+), 29 deletions(-)

New commits:
commit 816022a4d8a1878c8ea74f43a4821e3c8a12d1ea
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Fri Apr 24 18:30:12 2020 +0200
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Tue May 12 12:56:36 2020 +0200

    xmloff: ODF export: adapt to ODF 1.3
    
    * OFFICE-3883 legend svg:width/svg:height
    * OFFICE-3928 chart:coordinate-region
    * OFFICE-3943 draw:mime-type
    * OFFICE-3765 number:fill-character, number:text
    * OFFICE-3860 number:min-decimal-places, number:forced-exponent-sign
    * OFFICE-1828 number:exponent-interval
    * OFFICE-3695 number:max-denominator-value
    * OFFICE-3941 text:index-entry-link-start/text:index-entry-link-end
    * OFFICE-3776 meta:creator-initials
    * OFFICE-3789 style:header-first/style:footer-first
    
    Change-Id: I78c79231c0708c3ae9943097d162898fab71988f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92873
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>

diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index a0a2d2bf401a..6c2f7b1e4120 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -1419,8 +1419,14 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >
                             {
                                 awt::Size aSize( xLegendShape->getSize() );
                                 // tdf#131966: chart legend attributes width and height shouldn't be exported to ODF 1.2 (strict)
-                                if (nCurrentODFVersion > SvtSaveOptions::ODFSVER_012)
+                                if (nCurrentODFVersion >= SvtSaveOptions::ODFSVER_013)
+                                {   // ODF 1.3 OFFICE-3883
+                                    addSize( aSize, false );
+                                }
+                                else if (nCurrentODFVersion & SvtSaveOptions::ODFSVER_EXTENDED)
+                                {
                                     addSize( aSize, true );
+                                }
                                 OUStringBuffer aAspectRatioString;
                                 ::sax::Converter::convertDouble(
                                     aAspectRatioString,
@@ -2118,7 +2124,10 @@ void SchXMLExportHelper_Impl::exportCoordinateRegion( const uno::Reference< char
     addPosition( awt::Point(aRect.X,aRect.Y) );
     addSize( awt::Size(aRect.Width,aRect.Height) );
 
-    SvXMLElementExport aCoordinateRegion( mrExport, XML_NAMESPACE_CHART_EXT, XML_COORDINATE_REGION, true, true );//#i100778# todo: change to chart namespace in future - dependent on fileformat
+    // ODF 1.3 OFFICE-3928
+    SvXMLElementExport aCoordinateRegion( mrExport,
+        (SvtSaveOptions::ODFSVER_013 <= nCurrentODFVersion) ? XML_NAMESPACE_CHART : XML_NAMESPACE_CHART_EXT,
+        XML_COORDINATE_REGION, true, true );
 }
 
 namespace
diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx
index 2432d0756c07..afc209bc9b50 100644
--- a/xmloff/source/draw/sdxmlexp.cxx
+++ b/xmloff/source/draw/sdxmlexp.cxx
@@ -2551,9 +2551,15 @@ void SdXMLExport::exportAnnotations( const Reference<XDrawPage>& xDrawPage )
                 OUString aInitials( xAnnotation->getInitials() );
                 if( !aInitials.isEmpty() )
                 {
-                    // TODO: see OFFICE-3776 export meta:creator-initials for ODF 1.3
-                    SvXMLElementExport aInitialsElem( *this, XML_NAMESPACE_LO_EXT,
-                            XML_SENDER_INITIALS, true, false );
+                    // OFFICE-3776 export meta:creator-initials for ODF 1.3
+                    SvXMLElementExport aInitialsElem( *this,
+                            (SvtSaveOptions::ODFSVER_013 <= getSaneDefaultVersion())
+                                ? XML_NAMESPACE_META
+                                : XML_NAMESPACE_LO_EXT,
+                            (SvtSaveOptions::ODFSVER_013 <= getSaneDefaultVersion())
+                                ? XML_CREATOR_INITIALS
+                                : XML_SENDER_INITIALS,
+                            true, false );
                     Characters(aInitials);
                 }
 
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
index d1d46bf32dab..6d8aba12022e 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -2415,8 +2415,12 @@ void XMLShapeExport::ImpExportGraphicObjectShape(
                     GetExport().GetGraphicMimeTypeFromStream(xGraphic, sOutMimeType);
                 }
                 if (!sOutMimeType.isEmpty())
-                {
-                    GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, "mime-type", sOutMimeType);
+                {   // ODF 1.3 OFFICE-3943
+                    GetExport().AddAttribute(
+                        SvtSaveOptions::ODFSVER_013 <= GetExport().getSaneDefaultVersion()
+                            ? XML_NAMESPACE_DRAW
+                            : XML_NAMESPACE_LO_EXT,
+                        "mime-type", sOutMimeType);
                 }
             }
 
@@ -2457,7 +2461,13 @@ void XMLShapeExport::ImpExportGraphicObjectShape(
                 }
 
                 if (!aMimeType.isEmpty() && GetExport().getSaneDefaultVersion() > SvtSaveOptions::ODFSVER_012)
-                    mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, "mime-type", aMimeType);
+                {   // ODF 1.3 OFFICE-3943
+                    mrExport.AddAttribute(
+                        SvtSaveOptions::ODFSVER_013 <= GetExport().getSaneDefaultVersion()
+                            ? XML_NAMESPACE_DRAW
+                            : XML_NAMESPACE_LO_EXT,
+                        "mime-type", aMimeType);
+                }
 
                 SvXMLElementExport aElement(mrExport, XML_NAMESPACE_DRAW, XML_IMAGE, true, true);
 
diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx
index 178815c54316..9b844eda3a24 100644
--- a/xmloff/source/style/xmlnumfe.cxx
+++ b/xmloff/source/style/xmlnumfe.cxx
@@ -492,8 +492,8 @@ void SvXMLNumFmtExport::WriteRepeatedElement_Impl( sal_Unicode nChar )
     SvtSaveOptions::ODFSaneDefaultVersion eVersion = rExport.getSaneDefaultVersion();
     if (eVersion > SvtSaveOptions::ODFSVER_012)
     {
-        FinishTextElement_Impl(true);
-        // For 1.2+ use loext namespace, for 1.3 use number namespace.
+        FinishTextElement_Impl(eVersion < SvtSaveOptions::ODFSVER_013);
+        // OFFICE-3765 For 1.2+ use loext namespace, for 1.3 use number namespace.
         SvXMLElementExport aElem( rExport,
                                   ((eVersion < SvtSaveOptions::ODFSVER_013) ? XML_NAMESPACE_LO_EXT : XML_NAMESPACE_NUMBER),
                                   XML_FILL_CHARACTER, true, false );
@@ -547,7 +547,7 @@ void SvXMLNumFmtExport::WriteNumberElement_Impl(
         SvtSaveOptions::ODFSaneDefaultVersion eVersion = rExport.getSaneDefaultVersion();
         if (eVersion > SvtSaveOptions::ODFSVER_012)
         {
-            // For 1.2+ use loext namespace, for 1.3 use number namespace.
+            // OFFICE-3860 For 1.2+ use loext namespace, for 1.3 use number namespace.
             rExport.AddAttribute(
                 ((eVersion < SvtSaveOptions::ODFSVER_013) ? XML_NAMESPACE_LO_EXT : XML_NAMESPACE_NUMBER),
                                  XML_MIN_DECIMAL_PLACES,
@@ -636,7 +636,7 @@ void SvXMLNumFmtExport::WriteScientificElement_Impl(
         // Export only for 1.2 with extensions or 1.3 and later.
         if (eVersion > SvtSaveOptions::ODFSVER_012)
         {
-            // For 1.2+ use loext namespace, for 1.3 use number namespace.
+            // OFFICE-3860 For 1.2+ use loext namespace, for 1.3 use number namespace.
             rExport.AddAttribute(
                 ((eVersion < SvtSaveOptions::ODFSVER_013) ? XML_NAMESPACE_LO_EXT : XML_NAMESPACE_NUMBER),
                                  XML_MIN_DECIMAL_PLACES,
@@ -670,7 +670,7 @@ void SvXMLNumFmtExport::WriteScientificElement_Impl(
         // Export only for 1.2 with extensions or 1.3 and later.
         if (eVersion > SvtSaveOptions::ODFSVER_012)
         {
-            // For 1.2+ use loext namespace, for 1.3 use number namespace.
+            // OFFICE-1828 For 1.2+ use loext namespace, for 1.3 use number namespace.
             rExport.AddAttribute(
                     ((eVersion < SvtSaveOptions::ODFSVER_013) ? XML_NAMESPACE_LO_EXT : XML_NAMESPACE_NUMBER),
                     XML_EXPONENT_INTERVAL, OUString::number( nExpInterval ) );
@@ -681,7 +681,7 @@ void SvXMLNumFmtExport::WriteScientificElement_Impl(
     // Export only for 1.2 with extensions or 1.3 and later.
     if (eVersion > SvtSaveOptions::ODFSVER_012)
     {
-        // For 1.2+ use loext namespace, for 1.3 use number namespace.
+        // OFFICE-3860 For 1.2+ use loext namespace, for 1.3 use number namespace.
         rExport.AddAttribute(
             ((eVersion < SvtSaveOptions::ODFSVER_013) ? XML_NAMESPACE_LO_EXT : XML_NAMESPACE_NUMBER),
                              XML_FORCED_EXPONENT_SIGN,
@@ -779,7 +779,7 @@ void SvXMLNumFmtExport::WriteFractionElement_Impl(
                               OUString::number( nMinDenominatorDigits ) );
         if (eVersion > SvtSaveOptions::ODFSVER_012)
         {
-            // For 1.2+ use loext namespace, for 1.3 use number namespace.
+            // OFFICE-3695 For 1.2+ use loext namespace, for 1.3 use number namespace.
             rExport.AddAttribute(
                 ((eVersion < SvtSaveOptions::ODFSVER_013) ? XML_NAMESPACE_LO_EXT : XML_NAMESPACE_NUMBER),
                                  XML_MAX_DENOMINATOR_VALUE,
diff --git a/xmloff/source/text/XMLSectionExport.cxx b/xmloff/source/text/XMLSectionExport.cxx
index e69e6e11487a..7b03730e5b59 100644
--- a/xmloff/source/text/XMLSectionExport.cxx
+++ b/xmloff/source/text/XMLSectionExport.cxx
@@ -1316,7 +1316,10 @@ void XMLSectionExport::ExportIndexTemplateElement(
                         || eType == TEXT_SECTION_TYPE_OBJECT
                         || eType == TEXT_SECTION_TYPE_TABLE
                         || eType == TEXT_SECTION_TYPE_USER);
-                    nNamespace = XML_NAMESPACE_LO_EXT;
+                    // ODF 1.3 OFFICE-3941
+                    nNamespace = (SvtSaveOptions::ODFSVER_013 <= aODFVersion)
+                        ? XML_NAMESPACE_TEXT
+                        : XML_NAMESPACE_LO_EXT;
                 }
                 else
                 {
diff --git a/xmloff/source/text/XMLTextMasterPageExport.cxx b/xmloff/source/text/XMLTextMasterPageExport.cxx
index f2adab2600fa..4e688bdcfbd4 100644
--- a/xmloff/source/text/XMLTextMasterPageExport.cxx
+++ b/xmloff/source/text/XMLTextMasterPageExport.cxx
@@ -124,6 +124,8 @@ void XMLTextMasterPageExport::exportMasterPageContent(
     }
     else
     {
+        auto const nVersion(GetExport().getSaneDefaultVersion());
+
         aAny = rPropSet->getPropertyValue( gsHeaderOn );
         bool bHeader = false;
         aAny >>= bHeader;
@@ -162,12 +164,17 @@ void XMLTextMasterPageExport::exportMasterPageContent(
             exportHeaderFooterContent( xHeaderTextLeft, false );
         }
 
-        if( xHeaderTextFirst.is() && xHeaderTextFirst != xHeaderText )
+        if (xHeaderTextFirst.is() && xHeaderTextFirst != xHeaderText
+            && SvtSaveOptions::ODFSVER_012 < nVersion)
         {
             if (bHeaderFirstShared)
                 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
                                           XML_DISPLAY, XML_FALSE );
-            SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_LO_EXT,
+            // ODF 1.3 OFFICE-3789
+            SvXMLElementExport aElem( GetExport(),
+                                        SvtSaveOptions::ODFSVER_013 <= nVersion
+                                            ? XML_NAMESPACE_STYLE
+                                            : XML_NAMESPACE_LO_EXT,
                                         XML_HEADER_FIRST, true, true );
             exportHeaderFooterContent( xHeaderTextFirst, false );
         }
@@ -210,12 +217,17 @@ void XMLTextMasterPageExport::exportMasterPageContent(
             exportHeaderFooterContent( xFooterTextLeft, false );
         }
 
-        if( xFooterTextFirst.is() && xFooterTextFirst != xFooterText )
+        if (xFooterTextFirst.is() && xFooterTextFirst != xFooterText
+            && SvtSaveOptions::ODFSVER_012 < nVersion)
         {
             if (bFooterFirstShared)
                 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
                                           XML_DISPLAY, XML_FALSE );
-            SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_LO_EXT,
+            // ODF 1.3 OFFICE-3789
+            SvXMLElementExport aElem( GetExport(),
+                                        SvtSaveOptions::ODFSVER_013 <= nVersion
+                                            ? XML_NAMESPACE_STYLE
+                                            : XML_NAMESPACE_LO_EXT,
                                         XML_FOOTER_FIRST, true, true );
             exportHeaderFooterContent( xFooterTextFirst, false );
         }
diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx
index d2aefc403292..396e05075788 100644
--- a/xmloff/source/text/txtflde.cxx
+++ b/xmloff/source/text/txtflde.cxx
@@ -1794,16 +1794,22 @@ void XMLTextFieldExport::ExportFieldHelper(
             GetExport().Characters(aBuffer.makeStringAndClear());
         }
 
-        if (SvtSaveOptions().GetODFSaneDefaultVersion() > SvtSaveOptions::ODFSVER_012)
+        if (GetExport().getSaneDefaultVersion() > SvtSaveOptions::ODFSVER_012)
         {
             // initials
             OUString aInitials( GetStringProperty(gsPropertyInitials, rPropSet) );
             if( !aInitials.isEmpty() )
             {
-                // TODO: see OFFICE-3776 export meta:creator-initials for ODF 1.3
-                SvXMLElementExport aCreatorElem( GetExport(), XML_NAMESPACE_LO_EXT,
-                        XML_SENDER_INITIALS, true,
-                        false );
+                // ODF 1.3 OFFICE-3776 export meta:creator-initials for ODF 1.3
+                SvXMLElementExport aCreatorElem( GetExport(),
+                        (SvtSaveOptions::ODFSVER_013 <= GetExport().getSaneDefaultVersion())
+                            ? XML_NAMESPACE_META
+                            : XML_NAMESPACE_LO_EXT,
+
+                        (SvtSaveOptions::ODFSVER_013 <= GetExport().getSaneDefaultVersion())
+                            ? XML_CREATOR_INITIALS
+                            : XML_SENDER_INITIALS,
+                        true, false );
                 GetExport().Characters(aInitials);
             }
         }
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index 928005e3211d..26ff035a488b 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -3167,8 +3167,12 @@ void XMLTextParagraphExport::_exportTextGraphic(
                 GetExport().GetGraphicMimeTypeFromStream(xGraphic, sOutMimeType);
             }
             if (!sOutMimeType.isEmpty())
-            {
-                GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, "mime-type", sOutMimeType);
+            {   // ODF 1.3 OFFICE-3943
+                GetExport().AddAttribute(
+                    SvtSaveOptions::ODFSVER_013 <= GetExport().getSaneDefaultVersion()
+                        ? XML_NAMESPACE_DRAW
+                        : XML_NAMESPACE_LO_EXT,
+                    "mime-type", sOutMimeType);
             }
         }
 
@@ -3215,8 +3219,12 @@ void XMLTextParagraphExport::_exportTextGraphic(
                 GetExport().GetGraphicMimeTypeFromStream(xReplacementGraphic, sOutMimeType);
             }
             if (!sOutMimeType.isEmpty())
-            {
-                GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, "mime-type", sOutMimeType);
+            {   // ODF 1.3 OFFICE-3943
+                GetExport().AddAttribute(
+                    SvtSaveOptions::ODFSVER_013 <= GetExport().getSaneDefaultVersion()
+                        ? XML_NAMESPACE_DRAW
+                        : XML_NAMESPACE_LO_EXT,
+                    "mime-type", sOutMimeType);
             }
         }
 


More information about the Libreoffice-commits mailing list