Kaydet (Commit) 4be44a7a authored tarafından Armin Le Grand's avatar Armin Le Grand

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/55028Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarArmin Le Grand <Armin.Le.Grand@cib.de>
üst 7d275e3a
......@@ -24,7 +24,7 @@ namespace basctl
{
DlgEdModel::DlgEdModel()
:SdrModel()
: SdrModel()
{
}
......
......@@ -156,7 +156,10 @@ Graphic ViewElementListProvider::GetSymbolGraphic( sal_Int32 nStandardSymbol, co
ScopedVclPtrInstance< VirtualDevice > pVDev;
pVDev->SetMapMode(MapMode(MapUnit::Map100thMM));
std::unique_ptr<SdrModel> pModel( new SdrModel );
std::unique_ptr<SdrModel> pModel(
new SdrModel());
pModel->GetItemPool().FreezeIdRanges();
SdrPage* pPage = new SdrPage( *pModel, false );
pPage->SetSize(Size(1000,1000));
......
......@@ -271,7 +271,10 @@ void ChartController::executeDispatch_Paste()
{
xStm->Seek( 0 );
Reference< io::XInputStream > xInputStream( new utl::OInputStreamWrapper( *xStm ) );
std::unique_ptr< SdrModel > spModel( new SdrModel() );
std::unique_ptr< SdrModel > spModel(
new SdrModel());
if ( SvxDrawingLayerImport( spModel.get(), xInputStream ) )
{
impl_PasteShapes( spModel.get() );
......
......@@ -114,8 +114,9 @@ void DrawCommandDispatch::setAttributes( SdrObject* pObj )
if ( aObjList[ i ].equalsIgnoreAsciiCase( m_aCustomShapeType ) )
{
FmFormModel aModel;
SfxItemPool& rPool = aModel.GetItemPool();
SfxItemPool& rPool(aModel.GetItemPool());
rPool.FreezeIdRanges();
if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aModel ) )
{
const SdrObject* pSourceObj = aModel.GetPage( 0 )->GetObj( 0 );
......
......@@ -50,10 +50,10 @@ namespace chart
{
DrawModelWrapper::DrawModelWrapper()
: SdrModel( SvtPathOptions().GetPalettePath(), nullptr, nullptr, false )
, m_pChartItemPool(nullptr)
, m_xMainDrawPage(nullptr)
, m_xHiddenDrawPage(nullptr)
: SdrModel()
, m_pChartItemPool(nullptr)
, m_xMainDrawPage(nullptr)
, m_xHiddenDrawPage(nullptr)
{
m_pChartItemPool = ChartItemPool::CreateChartItemPool();
......
......@@ -341,7 +341,8 @@ void SvxLineTabPage::InitSymbols(MenuButton const * pButton)
{
ScopedVclPtrInstance< VirtualDevice > pVDev;
pVDev->SetMapMode(MapMode(MapUnit::Map100thMM));
std::unique_ptr<SdrModel> pModel(new SdrModel);
std::unique_ptr<SdrModel> pModel(
new SdrModel());
pModel->GetItemPool().FreezeIdRanges();
// Page
SdrPage* pPage = new SdrPage( *pModel, false );
......@@ -1119,7 +1120,8 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs )
ScopedVclPtrInstance< VirtualDevice > pVDev;
pVDev->SetMapMode(MapMode(MapUnit::Map100thMM));
std::unique_ptr<SdrModel> pModel(new SdrModel);
std::unique_ptr<SdrModel> pModel(
new SdrModel());
pModel->GetItemPool().FreezeIdRanges();
SdrPage* pPage = new SdrPage( *pModel, false );
pPage->SetSize(Size(1000,1000));
......
......@@ -47,12 +47,9 @@ private:
void operator=(const FmFormModel& rSrcModel) = delete;
public:
FmFormModel(SfxItemPool* pPool=nullptr, SfxObjectShell* pPers=nullptr );
FmFormModel(const OUString& rPath, SfxItemPool* pPool=nullptr,
SfxObjectShell* pPers=nullptr );
FmFormModel(const OUString& rPath, SfxItemPool* pPool, SfxObjectShell* pPers,
bool bUseExtColorTable);
FmFormModel(
SfxItemPool* pPool = nullptr,
SfxObjectShell* pPers = nullptr);
virtual ~FmFormModel() override;
......
......@@ -138,6 +138,15 @@ public:
SdrHintKind GetKind() const { return meHint;}
};
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// SdrModel
// DlgEdModel
// FmFormModel
// ScDrawLayer
// SdDrawDocument
// SwDrawModel
// OReportModel
struct SdrModelImpl;
......@@ -147,7 +156,6 @@ protected:
std::vector<SdrPage*> maMaPag; // master pages
std::vector<SdrPage*> maPages;
Link<SdrUndoAction*,void> aUndoLink; // link to a NotifyUndo-Handler
OUString aTablePath;
Size aMaxObjSize; // e.g. for auto-growing text
Fraction aObjUnit; // description of the coordinate units for ClipBoard, Drag&Drop, ...
MapUnit eObjUnit; // see above
......@@ -236,8 +244,10 @@ private:
SVX_DLLPRIVATE void ImpReformatAllTextObjects();
SVX_DLLPRIVATE void ImpReformatAllEdgeObjects();
SVX_DLLPRIVATE void ImpCreateTables();
SVX_DLLPRIVATE void ImpCtor(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* pPers, bool bUseExtColorTable);
SVX_DLLPRIVATE void ImpCtor(
SfxItemPool* pPool,
::comphelper::IEmbeddedHelper* pPers);
// this is a weak reference to a possible living api wrapper for this model
css::uno::Reference< css::uno::XInterface > mxUnoModel;
......@@ -256,9 +266,9 @@ public:
// if you want to use symbol objects inherited from SdrAttrObj.
// If, however, you use objects inheriting from SdrObject you are free
// to chose a pool of your liking.
explicit SdrModel();
explicit SdrModel(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* pPers);
explicit SdrModel(const OUString& rPath, SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* pPers, bool bUseExtColorTable);
explicit SdrModel(
SfxItemPool* pPool = nullptr,
::comphelper::IEmbeddedHelper* pPers = nullptr);
virtual ~SdrModel() override;
void ClearModel(bool bCalledFromDestructor);
......
......@@ -45,8 +45,10 @@ using namespace reportdesign;
using namespace com::sun::star;
OReportModel::OReportModel(::reportdesign::OReportDefinition* _pReportDefinition) :
SdrModel(SvtPathOptions().GetPalettePath(),nullptr,_pReportDefinition, false)
OReportModel::OReportModel(::reportdesign::OReportDefinition* _pReportDefinition)
: SdrModel(
nullptr,
_pReportDefinition)
,m_pController(nullptr)
,m_pReportDefinition(_pReportDefinition)
{
......
......@@ -241,12 +241,9 @@ static ScRange lcl_getClipRangeFromClipDoc(ScDocument* pClipDoc, SCTAB nClipTab)
}
ScDrawLayer::ScDrawLayer( ScDocument* pDocument, const OUString& rName ) :
FmFormModel( !utl::ConfigManager::IsFuzzing() ? SvtPathOptions().GetPalettePath() : OUString(),
nullptr, // SfxItemPool* Pool
pGlobalDrawPersist ?
pGlobalDrawPersist :
( pDocument ? pDocument->GetDocumentShell() : nullptr ),
true ), // bUseExtColorTable (is set below)
FmFormModel(
nullptr,
pGlobalDrawPersist ? pGlobalDrawPersist : (pDocument ? pDocument->GetDocumentShell() : nullptr)),
aName( rName ),
pDoc( pDocument ),
bRecording( false ),
......
......@@ -162,8 +162,9 @@ void FuConstCustomShape::SetAttributes( SdrObject* pObj )
if ( aObjList[ i ].equalsIgnoreAsciiCase( aCustomShape ) )
{
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 );
......
......@@ -22,7 +22,6 @@
#include <svx/svdpage.hxx>
#include <svx/svdocapt.hxx>
#include <sfx2/printer.hxx>
#include <unotools/pathoptions.hxx>
#include <svl/itempool.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
......@@ -79,9 +78,7 @@ IMPL_LINK_NOARG(ScNoteMarker, TimeHdl, Timer *, void)
{
if (!m_bVisible)
{
SvtPathOptions aPathOpt;
OUString aPath = aPathOpt.GetPalettePath();
m_pModel = new SdrModel(aPath, nullptr, nullptr, false);
m_pModel = new SdrModel();
m_pModel->SetScaleUnit(MapUnit::Map100thMM);
SfxItemPool& rPool = m_pModel->GetItemPool();
rPool.SetDefaultMetric(MapUnit::Map100thMM);
......
......@@ -38,7 +38,6 @@
#include <sot/formats.hxx>
#include <sot/filelist.hxx>
#include <sot/storage.hxx>
#include <unotools/pathoptions.hxx>
#include <svl/ptitem.hxx>
#include <svl/stritem.hxx>
#include <svtools/transfer.hxx>
......@@ -508,12 +507,13 @@ bool ScViewFunc::PasteDataFormat( SotClipboardFormatId nFormatId,
{
MakeDrawLayer(); // before loading model, so 3D factory has been created
SvtPathOptions aPathOpt;
OUString aPath = aPathOpt.GetPalettePath();
ScDocShellRef aDragShellRef( new ScDocShell );
aDragShellRef->DoInitNew();
std::unique_ptr<FmFormModel> pModel(new FmFormModel( aPath, nullptr, aDragShellRef.get() ));
std::unique_ptr<FmFormModel> pModel(
new FmFormModel(
nullptr,
aDragShellRef.get()));
pModel->GetItemPool().FreezeIdRanges();
xStm->Seek(0);
......
......@@ -131,7 +131,9 @@ PresentationSettings::PresentationSettings()
}
SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh)
: FmFormModel( !utl::ConfigManager::IsFuzzing() ? SvtPathOptions().GetPalettePath() : OUString(), nullptr, pDrDocSh )
: FmFormModel(
nullptr,
pDrDocSh)
, mpOutliner(nullptr)
, mpInternalOutliner(nullptr)
, mpWorkStartupTimer(nullptr)
......
......@@ -175,8 +175,9 @@ void FuConstructCustomShape::SetAttributes( SdrObject* pObj )
if ( aObjList[ i ].equalsIgnoreAsciiCase( aCustomShape ) )
{
FmFormModel aFormModel;
SfxItemPool& rPool = aFormModel.GetItemPool();
SfxItemPool& rPool(aFormModel.GetItemPool());
rPool.FreezeIdRanges();
if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aFormModel ) )
{
const SdrPage* pPage = aFormModel.GetPage( 0 );
......
......@@ -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 ) );
......
......@@ -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>{});
......
......@@ -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)
......
......@@ -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;
}
......
......@@ -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 );
......
......@@ -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();
......
......@@ -20,7 +20,6 @@
#include <svx/svxids.hrc>
#include <tools/stream.hxx>
#include <unotools/configmgr.hxx>
#include <unotools/pathoptions.hxx>
#include <sot/storage.hxx>
#include <svl/intitem.hxx>
#include <editeng/forbiddencharacterstable.hxx>
......@@ -41,18 +40,10 @@
using namespace com::sun::star;
// Constructor
const OUString GetPalettePath()
{
if (utl::ConfigManager::IsFuzzing())
return OUString();
SvtPathOptions aPathOpt;
return aPathOpt.GetPalettePath();
}
SwDrawModel::SwDrawModel(SwDoc *const pDoc)
: FmFormModel( ::GetPalettePath(), &pDoc->GetAttrPool(),
pDoc->GetDocShell(), true )
: FmFormModel(
&pDoc->GetAttrPool(),
pDoc->GetDocShell())
, m_pDoc( pDoc )
{
SetScaleUnit( MapUnit::MapTwip );
......
......@@ -23,7 +23,6 @@
#include <vcl/graph.hxx>
#include <sot/formats.hxx>
#include <sot/storage.hxx>
#include <unotools/pathoptions.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/viewsh.hxx>
......@@ -1308,9 +1307,11 @@ void SwFEShell::Paste( SvStream& rStrm, SwPasteSdr nAction, const Point* pPt )
StartAllAction();
StartUndo();
SvtPathOptions aPathOpt;
std::unique_ptr<FmFormModel> pModel( new FmFormModel( aPathOpt.GetPalettePath(),
nullptr, GetDoc()->GetDocShell() ) );
std::unique_ptr< FmFormModel > pModel(
new FmFormModel(
nullptr,
GetDoc()->GetDocShell()));
pModel->GetItemPool().FreezeIdRanges();
rStrm.Seek(0);
......
......@@ -119,8 +119,9 @@ void ConstCustomShape::SetAttributes( SdrObject* pObj )
if ( aObjList[ i ].equalsIgnoreAsciiCase( aCustomShape ) )
{
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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment