[Libreoffice-commits] core.git: Branch 'feature/graphicobject' - 3 commits - cui/source filter/source include/svtools include/svx sc/source svtools/source svx/source sw/source

Michael Meeks michael.meeks at suse.com
Mon Aug 26 01:26:10 PDT 2013


 cui/source/tabpages/tparea.cxx                    |    4 
 cui/source/tabpages/tpbitmap.cxx                  |   14 -
 filter/source/msfilter/msdffimp.cxx               |    8 
 include/svtools/grfmgr.hxx                        |   72 +++-----
 include/svx/xbtmpit.hxx                           |    5 
 sc/source/filter/excel/xiescher.cxx               |    2 
 sc/source/filter/oox/drawingmanager.cxx           |    2 
 sc/source/ui/view/viewfun7.cxx                    |    2 
 svtools/source/graphic/grfcache.cxx               |  195 +++++++++-------------
 svtools/source/graphic/grfcache.hxx               |   28 +--
 svtools/source/graphic/grfmgr.cxx                 |  121 ++-----------
 svtools/source/graphic/grfmgr2.cxx                |   85 ++++-----
 svx/source/customshapes/EnhancedCustomShape2d.cxx |    3 
 svx/source/customshapes/EnhancedCustomShape3d.cxx |    7 
 svx/source/svdraw/svdfmtf.cxx                     |    3 
 svx/source/svdraw/svdograf.cxx                    |    3 
 svx/source/svdraw/svdoole2.cxx                    |    3 
 svx/source/xoutdev/xattrbmp.cxx                   |   20 ++
 sw/source/core/frmedt/fecopy.cxx                  |    7 
 19 files changed, 244 insertions(+), 340 deletions(-)

New commits:
commit 254aa1cc7f897a7df6bfc7d49da5be83dab0144d
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Sat Aug 24 19:55:18 2013 +0100

    remove unused ReleaseFromCache and cleanup pCopyObj.
    
    Change-Id: Idee91df4e7da3a08de4e59e0b4e5166e644aced1

diff --git a/include/svtools/grfmgr.hxx b/include/svtools/grfmgr.hxx
index 14ad6b5..6e62066 100644
--- a/include/svtools/grfmgr.hxx
+++ b/include/svtools/grfmgr.hxx
@@ -235,11 +235,7 @@ private:
 
     void                    SVT_DLLPRIVATE ImplConstruct();
     void                    SVT_DLLPRIVATE ImplAssignGraphicData();
-    void                    SVT_DLLPRIVATE ImplSetGraphicManager(
-                                const OString* pID = NULL,
-                                const rtl::Reference< GraphicObject > &xCopyObj =
-                                    rtl::Reference< GraphicObject > ()
-                            );
+    void                    SVT_DLLPRIVATE ImplSetup( const OString* pID = NULL );
     void                    SVT_DLLPRIVATE ImplAutoSwapIn();
     sal_Bool                SVT_DLLPRIVATE ImplIsAutoSwapped() const { return mbAutoSwapped; }
     sal_Bool                SVT_DLLPRIVATE ImplGetCropParams(
@@ -381,7 +377,6 @@ public:
                                 const GraphicAttr* pAttr = NULL,
                                 sal_uLong nFlags = GRFMGR_DRAW_STANDARD
                             ) const;
-    void                    ReleaseFromCache();
 
     const Graphic&          GetGraphic() const;
 
@@ -617,13 +612,11 @@ private:
                             const GraphicAttr& rAttr
                         );
 
-                    // Only used by GraphicObject's Ctor's and Dtor's
+    // Only used by GraphicObject's Ctor's and Dtor's
     void SVT_DLLPRIVATE ImplRegisterObj(
                             const rtl::Reference< GraphicObject >& xObj,
                             Graphic& rSubstitute,
-                            const OString* pID = NULL,
-                            const rtl::Reference< GraphicObject > &xCopyObj =
-                                rtl::Reference< GraphicObject > ()
+                            const OString* pID = NULL
                         );
     void SVT_DLLPRIVATE ImplUnregisterObj( const rtl::Reference< GraphicObject >& xObj );
     inline sal_Bool SVT_DLLPRIVATE ImplHasObjects() const { return !maObjList.empty(); }
@@ -653,8 +646,6 @@ public:
 
     void                SetCacheTimeout( sal_uLong nTimeoutSeconds );
 
-    void                ReleaseFromCache( const rtl::Reference< GraphicObject >& xObj );
-
     sal_Bool            IsInCache(
                             OutputDevice* pOut,
                             const Point& rPt,
diff --git a/svtools/source/graphic/grfcache.cxx b/svtools/source/graphic/grfcache.cxx
index eda0e3a..28f2120 100644
--- a/svtools/source/graphic/grfcache.cxx
+++ b/svtools/source/graphic/grfcache.cxx
@@ -842,44 +842,16 @@ GraphicCache::~GraphicCache()
 void GraphicCache::AddGraphicObject(
     const rtl::Reference< GraphicObject >& xObj,
     Graphic& rSubstitute,
-    const OString* pID,
-    const rtl::Reference< GraphicObject >* pCopyObj
+    const OString* pID
 )
 {
-#error mis-handling of pCopyObj
-
     sal_Bool bInserted = sal_False;
 
     if(  !xObj->IsSwappedOut()
-      && (  pID
-         || (    pCopyObj
-            && ( pCopyObj->GetType() != GRAPHIC_NONE )
-            )
-         || ( xObj->GetType() != GRAPHIC_NONE )
+      && ( pID || ( xObj->GetType() != GRAPHIC_NONE )
          )
       )
     {
-        if( pCopyObj
-          && !maGraphicCache.empty()
-        )
-        {
-            GraphicCacheEntryList::iterator it = maGraphicCache.begin();
-            while(  !bInserted
-                 && ( it != maGraphicCache.end() )
-                 )
-            {
-                if( (*it)->HasGraphicObjectReference( *pCopyObj ) )
-                {
-                    (*it)->AddGraphicObjectReference( xObj, rSubstitute );
-                    bInserted = sal_True;
-                }
-                else
-                {
-                    ++it;
-                }
-            }
-        }
-
         if( !bInserted )
         {
             GraphicCacheEntryList::iterator it = maGraphicCache.begin();
@@ -1015,7 +987,7 @@ void GraphicCache::GraphicObjectWasSwappedIn( const rtl::Reference< GraphicObjec
         if( pEntry->GetID().IsEmpty() )
         {
             ReleaseGraphicObject( xObj );
-            AddGraphicObject( xObj, (Graphic&) xObj->GetGraphic(), NULL, NULL );
+            AddGraphicObject( xObj, (Graphic&) xObj->GetGraphic(), NULL );
         }
         else
             pEntry->GraphicObjectWasSwappedIn( xObj );
diff --git a/svtools/source/graphic/grfcache.hxx b/svtools/source/graphic/grfcache.hxx
index 1866628..60d0548 100644
--- a/svtools/source/graphic/grfcache.hxx
+++ b/svtools/source/graphic/grfcache.hxx
@@ -68,8 +68,7 @@ public:
     void                    AddGraphicObject(
                                 const rtl::Reference< GraphicObject >& rObj,
                                 Graphic& rSubstitute,
-                                const OString* pID,
-                                const rtl::Reference< GraphicObject >* pCopyObj
+                                const OString* pID
                             );
 
     void                    ReleaseGraphicObject( const rtl::Reference< GraphicObject >& rObj );
diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx
index 8a67cce..842e7f5 100644
--- a/svtools/source/graphic/grfmgr.cxx
+++ b/svtools/source/graphic/grfmgr.cxx
@@ -61,26 +61,26 @@ struct GrfSimpleCacheObj
 
 TYPEINIT1_AUTOFACTORY( GraphicObject, SvDataCopyStream );
 
-GraphicObject::GraphicObject()
+GraphicObject::GraphicObject() :
     mpLink      ( NULL ),
     mpUserData  ( NULL )
 {
     ImplConstruct();
     ImplAssignGraphicData();
-    ImplSetGraphicManager();
+    ImplSetup();
 }
 
-GraphicObject::GraphicObject( const Graphic& rGraphic, const GraphicManager* pMgr ) :
+GraphicObject::GraphicObject( const Graphic& rGraphic )
     maGraphic   ( rGraphic ),
     mpLink      ( NULL ),
     mpUserData  ( NULL )
 {
     ImplConstruct();
     ImplAssignGraphicData();
-    ImplSetGraphicManager();
+    ImplSetup();
 }
 
-GraphicObject::GraphicObject( const GraphicObject& rGraphicObj, const GraphicManager* pMgr ) :
+GraphicObject::GraphicObject( const GraphicObject& rGraphicObj ) :
     SvDataCopyStream(),
     maGraphic   ( rGraphicObj.GetGraphic() ),
     maAttr      ( rGraphicObj.maAttr ),
@@ -89,10 +89,10 @@ GraphicObject::GraphicObject( const GraphicObject& rGraphicObj, const GraphicMan
 {
     ImplConstruct();
     ImplAssignGraphicData();
-    ImplSetGraphicManager(NULL, &rGraphicObj );
+    ImplSetup();
 }
 
-GraphicObject::GraphicObject( const OString& rUniqueID, const GraphicManager* pMgr ) :
+GraphicObject::GraphicObject( const OString& rUniqueID ) :
     mpLink      ( NULL ),
     mpUserData  ( NULL )
 {
@@ -101,7 +101,7 @@ GraphicObject::GraphicObject( const OString& rUniqueID, const GraphicManager* pM
     // assign default properties
     ImplAssignGraphicData();
 
-    ImplSetGraphicManager(&rUniqueID);
+    ImplSetup(&rUniqueID);
 
     // update properties
     ImplAssignGraphicData();
@@ -123,10 +123,10 @@ GraphicObject::GraphicObject( css::uno::Sequence< css::uno::Any > const & args,
             throw css::lang::IllegalArgumentException();
 
         OString bsId ( OUStringToOString ( sId, RTL_TEXTENCODING_UTF8 ) );
-        ImplSetGraphicManager( NULL, &bsId );
+        ImplSetup( &bsId );
     }
     else
-        ImplSetGraphicManager( NULL );
+        ImplSetup();
 }
 
 css::uno::Reference< css::graphic::XGraphic > SAL_CALL GraphicObject::getGraphic()
@@ -197,7 +197,7 @@ void GraphicObject::ImplAssignGraphicData()
     mnAnimationLoopCount = ( mbAnimated ? maGraphic.GetAnimationLoopCount() : 0 );
 }
 
-void GraphicObject::ImplSetGraphicManager( const OString* pID, const rtl::Reference< GraphicObject > &xCopyObj )
+void GraphicObject::ImplSetup( const OString* pID )
 {
     GraphicManager *pGlobalMgr;
 
@@ -217,7 +217,7 @@ void GraphicObject::ImplSetGraphicManager( const OString* pID, const rtl::Refere
     // FIXME: remove this member in favour of the global eventually
     mpMgr = pGlobalMgr;
 
-    mpMgr->ImplRegisterObj( *this, maGraphic, pID, xCopyObj );
+    mpMgr->ImplRegisterObj( *this, maGraphic, pID );
 }
 
 void GraphicObject::ImplAutoSwapIn()
@@ -479,7 +479,7 @@ void GraphicObject::GraphicManagerDestroyed()
 {
     // we're alive, but our manager doesn't live anymore ==> connect to default manager
     mpMgr = NULL;
-    ImplSetGraphicManager( NULL );
+    ImplSetup( NULL );
 }
 
 sal_Bool GraphicObject::IsCached( OutputDevice* pOut, const Point& rPt, const Size& rSz,
@@ -505,12 +505,6 @@ sal_Bool GraphicObject::IsCached( OutputDevice* pOut, const Point& rPt, const Si
     return bRet;
 }
 
-void GraphicObject::ReleaseFromCache()
-{
-
-    mpMgr->ReleaseFromCache( *this );
-}
-
 bool GraphicObject::Draw( OutputDevice* pOut, const Point& rPt, const Size& rSz,
                           const GraphicAttr* pAttr, sal_uLong nFlags )
 {
diff --git a/svtools/source/graphic/grfmgr2.cxx b/svtools/source/graphic/grfmgr2.cxx
index 84a18a8..ec6be0f 100644
--- a/svtools/source/graphic/grfmgr2.cxx
+++ b/svtools/source/graphic/grfmgr2.cxx
@@ -70,21 +70,16 @@ void GraphicManager::SetCacheTimeout( sal_uLong nTimeoutSeconds )
     mpCache->SetCacheTimeout( nTimeoutSeconds );
 }
 
-void GraphicManager::ReleaseFromCache( const GraphicObject& /*rObj*/ )
-{
-    // !!!
-}
-
 sal_Bool GraphicManager::IsInCache( OutputDevice* pOut, const Point& rPt,
-                                    const Size& rSz, const GraphicObject& rObj,
+                                    const Size& rSz, const rtl::Reference< GraphicObject > &rObj,
                                     const GraphicAttr& rAttr ) const
 {
     return mpCache->IsInDisplayCache( pOut, rPt, rSz, rObj, rAttr );
 }
 
 sal_Bool GraphicManager::DrawObj( OutputDevice* pOut, const Point& rPt, const Size& rSz,
-                              GraphicObject& rObj, const GraphicAttr& rAttr,
-                              const sal_uLong nFlags, sal_Bool& rCached )
+                                  const rtl::Reference< GraphicObject >& rObj, const GraphicAttr& rAttr,
+                                  const sal_uLong nFlags, sal_Bool& rCached )
 {
     Point   aPt( rPt );
     Size    aSz( rSz );
@@ -140,12 +135,10 @@ sal_Bool GraphicManager::DrawObj( OutputDevice* pOut, const Point& rPt, const Si
 
 void GraphicManager::ImplRegisterObj( const rtl::Reference< GraphicObject >& xObj,
                                       Graphic& rSubstitute,
-                                      const OString* pID,
-                                      const rtl::Reference< GraphicObject >* pCopyObj )
+                                      const OString* pID )
 {
-#error mis-handling of pCopyObj
     maObjList.push_back( xObj );
-    mpCache->AddGraphicObject( xObj, rSubstitute, pID, pCopyObj );
+    mpCache->AddGraphicObject( xObj, rSubstitute, pID );
 }
 
 void GraphicManager::ImplUnregisterObj( const rtl::Reference< GraphicObject >& xObj )
commit f853fc635313eb1a5263c47bc40b49ad94a9fbaa
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Sat Aug 24 19:45:53 2013 +0100

    Make GraphicObjects immutable, create a new one to change it.
    
    Change-Id: Iaa5c520d2246412c46420fe1822b5d25583bc509

diff --git a/include/svtools/grfmgr.hxx b/include/svtools/grfmgr.hxx
index 6261f51..14ad6b5 100644
--- a/include/svtools/grfmgr.hxx
+++ b/include/svtools/grfmgr.hxx
@@ -176,7 +176,6 @@ private:
     explicit GraphicObject();
     GraphicObject( const Graphic& rGraphic );
     GraphicObject( const GraphicObject& rCacheObj );
-    GraphicObject& operator=( const GraphicObject& rCacheObj );
 
     explicit GraphicObject( const OString& rUniqueID );
 
@@ -385,8 +384,6 @@ public:
     void                    ReleaseFromCache();
 
     const Graphic&          GetGraphic() const;
-    void                    SetGraphic( const Graphic& rGraphic, const rtl::Reference< GraphicObject >& pCopyObj = rtl::Reference< GraphicObject >() );
-    void                    SetGraphic( const Graphic& rGraphic, const String& rLink );
 
     /** Get graphic transformed according to given attributes
 
diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx
index 1f80f8e..8a67cce 100644
--- a/svtools/source/graphic/grfmgr.cxx
+++ b/svtools/source/graphic/grfmgr.cxx
@@ -101,7 +101,7 @@ GraphicObject::GraphicObject( const OString& rUniqueID, const GraphicManager* pM
     // assign default properties
     ImplAssignGraphicData();
 
-    ImplSetGraphicManager(&rUniqueID );
+    ImplSetGraphicManager(&rUniqueID);
 
     // update properties
     ImplAssignGraphicData();
@@ -141,8 +141,10 @@ void SAL_CALL GraphicObject::setGraphic( const css::uno::Reference< css::graphic
 {
     SolarMutexGuard aSolarGuard;
 
-    Graphic aGraphic( xGraphic );
-    SetGraphic( aGraphic );
+    // GraphicObjects should be superficially immutable, and refer to one object.
+    assert( "this setGraphic method seems like a pretty horrible design flaw, and awfully un-necessary - please construct a new object" );
+//    Graphic aGraphic( xGraphic );
+//    SetGraphic( aGraphic );
 }
 
 OUString SAL_CALL GraphicObject::getUniqueID()
@@ -349,35 +351,6 @@ sal_Bool GraphicObject::ImplGetCropParams( OutputDevice* pOut, Point& rPt, Size&
     return bRet;
 }
 
-GraphicObject& GraphicObject::operator=( const GraphicObject& rGraphicObj )
-{
-    // FIXME: mmeeks this operator should be removed [!] ...
-    assert(false);
-
-    if( &rGraphicObj != this )
-    {
-        mpMgr->ImplUnregisterObj( *this );
-
-        delete mpSwapStreamHdl, mpSwapStreamHdl = NULL;
-        delete mpSimpleCache, mpSimpleCache = NULL;
-        delete mpLink;
-        delete mpUserData;
-
-        maGraphic = rGraphicObj.GetGraphic();
-        maAttr = rGraphicObj.maAttr;
-        mpLink = rGraphicObj.mpLink ? new String( *rGraphicObj.mpLink ) : NULL;
-        mpUserData = rGraphicObj.mpUserData ? new String( *rGraphicObj.mpUserData ) : NULL;
-        ImplAssignGraphicData();
-        mbAutoSwapped = sal_False;
-        mpMgr = rGraphicObj.mpMgr;
-
-        mpMgr->ImplRegisterObj( *this, maGraphic, NULL,
-                                GraphicObject::Create( &rGraphicObj ) );
-    }
-
-    return *this;
-}
-
 sal_Bool GraphicObject::operator==( const GraphicObject& rGraphicObj ) const
 {
     return( ( rGraphicObj.maGraphic == maGraphic ) &&
@@ -770,25 +743,6 @@ const Graphic& GraphicObject::GetGraphic() const
     return maGraphic;
 }
 
-void GraphicObject::SetGraphic( const Graphic& rGraphic, const rtl::Reference< GraphicObject > &xCopyObj )
-{
-    mpMgr->ImplUnregisterObj( *this );
-
-    if( mpSwapOutTimer )
-        mpSwapOutTimer->Stop();
-
-    maGraphic = rGraphic;
-    mbAutoSwapped = sal_False;
-    ImplAssignGraphicData();
-    delete mpLink, mpLink = NULL;
-    delete mpSimpleCache, mpSimpleCache = NULL;
-
-    mpMgr->ImplRegisterObj( *this, maGraphic, 0, xCopyObj);
-
-    if( mpSwapOutTimer )
-        mpSwapOutTimer->Start();
-}
-
 void GraphicObject::SetGraphic( const Graphic& rGraphic, const String& rLink )
 {
     SetGraphic( rGraphic );
commit 3a84b1724a800ef3177b5c51843636200970b0fe
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Sat Aug 24 19:34:39 2013 +0100

    Improved XFillBitmapItem constructor / cleanup.
    
    Change-Id: I3ddf6d5c7d3b31f339e51048a29c41ca2d98979b

diff --git a/cui/source/tabpages/tparea.cxx b/cui/source/tabpages/tparea.cxx
index 0a281b4..7126c1f 100644
--- a/cui/source/tabpages/tparea.cxx
+++ b/cui/source/tabpages/tparea.cxx
@@ -2074,12 +2074,12 @@ IMPL_LINK_NOARG(SvxAreaTabPage, ModifyBitmapHdl_Impl)
         const XBitmapEntry* pEntry = pBitmapList->GetBitmap(_nPos);
 
         rXFSet.Put(XFillStyleItem(XFILL_BITMAP));
-        rXFSet.Put(XFillBitmapItem(String(), pEntry->GetGraphicObject()));
+        rXFSet.Put(XFillBitmapItem(pEntry->GetGraphicObject()));
     }
     else if( SFX_ITEM_SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLBITMAP ), sal_True, &pPoolItem ) )
     {
         rXFSet.Put(XFillStyleItem(XFILL_BITMAP));
-        rXFSet.Put(XFillBitmapItem(String(), ((const XFillBitmapItem*)pPoolItem)->GetGraphicObject()));
+        rXFSet.Put(XFillBitmapItem(((const XFillBitmapItem*)pPoolItem)->GetGraphicObject()));
     }
     else
         rXFSet.Put( XFillStyleItem( XFILL_NONE ) );
diff --git a/cui/source/tabpages/tpbitmap.cxx b/cui/source/tabpages/tpbitmap.cxx
index 160af95..833330b 100644
--- a/cui/source/tabpages/tpbitmap.cxx
+++ b/cui/source/tabpages/tpbitmap.cxx
@@ -241,9 +241,7 @@ sal_Bool SvxBitmapTabPage::FillItemSet( SfxItemSet& _rOutAttrs )
             }
             else
             {
-                const BitmapEx aBitmapEx(m_pBitmapCtl->GetBitmapEx());
-
-                _rOutAttrs.Put(XFillBitmapItem(String(), Graphic(aBitmapEx)));
+                _rOutAttrs.Put(XFillBitmapItem(m_pBitmapCtl->GetBitmapEx());
             }
         }
     }
@@ -263,7 +261,7 @@ void SvxBitmapTabPage::Reset( const SfxItemSet&  )
     m_pBitmapCtl->SetBmpArray( m_pCtlPixel->GetBitmapPixelPtr() );
 
     // get bitmap and display it
-    const XFillBitmapItem aBmpItem(OUString(), Graphic(m_pBitmapCtl->GetBitmapEx()));
+    const XFillBitmapItem aBmpItem(m_pBitmapCtl->GetBitmapEx());
     rXFSet.Put( aBmpItem );
     m_pCtlPreview->SetAttributes( aXFillAttr.GetItemSet() );
     m_pCtlPreview->Invalidate();
@@ -390,7 +388,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ChangeBitmapHdl_Impl)
         m_pCtlPixel->Invalidate();
 
         // display bitmap
-        const XFillBitmapItem aXBmpItem(String(), *pGraphicObject);
+        const XFillBitmapItem aXBmpItem(*pGraphicObject);
         rXFSet.Put( aXBmpItem );
 
         m_pCtlPreview->SetAttributes( aXFillAttr.GetItemSet() );
@@ -907,7 +905,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ChangePixelColorHdl_Impl)
     m_pBitmapCtl->SetPixelColor( m_pLbColor->GetSelectEntryColor() );
 
     // get bitmap and display it
-    rXFSet.Put(XFillBitmapItem(String(), Graphic(m_pBitmapCtl->GetBitmapEx())));
+    rXFSet.Put(XFillBitmapItem(m_pBitmapCtl->GetBitmapEx()));
     m_pCtlPreview->SetAttributes( aXFillAttr.GetItemSet() );
     m_pCtlPreview->Invalidate();
 
@@ -926,7 +924,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ChangeBackgrndColorHdl_Impl)
     m_pBitmapCtl->SetBackgroundColor( m_pLbBackgroundColor->GetSelectEntryColor() );
 
     // get bitmap and display it
-    rXFSet.Put(XFillBitmapItem(String(), Graphic(m_pBitmapCtl->GetBitmapEx())));
+    rXFSet.Put(XFillBitmapItem(m_pBitmapCtl->GetBitmapEx()));
     m_pCtlPreview->SetAttributes( aXFillAttr.GetItemSet() );
     m_pCtlPreview->Invalidate();
 
@@ -944,7 +942,7 @@ void SvxBitmapTabPage::PointChanged( Window* pWindow, RECT_POINT )
         m_pBitmapCtl->SetBmpArray( m_pCtlPixel->GetBitmapPixelPtr() );
 
         // get bitmap and display it
-        rXFSet.Put(XFillBitmapItem(String(), Graphic(m_pBitmapCtl->GetBitmapEx())));
+        rXFSet.Put(XFillBitmapItem(m_pBitmapCtl->GetBitmapEx()));
         m_pCtlPreview->SetAttributes( aXFillAttr.GetItemSet() );
         m_pCtlPreview->Invalidate();
 
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 64ae2d9..6110458 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -1234,7 +1234,7 @@ void ApplyRectangularGradientAsBitmap( const SvxMSDffManager& rManager, SvStream
             }
 
             rSet.Put(XFillBmpTileItem(false));
-            rSet.Put(XFillBitmapItem(OUString(), GraphicObject::Create(Graphic(aBitmap))));
+            rSet.Put(XFillBitmapItem(Graphic(aBitmap)));
         }
     }
 }
@@ -1356,19 +1356,19 @@ void DffPropertyReader::ApplyFillAttributes( SvStream& rIn, SfxItemSet& rSet, co
                             aGraf = Graphic( aXOBitmap.GetBitmap()  );
                         }
 
-                        rSet.Put(XFillBitmapItem(OUString(), GraphicObject::Create(aGraf)));
+                        rSet.Put(XFillBitmapItem(aGraf));
                     }
                     else if ( eMSO_FillType == mso_fillTexture )
                     {
                         rSet.Put(XFillBmpTileItem(true));
-                        rSet.Put(XFillBitmapItem(OUString(), GraphicObject::Create(aGraf)));
+                        rSet.Put(XFillBitmapItem(aGraf));
                         rSet.Put(XFillBmpSizeXItem(GetPropertyValue(DFF_Prop_fillWidth, 0) / 360));
                         rSet.Put(XFillBmpSizeYItem(GetPropertyValue(DFF_Prop_fillHeight, 0) / 360));
                         rSet.Put(XFillBmpSizeLogItem(true));
                     }
                     else
                     {
-                        rSet.Put(XFillBitmapItem(OUString(), aGraf));
+                        rSet.Put(XFillBitmapItem(aGraf));
                         rSet.Put(XFillBmpTileItem(false));
                     }
                 }
diff --git a/include/svtools/grfmgr.hxx b/include/svtools/grfmgr.hxx
index dd43f33..6261f51 100644
--- a/include/svtools/grfmgr.hxx
+++ b/include/svtools/grfmgr.hxx
@@ -173,12 +173,12 @@ public:
     OUString SAL_CALL getUniqueID() throw (css::uno::RuntimeException);
 
 private:
-    explicit GraphicObject( const GraphicManager* pMgr = NULL );
-    GraphicObject( const Graphic& rGraphic, const GraphicManager* pMgr );
-    GraphicObject( const GraphicObject& rCacheObj, const GraphicManager* pMgr );
+    explicit GraphicObject();
+    GraphicObject( const Graphic& rGraphic );
+    GraphicObject( const GraphicObject& rCacheObj );
     GraphicObject& operator=( const GraphicObject& rCacheObj );
 
-    explicit GraphicObject( const OString& rUniqueID, const GraphicManager* pMgr );
+    explicit GraphicObject( const OString& rUniqueID );
 
 public: // only for internal access:
     GraphicObject( css::uno::Sequence< css::uno::Any > const & args,
@@ -186,28 +186,28 @@ public: // only for internal access:
         throw( css::uno::RuntimeException );
     virtual ~GraphicObject();
 
-    static rtl::Reference< GraphicObject > Create( const GraphicManager* pMgr = NULL )
+    static rtl::Reference< GraphicObject > Create()
     {
-        return rtl::Reference< GraphicObject >( new GraphicObject( pMgr ) );
+        return rtl::Reference< GraphicObject >( new GraphicObject() );
     }
-    static rtl::Reference< GraphicObject > Create( const Graphic& rGraphic, const GraphicManager* pMgr = NULL )
+    static rtl::Reference< GraphicObject > Create( const Graphic& rGraphic )
     {
-        return rtl::Reference< GraphicObject >( new GraphicObject( rGraphic, pMgr ) );
+        return rtl::Reference< GraphicObject >( new GraphicObject( rGraphic ) );
     }
-    static rtl::Reference< GraphicObject > Create( const GraphicObject& rCacheObj, const GraphicManager* pMgr = NULL )
+    static rtl::Reference< GraphicObject > Create( const GraphicObject& rCacheObj )
     {
-        return rtl::Reference< GraphicObject >( new GraphicObject( rCacheObj, pMgr ) );
+        return rtl::Reference< GraphicObject >( new GraphicObject( rCacheObj ) );
     }
-    static rtl::Reference< GraphicObject > Create( const rtl::Reference< GraphicObject > &xCacheObj, const GraphicManager* pMgr = NULL )
+    static rtl::Reference< GraphicObject > Create( const rtl::Reference< GraphicObject > &xCacheObj )
     {
         if( xCacheObj.is() )
-            return rtl::Reference< GraphicObject >( new GraphicObject( *xCacheObj.get(), pMgr ) );
+            return rtl::Reference< GraphicObject >( new GraphicObject( *xCacheObj.get() ) );
         else
             return rtl::Reference< GraphicObject >();
     }
-    static rtl::Reference< GraphicObject > Create( const OString& rUniqueID, const GraphicManager* pMgr = NULL )
+    static rtl::Reference< GraphicObject > Create( const OString& rUniqueID )
     {
-        return rtl::Reference< GraphicObject >( new GraphicObject( rUniqueID, pMgr ) );
+        return rtl::Reference< GraphicObject >( new GraphicObject( rUniqueID ) );
     }
 
 private:
@@ -237,10 +237,9 @@ private:
     void                    SVT_DLLPRIVATE ImplConstruct();
     void                    SVT_DLLPRIVATE ImplAssignGraphicData();
     void                    SVT_DLLPRIVATE ImplSetGraphicManager(
-                                const GraphicManager* pMgr,
                                 const OString* pID = NULL,
                                 const rtl::Reference< GraphicObject > &xCopyObj =
-                                    rtl::Reference< GraphicObject > () );
+                                    rtl::Reference< GraphicObject > ()
                             );
     void                    SVT_DLLPRIVATE ImplAutoSwapIn();
     sal_Bool                SVT_DLLPRIVATE ImplIsAutoSwapped() const { return mbAutoSwapped; }
@@ -550,7 +549,7 @@ public:
         double fBottomCrop) const;
 };
 
-typedef ::std::vector< GraphicObject* > GraphicObjectList_impl;
+typedef ::std::vector< rtl::Reference< GraphicObject > > GraphicObjectList_impl;
 
 class SVT_DLLPUBLIC GraphicManager
 {
@@ -558,6 +557,8 @@ class SVT_DLLPUBLIC GraphicManager
     friend class GraphicDisplayCacheEntry;
 
 private:
+    /// GraphicManager is a singleton
+    static GraphicManager  *pGlobalManager;
 
     GraphicObjectList_impl  maObjList;
     GraphicCache*           mpCache;
@@ -569,7 +570,7 @@ private:
                             OutputDevice* pOut,
                             const Point& rPt,
                             const Size& rSz,
-                            GraphicObject& rObj,
+                            const rtl::Reference< GraphicObject> & xObj,
                             const GraphicAttr& rAttr,
                             const sal_uLong nFlags,
                             sal_Bool& rCached
@@ -621,28 +622,29 @@ private:
 
                     // Only used by GraphicObject's Ctor's and Dtor's
     void SVT_DLLPRIVATE ImplRegisterObj(
-                            const GraphicObject& rObj,
+                            const rtl::Reference< GraphicObject >& xObj,
                             Graphic& rSubstitute,
                             const OString* pID = NULL,
                             const rtl::Reference< GraphicObject > &xCopyObj =
                                 rtl::Reference< GraphicObject > ()
                         );
-    void SVT_DLLPRIVATE ImplUnregisterObj( const GraphicObject& rObj );
+    void SVT_DLLPRIVATE ImplUnregisterObj( const rtl::Reference< GraphicObject >& xObj );
     inline sal_Bool SVT_DLLPRIVATE ImplHasObjects() const { return !maObjList.empty(); }
 
                     // Only used in swap case by GraphicObject
-    void SVT_DLLPRIVATE ImplGraphicObjectWasSwappedOut( const GraphicObject& rObj );
+    void SVT_DLLPRIVATE ImplGraphicObjectWasSwappedOut( const rtl::Reference< GraphicObject > & xObj );
     sal_Bool SVT_DLLPRIVATE ImplFillSwappedGraphicObject(
-                            const GraphicObject& rObj,
+                            const rtl::Reference< GraphicObject >& xObj,
                             Graphic& rSubstitute
                         );
-    void SVT_DLLPRIVATE ImplGraphicObjectWasSwappedIn( const GraphicObject& rObj );
+    void SVT_DLLPRIVATE ImplGraphicObjectWasSwappedIn( const rtl::Reference< GraphicObject >& xObj );
 
-    OString SVT_DLLPRIVATE ImplGetUniqueID( const GraphicObject& rObj ) const;
+    OString SVT_DLLPRIVATE ImplGetUniqueID( const rtl::Reference< GraphicObject >& xObj ) const;
+
+                        GraphicManager( sal_uLong nCacheSize = 10000000UL, sal_uLong nMaxObjCacheSize = 2400000UL );
 
 public:
 
-                        GraphicManager( sal_uLong nCacheSize = 10000000UL, sal_uLong nMaxObjCacheSize = 2400000UL );
                         ~GraphicManager();
 
     void                SetMaxCacheSize( sal_uLong nNewCacheSize );
@@ -654,13 +656,13 @@ public:
 
     void                SetCacheTimeout( sal_uLong nTimeoutSeconds );
 
-    void                ReleaseFromCache( const GraphicObject& rObj );
+    void                ReleaseFromCache( const rtl::Reference< GraphicObject >& xObj );
 
     sal_Bool            IsInCache(
                             OutputDevice* pOut,
                             const Point& rPt,
                             const Size& rSz,
-                            const GraphicObject& rObj,
+                            const rtl::Reference< GraphicObject > & xObj,
                             const GraphicAttr& rAttr
                         ) const;
 
@@ -668,7 +670,7 @@ public:
                             OutputDevice* pOut,
                             const Point& rPt,
                             const Size& rSz,
-                            GraphicObject& rObj,
+                            rtl::Reference< GraphicObject >& xObj,
                             const GraphicAttr& rAttr,
                             const sal_uLong nFlags,
                             sal_Bool& rCached
diff --git a/include/svx/xbtmpit.hxx b/include/svx/xbtmpit.hxx
index a0e655e..5476393 100644
--- a/include/svx/xbtmpit.hxx
+++ b/include/svx/xbtmpit.hxx
@@ -44,7 +44,10 @@ private:
 public:
             TYPEINFO();
             XFillBitmapItem() : NameOrIndex(XATTR_FILLBITMAP, -1 ) { mxGraphicObject = GraphicObject::Create(); }
-            XFillBitmapItem(const String& rName, const rtl::Reference< GraphicObject > & xGraphicObject);
+            explicit XFillBitmapItem(const Graphic & rGraphic);
+            explicit XFillBitmapItem(const BitmapEx & rBitmapEx);
+            explicit XFillBitmapItem(const rtl::Reference< GraphicObject > & xGraphicObject);
+            XFillBitmapItem(const OUString & rName, const rtl::Reference< GraphicObject > & xGraphicObject);
             XFillBitmapItem(SfxItemPool* pPool, const rtl::Reference< GraphicObject > & xGraphicObject);
             XFillBitmapItem( const XFillBitmapItem& rItem );
             XFillBitmapItem( SvStream& rIn, sal_uInt16 nVer = 0 );
diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx
index adeb3d8..42de8f6 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -758,7 +758,7 @@ void XclImpDrawObjBase::ConvertFillStyle( SdrObject& rSdrObj, const XclObjFillDa
             aBitmap = aXOBitmap.GetBitmap();
 
             rSdrObj.SetMergedItem(XFillStyleItem(XFILL_BITMAP));
-            rSdrObj.SetMergedItem(XFillBitmapItem(EMPTY_STRING, Graphic(aBitmap)));
+            rSdrObj.SetMergedItem(XFillBitmapItem(Graphic(aBitmap)));
         }
     }
 }
diff --git a/sc/source/filter/oox/drawingmanager.cxx b/sc/source/filter/oox/drawingmanager.cxx
index 6311583..fc04314 100644
--- a/sc/source/filter/oox/drawingmanager.cxx
+++ b/sc/source/filter/oox/drawingmanager.cxx
@@ -455,7 +455,7 @@ void BiffDrawingObjectBase::convertFillProperties( ShapePropertyMap& rPropMap, c
         aXOBitmap.SetPixelColor( aPattColor );
         aXOBitmap.SetBackgroundColor( aBackColor );
         rSdrObj.SetMergedItem( XFillStyleItem( XFILL_BITMAP ) );
-        rSdrObj.SetMergedItem( XFillBitmapItem( EMPTY_STRING, aXOBitmap ) );
+        rSdrObj.SetMergedItem( XFillBitmapItem( aXOBitmap ) );
 #endif
     }
 
diff --git a/sc/source/ui/view/viewfun7.cxx b/sc/source/ui/view/viewfun7.cxx
index 8fa0e38..96250d8 100644
--- a/sc/source/ui/view/viewfun7.cxx
+++ b/sc/source/ui/view/viewfun7.cxx
@@ -456,7 +456,7 @@ sal_Bool ScViewFunc::ApplyGraphicToObject( SdrObject* pPickObj, const Graphic& r
             SfxItemSet aSet( pScDrawView->GetModel()->GetItemPool(),
                                 XATTR_FILLSTYLE, XATTR_FILLBITMAP );
             aSet.Put(XFillStyleItem(XFILL_BITMAP));
-            aSet.Put(XFillBitmapItem(String(), rGraphic));
+            aSet.Put(XFillBitmapItem(rGraphic));
 
             pPickObj->SetMergedItemSetAndBroadcast(aSet);
 
diff --git a/svtools/source/graphic/grfcache.cxx b/svtools/source/graphic/grfcache.cxx
index f0d4629..eda0e3a 100644
--- a/svtools/source/graphic/grfcache.cxx
+++ b/svtools/source/graphic/grfcache.cxx
@@ -47,7 +47,7 @@ private:
 public:
 
 
-                GraphicID( const GraphicObject& rObj );
+                GraphicID( const rtl::Reference< GraphicObject >& xObj );
                 ~GraphicID() {}
 
     sal_Bool        operator==( const GraphicID& rID ) const
@@ -60,9 +60,9 @@ public:
     sal_Bool        IsEmpty() const { return( 0 == mnID4 ); }
 };
 
-GraphicID::GraphicID( const GraphicObject& rObj )
+GraphicID::GraphicID( const rtl::Reference< GraphicObject >& xObj )
 {
-    const Graphic& rGraphic = rObj.GetGraphic();
+    const Graphic& rGraphic = xObj->GetGraphic();
 
     mnID1 = ( (sal_uLong) rGraphic.GetType() ) << 28;
 
@@ -155,37 +155,37 @@ private:
     // SvgData support
     SvgDataPtr          maSvgData;
 
-    bool                ImplInit( const GraphicObject& rObj );
-    bool                ImplMatches( const GraphicObject& rObj ) const { return( GraphicID( rObj ) == maID ); }
+    bool                ImplInit( const rtl::Reference< GraphicObject >& xObj );
+    bool                ImplMatches( const rtl::Reference< GraphicObject >& xObj ) const { return( GraphicID( xObj ) == maID ); }
     void                ImplFillSubstitute( Graphic& rSubstitute );
 
 public:
 
-                        GraphicCacheEntry( const GraphicObject& rObj );
+                        GraphicCacheEntry( const rtl::Reference< GraphicObject >& xObj );
                         ~GraphicCacheEntry();
 
     const GraphicID&    GetID() const { return maID; }
 
-    void                AddGraphicObjectReference( const GraphicObject& rObj, Graphic& rSubstitute );
-    bool                ReleaseGraphicObjectReference( const GraphicObject& rObj );
+    void                AddGraphicObjectReference( const rtl::Reference< GraphicObject >& xObj, Graphic& rSubstitute );
+    bool                ReleaseGraphicObjectReference( const rtl::Reference< GraphicObject >& xObj );
     size_t              GetGraphicObjectReferenceCount() { return maGraphicObjectList.size(); }
-    bool                HasGraphicObjectReference( const GraphicObject& rObj );
+    bool                HasGraphicObjectReference( const rtl::Reference< GraphicObject >& xObj );
 
     void                TryToSwapIn();
-    void                GraphicObjectWasSwappedOut( const GraphicObject& rObj );
-    bool                FillSwappedGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute );
-    void                GraphicObjectWasSwappedIn( const GraphicObject& rObj );
+    void                GraphicObjectWasSwappedOut( const rtl::Reference< GraphicObject >& xObj );
+    bool                FillSwappedGraphicObject( const rtl::Reference< GraphicObject >& xObj, Graphic& rSubstitute );
+    void                GraphicObjectWasSwappedIn( const rtl::Reference< GraphicObject >& xObj );
 };
 
-GraphicCacheEntry::GraphicCacheEntry( const GraphicObject& rObj ) :
-    maID            ( rObj ),
+GraphicCacheEntry::GraphicCacheEntry( const rtl::Reference< GraphicObject >& xObj ) :
+    maID            ( xObj ),
     mpBmpEx         ( NULL ),
     mpMtf           ( NULL ),
     mpAnimation     ( NULL ),
     mbSwappedAll    ( true )
 {
-    mbSwappedAll = !ImplInit( rObj );
-    maGraphicObjectList.push_back( (GraphicObject*)&rObj );
+    mbSwappedAll = !ImplInit( xObj );
+    maGraphicObjectList.push_back( (GraphicObject*)&xObj );
 }
 
 GraphicCacheEntry::~GraphicCacheEntry()
@@ -200,13 +200,13 @@ GraphicCacheEntry::~GraphicCacheEntry()
     delete mpAnimation;
 }
 
-bool GraphicCacheEntry::ImplInit( const GraphicObject& rObj )
+bool GraphicCacheEntry::ImplInit( const rtl::Reference< GraphicObject >& xObj )
 {
     bool bRet = false;
 
-    if( !rObj.IsSwappedOut() )
+    if( !xObj->IsSwappedOut() )
     {
-        const Graphic& rGraphic = rObj.GetGraphic();
+        const Graphic& rGraphic = xObj->GetGraphic();
 
         if( mpBmpEx )
             delete mpBmpEx, mpBmpEx = NULL;
@@ -312,23 +312,20 @@ void GraphicCacheEntry::ImplFillSubstitute( Graphic& rSubstitute )
     }
 }
 
-void GraphicCacheEntry::AddGraphicObjectReference( const GraphicObject& rObj, Graphic& rSubstitute )
+void GraphicCacheEntry::AddGraphicObjectReference( const rtl::Reference< GraphicObject >& xObj, Graphic& rSubstitute )
 {
     if( mbSwappedAll )
-        mbSwappedAll = !ImplInit( rObj );
+        mbSwappedAll = !ImplInit( xObj );
 
     ImplFillSubstitute( rSubstitute );
-    maGraphicObjectList.push_back( (GraphicObject*) &rObj );
+    maGraphicObjectList.push_back( (GraphicObject*) &xObj );
 }
 
-bool GraphicCacheEntry::ReleaseGraphicObjectReference( const GraphicObject& rObj )
+bool GraphicCacheEntry::ReleaseGraphicObjectReference( const rtl::Reference< GraphicObject >& xObj )
 {
-    for(
-        GraphicObjectList_impl::iterator it = maGraphicObjectList.begin();
-        it != maGraphicObjectList.end();
-        ++it
-    ) {
-        if( &rObj == *it )
+    for( GraphicObjectList_impl::iterator it = maGraphicObjectList.begin();
+         it != maGraphicObjectList.end(); ++it ) {
+        if( *xObj.get() == *it->get() )
         {
             maGraphicObjectList.erase( it );
             return true;
@@ -338,12 +335,12 @@ bool GraphicCacheEntry::ReleaseGraphicObjectReference( const GraphicObject& rObj
     return false;
 }
 
-bool GraphicCacheEntry::HasGraphicObjectReference( const GraphicObject& rObj )
+bool GraphicCacheEntry::HasGraphicObjectReference( const rtl::Reference< GraphicObject >& xObj )
 {
     bool bRet = false;
 
     for( size_t i = 0, n = maGraphicObjectList.size(); ( i < n ) && !bRet; ++i )
-        if( &rObj == maGraphicObjectList[ i ] )
+        if( xObj == maGraphicObjectList[ i ] )
             bRet = true;
 
     return bRet;
@@ -355,7 +352,7 @@ void GraphicCacheEntry::TryToSwapIn()
         maGraphicObjectList.front()->FireSwapInRequest();
 }
 
-void GraphicCacheEntry::GraphicObjectWasSwappedOut( const GraphicObject& /*rObj*/ )
+void GraphicCacheEntry::GraphicObjectWasSwappedOut( const rtl::Reference< GraphicObject >& /*xObj*/ )
 {
     mbSwappedAll = true;
 
@@ -374,11 +371,11 @@ void GraphicCacheEntry::GraphicObjectWasSwappedOut( const GraphicObject& /*rObj*
     }
 }
 
-bool GraphicCacheEntry::FillSwappedGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute )
+bool GraphicCacheEntry::FillSwappedGraphicObject( const rtl::Reference< GraphicObject >& xObj, Graphic& rSubstitute )
 {
     bool bRet = false;
 
-    if( !mbSwappedAll && rObj.IsSwappedOut() )
+    if( !mbSwappedAll && xObj->IsSwappedOut() )
     {
         ImplFillSubstitute( rSubstitute );
         bRet = true;
@@ -387,10 +384,10 @@ bool GraphicCacheEntry::FillSwappedGraphicObject( const GraphicObject& rObj, Gra
     return bRet;
 }
 
-void GraphicCacheEntry::GraphicObjectWasSwappedIn( const GraphicObject& rObj )
+void GraphicCacheEntry::GraphicObjectWasSwappedIn( const rtl::Reference< GraphicObject >& xObj )
 {
     if( mbSwappedAll )
-        mbSwappedAll = !ImplInit( rObj );
+        mbSwappedAll = !ImplInit( xObj );
 }
 
 class GraphicDisplayCacheEntry
@@ -412,18 +409,18 @@ private:
 public:
 
     static sal_uLong                GetNeededSize( OutputDevice* pOut, const Point& rPt, const Size& rSz,
-                                               const GraphicObject& rObj, const GraphicAttr& rAttr );
+                                               const rtl::Reference< GraphicObject >& xObj, const GraphicAttr& rAttr );
 
 public:
 
                                 GraphicDisplayCacheEntry( const GraphicCacheEntry* pRefCacheEntry,
                                                           OutputDevice* pOut, const Point& rPt, const Size& rSz,
-                                                          const GraphicObject& rObj, const GraphicAttr& rAttr,
+                                                          const rtl::Reference< GraphicObject >& xObj, const GraphicAttr& rAttr,
                                                           const BitmapEx& rBmpEx ) :
                                     mpRefCacheEntry( pRefCacheEntry ),
                                     mpMtf( NULL ), mpBmpEx( new BitmapEx( rBmpEx ) ),
                                     maAttr( rAttr ), maOutSizePix( pOut->LogicToPixel( rSz ) ),
-                                    mnCacheSize( GetNeededSize( pOut, rPt, rSz, rObj, rAttr ) ),
+                                    mnCacheSize( GetNeededSize( pOut, rPt, rSz, xObj, rAttr ) ),
                                     mnOutDevDrawMode( pOut->GetDrawMode() ),
                                     mnOutDevBitCount( pOut->GetBitCount() )
                                     {
@@ -431,12 +428,12 @@ public:
 
                                 GraphicDisplayCacheEntry( const GraphicCacheEntry* pRefCacheEntry,
                                                           OutputDevice* pOut, const Point& rPt, const Size& rSz,
-                                                          const GraphicObject& rObj, const GraphicAttr& rAttr,
+                                                          const rtl::Reference< GraphicObject >& xObj, const GraphicAttr& rAttr,
                                                           const GDIMetaFile& rMtf ) :
                                     mpRefCacheEntry( pRefCacheEntry ),
                                     mpMtf( new GDIMetaFile( rMtf ) ), mpBmpEx( NULL ),
                                     maAttr( rAttr ), maOutSizePix( pOut->LogicToPixel( rSz ) ),
-                                    mnCacheSize( GetNeededSize( pOut, rPt, rSz, rObj, rAttr ) ),
+                                    mnCacheSize( GetNeededSize( pOut, rPt, rSz, xObj, rAttr ) ),
                                     mnOutDevDrawMode( pOut->GetDrawMode() ),
                                     mnOutDevBitCount( pOut->GetBitCount() )
                                     {
@@ -758,9 +755,9 @@ bool GraphicDisplayCacheEntry::IsCacheableAsBitmap( const GDIMetaFile& rMtf,
 }
 
 sal_uLong GraphicDisplayCacheEntry::GetNeededSize( OutputDevice* pOut, const Point& /*rPt*/, const Size& rSz,
-                                               const GraphicObject& rObj, const GraphicAttr& rAttr )
+                                               const rtl::Reference< GraphicObject >& xObj, const GraphicAttr& rAttr )
 {
-    const Graphic&      rGraphic = rObj.GetGraphic();
+    const Graphic&      rGraphic = xObj->GetGraphic();
     const GraphicType   eType = rGraphic.GetType();
 
     bool canCacheAsBitmap = false;
@@ -783,7 +780,7 @@ sal_uLong GraphicDisplayCacheEntry::GetNeededSize( OutputDevice* pOut, const Poi
         else if( nBitCount )
         {
             sal_uLong nNeededSize = aOutSizePix.Width() * aOutSizePix.Height() * nBitCount / 8;
-            if( rObj.IsTransparent() || ( rAttr.GetRotation() % 3600 ) )
+            if( xObj->IsTransparent() || ( rAttr.GetRotation() % 3600 ) )
                 nNeededSize += nNeededSize / nBitCount;
             return nNeededSize;
         }
@@ -843,20 +840,22 @@ GraphicCache::~GraphicCache()
 }
 
 void GraphicCache::AddGraphicObject(
-    const GraphicObject& rObj,
+    const rtl::Reference< GraphicObject >& xObj,
     Graphic& rSubstitute,
     const OString* pID,
-    const GraphicObject* pCopyObj
+    const rtl::Reference< GraphicObject >* pCopyObj
 )
 {
+#error mis-handling of pCopyObj
+
     sal_Bool bInserted = sal_False;
 
-    if(  !rObj.IsSwappedOut()
+    if(  !xObj->IsSwappedOut()
       && (  pID
          || (    pCopyObj
             && ( pCopyObj->GetType() != GRAPHIC_NONE )
             )
-         || ( rObj.GetType() != GRAPHIC_NONE )
+         || ( xObj->GetType() != GRAPHIC_NONE )
          )
       )
     {
@@ -871,7 +870,7 @@ void GraphicCache::AddGraphicObject(
             {
                 if( (*it)->HasGraphicObjectReference( *pCopyObj ) )
                 {
-                    (*it)->AddGraphicObjectReference( rObj, rSubstitute );
+                    (*it)->AddGraphicObjectReference( xObj, rSubstitute );
                     bInserted = sal_True;
                 }
                 else
@@ -888,7 +887,7 @@ void GraphicCache::AddGraphicObject(
 
             if( !pID )
             {
-                apID.reset( new GraphicID( rObj ) );
+                apID.reset( new GraphicID( xObj ) );
             }
 
             while(  !bInserted
@@ -915,14 +914,14 @@ void GraphicCache::AddGraphicObject(
 
                             if( rID.GetIDString() == *pID )
                             {
-                                (*jt)->AddGraphicObjectReference( rObj, rSubstitute );
+                                (*jt)->AddGraphicObjectReference( xObj, rSubstitute );
                                 bInserted = sal_True;
                             }
                         }
 
                         if( !bInserted )
                         {
-                            maGraphicCache.push_back( new GraphicCacheEntry( rObj ) );
+                            maGraphicCache.push_back( new GraphicCacheEntry( xObj ) );
                             bInserted = sal_True;
                         }
                     }
@@ -931,7 +930,7 @@ void GraphicCache::AddGraphicObject(
                 {
                     if( rEntryID == *apID )
                     {
-                        (*it)->AddGraphicObjectReference( rObj, rSubstitute );
+                        (*it)->AddGraphicObjectReference( xObj, rSubstitute );
                         bInserted = sal_True;
                     }
                 }
@@ -943,17 +942,17 @@ void GraphicCache::AddGraphicObject(
     }
 
     if( !bInserted )
-        maGraphicCache.push_back( new GraphicCacheEntry( rObj ) );
+        maGraphicCache.push_back( new GraphicCacheEntry( xObj ) );
 }
 
-void GraphicCache::ReleaseGraphicObject( const GraphicObject& rObj )
+void GraphicCache::ReleaseGraphicObject( const rtl::Reference< GraphicObject >& xObj )
 {
     // Release cached object
     bool    bRemoved = false;
     GraphicCacheEntryList::iterator it = maGraphicCache.begin();
     while (!bRemoved && it != maGraphicCache.end())
     {
-        bRemoved = (*it)->ReleaseGraphicObjectReference( rObj );
+        bRemoved = (*it)->ReleaseGraphicObjectReference( xObj );
 
         if( bRemoved )
         {
@@ -987,39 +986,39 @@ void GraphicCache::ReleaseGraphicObject( const GraphicObject& rObj )
     DBG_ASSERT( bRemoved, "GraphicCache::ReleaseGraphicObject(...): GraphicObject not found in cache" );
 }
 
-void GraphicCache::GraphicObjectWasSwappedOut( const GraphicObject& rObj )
+void GraphicCache::GraphicObjectWasSwappedOut( const rtl::Reference< GraphicObject >& xObj )
 {
-    // notify cache that rObj is swapped out (and can thus be pruned
+    // notify cache that xObj is swapped out (and can thus be pruned
     // from the cache)
-    GraphicCacheEntry* pEntry = ImplGetCacheEntry( rObj );
+    GraphicCacheEntry* pEntry = ImplGetCacheEntry( xObj );
 
     if( pEntry )
-        pEntry->GraphicObjectWasSwappedOut( rObj );
+        pEntry->GraphicObjectWasSwappedOut( xObj );
 }
 
-sal_Bool GraphicCache::FillSwappedGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute )
+sal_Bool GraphicCache::FillSwappedGraphicObject( const rtl::Reference< GraphicObject >& xObj, Graphic& rSubstitute )
 {
-    GraphicCacheEntry* pEntry = ImplGetCacheEntry( rObj );
+    GraphicCacheEntry* pEntry = ImplGetCacheEntry( xObj );
 
     if( !pEntry )
         return sal_False;
 
-    return pEntry->FillSwappedGraphicObject( rObj, rSubstitute );
+    return pEntry->FillSwappedGraphicObject( xObj, rSubstitute );
 }
 
-void GraphicCache::GraphicObjectWasSwappedIn( const GraphicObject& rObj )
+void GraphicCache::GraphicObjectWasSwappedIn( const rtl::Reference< GraphicObject >& xObj )
 {
-    GraphicCacheEntry* pEntry = ImplGetCacheEntry( rObj );
+    GraphicCacheEntry* pEntry = ImplGetCacheEntry( xObj );
 
     if( pEntry )
     {
         if( pEntry->GetID().IsEmpty() )
         {
-            ReleaseGraphicObject( rObj );
-            AddGraphicObject( rObj, (Graphic&) rObj.GetGraphic(), NULL, NULL );
+            ReleaseGraphicObject( xObj );
+            AddGraphicObject( xObj, (Graphic&) xObj->GetGraphic(), NULL, NULL );
         }
         else
-            pEntry->GraphicObjectWasSwappedIn( rObj );
+            pEntry->GraphicObjectWasSwappedIn( xObj );
     }
 }
 
@@ -1076,18 +1075,18 @@ void GraphicCache::SetCacheTimeout( sal_uLong nTimeoutSeconds )
 }
 
 sal_Bool GraphicCache::IsDisplayCacheable( OutputDevice* pOut, const Point& rPt, const Size& rSz,
-                                       const GraphicObject& rObj, const GraphicAttr& rAttr ) const
+                                       const rtl::Reference< GraphicObject >& xObj, const GraphicAttr& rAttr ) const
 {
-    return( GraphicDisplayCacheEntry::GetNeededSize( pOut, rPt, rSz, rObj, rAttr ) <=
+    return( GraphicDisplayCacheEntry::GetNeededSize( pOut, rPt, rSz, xObj, rAttr ) <=
             GetMaxObjDisplayCacheSize() );
 }
 
 sal_Bool GraphicCache::IsInDisplayCache( OutputDevice* pOut, const Point& rPt, const Size& rSz,
-                                     const GraphicObject& rObj, const GraphicAttr& rAttr ) const
+                                     const rtl::Reference< GraphicObject >& xObj, const GraphicAttr& rAttr ) const
 {
     const Point                 aPtPixel( pOut->LogicToPixel( rPt ) );
     const Size                  aSzPixel( pOut->LogicToPixel( rSz ) );
-    const GraphicCacheEntry*    pCacheEntry = ( (GraphicCache*) this )->ImplGetCacheEntry( rObj );
+    const GraphicCacheEntry*    pCacheEntry = ( (GraphicCache*) this )->ImplGetCacheEntry( xObj );
     sal_Bool                        bFound = sal_False;
 
     if( pCacheEntry )
@@ -1103,17 +1102,17 @@ sal_Bool GraphicCache::IsInDisplayCache( OutputDevice* pOut, const Point& rPt, c
     return bFound;
 }
 
-OString GraphicCache::GetUniqueID( const GraphicObject& rObj ) const
+OString GraphicCache::GetUniqueID( const rtl::Reference< GraphicObject >& xObj ) const
 {
     OString aRet;
-    GraphicCacheEntry*  pEntry = ( (GraphicCache*) this )->ImplGetCacheEntry( rObj );
+    GraphicCacheEntry*  pEntry = ( (GraphicCache*) this )->ImplGetCacheEntry( xObj );
 
     // ensure that the entry is correctly initialized (it has to be read at least once)
     if( pEntry && pEntry->GetID().IsEmpty() )
         pEntry->TryToSwapIn();
 
     // do another call to ImplGetCacheEntry in case of modified entry list
-    pEntry = ( (GraphicCache*) this )->ImplGetCacheEntry( rObj );
+    pEntry = ( (GraphicCache*) this )->ImplGetCacheEntry( xObj );
 
     if( pEntry )
         aRet = pEntry->GetID().GetIDString();
@@ -1122,10 +1121,10 @@ OString GraphicCache::GetUniqueID( const GraphicObject& rObj ) const
 }
 
 sal_Bool GraphicCache::CreateDisplayCacheObj( OutputDevice* pOut, const Point& rPt, const Size& rSz,
-                                          const GraphicObject& rObj, const GraphicAttr& rAttr,
+                                          const rtl::Reference< GraphicObject >& xObj, const GraphicAttr& rAttr,
                                           const BitmapEx& rBmpEx )
 {
-    const sal_uLong nNeededSize = GraphicDisplayCacheEntry::GetNeededSize( pOut, rPt, rSz, rObj, rAttr );
+    const sal_uLong nNeededSize = GraphicDisplayCacheEntry::GetNeededSize( pOut, rPt, rSz, xObj, rAttr );
     sal_Bool        bRet = sal_False;
 
     if( nNeededSize <= GetMaxObjDisplayCacheSize() )
@@ -1133,8 +1132,8 @@ sal_Bool GraphicCache::CreateDisplayCacheObj( OutputDevice* pOut, const Point& r
         if( nNeededSize > GetFreeDisplayCacheSize() )
             ImplFreeDisplayCacheSpace( nNeededSize - GetFreeDisplayCacheSize() );
 
-        GraphicDisplayCacheEntry* pNewEntry = new GraphicDisplayCacheEntry( ImplGetCacheEntry( rObj ),
-                                                                            pOut, rPt, rSz, rObj, rAttr, rBmpEx );
+        GraphicDisplayCacheEntry* pNewEntry = new GraphicDisplayCacheEntry( ImplGetCacheEntry( xObj ),
+                                                                            pOut, rPt, rSz, xObj, rAttr, rBmpEx );
 
         if( GetCacheTimeout() )
         {
@@ -1154,10 +1153,10 @@ sal_Bool GraphicCache::CreateDisplayCacheObj( OutputDevice* pOut, const Point& r
 }
 
 sal_Bool GraphicCache::CreateDisplayCacheObj( OutputDevice* pOut, const Point& rPt, const Size& rSz,
-                                          const GraphicObject& rObj, const GraphicAttr& rAttr,
+                                          const rtl::Reference< GraphicObject >& xObj, const GraphicAttr& rAttr,
                                           const GDIMetaFile& rMtf )
 {
-    const sal_uLong nNeededSize = GraphicDisplayCacheEntry::GetNeededSize( pOut, rPt, rSz, rObj, rAttr );
+    const sal_uLong nNeededSize = GraphicDisplayCacheEntry::GetNeededSize( pOut, rPt, rSz, xObj, rAttr );
     sal_Bool        bRet = sal_False;
 
     if( nNeededSize <= GetMaxObjDisplayCacheSize() )
@@ -1165,8 +1164,8 @@ sal_Bool GraphicCache::CreateDisplayCacheObj( OutputDevice* pOut, const Point& r
         if( nNeededSize > GetFreeDisplayCacheSize() )
             ImplFreeDisplayCacheSpace( nNeededSize - GetFreeDisplayCacheSize() );
 
-        GraphicDisplayCacheEntry* pNewEntry = new GraphicDisplayCacheEntry( ImplGetCacheEntry( rObj ),
-                                                                            pOut, rPt, rSz, rObj, rAttr, rMtf );
+        GraphicDisplayCacheEntry* pNewEntry = new GraphicDisplayCacheEntry( ImplGetCacheEntry( xObj ),
+                                                                            pOut, rPt, rSz, xObj, rAttr, rMtf );
 
         if( GetCacheTimeout() )
         {
@@ -1186,11 +1185,11 @@ sal_Bool GraphicCache::CreateDisplayCacheObj( OutputDevice* pOut, const Point& r
 }
 
 sal_Bool GraphicCache::DrawDisplayCacheObj( OutputDevice* pOut, const Point& rPt, const Size& rSz,
-                                        const GraphicObject& rObj, const GraphicAttr& rAttr )
+                                        const rtl::Reference< GraphicObject >& xObj, const GraphicAttr& rAttr )
 {
     const Point                 aPtPixel( pOut->LogicToPixel( rPt ) );
     const Size                  aSzPixel( pOut->LogicToPixel( rSz ) );
-    const GraphicCacheEntry*    pCacheEntry = ImplGetCacheEntry( rObj );
+    const GraphicCacheEntry*    pCacheEntry = ImplGetCacheEntry( xObj );
     GraphicDisplayCacheEntry*   pDisplayCacheEntry = NULL;
     GraphicDisplayCacheEntryList::iterator it = maDisplayCache.begin();
     sal_Bool                    bRet = sal_False;
@@ -1253,7 +1252,7 @@ sal_Bool GraphicCache::ImplFreeDisplayCacheSpace( sal_uLong nSizeToFree )
     return( nFreedSize >= nSizeToFree );
 }
 
-GraphicCacheEntry* GraphicCache::ImplGetCacheEntry( const GraphicObject& rObj )
+GraphicCacheEntry* GraphicCache::ImplGetCacheEntry( const rtl::Reference< GraphicObject >& xObj )
 {
     GraphicCacheEntry* pRet = NULL;
 
@@ -1262,7 +1261,7 @@ GraphicCacheEntry* GraphicCache::ImplGetCacheEntry( const GraphicObject& rObj )
         !pRet && it != maGraphicCache.end();
         ++it
     ) {
-        if( (*it)->HasGraphicObjectReference( rObj ) ) {
+        if( (*it)->HasGraphicObjectReference( xObj ) ) {
             pRet = *it;
         }
     }
diff --git a/svtools/source/graphic/grfcache.hxx b/svtools/source/graphic/grfcache.hxx
index ac54287..1866628 100644
--- a/svtools/source/graphic/grfcache.hxx
+++ b/svtools/source/graphic/grfcache.hxx
@@ -20,6 +20,7 @@
 #ifndef _GRFCACHE_HXX
 #define _GRFCACHE_HXX
 
+#include <rtl/ref.hxx>
 #include <vcl/graph.hxx>
 #include <vcl/timer.hxx>
 #include <list>
@@ -48,7 +49,7 @@ private:
     sal_uLong               mnUsedDisplaySize;
 
     sal_Bool                ImplFreeDisplayCacheSpace( sal_uLong nSizeToFree );
-    GraphicCacheEntry*      ImplGetCacheEntry( const GraphicObject& rObj );
+    GraphicCacheEntry*      ImplGetCacheEntry( const rtl::Reference< GraphicObject >& xObj );
 
 
                             DECL_LINK( ReleaseTimeoutHdl, Timer* pTimer );
@@ -65,19 +66,19 @@ public:
 public:
 
     void                    AddGraphicObject(
-                                const GraphicObject& rObj,
+                                const rtl::Reference< GraphicObject >& rObj,
                                 Graphic& rSubstitute,
                                 const OString* pID,
-                                const GraphicObject* pCopyObj
+                                const rtl::Reference< GraphicObject >* pCopyObj
                             );
 
-    void                    ReleaseGraphicObject( const GraphicObject& rObj );
+    void                    ReleaseGraphicObject( const rtl::Reference< GraphicObject >& rObj );
 
-    void                    GraphicObjectWasSwappedOut( const GraphicObject& rObj );
-    sal_Bool                FillSwappedGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute );
-    void                    GraphicObjectWasSwappedIn( const GraphicObject& rObj );
+    void                    GraphicObjectWasSwappedOut( const rtl::Reference< GraphicObject >& rObj );
+    sal_Bool                FillSwappedGraphicObject( const rtl::Reference< GraphicObject >& rObj, Graphic& rSubstitute );
+    void                    GraphicObjectWasSwappedIn( const rtl::Reference< GraphicObject >& rObj );
 
-    OString            GetUniqueID( const GraphicObject& rObj ) const;
+    OString                 GetUniqueID( const rtl::Reference< GraphicObject >& rObj ) const;
 
 public:
 
@@ -101,7 +102,7 @@ public:
                                 OutputDevice* pOut,
                                 const Point& rPt,
                                 const Size& rSz,
-                                const GraphicObject& rObj,
+                                const rtl::Reference< GraphicObject >& rObj,
                                 const GraphicAttr& rAttr
                             ) const;
 
@@ -109,7 +110,7 @@ public:
                                 OutputDevice* pOut,
                                 const Point& rPt,
                                 const Size& rSz,
-                                const GraphicObject& rObj,
+                                const rtl::Reference< GraphicObject >& rObj,
                                 const GraphicAttr& rAttr
                             ) const;
 
@@ -117,7 +118,7 @@ public:
                                 OutputDevice* pOut,
                                 const Point& rPt,
                                 const Size& rSz,
-                                const GraphicObject& rObj,
+                                const rtl::Reference< GraphicObject >& rObj,
                                 const GraphicAttr& rAttr,
                                 const BitmapEx& rBmpEx
                             );
@@ -126,7 +127,7 @@ public:
                                 OutputDevice* pOut,
                                 const Point& rPt,
                                 const Size& rSz,
-                                const GraphicObject& rObj,
+                                const rtl::Reference< GraphicObject >& rObj,
                                 const GraphicAttr& rAttr,
                                 const GDIMetaFile& rMtf
                             );
@@ -135,7 +136,7 @@ public:
                                 OutputDevice* pOut,
                                 const Point& rPt,
                                 const Size& rSz,
-                                const GraphicObject& rObj,
+                                const rtl::Reference< GraphicObject >& rObj,
                                 const GraphicAttr& rAttr
                             );
 };
diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx
index 076e1e3..1f80f8e 100644
--- a/svtools/source/graphic/grfmgr.cxx
+++ b/svtools/source/graphic/grfmgr.cxx
@@ -61,13 +61,13 @@ struct GrfSimpleCacheObj
 
 TYPEINIT1_AUTOFACTORY( GraphicObject, SvDataCopyStream );
 
-GraphicObject::GraphicObject( const GraphicManager* pMgr ) :
+GraphicObject::GraphicObject()
     mpLink      ( NULL ),
     mpUserData  ( NULL )
 {
     ImplConstruct();
     ImplAssignGraphicData();
-    ImplSetGraphicManager( pMgr );
+    ImplSetGraphicManager();
 }
 
 GraphicObject::GraphicObject( const Graphic& rGraphic, const GraphicManager* pMgr ) :
@@ -77,7 +77,7 @@ GraphicObject::GraphicObject( const Graphic& rGraphic, const GraphicManager* pMg
 {
     ImplConstruct();
     ImplAssignGraphicData();
-    ImplSetGraphicManager( pMgr );
+    ImplSetGraphicManager();
 }
 
 GraphicObject::GraphicObject( const GraphicObject& rGraphicObj, const GraphicManager* pMgr ) :
@@ -89,7 +89,7 @@ GraphicObject::GraphicObject( const GraphicObject& rGraphicObj, const GraphicMan
 {
     ImplConstruct();
     ImplAssignGraphicData();
-    ImplSetGraphicManager( pMgr, NULL, &rGraphicObj );
+    ImplSetGraphicManager(NULL, &rGraphicObj );
 }
 
 GraphicObject::GraphicObject( const OString& rUniqueID, const GraphicManager* pMgr ) :
@@ -101,7 +101,7 @@ GraphicObject::GraphicObject( const OString& rUniqueID, const GraphicManager* pM
     // assign default properties
     ImplAssignGraphicData();
 
-    ImplSetGraphicManager( pMgr, &rUniqueID );
+    ImplSetGraphicManager(&rUniqueID );
 
     // update properties
     ImplAssignGraphicData();
@@ -195,44 +195,27 @@ void GraphicObject::ImplAssignGraphicData()
     mnAnimationLoopCount = ( mbAnimated ? maGraphic.GetAnimationLoopCount() : 0 );
 }
 
-void GraphicObject::ImplSetGraphicManager( const GraphicManager* pMgr, const OString* pID, const rtl::Reference< GraphicObject > &xCopyObj )
+void GraphicObject::ImplSetGraphicManager( const OString* pID, const rtl::Reference< GraphicObject > &xCopyObj )
 {
-    if( !mpMgr || ( pMgr != mpMgr ) )
-    {
-        if( !pMgr && mpMgr && ( mpMgr == mpGlobalMgr ) )
-            return;
-        else
-        {
-            if( mpMgr )
-            {
-                mpMgr->ImplUnregisterObj( *this );
+    GraphicManager *pGlobalMgr;
 
-                if( ( mpMgr == mpGlobalMgr ) && !mpGlobalMgr->ImplHasObjects() )
-                    delete mpGlobalMgr, mpGlobalMgr = NULL;
-            }
-
-            if( !pMgr )
-            {
-                if( !mpGlobalMgr )
-                {
-                    mpGlobalMgr = new GraphicManager(
+    if ( ! ( pGlobalMgr = GraphicManager::pGlobalManager ) )
+    {
+        pGlobalMgr = new GraphicManager(
                         (officecfg::Office::Common::Cache::GraphicManager::
                          TotalCacheSize::get()),
                         (officecfg::Office::Common::Cache::GraphicManager::
                          ObjectCacheSize::get()));
-                    mpGlobalMgr->SetCacheTimeout(
+        pGlobalMgr->SetCacheTimeout(
                         officecfg::Office::Common::Cache::GraphicManager::
                         ObjectReleaseTime::get());
-                }
+        GraphicManager::pGlobalManager = pGlobalMgr;
+    }
 
-                mpMgr = mpGlobalMgr;
-            }
-            else
-                mpMgr = (GraphicManager*) pMgr;
+    // FIXME: remove this member in favour of the global eventually
+    mpMgr = pGlobalMgr;
 
-            mpMgr->ImplRegisterObj( *this, maGraphic, pID, xCopyObj );
-        }
-    }
+    mpMgr->ImplRegisterObj( *this, maGraphic, pID, xCopyObj );
 }
 
 void GraphicObject::ImplAutoSwapIn()
diff --git a/svtools/source/graphic/grfmgr2.cxx b/svtools/source/graphic/grfmgr2.cxx
index 5e5a5ea..84a18a8 100644
--- a/svtools/source/graphic/grfmgr2.cxx
+++ b/svtools/source/graphic/grfmgr2.cxx
@@ -138,52 +138,56 @@ sal_Bool GraphicManager::DrawObj( OutputDevice* pOut, const Point& rPt, const Si
     return bRet;
 }
 
-void GraphicManager::ImplRegisterObj( const GraphicObject& rObj, Graphic& rSubstitute,
-                                      const OString* pID, const GraphicObject* pCopyObj )
+void GraphicManager::ImplRegisterObj( const rtl::Reference< GraphicObject >& xObj,
+                                      Graphic& rSubstitute,
+                                      const OString* pID,
+                                      const rtl::Reference< GraphicObject >* pCopyObj )
 {
-    maObjList.push_back( (GraphicObject*)&rObj );
-    mpCache->AddGraphicObject( rObj, rSubstitute, pID, pCopyObj );
+#error mis-handling of pCopyObj
+    maObjList.push_back( xObj );
+    mpCache->AddGraphicObject( xObj, rSubstitute, pID, pCopyObj );
 }
 
-void GraphicManager::ImplUnregisterObj( const GraphicObject& rObj )
+void GraphicManager::ImplUnregisterObj( const rtl::Reference< GraphicObject >& xObj )
 {
-    mpCache->ReleaseGraphicObject( rObj );
+    mpCache->ReleaseGraphicObject( xObj );
     for( GraphicObjectList_impl::iterator it = maObjList.begin(); it != maObjList.end(); ++it )
     {
-        if ( *it == &rObj ) {
+        if ( *it == &xObj ) {
             maObjList.erase( it );
             break;
         }
     }
 }
 
-void GraphicManager::ImplGraphicObjectWasSwappedOut( const GraphicObject& rObj )
+void GraphicManager::ImplGraphicObjectWasSwappedOut( const rtl::Reference< GraphicObject >& xObj)
 {
-    mpCache->GraphicObjectWasSwappedOut( rObj );
+    mpCache->GraphicObjectWasSwappedOut( xObj );
 }
 
-OString GraphicManager::ImplGetUniqueID( const GraphicObject& rObj ) const
+OString GraphicManager::ImplGetUniqueID( const rtl::Reference< GraphicObject >& xObj ) const
 {
-    return mpCache->GetUniqueID( rObj );
+    return mpCache->GetUniqueID( xObj );
 }
 
-sal_Bool GraphicManager::ImplFillSwappedGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute )
+sal_Bool GraphicManager::ImplFillSwappedGraphicObject( const rtl::Reference< GraphicObject >& xObj, Graphic& rSubstitute )
 {
-    return( mpCache->FillSwappedGraphicObject( rObj, rSubstitute ) );
+    return( mpCache->FillSwappedGraphicObject( xObj, rSubstitute ) );
 }
 
-void GraphicManager::ImplGraphicObjectWasSwappedIn( const GraphicObject& rObj )
+void GraphicManager::ImplGraphicObjectWasSwappedIn( const rtl::Reference< GraphicObject >& xObj )
 {
-    mpCache->GraphicObjectWasSwappedIn( rObj );
+    mpCache->GraphicObjectWasSwappedIn( xObj );
 }
 
 sal_Bool GraphicManager::ImplDraw( OutputDevice* pOut, const Point& rPt,
-                               const Size& rSz, GraphicObject& rObj,
-                               const GraphicAttr& rAttr,
-                               const sal_uLong nFlags, sal_Bool& rCached )
+                                   const Size& rSz,
+                                   const rtl::Reference< GraphicObject >& xObj,
+                                   const GraphicAttr& rAttr,
+                                   const sal_uLong nFlags, sal_Bool& rCached )
 {
-    const Graphic&  rGraphic = rObj.GetGraphic();
-    sal_Bool            bRet = sal_False;
+    const Graphic&  rGraphic = xObj->GetGraphic();
+    sal_Bool        bRet = sal_False;
 
     if( rGraphic.IsSupportedGraphic() && !rGraphic.IsSwapOut() )
     {
@@ -194,13 +198,13 @@ sal_Bool GraphicManager::ImplDraw( OutputDevice* pOut, const Point& rPt,
             // #i46805# No point in caching a bitmap that is rendered
             // via RectFill on the OutDev
             if( !(pOut->GetDrawMode() & ( DRAWMODE_BLACKBITMAP | DRAWMODE_WHITEBITMAP )) &&
-                mpCache->IsDisplayCacheable( pOut, rPt, rSz, rObj, rAttr ) )
+                mpCache->IsDisplayCacheable( pOut, rPt, rSz, xObj, rAttr ) )
             {
                 BitmapEx aDstBmpEx;
 
                 if( ImplCreateOutput( pOut, rPt, rSz, aSrcBmpEx, rAttr, nFlags, &aDstBmpEx ) )
                 {
-                    rCached = mpCache->CreateDisplayCacheObj( pOut, rPt, rSz, rObj, rAttr, aDstBmpEx );
+                    rCached = mpCache->CreateDisplayCacheObj( pOut, rPt, rSz, xObj, rAttr, aDstBmpEx );
                     bRet = sal_True;
                 }
             }
@@ -212,7 +216,7 @@ sal_Bool GraphicManager::ImplDraw( OutputDevice* pOut, const Point& rPt,
         {
             const GDIMetaFile& rSrcMtf = rGraphic.GetGDIMetaFile();
 
-            if( mpCache->IsDisplayCacheable( pOut, rPt, rSz, rObj, rAttr ) )
+            if( mpCache->IsDisplayCacheable( pOut, rPt, rSz, xObj, rAttr ) )
             {
                 GDIMetaFile aDstMtf;
                 BitmapEx    aContainedBmpEx;
@@ -227,13 +231,13 @@ sal_Bool GraphicManager::ImplDraw( OutputDevice* pOut, const Point& rPt,
 
                         if( ImplCreateOutput( pOut, rPt, rSz, aContainedBmpEx, rAttr, nFlags, &aDstBmpEx ) )
                         {
-                            rCached = mpCache->CreateDisplayCacheObj( pOut, rPt, rSz, rObj, rAttr, aDstBmpEx );
+                            rCached = mpCache->CreateDisplayCacheObj( pOut, rPt, rSz, xObj, rAttr, aDstBmpEx );
                             bRet = sal_True;
                         }
                     }
                     else
                     {
-                        rCached = mpCache->CreateDisplayCacheObj( pOut, rPt, rSz, rObj, rAttr, aDstMtf );
+                        rCached = mpCache->CreateDisplayCacheObj( pOut, rPt, rSz, xObj, rAttr, aDstMtf );
                         bRet = sal_True;
                     }
                 }
@@ -241,7 +245,7 @@ sal_Bool GraphicManager::ImplDraw( OutputDevice* pOut, const Point& rPt,
 
             if( !bRet )
             {
-                const Graphic aGraphic( rObj.GetTransformedGraphic( &rAttr ) );
+                const Graphic aGraphic( xObj->GetTransformedGraphic( &rAttr ) );
 
                 if( aGraphic.IsSupportedGraphic() )
                 {
@@ -256,9 +260,9 @@ sal_Bool GraphicManager::ImplDraw( OutputDevice* pOut, const Point& rPt,
 }
 
 sal_Bool ImplCreateRotatedScaled( const BitmapEx& rBmpEx, const GraphicAttr& rAttributes,
-                                sal_uInt16 nRot10, const Size& rUnrotatedSzPix,
-                                long nStartX, long nEndX, long nStartY, long nEndY,
-                                BitmapEx& rOutBmpEx )
+                                  sal_uInt16 nRot10, const Size& rUnrotatedSzPix,
+                                  long nStartX, long nEndX, long nStartY, long nEndY,
+                                  BitmapEx& rOutBmpEx )
 {
     const long  aUnrotatedWidth  = rUnrotatedSzPix.Width();
     const long  aUnrotatedHeight = rUnrotatedSzPix.Height();
@@ -815,9 +819,10 @@ sal_Bool ImplCreateRotatedScaled( const BitmapEx& rBmpEx, const GraphicAttr& rAt
 }
 
 sal_Bool GraphicManager::ImplCreateOutput( OutputDevice* pOutputDevice,
-                                       const Point& rPoint, const Size& rSize,
-                                       const BitmapEx& rBitmapEx, const GraphicAttr& rAttributes,
-                                       const sal_uLong /*nFlags*/, BitmapEx* pBmpEx )
+                                           const Point& rPoint, const Size& rSize,
+                                           const BitmapEx& rBitmapEx,
+                                           const GraphicAttr& rAttributes,
+                                           const sal_uLong /*nFlags*/, BitmapEx* pBmpEx )
 {
     sal_uInt16  nRot10 = rAttributes.GetRotation() % 3600;
 
@@ -1033,9 +1038,10 @@ static BitmapEx checkMetadataBitmap( const BitmapEx& rBmpEx,
 }
 
 sal_Bool GraphicManager::ImplCreateOutput( OutputDevice* pOut,
-                                       const Point& rPt, const Size& rSz,
-                                       const GDIMetaFile& rMtf, const GraphicAttr& rAttr,
-                                       const sal_uLong /*nFlags*/, GDIMetaFile& rOutMtf, BitmapEx& rOutBmpEx )
+                                           const Point& rPt, const Size& rSz,
+                                           const GDIMetaFile& rMtf, const GraphicAttr& rAttr,
+                                           const sal_uLong /*nFlags*/,
+                                           GDIMetaFile& rOutMtf, BitmapEx& rOutBmpEx )
 {
     const Size aNewSize( rMtf.GetPrefSize() );
 
diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx
index f451294..d45d262 100644
--- a/svx/source/customshapes/EnhancedCustomShape2d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx
@@ -2197,8 +2197,7 @@ void EnhancedCustomShape2d::AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rC
                         static_cast< short > ( GetLuminanceChange(
                             std::min(nColorIndex, nColorCount-1))));
 
-                    rObj.SetMergedItem(XFillBitmapItem(
-                        String(), GraphicObject::Create(Graphic(aBitmap))));
+                    rObj.SetMergedItem(XFillBitmapItem(Graphic(aBitmap)));
                 }
 
                 break;
diff --git a/svx/source/customshapes/EnhancedCustomShape3d.cxx b/svx/source/customshapes/EnhancedCustomShape3d.cxx
index f2d812e..53edc42 100644
--- a/svx/source/customshapes/EnhancedCustomShape3d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape3d.cxx
@@ -505,7 +505,7 @@ SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, con
                         aLogicalSize.Height() *= 5;
                         aFillBmp.SetPrefSize( aLogicalSize );
                         aFillBmp.SetPrefMapMode( MAP_100TH_MM );
-                        p3DObj->SetMergedItem(XFillBitmapItem(String(), GraphicObject::Create(Graphic(aFillBmp))));
+                        p3DObj->SetMergedItem(XFillBitmapItem(aFillBmp));
                     }
                     else
                     {
@@ -523,8 +523,7 @@ SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, con
                                                     (sal_Int32)( aBmpSize.Height() * fYScale ) );
                             Rectangle aCropRect( aPt, aSize );
                              aFillBmp.Crop( aCropRect );
-                            p3DObj->SetMergedItem(XFillBitmapItem(String(),
-                                                                  GraphicObject::Create(Graphic(aFillBmp))));
+                            p3DObj->SetMergedItem(XFillBitmapItem(aFillBmp));
                         }
                     }
                     pScene->Insert3DObj( p3DObj );
@@ -547,7 +546,7 @@ SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, con
 
                     if ( ( aLocalFillStyle == XFILL_BITMAP ) && !aFillBmp.IsEmpty() )
                     {
-                        p3DObj->SetMergedItem(XFillBitmapItem(String(), GraphicObject::Create(Graphic(aFillBmp))));
+                        p3DObj->SetMergedItem(XFillBitmapItem(aFillBmp));
                     }
                 }
                 else if ( aLocalFillStyle == XFILL_NONE )
diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx
index 849d58a..6d4e3ad 100644
--- a/svx/source/svdraw/svdfmtf.cxx
+++ b/svx/source/svdraw/svdfmtf.cxx
@@ -599,8 +599,7 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale)
                             aClipSize);
 
                         pObj->SetMergedItem(XFillStyleItem(XFILL_BITMAP));
-                        pObj->SetMergedItem(
-                                XFillBitmapItem(String(), GraphicObject::Create(Graphic(aClippedBitmap))));
+                        pObj->SetMergedItem(XFillBitmapItem(aClippedBitmap));
                         pObj->SetMergedItem(XFillBmpTileItem(false));
                         pObj->SetMergedItem(XFillBmpStretchItem(true));
                     }
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index 07d1f1b..6bd8406 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -1170,8 +1170,7 @@ SdrObject* SdrGrafObj::DoConvertToPolyObj(sal_Bool bBezier, bool bAddText ) cons
                 SfxItemSet aSet(GetObjectItemSet());
 
                 aSet.Put(XFillStyleItem(XFILL_BITMAP));
-                const BitmapEx aBitmapEx(GetTransformedGraphic().GetBitmapEx());
-                aSet.Put(XFillBitmapItem(OUString(), GraphicObject::Create(Graphic(aBitmapEx))));
+                aSet.Put(XFillBitmapItem(GetTransformedGraphic().GetBitmapEx());
                 aSet.Put(XFillBmpTileItem(false));
 
                 pRetval->SetMergedItemSet(aSet);
diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx
index ed952de..a49aa77 100644
--- a/svx/source/svdraw/svdoole2.cxx
+++ b/svx/source/svdraw/svdoole2.cxx
@@ -1335,8 +1335,7 @@ SdrObject* SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText, bool /* bUseHC
 
         // bitmap fill
         pClone->SetMergedItem(XFillStyleItem(XFILL_BITMAP));
-        pClone->SetMergedItem(XFillBitmapItem(String(),
-                                              GraphicObject::Create(GetEmptyOLEReplacementGraphic())));
+        pClone->SetMergedItem(XFillBitmapItem(GetEmptyOLEReplacementGraphic()));
         pClone->SetMergedItem(XFillBmpTileItem(false));
         pClone->SetMergedItem(XFillBmpStretchItem(false));
 
diff --git a/svx/source/xoutdev/xattrbmp.cxx b/svx/source/xoutdev/xattrbmp.cxx
index 2106539..3593b81 100644
--- a/svx/source/xoutdev/xattrbmp.cxx
+++ b/svx/source/xoutdev/xattrbmp.cxx
@@ -264,13 +264,29 @@ TYPEINIT1_AUTOFACTORY(XFillBitmapItem, NameOrIndex);
 
 //////////////////////////////////////////////////////////////////////////////
 
-XFillBitmapItem::XFillBitmapItem(const XubString& rName, const rtl::Reference< GraphicObject >& xGraphicObject)
+XFillBitmapItem::XFillBitmapItem(const OUString& rName, const rtl::Reference< GraphicObject >& xGraphicObject)
 :   NameOrIndex(XATTR_FILLBITMAP, rName),
     mxGraphicObject(GraphicObject::Create(xGraphicObject))
 {
 }
 
-//////////////////////////////////////////////////////////////////////////////
+XFillBitmapItem::XFillBitmapItem(const BitmapEx &rBitmapEx)
+:   NameOrIndex(XATTR_FILLBITMAP, String()),
+    mxGraphicObject(GraphicObject::Create(Graphic(rBitmapEx)))
+{
+}
+
+XFillBitmapItem::XFillBitmapItem(const Graphic &rGraphic)
+:   NameOrIndex(XATTR_FILLBITMAP, String()),
+    mxGraphicObject(GraphicObject::Create(rGraphic))
+{
+}
+
+XFillBitmapItem::XFillBitmapItem(const rtl::Reference< GraphicObject > &xGraphicObject)
+:   NameOrIndex(XATTR_FILLBITMAP, String()),
+    mxGraphicObject(GraphicObject::Create(xGraphicObject))
+{
+}
 
 XFillBitmapItem::XFillBitmapItem(const XFillBitmapItem& rItem)
 :   NameOrIndex(rItem),
diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx
index a38e0cd..08aee3a 100644
--- a/sw/source/core/frmedt/fecopy.cxx
+++ b/sw/source/core/frmedt/fecopy.cxx
@@ -1478,9 +1478,10 @@ void SwFEShell::Paste( SvStream& rStrm, sal_uInt16 nAction, const Point* pPt )
                     // for SdrGrafObj, use the graphic as fill style argument
                     const Graphic& rGraphic = pSdrGrafObj->GetGraphic();
 
-                    if(GRAPHIC_NONE != rGraphic.GetType() && GRAPHIC_DEFAULT != rGraphic.GetType())
+                    if(GRAPHIC_NONE != rGraphic.GetType() &&
+                       GRAPHIC_DEFAULT != rGraphic.GetType())
                     {
-                        aSet.Put(XFillBitmapItem(String(), rGraphic));
+                        aSet.Put(XFillBitmapItem(rGraphic));
                         aSet.Put(XFillStyleItem(XFILL_BITMAP));
                     }
                 }
@@ -1563,7 +1564,7 @@ sal_Bool SwFEShell::Paste( const Graphic &rGrf )
         SfxItemSet aSet(GetAttrPool(), XATTR_FILLSTYLE, XATTR_FILLBITMAP);
 
         aSet.Put(XFillStyleItem(XFILL_BITMAP));
-        aSet.Put(XFillBitmapItem(aEmptyStr, rGrf));
+        aSet.Put(XFillBitmapItem(rGrf));
         pView->SetAttributes(aSet, false);
     }
     return bRet;


More information about the Libreoffice-commits mailing list