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

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Tue May 19 08:25:26 UTC 2020


 include/xmloff/txtprmap.hxx                    |    1 
 xmloff/inc/XMLNumberWithAutoForVoidPropHdl.hxx |   41 +++++++++++++++++++++++++
 xmloff/source/style/prhdlfac.cxx               |    3 +
 xmloff/source/style/xmlbahdl.cxx               |   12 ++++---
 xmloff/source/style/xmlbahdl.hxx               |   15 ---------
 xmloff/source/text/txtexppr.cxx                |   18 ++++++++++
 xmloff/source/text/txtprmap.cxx                |    2 -
 7 files changed, 70 insertions(+), 22 deletions(-)

New commits:
commit 9019288dc1ea8c6db615b9f8bbae14efc1ed8cd8
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Thu Apr 30 17:58:35 2020 +0200
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Tue May 19 10:24:46 2020 +0200

    tdf#91306 xmloff: ODF export: allow style:page-number="0" in ODF 1.3
    
    See OFFICE-3923.
    
    Change-Id: I619d9efe3eb17feaf84f7dd21f5b2197c30bc6aa
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93225
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>

diff --git a/include/xmloff/txtprmap.hxx b/include/xmloff/txtprmap.hxx
index c05619bf44ee..37c0d7a9f330 100644
--- a/include/xmloff/txtprmap.hxx
+++ b/include/xmloff/txtprmap.hxx
@@ -201,6 +201,7 @@
 #define CTF_CHAR_HIGHLIGHT                  (XML_TEXT_CTF_START + 172)
 #define CTF_FILLSTYLE                       (XML_TEXT_CTF_START + 173)
 #define CTF_FILLCOLOR                       (XML_TEXT_CTF_START + 174)
+#define CTF_PAGENUMBEROFFSET                (XML_TEXT_CTF_START + 175)
 
 
 enum class TextPropMap {
diff --git a/xmloff/inc/XMLNumberWithAutoForVoidPropHdl.hxx b/xmloff/inc/XMLNumberWithAutoForVoidPropHdl.hxx
new file mode 100644
index 000000000000..425ed84e1d56
--- /dev/null
+++ b/xmloff/inc/XMLNumberWithAutoForVoidPropHdl.hxx
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <xmloff/xmlprhdl.hxx>
+
+/**
+    PropertyHandler for the XML-data-type: XML_TYPE_NUMBER16_AUTO
+    Reads/writes numeric properties with special handling for "void" value
+    (i.e., void property will be written as "auto")
+*/
+class XMLNumberWithAutoForVoidPropHdl : public XMLPropertyHandler
+{
+public:
+    explicit XMLNumberWithAutoForVoidPropHdl() {}
+    virtual ~XMLNumberWithAutoForVoidPropHdl() override;
+
+    virtual bool importXML(const OUString& rStrImpValue, css::uno::Any& rValue,
+                           const SvXMLUnitConverter& rUnitConverter) const override;
+    virtual bool exportXML(OUString& rStrExpValue, const css::uno::Any& rValue,
+                           const SvXMLUnitConverter& rUnitConverter) const override;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/style/prhdlfac.cxx b/xmloff/source/style/prhdlfac.cxx
index f9ef62fa23ee..4343e534b690 100644
--- a/xmloff/source/style/prhdlfac.cxx
+++ b/xmloff/source/style/prhdlfac.cxx
@@ -54,6 +54,7 @@
 #include <AttributeContainerHandler.hxx>
 #include "durationhdl.hxx"
 #include <XMLRectangleMembersHandler.hxx>
+#include <XMLNumberWithAutoForVoidPropHdl.hxx>
 #include "DrawAspectHdl.hxx"
 
 #include <map>
@@ -457,7 +458,7 @@ std::unique_ptr<XMLPropertyHandler> XMLPropertyHandlerFactory::CreatePropertyHan
             pPropHdl.reset(new XMLNumberWithoutZeroPropHdl( 2 ));
             break;
         case XML_TYPE_NUMBER16_AUTO:
-            pPropHdl.reset(new XMLNumberWithAutoInsteadZeroPropHdl);
+            pPropHdl.reset(new XMLNumberWithAutoForVoidPropHdl);
             break;
         case XML_TYPE_TEXT_VERTICAL_POS:
             pPropHdl.reset(new XMLConstantsPropertyHandler( pXML_VertPos_Enum, XML_TOKEN_INVALID ));
diff --git a/xmloff/source/style/xmlbahdl.cxx b/xmloff/source/style/xmlbahdl.cxx
index 90cbbf04eafd..87b1e1c69363 100644
--- a/xmloff/source/style/xmlbahdl.cxx
+++ b/xmloff/source/style/xmlbahdl.cxx
@@ -19,6 +19,7 @@
 
 #include "xmlbahdl.hxx"
 
+#include <XMLNumberWithAutoForVoidPropHdl.hxx>
 #include <sal/log.hxx>
 #include <o3tl/any.hxx>
 #include <o3tl/safeint.hxx>
@@ -829,11 +830,11 @@ bool XMLNumberWithoutZeroPropHdl::exportXML( OUString& rStrExpValue, const Any&
 }
 
 
-XMLNumberWithAutoInsteadZeroPropHdl::~XMLNumberWithAutoInsteadZeroPropHdl()
+XMLNumberWithAutoForVoidPropHdl::~XMLNumberWithAutoForVoidPropHdl()
 {
 }
 
-bool XMLNumberWithAutoInsteadZeroPropHdl::importXML(
+bool XMLNumberWithAutoForVoidPropHdl::importXML(
     const OUString& rStrImpValue,
     Any& rValue,
     const SvXMLUnitConverter& ) const
@@ -850,14 +851,15 @@ bool XMLNumberWithAutoInsteadZeroPropHdl::importXML(
     return bRet;
 }
 
-bool XMLNumberWithAutoInsteadZeroPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
+bool XMLNumberWithAutoForVoidPropHdl::exportXML(
+        OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter&) const
 {
 
     sal_Int32 nValue = 0;
     bool bRet = lcl_xmloff_getAny( rValue, nValue, 2 );
-    bRet &= nValue != 0;
 
-    // FIXME: 0 is not a valid value - write "auto" instead
+    // note: 0 is a valid value here, see CTF_PAGENUMBEROFFSET for when it isn't
+
     if (!bRet)
         rStrExpValue = GetXMLToken( XML_AUTO );
     else
diff --git a/xmloff/source/style/xmlbahdl.hxx b/xmloff/source/style/xmlbahdl.hxx
index c88488f4848b..52622c539910 100644
--- a/xmloff/source/style/xmlbahdl.hxx
+++ b/xmloff/source/style/xmlbahdl.hxx
@@ -303,21 +303,6 @@ public:
     virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
 };
 
-/**
-    PropertyHandler for the XML-data-type: XML_TYPE_NUMBER16_AUTO
-    Reads/writes numeric properties with special handling for "void" value
-    (i.e., void property will be written as "auto")
-*/
-class XMLNumberWithAutoInsteadZeroPropHdl : public XMLNumberWithoutZeroPropHdl
-{
-public:
-    explicit XMLNumberWithAutoInsteadZeroPropHdl() : XMLNumberWithoutZeroPropHdl(4) {}
-    virtual ~XMLNumberWithAutoInsteadZeroPropHdl() override;
-
-    virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
-    virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
-};
-
 #endif // INCLUDED_XMLOFF_SOURCE_STYLE_XMLBAHDL_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/text/txtexppr.cxx b/xmloff/source/text/txtexppr.cxx
index 3ab5f8456801..fb1c459d304f 100644
--- a/xmloff/source/text/txtexppr.cxx
+++ b/xmloff/source/text/txtexppr.cxx
@@ -34,8 +34,10 @@
 #include <xmloff/txtprmap.hxx>
 #include <xmloff/xmlexp.hxx>
 #include <xmloff/maptype.hxx>
+#include <xmloff/nmspmap.hxx>
 #include "XMLSectionFootnoteConfigExport.hxx"
 #include <xmlsdtypes.hxx>
+#include <XMLNumberWithAutoForVoidPropHdl.hxx>
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -147,6 +149,22 @@ void XMLTextExportPropertySetMapper::handleSpecialItem(
 
     switch( getPropertySetMapper()->GetEntryContextId( rProperty.mnIndex ) )
     {
+    case CTF_PAGENUMBEROFFSET:
+        {
+            OUString value;
+            XMLNumberWithAutoForVoidPropHdl const handler;
+            handler.exportXML(value, rProperty.maValue, rUnitConverter);
+            if (GetExport().getSaneDefaultVersion() < SvtSaveOptions::ODFSVER_013
+                && value == "0") // tdf#91306 ODF 1.3 OFFICE-3923
+            {
+                value = "auto";
+            }
+            OUString const name = rNamespaceMap.GetQNameByKey(
+                getPropertySetMapper()->GetEntryNameSpace(rProperty.mnIndex),
+                getPropertySetMapper()->GetEntryXMLName(rProperty.mnIndex));
+            rAttrList.AddAttribute(name, value);
+        }
+        break;
     case CTF_DROPCAPWHOLEWORD:
         SAL_WARN_IF( !!bDropWholeWord, "xmloff", "drop whole word is set already!" );
         pThis->bDropWholeWord = *o3tl::doAccess<bool>(rProperty.maValue);
diff --git a/xmloff/source/text/txtprmap.cxx b/xmloff/source/text/txtprmap.cxx
index 4f779c43cdc2..61f59505a9d7 100644
--- a/xmloff/source/text/txtprmap.cxx
+++ b/xmloff/source/text/txtprmap.cxx
@@ -363,7 +363,7 @@ XMLPropertyMapEntry const aXMLParaPropMap[] =
     MP_E( "ParaIsAutoFirstLineIndent",  STYLE, AUTO_TEXT_INDENT,    XML_TYPE_BOOL, 0 ),
     // RES_PAGEDESC
     MP_E( "PageDescName",           STYLE,  MASTER_PAGE_NAME,           MID_FLAG_SPECIAL_ITEM|XML_TYPE_STYLENAME, CTF_PAGEDESCNAME ),
-    MP_E( "PageNumberOffset",       STYLE,  PAGE_NUMBER,            XML_TYPE_NUMBER16_AUTO, 0 ),
+    MP_E( "PageNumberOffset",       STYLE,  PAGE_NUMBER,            XML_TYPE_NUMBER16_AUTO|MID_FLAG_SPECIAL_ITEM_EXPORT, CTF_PAGENUMBEROFFSET ),
     // RES_BREAK : TODO: does this work?
     MP_E( "BreakType",      FO, BREAK_BEFORE,       XML_TYPE_TEXT_BREAKBEFORE|MID_FLAG_MULTI_PROPERTY, 0 ),
     MP_E( "BreakType",      FO, BREAK_AFTER,        XML_TYPE_TEXT_BREAKAFTER, 0 ),


More information about the Libreoffice-commits mailing list