summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-12-01 15:19:12 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-12-01 21:28:21 +0100
commitc6aae3f4035f0a2dceba94b1956f5fc0ace3b3ee (patch)
treedd294a5a4f62f7160fe7c1b131bf597f304e3eb7 /chart2
parent88397d5cce34bf24fdb90f60befcc48dd4616187 (diff)
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.grandin@collabora.co.uk>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/inc/chartview/DrawModelWrapper.hxx2
-rw-r--r--chart2/source/view/main/ChartItemPool.cxx43
-rw-r--r--chart2/source/view/main/ChartItemPool.hxx8
-rw-r--r--chart2/source/view/main/DrawModelWrapper.cxx29
4 files changed, 34 insertions, 48 deletions
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 3cf5a99fc29d..9f4637b21e1f 100644
--- a/chart2/source/view/main/ChartItemPool.cxx
+++ b/chart2/source/view/main/ChartItemPool.cxx
@@ -221,48 +221,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();
}