summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2023-03-28 17:55:17 -0400
committerHenry Castro <hcastro@collabora.com>2023-06-17 03:22:00 +0200
commit9e2d4e9b43cb835c0fb2783374a1f2666807984c (patch)
tree61b59911a0d026ccbc34db85581745b5a5c0baae /sc
parent506db23af4da2c5c8775fb0fd6fb9b8668e2fe86 (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> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151978 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153200 Tested-by: Jenkins
Diffstat (limited to 'sc')
-rw-r--r--sc/source/filter/inc/condformatbuffer.hxx1
-rw-r--r--sc/source/filter/oox/condformatbuffer.cxx18
2 files changed, 16 insertions, 3 deletions
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 e721526406fb..046f37d2c4aa 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()