diff options
author | Henry Castro <hcastro@collabora.com> | 2023-03-28 17:55:17 -0400 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2023-04-12 18:55:34 +0200 |
commit | b62e9fbf1ab54c9859852052aa94b332cd708ecd (patch) | |
tree | 73517b8afdbfe41062d5839eb2514400d56dd6f4 /sc | |
parent | 550eb72343eaeacb8b3b80f12e3acb4d4a1431e5 (diff) |
sc: filter: oox: only insert conditional format if has items
Otherwise, the empty conditional format will exists.
Signed-off-by: Henry Castro <hcastro@collabora.com>
Change-Id: I99d83bd50ce4c12ef9be6924cba31b8847c0ad07
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149720
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/filter/inc/condformatbuffer.hxx | 1 | ||||
-rw-r--r-- | sc/source/filter/oox/condformatbuffer.cxx | 18 |
2 files changed, 16 insertions, 3 deletions
diff --git a/sc/source/filter/inc/condformatbuffer.hxx b/sc/source/filter/inc/condformatbuffer.hxx index 0ff7006ee439..3af8f6f3e474 100644 --- a/sc/source/filter/inc/condformatbuffer.hxx +++ b/sc/source/filter/inc/condformatbuffer.hxx @@ -201,6 +201,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 6a9b80482f3a..1b0cb2e5405e 100644 --- a/sc/source/filter/oox/condformatbuffer.cxx +++ b/sc/source/filter/oox/condformatbuffer.cxx @@ -1097,6 +1097,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 ); @@ -1135,10 +1141,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() |