diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de> | 2018-05-24 19:09:44 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@cib.de> | 2018-05-31 15:53:51 +0200 |
commit | 4be44a7a6f2f480e55255d7cdd119f3d6577d085 (patch) | |
tree | e07008be8355538160d52ea94eb35a10dc83a4a1 /svx | |
parent | 7d275e3ab35b3f9bfd7ff16290393ca027c50355 (diff) |
SOSAW080: Cleanup of SdrModel
First step: Find all constructors/derivations, mark
all of them.
Removed two-value-constructors, adapted code as needed
Reduced constructors for SdrModel/FmFormModel
to a single one.
Removed PathName for List creation, this is not
needed and anyways all calls used the default
SvtPathOptions().GetPalettePath(). This is also
true for usage of IsFuzzing() that is also part
of the default creation process (without path).
All usages that need an extra-List were setting
it after construction explicitely.
Removed UseExtColorTable. This prevents a single
List to be not created by default, the ColorTable
which is replaced later by all callers that used
this. This is not needed since the default
ColorTable gets constructed just by default, no
expensive stuff is triggered (e.g. loading the
ColorTable). Thus now a default ColorTable is
created and kept for a short moment, destructed
again when a ColorTable is explicitely set.
Doing so is also more safe - it avoids not
creating a default-ColorTable and then not setting
one (what would be urgently required).
f23c24a8548d5246b77b1cc359ba89564538e81a
f124468c3898c5842d37123bdeb87d79a2b19c62
Change-Id: I865de4bb23f673c6684d83c2c6390439506dc5b6
Reviewed-on: https://gerrit.libreoffice.org/55028
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/dialog/graphctl.cxx | 2 | ||||
-rw-r--r-- | svx/source/engine3d/float3d.cxx | 4 | ||||
-rw-r--r-- | svx/source/form/fmmodel.cxx | 31 | ||||
-rw-r--r-- | svx/source/svdraw/svdmodel.cxx | 53 | ||||
-rw-r--r-- | svx/source/toolbars/fontworkbar.cxx | 3 | ||||
-rw-r--r-- | svx/source/unogallery/unogalitem.cxx | 2 |
6 files changed, 27 insertions, 68 deletions
diff --git a/svx/source/dialog/graphctl.cxx b/svx/source/dialog/graphctl.cxx index 45fd6f18d107..91073760eaa3 100644 --- a/svx/source/dialog/graphctl.cxx +++ b/svx/source/dialog/graphctl.cxx @@ -128,7 +128,7 @@ void GraphCtrl::InitSdrModel() delete pModel; // Creating a Model - pModel = new SdrModel; + pModel = new SdrModel(); pModel->GetItemPool().FreezeIdRanges(); pModel->SetScaleUnit( aMap100.GetMapUnit() ); pModel->SetScaleFraction( Fraction( 1, 1 ) ); diff --git a/svx/source/engine3d/float3d.cxx b/svx/source/engine3d/float3d.cxx index 98f9fb485df3..615957ada6a4 100644 --- a/svx/source/engine3d/float3d.cxx +++ b/svx/source/engine3d/float3d.cxx @@ -2786,8 +2786,10 @@ void Svx3DWin::LBSelectColor( SvxColorListBox* pLb, const Color& rColor ) void Svx3DWin::UpdatePreview() { - if( pModel == nullptr ) + if(nullptr == pModel) + { pModel = new FmFormModel(); + } // Get Itemset SfxItemSet aSet( pModel->GetItemPool(), svl::Items<SDRATTR_START, SDRATTR_END>{}); diff --git a/svx/source/form/fmmodel.cxx b/svx/source/form/fmmodel.cxx index ef5f56e09c41..decabb6cb5e6 100644 --- a/svx/source/form/fmmodel.cxx +++ b/svx/source/form/fmmodel.cxx @@ -49,31 +49,12 @@ struct FmFormModelImplData } }; -FmFormModel::FmFormModel(SfxItemPool* pPool, SfxObjectShell* pPers) - : SdrModel(pPool, pPers) - , m_pImpl(nullptr) - , m_pObjShell(nullptr) - , m_bOpenInDesignMode(false) - , m_bAutoControlFocus(false) -{ - m_pImpl.reset( new FmFormModelImplData ); - m_pImpl->mxUndoEnv = new FmXUndoEnvironment(*this); -} - -FmFormModel::FmFormModel(const OUString& rPath, SfxItemPool* pPool, SfxObjectShell* pPers) - : SdrModel(rPath, pPool, pPers, false) - , m_pImpl(nullptr) - , m_pObjShell(nullptr) - , m_bOpenInDesignMode(false) - , m_bAutoControlFocus(false) -{ - m_pImpl.reset( new FmFormModelImplData ); - m_pImpl->mxUndoEnv = new FmXUndoEnvironment(*this); -} - -FmFormModel::FmFormModel(const OUString& rPath, SfxItemPool* pPool, SfxObjectShell* pPers, - bool bUseExtColorTable) - : SdrModel(rPath, pPool, pPers, bUseExtColorTable) +FmFormModel::FmFormModel( + SfxItemPool* pPool, + SfxObjectShell* pPers) +: SdrModel( + pPool, + pPers) , m_pImpl(nullptr) , m_pObjShell(nullptr) , m_bOpenInDesignMode(false) diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx index bde671498fd1..b28b6f8c734e 100644 --- a/svx/source/svdraw/svdmodel.cxx +++ b/svx/source/svdraw/svdmodel.cxx @@ -17,22 +17,17 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - #include <svx/svdmodel.hxx> - #include <cassert> #include <math.h> - #include <osl/endian.h> #include <rtl/strbuf.hxx> #include <sal/log.hxx> - #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/document/XStorageBasedDocument.hpp> #include <com/sun/star/embed/ElementModes.hpp> - #include <unotools/configmgr.hxx> - +#include <unotools/pathoptions.hxx> #include <svl/whiter.hxx> #include <svl/asiancfg.hxx> #include <svx/xit.hxx> @@ -43,12 +38,9 @@ #include <svx/xflftrit.hxx> #include <svx/xflhtit.hxx> #include <svx/xlnstit.hxx> - #include <editeng/editdata.hxx> #include <editeng/editeng.hxx> - #include <svx/xtable.hxx> - #include <svx/svditer.hxx> #include <svx/svdtrans.hxx> #include <svx/svdpage.hxx> @@ -64,10 +56,8 @@ #include <svx/dialmgr.hxx> #include <svx/strings.hrc> #include <svdoutlinercache.hxx> - #include <svx/xflclit.hxx> #include <svx/xlnclit.hxx> - #include <officecfg/Office/Common.hxx> #include <editeng/fontitem.hxx> #include <editeng/colritem.hxx> @@ -80,10 +70,8 @@ #include <svl/zforlist.hxx> #include <comphelper/servicehelper.hxx> #include <comphelper/storagehelper.hxx> - #include <tools/tenccvt.hxx> #include <unotools/syslocale.hxx> - #include <svx/sdr/properties/properties.hxx> #include <editeng/eeitem.hxx> #include <svl/itemset.hxx> @@ -111,8 +99,9 @@ struct SdrModelImpl }; -void SdrModel::ImpCtor(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* _pEmbeddedHelper, - bool bUseExtColorTable) +void SdrModel::ImpCtor( + SfxItemPool* pPool, + ::comphelper::IEmbeddedHelper* _pEmbeddedHelper) { mpImpl.reset(new SdrModelImpl); mpImpl->mpUndoManager=nullptr; @@ -168,8 +157,6 @@ void SdrModel::ImpCtor(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* _pEmbe else mnCharCompressType = CharCompressType::NONE; - bExtColorTable=bUseExtColorTable; - if ( pPool == nullptr ) { pItemPool=new SdrItemPool(nullptr); @@ -216,26 +203,13 @@ void SdrModel::ImpCtor(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* _pEmbe ImpCreateTables(); } -SdrModel::SdrModel(): - maMaPag(), +SdrModel::SdrModel( + SfxItemPool* pPool, + ::comphelper::IEmbeddedHelper* pPers) +: maMaPag(), maPages() { - ImpCtor(nullptr, nullptr, false); -} - -SdrModel::SdrModel(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* pPers): - maMaPag(), - maPages() -{ - ImpCtor(pPool,pPers,false/*bUseExtColorTable*/); -} - -SdrModel::SdrModel(const OUString& rPath, SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* pPers, bool bUseExtColorTable): - maMaPag(), - maPages(), - aTablePath(rPath) -{ - ImpCtor(pPool,pPers,bUseExtColorTable); + ImpCtor(pPool,pPers); } SdrModel::~SdrModel() @@ -616,11 +590,12 @@ bool SdrModel::IsUndoEnabled() const void SdrModel::ImpCreateTables() { + // use standard path for initial construction + const OUString aTablePath(!utl::ConfigManager::IsFuzzing() ? SvtPathOptions().GetPalettePath() : ""); + for( auto i : o3tl::enumrange<XPropertyListType>() ) { - if( !bExtColorTable || i != XPropertyListType::Color ) - maProperties[i] = XPropertyList::CreatePropertyList ( - i, aTablePath, ""/*TODO?*/ ); + maProperties[i] = XPropertyList::CreatePropertyList(i, aTablePath, ""/*TODO?*/ ); } } @@ -655,7 +630,7 @@ void SdrModel::ClearModel(bool bCalledFromDestructor) SdrModel* SdrModel::AllocModel() const { - SdrModel* pModel=new SdrModel; + SdrModel* pModel=new SdrModel(); pModel->SetScaleUnit(eObjUnit,aObjUnit); return pModel; } diff --git a/svx/source/toolbars/fontworkbar.cxx b/svx/source/toolbars/fontworkbar.cxx index 338907dc1096..cdfc32236443 100644 --- a/svx/source/toolbars/fontworkbar.cxx +++ b/svx/source/toolbars/fontworkbar.cxx @@ -354,8 +354,9 @@ void GetGeometryForCustomShape( SdrCustomShapeGeometryItem& rGeometryItem, const if ( aObjList[ i ].equalsIgnoreAsciiCase( rCustomShape ) ) { FmFormModel aFormModel; - SfxItemPool& rPool = aFormModel.GetItemPool(); + SfxItemPool& rPool(aFormModel.GetItemPool()); rPool.FreezeIdRanges(); + if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aFormModel ) ) { const SdrObject* pSourceObj = aFormModel.GetPage( 0 )->GetObj( 0 ); diff --git a/svx/source/unogallery/unogalitem.cxx b/svx/source/unogallery/unogalitem.cxx index 6f1bbfecfc7f..361edc2f9a55 100644 --- a/svx/source/unogallery/unogalitem.cxx +++ b/svx/source/unogallery/unogalitem.cxx @@ -322,7 +322,7 @@ void GalleryItem::_getPropertyValues( const comphelper::PropertyMapEntry** ppEnt if( gallery::GalleryItemType::DRAWING == getType() ) { ::GalleryTheme* pGalTheme = ( isValid() ? mpTheme->implGetTheme() : nullptr ); - FmFormModel* pModel = new FmFormModel; + FmFormModel* pModel = new FmFormModel(); pModel->GetItemPool().FreezeIdRanges(); |