[PATCH] Resolves: fdo#58730 workaround [UL|LR]Space 100% problem

Caolán McNamara (via_Code_Review) gerrit at gerrit.libreoffice.org
Thu Jan 17 04:57:18 PST 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/1735

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/35/1735/1

Resolves: fdo#58730 workaround [UL|LR]Space 100% problem

If all paragraph margins are 100% on import, ignore that as being the implicit
default. That avoids explicit 100% being set onto the awesome [UL|LR]Space
which takes a relative propsize of 100% as a flag that its value field is
absolute and so rejected by SwTxtFmtColl::Modify as a candidate for getting its
true value initialized relative to its parent, so it ends up as an absolute 0

If all paragraph margins are 100% on export, then elide the property as being
the implicit default.

Trigged by 3c5facfce42a0dbe362d6b9fa5ac374fd76f51a1

Change-Id: I55f6ceeae287b7d8e99befa4bd3cc06738a21299
---
M xmloff/source/text/txtexppr.cxx
M xmloff/source/text/txtimppr.cxx
2 files changed, 50 insertions(+), 1 deletion(-)



diff --git a/xmloff/source/text/txtexppr.cxx b/xmloff/source/text/txtexppr.cxx
index ceff1d0..d3c8781 100644
--- a/xmloff/source/text/txtexppr.cxx
+++ b/xmloff/source/text/txtexppr.cxx
@@ -295,6 +295,29 @@
 // helper method; implementation below
 static bool lcl_IsOutlineStyle(const SvXMLExport&, const OUString&);
 
+//fdo#58730 The [UL|LR]Space class has a deficiency where "100%" also serves as
+//a flag that the value is an absolute value so we can't truly handle an
+//up/lower space property which wants to specify its 200% upper but 100% lower
+//of its parent (try typing 100% vs 200% into the edit style dialog and revisit
+//your style). So on xml load that ends up meaning 200%, 0 lower. This is a
+//crock.
+//
+//On export clear 100% relative sizes.
+static void
+lcl_clearDefaultRelSize(XMLPropertyState *const pRelState)
+{
+    if (pRelState)
+    {
+        sal_Int32 nTemp = 0;
+        pRelState->maValue >>= nTemp;
+        if (100 == nTemp)
+        {
+            pRelState->mnIndex = -1;
+            pRelState->maValue.clear();
+        }
+    }
+}
+
 static void
 lcl_checkMultiProperty(XMLPropertyState *const pState,
                        XMLPropertyState *const pRelState)
@@ -458,6 +481,9 @@
     XMLPropertyState* pAllParaMargin = NULL;
     XMLPropertyState* pAllMargin = NULL;
 
+    // filter fo:margins
+    XMLPropertyState* pAllParaMarginRel = NULL;
+
     sal_Bool bNeedsAnchor = sal_False;
 
     for( ::std::vector< XMLPropertyState >::iterator aIter = rProperties.begin();
@@ -574,6 +600,7 @@
         case CTF_TEXT_CLIP:             pClipState = propertie; break;
         case CTF_PARAMARGINALL:         pAllParaMargin = propertie; break;
         case CTF_MARGINALL:             pAllMargin = propertie; break;
+        case CTF_PARAMARGINALL_REL:     pAllParaMarginRel = propertie; break;
         }
     }
 
@@ -636,6 +663,8 @@
         pAllMargin->maValue.clear();
     }
 
+    lcl_clearDefaultRelSize(pAllParaMarginRel);
+
     if( pAllBorderWidthState )
     {
         if( pLeftBorderWidthState && pRightBorderWidthState && pTopBorderWidthState && pBottomBorderWidthState )
diff --git a/xmloff/source/text/txtimppr.cxx b/xmloff/source/text/txtimppr.cxx
index be8ef01..6622668 100644
--- a/xmloff/source/text/txtimppr.cxx
+++ b/xmloff/source/text/txtimppr.cxx
@@ -257,6 +257,26 @@
     }
 }
 
+//fdo#58730 The [UL|LR]Space class has a deficiency where "100%" also serves as
+//a flag that the value is an absolute value so we can't truly handle an
+//up/lower space property which wants to specify its 200% upper but 100% lower
+//of its parent (try typing 100% vs 200% into the edit style dialog and revisit
+//your style). So on xml load that ends up meaning 200%, 0 lower. This is a
+//crock.
+//
+//On import clear 100% all-margins relative sizes.
+static bool
+isNotDefaultRelSize(const XMLPropertyState* pRelState, const UniReference<XMLPropertySetMapper>& rPrMap)
+{
+    if (rPrMap->GetEntryContextId(pRelState->mnIndex) == CTF_PARAMARGINALL_REL)
+    {
+        sal_Int32 nTemp = 0;
+        pRelState->maValue >>= nTemp;
+        return nTemp != 100;
+    }
+    return true;
+}
+
 void XMLTextImportPropertyMapper::finished(
             ::std::vector< XMLPropertyState >& rProperties,
             sal_Int32 /*nStartIndex*/, sal_Int32 /*nEndIndex*/ ) const
@@ -425,7 +445,7 @@
 
     for (sal_uInt16 i = 0; i < 4; i++)
     {
-        if (pAllParaMargin && !pParaMargins[i])
+        if (pAllParaMargin && !pParaMargins[i] && isNotDefaultRelSize(pAllParaMargin, getPropertySetMapper()))
         {
 #if OSL_DEBUG_LEVEL > 0
             sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(

-- 
To view, visit https://gerrit.libreoffice.org/1735
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I55f6ceeae287b7d8e99befa4bd3cc06738a21299
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Caolán McNamara <caolanm at redhat.com>



More information about the LibreOffice mailing list