diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-12 09:53:27 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-12 12:24:28 +0200 |
commit | 5dd762ddc1829a86e7b4e23076143bc01d6073ad (patch) | |
tree | 90ac69d1bab369bc054ac84ede13ec3c87075642 /vcl | |
parent | 9bd372218dfea3fb70d503d7532ee2b144ada136 (diff) |
hold MetaAction by rtl::Reference
instead of yet another private implementation of manual reference
counting
Change-Id: Iefb1d2e595e45a2dfdc3be54e1c51b64afeaf9d8
Reviewed-on: https://gerrit.libreoffice.org/52753
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/Executable_outdevgrind.mk | 1 | ||||
-rw-r--r-- | vcl/README.GDIMetaFile | 4 | ||||
-rw-r--r-- | vcl/source/gdi/gdimetafiletools.cxx | 1 | ||||
-rw-r--r-- | vcl/source/gdi/gdimtf.cxx | 71 | ||||
-rw-r--r-- | vcl/source/gdi/metaact.cxx | 329 | ||||
-rw-r--r-- | vcl/source/gdi/print2.cxx | 2 | ||||
-rw-r--r-- | vcl/source/gdi/svmconverter.cxx | 12 | ||||
-rw-r--r-- | vcl/source/graphic/UnoGraphicProvider.cxx | 6 |
8 files changed, 138 insertions, 288 deletions
diff --git a/vcl/Executable_outdevgrind.mk b/vcl/Executable_outdevgrind.mk index 7b60d5e1b8c0..7c12e24ac327 100644 --- a/vcl/Executable_outdevgrind.mk +++ b/vcl/Executable_outdevgrind.mk @@ -29,6 +29,7 @@ $(eval $(call gb_Executable_use_libraries,outdevgrind,\ cppu \ cppuhelper \ comphelper \ + salhelper \ )) $(eval $(call gb_Executable_add_exception_objects,outdevgrind,\ diff --git a/vcl/README.GDIMetaFile b/vcl/README.GDIMetaFile index 2c8879de0c25..98be38d086d8 100644 --- a/vcl/README.GDIMetaFile +++ b/vcl/README.GDIMetaFile @@ -153,10 +153,6 @@ READ AND WRITE FUNCTIONS INTROSPECTIVE FUNCTIONS - GetType -- GetRefCount - reference counter -- ResetRefCount - reset to 1 -- Duplicate - increment refcounter -- Delete - delete if all instances no longer being referenced diff --git a/vcl/source/gdi/gdimetafiletools.cxx b/vcl/source/gdi/gdimetafiletools.cxx index 2170f2a9be2a..84cd0e373739 100644 --- a/vcl/source/gdi/gdimetafiletools.cxx +++ b/vcl/source/gdi/gdimetafiletools.cxx @@ -1042,7 +1042,6 @@ void clipMetafileContentAgainstOwnRegions(GDIMetaFile& rSource) } else { - const_cast< MetaAction* >(pAction)->Duplicate(); aTarget.AddAction(const_cast< MetaAction* >(pAction)); } } diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index 630619a2a059..06700e436c5d 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -136,10 +136,8 @@ GDIMetaFile::GDIMetaFile( const GDIMetaFile& rMtf ) : m_bRecord ( false ), m_bUseCanvas ( rMtf.m_bUseCanvas ) { - // Increment RefCount of MetaActions for( size_t i = 0, n = rMtf.GetActionSize(); i < n; ++i ) { - rMtf.GetAction( i )->Duplicate(); m_aList.push_back( rMtf.GetAction( i ) ); } @@ -164,33 +162,29 @@ size_t GDIMetaFile::GetActionSize() const MetaAction* GDIMetaFile::GetAction( size_t nAction ) const { - return (nAction < m_aList.size()) ? m_aList[ nAction ] : nullptr; + return (nAction < m_aList.size()) ? m_aList[ nAction ].get() : nullptr; } MetaAction* GDIMetaFile::FirstAction() { m_nCurrentActionElement = 0; - return m_aList.empty() ? nullptr : m_aList[ 0 ]; + return m_aList.empty() ? nullptr : m_aList[ 0 ].get(); } MetaAction* GDIMetaFile::NextAction() { - return ( m_nCurrentActionElement + 1 < m_aList.size() ) ? m_aList[ ++m_nCurrentActionElement ] : nullptr; + return ( m_nCurrentActionElement + 1 < m_aList.size() ) ? m_aList[ ++m_nCurrentActionElement ].get() : nullptr; } -MetaAction* GDIMetaFile::ReplaceAction( MetaAction* pAction, size_t nAction ) +void GDIMetaFile::ReplaceAction( rtl::Reference<MetaAction> pAction, size_t nAction ) { if ( nAction >= m_aList.size() ) { - // this method takes ownership of pAction and is - // therefore responsible for deleting it - pAction->Delete(); - return nullptr; + return; } //fdo#39995 This doesn't increment the incoming action ref-count nor does it //decrement the outgoing action ref-count std::swap(pAction, m_aList[nAction]); - return pAction; } GDIMetaFile& GDIMetaFile::operator=( const GDIMetaFile& rMtf ) @@ -202,7 +196,6 @@ GDIMetaFile& GDIMetaFile::operator=( const GDIMetaFile& rMtf ) // Increment RefCount of MetaActions for( size_t i = 0, n = rMtf.GetActionSize(); i < n; ++i ) { - rMtf.GetAction( i )->Duplicate(); m_aList.push_back( rMtf.GetAction( i ) ); } @@ -258,8 +251,6 @@ void GDIMetaFile::Clear() if( m_bRecord ) Stop(); - for(MetaAction* i : m_aList) - i->Delete(); m_aList.clear(); } @@ -320,7 +311,6 @@ void GDIMetaFile::Play( GDIMetaFile& rMtf ) { if( pAction ) { - pAction->Duplicate(); rMtf.AddAction( pAction ); } @@ -552,24 +542,21 @@ void GDIMetaFile::WindPrev() --m_nCurrentActionElement; } -void GDIMetaFile::AddAction( MetaAction* pAction ) +void GDIMetaFile::AddAction( rtl::Reference<MetaAction> pAction ) { m_aList.push_back( pAction ); if( m_pPrev ) { - pAction->Duplicate(); m_pPrev->AddAction( pAction ); } } -void GDIMetaFile::AddAction( MetaAction* pAction, size_t nPos ) +void GDIMetaFile::AddAction( rtl::Reference<MetaAction> pAction, size_t nPos ) { if ( nPos < m_aList.size() ) { - ::std::vector< MetaAction* >::iterator it = m_aList.begin(); - ::std::advance( it, nPos ); - m_aList.insert( it, pAction ); + m_aList.insert( m_aList.begin() + nPos, pAction ); } else { @@ -578,12 +565,11 @@ void GDIMetaFile::AddAction( MetaAction* pAction, size_t nPos ) if( m_pPrev ) { - pAction->Duplicate(); m_pPrev->AddAction( pAction, nPos ); } } -void GDIMetaFile::push_back( MetaAction* pAction ) +void GDIMetaFile::push_back( rtl::Reference<MetaAction> pAction ) { m_aList.push_back( pAction ); } @@ -640,8 +626,8 @@ void GDIMetaFile::Move( long nX, long nY ) if( pAct->GetRefCount() > 1 ) { - m_aList[ m_nCurrentActionElement ] = pModAct = pAct->Clone(); - pAct->Delete(); + m_aList[ m_nCurrentActionElement ] = pAct->Clone(); + pModAct = m_aList[ m_nCurrentActionElement ].get(); } else pModAct = pAct; @@ -675,8 +661,8 @@ void GDIMetaFile::Move( long nX, long nY, long nDPIX, long nDPIY ) if( pAct->GetRefCount() > 1 ) { - m_aList[ m_nCurrentActionElement ] = pModAct = pAct->Clone(); - pAct->Delete(); + m_aList[ m_nCurrentActionElement ] = pAct->Clone(); + pModAct = m_aList[ m_nCurrentActionElement ].get(); } else pModAct = pAct; @@ -709,8 +695,8 @@ void GDIMetaFile::Scale( double fScaleX, double fScaleY ) if( pAct->GetRefCount() > 1 ) { - m_aList[ m_nCurrentActionElement ] = pModAct = pAct->Clone(); - pAct->Delete(); + m_aList[ m_nCurrentActionElement ] = pAct->Clone(); + pModAct = m_aList[ m_nCurrentActionElement ].get(); } else pModAct = pAct; @@ -754,7 +740,6 @@ void GDIMetaFile::Clip( const tools::Rectangle& i_rClipRect ) aNewReg.Intersect( pOldAct->GetRegion() ); MetaClipRegionAction* pNewAct = new MetaClipRegionAction( aNewReg, true ); m_aList[ m_nCurrentActionElement ] = pNewAct; - pOldAct->Delete(); } } } @@ -809,7 +794,6 @@ void GDIMetaFile::ImplAddGradientEx( GDIMetaFile& rMtf, for( i=0; i < nAct; ++i ) { MetaAction* pMetaAct = aGradMtf.GetAction( i ); - pMetaAct->Duplicate(); rMtf.AddAction( pMetaAct ); } } @@ -1132,7 +1116,6 @@ void GDIMetaFile::Rotate( long nAngle10 ) || pCommentAct->GetComment() == "XPATHFILL_SEQ_END" ) { pAction->Execute( aMapVDev.get() ); - pAction->Duplicate(); aMtf.AddAction( pAction ); } } @@ -1192,7 +1175,6 @@ void GDIMetaFile::Rotate( long nAngle10 ) aMtf.AddAction( new MetaClipRegionAction( vcl::Region( ImplGetRotatedPolyPolygon( pAct->GetRegion().GetAsPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ) ), true ) ); else { - pAction->Duplicate(); aMtf.AddAction( pAction ); } } @@ -1216,7 +1198,6 @@ void GDIMetaFile::Rotate( long nAngle10 ) aMtf.AddAction( new MetaISectRegionClipRegionAction( vcl::Region( ImplGetRotatedPolyPolygon( rRegion.GetAsPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ) ) ) ); else { - pAction->Duplicate(); aMtf.AddAction( pAction ); } } @@ -1255,7 +1236,6 @@ void GDIMetaFile::Rotate( long nAngle10 ) default: { pAction->Execute( aMapVDev.get() ); - pAction->Duplicate(); aMtf.AddAction( pAction ); // update rotation point and offset, if necessary @@ -1845,9 +1825,7 @@ void GDIMetaFile::ImplExchangeColors( ColorExchangeFnc pFncCol, const void* pCol { MetaLineColorAction* pAct = static_cast<MetaLineColorAction*>(pAction); - if( !pAct->IsSetting() ) - pAct->Duplicate(); - else + if( pAct->IsSetting() ) pAct = new MetaLineColorAction( pFncCol( pAct->GetColor(), pColParam ), true ); aMtf.push_back( pAct ); @@ -1858,9 +1836,7 @@ void GDIMetaFile::ImplExchangeColors( ColorExchangeFnc pFncCol, const void* pCol { MetaFillColorAction* pAct = static_cast<MetaFillColorAction*>(pAction); - if( !pAct->IsSetting() ) - pAct->Duplicate(); - else + if( pAct->IsSetting() ) pAct = new MetaFillColorAction( pFncCol( pAct->GetColor(), pColParam ), true ); aMtf.push_back( pAct ); @@ -1878,9 +1854,7 @@ void GDIMetaFile::ImplExchangeColors( ColorExchangeFnc pFncCol, const void* pCol { MetaTextFillColorAction* pAct = static_cast<MetaTextFillColorAction*>(pAction); - if( !pAct->IsSetting() ) - pAct->Duplicate(); - else + if( pAct->IsSetting() ) pAct = new MetaTextFillColorAction( pFncCol( pAct->GetColor(), pColParam ), true ); aMtf.push_back( pAct ); @@ -1891,9 +1865,7 @@ void GDIMetaFile::ImplExchangeColors( ColorExchangeFnc pFncCol, const void* pCol { MetaTextLineColorAction* pAct = static_cast<MetaTextLineColorAction*>(pAction); - if( !pAct->IsSetting() ) - pAct->Duplicate(); - else + if( pAct->IsSetting() ) pAct = new MetaTextLineColorAction( pFncCol( pAct->GetColor(), pColParam ), true ); aMtf.push_back( pAct ); @@ -1904,9 +1876,7 @@ void GDIMetaFile::ImplExchangeColors( ColorExchangeFnc pFncCol, const void* pCol { MetaOverlineColorAction* pAct = static_cast<MetaOverlineColorAction*>(pAction); - if( !pAct->IsSetting() ) - pAct->Duplicate(); - else + if( pAct->IsSetting() ) pAct = new MetaOverlineColorAction( pFncCol( pAct->GetColor(), pColParam ), true ); aMtf.push_back( pAct ); @@ -2073,7 +2043,6 @@ void GDIMetaFile::ImplExchangeColors( ColorExchangeFnc pFncCol, const void* pCol default: { - pAction->Duplicate(); aMtf.push_back( pAction ); } break; diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx index 4f9eda7ce819..013662a7ab5a 100644 --- a/vcl/source/gdi/metaact.cxx +++ b/vcl/source/gdi/metaact.cxx @@ -147,17 +147,20 @@ inline void ImplScaleLineInfo( LineInfo& rLineInfo, double fScaleX, double fScal } //anonymous namespace MetaAction::MetaAction() : - mnRefCount( 1 ), mnType( MetaActionType::NONE ) { } MetaAction::MetaAction( MetaActionType nType ) : - mnRefCount( 1 ), mnType( nType ) { } +MetaAction::MetaAction( MetaAction const & rOther ) : + SimpleReferenceObject(), mnType( rOther.mnType ) +{ +} + MetaAction::~MetaAction() { } @@ -166,7 +169,7 @@ void MetaAction::Execute( OutputDevice* ) { } -MetaAction* MetaAction::Clone() +rtl::Reference<MetaAction> MetaAction::Clone() { return new MetaAction; } @@ -286,11 +289,9 @@ void MetaPixelAction::Execute( OutputDevice* pOut ) pOut->DrawPixel( maPt, maColor ); } -MetaAction* MetaPixelAction::Clone() +rtl::Reference<MetaAction> MetaPixelAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaPixelAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaPixelAction( *this ); } void MetaPixelAction::Move( long nHorzMove, long nVertMove ) @@ -335,11 +336,9 @@ void MetaPointAction::Execute( OutputDevice* pOut ) pOut->DrawPixel( maPt ); } -MetaAction* MetaPointAction::Clone() +rtl::Reference<MetaAction> MetaPointAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaPointAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaPointAction( *this ); } void MetaPointAction::Move( long nHorzMove, long nVertMove ) @@ -394,11 +393,9 @@ void MetaLineAction::Execute( OutputDevice* pOut ) pOut->DrawLine( maStartPt, maEndPt, maLineInfo ); } -MetaAction* MetaLineAction::Clone() +rtl::Reference<MetaAction> MetaLineAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaLineAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaLineAction( *this ); } void MetaLineAction::Move( long nHorzMove, long nVertMove ) @@ -456,11 +453,9 @@ void MetaRectAction::Execute( OutputDevice* pOut ) pOut->DrawRect( maRect ); } -MetaAction* MetaRectAction::Clone() +rtl::Reference<MetaAction> MetaRectAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaRectAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaRectAction( *this ); } void MetaRectAction::Move( long nHorzMove, long nVertMove ) @@ -508,11 +503,9 @@ void MetaRoundRectAction::Execute( OutputDevice* pOut ) pOut->DrawRect( maRect, mnHorzRound, mnVertRound ); } -MetaAction* MetaRoundRectAction::Clone() +rtl::Reference<MetaAction> MetaRoundRectAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaRoundRectAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaRoundRectAction( *this ); } void MetaRoundRectAction::Move( long nHorzMove, long nVertMove ) @@ -558,11 +551,9 @@ void MetaEllipseAction::Execute( OutputDevice* pOut ) pOut->DrawEllipse( maRect ); } -MetaAction* MetaEllipseAction::Clone() +rtl::Reference<MetaAction> MetaEllipseAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaEllipseAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaEllipseAction( *this ); } void MetaEllipseAction::Move( long nHorzMove, long nVertMove ) @@ -608,11 +599,9 @@ void MetaArcAction::Execute( OutputDevice* pOut ) pOut->DrawArc( maRect, maStartPt, maEndPt ); } -MetaAction* MetaArcAction::Clone() +rtl::Reference<MetaAction> MetaArcAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaArcAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaArcAction( *this ); } void MetaArcAction::Move( long nHorzMove, long nVertMove ) @@ -666,11 +655,9 @@ void MetaPieAction::Execute( OutputDevice* pOut ) pOut->DrawPie( maRect, maStartPt, maEndPt ); } -MetaAction* MetaPieAction::Clone() +rtl::Reference<MetaAction> MetaPieAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaPieAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaPieAction( *this ); } void MetaPieAction::Move( long nHorzMove, long nVertMove ) @@ -724,11 +711,9 @@ void MetaChordAction::Execute( OutputDevice* pOut ) pOut->DrawChord( maRect, maStartPt, maEndPt ); } -MetaAction* MetaChordAction::Clone() +rtl::Reference<MetaAction> MetaChordAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaChordAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaChordAction( *this ); } void MetaChordAction::Move( long nHorzMove, long nVertMove ) @@ -788,11 +773,9 @@ void MetaPolyLineAction::Execute( OutputDevice* pOut ) pOut->DrawPolyLine( maPoly, maLineInfo ); } -MetaAction* MetaPolyLineAction::Clone() +rtl::Reference<MetaAction> MetaPolyLineAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaPolyLineAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaPolyLineAction( *this ); } void MetaPolyLineAction::Move( long nHorzMove, long nVertMove ) @@ -859,11 +842,9 @@ void MetaPolygonAction::Execute( OutputDevice* pOut ) pOut->DrawPolygon( maPoly ); } -MetaAction* MetaPolygonAction::Clone() +rtl::Reference<MetaAction> MetaPolygonAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaPolygonAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaPolygonAction( *this ); } void MetaPolygonAction::Move( long nHorzMove, long nVertMove ) @@ -923,11 +904,9 @@ void MetaPolyPolygonAction::Execute( OutputDevice* pOut ) pOut->DrawPolyPolygon( maPolyPoly ); } -MetaAction* MetaPolyPolygonAction::Clone() +rtl::Reference<MetaAction> MetaPolyPolygonAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaPolyPolygonAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaPolyPolygonAction( *this ); } void MetaPolyPolygonAction::Move( long nHorzMove, long nVertMove ) @@ -1031,11 +1010,9 @@ void MetaTextAction::Execute( OutputDevice* pOut ) pOut->DrawText( maPt, maStr, mnIndex, mnLen ); } -MetaAction* MetaTextAction::Clone() +rtl::Reference<MetaAction> MetaTextAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaTextAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaTextAction( *this ); } void MetaTextAction::Move( long nHorzMove, long nVertMove ) @@ -1126,11 +1103,9 @@ void MetaTextArrayAction::Execute( OutputDevice* pOut ) pOut->DrawTextArray( maStartPt, maStr, mpDXAry.get(), mnIndex, mnLen ); } -MetaAction* MetaTextArrayAction::Clone() +rtl::Reference<MetaAction> MetaTextArrayAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaTextArrayAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaTextArrayAction( *this ); } void MetaTextArrayAction::Move( long nHorzMove, long nVertMove ) @@ -1257,11 +1232,9 @@ void MetaStretchTextAction::Execute( OutputDevice* pOut ) pOut->DrawStretchText( maPt, mnWidth, maStr, mnIndex, mnLen ); } -MetaAction* MetaStretchTextAction::Clone() +rtl::Reference<MetaAction> MetaStretchTextAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaStretchTextAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaStretchTextAction( *this ); } void MetaStretchTextAction::Move( long nHorzMove, long nVertMove ) @@ -1326,11 +1299,9 @@ void MetaTextRectAction::Execute( OutputDevice* pOut ) pOut->DrawText( maRect, maStr, mnStyle ); } -MetaAction* MetaTextRectAction::Clone() +rtl::Reference<MetaAction> MetaTextRectAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaTextRectAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaTextRectAction( *this ); } void MetaTextRectAction::Move( long nHorzMove, long nVertMove ) @@ -1395,11 +1366,9 @@ void MetaTextLineAction::Execute( OutputDevice* pOut ) pOut->DrawTextLine( maPos, mnWidth, meStrikeout, meUnderline, meOverline ); } -MetaAction* MetaTextLineAction::Clone() +rtl::Reference<MetaAction> MetaTextLineAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaTextLineAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaTextLineAction( *this ); } void MetaTextLineAction::Move( long nHorzMove, long nVertMove ) @@ -1469,11 +1438,9 @@ void MetaBmpAction::Execute( OutputDevice* pOut ) pOut->DrawBitmap( maPt, maBmp ); } -MetaAction* MetaBmpAction::Clone() +rtl::Reference<MetaAction> MetaBmpAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaBmpAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaBmpAction( *this ); } void MetaBmpAction::Move( long nHorzMove, long nVertMove ) @@ -1524,11 +1491,9 @@ void MetaBmpScaleAction::Execute( OutputDevice* pOut ) pOut->DrawBitmap( maPt, maSz, maBmp ); } -MetaAction* MetaBmpScaleAction::Clone() +rtl::Reference<MetaAction> MetaBmpScaleAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaBmpScaleAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaBmpScaleAction( *this ); } void MetaBmpScaleAction::Move( long nHorzMove, long nVertMove ) @@ -1587,11 +1552,9 @@ void MetaBmpScalePartAction::Execute( OutputDevice* pOut ) pOut->DrawBitmap( maDstPt, maDstSz, maSrcPt, maSrcSz, maBmp ); } -MetaAction* MetaBmpScalePartAction::Clone() +rtl::Reference<MetaAction> MetaBmpScalePartAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaBmpScalePartAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaBmpScalePartAction( *this ); } void MetaBmpScalePartAction::Move( long nHorzMove, long nVertMove ) @@ -1649,11 +1612,9 @@ void MetaBmpExAction::Execute( OutputDevice* pOut ) pOut->DrawBitmapEx( maPt, maBmpEx ); } -MetaAction* MetaBmpExAction::Clone() +rtl::Reference<MetaAction> MetaBmpExAction::Clone() { - MetaBmpExAction* pClone = new MetaBmpExAction( *this ); - pClone->ResetRefCount(); - return pClone; + return new MetaBmpExAction( *this ); } void MetaBmpExAction::Move( long nHorzMove, long nVertMove ) @@ -1704,11 +1665,9 @@ void MetaBmpExScaleAction::Execute( OutputDevice* pOut ) pOut->DrawBitmapEx( maPt, maSz, maBmpEx ); } -MetaAction* MetaBmpExScaleAction::Clone() +rtl::Reference<MetaAction> MetaBmpExScaleAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaBmpExScaleAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaBmpExScaleAction( *this ); } void MetaBmpExScaleAction::Move( long nHorzMove, long nVertMove ) @@ -1767,11 +1726,9 @@ void MetaBmpExScalePartAction::Execute( OutputDevice* pOut ) pOut->DrawBitmapEx( maDstPt, maDstSz, maSrcPt, maSrcSz, maBmpEx ); } -MetaAction* MetaBmpExScalePartAction::Clone() +rtl::Reference<MetaAction> MetaBmpExScalePartAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaBmpExScalePartAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaBmpExScalePartAction( *this ); } void MetaBmpExScalePartAction::Move( long nHorzMove, long nVertMove ) @@ -1832,11 +1789,9 @@ void MetaMaskAction::Execute( OutputDevice* pOut ) pOut->DrawMask( maPt, maBmp, maColor ); } -MetaAction* MetaMaskAction::Clone() +rtl::Reference<MetaAction> MetaMaskAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaMaskAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaMaskAction( *this ); } void MetaMaskAction::Move( long nHorzMove, long nVertMove ) @@ -1889,11 +1844,9 @@ void MetaMaskScaleAction::Execute( OutputDevice* pOut ) pOut->DrawMask( maPt, maSz, maBmp, maColor ); } -MetaAction* MetaMaskScaleAction::Clone() +rtl::Reference<MetaAction> MetaMaskScaleAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaMaskScaleAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaMaskScaleAction( *this ); } void MetaMaskScaleAction::Move( long nHorzMove, long nVertMove ) @@ -1954,11 +1907,9 @@ void MetaMaskScalePartAction::Execute( OutputDevice* pOut ) pOut->DrawMask( maDstPt, maDstSz, maSrcPt, maSrcSz, maBmp, maColor, MetaActionType::MASKSCALE ); } -MetaAction* MetaMaskScalePartAction::Clone() +rtl::Reference<MetaAction> MetaMaskScalePartAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaMaskScalePartAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaMaskScalePartAction( *this ); } void MetaMaskScalePartAction::Move( long nHorzMove, long nVertMove ) @@ -2018,11 +1969,9 @@ void MetaGradientAction::Execute( OutputDevice* pOut ) pOut->DrawGradient( maRect, maGradient ); } -MetaAction* MetaGradientAction::Clone() +rtl::Reference<MetaAction> MetaGradientAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaGradientAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaGradientAction( *this ); } void MetaGradientAction::Move( long nHorzMove, long nVertMove ) @@ -2067,16 +2016,13 @@ void MetaGradientExAction::Execute( OutputDevice* pOut ) { if( pOut->GetConnectMetaFile() ) { - Duplicate(); pOut->GetConnectMetaFile()->AddAction( this ); } } -MetaAction* MetaGradientExAction::Clone() +rtl::Reference<MetaAction> MetaGradientExAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaGradientExAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaGradientExAction( *this ); } void MetaGradientExAction::Move( long nHorzMove, long nVertMove ) @@ -2128,11 +2074,9 @@ void MetaHatchAction::Execute( OutputDevice* pOut ) pOut->DrawHatch( maPolyPoly, maHatch ); } -MetaAction* MetaHatchAction::Clone() +rtl::Reference<MetaAction> MetaHatchAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaHatchAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaHatchAction( *this ); } void MetaHatchAction::Move( long nHorzMove, long nVertMove ) @@ -2185,11 +2129,9 @@ void MetaWallpaperAction::Execute( OutputDevice* pOut ) pOut->DrawWallpaper( maRect, maWallpaper ); } -MetaAction* MetaWallpaperAction::Clone() +rtl::Reference<MetaAction> MetaWallpaperAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaWallpaperAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaWallpaperAction( *this ); } void MetaWallpaperAction::Move( long nHorzMove, long nVertMove ) @@ -2238,11 +2180,9 @@ void MetaClipRegionAction::Execute( OutputDevice* pOut ) pOut->SetClipRegion(); } -MetaAction* MetaClipRegionAction::Clone() +rtl::Reference<MetaAction> MetaClipRegionAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaClipRegionAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaClipRegionAction( *this ); } void MetaClipRegionAction::Move( long nHorzMove, long nVertMove ) @@ -2288,11 +2228,9 @@ void MetaISectRectClipRegionAction::Execute( OutputDevice* pOut ) pOut->IntersectClipRegion( maRect ); } -MetaAction* MetaISectRectClipRegionAction::Clone() +rtl::Reference<MetaAction> MetaISectRectClipRegionAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaISectRectClipRegionAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaISectRectClipRegionAction( *this ); } void MetaISectRectClipRegionAction::Move( long nHorzMove, long nVertMove ) @@ -2336,11 +2274,9 @@ void MetaISectRegionClipRegionAction::Execute( OutputDevice* pOut ) pOut->IntersectClipRegion( maRegion ); } -MetaAction* MetaISectRegionClipRegionAction::Clone() +rtl::Reference<MetaAction> MetaISectRegionClipRegionAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaISectRegionClipRegionAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaISectRegionClipRegionAction( *this ); } void MetaISectRegionClipRegionAction::Move( long nHorzMove, long nVertMove ) @@ -2386,11 +2322,9 @@ void MetaMoveClipRegionAction::Execute( OutputDevice* pOut ) pOut->MoveClipRegion( mnHorzMove, mnVertMove ); } -MetaAction* MetaMoveClipRegionAction::Clone() +rtl::Reference<MetaAction> MetaMoveClipRegionAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaMoveClipRegionAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaMoveClipRegionAction( *this ); } void MetaMoveClipRegionAction::Scale( double fScaleX, double fScaleY ) @@ -2437,11 +2371,9 @@ void MetaLineColorAction::Execute( OutputDevice* pOut ) pOut->SetLineColor(); } -MetaAction* MetaLineColorAction::Clone() +rtl::Reference<MetaAction> MetaLineColorAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaLineColorAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaLineColorAction( *this ); } void MetaLineColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) @@ -2481,11 +2413,9 @@ void MetaFillColorAction::Execute( OutputDevice* pOut ) pOut->SetFillColor(); } -MetaAction* MetaFillColorAction::Clone() +rtl::Reference<MetaAction> MetaFillColorAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaFillColorAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaFillColorAction( *this ); } void MetaFillColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) @@ -2520,11 +2450,9 @@ void MetaTextColorAction::Execute( OutputDevice* pOut ) pOut->SetTextColor( maColor ); } -MetaAction* MetaTextColorAction::Clone() +rtl::Reference<MetaAction> MetaTextColorAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaTextColorAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaTextColorAction( *this ); } void MetaTextColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) @@ -2562,11 +2490,9 @@ void MetaTextFillColorAction::Execute( OutputDevice* pOut ) pOut->SetTextFillColor(); } -MetaAction* MetaTextFillColorAction::Clone() +rtl::Reference<MetaAction> MetaTextFillColorAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaTextFillColorAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaTextFillColorAction( *this ); } void MetaTextFillColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) @@ -2606,11 +2532,9 @@ void MetaTextLineColorAction::Execute( OutputDevice* pOut ) pOut->SetTextLineColor(); } -MetaAction* MetaTextLineColorAction::Clone() +rtl::Reference<MetaAction> MetaTextLineColorAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaTextLineColorAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaTextLineColorAction( *this ); } void MetaTextLineColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) @@ -2650,11 +2574,9 @@ void MetaOverlineColorAction::Execute( OutputDevice* pOut ) pOut->SetOverlineColor(); } -MetaAction* MetaOverlineColorAction::Clone() +rtl::Reference<MetaAction> MetaOverlineColorAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaOverlineColorAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaOverlineColorAction( *this ); } void MetaOverlineColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) @@ -2690,11 +2612,9 @@ void MetaTextAlignAction::Execute( OutputDevice* pOut ) pOut->SetTextAlign( maAlign ); } -MetaAction* MetaTextAlignAction::Clone() +rtl::Reference<MetaAction> MetaTextAlignAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaTextAlignAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaTextAlignAction( *this ); } void MetaTextAlignAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) @@ -2729,11 +2649,9 @@ void MetaMapModeAction::Execute( OutputDevice* pOut ) pOut->SetMapMode( maMapMode ); } -MetaAction* MetaMapModeAction::Clone() +rtl::Reference<MetaAction> MetaMapModeAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaMapModeAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaMapModeAction( *this ); } void MetaMapModeAction::Scale( double fScaleX, double fScaleY ) @@ -2784,11 +2702,9 @@ void MetaFontAction::Execute( OutputDevice* pOut ) pOut->SetFont( maFont ); } -MetaAction* MetaFontAction::Clone() +rtl::Reference<MetaAction> MetaFontAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaFontAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaFontAction( *this ); } void MetaFontAction::Scale( double fScaleX, double fScaleY ) @@ -2836,11 +2752,9 @@ void MetaPushAction::Execute( OutputDevice* pOut ) pOut->Push( mnFlags ); } -MetaAction* MetaPushAction::Clone() +rtl::Reference<MetaAction> MetaPushAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaPushAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaPushAction( *this ); } void MetaPushAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) @@ -2870,11 +2784,9 @@ void MetaPopAction::Execute( OutputDevice* pOut ) pOut->Pop(); } -MetaAction* MetaPopAction::Clone() +rtl::Reference<MetaAction> MetaPopAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaPopAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaPopAction( *this ); } void MetaPopAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) @@ -2907,11 +2819,9 @@ void MetaRasterOpAction::Execute( OutputDevice* pOut ) pOut->SetRasterOp( meRasterOp ); } -MetaAction* MetaRasterOpAction::Clone() +rtl::Reference<MetaAction> MetaRasterOpAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaRasterOpAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaRasterOpAction( *this ); } void MetaRasterOpAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) @@ -2948,11 +2858,9 @@ void MetaTransparentAction::Execute( OutputDevice* pOut ) pOut->DrawTransparent( maPolyPoly, mnTransPercent ); } -MetaAction* MetaTransparentAction::Clone() +rtl::Reference<MetaAction> MetaTransparentAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaTransparentAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaTransparentAction( *this ); } void MetaTransparentAction::Move( long nHorzMove, long nVertMove ) @@ -3015,11 +2923,9 @@ void MetaFloatTransparentAction::Execute( OutputDevice* pOut ) pOut->DrawTransparent( maMtf, maPoint, maSize, maGradient ); } -MetaAction* MetaFloatTransparentAction::Clone() +rtl::Reference<MetaAction> MetaFloatTransparentAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaFloatTransparentAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaFloatTransparentAction( *this ); } void MetaFloatTransparentAction::Move( long nHorzMove, long nVertMove ) @@ -3076,11 +2982,9 @@ void MetaEPSAction::Execute( OutputDevice* pOut ) pOut->DrawEPS( maPoint, maSize, maGfxLink, &maSubst ); } -MetaAction* MetaEPSAction::Clone() +rtl::Reference<MetaAction> MetaEPSAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaEPSAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaEPSAction( *this ); } void MetaEPSAction::Move( long nHorzMove, long nVertMove ) @@ -3138,11 +3042,9 @@ void MetaRefPointAction::Execute( OutputDevice* pOut ) pOut->SetRefPoint(); } -MetaAction* MetaRefPointAction::Clone() +rtl::Reference<MetaAction> MetaRefPointAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaRefPointAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaRefPointAction( *this ); } void MetaRefPointAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) @@ -3206,16 +3108,13 @@ void MetaCommentAction::Execute( OutputDevice* pOut ) { if ( pOut->GetConnectMetaFile() ) { - Duplicate(); pOut->GetConnectMetaFile()->AddAction( this ); } } -MetaAction* MetaCommentAction::Clone() +rtl::Reference<MetaAction> MetaCommentAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaCommentAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaCommentAction( *this ); } void MetaCommentAction::Move( long nXMove, long nYMove ) @@ -3388,11 +3287,9 @@ void MetaLayoutModeAction::Execute( OutputDevice* pOut ) pOut->SetLayoutMode( mnLayoutMode ); } -MetaAction* MetaLayoutModeAction::Clone() +rtl::Reference<MetaAction> MetaLayoutModeAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaLayoutModeAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaLayoutModeAction( *this ); } void MetaLayoutModeAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) @@ -3428,11 +3325,9 @@ void MetaTextLanguageAction::Execute( OutputDevice* pOut ) pOut->SetDigitLanguage( meTextLanguage ); } -MetaAction* MetaTextLanguageAction::Clone() +rtl::Reference<MetaAction> MetaTextLanguageAction::Clone() { - MetaAction* pClone = static_cast<MetaAction*>(new MetaTextLanguageAction( *this )); - pClone->ResetRefCount(); - return pClone; + return new MetaTextLanguageAction( *this ); } void MetaTextLanguageAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) diff --git a/vcl/source/gdi/print2.cxx b/vcl/source/gdi/print2.cxx index 8bccc523ad9c..e131b061557b 100644 --- a/vcl/source/gdi/print2.cxx +++ b/vcl/source/gdi/print2.cxx @@ -1088,7 +1088,6 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, { // simply add this action (above, we inserted the actions // starting at index 0 up to and including nLastBgAction) - component.first->Duplicate(); rOutMtf.AddAction( component.first ); } @@ -1300,7 +1299,6 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, else { // simply add this action - pCurrAct->Duplicate(); rOutMtf.AddAction( pCurrAct ); } diff --git a/vcl/source/gdi/svmconverter.cxx b/vcl/source/gdi/svmconverter.cxx index a3a12575ebab..a9773ffbd682 100644 --- a/vcl/source/gdi/svmconverter.cxx +++ b/vcl/source/gdi/svmconverter.cxx @@ -669,13 +669,11 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) // Subdivided for better quality for older usages if(1 == aInputPolyPolygon.Count()) { - MetaAction* pAction = rMtf.ReplaceAction( + rMtf.ReplaceAction( new MetaPolyLineAction( aInputPolyPolygon.GetObject(0), pPolyLineAction->GetLineInfo()), nLastPolygonAction); - if(pAction) - pAction->Delete(); } } else @@ -688,12 +686,10 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) // same sub-polygon count if(pPolyPolygonAction->GetPolyPolygon().Count() == aInputPolyPolygon.Count()) { - MetaAction* pAction = rMtf.ReplaceAction( + rMtf.ReplaceAction( new MetaPolyPolygonAction( aInputPolyPolygon), nLastPolygonAction); - if(pAction) - pAction->Delete(); } } else @@ -705,12 +701,10 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) // replace MetaPolygonAction if(1 == aInputPolyPolygon.Count()) { - MetaAction* pAction = rMtf.ReplaceAction( + rMtf.ReplaceAction( new MetaPolygonAction( aInputPolyPolygon.GetObject(0)), nLastPolygonAction); - if(pAction) - pAction->Delete(); } } } diff --git a/vcl/source/graphic/UnoGraphicProvider.cxx b/vcl/source/graphic/UnoGraphicProvider.cxx index dd51f7533728..50c273006b85 100644 --- a/vcl/source/graphic/UnoGraphicProvider.cxx +++ b/vcl/source/graphic/UnoGraphicProvider.cxx @@ -655,15 +655,13 @@ void ImplApplyFilterData( ::Graphic& rGraphic, uno::Sequence< beans::PropertyVal ImplApplyBitmapResolution( aGraphic, nImageResolution, aGraphic.GetSizePixel(), awt::Size( aSize100thmm2.Width(), aSize100thmm2.Height() ) ); - MetaAction* pNewAction; + rtl::Reference<MetaAction> pNewAction; if ( pAction->GetType() == MetaActionType::BMPSCALE ) pNewAction = new MetaBmpScaleAction ( aPos, aSize, aGraphic.GetBitmap() ); else pNewAction = new MetaBmpExScaleAction( aPos, aSize, aGraphic.GetBitmapEx() ); - MetaAction* pDeleteAction = aMtf.ReplaceAction( pNewAction, i ); - if(pDeleteAction) - pDeleteAction->Delete(); + aMtf.ReplaceAction( pNewAction, i ); break; } default: |