diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2013-09-27 16:39:56 +0200 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2013-09-27 16:39:56 +0200 |
commit | 134741211d5c95a1a0ef07e13eb4846c62adce22 (patch) | |
tree | 9b220785f4b9f5e0775ef848e76ea9ff08a1acfb | |
parent | 0854f0566c5d18b919b76df10b4bbd5a3606b7d6 (diff) |
Save Commit: must be squashed!!! ObjectGraphic refactor
Change-Id: I69f0b8bef3a08d1a325ccbe2b5f128df9cc14880
74 files changed, 586 insertions, 556 deletions
diff --git a/canvas/source/vcl/cachedbitmap.cxx b/canvas/source/vcl/cachedbitmap.cxx index bdbbcab79996..657b50957e82 100644 --- a/canvas/source/vcl/cachedbitmap.cxx +++ b/canvas/source/vcl/cachedbitmap.cxx @@ -35,7 +35,7 @@ using namespace ::com::sun::star; namespace vclcanvas { - CachedBitmap::CachedBitmap( const GraphicObjectSharedPtr& rGraphicObject, + CachedBitmap::CachedBitmap( const rtl::Reference< GraphicObject>& xGraphicObject, const ::Point& rPoint, const ::Size& rSize, const GraphicAttr& rAttr, @@ -43,7 +43,7 @@ namespace vclcanvas const rendering::RenderState& rUsedRenderState, const uno::Reference< rendering::XCanvas >& rTarget ) : CachedPrimitiveBase( rUsedViewState, rTarget, true ), - mpGraphicObject( rGraphicObject ), + mpGraphicObject( xGraphicObject ), maRenderState(rUsedRenderState), maPoint( rPoint ), maSize( rSize ), @@ -55,7 +55,7 @@ namespace vclcanvas { ::osl::MutexGuard aGuard( m_aMutex ); - mpGraphicObject.reset(); + mpGraphicObject.clear(); CachedPrimitiveBase::disposing(); } diff --git a/canvas/source/vcl/cachedbitmap.hxx b/canvas/source/vcl/cachedbitmap.hxx index 117d560943f1..5e52983dbaba 100644 --- a/canvas/source/vcl/cachedbitmap.hxx +++ b/canvas/source/vcl/cachedbitmap.hxx @@ -31,7 +31,6 @@ namespace vclcanvas { - typedef ::boost::shared_ptr< GraphicObject > GraphicObjectSharedPtr; class CachedBitmap : public ::canvas::CachedPrimitiveBase { @@ -59,7 +58,7 @@ namespace vclcanvas bool bSameViewTransform ); - GraphicObjectSharedPtr mpGraphicObject; + rtl::Reference< GraphicObject> mpGraphicObject; const ::com::sun::star::rendering::RenderState maRenderState; const ::Point maPoint; const ::Size maSize; diff --git a/canvas/source/vcl/canvas.cxx b/canvas/source/vcl/canvas.cxx index 5a44e4016307..30c0aebd9821 100644 --- a/canvas/source/vcl/canvas.cxx +++ b/canvas/source/vcl/canvas.cxx @@ -135,7 +135,7 @@ namespace vclcanvas return OUString( CANVAS_SERVICE_NAME ); } - bool Canvas::repaint( const GraphicObjectSharedPtr& rGrf, + bool Canvas::repaint( const rtl::Reference< GraphicObject>& rGrf, const rendering::ViewState& viewState, const rendering::RenderState& renderState, const ::Point& rPt, diff --git a/canvas/source/vcl/canvas.hxx b/canvas/source/vcl/canvas.hxx index 10bee3b48783..33376519f9fc 100644 --- a/canvas/source/vcl/canvas.hxx +++ b/canvas/source/vcl/canvas.hxx @@ -101,7 +101,7 @@ namespace vclcanvas virtual OUString SAL_CALL getServiceName( ) throw (::com::sun::star::uno::RuntimeException); // RepaintTarget - virtual bool repaint( const GraphicObjectSharedPtr& rGrf, + virtual bool repaint( const rtl::Reference< GraphicObject>& rGrf, const com::sun::star::rendering::ViewState& viewState, const com::sun::star::rendering::RenderState& renderState, const ::Point& rPt, diff --git a/canvas/source/vcl/canvasbitmap.cxx b/canvas/source/vcl/canvasbitmap.cxx index a469e448ed41..21c8356591c3 100644 --- a/canvas/source/vcl/canvasbitmap.cxx +++ b/canvas/source/vcl/canvasbitmap.cxx @@ -101,7 +101,7 @@ namespace vclcanvas return maCanvasHelper.getBitmap(); } - bool CanvasBitmap::repaint( const GraphicObjectSharedPtr& rGrf, + bool CanvasBitmap::repaint( const rtl::Reference< GraphicObject>& rGrf, const rendering::ViewState& viewState, const rendering::RenderState& renderState, const ::Point& rPt, diff --git a/canvas/source/vcl/canvasbitmap.hxx b/canvas/source/vcl/canvasbitmap.hxx index 176d4faea3bf..d7bb30573613 100644 --- a/canvas/source/vcl/canvasbitmap.hxx +++ b/canvas/source/vcl/canvasbitmap.hxx @@ -84,7 +84,7 @@ namespace vclcanvas virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); // RepaintTarget interface - virtual bool repaint( const GraphicObjectSharedPtr& rGrf, + virtual bool repaint( const rtl::Reference< GraphicObject>& rGrf, const ::com::sun::star::rendering::ViewState& viewState, const ::com::sun::star::rendering::RenderState& renderState, const ::Point& rPt, diff --git a/canvas/source/vcl/canvascustomsprite.cxx b/canvas/source/vcl/canvascustomsprite.cxx index 9dead83713de..9d6a0290dddb 100644 --- a/canvas/source/vcl/canvascustomsprite.cxx +++ b/canvas/source/vcl/canvascustomsprite.cxx @@ -161,7 +161,7 @@ namespace vclcanvas mbSurfaceDirty = false; } - bool CanvasCustomSprite::repaint( const GraphicObjectSharedPtr& rGrf, + bool CanvasCustomSprite::repaint( const rtl::Reference< GraphicObject>& rGrf, const rendering::ViewState& viewState, const rendering::RenderState& renderState, const ::Point& rPt, diff --git a/canvas/source/vcl/canvascustomsprite.hxx b/canvas/source/vcl/canvascustomsprite.hxx index 0014c3f91392..dd7a446de76b 100644 --- a/canvas/source/vcl/canvascustomsprite.hxx +++ b/canvas/source/vcl/canvascustomsprite.hxx @@ -111,7 +111,7 @@ namespace vclcanvas bool bBufferedUpdate ) const; // RepaintTarget - virtual bool repaint( const GraphicObjectSharedPtr& rGrf, + virtual bool repaint( const rtl::Reference< GraphicObject>& rGrf, const ::com::sun::star::rendering::ViewState& viewState, const ::com::sun::star::rendering::RenderState& renderState, const ::Point& rPt, diff --git a/canvas/source/vcl/canvashelper.cxx b/canvas/source/vcl/canvashelper.cxx index d1adb780f8d5..c611e92754df 100644 --- a/canvas/source/vcl/canvashelper.cxx +++ b/canvas/source/vcl/canvashelper.cxx @@ -1410,14 +1410,14 @@ namespace vclcanvas return true; } - bool CanvasHelper::repaint( const GraphicObjectSharedPtr& rGrf, + bool CanvasHelper::repaint( const rtl::Reference< GraphicObject>& rGrf, const rendering::ViewState& viewState, const rendering::RenderState& renderState, const ::Point& rPt, const ::Size& rSz, const GraphicAttr& rAttr ) const { - ENSURE_OR_RETURN_FALSE( rGrf, + ENSURE_OR_RETURN_FALSE( rGrf.is(), "Invalid Graphic" ); if( !mpOutDev ) diff --git a/canvas/source/vcl/canvashelper.hxx b/canvas/source/vcl/canvashelper.hxx index 5729d60c103e..77fdafc37397 100644 --- a/canvas/source/vcl/canvashelper.hxx +++ b/canvas/source/vcl/canvashelper.hxx @@ -264,7 +264,7 @@ namespace vclcanvas ::com::sun::star::rendering::IntegerBitmapLayout getMemoryLayout(); /// Repaint a cached bitmap - bool repaint( const GraphicObjectSharedPtr& rGrf, + bool repaint( const rtl::Reference< GraphicObject>& rGrf, const ::com::sun::star::rendering::ViewState& viewState, const ::com::sun::star::rendering::RenderState& renderState, const ::Point& rPt, diff --git a/canvas/source/vcl/repainttarget.hxx b/canvas/source/vcl/repainttarget.hxx index 84363da81e99..dd45056b281d 100644 --- a/canvas/source/vcl/repainttarget.hxx +++ b/canvas/source/vcl/repainttarget.hxx @@ -43,7 +43,7 @@ namespace vclcanvas virtual ~RepaintTarget() {} // call this when a bitmap is repainted - virtual bool repaint( const GraphicObjectSharedPtr& rGrf, + virtual bool repaint( const rtl::Reference< GraphicObject>& rGrf, const ::com::sun::star::rendering::ViewState& viewState, const ::com::sun::star::rendering::RenderState& renderState, const ::Point& rPt, diff --git a/canvas/source/vcl/spritecanvas.cxx b/canvas/source/vcl/spritecanvas.cxx index c18a7f9e6a58..9dbccf945a44 100644 --- a/canvas/source/vcl/spritecanvas.cxx +++ b/canvas/source/vcl/spritecanvas.cxx @@ -154,7 +154,7 @@ namespace vclcanvas return OUString( SPRITECANVAS_SERVICE_NAME ); } - bool SpriteCanvas::repaint( const GraphicObjectSharedPtr& rGrf, + bool SpriteCanvas::repaint( const rtl::Reference< GraphicObject>& rGrf, const rendering::ViewState& viewState, const rendering::RenderState& renderState, const ::Point& rPt, diff --git a/canvas/source/vcl/spritecanvas.hxx b/canvas/source/vcl/spritecanvas.hxx index 5ca1f77d25f0..18dfc975436c 100644 --- a/canvas/source/vcl/spritecanvas.hxx +++ b/canvas/source/vcl/spritecanvas.hxx @@ -135,7 +135,7 @@ namespace vclcanvas virtual OUString SAL_CALL getServiceName( ) throw (::com::sun::star::uno::RuntimeException); // RepaintTarget - virtual bool repaint( const GraphicObjectSharedPtr& rGrf, + virtual bool repaint( const rtl::Reference< GraphicObject>& rGrf, const ::com::sun::star::rendering::ViewState& viewState, const ::com::sun::star::rendering::RenderState& renderState, const ::Point& rPt, diff --git a/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx index a9eb28b2919f..d418e5396f7a 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx @@ -334,9 +334,9 @@ OUString WrappedSymbolBitmapURLProperty::getValueFromSeries( const Reference< be if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol ) && aSymbol.Graphic.is()) { - GraphicObject aGrObj( Graphic( aSymbol.Graphic )); + rtl::Reference<GraphicObject> aGrObj = GraphicObject::Create( aSymbol.Graphic); aRet = UNO_NAME_GRAPHOBJ_URLPREFIX + - OStringToOUString(aGrObj.GetUniqueID(), + OStringToOUString(aGrObj->GetUniqueID(), RTL_TEXTENCODING_ASCII_US); } return aRet; @@ -355,9 +355,9 @@ void WrappedSymbolBitmapURLProperty::setValueToSeries( bool bMatchesPrefix = aNewGraphicURL.match( UNO_NAME_GRAPHOBJ_URLPREFIX ); if( bMatchesPrefix ) { - GraphicObject aGrObj = GraphicObject( + rtl::Reference<GraphicObject> aGrObj = GraphicObject::Create( OUStringToOString(aNewGraphicURL.copy( RTL_CONSTASCII_LENGTH(UNO_NAME_GRAPHOBJ_URLPREFIX) ), RTL_TEXTENCODING_ASCII_US)); - aSymbol.Graphic.set( aGrObj.GetGraphic().GetXGraphic()); + aSymbol.Graphic.set( aGrObj->GetGraphic().GetXGraphic()); xSeriesPropertySet->setPropertyValue( "Symbol", uno::makeAny( aSymbol ) ); } else diff --git a/chart2/source/model/main/ChartModel.hxx b/chart2/source/model/main/ChartModel.hxx index ee36ddde856d..298bb927545d 100644 --- a/chart2/source/model/main/ChartModel.hxx +++ b/chart2/source/model/main/ChartModel.hxx @@ -137,7 +137,7 @@ private: ::com::sun::star::awt::Size m_aVisualAreaSize; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xParent; ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XRangeHighlighter > m_xRangeHighlighter; - ::std::vector< GraphicObject > m_aGraphicObjectVector; + ::std::vector< rtl::Reference <GraphicObject >> m_aGraphicObjectVector; ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > m_xDataProvider; /** is only valid if m_xDataProvider is set. If m_xDataProvider is set to an diff --git a/cui/source/dialogs/cuigaldlg.cxx b/cui/source/dialogs/cuigaldlg.cxx index f333f10ac687..f131f18313ef 100644 --- a/cui/source/dialogs/cuigaldlg.cxx +++ b/cui/source/dialogs/cuigaldlg.cxx @@ -1082,7 +1082,7 @@ IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickPreviewHdl) if( !aCbxPreview.IsChecked() ) { xMediaPlayer.clear(); - aWndPreview.SetGraphic( Graphic() ); + aWndPreview.ClearGraphic(); aWndPreview.Invalidate(); } else diff --git a/cui/source/options/optmemory.cxx b/cui/source/options/optmemory.cxx index 9e8976d500dc..97107b2d5b58 100644 --- a/cui/source/options/optmemory.cxx +++ b/cui/source/options/optmemory.cxx @@ -180,13 +180,11 @@ sal_Bool OfaMemoryOptionsPage::FillItemSet( SfxItemSet& rSet ) officecfg::Office::Common::Cache::GraphicManager::ObjectReleaseTime::set( objectReleaseTime, batch); - // create a dummy graphic object to get access to the common GraphicManager - GraphicObject aDummyObject; - GraphicManager& rGrfMgr = aDummyObject.GetGraphicManager(); + GraphicManager* pGrfMgr = GraphicManager::GetGlobalManager(); - rGrfMgr.SetMaxCacheSize(totalCacheSize); - rGrfMgr.SetMaxObjCacheSize(objectCacheSize, true); - rGrfMgr.SetCacheTimeout(objectReleaseTime); + pGrfMgr->SetMaxCacheSize(totalCacheSize); + pGrfMgr->SetMaxObjCacheSize(objectCacheSize, true); + pGrfMgr->SetCacheTimeout(objectReleaseTime); // OLECache officecfg::Office::Common::Cache::Writer::OLE_Objects::set( diff --git a/cui/source/tabpages/backgrnd.cxx b/cui/source/tabpages/backgrnd.cxx index 2b80d1031da4..b7fe6f859ab2 100644 --- a/cui/source/tabpages/backgrnd.cxx +++ b/cui/source/tabpages/backgrnd.cxx @@ -1874,9 +1874,9 @@ void SvxBackgroundTabPage::FillControls_Impl( const SvxBrushItem& rBgdAttr, if(bGraphTransparency) { - const GraphicObject* pObject = rBgdAttr.GetGraphicObject(); - if(pObject) - m_pGraphTransMF->SetValue(lcl_TransparencyToPercent(pObject->GetAttr().GetTransparency())); + const rtl::Reference<GraphicObject> xGraphObj = rBgdAttr.GetGraphicObject(); + if(xGraphObj.is()) + m_pGraphTransMF->SetValue(lcl_TransparencyToPercent(xGraphObj->GetAttr().GetTransparency())); else m_pGraphTransMF->SetValue(0); m_pGraphTransMF->SaveValue(); diff --git a/cui/source/tabpages/tpbitmap.cxx b/cui/source/tabpages/tpbitmap.cxx index 833330bee4f9..0a50679d5d16 100644 --- a/cui/source/tabpages/tpbitmap.cxx +++ b/cui/source/tabpages/tpbitmap.cxx @@ -65,7 +65,7 @@ SvxBitmapTabPage::SvxBitmapTabPage( Window* pParent, const SfxItemSet& rInAttrs pXPool ( (XOutdevItemPool*) rInAttrs.GetPool() ), aXFStyleItem ( XFILL_BITMAP ), - aXBitmapItem ( String(), Graphic() ), + aXBitmapItem (), aXFillAttr ( pXPool ), rXFSet ( aXFillAttr.GetItemSet() ) { @@ -241,7 +241,7 @@ sal_Bool SvxBitmapTabPage::FillItemSet( SfxItemSet& _rOutAttrs ) } else { - _rOutAttrs.Put(XFillBitmapItem(m_pBitmapCtl->GetBitmapEx()); + _rOutAttrs.Put(XFillBitmapItem(m_pBitmapCtl->GetBitmapEx())); } } } @@ -296,12 +296,12 @@ SfxTabPage* SvxBitmapTabPage::Create( Window* pWindow, IMPL_LINK_NOARG(SvxBitmapTabPage, ChangeBitmapHdl_Impl) { - GraphicObject* pGraphicObject = 0; + rtl::Reference<GraphicObject> xGraphicObject; int nPos(m_pLbBitmaps->GetSelectEntryPos()); if(LISTBOX_ENTRY_NOTFOUND != nPos) { - pGraphicObject = new GraphicObject(pBitmapList->GetBitmap(nPos)->GetGraphicObject()); + xGraphicObject = GraphicObject::Create(pBitmapList->GetBitmap(nPos)->GetGraphicObject()); } else { @@ -313,27 +313,27 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ChangeBitmapHdl_Impl) if((XFILL_BITMAP == eXFS) && (SFX_ITEM_SET == rOutAttrs.GetItemState(GetWhich(XATTR_FILLBITMAP), true, &pPoolItem))) { - pGraphicObject = new GraphicObject(((const XFillBitmapItem*)pPoolItem)->GetGraphicObject()); + xGraphicObject = GraphicObject::Create(((const XFillBitmapItem*)pPoolItem)->GetGraphicObject()); } } - if(!pGraphicObject) + if(!xGraphicObject.is()) { m_pLbBitmaps->SelectEntryPos(0); nPos = m_pLbBitmaps->GetSelectEntryPos(); if(LISTBOX_ENTRY_NOTFOUND != nPos) { - pGraphicObject = new GraphicObject(pBitmapList->GetBitmap(nPos)->GetGraphicObject()); + xGraphicObject = GraphicObject::Create(pBitmapList->GetBitmap(nPos)->GetGraphicObject()); } } } - if(pGraphicObject) + if(xGraphicObject.is()) { BitmapColor aBack; BitmapColor aFront; - bool bIs8x8(isHistorical8x8(pGraphicObject->GetGraphic().GetBitmap(), aBack, aFront)); + bool bIs8x8(isHistorical8x8(xGraphicObject->GetGraphic().GetBitmap(), aBack, aFront)); m_pLbColor->SetNoSelection(); m_pLbBackgroundColor->SetNoSelection(); @@ -347,7 +347,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ChangeBitmapHdl_Impl) // setting the pixel control - m_pCtlPixel->SetXBitmap(pGraphicObject->GetGraphic().GetBitmapEx()); + m_pCtlPixel->SetXBitmap(xGraphicObject->GetGraphic().GetBitmapEx()); Color aPixelColor = aFront; Color aBackColor = aBack; @@ -388,14 +388,13 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ChangeBitmapHdl_Impl) m_pCtlPixel->Invalidate(); // display bitmap - const XFillBitmapItem aXBmpItem(*pGraphicObject); + const XFillBitmapItem aXBmpItem(xGraphicObject); rXFSet.Put( aXBmpItem ); m_pCtlPreview->SetAttributes( aXFillAttr.GetItemSet() ); m_pCtlPreview->Invalidate(); bBmpChanged = sal_False; - delete pGraphicObject; } return 0; @@ -518,7 +517,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickAddHdl_Impl) { const BitmapEx aBitmapEx(m_pBitmapCtl->GetBitmapEx()); - pEntry = new XBitmapEntry(Graphic(aBitmapEx), aName); + pEntry = new XBitmapEntry(GraphicObject::Create(Graphic(aBitmapEx)), aName); } else // it must be a not existing imported bitmap { @@ -625,7 +624,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickImportHdl_Impl) if( !nError ) { - XBitmapEntry* pEntry = new XBitmapEntry( aGraphic, aName ); + XBitmapEntry* pEntry = new XBitmapEntry( GraphicObject::Create(aGraphic), aName ); pBitmapList->Insert( pEntry ); const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); @@ -687,7 +686,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickModifyHdl_Impl) bLoop = sal_False; const BitmapEx aBitmapEx(m_pBitmapCtl->GetBitmapEx()); - const XBitmapEntry aEntry(Graphic(aBitmapEx), aName); + const XBitmapEntry aEntry(GraphicObject::Create(Graphic(aBitmapEx)), aName); m_pLbBitmaps->Modify( rStyleSettings.GetListBoxPreviewDefaultPixelSize(), aEntry, nPos ); m_pLbBitmaps->SelectEntryPos( nPos ); diff --git a/dbaccess/source/ui/app/AppDetailPageHelper.cxx b/dbaccess/source/ui/app/AppDetailPageHelper.cxx index 79a0afff37ee..724c41744ec6 100644 --- a/dbaccess/source/ui/app/AppDetailPageHelper.cxx +++ b/dbaccess/source/ui/app/AppDetailPageHelper.cxx @@ -1351,15 +1351,18 @@ void OPreviewWindow::Paint( const Rectangle& rRect ) { Window::Paint( rRect ); - if( ImplGetGraphicCenterRect( m_aGraphicObj.GetGraphic(), m_aPreviewRect ) ) + if(m_xGraphicObj.is()) { - const Point aPos( m_aPreviewRect.TopLeft() ); - const Size aSize( m_aPreviewRect.GetSize() ); + if( ImplGetGraphicCenterRect( m_xGraphicObj->GetGraphic(), m_aPreviewRect ) ) + { + const Point aPos( m_aPreviewRect.TopLeft() ); + const Size aSize( m_aPreviewRect.GetSize() ); - if( m_aGraphicObj.IsAnimated() ) - m_aGraphicObj.StartAnimation( this, aPos, aSize ); - else - m_aGraphicObj.Draw( this, aPos, aSize ); + if( m_xGraphicObj->IsAnimated() ) + m_xGraphicObj->StartAnimation( this, aPos, aSize ); + else + m_xGraphicObj->Draw( this, aPos, aSize ); + } } } // ----------------------------------------------------------------------------- diff --git a/dbaccess/source/ui/app/AppDetailPageHelper.hxx b/dbaccess/source/ui/app/AppDetailPageHelper.hxx index 92202ecadcd3..f9467ccd57de 100644 --- a/dbaccess/source/ui/app/AppDetailPageHelper.hxx +++ b/dbaccess/source/ui/app/AppDetailPageHelper.hxx @@ -49,7 +49,7 @@ namespace dbaui class OPreviewWindow : public Window { - GraphicObject m_aGraphicObj; + rtl::Reference<GraphicObject> m_xGraphicObj; Rectangle m_aPreviewRect; /** gets the graphic cnter rect @@ -71,7 +71,7 @@ namespace dbaui // window overloads virtual void Paint(const Rectangle& rRect); - void setGraphic(const Graphic& _rGraphic ) { m_aGraphicObj.SetGraphic(_rGraphic); } + void setGraphic(const Graphic& _rGraphic ) { m_xGraphicObj = GraphicObject::Create(_rGraphic); } }; //================================================================== // A helper class for the controls in the detail page. diff --git a/editeng/source/items/bulitem.cxx b/editeng/source/items/bulitem.cxx index d89476cfbac3..c8afe12673c8 100644 --- a/editeng/source/items/bulitem.cxx +++ b/editeng/source/items/bulitem.cxx @@ -214,7 +214,7 @@ void SvxBulletItem::SetDefaultFont_Impl() void SvxBulletItem::SetDefaults_Impl() { - mxGraphicObject = rtl::Reference< GraphicObject >(); + mxGraphicObject = GraphicObject::Create(Graphic()); nWidth = 1200; // 1.2cm nStart = 1; nStyle = BS_123; @@ -287,12 +287,7 @@ int SvxBulletItem::operator==( const SfxPoolItem& rItem ) const if( nStyle == BS_BMP ) { - if( ( mxGraphicObject.is() && !rBullet.mxGraphicObject.is() ) || - ( !mxGraphicObject.is() && rBullet.mxGraphicObject.is() ) ) - return 0; - - if( ( mxGraphicObject.is() && rBullet.mxGraphicObject.is() ) && - ( ( mxGraphicObject.get() != rBullet.mxGraphicObject.get() ) || + if( ( ( mxGraphicObject.get() != rBullet.mxGraphicObject.get() ) || ( mxGraphicObject->GetPrefSize() != rBullet.mxGraphicObject->GetPrefSize() ) ) ) { return 0; @@ -308,10 +303,9 @@ SvStream& SvxBulletItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) c { // Correction for empty bitmap if( ( nStyle == BS_BMP ) && - ( !mxGraphicObject.is() || ( GRAPHIC_NONE == mxGraphicObject->GetType() ) || ( GRAPHIC_DEFAULT == mxGraphicObject->GetType() ) ) ) + ( GRAPHIC_NONE == mxGraphicObject->GetType() || GRAPHIC_DEFAULT == mxGraphicObject->GetType() ) ) { - if( mxGraphicObject.is() ) - const_cast< SvxBulletItem* >( this )->mxGraphicObject.clear(); + const_cast< SvxBulletItem* >( this )->mxGraphicObject.clear(); const_cast< SvxBulletItem* >( this )->nStyle = BS_NONE; } @@ -403,13 +397,7 @@ SfxItemPresentation SvxBulletItem::GetPresentation rtl::Reference< GraphicObject > SvxBulletItem::GetGraphicObject() const { - if( mxGraphicObject.is() ) - return mxGraphicObject; - else - { - static const rtl::Reference< GraphicObject > xDefaultObject = GraphicObject::Create(); - return xDefaultObject; - } + return mxGraphicObject; } //------------------------------------------------------------------------ diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx index a4eceebc7a57..3aa9b4755459 100644 --- a/editeng/source/items/frmitems.cxx +++ b/editeng/source/items/frmitems.cxx @@ -3602,8 +3602,10 @@ bool SvxBrushItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const { OUString sLink; if ( pStrLink ) + { sLink = *pStrLink; - else if( pImpl->mxGraphicObject.is() ) + } + else { OUString sPrefix( UNO_NAME_GRAPHOBJ_URLPREFIX); @@ -3741,8 +3743,7 @@ bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) if(nTmp >= 0 && nTmp <= 100) { pImpl->nGraphicTransparency = sal_Int8(nTmp); - if(pImpl->mxGraphicObject.is()) - ApplyGraphicTransparency_Impl(); + ApplyGraphicTransparency_Impl(); } } break; @@ -3819,8 +3820,11 @@ SvxBrushItem& SvxBrushItem::operator=( const SvxBrushItem& rItem ) pStrLink = new String( *rItem.pStrLink ); if ( rItem.pStrFilter ) pStrFilter = new String( *rItem.pStrFilter ); - if ( rItem.pImpl->mxGraphicObject.is() ) - pImpl->mxGraphicObject = GraphicObject::Create( rItem.pImpl->mxGraphicObject ); + pImpl->mxGraphicObject = GraphicObject::Create( rItem.pImpl->mxGraphicObject ); + } + else + { + pImpl->mxGraphicObject = GraphicObject::Create( Graphic() ); } nShadingValue = rItem.nShadingValue; @@ -3858,11 +3862,7 @@ int SvxBrushItem::operator==( const SfxPoolItem& rAttr ) const if ( bEqual && !rCmp.pStrLink ) { - if ( !rCmp.pImpl->mxGraphicObject.is() ) - bEqual = !pImpl->mxGraphicObject.is(); - else - bEqual = pImpl->mxGraphicObject.is() && - ( *pImpl->mxGraphicObject.get() == *rCmp.pImpl->mxGraphicObject.get() ); + bEqual = *pImpl->mxGraphicObject.get() == *rCmp.pImpl->mxGraphicObject.get(); } } @@ -3900,17 +3900,25 @@ SvStream& SvxBrushItem::Store( SvStream& rStream , sal_uInt16 /*nItemVersion*/ ) sal_uInt16 nDoLoad = 0; - if ( pImpl->mxGraphicObject.is() && !pStrLink ) + if ( !pStrLink ) + { nDoLoad |= LOAD_GRAPHIC; - if ( pStrLink ) + } + else + { nDoLoad |= LOAD_LINK; + } if ( pStrFilter ) + { nDoLoad |= LOAD_FILTER; + } rStream << nDoLoad; - if ( pImpl->mxGraphicObject.is() && !pStrLink ) + if ( !pStrLink ) + { rStream << pImpl->mxGraphicObject->GetGraphic(); - if ( pStrLink ) + } + else { OSL_FAIL("No BaseURL!"); // TODO/MBA: how to get a BaseURL?! @@ -3937,7 +3945,7 @@ void SvxBrushItem::PurgeMedium() const // ----------------------------------------------------------------------- rtl::Reference< GraphicObject > SvxBrushItem::GetGraphicObject() const { - if ( bLoadAgain && pStrLink && !pImpl->mxGraphicObject.is() ) + if ( bLoadAgain && pStrLink ) // when graphics already loaded, use as a cache { // only with "valid" names - empty names now allowed @@ -3978,7 +3986,7 @@ rtl::Reference< GraphicObject > SvxBrushItem::GetGraphicObject() const const Graphic* SvxBrushItem::GetGraphic() const { rtl::Reference< GraphicObject > xGrafObj = GetGraphicObject(); - return xGrafObj.is() ? &( xGrafObj->GetGraphic() ) : NULL; + return &( xGrafObj->GetGraphic()); } // ----------------------------------------------------------------------- @@ -3992,11 +4000,12 @@ void SvxBrushItem::SetGraphicPos( SvxGraphicPosition eNew ) pImpl->mxGraphicObject.clear(); DELETEZ( pStrLink ); DELETEZ( pStrFilter ); + pImpl->mxGraphicObject = GraphicObject::Create(Graphic()); // Creating a dummy } else { if ( !pImpl->mxGraphicObject.is() && !pStrLink ) - pImpl->mxGraphicObject = GraphicObject::Create(); // Creating a dummy + pImpl->mxGraphicObject = GraphicObject::Create(Graphic()); // Creating a dummy } } diff --git a/editeng/source/uno/unonrule.cxx b/editeng/source/uno/unonrule.cxx index 1713b637bac5..b83eaabed71b 100644 --- a/editeng/source/uno/unonrule.cxx +++ b/editeng/source/uno/unonrule.cxx @@ -463,8 +463,8 @@ void SvxUnoNumberingRules::setNumberingRuleByIndex( const Sequence< beans::Prope { if( NULL == aFmt.GetBrush() ) { - rtl::Reference< GraphicObject > xGrafObj = GraphicObject::Create(); - SvxBrushItem aBrushItem( xGrafObj, GPOS_AREA, SID_ATTR_BRUSH ); + rtl::Reference< GraphicObject > xGrafObj = rtl::Reference< GraphicObject >(); + SvxBrushItem aBrushItem( rtl::Reference< GraphicObject >(), GPOS_AREA, SID_ATTR_BRUSH ); aFmt.SetGraphicBrush( &aBrushItem ); } } diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx index b8df2b08b1a8..ccfc96eb9c73 100644 --- a/filter/source/msfilter/escherex.cxx +++ b/filter/source/msfilter/escherex.cxx @@ -1287,10 +1287,10 @@ sal_Bool EscherPropertyContainer::CreateOLEGraphicProperties( return bRetValue; } -sal_Bool EscherPropertyContainer::CreateGraphicProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & rXShape, const GraphicObject& rGraphicObj ) +sal_Bool EscherPropertyContainer::CreateGraphicProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & rXShape, const rtl::Reference<GraphicObject>& rGraphicObj ) { sal_Bool bRetValue = sal_False; - OString aUniqueId( rGraphicObj.GetUniqueID() ); + OString aUniqueId( rGraphicObj->GetUniqueID() ); if ( !aUniqueId.isEmpty() ) { AddOpt( ESCHER_Prop_fillType, ESCHER_FillPicture ); @@ -4238,7 +4238,7 @@ sal_uInt32 EscherGraphicProvider::GetBlibID( SvStream& rPicOutStrm, const OStrin sal_Bool bUseNativeGraphic( sal_False ); - Graphic aGraphic( mxGraphicObject->GetTransformedGraphic( pGraphicAttr ) ); + Graphic aGraphic( xGraphicObject->GetTransformedGraphic( pGraphicAttr ) ); GfxLink aGraphicLink; SvMemoryStream aStream; diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index 611045848aad..cf18bae30b85 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -6132,8 +6132,8 @@ sal_Bool SvxMSDffManager::GetBLIP( sal_uLong nIdx_, Graphic& rData, Rectangle* p { /* if this entry is available, then it should be possible to get the Graphic via GraphicObject */ - GraphicObject aGraphicObject( iter->second ); - rData = aGraphicObject.GetGraphic(); + rtl::Reference <GraphicObject> xGraphicObject = GraphicObject::Create( iter->second ); + rData = xGraphicObject->GetGraphic(); if ( rData.GetType() != GRAPHIC_NONE ) bOk = sal_True; else @@ -6190,8 +6190,8 @@ sal_Bool SvxMSDffManager::GetBLIP( sal_uLong nIdx_, Graphic& rData, Rectangle* p if ( bOk ) { // create new BlipCacheEntry for this graphic - GraphicObject aGraphicObject( rData ); - aEscherBlipCache.insert(std::make_pair(nIdx_,aGraphicObject.GetUniqueID())); + rtl::Reference<GraphicObject> xGraphicObject = GraphicObject::Create( rData ); + aEscherBlipCache.insert(std::make_pair(nIdx_, xGraphicObject->GetUniqueID())); } } } diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx index 41307b7b6631..9ef91fd4eace 100644 --- a/filter/source/msfilter/svdfppt.cxx +++ b/filter/source/msfilter/svdfppt.cxx @@ -7355,7 +7355,7 @@ void ApplyCellAttributes( const SdrObject* pObj, Reference< XCell >& xCell ) const XFillBitmapItem aXFillBitmapItem((const XFillBitmapItem&)pObj->GetMergedItem( XATTR_FILLBITMAP )); OUString aURL( UNO_NAME_GRAPHOBJ_URLPREFIX); aURL += OStringToOUString( - aXFillBitmapItem.GetGraphicObject().GetUniqueID(), + aXFillBitmapItem.GetGraphicObject()->GetUniqueID(), RTL_TEXTENCODING_ASCII_US); xPropSet->setPropertyValue("FillBitmapURL", Any( aURL ) ); diff --git a/include/filter/msfilter/escherex.hxx b/include/filter/msfilter/escherex.hxx index e21805a0d208..68e36f44f879 100644 --- a/include/filter/msfilter/escherex.hxx +++ b/include/filter/msfilter/escherex.hxx @@ -1052,7 +1052,7 @@ public: EscherBlibEntry( sal_uInt32 nPictureOffset, - const GraphicObject& rObj, + const rtl::Reference<GraphicObject>& rObj, const OString& rId, const GraphicAttr* pAttr = NULL ); @@ -1233,7 +1233,7 @@ public: ); sal_Bool CreateGraphicProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & rXShape, - const GraphicObject& rGraphicObj + const rtl::Reference<GraphicObject>& rGraphicObj ); sal_Bool CreateMediaGraphicProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & rXMediaObject diff --git a/include/svtools/grfmgr.hxx b/include/svtools/grfmgr.hxx index f7e9da3bdb87..0c8da6728cfa 100644 --- a/include/svtools/grfmgr.hxx +++ b/include/svtools/grfmgr.hxx @@ -153,13 +153,13 @@ public: mnGPercent != 0 || mnBPercent != 0 || mfGamma != 1.0 || mbInvert ); } - friend SvStream& operator<<( SvStream& rOStm, const GraphicAttr& rAttr ); - friend SvStream& operator>>( SvStream& rIStm, GraphicAttr& rAttr ); + friend SvStream& operator<<( SvStream& rOStm, const GraphicAttr& rAttr ); + friend SvStream& operator>>( SvStream& rIStm, GraphicAttr& rAttr ); }; typedef ::cppu::WeakImplHelper1< css::graphic::XGraphicObject > GraphicObject_BASE; -class SVT_DLLPUBLIC GraphicObject : public SvDataCopyStream, public GraphicObject_BASE +class SVT_DLLPUBLIC GraphicObject : public GraphicObject_BASE { friend class GraphicManager; sal_uInt32 nRefCount; @@ -196,10 +196,8 @@ public: // only for internal access: } static rtl::Reference< GraphicObject > Create( const rtl::Reference< GraphicObject > &xCacheObj ) { - if( xCacheObj.is() ) - return rtl::Reference< GraphicObject >( new GraphicObject( *xCacheObj.get() ) ); - else - return rtl::Reference< GraphicObject >(); + assert(xCacheObj.is()); + return rtl::Reference< GraphicObject >( new GraphicObject( *xCacheObj.get() ) ); } static rtl::Reference< GraphicObject > Create( const OString& rUniqueID ) { @@ -351,9 +349,9 @@ protected: virtual void GraphicManagerDestroyed(); virtual SvStream* GetSwapStream() const; - virtual void Load( SvStream& ); - virtual void Save( SvStream& ); - virtual void Assign( const SvDataCopyStream& ); +// virtual void Load( SvStream& ); +// virtual void Save( SvStream& ); +// virtual void Assign( const SvDataCopyStream& ); public: TYPEINFO(); @@ -522,9 +520,8 @@ public: void StopAnimation( OutputDevice* pOut = NULL, long nExtraData = 0L ); - friend SvStream& operator<<( SvStream& rOStm, const GraphicObject& rGraphicObj ); - friend SvStream& operator>>( SvStream& rIStm, GraphicObject& rGraphicObj ); - +// friend SvStream& operator<<( SvStream& rOStm, const GraphicObject& rGraphicObj ); +// friend SvStream& operator>>( SvStream& rIStm, GraphicObject& rGraphicObj ); static rtl::Reference< GraphicObject > CreateGraphicObjectFromURL( const OUString &rURL ); // will inspect an object ( e.g. a control ) for any 'ImageURL' // properties and return these in a vector. Note: this implementation @@ -553,7 +550,8 @@ class SVT_DLLPUBLIC GraphicManager private: /// GraphicManager is a singleton - static GraphicManager *pGlobalManager; + /// FIXME: make sure it is initialized as such, thread-safely + static GraphicManager* mpGlobalManager; GraphicObjectList_impl maObjList; GraphicCache* mpCache; @@ -667,6 +665,17 @@ public: const sal_uLong nFlags, sal_Bool& rCached ); + static void InitGlobal(); + static GraphicManager * GetGlobalManager() + { + /* FIXME: this is racy */ + if(!GraphicManager::mpGlobalManager) + { + GraphicManager::InitGlobal(); + }; + return GraphicManager::mpGlobalManager; + } + static void SetGlobalManager(GraphicManager* pMgr) { GraphicManager::mpGlobalManager = pMgr; } }; #endif // _GRFMGR_HXX diff --git a/include/svx/extedit.hxx b/include/svx/extedit.hxx index a2580edae11c..ea8273e91330 100644 --- a/include/svx/extedit.hxx +++ b/include/svx/extedit.hxx @@ -20,14 +20,14 @@ class SVX_DLLPUBLIC ExternalToolEdit { public: - GraphicObject* m_pGraphicObject; + rtl::Reference<GraphicObject> m_xGraphicObject; OUString m_aFileName; ExternalToolEdit(); virtual ~ExternalToolEdit(); virtual void Update( Graphic& aGraphic ) = 0; - void Edit( GraphicObject *pGraphic ); + void Edit( rtl::Reference<GraphicObject> xGraphicObj ); DECL_LINK( StartListeningEvent, void *pEvent ); diff --git a/include/svx/galctrl.hxx b/include/svx/galctrl.hxx index 5851b52cee6c..9f1ae8b884b0 100644 --- a/include/svx/galctrl.hxx +++ b/include/svx/galctrl.hxx @@ -74,8 +74,9 @@ public: GalleryPreview( Window* pParent, const ResId& rResId ); ~GalleryPreview(); - void SetGraphic( const Graphic& rGraphic ) { mxGraphicObj->SetGraphic( rGraphic ); } + void ClearGraphic(); bool SetGraphic( const INetURLObject& ); + bool SetGraphic( Graphic& rGraphic ); void PreviewMedia( const INetURLObject& rURL ); }; diff --git a/include/svx/grfflt.hxx b/include/svx/grfflt.hxx index 8557c121c648..15dcb34195bd 100644 --- a/include/svx/grfflt.hxx +++ b/include/svx/grfflt.hxx @@ -52,7 +52,7 @@ class SVX_DLLPUBLIC SvxGraphicFilter { public: - static sal_uLong ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObject& rFilterObject ); + static sal_uLong ExecuteGrfFilterSlot( SfxRequest& rReq, Graphic** pFilterObject ); static void DisableGraphicFilterSlots( SfxItemSet& rSet ); }; diff --git a/include/svx/svdograf.hxx b/include/svx/svdograf.hxx index 49a5824b526d..2278cbccdac6 100644 --- a/include/svx/svdograf.hxx +++ b/include/svx/svdograf.hxx @@ -80,7 +80,7 @@ private: OUString aFileName; // Wenn es sich um einen Link handelt, steht hier der Dateiname drin. OUString aFilterName; - rtl::Reference< GraphicObject> mxGraphic; // Zur Beschleunigung von Bitmapausgaben, besonders von gedrehten. + mutable rtl::Reference< GraphicObject> mxGraphic; // Zur Beschleunigung von Bitmapausgaben, besonders von gedrehten. rtl::Reference< GraphicObject> mxReplacementGraphic; SdrGraphicLink* pGraphicLink; // Und hier noch ein Pointer fuer gelinkte Grafiken bool bMirrored:1; // True bedeutet, die Grafik ist horizontal, d.h. ueber die Y-Achse gespiegelt auszugeben. diff --git a/include/svx/xbtmpit.hxx b/include/svx/xbtmpit.hxx index 54763935ac25..2354b14f5b51 100644 --- a/include/svx/xbtmpit.hxx +++ b/include/svx/xbtmpit.hxx @@ -43,7 +43,7 @@ private: public: TYPEINFO(); - XFillBitmapItem() : NameOrIndex(XATTR_FILLBITMAP, -1 ) { mxGraphicObject = GraphicObject::Create(); } + XFillBitmapItem() : NameOrIndex(XATTR_FILLBITMAP, -1 ) { mxGraphicObject = rtl::Reference< GraphicObject >(); } explicit XFillBitmapItem(const Graphic & rGraphic); explicit XFillBitmapItem(const BitmapEx & rBitmapEx); explicit XFillBitmapItem(const rtl::Reference< GraphicObject > & xGraphicObject); diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 7d08cabed790..a6c5937849e3 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -419,10 +419,13 @@ OUString DrawingML::WriteImage( const OUString& rURL ) if ( index != -1 ) { DBG(printf ("begin: %ld %s\n", long( sizeof( aURLBegin ) ), USS( rURL ) + RTL_CONSTASCII_LENGTH( aURLBegin ) )); - Graphic aGraphic = GraphicObject( aURLBS.copy(RTL_CONSTASCII_LENGTH(aURLBegin)) ).GetTransformedGraphic (); + rtl::Reference<GraphicObject> xGraphicObj = GraphicObject::Create(aURLBS.copy(RTL_CONSTASCII_LENGTH(aURLBegin))); + Graphic aGraphic = xGraphicObj->GetTransformedGraphic(); return WriteImage( aGraphic ); - } else { + } + else + { // add link to relations } @@ -433,9 +436,9 @@ const char* DrawingML::GetComponentDir() { switch ( meDocumentType ) { - case DOCUMENT_DOCX: return "word"; - case DOCUMENT_PPTX: return "ppt"; - case DOCUMENT_XLSX: return "xl"; + case DOCUMENT_DOCX: return "word"; + case DOCUMENT_PPTX: return "ppt"; + case DOCUMENT_XLSX: return "xl"; } return "unknown"; @@ -445,9 +448,9 @@ const char* DrawingML::GetRelationCompPrefix() { switch ( meDocumentType ) { - case DOCUMENT_DOCX: return ""; - case DOCUMENT_PPTX: - case DOCUMENT_XLSX: return "../"; + case DOCUMENT_DOCX: return ""; + case DOCUMENT_PPTX: + case DOCUMENT_XLSX: return "../"; } return "unknown"; @@ -459,59 +462,64 @@ OUString DrawingML::WriteImage( const Graphic& rGraphic ) OUString sMediaType; const char* pExtension = ""; OUString sRelId; - + GraphicType aType; SvMemoryStream aStream; const void* aData = aLink.GetData(); sal_Size nDataSize = aLink.GetDataSize(); - switch ( aLink.GetType() ) { - case GFX_LINK_TYPE_NATIVE_GIF: - sMediaType = "image/gif"; - pExtension = ".gif"; - break; - case GFX_LINK_TYPE_NATIVE_JPG: - sMediaType = "image/jpeg"; - pExtension = ".jpeg"; - break; - case GFX_LINK_TYPE_NATIVE_PNG: + switch ( aLink.GetType() ) + { + case GFX_LINK_TYPE_NATIVE_GIF: + sMediaType = "image/gif"; + pExtension = ".gif"; + break; + case GFX_LINK_TYPE_NATIVE_JPG: + sMediaType = "image/jpeg"; + pExtension = ".jpeg"; + break; + case GFX_LINK_TYPE_NATIVE_PNG: + sMediaType = "image/png"; + pExtension = ".png"; + break; + case GFX_LINK_TYPE_NATIVE_TIF: + sMediaType = "image/tiff"; + pExtension = ".tiff"; + break; + case GFX_LINK_TYPE_NATIVE_WMF: + sMediaType = "image/x-wmf"; + pExtension = ".wmf"; + break; + case GFX_LINK_TYPE_NATIVE_MET: + sMediaType = "image/x-met"; + pExtension = ".met"; + break; + case GFX_LINK_TYPE_NATIVE_PCT: + sMediaType = "image/x-pict"; + pExtension = ".pct"; + break; + default: + aType = rGraphic.GetType(); + if ( aType == GRAPHIC_BITMAP ) + { + GraphicConverter::Export( aStream, rGraphic, CVT_PNG ); sMediaType = "image/png"; pExtension = ".png"; + } + else if( aType == GRAPHIC_GDIMETAFILE ) + { + GraphicConverter::Export( aStream, rGraphic, CVT_EMF ); + sMediaType = "image/x-emf"; + pExtension = ".emf"; + } + else + { + OSL_TRACE( "unhandled graphic type" ); break; - case GFX_LINK_TYPE_NATIVE_TIF: - sMediaType = "image/tiff"; - pExtension = ".tiff"; - break; - case GFX_LINK_TYPE_NATIVE_WMF: - sMediaType = "image/x-wmf"; - pExtension = ".wmf"; - break; - case GFX_LINK_TYPE_NATIVE_MET: - sMediaType = "image/x-met"; - pExtension = ".met"; - break; - case GFX_LINK_TYPE_NATIVE_PCT: - sMediaType = "image/x-pict"; - pExtension = ".pct"; - break; - default: { - GraphicType aType = rGraphic.GetType(); - if ( aType == GRAPHIC_BITMAP ) { - GraphicConverter::Export( aStream, rGraphic, CVT_PNG ); - sMediaType = "image/png"; - pExtension = ".png"; - } else if ( aType == GRAPHIC_GDIMETAFILE ) { - GraphicConverter::Export( aStream, rGraphic, CVT_EMF ); - sMediaType = "image/x-emf"; - pExtension = ".emf"; - } else { - OSL_TRACE( "unhandled graphic type" ); - break; - } + } - aData = aStream.GetData(); - nDataSize = aStream.GetEndOfData(); - break; - } + aData = aStream.GetData(); + nDataSize = aStream.GetEndOfData(); + break; } Reference< XOutputStream > xOutStream = mpFB->openFragmentStream( OUStringBuffer() @@ -617,7 +625,7 @@ void DrawingML::WriteBlipFill( Reference< XPropertySet > rXPropSet, OUString sUR void DrawingML::WriteSrcRect( Reference< XPropertySet > rXPropSet, const OUString& rURL ) { - Size aOriginalSize( GraphicObject::CreateGraphicObjectFromURL( rURL ).GetPrefSize() ); + Size aOriginalSize( GraphicObject::CreateGraphicObjectFromURL( rURL )->GetPrefSize() ); if ( GetProperty( rXPropSet, "GraphicCrop" ) ) { diff --git a/sc/source/ui/drawfunc/graphsh.cxx b/sc/source/ui/drawfunc/graphsh.cxx index 6276575cd712..9b295b685266 100644 --- a/sc/source/ui/drawfunc/graphsh.cxx +++ b/sc/source/ui/drawfunc/graphsh.cxx @@ -59,7 +59,7 @@ public: aStr.Append( sal_Unicode(' ') ); aStr.Append( String( "External Edit" ) ); m_pView->BegUndo( aStr ); - pNewObj->SetGraphicObject( aGraphic ); + pNewObj->SetGraphicObject( GraphicObject::Create(aGraphic) ); m_pView->ReplaceObjectAtView( m_pObj, *pPageView, pNewObj ); m_pView->EndUndo(); } @@ -135,10 +135,10 @@ void ScGraphicShell::ExecuteFilter( SfxRequest& rReq ) if( pObj && pObj->ISA( SdrGrafObj ) && ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP ) { - GraphicObject aFilterObj( ( (SdrGrafObj*) pObj )->GetGraphicObject() ); + Graphic* pFilterObj = new Graphic( ( (SdrGrafObj*) pObj )->GetGraphicObject()->GetGraphic() ); if( SVX_GRAPHICFILTER_ERRCODE_NONE == - SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, aFilterObj ) ) + SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, &pFilterObj ) ) { SdrPageView* pPageView = pView->GetSdrPageView(); @@ -150,11 +150,12 @@ void ScGraphicShell::ExecuteFilter( SfxRequest& rReq ) aStr.Append( sal_Unicode(' ') ); aStr.Append( String( ScResId( SCSTR_UNDO_GRAFFILTER ) ) ); pView->BegUndo( aStr ); - pFilteredObj->SetGraphicObject( aFilterObj ); + pFilteredObj->SetGraphicObject( GraphicObject::Create(*pFilterObj )); pView->ReplaceObjectAtView( pObj, *pPageView, pFilteredObj ); pView->EndUndo(); } } + delete pFilterObj; } } @@ -189,9 +190,9 @@ void ScGraphicShell::ExecuteExternalEdit( SfxRequest& ) if( pObj && pObj->ISA( SdrGrafObj ) && ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP ) { - GraphicObject aGraphicObject( ( (SdrGrafObj*) pObj )->GetGraphicObject() ); + rtl::Reference<GraphicObject> xGraphicObject = ( (SdrGrafObj*) pObj )->GetGraphicObject(); ScExternalToolEdit* aExternalToolEdit = new ScExternalToolEdit( pView, pObj ); - aExternalToolEdit->Edit( &aGraphicObject ); + aExternalToolEdit->Edit( xGraphicObject ); } } diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx index e7fa2bb3b623..8d0f1f802cce 100644 --- a/sc/source/ui/view/printfun.cxx +++ b/sc/source/ui/view/printfun.cxx @@ -1146,10 +1146,10 @@ static void lcl_DrawGraphic( const SvxBrushItem &rBrush, OutputDevice *pOut, Out // (pixel rounding is handled correctly, and a very small bitmap // is duplicated into a bigger one for better performance) - GraphicObject aObject( *pGraphic ); + rtl::Reference<GraphicObject> xObject = GraphicObject::Create( *pGraphic ); if( pOut->GetPDFWriter() && - (aObject.GetType() == GRAPHIC_BITMAP || aObject.GetType() == GRAPHIC_DEFAULT) ) + (xObject->GetType() == GRAPHIC_BITMAP || xObject->GetType() == GRAPHIC_DEFAULT) ) { // For PDF export, every draw // operation for bitmaps takes a noticeable @@ -1178,13 +1178,13 @@ static void lcl_DrawGraphic( const SvxBrushItem &rBrush, OutputDevice *pOut, Out const Size aSize( rOrg.GetSize() ); const double Abitmap( k1/k2 * aSize.Width()*aSize.Height() ); - aObject.DrawTiled( pOut, rOrg, aGrfSize, Size(0,0), + xObject->DrawTiled( pOut, rOrg, aGrfSize, Size(0,0), NULL, GRFMGR_DRAW_STANDARD, ::std::max( 128, static_cast<int>( sqrt(sqrt( Abitmap)) + .5 ) ) ); } else { - aObject.DrawTiled( pOut, rOrg, aGrfSize, Size(0,0) ); + xObject->DrawTiled( pOut, rOrg, aGrfSize, Size(0,0) ); } bDraw = false; diff --git a/sd/source/core/drawdoc4.cxx b/sd/source/core/drawdoc4.cxx index 6954913a18a3..9c17c1d7adc6 100644 --- a/sd/source/core/drawdoc4.cxx +++ b/sd/source/core/drawdoc4.cxx @@ -168,7 +168,7 @@ void SdDrawDocument::CreateLayoutTemplates() Color aNullColor( COL_WHITE ); Bitmap aNullBmp( aNullSize, 8 ); aNullBmp.Erase( aNullColor ); - rISet.Put(XFillBitmapItem(pPool, Graphic(aNullBmp))); + rISet.Put(XFillBitmapItem(pPool, GraphicObject::Create(Graphic(aNullBmp)))); // Shadow attributes (Drawing Engine) rISet.Put(SdrShadowItem(sal_False)); diff --git a/sd/source/filter/eppt/epptso.cxx b/sd/source/filter/eppt/epptso.cxx index 7a0ebb763f63..5741125f4c09 100644 --- a/sd/source/filter/eppt/epptso.cxx +++ b/sd/source/filter/eppt/epptso.cxx @@ -118,8 +118,8 @@ sal_uInt16 PPTExBulletProvider::GetId( const OString& rUniqueId, Size& rGraphicS if ( !rUniqueId.isEmpty() ) { Rectangle aRect; - GraphicObject aGraphicObject( rUniqueId ); - Graphic aMappedGraphic, aGraphic( aGraphicObject.GetGraphic() ); + rtl::Reference<GraphicObject> xGraphicObject = GraphicObject::Create( rUniqueId ); + Graphic aMappedGraphic, aGraphic( xGraphicObject->GetGraphic() ); Size aPrefSize( aGraphic.GetPrefSize() ); BitmapEx aBmpEx( aGraphic.GetBitmapEx() ); @@ -144,10 +144,10 @@ sal_uInt16 PPTExBulletProvider::GetId( const OString& rUniqueId, Size& rGraphicS rGraphicSize = aNewSize; aMappedGraphic = Graphic( aBmpEx ); - aGraphicObject = GraphicObject( aMappedGraphic ); + xGraphicObject = GraphicObject::Create( aMappedGraphic ); } } - sal_uInt32 nId = pGraphicProv->GetBlibID( aBuExPictureStream, aGraphicObject.GetUniqueID(), aRect, NULL, NULL ); + sal_uInt32 nId = pGraphicProv->GetBlibID( aBuExPictureStream, xGraphicObject->GetUniqueID(), aRect, NULL, NULL ); if ( nId && ( nId < 0x10000 ) ) nRetValue = (sal_uInt16)nId - 1; diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx index abae1282329a..6b159d70ce7d 100644 --- a/sd/source/ui/func/fupage.cxx +++ b/sd/source/ui/func/fupage.cxx @@ -294,7 +294,7 @@ const SfxItemSet* FuPage::ExecuteDialog( Window* pParent ) // MigrateItemSet makes sure the XFillBitmapItem will have a unique name SfxItemSet aMigrateSet( mpDoc->GetPool(), XATTR_FILLBITMAP, XATTR_FILLBITMAP ); - aMigrateSet.Put(XFillBitmapItem(OUString("background"), aGraphic)); + aMigrateSet.Put(XFillBitmapItem(OUString("background"), GraphicObject::Create(aGraphic))); mpDoc->MigrateItemSet( &aMigrateSet, pTempSet.get(), NULL ); pTempSet->Put( XFillBmpStretchItem( sal_True )); diff --git a/sd/source/ui/view/GraphicObjectBar.cxx b/sd/source/ui/view/GraphicObjectBar.cxx index aed500bef3c6..bf8004c748bc 100644 --- a/sd/source/ui/view/GraphicObjectBar.cxx +++ b/sd/source/ui/view/GraphicObjectBar.cxx @@ -144,10 +144,10 @@ void GraphicObjectBar::ExecuteFilter( SfxRequest& rReq ) if( pObj && pObj->ISA( SdrGrafObj ) && ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP ) { - GraphicObject aFilterObj( ( (SdrGrafObj*) pObj )->GetGraphicObject() ); + Graphic* pFilterObj = new Graphic( ( (SdrGrafObj*) pObj )->GetGraphicObject()->GetGraphic() ); if( SVX_GRAPHICFILTER_ERRCODE_NONE == - SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, aFilterObj ) ) + SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, &pFilterObj ) ) { SdrPageView* pPageView = mpView->GetSdrPageView(); @@ -159,13 +159,14 @@ void GraphicObjectBar::ExecuteFilter( SfxRequest& rReq ) aStr.Append( sal_Unicode(' ') ); aStr.Append( String( SdResId( STR_UNDO_GRAFFILTER ) ) ); mpView->BegUndo( aStr ); - pFilteredObj->SetGraphicObject( aFilterObj ); + pFilteredObj->SetGraphicObject( GraphicObject::Create(*pFilterObj )); ::sd::View* const pView = mpView; pView->ReplaceObjectAtView( pObj, *pPageView, pFilteredObj ); pView->EndUndo(); return; } } + delete pFilterObj; } } diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 835cc9302e66..300262b430b2 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -194,7 +194,7 @@ public: aStr.Append( sal_Unicode(' ') ); aStr.Append( String( "External Edit" ) ); m_pView->BegUndo( aStr ); - pNewObj->SetGraphicObject( aGraphic ); + pNewObj->SetGraphicObject( GraphicObject::Create(aGraphic) ); m_pView->ReplaceObjectAtView( m_pObj, *pPageView, pNewObj ); m_pView->EndUndo(); } @@ -970,9 +970,9 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); if( pObj && pObj->ISA( SdrGrafObj ) && ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP ) { - GraphicObject aGraphicObject( ( (SdrGrafObj*) pObj )->GetGraphicObject() ); + rtl::Reference<GraphicObject> xGraphicObject = ( (SdrGrafObj*) pObj )->GetGraphicObject(); { - GraphicHelper::ExportGraphic( aGraphicObject.GetGraphic(), String("") ); + GraphicHelper::ExportGraphic( xGraphicObject->GetGraphic(), String("") ); } } } @@ -989,9 +989,9 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); if( pObj && pObj->ISA( SdrGrafObj ) && ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP ) { - GraphicObject aGraphicObject( ( (SdrGrafObj*) pObj )->GetGraphicObject() ); + rtl::Reference<GraphicObject> xGraphicObject = ( ( (SdrGrafObj*) pObj )->GetGraphicObject() ); SdExternalToolEdit* aExternalToolEdit = new SdExternalToolEdit( mpDrawView, pObj ); - aExternalToolEdit->Edit( &aGraphicObject ); + aExternalToolEdit->Edit( xGraphicObject ); } } Cancel(); diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx index cdbe0aeb2a3d..b3c079385506 100644 --- a/sd/source/ui/view/sdview3.cxx +++ b/sd/source/ui/view/sdview3.cxx @@ -756,7 +756,7 @@ sal_Bool View::InsertData( const TransferableDataHelper& rDataHelper, // If we have a graphic as source object, use it's graphic // content as fill style aSet.Put(XFillStyleItem(XFILL_BITMAP)); - aSet.Put(XFillBitmapItem(&mrDoc.GetPool(), pSdrGrafObj->GetGraphic())); + aSet.Put(XFillBitmapItem(&mrDoc.GetPool(), GraphicObject::Create(pSdrGrafObj->GetGraphic()))); } pPickObj->SetMergedItemSetAndBroadcast( aSet ); diff --git a/sd/source/ui/view/sdview4.cxx b/sd/source/ui/view/sdview4.cxx index 067b677a1f0c..49ee09da400c 100644 --- a/sd/source/ui/view/sdview4.cxx +++ b/sd/source/ui/view/sdview4.cxx @@ -151,7 +151,7 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction, SfxItemSet aSet(mpDocSh->GetPool(), XATTR_FILLSTYLE, XATTR_FILLBITMAP); aSet.Put(XFillStyleItem(XFILL_BITMAP)); - aSet.Put(XFillBitmapItem(&mpDocSh->GetPool(), rGraphic)); + aSet.Put(XFillBitmapItem(&mpDocSh->GetPool(), GraphicObject::Create(rGraphic))); pPickObj->SetMergedItemSetAndBroadcast(aSet); } } diff --git a/slideshow/source/engine/shapes/shapeimporter.cxx b/slideshow/source/engine/shapes/shapeimporter.cxx index 6c958a0c406e..c07ca00989c3 100644 --- a/slideshow/source/engine/shapes/shapeimporter.cxx +++ b/slideshow/source/engine/shapes/shapeimporter.cxx @@ -64,8 +64,8 @@ namespace internal { namespace { bool importShapeGraphic( - GraphicObject & o_rGraphic, - uno::Reference<beans::XPropertySet> const& xPropSet ) + rtl::Reference<GraphicObject> & o_rGraphic, + uno::Reference<beans::XPropertySet> const& xPropSet ) { OUString aURL; if( !getPropertyValue( aURL, xPropSet, "GraphicURL") || @@ -103,11 +103,11 @@ bool importShapeGraphic( // fetch already loaded graphic from graphic manager. OString const aOldString(OUStringToOString(aUniqueId, RTL_TEXTENCODING_UTF8)); - o_rGraphic = GraphicObject( aOldString ); + o_rGraphic = GraphicObject::Create( aOldString ); - if( GRAPHIC_DEFAULT == o_rGraphic.GetType() - || GRAPHIC_NONE == o_rGraphic.GetType() ) + if( GRAPHIC_DEFAULT == o_rGraphic->GetType() + || GRAPHIC_NONE == o_rGraphic->GetType() ) { // even the GrfMgr does not seem to know this graphic return false; @@ -138,7 +138,7 @@ bool importShapeGraphic( return false; } - o_rGraphic = GraphicObject( aTmpGraphic ); + o_rGraphic = GraphicObject::Create( aTmpGraphic ); } return true; } @@ -329,18 +329,18 @@ ShapeSharedPtr ShapeImporter::createShape( } else if( shapeType == "com.sun.star.drawing.GraphicObjectShape" || shapeType == "com.sun.star.presentation.GraphicObjectShape" ) { - GraphicObject aGraphicObject; + rtl::Reference<GraphicObject> xGraphicObject; // to get hold of GIF animations, inspect Graphic // objects more thoroughly (the plain-jane shape // metafile of course would only contain the first // animation frame) - if( !importShapeGraphic( aGraphicObject, xPropSet ) ) + if( !importShapeGraphic( xGraphicObject, xPropSet ) ) return ShapeSharedPtr(); // error loading graphic - // no placeholders in // slideshow - if( !aGraphicObject.IsAnimated() ) + if( !xGraphicObject->IsAnimated() ) { // no animation - simply utilize plain draw shape import @@ -403,9 +403,9 @@ ShapeSharedPtr ShapeImporter::createShape( // --------------------------------------------- Graphic aGraphic( - aGraphicObject.GetTransformedGraphic( - aGraphicObject.GetPrefSize(), - aGraphicObject.GetPrefMapMode(), + xGraphicObject->GetTransformedGraphic( + xGraphicObject->GetPrefSize(), + xGraphicObject->GetPrefMapMode(), aGraphAttrs ) ); return DrawShape::create( xCurrShape, diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx index 5a286a9ca61e..fe2406927975 100644 --- a/svtools/source/graphic/grfmgr.cxx +++ b/svtools/source/graphic/grfmgr.cxx @@ -48,7 +48,7 @@ using com::sun::star::uno::RuntimeException; using com::sun::star::container::XNameContainer; using com::sun::star::beans::XPropertySet; -GraphicManager* GraphicObject::mpGlobalMgr = NULL; +GraphicManager* GraphicManager::mpGlobalManager = NULL; struct GrfSimpleCacheObj { @@ -81,7 +81,6 @@ GraphicObject::GraphicObject( const Graphic& rGraphic ) : } GraphicObject::GraphicObject( const GraphicObject& rGraphicObj ) : - SvDataCopyStream(), maGraphic ( rGraphicObj.GetGraphic() ), maAttr ( rGraphicObj.maAttr ), mpLink ( rGraphicObj.mpLink ? ( new String( *rGraphicObj.mpLink ) ) : NULL ), @@ -192,25 +191,24 @@ void GraphicObject::ImplAssignGraphicData() mnAnimationLoopCount = ( mbAnimated ? maGraphic.GetAnimationLoopCount() : 0 ); } -void GraphicObject::ImplSetup( const OString* pID ) +void GraphicManager::InitGlobal() { - GraphicManager *pGlobalMgr; + GraphicManager* pMgr = new GraphicManager( + (officecfg::Office::Common::Cache::GraphicManager:: + TotalCacheSize::get()), + (officecfg::Office::Common::Cache::GraphicManager:: + ObjectCacheSize::get())); + pMgr->SetCacheTimeout( + officecfg::Office::Common::Cache::GraphicManager:: + ObjectReleaseTime::get()); + GraphicManager::SetGlobalManager(pMgr); +} - if ( ! ( pGlobalMgr = GraphicManager::pGlobalManager ) ) - { - pGlobalMgr = new GraphicManager( - (officecfg::Office::Common::Cache::GraphicManager:: - TotalCacheSize::get()), - (officecfg::Office::Common::Cache::GraphicManager:: - ObjectCacheSize::get())); - pGlobalMgr->SetCacheTimeout( - officecfg::Office::Common::Cache::GraphicManager:: - ObjectReleaseTime::get()); - GraphicManager::pGlobalManager = pGlobalMgr; - } +void GraphicObject::ImplSetup( const OString* pID ) +{ // FIXME: remove this member in favour of the global eventually - mpMgr = pGlobalMgr; + mpMgr = GraphicManager::GetGlobalManager(); mpMgr->ImplRegisterObj( *this, maGraphic, pID ); } @@ -353,20 +351,10 @@ sal_Bool GraphicObject::operator==( const GraphicObject& rGraphicObj ) const ( rGraphicObj.GetLink() == GetLink() ) ); } -void GraphicObject::Load( SvStream& rIStm ) -{ - rIStm >> *this; -} - -void GraphicObject::Save( SvStream& rOStm ) -{ - rOStm << *this; -} - -void GraphicObject::Assign( const SvDataCopyStream& rCopyStream ) -{ - *this = (const GraphicObject& ) rCopyStream; -} +//void GraphicObject::Assign( const SvDataCopyStream& rCopyStream ) +//{ +// *this = (const GraphicObject& ) rCopyStream; +//} OString GraphicObject::GetUniqueID() const { @@ -1106,10 +1094,11 @@ GraphicObject::GraphicObject( SvStream& rIStm ) : else SetLink(); - SetSwapStreamHdl(); +// SetSwapStreamHdl(); } // FIXME: should we match the above create with a save method ? +/* SvStream& operator<<( SvStream& rOStm, const GraphicObject& rGraphicObj ) { VersionCompat aCompat( rOStm, STREAM_WRITE, 1 ); @@ -1122,6 +1111,7 @@ SvStream& operator<<( SvStream& rOStm, const GraphicObject& rGraphicObj ) return rOStm; } +*/ #define UNO_NAME_GRAPHOBJ_URLPREFIX "vnd.sun.star.GraphicObject:" @@ -1148,8 +1138,8 @@ rtl::Reference< GraphicObject > GraphicObject::CreateGraphicObjectFromURL( const } } -void -GraphicObject::InspectForGraphicObjectImageURL( const Reference< XInterface >& xIf, std::vector< OUString >& rvEmbedImgUrls ) +void GraphicObject::InspectForGraphicObjectImageURL( const Reference< XInterface >& xIf, + std::vector< OUString >& rvEmbedImgUrls ) { static OUString sImageURL( "ImageURL" ); Reference< XPropertySet > xProps( xIf, UNO_QUERY ); diff --git a/svx/source/core/extedit.cxx b/svx/source/core/extedit.cxx index bcc79e91a9cc..1f2edb8aff86 100644 --- a/svx/source/core/extedit.cxx +++ b/svx/source/core/extedit.cxx @@ -77,11 +77,12 @@ void ExternalToolEdit::threadWorker(void* pThreadData) xSystemShellExecute->execute( pData->m_aFileName, OUString(), SystemShellExecuteFlags::URIS_ONLY ); } -void ExternalToolEdit::Edit( GraphicObject* pGraphicObject ) +void ExternalToolEdit::Edit( rtl::Reference<GraphicObject> xGraphicObject ) { + assert(xGraphicObject.is()); //Get the graphic from the GraphicObject - m_pGraphicObject = pGraphicObject; - const Graphic aGraphic = pGraphicObject->GetGraphic(); + m_xGraphicObject = xGraphicObject; + const Graphic aGraphic = xGraphicObject->GetGraphic(); //get the Preferred File Extension for this graphic OUString fExtension; diff --git a/svx/source/dialog/grfflt.cxx b/svx/source/dialog/grfflt.cxx index 74ad3d111547..dc5f67492621 100644 --- a/svx/source/dialog/grfflt.cxx +++ b/svx/source/dialog/grfflt.cxx @@ -33,12 +33,11 @@ // - SvxGraphicFilter - // -------------------- -sal_uIntPtr SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObject& rFilterObject ) +sal_uIntPtr SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, Graphic** ppGraphic ) { - const Graphic& rGraphic = rFilterObject.GetGraphic(); sal_uIntPtr nRet = SVX_GRAPHICFILTER_UNSUPPORTED_GRAPHICTYPE; - - if( rGraphic.GetType() == GRAPHIC_BITMAP ) + Graphic* pGraphic = *ppGraphic; + if( pGraphic->GetType() == GRAPHIC_BITMAP ) { SfxViewFrame* pViewFrame = SfxViewFrame::Current(); SfxObjectShell* pShell = pViewFrame ? pViewFrame->GetObjectShell() : NULL; @@ -52,16 +51,16 @@ sal_uIntPtr SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObj if( pShell ) pShell->SetWaitCursor( sal_True ); - if( rGraphic.IsAnimated() ) + if( pGraphic->IsAnimated() ) { - Animation aAnimation( rGraphic.GetAnimation() ); + Animation aAnimation( pGraphic->GetAnimation() ); if( aAnimation.Invert() ) aGraphic = aAnimation; } else { - BitmapEx aBmpEx( rGraphic.GetBitmapEx() ); + BitmapEx aBmpEx( pGraphic->GetBitmapEx() ); if( aBmpEx.Invert() ) aGraphic = aBmpEx; @@ -77,10 +76,10 @@ sal_uIntPtr SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObj SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if(pFact) { - AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterSmooth( pWindow, rGraphic, 0.7, RID_SVX_GRFFILTER_DLG_SEPIA); + AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterSmooth( pWindow, *pGraphic, 0.7, RID_SVX_GRFFILTER_DLG_SEPIA); DBG_ASSERT(aDlg, "Dialogdiet fail!"); if( aDlg->Execute() == RET_OK ) - aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 ); + aGraphic = aDlg->GetFilteredGraphic( *pGraphic, 1.0, 1.0 ); delete aDlg; } } @@ -91,16 +90,16 @@ sal_uIntPtr SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObj if( pShell ) pShell->SetWaitCursor( sal_True ); - if( rGraphic.IsAnimated() ) + if( pGraphic->IsAnimated() ) { - Animation aAnimation( rGraphic.GetAnimation() ); + Animation aAnimation( pGraphic->GetAnimation() ); if( aAnimation.Filter( BMP_FILTER_SHARPEN ) ) aGraphic = aAnimation; } else { - BitmapEx aBmpEx( rGraphic.GetBitmapEx() ); + BitmapEx aBmpEx( pGraphic->GetBitmapEx() ); if( aBmpEx.Filter( BMP_FILTER_SHARPEN ) ) aGraphic = aBmpEx; @@ -116,16 +115,16 @@ sal_uIntPtr SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObj if( pShell ) pShell->SetWaitCursor( sal_True ); - if( rGraphic.IsAnimated() ) + if( pGraphic->IsAnimated() ) { - Animation aAnimation( rGraphic.GetAnimation() ); + Animation aAnimation( pGraphic->GetAnimation() ); if( aAnimation.Filter( BMP_FILTER_REMOVENOISE ) ) aGraphic = aAnimation; } else { - BitmapEx aBmpEx( rGraphic.GetBitmapEx() ); + BitmapEx aBmpEx( pGraphic->GetBitmapEx() ); if( aBmpEx.Filter( BMP_FILTER_REMOVENOISE ) ) aGraphic = aBmpEx; @@ -141,16 +140,16 @@ sal_uIntPtr SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObj if( pShell ) pShell->SetWaitCursor( sal_True ); - if( rGraphic.IsAnimated() ) + if( pGraphic->IsAnimated() ) { - Animation aAnimation( rGraphic.GetAnimation() ); + Animation aAnimation( pGraphic->GetAnimation() ); if( aAnimation.Filter( BMP_FILTER_SOBEL_GREY ) ) aGraphic = aAnimation; } else { - BitmapEx aBmpEx( rGraphic.GetBitmapEx() ); + BitmapEx aBmpEx( pGraphic->GetBitmapEx() ); if( aBmpEx.Filter( BMP_FILTER_SOBEL_GREY ) ) aGraphic = aBmpEx; @@ -166,10 +165,10 @@ sal_uIntPtr SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObj SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if(pFact) { - AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterMosaic( pWindow, rGraphic, 4, 4, sal_False, RID_SVX_GRFFILTER_DLG_MOSAIC); + AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterMosaic( pWindow, *pGraphic, 4, 4, sal_False, RID_SVX_GRFFILTER_DLG_MOSAIC); DBG_ASSERT(aDlg, "Dialogdiet fail!"); if( aDlg->Execute() == RET_OK ) - aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 ); + aGraphic = aDlg->GetFilteredGraphic( *pGraphic, 1.0, 1.0 ); delete aDlg; } } @@ -180,10 +179,10 @@ sal_uIntPtr SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObj SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if(pFact) { - AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterEmboss( pWindow, rGraphic, RP_MM, RID_SVX_GRFFILTER_DLG_EMBOSS ); + AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterEmboss( pWindow, *pGraphic, RP_MM, RID_SVX_GRFFILTER_DLG_EMBOSS ); DBG_ASSERT(aDlg, "Dialogdiet fail!"); if( aDlg->Execute() == RET_OK ) - aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 ); + aGraphic = aDlg->GetFilteredGraphic( *pGraphic, 1.0, 1.0 ); delete aDlg; } } @@ -194,10 +193,10 @@ sal_uIntPtr SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObj SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if(pFact) { - AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterPosterSepia( pWindow, rGraphic, 16, RID_SVX_GRFFILTER_DLG_POSTER ); + AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterPosterSepia( pWindow, *pGraphic, 16, RID_SVX_GRFFILTER_DLG_POSTER ); DBG_ASSERT(aDlg, "Dialogdiet fail!"); if( aDlg->Execute() == RET_OK ) - aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 ); + aGraphic = aDlg->GetFilteredGraphic( *pGraphic, 1.0, 1.0 ); delete aDlg; } } @@ -208,16 +207,16 @@ sal_uIntPtr SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObj if( pShell ) pShell->SetWaitCursor( sal_True ); - if( rGraphic.IsAnimated() ) + if( pGraphic->IsAnimated() ) { - Animation aAnimation( rGraphic.GetAnimation() ); + Animation aAnimation( pGraphic->GetAnimation() ); if( aAnimation.Filter( BMP_FILTER_POPART ) ) aGraphic = aAnimation; } else { - BitmapEx aBmpEx( rGraphic.GetBitmapEx() ); + BitmapEx aBmpEx( pGraphic->GetBitmapEx() ); if( aBmpEx.Filter( BMP_FILTER_POPART ) ) aGraphic = aBmpEx; @@ -233,10 +232,10 @@ sal_uIntPtr SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObj SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if(pFact) { - AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterPosterSepia( pWindow, rGraphic, 10, RID_SVX_GRFFILTER_DLG_SEPIA ); + AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterPosterSepia( pWindow, *pGraphic, 10, RID_SVX_GRFFILTER_DLG_SEPIA ); DBG_ASSERT(aDlg, "Dialogdiet fail!"); if( aDlg->Execute() == RET_OK ) - aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 ); + aGraphic = aDlg->GetFilteredGraphic( *pGraphic, 1.0, 1.0 ); delete aDlg; } } @@ -247,10 +246,10 @@ sal_uIntPtr SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObj SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if(pFact) { - AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterSolarize( pWindow, rGraphic, 128, sal_False, RID_SVX_GRFFILTER_DLG_SOLARIZE ); + AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterSolarize( pWindow, *pGraphic, 128, sal_False, RID_SVX_GRFFILTER_DLG_SOLARIZE ); DBG_ASSERT(aDlg, "Dialogdiet fail!"); if( aDlg->Execute() == RET_OK ) - aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 ); + aGraphic = aDlg->GetFilteredGraphic( *pGraphic, 1.0, 1.0 ); delete aDlg; } } @@ -273,7 +272,7 @@ sal_uIntPtr SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObj if( aGraphic.GetType() != GRAPHIC_NONE ) { - rFilterObject.SetGraphic( aGraphic ); + *ppGraphic = new Graphic(aGraphic); nRet = SVX_GRAPHICFILTER_ERRCODE_NONE; } } diff --git a/svx/source/gallery2/galbrws2.cxx b/svx/source/gallery2/galbrws2.cxx index 7ac642535826..853220201aa0 100644 --- a/svx/source/gallery2/galbrws2.cxx +++ b/svx/source/gallery2/galbrws2.cxx @@ -804,7 +804,7 @@ void GalleryBrowser2::SetMode( GalleryBrowserMode eMode ) mpListView->Hide(); mpPreview->Hide(); - mpPreview->SetGraphic( Graphic() ); + mpPreview->ClearGraphic(); mpPreview->PreviewMedia( INetURLObject() ); mpIconView->Show(); @@ -822,7 +822,7 @@ void GalleryBrowser2::SetMode( GalleryBrowserMode eMode ) mpIconView->Hide(); mpPreview->Hide(); - mpPreview->SetGraphic( Graphic() ); + mpPreview->ClearGraphic(); mpPreview->PreviewMedia( INetURLObject() ); mpListView->Show(); @@ -852,7 +852,7 @@ void GalleryBrowser2::SetMode( GalleryBrowserMode eMode ) mpCurTheme->GetGraphic( nPos, aGraphic ); mpPreview->SetGraphic( aGraphic ); - mpPreview->Show(); + mpPreview->Show(); if( mpCurTheme && mpCurTheme->GetObjectKind( nPos ) == SGA_OBJ_SOUND ) mpPreview->PreviewMedia( mpCurTheme->GetObjectURL( nPos ) ); diff --git a/svx/source/gallery2/galctrl.cxx b/svx/source/gallery2/galctrl.cxx index 8aa10e90bb32..a730371466a3 100644 --- a/svx/source/gallery2/galctrl.cxx +++ b/svx/source/gallery2/galctrl.cxx @@ -49,7 +49,7 @@ GalleryPreview::GalleryPreview( GalleryBrowser2* pParent, GalleryTheme* pTheme ) SetHelpId( HID_GALLERY_WINDOW ); InitSettings(); - mxGraphicObj = GraphicObject::Create(); + mxGraphicObj = rtl::Reference< GraphicObject >(); } GalleryPreview::GalleryPreview( Window* pParent, const ResId & rResId ) : @@ -62,7 +62,7 @@ GalleryPreview::GalleryPreview( Window* pParent, const ResId & rResId ) : SetHelpId( HID_GALLERY_PREVIEW ); InitSettings(); - mxGraphicObj = GraphicObject::Create(); + mxGraphicObj = rtl::Reference< GraphicObject >(); } GalleryPreview::~GalleryPreview() @@ -70,6 +70,11 @@ GalleryPreview::~GalleryPreview() DBG_DTOR(GalleryPreview,NULL); } +bool GalleryPreview::SetGraphic( Graphic& rGraphic ) +{ + mxGraphicObj = GraphicObject::Create(rGraphic); + return true; +}; bool GalleryPreview::SetGraphic( const INetURLObject& _aURL ) { @@ -86,12 +91,16 @@ bool GalleryPreview::SetGraphic( const INetURLObject& _aURL ) if( rFilter.ImportGraphic( aGraphic, _aURL, GRFILTER_FORMAT_DONTKNOW ) ) bRet = false; } - - SetGraphic( aGraphic ); + mxGraphicObj = GraphicObject::Create(aGraphic); Invalidate(); return bRet; } +void GalleryPreview::ClearGraphic() +{ + mxGraphicObj.clear(); +} + void GalleryPreview::InitSettings() { SetBackground( Wallpaper( GALLERY_BG_COLOR ) ); @@ -143,16 +152,18 @@ sal_Bool GalleryPreview::ImplGetGraphicCenterRect( const Graphic& rGraphic, Rect void GalleryPreview::Paint( const Rectangle& rRect ) { Window::Paint( rRect ); - - if( ImplGetGraphicCenterRect( mxGraphicObj->GetGraphic(), maPreviewRect ) ) + if(mxGraphicObj.is()) { - const Point aPos( maPreviewRect.TopLeft() ); - const Size aSize( maPreviewRect.GetSize() ); + if( ImplGetGraphicCenterRect( mxGraphicObj->GetGraphic(), maPreviewRect ) ) + { + const Point aPos( maPreviewRect.TopLeft() ); + const Size aSize( maPreviewRect.GetSize() ); - if( mxGraphicObj->IsAnimated() ) - mxGraphicObj->StartAnimation( this, aPos, aSize ); - else - mxGraphicObj->Draw( this, aPos, aSize ); + if( mxGraphicObj->IsAnimated() ) + mxGraphicObj->StartAnimation( this, aPos, aSize ); + else + mxGraphicObj->Draw( this, aPos, aSize ); + } } } diff --git a/svx/source/sdr/contact/viewcontactofgraphic.cxx b/svx/source/sdr/contact/viewcontactofgraphic.cxx index 03434b82eed5..04d2c7d85f69 100644 --- a/svx/source/sdr/contact/viewcontactofgraphic.cxx +++ b/svx/source/sdr/contact/viewcontactofgraphic.cxx @@ -87,7 +87,7 @@ namespace sdr const GraphicAttr& rLocalGrafInfo) const { drawinglayer::primitive2d::Primitive2DSequence xRetval; - rtl::Reference< GraphicObject > xEmptyGraphicObject = GraphicObject::Create(); + rtl::Reference< GraphicObject > xEmptyGraphicObject= rtl::Reference< GraphicObject >(); GraphicAttr aEmptyGraphicAttr; // SdrGrafPrimitive2D without content in original size which carries all eventual attributes and texts @@ -150,7 +150,7 @@ namespace sdr const drawinglayer::attribute::SdrLineFillShadowTextAttribute& rAttribute) const { drawinglayer::primitive2d::Primitive2DSequence xRetval; - rtl::Reference< GraphicObject > xEmptyGraphicObject = GraphicObject::Create(); + rtl::Reference< GraphicObject > xEmptyGraphicObject = rtl::Reference< GraphicObject >(); GraphicAttr aEmptyGraphicAttr; // SdrGrafPrimitive2D without content in original size which carries all eventual attributes and texts diff --git a/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx index d6cdd21093a1..693ab6111bcc 100644 --- a/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx +++ b/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx @@ -146,9 +146,9 @@ namespace drawinglayer const SdrGrafPrimitive2D& rCompare = (SdrGrafPrimitive2D&)rPrimitive; return (getTransform() == rCompare.getTransform() - && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute() - && getGraphicObject() == rCompare.getGraphicObject() - && getGraphicAttr() == rCompare.getGraphicAttr()); + && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute() + && getGraphicObject() == rCompare.getGraphicObject() + && getGraphicAttr() == rCompare.getGraphicAttr()); } return false; @@ -157,7 +157,7 @@ namespace drawinglayer bool SdrGrafPrimitive2D::isTransparent() const { return ((0L != getGraphicAttr().GetTransparency()) - || (getGraphicObject()->IsTransparent())); + || (getGraphicObject().is() && getGraphicObject()->IsTransparent())); } // provide unique ID diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx index 0c596b08f9ee..e20bb77fd8bc 100644 --- a/svx/source/svdraw/svdoashp.cxx +++ b/svx/source/svdraw/svdoashp.cxx @@ -379,16 +379,16 @@ SdrObject* ImpCreateShadowObjectClone(const SdrObject& rOriginal, const SfxItemS { if(aBitmapEx.IsAlpha()) { - xGraphicObject->SetGraphic(Graphic(BitmapEx(aDestBitmap, aBitmapEx.GetAlpha()))); + xGraphicObject = GraphicObject::Create(Graphic(BitmapEx(aDestBitmap, aBitmapEx.GetAlpha()))); } else { - xGraphicObject->SetGraphic(Graphic(BitmapEx(aDestBitmap, aBitmapEx.GetMask()))); + xGraphicObject = GraphicObject::Create(Graphic(BitmapEx(aDestBitmap, aBitmapEx.GetMask()))); } } else { - xGraphicObject->SetGraphic(Graphic(aDestBitmap)); + xGraphicObject = GraphicObject::Create(Graphic(aDestBitmap)); } } } diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index 6bd84069f23c..d51ef7adec44 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -331,7 +331,7 @@ SdrGrafObj::SdrGrafObj() pGraphicLink ( NULL ), bMirrored ( false ) { - mxGraphic = GraphicObject::Create(); + mxGraphic = rtl::Reference<GraphicObject>(); mxGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), SWAPGRAPHIC_TIMEOUT ); onGraphicChanged(); @@ -437,7 +437,7 @@ rtl::Reference< GraphicObject > SdrGrafObj::GetReplacementGraphicObject() const void SdrGrafObj::NbcSetGraphic( const Graphic& rGrf ) { - mxGraphic->SetGraphic( rGrf ); + mxGraphic = GraphicObject::Create( rGrf ); mxReplacementGraphic.clear(); mxGraphic->SetUserData(); mbIsPreview = false; @@ -551,30 +551,27 @@ String SdrGrafObj::GetGrafStreamURL() const void SdrGrafObj::ForceSwapIn() const { - if( mbIsPreview ) + if(mxGraphic.is()) { - // removing preview graphic - const String aUserData( mxGraphic->GetUserData() ); - - Graphic aEmpty; - mxGraphic->SetGraphic( aEmpty ); - mxGraphic->SetUserData( aUserData ); - mxGraphic->SetSwapState(); - - const_cast< SdrGrafObj* >( this )->mbIsPreview = false; - } - if ( pGraphicLink && mxGraphic->IsSwappedOut() ) - ImpUpdateGraphicLink( false ); - else - mxGraphic->FireSwapInRequest(); + if( mbIsPreview ) + { + // removing preview graphic + mxGraphic->SetSwapState(); + const_cast< SdrGrafObj* >( this )->mbIsPreview = false; + } + if ( pGraphicLink && mxGraphic->IsSwappedOut() ) + ImpUpdateGraphicLink( false ); + else + mxGraphic->FireSwapInRequest(); - if( mxGraphic->IsSwappedOut() || - ( mxGraphic->GetType() == GRAPHIC_NONE ) || - ( mxGraphic->GetType() == GRAPHIC_DEFAULT ) ) - { - Graphic aDefaultGraphic; - aDefaultGraphic.SetDefaultType(); - mxGraphic->SetGraphic( aDefaultGraphic ); + if( mxGraphic->IsSwappedOut() || + ( mxGraphic->GetType() == GRAPHIC_NONE ) || + ( mxGraphic->GetType() == GRAPHIC_DEFAULT ) ) + { + Graphic aDefaultGraphic; + aDefaultGraphic.SetDefaultType(); + mxGraphic = GraphicObject::Create(aDefaultGraphic); + } } } @@ -838,7 +835,7 @@ SdrGrafObj& SdrGrafObj::operator=( const SdrGrafObj& rObj ) return *this; SdrRectObj::operator=( rObj ); - mxGraphic->SetGraphic( rObj.GetGraphic(), rObj.GetGraphicObject() ); + mxGraphic = GraphicObject::Create(rObj.GetGraphic()); aFileName = rObj.aFileName; aFilterName = rObj.aFilterName; bMirrored = rObj.bMirrored; @@ -1170,7 +1167,7 @@ SdrObject* SdrGrafObj::DoConvertToPolyObj(sal_Bool bBezier, bool bAddText ) cons SfxItemSet aSet(GetObjectItemSet()); aSet.Put(XFillStyleItem(XFILL_BITMAP)); - aSet.Put(XFillBitmapItem(GetTransformedGraphic().GetBitmapEx()); + aSet.Put(XFillBitmapItem(GetTransformedGraphic().GetBitmapEx())); aSet.Put(XFillBmpTileItem(false)); pRetval->SetMergedItemSet(aSet); @@ -1356,7 +1353,7 @@ IMPL_LINK( SdrGrafObj, ImpSwapHdl, GraphicObject*, pO ) { const String aNewUserData( mxGraphic->GetUserData() ); - mxGraphic->SetGraphic( aGraphic ); + mxGraphic = GraphicObject::Create(aGraphic); mxGraphic->SetUserData( aNewUserData ); // Graphic successfully swapped in. diff --git a/sw/inc/IDocumentContentOperations.hxx b/sw/inc/IDocumentContentOperations.hxx index 6f0bf4067b53..75ccb341fdbe 100644 --- a/sw/inc/IDocumentContentOperations.hxx +++ b/sw/inc/IDocumentContentOperations.hxx @@ -17,10 +17,11 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - #ifndef IDOCUMENTCONTENTOPERATIONS_HXX_INCLUDED - #define IDOCUMENTCONTENTOPERATIONS_HXX_INCLUDED +#ifndef IDOCUMENTCONTENTOPERATIONS_HXX_INCLUDED +#define IDOCUMENTCONTENTOPERATIONS_HXX_INCLUDED - #include <sal/types.h> +#include <sal/types.h> +#include <rtl/ref.hxx> class SwPaM; struct SwPosition; @@ -115,7 +116,7 @@ virtual SwFlyFrmFmt* Insert(const SwPaM &rRg, const String& rGrfName, const String& rFltName, const Graphic* pGraphic, const SfxItemSet* pFlyAttrSet, const SfxItemSet* pGrfAttrSet, SwFrmFmt*) = 0; - virtual SwFlyFrmFmt* Insert(const SwPaM& rRg, const GraphicObject& rGrfObj, const SfxItemSet* pFlyAttrSet, + virtual SwFlyFrmFmt* Insert(const SwPaM& rRg, rtl::Reference< GraphicObject> xGrfObj, const SfxItemSet* pFlyAttrSet, const SfxItemSet* pGrfAttrSet, SwFrmFmt*) = 0; /** Transpose graphic (with undo) diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 854b86992bae..4b16a93881a1 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -868,7 +868,7 @@ public: virtual bool UpdateRsid( const SwPaM &rRg, xub_StrLen nLen ); virtual SwFlyFrmFmt* Insert(const SwPaM &rRg, const String& rGrfName, const String& rFltName, const Graphic* pGraphic, const SfxItemSet* pFlyAttrSet, const SfxItemSet* pGrfAttrSet, SwFrmFmt*); - virtual SwFlyFrmFmt* Insert(const SwPaM& rRg, const GraphicObject& rGrfObj, const SfxItemSet* pFlyAttrSet, + virtual SwFlyFrmFmt* Insert(const SwPaM& rRg, rtl::Reference< GraphicObject> xGrfObj, const SfxItemSet* pFlyAttrSet, const SfxItemSet* pGrfAttrSet, SwFrmFmt*); virtual SwDrawFrmFmt* Insert(const SwPaM &rRg, SdrObject& rDrawObj, const SfxItemSet* pFlyAttrSet, SwFrmFmt*); virtual SwFlyFrmFmt* Insert(const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj, const SfxItemSet* pFlyAttrSet, diff --git a/sw/inc/ndarr.hxx b/sw/inc/ndarr.hxx index 4acccc34125f..d662e5b92090 100644 --- a/sw/inc/ndarr.hxx +++ b/sw/inc/ndarr.hxx @@ -23,7 +23,7 @@ #include <vector> #include <boost/utility.hpp> - +#include <rtl/ref.hxx> #include <com/sun/star/embed/XEmbeddedObject.hpp> #include <svtools/embedhlp.hxx> @@ -231,7 +231,7 @@ public: sal_Bool bDelayed = sal_False ); ///< in ndgrf.cxx SwGrfNode *MakeGrfNode( const SwNodeIndex & rWhere, - const GraphicObject& rGrfObj, + rtl::Reference<GraphicObject> xGrfObj, SwGrfFmtColl *pColl, SwAttrSet* pAutoAttr = 0 ); ///< in ndgrf.cxx diff --git a/sw/inc/ndgrf.hxx b/sw/inc/ndgrf.hxx index e970615e9fe8..99eb35552217 100644 --- a/sw/inc/ndgrf.hxx +++ b/sw/inc/ndgrf.hxx @@ -37,8 +37,8 @@ class SW_DLLPUBLIC SwGrfNode: public SwNoTxtNode { friend class SwNodes; - GraphicObject maGrfObj; - GraphicObject *mpReplacementGraphic; + rtl::Reference<GraphicObject> mxGrfObj; + rtl::Reference<GraphicObject> mxReplacementGraphic; ::sfx2::SvBaseLinkRef refLink; ///< If graphics only as link then pointer is set. Size nGrfSize; String aNewStrmName; /**< SW3/XML: new stream name (either SW3 stream @@ -70,13 +70,13 @@ class SW_DLLPUBLIC SwGrfNode: public SwNoTxtNode SwGrfFmtColl* pGrfColl, SwAttrSet* pAutoAttr = 0 ); SwGrfNode( const SwNodeIndex& rWhere, - const GraphicObject& rGrfObj, + rtl::Reference<GraphicObject> xGrfObj, SwGrfFmtColl* pGrfColl, SwAttrSet* pAutoAttr = 0 ); void InsertLink( const String& rGrfName, const String& rFltName ); sal_Bool ImportGraphic( SvStream& rStrm ); - sal_Bool HasStreamName() const { return maGrfObj.HasUserData(); } + sal_Bool HasStreamName() const { return mxGrfObj.is() && mxGrfObj->HasUserData(); } /** adjust return type and rename method to indicate that its an private one. */ @@ -85,7 +85,7 @@ class SW_DLLPUBLIC SwGrfNode: public SwNoTxtNode void _GetStreamStorageNames( String& rStrmName, String& rStgName ) const; void DelStreamName(); - DECL_LINK( SwapGraphic, GraphicObject* ); + DECL_LINK( SwapGraphic, const GraphicObject* ); /** helper method to determine stream for the embedded graphic. @@ -128,19 +128,19 @@ class SW_DLLPUBLIC SwGrfNode: public SwNoTxtNode public: virtual ~SwGrfNode(); - const Graphic& GetGrf() const { return maGrfObj.GetGraphic(); } - const GraphicObject& GetGrfObj() const { return maGrfObj; } - const GraphicObject* GetReplacementGrfObj() const; + const Graphic& GetGrf() const { return mxGrfObj->GetGraphic(); } + rtl::Reference<GraphicObject> GetGrfObj() const { return mxGrfObj; } + const GraphicObject* GetReplacementGrfObj() const; virtual SwCntntNode *SplitCntntNode( const SwPosition & ); /// isolated only way to set GraphicObject to allow more actions when doing so void SetGraphic(const Graphic& rGraphic, const String& rLink); /// wrappers for non-const calls at GraphicObject - void ReleaseGraphicFromCache() { maGrfObj.ReleaseFromCache(); } - void DrawGraphicWithPDFHandling(OutputDevice& rOutDev, const Point& rPt, const Size& rSz, const GraphicAttr* pGrfAttr = NULL, const sal_uLong nFlags = GRFMGR_DRAW_STANDARD) { maGrfObj.DrawWithPDFHandling(rOutDev, rPt, rSz, pGrfAttr, nFlags); } - void StartGraphicAnimation(OutputDevice* pOut, const Point& rPt, const Size& rSz, long nExtraData = 0, const GraphicAttr* pAttr = NULL, sal_uLong nFlags = GRFMGR_DRAW_STANDARD, OutputDevice* pFirstFrameOutDev = NULL) { maGrfObj.StartAnimation(pOut, rPt, rSz, nExtraData, pAttr, nFlags, pFirstFrameOutDev); } - void StopGraphicAnimation(OutputDevice* pOut = NULL, long nExtraData = 0) { maGrfObj.StopAnimation(pOut, nExtraData); } + void ReleaseGraphicFromCache() { /*FIXME : maGrfObj.ReleaseFromCache(); */ } + void DrawGraphicWithPDFHandling(OutputDevice& rOutDev, const Point& rPt, const Size& rSz, const GraphicAttr* pGrfAttr = NULL, const sal_uLong nFlags = GRFMGR_DRAW_STANDARD) { mxGrfObj->DrawWithPDFHandling(rOutDev, rPt, rSz, pGrfAttr, nFlags); } + void StartGraphicAnimation(OutputDevice* pOut, const Point& rPt, const Size& rSz, long nExtraData = 0, const GraphicAttr* pAttr = NULL, sal_uLong nFlags = GRFMGR_DRAW_STANDARD, OutputDevice* pFirstFrameOutDev = NULL) { mxGrfObj->StartAnimation(pOut, rPt, rSz, nExtraData, pAttr, nFlags, pFirstFrameOutDev); } + void StopGraphicAnimation(OutputDevice* pOut = NULL, long nExtraData = 0) { mxGrfObj->StopAnimation(pOut, nExtraData); } /// allow reaction on change of content of GraphicObject, so always call /// when GraphicObject content changes @@ -152,7 +152,7 @@ public: sal_Bool IsTransparent() const; - inline sal_Bool IsAnimated() const { return maGrfObj.IsAnimated(); } + inline sal_Bool IsAnimated() const { return mxGrfObj.is() && mxGrfObj->IsAnimated(); } inline sal_Bool IsChgTwipSize() const { return bChgTwipSize; } inline sal_Bool IsChgTwipSizeFromPixel() const { return bChgTwipSizeFromPixel; } @@ -174,15 +174,15 @@ public: /** Re-read in case graphic was not OK. The current one gets replaced by the new one. */ sal_Bool ReRead( const String& rGrfName, const String& rFltName, - const Graphic* pGraphic = 0, - const GraphicObject* pGrfObj = 0, - sal_Bool bModify = sal_True ); + const Graphic* pGraphic = 0, + const GraphicObject* pGrfObj = 0, + sal_Bool bModify = sal_True ); /// Loading of graphic immediately before displaying. short SwapIn( sal_Bool bWaitForData = sal_False ); /// Remove graphic in order to free memory. short SwapOut(); /// Access to storage stream-name. - void SetStreamName( const String& r ) { maGrfObj.SetUserData( r ); } + void SetStreamName( const String& r ) { mxGrfObj->SetUserData( r ); } void SetNewStreamName( const String& r ) { aNewStrmName = r; } /// Is this node selected by any shell? sal_Bool IsSelected() const; diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 4840727cb3a9..2d08be457651 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1043,7 +1043,7 @@ SwFlyFrmFmt* SwDoc::Insert( const SwPaM &rRg, return pSwFlyFrmFmt; } -SwFlyFrmFmt* SwDoc::Insert( const SwPaM &rRg, const GraphicObject& rGrfObj, +SwFlyFrmFmt* SwDoc::Insert( const SwPaM &rRg, rtl::Reference<GraphicObject> xGrfObj, const SfxItemSet* pFlyAttrSet, const SfxItemSet* pGrfAttrSet, SwFrmFmt* pFrmFmt ) @@ -1052,7 +1052,7 @@ SwFlyFrmFmt* SwDoc::Insert( const SwPaM &rRg, const GraphicObject& rGrfObj, pFrmFmt = GetFrmFmtFromPool( RES_POOLFRM_GRAPHIC ); SwGrfNode* pSwGrfNode = GetNodes().MakeGrfNode( SwNodeIndex( GetNodes().GetEndOfAutotext() ), - rGrfObj, mpDfltGrfFmtColl ); + xGrfObj, mpDfltGrfFmtColl ); SwFlyFrmFmt* pSwFlyFrmFmt = _InsNoTxtNode( *rRg.GetPoint(), pSwGrfNode, pFlyAttrSet, pGrfAttrSet, pFrmFmt ); pSwGrfNode->onGraphicChanged(); diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index ee0565fc52a6..39c091268afc 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -570,7 +570,7 @@ void SwNoTxtFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) if( pVSh ) { GraphicAttr aAttr; - if( pNd->GetGrfObj().IsCached( pVSh->GetOut(), Point(), + if( pNd->GetGrfObj()->IsCached( pVSh->GetOut(), Point(), Prt().SSize(), &pNd->GetGraphicAttr( aAttr, this ) )) { ViewShell *pSh = pVSh; @@ -828,7 +828,7 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons } bool bForceSwap = false, bContinue = true; - const GraphicObject& rGrfObj = pGrfNd->GetGrfObj(); + rtl::Reference<GraphicObject> xGrfObj = pGrfNd->GetGrfObj(); GraphicAttr aGrfAttr; pGrfNd->GetGraphicAttr( aGrfAttr, this ); @@ -842,8 +842,8 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons } // #i85717#, #i90395# - check, if asynchronous retrieval // if input stream for the graphic is possible - else if ( ( rGrfObj.GetType() == GRAPHIC_DEFAULT || - rGrfObj.GetType() == GRAPHIC_NONE ) && + else if ( (xGrfObj->GetType() == GRAPHIC_DEFAULT || + xGrfObj->GetType() == GRAPHIC_NONE ) && pGrfNd->IsLinkedFile() && pGrfNd->IsAsyncRetrieveInputStreamPossible() ) { @@ -862,8 +862,8 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons ::lcl_PaintReplacement( aAlignedGrfArea, aTxt, *pShell, this, false ); bContinue = false; } - else if( rGrfObj.IsCached( pOut, aAlignedGrfArea.Pos(), - aAlignedGrfArea.SSize(), &aGrfAttr )) + else if( xGrfObj->IsCached( pOut, aAlignedGrfArea.Pos(), + aAlignedGrfArea.SSize(), &aGrfAttr )) { pGrfNd->DrawGraphicWithPDFHandling(*pOut, aAlignedGrfArea.Pos(), aAlignedGrfArea.SSize(), @@ -874,11 +874,11 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons if( bContinue ) { - const sal_Bool bSwapped = rGrfObj.IsSwappedOut(); + const sal_Bool bSwapped = xGrfObj->IsSwappedOut(); const bool bSwappedIn = 0 != pGrfNd->SwapIn( bPrn ); - if( bSwappedIn && rGrfObj.GetGraphic().IsSupportedGraphic()) + if( bSwappedIn && xGrfObj->GetGraphic().IsSupportedGraphic()) { - const bool bAnimate = rGrfObj.IsAnimated() && + const bool bAnimate = xGrfObj->IsAnimated() && !pShell->IsPreView() && !pShell->GetAccessibilityOptions()->IsStopAnimatedGraphics() && // #i9684# Stop animation during printing/pdf export @@ -906,7 +906,7 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons } else { - const SvgDataPtr& rSvgDataPtr = rGrfObj.GetGraphic().getSvgData(); + const SvgDataPtr& rSvgDataPtr = xGrfObj->GetGraphic().getSvgData(); bool bDone(false); if(rSvgDataPtr.get()) @@ -933,7 +933,7 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons if(bNeedTransformedGraphic) { // #i122039# need to apply graphic transformation if GraphicAttr are used qwhich need this - const Graphic aTransformedGraphic(rGrfObj.GetTransformedGraphic(&aSuppressGraphicAttr)); + const Graphic aTransformedGraphic(xGrfObj->GetTransformedGraphic(&aSuppressGraphicAttr)); const basegfx::B2DRange aRange(rSvgDataPtr->getRange()); const basegfx::B2DHomMatrix aTransform( basegfx::tools::createScaleTranslateB2DHomMatrix( @@ -975,9 +975,9 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons sal_uInt16 nResId = 0; if( bSwappedIn ) { - if( GRAPHIC_NONE == rGrfObj.GetType() ) + if( GRAPHIC_NONE == xGrfObj->GetType() ) nResId = STR_COMCORE_READERROR; - else if ( !rGrfObj.GetGraphic().IsSupportedGraphic() ) + else if ( !xGrfObj->GetGraphic().IsSupportedGraphic() ) nResId = STR_COMCORE_CANT_SHOW; } ((SwNoTxtFrm*)this)->nWeight = -1; diff --git a/sw/source/core/docnode/swbaslnk.cxx b/sw/source/core/docnode/swbaslnk.cxx index ae8ed8a5cde5..c14766c5bcab 100644 --- a/sw/source/core/docnode/swbaslnk.cxx +++ b/sw/source/core/docnode/swbaslnk.cxx @@ -137,7 +137,7 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem ) { SwGrfNode* pSwGrfNode = dynamic_cast< SwGrfNode* >(pCntntNode); OSL_ENSURE(pSwGrfNode, "Error, pSwGrfNode expected when node answers IsGrfNode() with true (!)"); - const GraphicObject& rGrfObj = pSwGrfNode->GetGrfObj(); + const GraphicObject* pGrfObj = pSwGrfNode->GetGrfObj().get(); bDontNotify = pSwGrfNode->IsFrameInPaint(); @@ -148,7 +148,7 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem ) Graphic aGrf; if( sfx2::LinkManager::GetGraphicFromAny( rMimeType, rValue, aGrf ) && ( GRAPHIC_DEFAULT != aGrf.GetType() || - GRAPHIC_DEFAULT != rGrfObj.GetType() ) ) + (pGrfObj && GRAPHIC_DEFAULT != pGrfObj->GetType()) ) ) { aGrfSz = ::GetGraphicSizeTwip( aGrf, 0 ); if( pSwGrfNode->IsChgTwipSizeFromPixel() ) @@ -175,7 +175,7 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem ) bGraphicPieceArrived = sal_False; } - pSwGrfNode->SetGraphic(aGrf, rGrfObj.GetLink()); + pSwGrfNode->SetGraphic(aGrf, pGrfObj ? pGrfObj->GetLink() : String()); bUpdate = true; // In order for the Node to have the right transparency status @@ -246,7 +246,7 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem ) if( pBLink != this && ( !bSwapIn || - GRAPHIC_DEFAULT == pGrfNd->GetGrfObj().GetType())) + GRAPHIC_DEFAULT == pGrfNd->GetGrfObj()->GetType())) { pBLink->bIgnoreDataChanged = sal_False; pBLink->DataChanged( rMimeType, rValue ); diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx index c49cb15fd4e3..c17f9890b084 100644 --- a/sw/source/core/edit/editsh.cxx +++ b/sw/source/core/edit/editsh.cxx @@ -265,21 +265,21 @@ sal_Bool SwEditShell::IsGrfSwapOut( sal_Bool bOnlyLinked ) const SwGrfNode *pGrfNode = _GetGrfNode(); return pGrfNode && (bOnlyLinked ? ( pGrfNode->IsLinkedFile() && - ( GRAPHIC_DEFAULT == pGrfNode->GetGrfObj().GetType()|| - pGrfNode->GetGrfObj().IsSwappedOut())) - : pGrfNode->GetGrfObj().IsSwappedOut()); + ( GRAPHIC_DEFAULT == pGrfNode->GetGrfObj()->GetType()|| + pGrfNode->GetGrfObj()->IsSwappedOut())) + : pGrfNode->GetGrfObj()->IsSwappedOut()); } const GraphicObject* SwEditShell::GetGraphicObj() const { SwGrfNode* pGrfNode = _GetGrfNode(); - return pGrfNode ? &(pGrfNode->GetGrfObj()) : 0L; + return pGrfNode ? pGrfNode->GetGrfObj().get() : 0L; } sal_uInt16 SwEditShell::GetGraphicType() const { SwGrfNode *pGrfNode = _GetGrfNode(); - return static_cast<sal_uInt16>(pGrfNode ? pGrfNode->GetGrfObj().GetType() : GRAPHIC_NONE); + return static_cast<sal_uInt16>(pGrfNode ? pGrfNode->GetGrfObj()->GetType() : GRAPHIC_NONE); } // returns the size of a graphic in <rSz> if CurCrsr->GetPoint() points to a SwGrfNode and diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx index e874282930f8..09449a0cfd3a 100644 --- a/sw/source/core/graphic/ndgrf.cxx +++ b/sw/source/core/graphic/ndgrf.cxx @@ -62,33 +62,33 @@ SwGrfNode::SwGrfNode( SwGrfFmtColl *pGrfColl, SwAttrSet* pAutoAttr ) : SwNoTxtNode( rWhere, ND_GRFNODE, pGrfColl, pAutoAttr ), - maGrfObj(), - mpReplacementGraphic(0), + mxGrfObj(), + mxReplacementGraphic(), // #i73788# mbLinkedInputStreamReady( false ), mbIsStreamReadOnly( sal_False ) { - maGrfObj.SetSwapStreamHdl( LINK( this, SwGrfNode, SwapGraphic ) ); bInSwapIn = bChgTwipSize = bChgTwipSizeFromPixel = bLoadLowResGrf = bFrameInPaint = bScaleImageMap = sal_False; bGrafikArrived = sal_True; - ReRead(rGrfName,rFltName, pGraphic, 0, sal_False); + ReRead(rGrfName,rFltName, pGraphic, mxGrfObj.is() ? mxGrfObj.get() : NULL, sal_False); + mxGrfObj->SetSwapStreamHdl( LINK( this, SwGrfNode, SwapGraphic ) ); } SwGrfNode::SwGrfNode( const SwNodeIndex & rWhere, - const GraphicObject& rGrfObj, + const rtl::Reference<GraphicObject> xGrfObj, SwGrfFmtColl *pGrfColl, SwAttrSet* pAutoAttr ) : SwNoTxtNode( rWhere, ND_GRFNODE, pGrfColl, pAutoAttr ), - maGrfObj(rGrfObj), - mpReplacementGraphic(0), + mxGrfObj(xGrfObj), + mxReplacementGraphic(), // #i73788# mbLinkedInputStreamReady( false ), mbIsStreamReadOnly( sal_False ) { - maGrfObj.SetSwapStreamHdl( LINK( this, SwGrfNode, SwapGraphic ) ); - if( rGrfObj.HasUserData() && rGrfObj.IsSwappedOut() ) - maGrfObj.SetSwapState(); + mxGrfObj->SetSwapStreamHdl( LINK( this, SwGrfNode, SwapGraphic ) ); + if( xGrfObj->HasUserData() && xGrfObj->IsSwappedOut() ) + mxGrfObj->SetSwapState(); bInSwapIn = bChgTwipSize = bChgTwipSizeFromPixel= bLoadLowResGrf = bFrameInPaint = bScaleImageMap = sal_False; bGrafikArrived = sal_True; @@ -105,16 +105,17 @@ SwGrfNode::SwGrfNode( const SwNodeIndex & rWhere, SwGrfFmtColl *pGrfColl, SwAttrSet* pAutoAttr ) : SwNoTxtNode( rWhere, ND_GRFNODE, pGrfColl, pAutoAttr ), - maGrfObj(), - mpReplacementGraphic(0), + mxGrfObj(), + mxReplacementGraphic(), // #i73788# mbLinkedInputStreamReady( false ), mbIsStreamReadOnly( sal_False ) { - maGrfObj.SetSwapStreamHdl( LINK( this, SwGrfNode, SwapGraphic ) ); Graphic aGrf; aGrf.SetDefaultType(); - maGrfObj.SetGraphic( aGrf, rGrfName ); + mxGrfObj = GraphicObject::Create( aGrf ); + mxGrfObj->SetLink(rGrfName ); + mxGrfObj->SetSwapStreamHdl( LINK( this, SwGrfNode, SwapGraphic ) ); bInSwapIn = bChgTwipSize = bChgTwipSizeFromPixel = bLoadLowResGrf = bFrameInPaint = bScaleImageMap = sal_False; @@ -139,10 +140,9 @@ sal_Bool SwGrfNode::ReRead( sal_Bool bNewGrf ) { sal_Bool bReadGrf = sal_False, bSetTwipSize = sal_True; - delete mpReplacementGraphic; - mpReplacementGraphic = 0; + mxReplacementGraphic.clear(); - OSL_ENSURE( pGraphic || pGrfObj || rGrfName.Len(), + OSL_ENSURE( pGraphic || rGrfName.Len(), "GraphicNode without a name, Graphic or GraphicObject" ); // with name @@ -182,16 +182,17 @@ sal_Bool SwGrfNode::ReRead( if( pGraphic ) { - maGrfObj.SetGraphic( *pGraphic, rGrfName ); + mxGrfObj = GraphicObject::Create( *pGraphic ); + mxGrfObj->SetLink(rGrfName ); onGraphicChanged(); bReadGrf = sal_True; } - else if( pGrfObj ) + else if( pGrfObj) { - maGrfObj = *pGrfObj; + mxGrfObj = GraphicObject::Create(*pGrfObj); if( pGrfObj->HasUserData() && pGrfObj->IsSwappedOut() ) - maGrfObj.SetSwapState(); - maGrfObj.SetLink( rGrfName ); + mxGrfObj->SetSwapState(); + mxGrfObj->SetLink( rGrfName ); onGraphicChanged(); bReadGrf = sal_True; } @@ -200,7 +201,8 @@ sal_Bool SwGrfNode::ReRead( // reset data of the old graphic so that the correct placeholder is // shown in case the new link could not be loaded Graphic aGrf; aGrf.SetDefaultType(); - maGrfObj.SetGraphic( aGrf, rGrfName ); + mxGrfObj = GraphicObject::Create( aGrf ); + mxGrfObj->SetLink(rGrfName ); if( refLink.Is() ) { @@ -226,7 +228,7 @@ sal_Bool SwGrfNode::ReRead( if( HasStreamName() ) DelStreamName(); - maGrfObj.SetGraphic( *pGraphic ); + mxGrfObj = GraphicObject::Create( *pGraphic ); onGraphicChanged(); bReadGrf = sal_True; } @@ -236,14 +238,14 @@ sal_Bool SwGrfNode::ReRead( if( HasStreamName() ) DelStreamName(); - maGrfObj = *pGrfObj; + mxGrfObj = GraphicObject::Create(*pGrfObj); onGraphicChanged(); if( pGrfObj->HasUserData() && pGrfObj->IsSwappedOut() ) - maGrfObj.SetSwapState(); + mxGrfObj->SetSwapState(); bReadGrf = sal_True; } // Was the graphic already loaded? - else if( !bNewGrf && GRAPHIC_NONE != maGrfObj.GetType() ) + else if( !bNewGrf && mxGrfObj.is() && GRAPHIC_NONE != mxGrfObj->GetType() ) return sal_True; else { @@ -257,7 +259,8 @@ sal_Bool SwGrfNode::ReRead( { if( pGraphic ) { - maGrfObj.SetGraphic( *pGraphic, rGrfName ); + mxGrfObj = GraphicObject::Create( *pGraphic ); + mxGrfObj->SetLink(rGrfName ); onGraphicChanged(); bReadGrf = sal_True; // create connection without update, as we have the graphic @@ -265,8 +268,8 @@ sal_Bool SwGrfNode::ReRead( } else if( pGrfObj ) { - maGrfObj = *pGrfObj; - maGrfObj.SetLink( rGrfName ); + mxGrfObj = GraphicObject::Create(*pGrfObj); + mxGrfObj->SetLink( rGrfName ); onGraphicChanged(); bReadGrf = sal_True; // create connection without update, as we have the graphic @@ -277,7 +280,8 @@ sal_Bool SwGrfNode::ReRead( // reset data of the old graphic so that the correct placeholder is // shown in case the new link could not be loaded Graphic aGrf; aGrf.SetDefaultType(); - maGrfObj.SetGraphic( aGrf, rGrfName ); + mxGrfObj = GraphicObject::Create( aGrf ); + mxGrfObj->SetLink(rGrfName ); onGraphicChanged(); // #i59688# - do not load linked graphic, if it isn't a new linked graphic. if ( bNewGrf ) @@ -291,7 +295,7 @@ sal_Bool SwGrfNode::ReRead( // Bug 39281: Do not delete Size immediately - Events on ImageMaps should have // something to work with when swapping if( bSetTwipSize ) - SetTwipSize( ::GetGraphicSizeTwip( maGrfObj.GetGraphic(), 0 ) ); + SetTwipSize( ::GetGraphicSizeTwip( mxGrfObj->GetGraphic(), 0 ) ); // create an updates for the frames if( bReadGrf && bNewGrf ) @@ -305,8 +309,7 @@ sal_Bool SwGrfNode::ReRead( SwGrfNode::~SwGrfNode() { - delete mpReplacementGraphic; - mpReplacementGraphic = 0; + mxReplacementGraphic.clear(); // #i73788# mpThreadConsumer.reset(); @@ -386,23 +389,24 @@ void SwGrfNode::onGraphicChanged() void SwGrfNode::SetGraphic(const Graphic& rGraphic, const String& rLink) { - maGrfObj.SetGraphic(rGraphic, rLink); + mxGrfObj = GraphicObject::Create( rGraphic ); + mxGrfObj->SetLink(rLink ); onGraphicChanged(); } const GraphicObject* SwGrfNode::GetReplacementGrfObj() const { - if(!mpReplacementGraphic) + if(!mxReplacementGraphic.is()) { - const SvgDataPtr& rSvgDataPtr = GetGrfObj().GetGraphic().getSvgData(); + const SvgDataPtr& rSvgDataPtr = GetGrfObj()->GetGraphic().getSvgData(); if(rSvgDataPtr.get()) { - const_cast< SwGrfNode* >(this)->mpReplacementGraphic = new GraphicObject(rSvgDataPtr->getReplacement()); + const_cast< SwGrfNode* >(this)->mxReplacementGraphic = GraphicObject::Create(rSvgDataPtr->getReplacement()); } } - return mpReplacementGraphic; + return mxReplacementGraphic.get(); } SwCntntNode *SwGrfNode::SplitCntntNode( const SwPosition & ) @@ -431,12 +435,12 @@ SwGrfNode * SwNodes::MakeGrfNode( const SwNodeIndex & rWhere, } SwGrfNode * SwNodes::MakeGrfNode( const SwNodeIndex & rWhere, - const GraphicObject& rGrfObj, - SwGrfFmtColl* pGrfColl, - SwAttrSet* pAutoAttr ) + rtl::Reference<GraphicObject> rxGrfObj, + SwGrfFmtColl* pGrfColl, + SwAttrSet* pAutoAttr ) { OSL_ENSURE( pGrfColl, "MakeGrfNode: Formatpointer ist 0." ); - return new SwGrfNode( rWhere, rGrfObj, pGrfColl, pAutoAttr ); + return new SwGrfNode( rWhere, rxGrfObj, pGrfColl, pAutoAttr ); } Size SwGrfNode::GetTwipSize() const @@ -447,15 +451,17 @@ Size SwGrfNode::GetTwipSize() const sal_Bool SwGrfNode::ImportGraphic( SvStream& rStrm ) { Graphic aGraphic; - const String aURL(maGrfObj.GetUserData()); - + String aURL; + if(mxGrfObj.is()) + { + aURL = mxGrfObj->GetUserData(); + } if(!GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic, aURL, rStrm)) { - delete mpReplacementGraphic; - mpReplacementGraphic = 0; + mxReplacementGraphic.clear(); - maGrfObj.SetGraphic( aGraphic ); - maGrfObj.SetUserData( aURL ); + mxGrfObj = GraphicObject::Create( aGraphic ); + mxGrfObj->SetUserData( aURL ); onGraphicChanged(); return sal_True; } @@ -470,8 +476,9 @@ sal_Bool SwGrfNode::ImportGraphic( SvStream& rStrm ) */ short SwGrfNode::SwapIn( sal_Bool bWaitForData ) { +#if 0 /* FIXME FIXME FIXME */ if( bInSwapIn ) // not recursively! - return !maGrfObj.IsSwappedOut(); + return !mxGrfObj->IsSwappedOut(); short nRet = 0; bInSwapIn = sal_True; @@ -479,36 +486,46 @@ short SwGrfNode::SwapIn( sal_Bool bWaitForData ) if( pLink ) { - if( GRAPHIC_NONE == maGrfObj.GetType() || - GRAPHIC_DEFAULT == maGrfObj.GetType() ) + if(mxGrfObj.is()) { - // link was not loaded yet - if( pLink->SwapIn( bWaitForData ) ) - nRet = -1; - else if( GRAPHIC_DEFAULT == maGrfObj.GetType() ) + if( GRAPHIC_NONE == mxGrfObj->GetType() || + GRAPHIC_DEFAULT == mxGrfObj->GetType() ) { - // no default bitmap anymore, thus re-paint - delete mpReplacementGraphic; - mpReplacementGraphic = 0; + // link was not loaded yet + if( pLink->SwapIn( bWaitForData ) ) + { + nRet = -1; + } + else if( GRAPHIC_DEFAULT == mxGrfObj->GetType() ) + { + // no default bitmap anymore, thus re-paint + mxReplacementGraphic.clear(); - maGrfObj.SetGraphic( Graphic() ); - onGraphicChanged(); - SwMsgPoolItem aMsgHint( RES_GRAPHIC_PIECE_ARRIVED ); - ModifyNotification( &aMsgHint, &aMsgHint ); + mxGrfObj = rtl::Reference<GraphicObject>(); + onGraphicChanged(); + SwMsgPoolItem aMsgHint( RES_GRAPHIC_PIECE_ARRIVED ); + ModifyNotification( &aMsgHint, &aMsgHint ); + } + } + else if( mxGrfObj->IsSwappedOut() ) { + // link to download + nRet = pLink->SwapIn( bWaitForData ) ? 1 : 0; + } + else + { + nRet = 1; } - } - else if( maGrfObj.IsSwappedOut() ) { - // link to download - nRet = pLink->SwapIn( bWaitForData ) ? 1 : 0; } else + { nRet = 1; + } } - else if( maGrfObj.IsSwappedOut() ) + else if( mxGrfObj.is() && mxGrfObj->IsSwappedOut() ) { // graphic is in storage or in a temp file if( !HasStreamName() ) - nRet = (short)maGrfObj.SwapIn(); + nRet = (short)mxGrfObj->SwapIn(); else { try @@ -543,18 +560,23 @@ short SwGrfNode::SwapIn( sal_Bool bWaitForData ) if( nRet ) { + /* FIXME: what if mxGrfObj is empty ref ? */ if( !nGrfSize.Width() && !nGrfSize.Height() ) - SetTwipSize( ::GetGraphicSizeTwip( maGrfObj.GetGraphic(), 0 ) ); + SetTwipSize( ::GetGraphicSizeTwip( mxGrfObj->GetGraphic(), 0 ) ); } bInSwapIn = sal_False; return nRet; +#else + return 0; +#endif } short SwGrfNode::SwapOut() { - if( maGrfObj.GetType() != GRAPHIC_DEFAULT && - maGrfObj.GetType() != GRAPHIC_NONE && - !maGrfObj.IsSwappedOut() && !bInSwapIn ) +#if 0 /* FIXME FIXME */ + if( mxGrfObj->GetType() != GRAPHIC_DEFAULT && + mxGrfObj->GetType() != GRAPHIC_NONE && + !mxGrfObj->IsSwappedOut() && !bInSwapIn ) { if( !refLink.Is() ) { @@ -562,13 +584,16 @@ short SwGrfNode::SwapOut() // The graphic will be written into a temp file if it is new, i.e. // if there is no stream name in the storage yet if( !HasStreamName() ) - if( !maGrfObj.SwapOut() ) + if( !mxGrfObj->SwapOut() ) return 0; } // written graphics and links are removed here - return (short) maGrfObj.SwapOut( NULL ); + return (short) mxGrfObj->SwapOut( NULL ); } return 1; +#else + return 0; +#endif } bool SwGrfNode::GetFileFilterNms( String* pFileNm, String* pFilterNm ) const @@ -671,7 +696,7 @@ void SwGrfNode::InsertLink( const String& rGrfName, const String& rFltName ) (!bSync && rFltName.Len() ? &rFltName : 0) ); } } - maGrfObj.SetLink( rGrfName ); + mxGrfObj->SetLink( rGrfName ); } void SwGrfNode::ReleaseLink() @@ -686,7 +711,7 @@ void SwGrfNode::ReleaseLink() } getIDocumentLinksAdministration()->GetLinkManager().Remove( refLink ); refLink.Clear(); - maGrfObj.SetLink(); + mxGrfObj->SetLink(); } } @@ -790,7 +815,7 @@ void SwGrfNode::DelStreamName() } } - maGrfObj.SetUserData(); + mxGrfObj->SetUserData(); } } @@ -844,9 +869,9 @@ SvStream* SwGrfNode::_GetStreamForEmbedGrf( { xub_StrLen nExtPos = _aStrmName.Search( '.' ); String aExtStr = _aStrmName.Copy( nExtPos ); - if ( GetGrfObj().GetType() != GRAPHIC_NONE ) + if ( GetGrfObj()->GetType() != GRAPHIC_NONE ) { - _aStrmName = OStringToOUString(GetGrfObj().GetUniqueID(), + _aStrmName = OStringToOUString(GetGrfObj()->GetUniqueID(), RTL_TEXTENCODING_ASCII_US); _aStrmName += aExtStr; } @@ -874,7 +899,7 @@ void SwGrfNode::_GetStreamStorageNames( String& rStrmName, rStorName.Erase(); rStrmName.Erase(); - String aUserData( maGrfObj.GetUserData() ); + String aUserData( mxGrfObj->GetUserData() ); if( !aUserData.Len() ) return; @@ -925,7 +950,7 @@ SwCntntNode* SwGrfNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aStrmName ); if ( pStrm ) { - const OUString aURL(maGrfObj.GetUserData()); + const OUString aURL(mxGrfObj->GetUserData()); GraphicFilter::GetGraphicFilter().ImportGraphic(aTmpGrf, aURL, *pStrm); delete pStrm; } @@ -938,9 +963,9 @@ SwCntntNode* SwGrfNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const } else { - if( maGrfObj.IsSwappedOut() ) + if( mxGrfObj->IsSwappedOut() ) const_cast<SwGrfNode*>(this)->SwapIn(); - aTmpGrf = maGrfObj.GetGraphic(); + aTmpGrf = mxGrfObj->GetGraphic(); } const sfx2::LinkManager& rMgr = getIDocumentLinksAdministration()->GetLinkManager(); @@ -964,7 +989,7 @@ SwCntntNode* SwGrfNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const return pGrfNd; } -IMPL_LINK( SwGrfNode, SwapGraphic, GraphicObject*, pGrfObj ) +IMPL_LINK( SwGrfNode, SwapGraphic, const GraphicObject*, pGrfObj ) { SvStream* pRet; @@ -1110,7 +1135,7 @@ GraphicAttr& SwGrfNode::GetGraphicAttr( GraphicAttr& rGA, sal_Bool SwGrfNode::IsTransparent() const { - sal_Bool bRet = maGrfObj.IsTransparent(); + sal_Bool bRet = mxGrfObj->IsTransparent(); if( !bRet ) // ask the attribut bRet = 0 != GetSwAttrSet().GetTransparencyGrf().GetValue(); diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 7677accdfa81..4a32c47d7ac4 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -2945,11 +2945,8 @@ sal_Bool SwFlyFrmFmt::IsBackgroundTransparent() const } else { - const GraphicObject *pTmpGrf = - static_cast<const GraphicObject*>(GetBackground().GetGraphicObject()); - if ( (pTmpGrf) && - (pTmpGrf->GetAttr().GetTransparency() != 0) - ) + const rtl::Reference<GraphicObject> xTmpGrf = GetBackground().GetGraphicObject(); + if ( xTmpGrf.is() && (xTmpGrf->GetAttr().GetTransparency() != 0) ) { bReturn = sal_True; } @@ -2975,7 +2972,7 @@ sal_Bool SwFlyFrmFmt::IsBackgroundBrushInherited() const sal_Bool bReturn = sal_False; if ( (GetBackground().GetColor() == COL_TRANSPARENT) && - !(GetBackground().GetGraphicObject()) ) + !(GetBackground().GetGraphicObject().is()) ) { bReturn = sal_True; } diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index d92184988db4..46a3570927db 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -2614,20 +2614,18 @@ sal_Bool SwFlyFrm::GetContour( PolyPolygon& rContour, // OD 16.04.2003 #i13147# - determine <GraphicObject> instead of <Graphic> // in order to avoid load of graphic, if <SwNoTxtNode> contains a graphic // node and method is called for paint. - const GraphicObject* pGrfObj = NULL; - bool bGrfObjCreated = false; + rtl::Reference<GraphicObject> xGrfObj; const SwGrfNode* pGrfNd = pNd->GetGrfNode(); if ( pGrfNd && _bForPaint ) { - pGrfObj = &(pGrfNd->GetGrfObj()); + xGrfObj = pGrfNd->GetGrfObj(); } else { - pGrfObj = new GraphicObject( pNd->GetGraphic() ); - bGrfObjCreated = true; + xGrfObj = GraphicObject::Create( pNd->GetGraphic() ); } - OSL_ENSURE( pGrfObj, "SwFlyFrm::GetContour() - No Graphic/GraphicObject found at <SwNoTxtNode>." ); - if ( pGrfObj && pGrfObj->GetType() != GRAPHIC_NONE ) + OSL_ENSURE( xGrfObj.is(), "SwFlyFrm::GetContour() - No Graphic/GraphicObject found at <SwNoTxtNode>." ); + if ( xGrfObj.is() && xGrfObj->GetType() != GRAPHIC_NONE ) { if( !pNd->HasContour() ) { @@ -2653,8 +2651,8 @@ sal_Bool SwFlyFrm::GetContour( PolyPolygon& rContour, { OutputDevice* pOutDev = Application::GetDefaultDevice(); const MapMode aDispMap( MAP_TWIP ); - const MapMode aGrfMap( pGrfObj->GetPrefMapMode() ); - const Size aGrfSize( pGrfObj->GetPrefSize() ); + const MapMode aGrfMap( xGrfObj->GetPrefMapMode() ); + const Size aGrfSize( xGrfObj->GetPrefSize() ); Size aOrgSize; Point aNewPoint; bool bPixelMap = aGrfMap.GetMapUnit() == MAP_PIXEL; @@ -2685,11 +2683,7 @@ sal_Bool SwFlyFrm::GetContour( PolyPolygon& rContour, } } } - // OD 17.04.2003 #i13147# - destroy created <GraphicObject>. - if ( bGrfObjCreated ) - { - delete pGrfObj; - } + rContour.Move( aOrig.Left(), aOrig.Top() ); if( !aClip.Width() ) aClip.Width( 1 ); diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index ca3fcd7ccb5e..fab3f7f32938 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -1654,9 +1654,9 @@ static void lcl_SubtractFlys( const SwFrm *pFrm, const SwPageFrm *pPage, boolean (optional; default: false) indicating, if the background is already drawn. */ static void lcl_implDrawGraphicBackgrd( const SvxBrushItem& _rBackgrdBrush, - OutputDevice* _pOut, - const SwRect& _rAlignedPaintRect, - const GraphicObject& _rGraphicObj ) + OutputDevice* _pOut, + const SwRect& _rAlignedPaintRect, + rtl::Reference<GraphicObject> xGraphicObj ) { /// determine color of background /// If color of background brush is not "no fill"/"auto fill" or @@ -1676,13 +1676,13 @@ static void lcl_implDrawGraphicBackgrd( const SvxBrushItem& _rBackgrdBrush, bDrawTransparent = true; nTransparencyPercent = (aColor.GetTransparency()*100 + 0x7F)/0xFF; } - else if ( (_rGraphicObj.GetAttr().GetTransparency() != 0) && + else if ( (xGraphicObj->GetAttr().GetTransparency() != 0) && (_rBackgrdBrush.GetColor() == COL_TRANSPARENT) ) /// graphic is drawn transparent and background color is /// "no fill"/"auto fill" --> draw transparent { bDrawTransparent = true; - nTransparencyPercent = (_rGraphicObj.GetAttr().GetTransparency()*100 + 0x7F)/0xFF; + nTransparencyPercent = (xGraphicObj->GetAttr().GetTransparency()*100 + 0x7F)/0xFF; } if ( bDrawTransparent ) @@ -1703,11 +1703,11 @@ static void lcl_implDrawGraphicBackgrd( const SvxBrushItem& _rBackgrdBrush, } static inline void lcl_DrawGraphicBackgrd( const SvxBrushItem& _rBackgrdBrush, - OutputDevice* _pOut, - const SwRect& _rAlignedPaintRect, - const GraphicObject& _rGraphicObj, - bool _bNumberingGraphic, - bool _bBackgrdAlreadyDrawn = false ) + OutputDevice* _pOut, + const SwRect& _rAlignedPaintRect, + rtl::Reference<GraphicObject> xGraphicObj, + bool _bNumberingGraphic, + bool _bBackgrdAlreadyDrawn = false ) { /// draw background with background color, if /// (1) graphic is not used as a numbering AND @@ -1715,10 +1715,10 @@ static inline void lcl_DrawGraphicBackgrd( const SvxBrushItem& _rBackgrdBrush, /// (3) intrinsic graphic is transparent OR intrinsic graphic doesn't exists if ( !_bNumberingGraphic && !_bBackgrdAlreadyDrawn && - ( _rGraphicObj.IsTransparent() || _rGraphicObj.GetType() == GRAPHIC_NONE ) + ( xGraphicObj->IsTransparent() || xGraphicObj->GetType() == GRAPHIC_NONE ) ) { - lcl_implDrawGraphicBackgrd( _rBackgrdBrush, _pOut, _rAlignedPaintRect, _rGraphicObj ); + lcl_implDrawGraphicBackgrd( _rBackgrdBrush, _pOut, _rAlignedPaintRect, xGraphicObj ); } } @@ -1754,15 +1754,15 @@ static void lcl_DrawGraphic( const SvxBrushItem& rBrush, OutputDevice *pOut, //Hier kein Link, wir wollen die Grafik synchron laden! ((SvxBrushItem&)rBrush).SetDoneLink( Link() ); - GraphicObject *pGrf = (GraphicObject*)rBrush.GetGraphicObject(); + rtl::Reference<GraphicObject> xGrf = rBrush.GetGraphicObject(); /// Outsourcing drawing of background with a background color. - ::lcl_DrawGraphicBackgrd( rBrush, pOut, aAlignedGrfRect, *pGrf, bGrfNum, bBackgrdAlreadyDrawn ); + ::lcl_DrawGraphicBackgrd( rBrush, pOut, aAlignedGrfRect, xGrf, bGrfNum, bBackgrdAlreadyDrawn ); /// Because for drawing a graphic left-top-corner and size coordinations are /// used, these coordinations have to be determined on pixel level. ::SwAlignGrfRect( &aAlignedGrfRect, *pOut ); - pGrf->DrawWithPDFHandling( *pOut, aAlignedGrfRect.Pos(), aAlignedGrfRect.SSize() ); + xGrf->DrawWithPDFHandling( *pOut, aAlignedGrfRect.Pos(), aAlignedGrfRect.SSize() ); if ( bNotInside ) pOut->Pop(); @@ -1877,12 +1877,12 @@ void DrawGraphic( const SvxBrushItem *pBrush, { // draw background of tiled graphic before drawing tiled graphic in loop // determine graphic object - GraphicObject* pGraphicObj = const_cast< GraphicObject* >(pBrush->GetGraphicObject()); + rtl::Reference<GraphicObject> xGraphicObj = pBrush->GetGraphicObject(); // calculate aligned paint rectangle SwRect aAlignedPaintRect = rOut; ::SwAlignRect( aAlignedPaintRect, &rSh ); // draw background color for aligned paint rectangle - lcl_DrawGraphicBackgrd( *pBrush, pOutDev, aAlignedPaintRect, *pGraphicObj, bGrfNum ); + lcl_DrawGraphicBackgrd( *pBrush, pOutDev, aAlignedPaintRect, xGraphicObj, bGrfNum ); // set left-top-corner of background graphic to left-top-corner of the // area, from which the background brush is determined. @@ -1919,7 +1919,7 @@ void DrawGraphic( const SvxBrushItem *pBrush, const Size aSize( aAlignedPaintRect.SSize() ); const double Abitmap( k1/k2 * static_cast<double>(aSize.Width())*aSize.Height() ); - pGraphicObj->DrawTiled( pOutDev, + xGraphicObj->DrawTiled( pOutDev, aAlignedPaintRect.SVRect(), aGrf.SSize(), Size( aPaintOffset.X(), aPaintOffset.Y() ), @@ -1962,10 +1962,10 @@ void DrawGraphic( const SvxBrushItem *pBrush, (ePos != GPOS_TILED) && (ePos != GPOS_AREA) ) { - GraphicObject *pGrf = (GraphicObject*)pBrush->GetGraphicObject(); + rtl::Reference<GraphicObject> xGrf = pBrush->GetGraphicObject(); if ( bConsiderBackgroundTransparency ) { - GraphicAttr pGrfAttr = pGrf->GetAttr(); + GraphicAttr pGrfAttr = xGrf->GetAttr(); if ( (pGrfAttr.GetTransparency() != 0) && ( pBrush && (pBrush->GetColor() == COL_TRANSPARENT) ) ) @@ -1974,7 +1974,7 @@ void DrawGraphic( const SvxBrushItem *pBrush, nGrfTransparency = pGrfAttr.GetTransparency(); } } - if ( pGrf->IsTransparent() ) + if ( xGrf->IsTransparent() ) { bGrfIsTransparent = true; } @@ -3717,11 +3717,8 @@ sal_Bool SwFlyFrm::IsBackgroundTransparent() const } else { - const GraphicObject *pTmpGrf = - static_cast<const GraphicObject*>(pBackgrdBrush->GetGraphicObject()); - if ( (pTmpGrf) && - (pTmpGrf->GetAttr().GetTransparency() != 0) - ) + rtl::Reference<GraphicObject> xTmpGrf = pBackgrdBrush->GetGraphicObject(); + if ( xTmpGrf->GetAttr().GetTransparency() != 0) { bBackgroundTransparent = sal_True; } diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index d0ec1efb18e2..b6336c150121 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -1172,7 +1172,7 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno:: FN_UNO_GRAPHIC_FILTER == pEntry->nWID) { String sGrfName, sFltName; - GraphicObject *pGrfObj = 0; + rtl::Reference<GraphicObject> xGrfObj; pFmt->GetDoc()->GetGrfNms( *(SwFlyFrmFmt*)pFmt, &sGrfName, &sFltName ); OUString uTemp; aValue >>= uTemp; @@ -1183,9 +1183,9 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno:: if( sTmp.EqualsAscii( sPackageProtocol, 0, sizeof( sPackageProtocol )-1 ) ) { - pGrfObj = new GraphicObject; - pGrfObj->SetUserData( sTmp ); - pGrfObj->SetSwapState(); + xGrfObj = GraphicObject::Create(Graphic()); + xGrfObj->SetUserData( sTmp ); + xGrfObj->SetSwapState(); sGrfName.Erase(); } else if( sTmp.EqualsAscii( sGraphicObjectProtocol, @@ -1194,7 +1194,7 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno:: OString sId(OUStringToOString( sTmp.Copy(sizeof(sGraphicObjectProtocol)-1), RTL_TEXTENCODING_ASCII_US)); - pGrfObj = new GraphicObject( sId ); + xGrfObj = GraphicObject::Create( sId ); sGrfName.Erase(); } else @@ -1215,14 +1215,12 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno:: SwGrfNode* pGrfNode = aIdx.GetNode().GetGrfNode(); if(!pGrfNode) { - delete pGrfObj; throw uno::RuntimeException(); } SwPaM aGrfPaM(*pGrfNode); pFmt->GetDoc()->ReRead( aGrfPaM, sGrfName, sFltName, 0, - pGrfObj ); + xGrfObj.get() ); } - delete pGrfObj; } else if( FN_UNO_GRAPHIC == pEntry->nWID ) { @@ -1252,7 +1250,7 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno:: Graphic aGraphic; if( bURL ) { - GraphicObject *pGrfObj = 0; + rtl::Reference<GraphicObject> xGrfObj; OUString aGrfUrl; aValue >>= aGrfUrl; @@ -1264,8 +1262,8 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno:: OString sId(OUStringToOString( aGrfUrl.copy(sizeof(sGraphicObjectProtocol)-1), RTL_TEXTENCODING_ASCII_US)); - pGrfObj = new GraphicObject( sId ); - aGraphic = pGrfObj->GetGraphic(); + xGrfObj = GraphicObject::Create( sId ); + aGraphic = xGrfObj->GetGraphic(); bApply = true; } } @@ -1569,7 +1567,7 @@ uno::Any SwXFrame::getPropertyValue(const OUString& rPropertyName) { OUString sPrefix( RTL_CONSTASCII_USTRINGPARAM(sGraphicObjectProtocol) ); OUString sId(OStringToOUString( - pGrfNode->GetGrfObj().GetUniqueID(), + pGrfNode->GetGrfObj()->GetUniqueID(), RTL_TEXTENCODING_ASCII_US)); sGrfName = sPrefix + sId; } @@ -2232,7 +2230,7 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan UnoActionContext aCont(pDoc); const ::uno::Any* pGraphicURL; String sGraphicURL; - GraphicObject *pGrfObj = 0; + rtl::Reference<GraphicObject> xGrfObj; if(pProps->GetProperty(FN_UNO_GRAPHIC_U_R_L, 0, pGraphicURL)) { OUString uTemp; @@ -2241,9 +2239,9 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan if( sGraphicURL.EqualsAscii( sPackageProtocol, 0, sizeof( sPackageProtocol )-1 ) ) { - pGrfObj = new GraphicObject; - pGrfObj->SetUserData( sGraphicURL ); - pGrfObj->SetSwapState(); + xGrfObj = GraphicObject::Create(Graphic()); + xGrfObj->SetUserData( sGraphicURL ); + xGrfObj->SetSwapState(); sGraphicURL.Erase(); } else if( sGraphicURL.EqualsAscii( sGraphicObjectProtocol, @@ -2252,7 +2250,7 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan OString sId(OUStringToOString( sGraphicURL.Copy( sizeof(sGraphicObjectProtocol)-1 ), RTL_TEXTENCODING_ASCII_US)); - pGrfObj = new GraphicObject( sId ); + xGrfObj = GraphicObject::Create( sId ); sGraphicURL.Erase(); } } @@ -2275,11 +2273,11 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan } pFmt = - pGrfObj ? pDoc->Insert( aPam, *pGrfObj, &aFrmSet, &aGrSet, + !sGraphicURL.Len() ? pDoc->Insert( aPam, xGrfObj, &aFrmSet, &aGrSet, pParentFrmFmt ) : pDoc->Insert( aPam, sGraphicURL, sFltName, &aGraphic, &aFrmSet, &aGrSet, pParentFrmFmt ); - delete pGrfObj; + if(pFmt) { SwGrfNode *pGrfNd = pDoc->GetNodes()[ pFmt->GetCntnt().GetCntntIdx() diff --git a/sw/source/filter/ww8/rtfsdrexport.cxx b/sw/source/filter/ww8/rtfsdrexport.cxx index cb2f88540e8a..253291f80779 100644 --- a/sw/source/filter/ww8/rtfsdrexport.cxx +++ b/sw/source/filter/ww8/rtfsdrexport.cxx @@ -444,7 +444,8 @@ void RtfSdrExport::impl_writeGraphic() xPropertySet->getPropertyValue("GraphicURL") >>= sGraphicURL; OString aURLBS(OUStringToOString(sGraphicURL, RTL_TEXTENCODING_UTF8)); const char aURLBegin[] = "vnd.sun.star.GraphicObject:"; - Graphic aGraphic = GraphicObject(aURLBS.copy(RTL_CONSTASCII_LENGTH(aURLBegin))).GetTransformedGraphic(); + rtl::Reference<GraphicObject> xGrfObj = GraphicObject::Create(aURLBS.copy(RTL_CONSTASCII_LENGTH(aURLBegin))); + Graphic aGraphic = xGrfObj->GetTransformedGraphic(); // Export it to a stream. SvMemoryStream aStream; diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx index 08c68a074be8..d9fbdfe5356c 100644 --- a/sw/source/filter/ww8/writerhelper.cxx +++ b/sw/source/filter/ww8/writerhelper.cxx @@ -674,7 +674,7 @@ namespace sw SwGrfNode *pGrfNode = const_cast<SwGrfNode*>(rNd.GetGrfNode()); if (pGrfNode && (GRAPHIC_NONE != pGrfNode->GetGrf().GetType())) { - bool bWasSwappedOut = pGrfNode->GetGrfObj().IsSwappedOut(); + bool bWasSwappedOut = pGrfNode->GetGrfObj()->IsSwappedOut(); pGrfNode->SwapIn(); aGrTwipSz = pGrfNode->GetTwipSize(); if (bWasSwappedOut) diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index ecd54e861087..49fe80b9a625 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -1344,8 +1344,8 @@ sal_Int32 SwBasicEscherEx::WriteGrfBullet(const Graphic& rGrf) OpenContainer( ESCHER_SpContainer ); AddShape(ESCHER_ShpInst_PictureFrame, 0xa00,0x401); EscherPropertyContainer aPropOpt; - GraphicObject aGraphicObject( rGrf ); - OString aUniqueId = aGraphicObject.GetUniqueID(); + rtl::Reference<GraphicObject> xGraphicObject = GraphicObject::Create( rGrf ); + OString aUniqueId = xGraphicObject->GetUniqueID(); if ( !aUniqueId.isEmpty() ) { const MapMode aMap100mm( MAP_100TH_MM ); @@ -1431,8 +1431,8 @@ sal_Int32 SwBasicEscherEx::WriteGrfFlyFrame(const SwFrmFmt& rFmt, sal_uInt32 nSh pGrfNd->SwapIn(true); Graphic aGraphic(pGrfNd->GetGrf()); - GraphicObject aGraphicObject( aGraphic ); - OString aUniqueId = aGraphicObject.GetUniqueID(); + rtl::Reference<GraphicObject> xGraphicObject = GraphicObject::Create( aGraphic ); + OString aUniqueId = xGraphicObject->GetUniqueID(); if (!aUniqueId.isEmpty()) { @@ -1639,12 +1639,13 @@ void SwBasicEscherEx::WriteBrushAttr(const SvxBrushItem &rBrush, { bool bSetOpacity = false; sal_uInt32 nOpaque = 0; - if (const GraphicObject *pGraphicObject = rBrush.GetGraphicObject()) + rtl::Reference<GraphicObject> xGraphicObject = rBrush.GetGraphicObject(); + if(xGraphicObject.is()) { - OString aUniqueId = pGraphicObject->GetUniqueID(); + OString aUniqueId = xGraphicObject->GetUniqueID(); if (!aUniqueId.isEmpty()) { - const Graphic &rGraphic = pGraphicObject->GetGraphic(); + const Graphic &rGraphic = xGraphicObject->GetGraphic(); Size aSize(rGraphic.GetPrefSize()); const MapMode aMap100mm(MAP_100TH_MM); if (MAP_PIXEL == rGraphic.GetPrefMapMode().GetMapUnit()) @@ -1667,7 +1668,7 @@ void SwBasicEscherEx::WriteBrushAttr(const SvxBrushItem &rBrush, rPropOpt.AddOpt(ESCHER_Prop_fillBlip,nBlibId,sal_True); } - if (0 != (nOpaque = pGraphicObject->GetAttr().GetTransparency())) + if (0 != (nOpaque = xGraphicObject->GetAttr().GetTransparency())) bSetOpacity = true; rPropOpt.AddOpt( ESCHER_Prop_fillType, ESCHER_FillPicture ); @@ -2813,8 +2814,8 @@ void SwBasicEscherEx::WriteOLEPicture(EscherPropertyContainer &rPropOpt, //nShapeFlags == 0xA00 + flips and ole active AddShape(ESCHER_ShpInst_PictureFrame, nShapeFlags, nShapeId); - GraphicObject aGraphicObject(rGraphic); - OString aId = aGraphicObject.GetUniqueID(); + rtl::Reference<GraphicObject> xGraphicObject = GraphicObject::Create(rGraphic); + OString aId = xGraphicObject->GetUniqueID(); if (!aId.isEmpty()) { Rectangle aRect = rObj.GetLogicRect(); diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx index ce1b721f83a1..36d8b2097ba9 100644 --- a/sw/source/filter/ww8/ww8graf.cxx +++ b/sw/source/filter/ww8/ww8graf.cxx @@ -1804,18 +1804,18 @@ void SwWW8ImplReader::MatchSdrItemsIntoFlySet( SdrObject* pSdrObj, break; case XFILL_BITMAP: { - GraphicObject aGrfObj(static_cast< XFillBitmapItem const & >(rOldSet.Get(XATTR_FILLBITMAP)).GetGraphicObject()); + rtl::Reference<GraphicObject> xGrfObj(static_cast< XFillBitmapItem const & >(rOldSet.Get(XATTR_FILLBITMAP)).GetGraphicObject()); const bool bTile(WW8ITEMVALUE(rOldSet, XATTR_FILLBMP_TILE, SfxBoolItem) ? true: false); if(bBrushItemOk) //has trans { - GraphicAttr aAttr(aGrfObj.GetAttr()); + GraphicAttr aAttr(xGrfObj->GetAttr()); aAttr.SetTransparency(nTrans); - aGrfObj.SetAttr(aAttr); + xGrfObj->SetAttr(aAttr); } - aBrushItem.SetGraphicObject(aGrfObj); + aBrushItem.SetGraphicObject(xGrfObj); aBrushItem.SetGraphicPos(bTile ? GPOS_TILED : GPOS_AREA); bBrushItemOk = true; } diff --git a/sw/source/filter/xml/xmlbrsh.cxx b/sw/source/filter/xml/xmlbrsh.cxx index 4364c341bd72..19685949afd2 100644 --- a/sw/source/filter/xml/xmlbrsh.cxx +++ b/sw/source/filter/xml/xmlbrsh.cxx @@ -121,8 +121,8 @@ SvXMLImportContext *SwXMLBrushItemImportContext::CreateChildContext( { if( !xBase64Stream.is() && !pItem->GetGraphicLink() ) { - const GraphicObject *pGrObj = pItem->GetGraphicObject(); - if( !pGrObj || GRAPHIC_NONE == pGrObj->GetType() ) + rtl::Reference< GraphicObject > xGrObj = pItem->GetGraphicObject(); + if( GRAPHIC_NONE == xGrObj->GetType() ) { xBase64Stream = GetImport().GetStreamForGraphicObjectURLFromBase64(); diff --git a/sw/source/ui/shells/grfsh.cxx b/sw/source/ui/shells/grfsh.cxx index 33108c062559..ce3ca38537f2 100644 --- a/sw/source/ui/shells/grfsh.cxx +++ b/sw/source/ui/shells/grfsh.cxx @@ -266,7 +266,7 @@ void SwGrfShell::Execute(SfxRequest &rReq) const GraphicObject* pGrfObj = rSh.GetGraphicObj(); if ( pGrfObj ) { - aSet.Put( SvxBrushItem( *pGrfObj, GPOS_LT, + aSet.Put( SvxBrushItem( GraphicObject::Create(*pGrfObj), GPOS_LT, SID_ATTR_GRAF_GRAPHIC ) ); } } @@ -551,11 +551,12 @@ void SwGrfShell::ExecAttr( SfxRequest &rReq ) const GraphicObject* pFilterObj( GetShell().GetGraphicObj() ); if ( pFilterObj ) { - GraphicObject aFilterObj( *pFilterObj ); + Graphic* pGraphObj = new Graphic(pFilterObj->GetGraphic()); if( SVX_GRAPHICFILTER_ERRCODE_NONE == - SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, aFilterObj )) + SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, &pGraphObj )) GetShell().ReRead( aEmptyStr, aEmptyStr, - &aFilterObj.GetGraphic() ); + &(*pGraphObj) ); + delete pGraphObj; } } break; diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 1ca8f179909d..fef3215f942a 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -705,7 +705,8 @@ int RTFDocumentImpl::resolvePict(bool bInline) const char aURLBegin[] = "vnd.sun.star.GraphicObject:"; if (aURLBS.compareTo(aURLBegin, RTL_CONSTASCII_LENGTH(aURLBegin)) == 0) { - Graphic aGraphic = GraphicObject(aURLBS.copy(RTL_CONSTASCII_LENGTH(aURLBegin))).GetTransformedGraphic(); + rtl::Reference<GraphicObject> xGrObj = GraphicObject::Create(aURLBS.copy(RTL_CONSTASCII_LENGTH(aURLBegin))); + Graphic aGraphic = xGrObj->GetTransformedGraphic(); Size aSize(aGraphic.GetPrefSize()); MapMode aMap(MAP_100TH_MM); if (aGraphic.GetPrefMapMode().GetMapUnit() == MAP_PIXEL) |