[Libreoffice-commits] core.git: include/svx sd/source svx/source

Stephan Bergmann sbergman at redhat.com
Mon Jun 16 03:06:02 PDT 2014


 include/svx/svdmodel.hxx                          |    6 ++----
 sd/source/ui/dlg/unchss.cxx                       |    8 ++++----
 sd/source/ui/func/fupage.cxx                      |    2 +-
 svx/source/sdr/properties/attributeproperties.cxx |    2 +-
 svx/source/svdraw/svdmodel.cxx                    |    5 ++---
 5 files changed, 10 insertions(+), 13 deletions(-)

New commits:
commit e9f405a0daf1dc47a46cb902f05fe24e095b837d
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jun 16 12:00:37 2014 +0200

    Clean up SdrModel::MigrateItemSet
    
    * No need to support null pNewModel argument (the one call site that did pass in
      null explicitly in sd/source/ui/func/fupate.cxx can just as well pass in
      mpDoc, and all existing call sites are guaranteed to pass in a non-null
      value).
    
    * With that changed, SdrModel::MigrateItemSet can be static.  (At least in
      JunitTest_forms_unoapi it could happen that the call from
      svx/source/sdr/properties/attributeproperites.cxx called MigrateItemSet on a
      null GetSdrObject.GetModel(), which was undefined behavior even though it was
      harmless.)
    
    Change-Id: Idface48da7e889c6e5768d0e49bc67c88b4c3ec4

diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx
index ae32250..a97bf5d 100644
--- a/include/svx/svdmodel.hxx
+++ b/include/svx/svdmodel.hxx
@@ -645,10 +645,8 @@ public:
     virtual SvxNumType GetPageNumType() const;
 
     /** copies the items from the source set to the destination set. Both sets must have
-        same ranges but can have different pools. If pNewModel is optional. If it is null,
-        this model is used. */
-
-    void MigrateItemSet( const SfxItemSet* pSourceSet, SfxItemSet* pDestSet, SdrModel* pNewModel );
+        same ranges but can have different pools. */
+    static void MigrateItemSet( const SfxItemSet* pSourceSet, SfxItemSet* pDestSet, SdrModel* pNewModel );
 
     bool IsInDestruction() const { return mbInDestruction;}
 
diff --git a/sd/source/ui/dlg/unchss.cxx b/sd/source/ui/dlg/unchss.cxx
index a876559..05a5f02 100644
--- a/sd/source/ui/dlg/unchss.cxx
+++ b/sd/source/ui/dlg/unchss.cxx
@@ -46,10 +46,10 @@ StyleSheetUndoAction::StyleSheetUndoAction(SdDrawDocument* pTheDoc,
     // Create ItemSets; Attention, it is possible that the new one is from a,
     // different pool. Therefore we clone it with its items.
     pNewSet = new SfxItemSet((SfxItemPool&)SdrObject::GetGlobalDrawObjectItemPool(), pTheNewItemSet->GetRanges());
-    pTheDoc->MigrateItemSet( pTheNewItemSet, pNewSet, pTheDoc );
+    SdrModel::MigrateItemSet( pTheNewItemSet, pNewSet, pTheDoc );
 
     pOldSet = new SfxItemSet((SfxItemPool&)SdrObject::GetGlobalDrawObjectItemPool(),pStyleSheet->GetItemSet().GetRanges());
-    pTheDoc->MigrateItemSet( &pStyleSheet->GetItemSet(), pOldSet, pTheDoc );
+    SdrModel::MigrateItemSet( &pStyleSheet->GetItemSet(), pOldSet, pTheDoc );
 
     aComment = SD_RESSTR(STR_UNDO_CHANGE_PRES_OBJECT);
     OUString aName(pStyleSheet->GetName());
@@ -98,7 +98,7 @@ StyleSheetUndoAction::StyleSheetUndoAction(SdDrawDocument* pTheDoc,
 void StyleSheetUndoAction::Undo()
 {
     SfxItemSet aNewSet( mpDoc->GetItemPool(), pOldSet->GetRanges() );
-    mpDoc->MigrateItemSet( pOldSet, &aNewSet, mpDoc );
+    SdrModel::MigrateItemSet( pOldSet, &aNewSet, mpDoc );
 
     pStyleSheet->GetItemSet().Set(aNewSet);
     if( pStyleSheet->GetFamily() == SD_STYLE_FAMILY_PSEUDO )
@@ -111,7 +111,7 @@ void StyleSheetUndoAction::Undo()
 void StyleSheetUndoAction::Redo()
 {
     SfxItemSet aNewSet( mpDoc->GetItemPool(), pOldSet->GetRanges() );
-    mpDoc->MigrateItemSet( pNewSet, &aNewSet, mpDoc );
+    SdrModel::MigrateItemSet( pNewSet, &aNewSet, mpDoc );
 
     pStyleSheet->GetItemSet().Set(aNewSet);
     if( pStyleSheet->GetFamily() == SD_STYLE_FAMILY_PSEUDO )
diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx
index 9277632..a0bb59f 100644
--- a/sd/source/ui/func/fupage.cxx
+++ b/sd/source/ui/func/fupage.cxx
@@ -301,7 +301,7 @@ const SfxItemSet* FuPage::ExecuteDialog( Window* pParent )
                 // MigrateItemSet makes sure the XFillBitmapItem will have a unique name
                 SfxItemSet aMigrateSet( mpDoc->GetPool(), XATTR_FILLBITMAP, XATTR_FILLBITMAP );
                 aMigrateSet.Put(XFillBitmapItem(OUString("background"), aGraphic));
-                mpDoc->MigrateItemSet( &aMigrateSet, pTempSet.get(), NULL );
+                SdrModel::MigrateItemSet( &aMigrateSet, pTempSet.get(), mpDoc );
 
                 pTempSet->Put( XFillBmpStretchItem( true ));
                 pTempSet->Put( XFillBmpTileItem( false ));
diff --git a/svx/source/sdr/properties/attributeproperties.cxx b/svx/source/sdr/properties/attributeproperties.cxx
index 2675438..d7665c8 100644
--- a/svx/source/sdr/properties/attributeproperties.cxx
+++ b/svx/source/sdr/properties/attributeproperties.cxx
@@ -268,7 +268,7 @@ namespace sdr
                     }
 
                     mpItemSet = mpItemSet->Clone(false, pDestPool);
-                    GetSdrObject().GetModel()->MigrateItemSet(pOldSet, mpItemSet, pNewModel);
+                    SdrModel::MigrateItemSet(pOldSet, mpItemSet, pNewModel);
 
                     // set stylesheet (if used)
                     if(pStySheet)
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index f713087..4b80ef0 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -20,6 +20,7 @@
 
 #include <svx/svdmodel.hxx>
 
+#include <cassert>
 #include <math.h>
 
 #include <osl/endian.h>
@@ -1805,11 +1806,9 @@ void SdrModel::setLock( bool bLock )
 
 void SdrModel::MigrateItemSet( const SfxItemSet* pSourceSet, SfxItemSet* pDestSet, SdrModel* pNewModel )
 {
+    assert(pNewModel != 0);
     if( pSourceSet && pDestSet && (pSourceSet != pDestSet ) )
     {
-        if( pNewModel == NULL )
-            pNewModel = this;
-
         SfxWhichIter aWhichIter(*pSourceSet);
         sal_uInt16 nWhich(aWhichIter.FirstWhich());
         const SfxPoolItem *pPoolItem;


More information about the Libreoffice-commits mailing list