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-05-23 01:01:45 +0200
commit805c4cddd82d08e803fb921728f3f0b6a1b30ee9 (patch)
tree3b2829fe853e7035f1711600efd2db29dea5e53f /sc
parent4864bc29dade0c3eedd3192476e7c206dc4eedff (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>
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 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()