[Libreoffice-commits] core.git: Branch 'aoo/trunk' - svx/source

Armin Le Grand alg at apache.org
Mon Jul 7 09:07:56 PDT 2014


 svx/source/svdraw/svdfmtf.cxx |   33 +++++++++++++++++++++------------
 svx/source/svdraw/svdfmtf.hxx |    5 ++++-
 2 files changed, 25 insertions(+), 13 deletions(-)

New commits:
commit 87637364387e5fd87d3b880ce230caa053ec555d
Author: Armin Le Grand <alg at apache.org>
Date:   Mon Jul 7 15:19:08 2014 +0000

    i125211 corrected beaking metafiles with gradient actions

diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx
index 3e7cc6e..c2fce3f 100644
--- a/svx/source/svdraw/svdfmtf.cxx
+++ b/svx/source/svdraw/svdfmtf.cxx
@@ -180,7 +180,10 @@ void ImpSdrGDIMetaFileImport::DoLoopActions(GDIMetaFile& rMtf, SvdProgressInfo*
             case META_PUSH_ACTION           : DoAction((MetaPushAction           &)*pAct); break;
             case META_POP_ACTION            : DoAction((MetaPopAction            &)*pAct); break;
             case META_HATCH_ACTION          : DoAction((MetaHatchAction          &)*pAct); break;
-            case META_COMMENT_ACTION        : DoAction((MetaCommentAction        &)*pAct, &rMtf); break;
+
+            // #i125211# MetaCommentAction may change index, thus hand it over
+            case META_COMMENT_ACTION        : DoAction((MetaCommentAction&)*pAct, rMtf, a);
+                break;
 
             // missing actions added
             case META_TEXTRECT_ACTION       : DoAction((MetaTextRectAction&)*pAct); break;
@@ -1159,7 +1162,8 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaHatchAction& rAct )
         {
             const Hatch& rHatch = rAct.GetHatch();
             SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
-            SfxItemSet aHatchAttr(mpModel->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE, XATTR_FILLHATCH, XATTR_FILLHATCH, 0, 0);
+            // #i125211# Use the ranges from the SdrObject to create a new empty SfxItemSet
+            SfxItemSet aHatchAttr(mpModel->GetItemPool(), pPath->GetMergedItemSet().GetRanges());
             XHatchStyle eStyle;
 
             switch(rHatch.GetStyle())
@@ -1231,13 +1235,14 @@ void ImpSdrGDIMetaFileImport::MapScaling()
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
-void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction& rAct, GDIMetaFile* pMtf )
+void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction& rAct, GDIMetaFile& rMtf, sal_uLong& a) // GDIMetaFile* pMtf )
 {
     ByteString aSkipComment;
 
-    if( rAct.GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_BEGIN" ) == COMPARE_EQUAL )
+    if( a < rMtf.GetActionCount() && rAct.GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_BEGIN" ) == COMPARE_EQUAL )
     {
-        MetaGradientExAction* pAct = (MetaGradientExAction*) pMtf->NextAction();
+        // #i125211# Check if next action is a MetaGradientExAction
+        MetaGradientExAction* pAct = dynamic_cast< MetaGradientExAction* >(rMtf.GetAction(a + 1));
 
         if( pAct && pAct->GetType() == META_GRADIENTEX_ACTION )
         {
@@ -1250,7 +1255,8 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction& rAct, GDIMetaFile* pM
                 {
                     const Gradient& rGrad = pAct->GetGradient();
                     SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
-                    SfxItemSet aGradAttr(mpModel->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE, XATTR_FILLGRADIENT, XATTR_FILLGRADIENT, 0, 0);
+                    // #i125211# Use the ranges from the SdrObject to create a new empty SfxItemSet
+                    SfxItemSet aGradAttr(mpModel->GetItemPool(), pPath->GetMergedItemSet().GetRanges());
                     XGradient aXGradient;
 
                     aXGradient.SetGradientStyle((XGradientStyle)rGrad.GetStyle());
@@ -1288,13 +1294,14 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction& rAct, GDIMetaFile* pM
 
     if(aSkipComment.Len())
     {
-        MetaAction* pSkipAct = pMtf->NextAction();
+        // #i125211# forward until closing MetaCommentAction
+        MetaAction* pSkipAct = rMtf.GetAction(++a);
 
         while( pSkipAct
             && ((pSkipAct->GetType() != META_COMMENT_ACTION )
                 || (((MetaCommentAction*)pSkipAct)->GetComment().CompareIgnoreCaseToAscii(aSkipComment.GetBuffer()) != COMPARE_EQUAL)))
         {
-            pSkipAct = pMtf->NextAction();
+            pSkipAct = rMtf.GetAction(++a);
         }
     }
 }
@@ -1422,7 +1429,8 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaGradientAction& rAct)
                 floor(aRange.getMinY()),
                 ceil(aRange.getMaxX()),
                 ceil(aRange.getMaxY())));
-        SfxItemSet aGradientAttr(mpModel->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE, XATTR_FILLGRADIENT, XATTR_FILLGRADIENT, 0, 0);
+        // #i125211# Use the ranges from the SdrObject to create a new empty SfxItemSet
+        SfxItemSet aGradientAttr(mpModel->GetItemPool(), pRect->GetMergedItemSet().GetRanges());
         const XGradientStyle aXGradientStyle(getXGradientStyleFromGradientStyle(rGradient.GetStyle()));
         const XFillGradientItem aXFillGradientItem(
             &mpModel->GetItemPool(),
@@ -1439,7 +1447,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaGradientAction& rAct)
                 rGradient.GetSteps()));
 
         SetAttributes(pRect);
-        aGradientAttr.Put(XFillStyleItem(XFILL_HATCH));
+        aGradientAttr.Put(XFillStyleItem(XFILL_GRADIENT)); // #i125211#
         aGradientAttr.Put(aXFillGradientItem);
         pRect->SetMergedItemSet(aGradientAttr);
 
@@ -1492,7 +1500,8 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaGradientExAction& rAct)
         {
             const Gradient& rGradient = rAct.GetGradient();
             SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
-            SfxItemSet aGradientAttr(mpModel->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE, XATTR_FILLGRADIENT, XATTR_FILLGRADIENT, 0, 0);
+            // #i125211# Use the ranges from the SdrObject to create a new empty SfxItemSet
+            SfxItemSet aGradientAttr(mpModel->GetItemPool(), pPath->GetMergedItemSet().GetRanges());
             const XGradientStyle aXGradientStyle(getXGradientStyleFromGradientStyle(rGradient.GetStyle()));
             const XFillGradientItem aXFillGradientItem(
                 &mpModel->GetItemPool(),
@@ -1509,7 +1518,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaGradientExAction& rAct)
                     rGradient.GetSteps()));
 
             SetAttributes(pPath);
-            aGradientAttr.Put(XFillStyleItem(XFILL_HATCH));
+            aGradientAttr.Put(XFillStyleItem(XFILL_GRADIENT)); // #i125211#
             aGradientAttr.Put(aXFillGradientItem);
             pPath->SetMergedItemSet(aGradientAttr);
 
diff --git a/svx/source/svdraw/svdfmtf.hxx b/svx/source/svdraw/svdfmtf.hxx
index c0431ce..c0dbccb 100644
--- a/svx/source/svdraw/svdfmtf.hxx
+++ b/svx/source/svdraw/svdfmtf.hxx
@@ -122,7 +122,10 @@ protected:
     void DoAction(MetaMoveClipRegionAction  & rAct) { rAct.Execute(&maVD); checkClip(); }
     void DoAction(MetaISectRectClipRegionAction& rAct) { rAct.Execute(&maVD); checkClip(); }
     void DoAction(MetaISectRegionClipRegionAction& rAct) { rAct.Execute(&maVD); checkClip(); }
-    void DoAction(MetaCommentAction& rAct, GDIMetaFile* pMtf);
+
+    // #i125211# The MetaCommentAction needs to advance (if used), thus
+    // give current metafile and index which may be changed
+    void DoAction(MetaCommentAction& rAct, GDIMetaFile& rMtf, sal_uLong& a);
 
     // missing actions added
     void DoAction(MetaTextRectAction& rAct);


More information about the Libreoffice-commits mailing list