diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-10-16 10:14:49 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-10-16 18:27:40 +0200 |
commit | 6506279e3bed2284ce0ec9a0957a0201eb0d72ae (patch) | |
tree | 1eeec155055733c37516cb37e3226c94f65082b1 /chart2/source | |
parent | be71e660fd29a714466bf041a6b9b394b9fdbf08 (diff) |
tdf#157776: Do not set chart and its parent modified when painting
When the chart is painted for the first time, its update may create
the initial set of objects, which used to set modified state after
loading documents.
Change-Id: Ie50ef34875440058020486192fe649b492e4baf9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158015
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'chart2/source')
-rw-r--r-- | chart2/source/view/main/ChartView.cxx | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index d499aae6f298..08aaeb69ffe1 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -75,6 +75,7 @@ #include <osl/mutex.hxx> #include <svx/unofill.hxx> #include <drawinglayer/XShapeDumper.hxx> +#include <sfx2/objsh.hxx> #include <time.h> @@ -112,12 +113,9 @@ #include <memory> #include <libxml/xmlwriter.h> -namespace com::sun::star::chart2 { class XChartDocument; } - namespace chart { using namespace ::com::sun::star; -using namespace ::com::sun::star::chart2; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Any; @@ -1413,6 +1411,35 @@ void SAL_CALL ChartView::disposing( const lang::EventObject& /* rSource */ ) { } +namespace +{ +// Disables setting the chart's modified state, as well as its parent's (if exists). +// Painting a chart must not set these states. +struct ChartModelDisableSetModified +{ + ChartModel& mrChartModel; + SfxObjectShell* mpParentShell; + bool mbWasUnmodified; + ChartModelDisableSetModified(ChartModel& rChartModel) + : mrChartModel(rChartModel) + , mpParentShell(SfxObjectShell::GetShellFromComponent(rChartModel.getParent())) + , mbWasUnmodified(!rChartModel.isModified()) + { + if (mpParentShell && mpParentShell->IsEnableSetModified()) + mpParentShell->EnableSetModified(false); + else + mpParentShell = nullptr; + } + ~ChartModelDisableSetModified() + { + if (mbWasUnmodified && mrChartModel.isModified()) + mrChartModel.setModified(false); + if (mpParentShell) + mpParentShell->EnableSetModified(true); + } +}; +} + void ChartView::impl_updateView( bool bCheckLockedCtrler ) { if( !m_pDrawModelWrapper ) @@ -1443,6 +1470,9 @@ void ChartView::impl_updateView( bool bCheckLockedCtrler ) m_pDrawModelWrapper->lockControllers(); } + // Rendering the chart must not set its (or its parent) modified status + ChartModelDisableSetModified dontSetModified(mrChartModel); + //create chart view { m_bViewDirty = false; |