sc/source/filter/inc/condformatbuffer.hxx | 1 + sc/source/filter/oox/condformatbuffer.cxx | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-)
New commits: commit 805c4cddd82d08e803fb921728f3f0b6a1b30ee9 Author: Henry Castro <hcas...@collabora.com> AuthorDate: Tue Mar 28 17:55:17 2023 -0400 Commit: Henry Castro <hcas...@collabora.com> CommitDate: Tue May 23 01:01:45 2023 +0200 sc: filter: oox: only insert conditional format if has items Otherwise, the empty conditional format will exists. Signed-off-by: Henry Castro <hcas...@collabora.com> Change-Id: I99d83bd50ce4c12ef9be6924cba31b8847c0ad07 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149720 Reviewed-by: Andras Timar <andras.ti...@collabora.com> Tested-by: Andras Timar <andras.ti...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151978 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/sc/source/filter/inc/condformatbuffer.hxx b/sc/source/filter/inc/condformatbuffer.hxx index 9d3cc83fc953..e62917678b9a 100644 --- a/sc/source/filter/inc/condformatbuffer.hxx +++ b/sc/source/filter/inc/condformatbuffer.hxx @@ -202,6 +202,7 @@ class CondFormat final : public WorksheetHelper friend class CondFormatBuffer; public: explicit CondFormat( const WorksheetHelper& rHelper ); + ~CondFormat(); /** Imports settings from the conditionalFormatting element. */ void importConditionalFormatting( const AttributeList& rAttribs ); diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx index 1d5e55fdbc1b..c83f4676ba54 100644 --- a/sc/source/filter/oox/condformatbuffer.cxx +++ b/sc/source/filter/oox/condformatbuffer.cxx @@ -1099,6 +1099,12 @@ CondFormat::CondFormat( const WorksheetHelper& rHelper ) : { } +CondFormat::~CondFormat() +{ + if (!mbReadyForFinalize && mpFormat) + delete mpFormat; +} + void CondFormat::importConditionalFormatting( const AttributeList& rAttribs ) { getAddressConverter().convertToCellRangeList( maModel.maRanges, rAttribs.getString( XML_sqref, OUString() ), getSheetIndex(), true ); @@ -1137,10 +1143,16 @@ void CondFormat::finalizeImport() ScDocument& rDoc = getScDocument(); mpFormat->SetRange(maModel.maRanges); maRules.forEachMem( &CondFormatRule::finalizeImport ); - SCTAB nTab = maModel.maRanges.GetTopLeftCorner().Tab(); - sal_Int32 nIndex = getScDocument().AddCondFormat(std::unique_ptr<ScConditionalFormat>(mpFormat), nTab); - rDoc.AddCondFormatData( maModel.maRanges, nTab, nIndex ); + if (mpFormat->size() > 0) + { + SCTAB nTab = maModel.maRanges.GetTopLeftCorner().Tab(); + sal_Int32 nIndex = getScDocument().AddCondFormat(std::unique_ptr<ScConditionalFormat>(mpFormat), nTab); + + rDoc.AddCondFormatData( maModel.maRanges, nTab, nIndex ); + } + else + mbReadyForFinalize = false; } CondFormatRuleRef CondFormat::createRule()