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

Michael Stahl mstahl at redhat.com
Tue Apr 21 06:53:36 PDT 2015


 xmloff/source/text/txtexppr.cxx |   53 ++++++++++++++++++++--------------------
 xmloff/source/text/txtprmap.cxx |    3 ++
 2 files changed, 30 insertions(+), 26 deletions(-)

New commits:
commit c13b80e202a07b374531babe3af5a8529483f060
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Apr 21 14:03:01 2015 +0200

    tdf#90640: xmloff: ODF export: fix style:background-image attributes
    
    ... for Writer frames, which were missing the draw:opacity; turns out
    this is because now the the default valued properties are not exported
    any more, which causes them to be missing in the property array so the
    hard-coded indexes in XMLTextExportPropertySetMapper::handleElementItem()
    do not find them.
    
    (regression from c3e49660e782816d1203cb936156ef6d6a1ad572)
    
    Change-Id: I84b6c09b23a2275161135290f1b0ac9f52546a80

diff --git a/xmloff/source/text/txtexppr.cxx b/xmloff/source/text/txtexppr.cxx
index 0b453bd..dfb3594 100644
--- a/xmloff/source/text/txtexppr.cxx
+++ b/xmloff/source/text/txtexppr.cxx
@@ -71,35 +71,36 @@ void XMLTextExportPropertySetMapper::handleElementItem(
 
     case CTF_BACKGROUND_URL:
         {
-            DBG_ASSERT( pProperties && nIdx >= 3,
-                        "property vector missing" );
+            assert(pProperties && nIdx >= 3);
             const Any *pPos = 0, *pFilter = 0, *pTrans = 0;
-            if( pProperties && nIdx >= 3 )
+            sal_uInt32 nPropIndex = rProperty.mnIndex;
+
+            // these are all optional, so have to check them in order
+            // note: this index order dependency is a steaming pile of manure
+            sal_uInt32 nIndex(nIdx - 1);
+            const XMLPropertyState& rFilter = (*pProperties)[nIndex];
+            if (CTF_BACKGROUND_FILTER == getPropertySetMapper()
+                    ->GetEntryContextId(rFilter.mnIndex))
             {
-                const XMLPropertyState& rTrans = (*pProperties)[nIdx-3];
-                // #99657# transparency may be there, but doesn't have to be.
-                // If it's there, it must be in the right position.
-                if( CTF_BACKGROUND_TRANSPARENCY == getPropertySetMapper()
-                      ->GetEntryContextId( rTrans.mnIndex ) )
-                    pTrans = &rTrans.maValue;
-
-                const XMLPropertyState& rPos = (*pProperties)[nIdx-2];
-                DBG_ASSERT( CTF_BACKGROUND_POS == getPropertySetMapper()
-                        ->GetEntryContextId( rPos.mnIndex ),
-                         "invalid property map: pos expected" );
-                if( CTF_BACKGROUND_POS == getPropertySetMapper()
-                        ->GetEntryContextId( rPos.mnIndex ) )
-                    pPos = &rPos.maValue;
-
-                const XMLPropertyState& rFilter = (*pProperties)[nIdx-1];
-                DBG_ASSERT( CTF_BACKGROUND_FILTER == getPropertySetMapper()
-                        ->GetEntryContextId( rFilter.mnIndex ),
-                         "invalid property map: filter expected" );
-                if( CTF_BACKGROUND_FILTER == getPropertySetMapper()
-                        ->GetEntryContextId( rFilter.mnIndex ) )
-                    pFilter = &rFilter.maValue;
+                pFilter = &rFilter.maValue;
+                --nIndex;
             }
-            sal_uInt32 nPropIndex = rProperty.mnIndex;
+
+            const XMLPropertyState& rPos = (*pProperties)[nIndex];
+            if (CTF_BACKGROUND_POS == getPropertySetMapper()
+                    ->GetEntryContextId(rPos.mnIndex))
+            {
+                pPos = &rPos.maValue;
+                --nIndex;
+            }
+
+            const XMLPropertyState& rTrans = (*pProperties)[nIndex];
+            // #99657# transparency may be there, but doesn't have to be.
+            // If it's there, it must be in the right position.
+            if( CTF_BACKGROUND_TRANSPARENCY == getPropertySetMapper()
+                  ->GetEntryContextId( rTrans.mnIndex ) )
+                pTrans = &rTrans.maValue;
+
             pThis->maBackgroundImageExport.exportXML(
                     rProperty.maValue, pPos, pFilter, pTrans,
                     getPropertySetMapper()->GetEntryNameSpace( nPropIndex ),
diff --git a/xmloff/source/text/txtprmap.cxx b/xmloff/source/text/txtprmap.cxx
index 19979c9..7f892f4 100644
--- a/xmloff/source/text/txtprmap.cxx
+++ b/xmloff/source/text/txtprmap.cxx
@@ -382,6 +382,7 @@ XMLPropertyMapEntry aXMLParaPropMap[] =
     // RES_ANCHOR
     // not required
     // RES_BACKGROUND
+    // DO NOT REORDER these!
     MP_E( "ParaBackColor",  FO, BACKGROUND_COLOR,       XML_TYPE_COLORTRANSPARENT|MID_FLAG_MULTI_PROPERTY, 0 ),
     MP_E( "ParaBackTransparent",    FO, BACKGROUND_COLOR,       XML_TYPE_ISTRANSPARENT|MID_FLAG_MERGE_ATTRIBUTE, 0 ),
     MP_E( "ParaBackGraphicLocation",    STYLE,  POSITION,   MID_FLAG_SPECIAL_ITEM|XML_TYPE_BUILDIN_CMP_ONLY, CTF_BACKGROUND_POS  ),
@@ -744,6 +745,7 @@ XMLPropertyMapEntry aXMLFramePropMap[] =
     // RES_ANCHOR
     // see above
     // RES_BACKGROUND
+    // DO NOT REORDER these!
     MG_ED( "BackColorRGB",  FO, BACKGROUND_COLOR,       XML_TYPE_COLORTRANSPARENT|MID_FLAG_MULTI_PROPERTY, 0 ),
     MG_ED( "BackTransparent",   FO, BACKGROUND_COLOR,       XML_TYPE_ISTRANSPARENT|MID_FLAG_MERGE_ATTRIBUTE|MID_FLAG_MULTI_PROPERTY, CTF_BACKGROUND_TRANSPARENT ),
     MG_ED( "BackColorTransparency", STYLE, BACKGROUND_TRANSPARENCY, XML_TYPE_PERCENT8, CTF_BACKGROUND_TRANSPARENCY ),
@@ -924,6 +926,7 @@ XMLPropertyMapEntry aXMLSectionPropMap[] =
     MS_E( "TextColumns",            STYLE,  COLUMNS,    MID_FLAG_ELEMENT_ITEM|XML_TYPE_TEXT_COLUMNS, CTF_TEXTCOLUMNS ),
 
     // RES_BACKGROUND
+    // DO NOT REORDER these!
     MS_E( "BackColor",  FO, BACKGROUND_COLOR,       XML_TYPE_COLORTRANSPARENT|MID_FLAG_MULTI_PROPERTY, 0 ),
     MS_E( "BackTransparent",    FO, BACKGROUND_COLOR,       XML_TYPE_ISTRANSPARENT|MID_FLAG_MERGE_ATTRIBUTE, 0 ),
     MS_E( "BackGraphicLocation",    STYLE,  POSITION,   MID_FLAG_SPECIAL_ITEM|XML_TYPE_BUILDIN_CMP_ONLY, CTF_BACKGROUND_POS  ),


More information about the Libreoffice-commits mailing list