sc/qa/unit/data/xlsx/totalsRowShown.xlsx |binary sc/qa/unit/subsequent_export_test4.cxx | 11 +++++++++ sc/source/filter/excel/xedbdata.cxx | 5 ++-- sc/source/filter/inc/tablebuffer.hxx | 8 +++---- sc/source/filter/oox/tablebuffer.cxx | 35 +++++++++++++------------------ 5 files changed, 33 insertions(+), 26 deletions(-)
New commits: commit 77ade2b31e77576a756142b36b80d6e7152eb9ac Author: Balazs Varga <[email protected]> AuthorDate: Mon Jan 5 08:43:10 2026 +0100 Commit: Andras Timar <[email protected]> CommitDate: Wed Jan 14 08:13:49 2026 +0100 Table Style: ooxml export: fix corrupt ooxml files because of XML_totalsRowShown with value "0". We don't support totalsRowShown in core as it should be according to ooxml standard. totalsRowShown is false until we didn't set the Total row for the first time, after that it is always true. If there are totals or have any total row attribute is set, Total Row was shown. TODO: handle XML_totalsRowShown in core. regression after: e725c5b9327424fb927ed251d54b6913ae9d8568 Change-Id: Id3233afa760c198401d5a9f4a9637e907dd5cd63 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196532 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Balazs Varga <[email protected]> (cherry picked from commit dc4a0d64b2d0baaea0299406dd9cc2cc7bcd1ec8) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197058 Tested-by: Andras Timar <[email protected]> Reviewed-by: Andras Timar <[email protected]> diff --git a/sc/qa/unit/data/xlsx/totalsRowShown.xlsx b/sc/qa/unit/data/xlsx/totalsRowShown.xlsx new file mode 100644 index 000000000000..5503ae3a3784 Binary files /dev/null and b/sc/qa/unit/data/xlsx/totalsRowShown.xlsx differ diff --git a/sc/qa/unit/subsequent_export_test4.cxx b/sc/qa/unit/subsequent_export_test4.cxx index 2403bb9f2c18..9f78e4e38a14 100644 --- a/sc/qa/unit/subsequent_export_test4.cxx +++ b/sc/qa/unit/subsequent_export_test4.cxx @@ -1793,6 +1793,17 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testTotalsRowFunction) } } +CPPUNIT_TEST_FIXTURE(ScExportTest4, testTotalsRowShown) +{ + createScDoc("xlsx/totalsRowShown.xlsx"); + saveAndReload(u"Calc Office Open XML"_ustr); + { + xmlDocUniquePtr pDocXml = parseExport(u"xl/tables/table1.xml"_ustr); + CPPUNIT_ASSERT(pDocXml); + assertXPathNoAttribute(pDocXml, "/x:table", "totalsRowShown"); + } +} + CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf167689_xmlMaps_and_xmlColumnPr) { createScDoc("xlsx/tdf167689_xmlMaps_and_xmlColumnPr.xlsx"); diff --git a/sc/source/filter/excel/xedbdata.cxx b/sc/source/filter/excel/xedbdata.cxx index fad30749c746..522b5ea19747 100644 --- a/sc/source/filter/excel/xedbdata.cxx +++ b/sc/source/filter/excel/xedbdata.cxx @@ -193,7 +193,7 @@ void XclExpTables::SaveTableXml( XclExpXmlStream& rStrm, const Entry& rEntry ) = rData.GetTotalRowAttributes(formula::FormulaGrammar::GRAM_OOXML); // if the Total row have ever been showed it will be true - bool hasAnySetValue = std::any_of(aTotalValues.begin(), aTotalValues.end(), + bool hasAnySetValue = rData.HasTotals() || std::any_of(aTotalValues.begin(), aTotalValues.end(), [](const TableColumnAttributes& attr) { return attr.maTotalsRowLabel.has_value() @@ -210,7 +210,8 @@ void XclExpTables::SaveTableXml( XclExpXmlStream& rStrm, const Entry& rEntry ) XML_tableType, tableType, XML_headerRowCount, ToPsz10(rData.HasHeader()), XML_totalsRowCount, ToPsz10(rData.HasTotals()), - XML_totalsRowShown, ToPsz10(hasAnySetValue) + XML_totalsRowShown, (hasAnySetValue ? nullptr : ToPsz10(false)) // we don't support that but + // if there are totals or any total row attribute is set they are shown // OOXTODO: XML_comment, ..., // OOXTODO: XML_connectionId, ..., // OOXTODO: XML_dataCellStyle, ..., commit 5b502bba09b04307351699c6ef861d1d13e1db6b Author: Balazs Varga <[email protected]> AuthorDate: Tue Dec 23 20:12:39 2025 +0100 Commit: Andras Timar <[email protected]> CommitDate: Wed Jan 14 08:13:36 2026 +0100 Table Style: import table area with empty style even if XML_TableStyleInfo is not present in the ooxml file. Change-Id: If3045d5eedd1ec21f69230e641bdf6f7b7aa88d5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196174 Reviewed-by: Balazs Varga <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> (cherry picked from commit 6632f62040d8fe2e6260335fb5849ed33fd0d3a8) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197057 Reviewed-by: Andras Timar <[email protected]> Tested-by: Andras Timar <[email protected]> diff --git a/sc/source/filter/inc/tablebuffer.hxx b/sc/source/filter/inc/tablebuffer.hxx index bf995393000c..886ed2bac664 100644 --- a/sc/source/filter/inc/tablebuffer.hxx +++ b/sc/source/filter/inc/tablebuffer.hxx @@ -28,7 +28,7 @@ namespace oox::xls { struct TableStyleInfo { - std::optional<OUString> maStyleName; + OUString maStyleName; bool mbShowFirstColumn; bool mbShowLastColumn; bool mbShowRowStripes; @@ -63,8 +63,8 @@ public: AutoFilter& createAutoFilter() { return maAutoFilters.createAutoFilter(); } /** Creates a new tableColumns handler and stores it internally. */ TableColumns& createTableColumns() { return maTableColumns.createTableColumns(); } - - void importTableStyleInfo(const AttributeList& rAttribs); + /** Imports the table style info attributes. */ + void importTableStyleInfo( const AttributeList& rAttribs ); /** Creates a database range from this tables. */ void finalizeImport(); @@ -93,7 +93,7 @@ public: private: TableModel maModel; - std::optional<TableStyleInfo> maStyleInfo; + TableStyleInfo maStyleInfo; /// Table style information. AutoFilterBuffer maAutoFilters; /// Filter settings for this table. TableColumnsBuffer maTableColumns; /// Column names of this table. OUString maDBRangeName; /// Name of the database range in the Calc document. diff --git a/sc/source/filter/oox/tablebuffer.cxx b/sc/source/filter/oox/tablebuffer.cxx index e2dbd282a94f..f1b767c52a41 100644 --- a/sc/source/filter/oox/tablebuffer.cxx +++ b/sc/source/filter/oox/tablebuffer.cxx @@ -40,11 +40,12 @@ using namespace ::com::sun::star::sheet; using namespace ::com::sun::star::uno; TableStyleInfo::TableStyleInfo(): - mbShowFirstColumn(true), - mbShowLastColumn(true), - mbShowRowStripes(true), - mbShowColStripes(true) + mbShowFirstColumn( false ), + mbShowLastColumn( false ), + mbShowRowStripes( false ), + mbShowColStripes( false ) { + maStyleName = u"none"_ustr; } TableModel::TableModel() : @@ -95,14 +96,11 @@ void Table::importTable( SequenceInputStream& rStrm, sal_Int16 nSheet ) void Table::importTableStyleInfo(const AttributeList& rAttribs) { - TableStyleInfo aInfo; - aInfo.maStyleName = rAttribs.getString(XML_name, u"none"_ustr); - aInfo.mbShowFirstColumn = rAttribs.getBool(XML_showFirstColumn, true); - aInfo.mbShowLastColumn = rAttribs.getBool(XML_showLastColumn, true); - aInfo.mbShowRowStripes = rAttribs.getBool(XML_showRowStripes, true); - aInfo.mbShowColStripes = rAttribs.getBool(XML_showColumnStripes, true); - - maStyleInfo = aInfo; + maStyleInfo.maStyleName = rAttribs.getString(XML_name, u"none"_ustr); + maStyleInfo.mbShowFirstColumn = rAttribs.getBool(XML_showFirstColumn, false); + maStyleInfo.mbShowLastColumn = rAttribs.getBool(XML_showLastColumn, false); + maStyleInfo.mbShowRowStripes = rAttribs.getBool(XML_showRowStripes, false); + maStyleInfo.mbShowColStripes = rAttribs.getBool(XML_showColumnStripes, false); } void Table::finalizeImport() @@ -167,14 +165,11 @@ void Table::finalizeImport() if( !aPropSet.getProperty( mnTokenIndex, PROP_TokenIndex ) ) mnTokenIndex = -1; - if(maStyleInfo && maStyleInfo->maStyleName) - { - aPropSet.setProperty( PROP_TableStyleName, css::uno::Any(*maStyleInfo->maStyleName)); - aPropSet.setProperty( PROP_UseRowStripes, maStyleInfo->mbShowRowStripes); - aPropSet.setProperty( PROP_UseColStripes, maStyleInfo->mbShowColStripes); - aPropSet.setProperty( PROP_UseFirstColumnFormatting, maStyleInfo->mbShowFirstColumn); - aPropSet.setProperty( PROP_UseLastColumnFormatting, maStyleInfo->mbShowLastColumn); - } + aPropSet.setProperty( PROP_TableStyleName, css::uno::Any(maStyleInfo.maStyleName)); + aPropSet.setProperty( PROP_UseRowStripes, maStyleInfo.mbShowRowStripes); + aPropSet.setProperty( PROP_UseColStripes, maStyleInfo.mbShowColStripes); + aPropSet.setProperty( PROP_UseFirstColumnFormatting, maStyleInfo.mbShowFirstColumn); + aPropSet.setProperty( PROP_UseLastColumnFormatting, maStyleInfo.mbShowLastColumn); } catch( Exception& ) {
