[Libreoffice-commits] core.git: Branch 'feature/graphicobject' - include/svtools svtools/source

Michael Meeks michael.meeks at suse.com
Mon Aug 26 21:57:59 PDT 2013


 include/svtools/grfmgr.hxx         |   13 +++++-----
 svtools/source/graphic/grfmgr.cxx  |   32 +++++++++++--------------
 svtools/source/graphic/grfmgr2.cxx |   47 ++++++++++++++++++++-----------------
 3 files changed, 47 insertions(+), 45 deletions(-)

New commits:
commit 0032b7ef849ae67b4b8f3fff7856b922d9e48cec
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Tue Aug 27 05:56:06 2013 +0100

    Cleanup referencing variously.
    
    Change-Id: Ic31cad1ac2c28d79489f2fb3a49afc380778138c

diff --git a/include/svtools/grfmgr.hxx b/include/svtools/grfmgr.hxx
index 6e62066..39558f3 100644
--- a/include/svtools/grfmgr.hxx
+++ b/include/svtools/grfmgr.hxx
@@ -614,22 +614,23 @@ private:
 
     // Only used by GraphicObject's Ctor's and Dtor's
     void SVT_DLLPRIVATE ImplRegisterObj(
-                            const rtl::Reference< GraphicObject >& xObj,
+                            GraphicObject &rObj,
                             Graphic& rSubstitute,
                             const OString* pID = NULL
                         );
+
     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 rtl::Reference< GraphicObject > & xObj );
+    void SVT_DLLPRIVATE ImplGraphicObjectWasSwappedOut( GraphicObject & rObj );
     sal_Bool SVT_DLLPRIVATE ImplFillSwappedGraphicObject(
-                            const rtl::Reference< GraphicObject >& xObj,
+                            GraphicObject& rObj,
                             Graphic& rSubstitute
                         );
-    void SVT_DLLPRIVATE ImplGraphicObjectWasSwappedIn( const rtl::Reference< GraphicObject >& xObj );
+    void SVT_DLLPRIVATE ImplGraphicObjectWasSwappedIn( GraphicObject& rObj );
 
-    OString SVT_DLLPRIVATE ImplGetUniqueID( const rtl::Reference< GraphicObject >& xObj ) const;
+    OString SVT_DLLPRIVATE ImplGetUniqueID( const GraphicObject & rObj ) const;
 
                         GraphicManager( sal_uLong nCacheSize = 10000000UL, sal_uLong nMaxObjCacheSize = 2400000UL );
 
@@ -658,7 +659,7 @@ public:
                             OutputDevice* pOut,
                             const Point& rPt,
                             const Size& rSz,
-                            rtl::Reference< GraphicObject >& xObj,
+                            const rtl::Reference< GraphicObject >& xObj,
                             const GraphicAttr& rAttr,
                             const sal_uLong nFlags,
                             sal_Bool& rCached
diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx
index 842e7f5..3aff3cc 100644
--- a/svtools/source/graphic/grfmgr.cxx
+++ b/svtools/source/graphic/grfmgr.cxx
@@ -70,7 +70,7 @@ GraphicObject::GraphicObject() :
     ImplSetup();
 }
 
-GraphicObject::GraphicObject( const Graphic& rGraphic )
+GraphicObject::GraphicObject( const Graphic& rGraphic ) :
     maGraphic   ( rGraphic ),
     mpLink      ( NULL ),
     mpUserData  ( NULL )
@@ -136,7 +136,7 @@ css::uno::Reference< css::graphic::XGraphic > SAL_CALL GraphicObject::getGraphic
     return GetGraphic().GetXGraphic();
 }
 
-void SAL_CALL GraphicObject::setGraphic( const css::uno::Reference< css::graphic::XGraphic >& xGraphic )
+void SAL_CALL GraphicObject::setGraphic( const css::uno::Reference< css::graphic::XGraphic >& /* xGraphic */ )
     throw( RuntimeException )
 {
     SolarMutexGuard aSolarGuard;
@@ -158,12 +158,7 @@ OUString SAL_CALL GraphicObject::getUniqueID()
 GraphicObject::~GraphicObject()
 {
     if( mpMgr )
-    {
-        mpMgr->ImplUnregisterObj( *this );
-
-        if( ( mpMgr == mpGlobalMgr ) && !mpGlobalMgr->ImplHasObjects() )
-            delete mpGlobalMgr, mpGlobalMgr = NULL;
-    }
+        mpMgr->ImplUnregisterObj( rtl::Reference< GraphicObject >( this ) );
 
     delete mpSwapOutTimer;
     delete mpSwapStreamHdl;
@@ -483,7 +478,7 @@ void GraphicObject::GraphicManagerDestroyed()
 }
 
 sal_Bool GraphicObject::IsCached( OutputDevice* pOut, const Point& rPt, const Size& rSz,
-                              const GraphicAttr* pAttr, sal_uLong nFlags ) const
+                                  const GraphicAttr* pAttr, sal_uLong nFlags ) const
 {
     sal_Bool bRet;
 
@@ -497,7 +492,10 @@ sal_Bool GraphicObject::IsCached( OutputDevice* pOut, const Point& rPt, const Si
             sal_Bool        bRectClip;
             ImplGetCropParams( pOut, aPt, aSz, pAttr, aClipPolyPoly, bRectClip );
         }
-        bRet = mpMgr->IsInCache( pOut, aPt, aSz, *this, ( pAttr ? *pAttr : GetAttr() ) );
+        bRet = mpMgr->IsInCache( pOut, aPt, aSz,
+                                 rtl::Reference< GraphicObject >(
+                                        const_cast< GraphicObject *>( this ) ),
+                                 ( pAttr ? *pAttr : GetAttr() ) );
     }
     else
         bRet = sal_False;
@@ -562,7 +560,7 @@ bool GraphicObject::Draw( OutputDevice* pOut, const Point& rPt, const Size& rSz,
         }
     }
 
-    bRet = mpMgr->DrawObj( pOut, aPt, aSz, *this, aAttr, nFlags, bCached );
+    bRet = mpMgr->DrawObj( pOut, aPt, aSz, rtl::Reference< GraphicObject >( this ), aAttr, nFlags, bCached );
 
     if( bCropped )
         pOut->Pop();
@@ -737,12 +735,6 @@ const Graphic& GraphicObject::GetGraphic() const
     return maGraphic;
 }
 
-void GraphicObject::SetGraphic( const Graphic& rGraphic, const String& rLink )
-{
-    SetGraphic( rGraphic );
-    mpLink = new String( rLink );
-}
-
 Graphic GraphicObject::GetTransformedGraphic( const Size& rDestSize, const MapMode& rDestMap, const GraphicAttr& rAttr ) const
 {
     // #104550# Extracted from svx/source/svdraw/svdograf.cxx
@@ -1098,10 +1090,12 @@ SvStream& operator>>( SvStream& rIStm, GraphicObject& rGraphicObj )
     VersionCompat   aCompat( rIStm, STREAM_READ );
     Graphic         aGraphic;
     GraphicAttr     aAttr;
-    sal_Bool            bLink;
+    sal_Bool        bLink;
 
     rIStm >> aGraphic >> aAttr >> bLink;
 
+#error - tweak me here ...
+    // FIXME: we need to have a Create method for stream loading ...
     rGraphicObj.SetGraphic( aGraphic );
     rGraphicObj.SetAttr( aAttr );
 
@@ -1118,6 +1112,8 @@ SvStream& operator>>( SvStream& rIStm, GraphicObject& rGraphicObj )
     return rIStm;
 }
 
+// FIXME: should we match the create with a save method ?
+
 SvStream& operator<<( SvStream& rOStm, const GraphicObject& rGraphicObj )
 {
     VersionCompat   aCompat( rOStm, STREAM_WRITE, 1 );
diff --git a/svtools/source/graphic/grfmgr2.cxx b/svtools/source/graphic/grfmgr2.cxx
index ec6be0f..ee8325f 100644
--- a/svtools/source/graphic/grfmgr2.cxx
+++ b/svtools/source/graphic/grfmgr2.cxx
@@ -78,7 +78,8 @@ sal_Bool GraphicManager::IsInCache( OutputDevice* pOut, const Point& rPt,
 }
 
 sal_Bool GraphicManager::DrawObj( OutputDevice* pOut, const Point& rPt, const Size& rSz,
-                                  const rtl::Reference< GraphicObject >& rObj, const GraphicAttr& rAttr,
+                                  const rtl::Reference< GraphicObject >& xObj,
+                                  const GraphicAttr& rAttr,
                                   const sal_uLong nFlags, sal_Bool& rCached )
 {
     Point   aPt( rPt );
@@ -87,18 +88,18 @@ sal_Bool GraphicManager::DrawObj( OutputDevice* pOut, const Point& rPt, const Si
 
     rCached = sal_False;
 
-    if( ( rObj.GetType() == GRAPHIC_BITMAP ) || ( rObj.GetType() == GRAPHIC_GDIMETAFILE ) )
+    if( ( xObj->GetType() == GRAPHIC_BITMAP ) || ( xObj->GetType() == GRAPHIC_GDIMETAFILE ) )
     {
         // create output and fill cache
 
-        if( rObj.IsAnimated() || ( pOut->GetOutDevType() == OUTDEV_PRINTER ) ||
+        if( xObj->IsAnimated() || ( pOut->GetOutDevType() == OUTDEV_PRINTER ) ||
             ( !( nFlags & GRFMGR_DRAW_NO_SUBSTITUTE ) &&
               ( ( nFlags & GRFMGR_DRAW_SUBSTITUTE ) ||
                 !( nFlags & GRFMGR_DRAW_CACHED ) ||
                 ( pOut->GetConnectMetaFile() && !pOut->IsOutputEnabled() ) ) ) )
         {
             // simple output of transformed graphic
-            const Graphic aGraphic( rObj.GetTransformedGraphic( &rAttr ) );
+            const Graphic aGraphic( xObj->GetTransformedGraphic( &rAttr ) );
 
             if( aGraphic.IsSupportedGraphic() )
             {
@@ -123,8 +124,8 @@ sal_Bool GraphicManager::DrawObj( OutputDevice* pOut, const Point& rPt, const Si
         if( !bRet )
         {
             // cached/direct drawing
-            if( !mpCache->DrawDisplayCacheObj( pOut, aPt, aSz, rObj, rAttr ) )
-                bRet = ImplDraw( pOut, aPt, aSz, rObj, rAttr, nFlags, rCached );
+            if( !mpCache->DrawDisplayCacheObj( pOut, aPt, aSz, xObj, rAttr ) )
+                bRet = ImplDraw( pOut, aPt, aSz, xObj, rAttr, nFlags, rCached );
             else
                 bRet = rCached = sal_True;
         }
@@ -133,10 +134,11 @@ sal_Bool GraphicManager::DrawObj( OutputDevice* pOut, const Point& rPt, const Si
     return bRet;
 }
 
-void GraphicManager::ImplRegisterObj( const rtl::Reference< GraphicObject >& xObj,
+void GraphicManager::ImplRegisterObj( GraphicObject &rObj,
                                       Graphic& rSubstitute,
                                       const OString* pID )
 {
+    rtl::Reference< GraphicObject > xObj( &rObj );
     maObjList.push_back( xObj );
     mpCache->AddGraphicObject( xObj, rSubstitute, pID );
 }
@@ -146,31 +148,34 @@ void GraphicManager::ImplUnregisterObj( const rtl::Reference< GraphicObject >& x
     mpCache->ReleaseGraphicObject( xObj );
     for( GraphicObjectList_impl::iterator it = maObjList.begin(); it != maObjList.end(); ++it )
     {
-        if ( *it == &xObj ) {
+        if ( *it == xObj ) {
             maObjList.erase( it );
             break;
         }
     }
+    // FIXME: do we need to delete ourselves when we unregister the last object ?
 }
 
-void GraphicManager::ImplGraphicObjectWasSwappedOut( const rtl::Reference< GraphicObject >& xObj)
+void GraphicManager::ImplGraphicObjectWasSwappedOut( GraphicObject& rObj)
 {
-    mpCache->GraphicObjectWasSwappedOut( xObj );
+    mpCache->GraphicObjectWasSwappedOut( rtl::Reference< GraphicObject >( &rObj ) );
 }
 
-OString GraphicManager::ImplGetUniqueID( const rtl::Reference< GraphicObject >& xObj ) const
+OString GraphicManager::ImplGetUniqueID( const GraphicObject &rObj ) const
 {
-    return mpCache->GetUniqueID( xObj );
+    return mpCache->GetUniqueID( rtl::Reference< GraphicObject >(
+                const_cast< GraphicObject * > ( &rObj ) ) );
 }
 
-sal_Bool GraphicManager::ImplFillSwappedGraphicObject( const rtl::Reference< GraphicObject >& xObj, Graphic& rSubstitute )
+sal_Bool GraphicManager::ImplFillSwappedGraphicObject( GraphicObject & rObj, Graphic& rSubstitute )
 {
-    return( mpCache->FillSwappedGraphicObject( xObj, rSubstitute ) );
+    return( mpCache->FillSwappedGraphicObject( rtl::Reference< GraphicObject >( &rObj ),
+                                               rSubstitute ) );
 }
 
-void GraphicManager::ImplGraphicObjectWasSwappedIn( const rtl::Reference< GraphicObject >& xObj )
+void GraphicManager::ImplGraphicObjectWasSwappedIn( GraphicObject &rObj )
 {
-    mpCache->GraphicObjectWasSwappedIn( xObj );
+    mpCache->GraphicObjectWasSwappedIn( rtl::Reference< GraphicObject >( &rObj ) );
 }
 
 sal_Bool GraphicManager::ImplDraw( OutputDevice* pOut, const Point& rPt,
@@ -1857,15 +1862,15 @@ bool GraphicObject::ImplDrawTiled( OutputDevice* pOut, const Rectangle& rArea, c
             // draw alpha content, if any
             if( IsTransparent() )
             {
-                GraphicObject aAlphaGraphic;
+                rtl::Reference< GraphicObject > xAlphaGraphic;
 
                 if( GetGraphic().IsAlpha() )
-                    aAlphaGraphic.SetGraphic( GetGraphic().GetBitmapEx().GetAlpha().GetBitmap() );
+                    xAlphaGraphic = GraphicObject::Create( GetGraphic().GetBitmapEx().GetAlpha().GetBitmap() );
                 else
-                    aAlphaGraphic.SetGraphic( GetGraphic().GetBitmapEx().GetMask() );
+                    xAlphaGraphic = GraphicObject::Create( GetGraphic().GetBitmapEx().GetMask() );
 
-                if( aAlphaGraphic.ImplRenderTempTile( aVDev, SubdivisionExponent, nNumTilesInCacheX,
-                                                      nNumTilesInCacheY, rSizePixel, pAttr, nFlags ) )
+                if( xAlphaGraphic->ImplRenderTempTile( aVDev, SubdivisionExponent, nNumTilesInCacheX,
+                                                       nNumTilesInCacheY, rSizePixel, pAttr, nFlags ) )
                 {
                     // Combine bitmap and alpha/mask
                     if( GetGraphic().IsAlpha() )


More information about the Libreoffice-commits mailing list