oox/source/token/properties.txt | 1 + sc/inc/dbdata.hxx | 7 ++++++- sc/inc/unonames.hxx | 1 + sc/qa/unit/subsequent_export_test4.cxx | 11 ++++++++++- sc/source/core/tool/dbdata.cxx | 6 +++++- sc/source/filter/excel/xedbdata.cxx | 10 ++++++++-- sc/source/filter/inc/tablebuffer.hxx | 2 +- sc/source/filter/oox/tablebuffer.cxx | 18 ++++++++++++++++++ sc/source/filter/oox/tablecolumnsbuffer.cxx | 1 + sc/source/ui/unoobj/datauno.cxx | 12 ++++++++++++ 10 files changed, 63 insertions(+), 6 deletions(-)
New commits: commit e1fed7935ad8033caa3595ed2e79100ad63c6b60 Author: Bayram Çiçek <[email protected]> AuthorDate: Thu Aug 28 09:42:50 2025 +0300 Commit: Bayram Çiçek <[email protected]> CommitDate: Sat Sep 20 08:05:03 2025 +0200 tdf#167689: sc: support tableType attr. in <table> node and import&export uniqueName attr. of <tableColumn>. - also added a unittest Signed-off-by: Bayram Çiçek <[email protected]> Change-Id: I98c6b7f6f7260195fc89aaae20a9a34208204186 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190314 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Jenkins (cherry picked from commit d091c60f9a68b35473a807d0ad877a69c9bd6b17) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191207 Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index 96b1fc988f09..ef939a44c063 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -580,6 +580,7 @@ TableBorder TableLayout TableSelected Tables +TableType Tabstop Tag TargetFrame diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx index 5723ff4d7743..9b74ae0c9de9 100644 --- a/sc/inc/dbdata.hxx +++ b/sc/inc/dbdata.hxx @@ -65,6 +65,8 @@ struct TableColumnModel XmlColumnPrModelPtr mxXmlColumnPr; // Special settings for XML Column Properties. XmlColumnPrModel& createXmlColumnPr(); + OUString maUniqueName; // unique name of the <tableColumn> + explicit TableColumnModel(); }; @@ -95,6 +97,7 @@ private: /// DBParam const OUString aName; OUString aUpper; + OUString aTableType; SCTAB nTable; SCCOL nStartCol; SCROW nStartRow; @@ -134,7 +137,7 @@ public: SC_DLLPUBLIC ScDBData(const OUString& rName, SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, - bool bByR = true, bool bHasH = true, bool bTotals = false); + bool bByR = true, bool bHasH = true, bool bTotals = false, const OUString& rTableType = "worksheet"); ScDBData(const ScDBData& rData); ScDBData(const OUString& rName, const ScDBData& rData); SC_DLLPUBLIC virtual ~ScDBData() override; @@ -166,6 +169,8 @@ public: void SetKeepFmt(bool bSet) { bKeepFmt = bSet; } bool IsStripData() const { return bStripData; } void SetStripData(bool bSet) { bStripData = bSet; } + void SetTableType(OUString& sTableType) { aTableType = sTableType; } + const OUString& GetTableType() const { return aTableType; } void SetContainer( ScDBDataContainerBase* pContainer ) { mpContainer = pContainer; } /** Returns header row range if has headers, else invalid range. */ diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx index 0d8fd9dbd696..a1dd70ad3892 100644 --- a/sc/inc/unonames.hxx +++ b/sc/inc/unonames.hxx @@ -329,6 +329,7 @@ inline constexpr OUString SC_UNONAME_CONRES = u"ConnectionResource"_us inline constexpr OUString SC_UNONAME_TOKENINDEX = u"TokenIndex"_ustr; inline constexpr OUString SC_UNONAME_ISSHAREDFMLA = u"IsSharedFormula"_ustr; inline constexpr OUString SC_UNONAME_TOTALSROW = u"TotalsRow"_ustr; +inline constexpr OUString SC_UNONAME_TABLETYPE = u"TableType"_ustr; // text fields inline constexpr OUString SC_UNONAME_ANCTYPE = u"AnchorType"_ustr; diff --git a/sc/qa/unit/subsequent_export_test4.cxx b/sc/qa/unit/subsequent_export_test4.cxx index b039b5b5c92a..edd0a0a35e51 100644 --- a/sc/qa/unit/subsequent_export_test4.cxx +++ b/sc/qa/unit/subsequent_export_test4.cxx @@ -1746,11 +1746,20 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf167689_xmlMaps_and_xmlColumnPr) "xsd:element[1]", "name", u"Code"); - // test <xmlColumnPr> of xl/tables/table1.xml + // xl/tables/table1.xml xmlDocUniquePtr pDocXmlTables = parseExport(u"xl/tables/table1.xml"_ustr); CPPUNIT_ASSERT(pDocXmlTables); + + // test xpath attribute of <xmlColumnPr> assertXPath(pDocXmlTables, "/x:table/x:tableColumns/x:tableColumn[1]/x:xmlColumnPr", "xpath", u"/DataList/TransactionTypeList/TransactionType/Code"); + + // test tableType attribute of <table> + assertXPath(pDocXmlTables, "/x:table", "tableType", u"xml"); + + // test uniqueName attribute of <tableColumn> + assertXPath(pDocXmlTables, "/x:table/x:tableColumns/x:tableColumn[2]", "uniqueName", + u"Description"); } CPPUNIT_TEST_FIXTURE(ScExportTest4, testAutofilterHiddenButton) diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx index b719cb056221..7992d10e916f 100644 --- a/sc/source/core/tool/dbdata.cxx +++ b/sc/source/core/tool/dbdata.cxx @@ -50,7 +50,7 @@ bool ScDBData::less::operator() (const std::unique_ptr<ScDBData>& left, const st ScDBData::ScDBData( const OUString& rName, SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, - bool bByR, bool bHasH, bool bTotals) : + bool bByR, bool bHasH, bool bTotals, const OUString& rTableType) : // Listeners are to be setup by the "parent" container. mpSortParam(new ScSortParam), mpQueryParam(new ScQueryParam), @@ -59,6 +59,7 @@ ScDBData::ScDBData( const OUString& rName, mpContainer (nullptr), aName (rName), aUpper (rName), + aTableType (rTableType), nTable (nTab), nStartCol (nCol1), nStartRow (nRow1), @@ -92,6 +93,7 @@ ScDBData::ScDBData( const ScDBData& rData ) : mpContainer (nullptr), aName (rData.aName), aUpper (rData.aUpper), + aTableType (rData.aTableType), nTable (rData.nTable), nStartCol (rData.nStartCol), nStartRow (rData.nStartRow), @@ -127,6 +129,7 @@ ScDBData::ScDBData( const OUString& rName, const ScDBData& rData ) : mpContainer (nullptr), aName (rName), aUpper (rName), + aTableType (rData.aTableType), nTable (rData.nTable), nStartCol (rData.nStartCol), nStartRow (rData.nStartRow), @@ -185,6 +188,7 @@ ScDBData& ScDBData::operator= (const ScDBData& rData) bStripData = rData.bStripData; bIsAdvanced = rData.bIsAdvanced; aAdvSource = rData.aAdvSource; + aTableType = rData.aTableType; bDBSelection = rData.bDBSelection; nIndex = rData.nIndex; bAutoFilter = rData.bAutoFilter; diff --git a/sc/source/filter/excel/xedbdata.cxx b/sc/source/filter/excel/xedbdata.cxx index 128e145ac51d..a2dbf1e96f8d 100644 --- a/sc/source/filter/excel/xedbdata.cxx +++ b/sc/source/filter/excel/xedbdata.cxx @@ -187,6 +187,7 @@ void XclExpTables::SaveTableXml( XclExpXmlStream& rStrm, const Entry& rEntry ) XML_name, rData.GetName().toUtf8(), XML_displayName, rData.GetName().toUtf8(), XML_ref, XclXmlUtils::ToOString(rStrm.GetRoot().GetDoc(), aRange), + XML_tableType, rData.GetTableType().toUtf8(), XML_headerRowCount, ToPsz10(rData.HasHeader()), XML_totalsRowCount, ToPsz10(rData.HasTotals()), XML_totalsRowShown, ToPsz10(rData.HasTotals()) // we don't support that but if there are totals they are shown @@ -201,7 +202,6 @@ void XclExpTables::SaveTableXml( XclExpXmlStream& rStrm, const Entry& rEntry ) // OOXTODO: XML_insertRowShift, ..., // OOXTODO: XML_published, ..., // OOXTODO: XML_tableBorderDxfId, ..., - // OOXTODO: XML_tableType, ..., // OOXTODO: XML_totalsRowBorderDxfId, ..., // OOXTODO: XML_totalsRowCellStyle, ..., // OOXTODO: XML_totalsRowDxfId, ... @@ -237,8 +237,15 @@ void XclExpTables::SaveTableXml( XclExpXmlStream& rStrm, const Entry& rEntry ) // OOXTODO: write <totalsRowFormula> once we support it. + OUString uniqueName; + if (i < rTableColumnModel.size() && !rTableColumnModel[i].maUniqueName.isEmpty()) + uniqueName = rTableColumnModel[i].maUniqueName; + else + uniqueName = rColNames[i]; // fallback to column name if no unique name. + pTableStrm->startElement( XML_tableColumn, XML_id, OString::number(i+1), + XML_uniqueName, uniqueName, XML_name, rColNames[i].toUtf8(), XML_totalsRowFunction, (i < rColAttributes.size() ? rColAttributes[i].maTotalsFunction : std::nullopt) // OOXTODO: XML_dataCellStyle, ..., @@ -249,7 +256,6 @@ void XclExpTables::SaveTableXml( XclExpXmlStream& rStrm, const Entry& rEntry ) // OOXTODO: XML_totalsRowCellStyle, ..., // OOXTODO: XML_totalsRowDxfId, ..., // OOXTODO: XML_totalsRowLabel, ..., - // OOXTODO: XML_uniqueName, ... ); if (i < rTableColumnModel.size() && rTableColumnModel[i].mxXmlColumnPr) diff --git a/sc/source/filter/inc/tablebuffer.hxx b/sc/source/filter/inc/tablebuffer.hxx index 66f6816c1e23..40facdd3e9a7 100644 --- a/sc/source/filter/inc/tablebuffer.hxx +++ b/sc/source/filter/inc/tablebuffer.hxx @@ -31,7 +31,7 @@ struct TableModel OUString maProgName; /// Programmatical name. OUString maDisplayName; /// Display name. sal_Int32 mnId; /// Unique table identifier. - sal_Int32 mnType; /// Table type (worksheet, query, etc.). + sal_Int32 mnType; /// Table type ( [default] worksheet, xml or queryTable ). sal_Int32 mnHeaderRows; /// Number of header rows. sal_Int32 mnTotalsRows; /// Number of totals rows. diff --git a/sc/source/filter/oox/tablebuffer.cxx b/sc/source/filter/oox/tablebuffer.cxx index d43f32806a8c..e2c8e273b50b 100644 --- a/sc/source/filter/oox/tablebuffer.cxx +++ b/sc/source/filter/oox/tablebuffer.cxx @@ -122,6 +122,24 @@ void Table::finalizeImport() aPropSet.setProperty( PROP_TotalsRow, true); } + // import tableType attribute of <table> node + sal_Int32 nToken = maModel.mnType; + OUString sValue; + + switch (nToken) + { + case XML_xml: + sValue = "xml"; + break; + case XML_queryTable: + sValue = "queryTable"; + break; + default: + sValue = "worksheet"; + break; + } + aPropSet.setProperty(PROP_TableType, css::uno::Any(sValue)); + // get formula token index of the database range if( !aPropSet.getProperty( mnTokenIndex, PROP_TokenIndex ) ) mnTokenIndex = -1; diff --git a/sc/source/filter/oox/tablecolumnsbuffer.cxx b/sc/source/filter/oox/tablecolumnsbuffer.cxx index 55112f7be7d2..0611d3690c2e 100644 --- a/sc/source/filter/oox/tablecolumnsbuffer.cxx +++ b/sc/source/filter/oox/tablecolumnsbuffer.cxx @@ -53,6 +53,7 @@ void TableColumn::importTableColumn( const AttributeList& rAttribs ) { mnId = rAttribs.getInteger( XML_id, -1 ); maName = rAttribs.getString( XML_name, OUString() ); + maModel.maUniqueName = rAttribs.getXString( XML_uniqueName, OUString() ); mnDataDxfId = rAttribs.getInteger( XML_dataDxfId, -1 ); if ( rAttribs.hasAttribute( XML_totalsRowFunction ) ) maColumnAttributes.maTotalsFunction = rAttribs.getStringDefaulted( XML_totalsRowFunction ); diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx index 99cb53d48222..cbf99cacd35d 100644 --- a/sc/source/ui/unoobj/datauno.cxx +++ b/sc/source/ui/unoobj/datauno.cxx @@ -1964,6 +1964,12 @@ void SAL_CALL ScDatabaseRangeObj::setPropertyValue( aNewData.SetTotals( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); else if ( aPropertyName == SC_UNONAME_CONTHDR ) aNewData.SetHeader( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); + else if ( aPropertyName == SC_UNONAME_TABLETYPE ) + { + OUString aStrVal; + aValue >>= aStrVal; + aNewData.SetTableType(aStrVal); + } else bDo = false; @@ -2050,6 +2056,12 @@ uno::Any SAL_CALL ScDatabaseRangeObj::getPropertyValue( const OUString& aPropert aRet <<= bHeader; } + else if (aPropertyName == SC_UNONAME_TABLETYPE ) + { + OUString sType(GetDBData_Impl()->GetTableType()); + + aRet <<= sType; + } } return aRet; }
