summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2021-08-26 19:10:58 +0200
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2021-09-08 19:25:50 +0200
commit25bdfc5404f210ed889e452cb3b7deb016c6c0d3 (patch)
tree37de4323096233527e88279fc532a05b21d3e065
parent38c87f7bad183877a172d10e60607c85f8aa414b (diff)
tdf#143940: the style index might be -1
Similar to 52aebe6986bcec07071adb3f94d6c09fea147044 < tdf#138466 Crash when creating different scenarios > ExportColumns calls GetStyleNameIndex which might return -1 so check the index is different than -1 as it's already done when calling ScFormatRangeStyles::GetStyleNameByIndex Also move fix for tdf#138466 down the stack to be consistent Debug builds will still assert, see coverity#1438402 Since 5e777f23fd0118f6649f0d9e30eb77a72f1099e4 < loplugin:useuniqueptr in ScColumnRowStylesBase > where the nIndex < 0 check in ScColumnRowStylesBase::GetStyleNameByIndex was removed Change-Id: I084bfa04c39f37cb325c3b3df76801b3abdea994 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121128 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> (cherry picked from commit 7246759822aff30e4e4e1bca7949eae3b0d960ef) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121068 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> (cherry picked from commit aecdbb01ea6d89d1e3e25707b0dcd2bedaeb64a6) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121287 Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com> Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> Tested-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
-rw-r--r--sc/source/filter/xml/xmlexprt.cxx12
1 files changed, 7 insertions, 5 deletions
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 497daf4a49e3..affd763e80ad 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -737,7 +737,9 @@ void ScXMLExport::WriteSingleColumn(const sal_Int32 nRepeatColumns, const sal_In
const sal_Int32 nIndex, const bool bIsAutoStyle, const bool bIsVisible)
{
CheckAttrList();
- AddAttribute(sAttrStyleName, pColumnStyles->GetStyleNameByIndex(nStyleIndex));
+ // tdf#138466
+ if (nStyleIndex != -1)
+ AddAttribute(sAttrStyleName, pColumnStyles->GetStyleNameByIndex(nStyleIndex));
if (!bIsVisible)
AddAttribute(XML_NAMESPACE_TABLE, XML_VISIBILITY, XML_COLLAPSE);
if (nRepeatColumns > 1)
@@ -870,9 +872,7 @@ void ScXMLExport::ExportColumns(const sal_Int32 nTable, const ScRange& aColumnHe
nColsRepeated = 1;
}
}
- // tdf#138466
- if (nPrevIndex != -1)
- WriteColumn(nPrevColumn, nColsRepeated, nPrevIndex, bPrevIsVisible);
+ WriteColumn(nPrevColumn, nColsRepeated, nPrevIndex, bPrevIsVisible);
if (!bIsClosed)
CloseHeaderColumn();
if (pGroupColumns->IsGroupEnd(nColumn - 1))
@@ -1351,7 +1351,9 @@ void ScXMLExport::WriteRowStartTag(
const sal_Int32 nIndex, const sal_Int32 nEqualRows,
bool bHidden, bool bFiltered)
{
- AddAttribute(sAttrStyleName, pRowStyles->GetStyleNameByIndex(nIndex));
+ // tdf#143940
+ if (nIndex != -1)
+ AddAttribute(sAttrStyleName, pRowStyles->GetStyleNameByIndex(nIndex));
if (bHidden)
{
if (bFiltered)