tdf#118731 delay on showing dialogs that create SdrModels
for their preview widgets. since...
commit 4be44a7a6f2f480e55255d7cdd119f3d6577d085
Date: Thu May 24 19:09:44 2018 +0200
SOSAW080: Cleanup of SdrModel
Change-Id: I102b64bdacc56a41091bbe60e932c2915f20323f
Reviewed-on: https://gerrit.libreoffice.org/58693
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
diff --git a/cui/source/tabpages/tpline.cxx b/cui/source/tabpages/tpline.cxx
index 5a633ac..f8c8a8b 100644
--- a/cui/source/tabpages/tpline.cxx
+++ b/cui/source/tabpages/tpline.cxx
@@ -335,7 +335,7 @@ void SvxLineTabPage::InitSymbols(MenuButton const * pButton)
ScopedVclPtrInstance< VirtualDevice > pVDev;
pVDev->SetMapMode(MapMode(MapUnit::Map100thMM));
std::unique_ptr<SdrModel> pModel(
new SdrModel());
new SdrModel(nullptr, nullptr, true));
pModel->GetItemPool().FreezeIdRanges();
// Page
SdrPage* pPage = new SdrPage( *pModel, false );
@@ -1112,7 +1112,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs )
pVDev->SetMapMode(MapMode(MapUnit::Map100thMM));
std::unique_ptr<SdrModel> pModel(
new SdrModel());
new SdrModel(nullptr, nullptr, true));
pModel->GetItemPool().FreezeIdRanges();
SdrPage* pPage = new SdrPage( *pModel, false );
pPage->SetSize(Size(1000,1000));
diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx
index 127bf4e..62bb9dd 100644
--- a/include/svx/svdmodel.hxx
+++ b/include/svx/svdmodel.hxx
@@ -270,11 +270,12 @@ private:
SVX_DLLPRIVATE void ImpSetOutlinerDefaults( SdrOutliner* pOutliner, bool bInit = false );
SVX_DLLPRIVATE void ImpReformatAllTextObjects();
SVX_DLLPRIVATE void ImpReformatAllEdgeObjects();
SVX_DLLPRIVATE void ImpCreateTables();
SVX_DLLPRIVATE void ImpCreateTables(bool bDisablePropertyFiles);
SVX_DLLPRIVATE void ImpCtor(
SfxItemPool* pPool,
::comphelper::IEmbeddedHelper* pPers);
::comphelper::IEmbeddedHelper* pPers,
bool bDisablePropertyFiles);
// this is a weak reference to a possible living api wrapper for this model
css::uno::Reference< css::uno::XInterface > mxUnoModel;
@@ -293,9 +294,13 @@ 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.
//
// tdf#118731 a bDisablePropertyFiles of true will disable ability to load
// XPropertyFiles describing defaults. Useful for UI preview widgets
explicit SdrModel(
SfxItemPool* pPool = nullptr,
::comphelper::IEmbeddedHelper* pPers = nullptr);
::comphelper::IEmbeddedHelper* pPers = nullptr,
bool bDisablePropertyFiles = false);
virtual ~SdrModel() override;
void ClearModel(bool bCalledFromDestructor);
diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx
index e482f1f..6f757f1 100644
--- a/svx/source/dialog/dlgctrl.cxx
+++ b/svx/source/dialog/dlgctrl.cxx
@@ -1786,7 +1786,7 @@ void SvxPreviewBase::InitSettings(bool bForeground, bool bBackground)
SvxPreviewBase::SvxPreviewBase(vcl::Window* pParent)
: Control(pParent, WB_BORDER)
, mpModel(new SdrModel())
, mpModel(new SdrModel(nullptr, nullptr, true))
, mpBufferDevice(VclPtr<VirtualDevice>::Create(*this))
{
// Draw the control's border as a flat thin black line.
@@ -2189,7 +2189,7 @@ void PreviewBase::InitSettings()
}
PreviewBase::PreviewBase()
: mpModel(new SdrModel())
: mpModel(new SdrModel(nullptr, nullptr, true))
{
// init model
mpModel->GetItemPool().FreezeIdRanges();
diff --git a/svx/source/dialog/graphctl.cxx b/svx/source/dialog/graphctl.cxx
index 0f93252..17d416d 100644
--- a/svx/source/dialog/graphctl.cxx
+++ b/svx/source/dialog/graphctl.cxx
@@ -120,7 +120,7 @@ void GraphCtrl::InitSdrModel()
pModel.reset();
// Creating a Model
pModel.reset(new SdrModel());
pModel.reset(new SdrModel(nullptr, nullptr, true));
pModel->GetItemPool().FreezeIdRanges();
pModel->SetScaleUnit( aMap100.GetMapUnit() );
pModel->SetScaleFraction( Fraction( 1, 1 ) );
diff --git a/svx/source/dialog/measctrl.cxx b/svx/source/dialog/measctrl.cxx
index 2aa183e..578a49c 100644
--- a/svx/source/dialog/measctrl.cxx
+++ b/svx/source/dialog/measctrl.cxx
@@ -41,7 +41,7 @@ SvxXMeasurePreview::SvxXMeasurePreview(vcl::Window* pParent, WinBits nStyle)
Point aPt1 = Point(aSize.Width() / 5, static_cast<long>(aSize.Height() / 2));
Point aPt2 = Point(aSize.Width() * 4 / 5, static_cast<long>(aSize.Height() / 2));
pModel.reset(new SdrModel());
pModel.reset(new SdrModel(nullptr, nullptr, true));
pMeasureObj = new SdrMeasureObj(
*pModel,
aPt1,
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index a63401dc..4889328 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -100,7 +100,8 @@ struct SdrModelImpl
void SdrModel::ImpCtor(
SfxItemPool* pPool,
::comphelper::IEmbeddedHelper* _pEmbeddedHelper)
::comphelper::IEmbeddedHelper* _pEmbeddedHelper,
bool bDisablePropertyFiles)
{
mpImpl.reset(new SdrModelImpl);
mpImpl->mpUndoManager=nullptr;
@@ -198,12 +199,13 @@ void SdrModel::ImpCtor(
pTextChain.reset(new TextChain);
/* End Text Chaining related code */
ImpCreateTables();
ImpCreateTables(bDisablePropertyFiles || utl::ConfigManager::IsFuzzing());
}
SdrModel::SdrModel(
SfxItemPool* pPool,
::comphelper::IEmbeddedHelper* pPers)
::comphelper::IEmbeddedHelper* pPers,
bool bDisablePropertyFiles)
:
#ifdef DBG_UTIL
// SdrObjectLifetimeWatchDog:
@@ -212,7 +214,7 @@ SdrModel::SdrModel(
maMaPag(),
maPages()
{
ImpCtor(pPool,pPers);
ImpCtor(pPool,pPers,bDisablePropertyFiles);
}
SdrModel::~SdrModel()
@@ -606,10 +608,10 @@ bool SdrModel::IsUndoEnabled() const
}
}
void SdrModel::ImpCreateTables()
void SdrModel::ImpCreateTables(bool bDisablePropertyFiles)
{
// use standard path for initial construction
const OUString aTablePath(!utl::ConfigManager::IsFuzzing() ? SvtPathOptions().GetPalettePath() : "");
const OUString aTablePath(!bDisablePropertyFiles ? SvtPathOptions().GetPalettePath() : "");
for( auto i : o3tl::enumrange<XPropertyListType>() )
{