chart2/source/inc/chartview/DrawModelWrapper.hxx | 2 - chart2/source/view/main/ChartItemPool.cxx | 43 +---------------------- chart2/source/view/main/ChartItemPool.hxx | 8 +--- chart2/source/view/main/DrawModelWrapper.cxx | 29 ++++++++++++++- 4 files changed, 34 insertions(+), 48 deletions(-)
New commits: commit 64db5c602b25aeaefcbb8ac93413a8e6b6ef5ffa Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Dec 1 15:19:12 2022 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Dec 27 18:10:41 2022 +0000 tdf#145599 Charts gets corrupted when you draw a line inside them This reverts commit 2ed8c34bca56c1a30d727b21d9096cb77e88197a use a single global item pool for chart2 draw model Change-Id: I640a981a2cbbed1cb9e6c0b0c239c78bb481e12e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143526 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> (cherry picked from commit c6aae3f4035f0a2dceba94b1956f5fc0ace3b3ee) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144803 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/chart2/source/inc/chartview/DrawModelWrapper.hxx b/chart2/source/inc/chartview/DrawModelWrapper.hxx index 0b4da35435d4..fb977528e8f1 100644 --- a/chart2/source/inc/chartview/DrawModelWrapper.hxx +++ b/chart2/source/inc/chartview/DrawModelWrapper.hxx @@ -40,7 +40,7 @@ class OOO_DLLPUBLIC_CHARTVIEW DrawModelWrapper final : private SdrModel private: rtl::Reference<SvxDrawPage> m_xMainDrawPage; rtl::Reference<SvxDrawPage> m_xHiddenDrawPage; - + rtl::Reference<SfxItemPool> m_xChartItemPool; VclPtr<OutputDevice> m_pRefDevice; public: diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx index 37e78c116b76..3410bcdbf24e 100644 --- a/chart2/source/view/main/ChartItemPool.cxx +++ b/chart2/source/view/main/ChartItemPool.cxx @@ -216,48 +216,9 @@ MapUnit ChartItemPool::GetMetric(sal_uInt16 /* nWhich */) const return MapUnit::Map100thMM; } -static rtl::Reference<SfxItemPool> g_Pool1, g_Pool2, g_Pool3; - -/** If we let the libc runtime clean us up, we trigger a crash */ -namespace -{ -class TerminateListener : public ::cppu::WeakImplHelper< css::frame::XTerminateListener > -{ - void SAL_CALL queryTermination( const css::lang::EventObject& ) override - {} - void SAL_CALL notifyTermination( const css::lang::EventObject& ) override - { - g_Pool1.clear(); - g_Pool2.clear(); - g_Pool3.clear(); - } - virtual void SAL_CALL disposing( const ::css::lang::EventObject& ) override - {} -}; -}; - -SfxItemPool& ChartItemPool::GetGlobalChartItemPool() +rtl::Reference<SfxItemPool> ChartItemPool::CreateChartItemPool() { - if (!g_Pool1) - { - // similar logic to SdrModel's pool, but with our chart pool tagged on the end - g_Pool1 = new SdrItemPool(nullptr); - g_Pool2 = EditEngine::CreatePool(); - g_Pool3 = new ChartItemPool(); - g_Pool1->SetSecondaryPool(g_Pool2.get()); - - g_Pool1->SetDefaultMetric(MapUnit::Map100thMM); - g_Pool1->SetPoolDefaultItem(SfxBoolItem(EE_PARA_HYPHENATE, true) ); - g_Pool1->SetPoolDefaultItem(makeSvx3DPercentDiagonalItem (5)); - - g_Pool2->SetSecondaryPool(g_Pool3.get()); - g_Pool1->FreezeIdRanges(); - - css::uno::Reference< css::frame::XDesktop2 > xDesktop = css::frame::Desktop::create(comphelper::getProcessComponentContext()); - css::uno::Reference< css::frame::XTerminateListener > xListener( new TerminateListener ); - xDesktop->addTerminateListener( xListener ); - } - return *g_Pool1; + return new ChartItemPool(); } } // namespace chart diff --git a/chart2/source/view/main/ChartItemPool.hxx b/chart2/source/view/main/ChartItemPool.hxx index 2ac440183740..74a7ab1ebb29 100644 --- a/chart2/source/view/main/ChartItemPool.hxx +++ b/chart2/source/view/main/ChartItemPool.hxx @@ -29,18 +29,16 @@ class ChartItemPool : public SfxItemPool private: std::unique_ptr<SfxItemInfo[]> pItemInfos; +public: ChartItemPool(); ChartItemPool(const ChartItemPool& rPool); - -protected: virtual ~ChartItemPool() override; -public: virtual rtl::Reference<SfxItemPool> Clone() const override; MapUnit GetMetric(sal_uInt16 nWhich) const override; - /// get the pure chart item pool - static SfxItemPool& GetGlobalChartItemPool(); + /// creates a pure chart item pool + static rtl::Reference<SfxItemPool> CreateChartItemPool(); }; } // namespace chart diff --git a/chart2/source/view/main/DrawModelWrapper.cxx b/chart2/source/view/main/DrawModelWrapper.cxx index aa7a002c967a..6a6488435f97 100644 --- a/chart2/source/view/main/DrawModelWrapper.cxx +++ b/chart2/source/view/main/DrawModelWrapper.cxx @@ -25,6 +25,7 @@ #include <svl/itempool.hxx> #include <svx/objfac3d.hxx> #include <svx/svdpage.hxx> +#include <svx/svx3ditems.hxx> #include <svx/xtable.hxx> #include <svx/svdoutl.hxx> #include <editeng/unolingu.hxx> @@ -43,12 +44,22 @@ namespace chart { DrawModelWrapper::DrawModelWrapper() -: SdrModel(&ChartItemPool::GetGlobalChartItemPool()) +: SdrModel() { + m_xChartItemPool = ChartItemPool::CreateChartItemPool(); + SetScaleUnit(MapUnit::Map100thMM); SetScaleFraction(Fraction(1, 1)); SetDefaultFontHeight(423); // 12pt + SfxItemPool* pMasterPool = &GetItemPool(); + pMasterPool->SetDefaultMetric(MapUnit::Map100thMM); + pMasterPool->SetPoolDefaultItem(SfxBoolItem(EE_PARA_HYPHENATE, true) ); + pMasterPool->SetPoolDefaultItem(makeSvx3DPercentDiagonalItem (5)); + + // append chart pool to end of pool chain + pMasterPool->GetLastPoolInChain()->SetSecondaryPool(m_xChartItemPool.get()); + pMasterPool->FreezeIdRanges(); SetTextDefaults(); //this factory needs to be created before first use of 3D scenes once upon an office runtime @@ -92,6 +103,22 @@ DrawModelWrapper::DrawModelWrapper() DrawModelWrapper::~DrawModelWrapper() { + //remove m_pChartItemPool from pool chain + if(m_xChartItemPool) + { + SfxItemPool* pPool = &GetItemPool(); + for (;;) + { + SfxItemPool* pSecondary = pPool->GetSecondaryPool(); + if(pSecondary == m_xChartItemPool.get()) + { + pPool->SetSecondaryPool (nullptr); + break; + } + pPool = pSecondary; + } + m_xChartItemPool.clear(); + } m_pRefDevice.disposeAndClear(); }