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 /sw/source | |
parent | 0854f0566c5d18b919b76df10b4bbd5a3606b7d6 (diff) |
Save Commit: must be squashed!!! ObjectGraphic refactor
Change-Id: I69f0b8bef3a08d1a325ccbe2b5f128df9cc14880
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/doc/doc.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/doc/notxtfrm.cxx | 26 | ||||
-rw-r--r-- | sw/source/core/docnode/swbaslnk.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/edit/editsh.cxx | 10 | ||||
-rw-r--r-- | sw/source/core/graphic/ndgrf.cxx | 197 | ||||
-rw-r--r-- | sw/source/core/layout/atrfrm.cxx | 9 | ||||
-rw-r--r-- | sw/source/core/layout/fly.cxx | 22 | ||||
-rw-r--r-- | sw/source/core/layout/paintfrm.cxx | 49 | ||||
-rw-r--r-- | sw/source/core/unocore/unoframe.cxx | 36 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfsdrexport.cxx | 3 | ||||
-rw-r--r-- | sw/source/filter/ww8/writerhelper.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8esh.cxx | 21 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8graf.cxx | 8 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlbrsh.cxx | 4 | ||||
-rw-r--r-- | sw/source/ui/shells/grfsh.cxx | 9 |
15 files changed, 211 insertions, 197 deletions
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; |