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

Michael Meeks michael.meeks at collabora.com
Wed Sep 25 06:50:16 PDT 2013


 editeng/source/items/frmitems.cxx |    8 ++------
 include/svtools/grfmgr.hxx        |   11 +++++++----
 svtools/source/graphic/grfmgr.cxx |   26 +++++++++++---------------
 3 files changed, 20 insertions(+), 25 deletions(-)

New commits:
commit 0854f0566c5d18b919b76df10b4bbd5a3606b7d6
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Tue Sep 24 15:46:34 2013 +0200

    Construct graphic objects from streams and misc. other fixes.
    
    Change-Id: I3b8c65adf7621e855b36d777e358d2465d7d0a14

diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx
index 02c9301..a4eceeb 100644
--- a/editeng/source/items/frmitems.cxx
+++ b/editeng/source/items/frmitems.cxx
@@ -3959,8 +3959,7 @@ rtl::Reference< GraphicObject > SvxBrushItem::GetGraphicObject() const
                 }
                 else
                 {
-                    pImpl->mxGraphicObject = GraphicObject::Create();
-                    pImpl->mxGraphicObject->SetGraphic( aGraphic );
+                    pImpl->mxGraphicObject = GraphicObject::Create( aGraphic );
                     const_cast < SvxBrushItem*> (this)->ApplyGraphicTransparency_Impl();
                 }
             }
@@ -4007,10 +4006,7 @@ void SvxBrushItem::SetGraphic( const Graphic& rNew )
 {
     if ( !pStrLink )
     {
-        if ( pImpl->mxGraphicObject.is() )
-            pImpl->mxGraphicObject->SetGraphic( rNew );
-        else
-            pImpl->mxGraphicObject = GraphicObject::Create( rNew );
+        pImpl->mxGraphicObject = GraphicObject::Create( rNew );
 
         ApplyGraphicTransparency_Impl();
 
diff --git a/include/svtools/grfmgr.hxx b/include/svtools/grfmgr.hxx
index 39558f3..f7e9da3 100644
--- a/include/svtools/grfmgr.hxx
+++ b/include/svtools/grfmgr.hxx
@@ -176,6 +176,7 @@ private:
     explicit GraphicObject();
     GraphicObject( const Graphic& rGraphic );
     GraphicObject( const GraphicObject& rCacheObj );
+    GraphicObject( SvStream &rIStm );
 
     explicit GraphicObject( const OString& rUniqueID );
 
@@ -185,10 +186,6 @@ public: // only for internal access:
         throw( css::uno::RuntimeException );
     virtual ~GraphicObject();
 
-    static rtl::Reference< GraphicObject > Create()
-    {
-        return rtl::Reference< GraphicObject >( new GraphicObject() );
-    }
     static rtl::Reference< GraphicObject > Create( const Graphic& rGraphic )
     {
         return rtl::Reference< GraphicObject >( new GraphicObject( rGraphic ) );
@@ -208,6 +205,10 @@ public: // only for internal access:
     {
         return rtl::Reference< GraphicObject >( new GraphicObject( rUniqueID ) );
     }
+    static rtl::Reference< GraphicObject > Create( SvStream &rIStm )
+    {
+        return rtl::Reference< GraphicObject >( new GraphicObject( rIStm ) );
+    }
 
 private:
     static GraphicManager*  mpGlobalMgr;
@@ -416,6 +417,8 @@ public:
     const GraphicAttr&      GetAttr() const { return maAttr; }
 
     sal_Bool                HasLink() const { return( mpLink != NULL && mpLink->Len() > 0 ); }
+
+// FIXME: remove these mutators: 'SetLink' indeed ... [!] ...
     void                    SetLink();
     void                    SetLink( const String& rLink );
     String                  GetLink() const;
diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx
index 3aff3cc..5a286a9 100644
--- a/svtools/source/graphic/grfmgr.cxx
+++ b/svtools/source/graphic/grfmgr.cxx
@@ -1085,35 +1085,31 @@ IMPL_LINK_NOARG(GraphicObject, ImplAutoSwapOutHdl)
     return 0L;
 }
 
-SvStream& operator>>( SvStream& rIStm, GraphicObject& rGraphicObj )
+GraphicObject::GraphicObject( SvStream& rIStm ) :
+    mpLink     ( NULL ),
+    mpUserData ( NULL )
 {
     VersionCompat   aCompat( rIStm, STREAM_READ );
-    Graphic         aGraphic;
-    GraphicAttr     aAttr;
     sal_Bool        bLink;
 
-    rIStm >> aGraphic >> aAttr >> bLink;
+    rIStm >> maGraphic >> maAttr >> bLink;
 
-#error - tweak me here ...
-    // FIXME: we need to have a Create method for stream loading ...
-    rGraphicObj.SetGraphic( aGraphic );
-    rGraphicObj.SetAttr( aAttr );
+    ImplConstruct();
+    ImplAssignGraphicData();
+    ImplSetup();
 
     if( bLink )
     {
         OUString aLink = read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(rIStm, RTL_TEXTENCODING_UTF8);
-        rGraphicObj.SetLink(aLink);
+        SetLink(aLink);
     }
     else
-        rGraphicObj.SetLink();
+        SetLink();
 
-    rGraphicObj.SetSwapStreamHdl();
-
-    return rIStm;
+    SetSwapStreamHdl();
 }
 
-// FIXME: should we match the create with a save method ?
-
+// FIXME: should we match the above create with a save method ?
 SvStream& operator<<( SvStream& rOStm, const GraphicObject& rGraphicObj )
 {
     VersionCompat   aCompat( rOStm, STREAM_WRITE, 1 );


More information about the Libreoffice-commits mailing list