diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2013-09-24 15:46:34 +0200 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2013-09-24 15:46:34 +0200 |
commit | 0854f0566c5d18b919b76df10b4bbd5a3606b7d6 (patch) | |
tree | 1b188d834fa67da40f7c6afc77762dc8531d3a94 | |
parent | 0032b7ef849ae67b4b8f3fff7856b922d9e48cec (diff) |
Construct graphic objects from streams and misc. other fixes.
Change-Id: I3b8c65adf7621e855b36d777e358d2465d7d0a14
-rw-r--r-- | editeng/source/items/frmitems.cxx | 8 | ||||
-rw-r--r-- | include/svtools/grfmgr.hxx | 11 | ||||
-rw-r--r-- | svtools/source/graphic/grfmgr.cxx | 26 |
3 files changed, 20 insertions, 25 deletions
diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx index 02c93014efff..a4eceebc7a57 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 39558f3de313..f7e9da3bdb87 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 3aff3cc704ef..5a286a9ca61e 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 ); |