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

Michael Stahl mstahl at redhat.com
Tue Dec 17 15:16:48 PST 2013


 sw/source/core/layout/atrfrm.cxx  |    6 +++++-
 sw/source/filter/xml/xmlexpit.cxx |    2 +-
 xmloff/source/style/xmlbahdl.cxx  |    5 +++--
 xmloff/source/style/xmlbahdl.hxx  |    4 ++--
 4 files changed, 11 insertions(+), 6 deletions(-)

New commits:
commit 22355042a6fc7aecf3caab69b3fa3be1430b697f
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Dec 17 23:44:38 2013 +0100

    fdo#72452: ODF import/export: fix handling of style:page-number
    
    Class XMLNumberWithAutoInsteadZeroPropHdl (which appears to be used only
    for this attribute) needs to be adapted to the change that
    "PageNumberOffset" value 0 is no longer invalid; use "void" value for
    invalid instead, which appears more appropriate anyway.
    
    Unfortunately the type of style:page-number is positiveInteger so
    writing 0 would be invalid; write "auto" instead for now.
    
    Change-Id: I9621ea201fd928087b863c562607c3d77a3b0269

diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index eb540b4..2434150 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -710,7 +710,11 @@ bool SwFmtPageDesc::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
         case MID_PAGEDESC_PAGENUMOFFSET:
         {
             sal_Int16 nOffset = 0;
-            if(rVal >>= nOffset)
+            if (!rVal.hasValue())
+            {
+                SetNumOffset(boost::none);
+            }
+            else if (rVal >>= nOffset)
                 SetNumOffset( nOffset );
             else
                 bRet = false;
diff --git a/sw/source/filter/xml/xmlexpit.cxx b/sw/source/filter/xml/xmlexpit.cxx
index abe355d..b1e5182 100644
--- a/sw/source/filter/xml/xmlexpit.cxx
+++ b/sw/source/filter/xml/xmlexpit.cxx
@@ -1005,7 +1005,7 @@ bool SvXMLExportItemMapper::QueryXMLValue(
             if( MID_PAGEDESC_PAGENUMOFFSET==nMemberId )
             {
                 ::boost::optional<sal_uInt16> oNumOffset = pPageDesc->GetNumOffset();
-                if (oNumOffset)
+                if (oNumOffset && oNumOffset.get() > 0)
                 {
                     // #i114163# positiveInteger only!
                     sal_Int32 const number(oNumOffset.get());
diff --git a/xmloff/source/style/xmlbahdl.cxx b/xmloff/source/style/xmlbahdl.cxx
index 3397e47..0a797e5 100644
--- a/xmloff/source/style/xmlbahdl.cxx
+++ b/xmloff/source/style/xmlbahdl.cxx
@@ -879,7 +879,7 @@ bool XMLNumberWithAutoInsteadZeroPropHdl::importXML(
         lcl_xmloff_setAny( rValue, nValue, 2 );
     else if( rStrImpValue == GetXMLToken( XML_AUTO ) )
     {
-        rValue <<= (sal_Int16)nValue;
+        rValue.clear(); // void
         bRet = true;
     }
     return bRet;
@@ -891,7 +891,8 @@ bool XMLNumberWithAutoInsteadZeroPropHdl::exportXML( OUString& rStrExpValue, con
     sal_Int32 nValue = 0;
     lcl_xmloff_getAny( rValue, nValue, 2 );
 
-    if( 0 == nValue )
+    // FIXME: 0 is not a valid value - write "auto" instead
+    if (0 == nValue || !rValue.hasValue())
         rStrExpValue = GetXMLToken( XML_AUTO );
     else
     {
diff --git a/xmloff/source/style/xmlbahdl.hxx b/xmloff/source/style/xmlbahdl.hxx
index 58c6dc1..8b57ccb 100644
--- a/xmloff/source/style/xmlbahdl.hxx
+++ b/xmloff/source/style/xmlbahdl.hxx
@@ -306,8 +306,8 @@ public:
 
 /**
     PropertyHandler for the XML-data-type: XML_TYPE_NUMBER16_AUTO
-    Reads/writes numeric properties with special handling for the value zero
-    (i.e., a value 0 property will be written as "auto")
+    Reads/writes numeric properties with special handling for "void" value
+    (i.e., void property will be written as "auto")
 */
 class XMLNumberWithAutoInsteadZeroPropHdl : public XMLNumberWithoutZeroPropHdl
 {


More information about the Libreoffice-commits mailing list