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 ++++++++++++
 9 files changed, 62 insertions(+), 6 deletions(-)

New commits:
commit d091c60f9a68b35473a807d0ad877a69c9bd6b17
Author:     Bayram Çiçek <bayram.ci...@collabora.com>
AuthorDate: Thu Aug 28 09:42:50 2025 +0300
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Fri Aug 29 09:18:22 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 <bayram.ci...@collabora.com>
    Change-Id: I98c6b7f6f7260195fc89aaae20a9a34208204186
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190314
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Tested-by: Jenkins

diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx
index ef03c84f227a..4cc253c6275e 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 433dcee0f4b2..88e06748b110 100644
--- a/sc/inc/unonames.hxx
+++ b/sc/inc/unonames.hxx
@@ -330,6 +330,7 @@ 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_NUMBERBEHAVIOR   = u"NumberBehavior"_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 61548dfe43a3..9317f1f57f8b 100644
--- a/sc/qa/unit/subsequent_export_test4.cxx
+++ b/sc/qa/unit/subsequent_export_test4.cxx
@@ -1665,11 +1665,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 333a4a12ddb0..b1d714c55efa 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 132c0ee7e3aa..bc0ff343e79f 100644
--- a/sc/source/filter/oox/tablebuffer.cxx
+++ b/sc/source/filter/oox/tablebuffer.cxx
@@ -119,6 +119,24 @@ void Table::finalizeImport()
             xDatabaseRange->setPropertyValue( u"TotalsRow"_ustr, 
css::uno::Any(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;
+        }
+        xDatabaseRange->setPropertyValue(u"TableType"_ustr, 
css::uno::Any(sValue));
+
         // get formula token index of the database range
         if( !(xDatabaseRange->getPropertyValue(u"TokenIndex"_ustr) >>= 
mnTokenIndex))
             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 6da084dff2f1..37d38d49c0fe 100644
--- a/sc/source/ui/unoobj/datauno.cxx
+++ b/sc/source/ui/unoobj/datauno.cxx
@@ -1976,6 +1976,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;
 
@@ -2062,6 +2068,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;
 }

Reply via email to