sc/inc/dbdata.hxx                     |    5 ++-
 sc/inc/document.hxx                   |    6 +++
 sc/source/core/data/documen3.cxx      |   21 +++++++++++--
 sc/source/core/data/documen4.cxx      |    7 +---
 sc/source/core/data/fillinfo.cxx      |    3 +
 sc/source/core/tool/dbdata.cxx        |   53 ++++++++++++++++++++++++++++++----
 sc/source/filter/excel/xedbdata.cxx   |    8 +++--
 sc/source/filter/oox/tablebuffer.cxx  |    2 -
 sc/source/ui/cctrl/TableStylesBox.cxx |    4 +-
 sc/source/ui/dbgui/dbtabledlg.cxx     |    2 -
 sc/source/ui/drawfunc/drawsh2.cxx     |    4 +-
 sc/source/ui/inc/tableshell.hxx       |    2 -
 sc/source/ui/view/cellsh2.cxx         |    6 +--
 sc/source/ui/view/dbfunc3.cxx         |    4 +-
 sc/source/ui/view/gridwin.cxx         |    8 ++---
 sc/source/ui/view/tableshell.cxx      |   29 +++++-------------
 sc/source/ui/view/tabview3.cxx        |    7 ++--
 17 files changed, 111 insertions(+), 60 deletions(-)

New commits:
commit 726390523594543edf0dc4340b15e539c80572dc
Author:     Balazs Varga <[email protected]>
AuthorDate: Thu Dec 4 18:21:29 2025 +0100
Commit:     Balazs Varga <[email protected]>
CommitDate: Thu Jan 29 09:33:32 2026 +0100

    Table Styles: simplify checking whether we are in a
    
    table style area or in a normal dbrange area. These two
    ranges could have conflicted with each other.
    
    Change-Id: Ic7f3af1949789ac01012e8ffc3bee8d901f318da
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195037
    Reviewed-by: Balazs Varga <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196774
    Tested-by: Balazs Varga <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198000
    Tested-by: Jenkins

diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx
index dae33cacc6bc..f7d7752ff446 100644
--- a/sc/inc/dbdata.hxx
+++ b/sc/inc/dbdata.hxx
@@ -436,13 +436,16 @@ public:
     AnonDBs& getAnonDBs() { return maAnonDBs;}
     const AnonDBs& getAnonDBs() const { return maAnonDBs;}
 
+    const ScDBData* GetTableDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, 
ScDBDataPortion ePortion) const;
+    ScDBData* GetTableDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, 
ScDBDataPortion ePortion);
     const ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, 
ScDBDataPortion ePortion) const;
     ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, 
ScDBDataPortion ePortion);
     const ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL 
nCol2, SCROW nRow2) const;
     SC_DLLPUBLIC ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, 
SCCOL nCol2, SCROW nRow2);
     SC_DLLPUBLIC ScDBData* GetDBNearCursor(SCCOL nCol, SCROW nRow, SCTAB nTab 
);
     SC_DLLPUBLIC std::vector<ScDBData*> GetAllDBsFromTab(SCTAB nTab);
-    std::vector<const ScDBData*> GetAllDBsInArea(SCCOL nCol1, SCROW nRow1, 
SCCOL nCol2, SCROW nRow2, SCTAB nTab) const;
+    std::vector<const ScDBData*> GetAllNamedDBsInArea(SCCOL nCol1, SCROW 
nRow1, SCCOL nCol2,
+                                                      SCROW nRow2, SCTAB nTab) 
const;
 
     void RefreshDirtyTableColumnNames();
 
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 1985b58e6b36..75c8e67ef9c1 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -895,11 +895,15 @@ public:
     SC_DLLPUBLIC ScDBCollection* GetDBCollection() const { return 
pDBCollection.get();}
     void                         SetDBCollection( 
std::unique_ptr<ScDBCollection> pNewDBCollection,
                                                   bool bRemoveAutoFilter = 
false );
+
+    const ScDBData*              GetTableDBAtCursor(SCCOL nCol, SCROW nRow, 
SCTAB nTab, ScDBDataPortion ePortion) const;
+    ScDBData*                    GetTableDBAtCursor(SCCOL nCol, SCROW nRow, 
SCTAB nTab, ScDBDataPortion ePortion);
     const ScDBData*              GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB 
nTab, ScDBDataPortion ePortion) const;
     ScDBData*                    GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB 
nTab, ScDBDataPortion ePortion);
     SC_DLLPUBLIC const ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW 
nRow1, SCCOL nCol2, SCROW nRow2) const;
     SC_DLLPUBLIC ScDBData*       GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW 
nRow1, SCCOL nCol2, SCROW nRow2);
-    std::vector<const ScDBData*> GetAllDBsInArea(SCCOL nCol1, SCROW nRow1, 
SCCOL nCol2, SCROW nRow2, SCTAB nTab) const;
+    std::vector<const ScDBData*> GetAllNamedDBsInArea(SCCOL nCol1, SCROW 
nRow1, SCCOL nCol2,
+                                                      SCROW nRow2, SCTAB nTab) 
const;
     void                         RefreshDirtyTableColumnNames();
     SC_DLLPUBLIC sc::ExternalDataMapper& GetExternalDataMapper();
 
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index c470eb227710..9f3c36d24fa6 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -325,6 +325,22 @@ void ScDocument::SetDBCollection( 
std::unique_ptr<ScDBCollection> pNewDBCollecti
     pDBCollection = std::move(pNewDBCollection);
 }
 
+const ScDBData* ScDocument::GetTableDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB 
nTab, ScDBDataPortion ePortion) const
+{
+    if (pDBCollection)
+        return pDBCollection->GetTableDBAtCursor(nCol, nRow, nTab, ePortion);
+    else
+        return nullptr;
+}
+
+ScDBData* ScDocument::GetTableDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, 
ScDBDataPortion ePortion)
+{
+    if (pDBCollection)
+        return pDBCollection->GetTableDBAtCursor(nCol, nRow, nTab, ePortion);
+    else
+        return nullptr;
+}
+
 const ScDBData* ScDocument::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, 
ScDBDataPortion ePortion) const
 {
     if (pDBCollection)
@@ -357,11 +373,10 @@ ScDBData* ScDocument::GetDBAtArea(SCTAB nTab, SCCOL 
nCol1, SCROW nRow1, SCCOL nC
         return nullptr;
 }
 
-std::vector<const ScDBData*> ScDocument::GetAllDBsInArea(SCCOL nCol1, SCROW 
nRow1, SCCOL nCol2,
-                                                         SCROW nRow2, SCTAB 
nTab) const
+std::vector<const ScDBData*> ScDocument::GetAllNamedDBsInArea(SCCOL nCol1, 
SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCTAB nTab) const
 {
     if (pDBCollection)
-        return pDBCollection->GetAllDBsInArea(nCol1, nRow1, nCol2, nRow2, 
nTab);
+        return pDBCollection->GetAllNamedDBsInArea(nCol1, nRow1, nCol2, nRow2, 
nTab);
     else
         return std::vector<const ScDBData*>();
 }
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index 76b92b4fa8de..fe97855bb176 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -795,13 +795,10 @@ const SfxPoolItem* ScDocument::GetEffItem(
 
 const SfxItemSet* ScDocument::GetTableFormatSet(SCCOL nCol, SCROW nRow, SCTAB 
nTab) const
 {
-    const ScDBData* pDBData = GetDBAtCursor(nCol, nRow, nTab, 
ScDBDataPortion::AREA);
-    if (pDBData)
+    const ScDBData* pDBData = GetTableDBAtCursor(nCol, nRow, nTab, 
ScDBDataPortion::AREA);
+    if (pDBData && mpTableStyles)
     {
         const ScTableStyleParam* pTableStyleInfo = 
pDBData->GetTableStyleInfo();
-        if (!pTableStyleInfo)
-            return nullptr;
-
         const ScTableStyle* pTableStyle = 
mpTableStyles->GetTableStyle(pTableStyleInfo->maStyleID);
         if (!pTableStyle)
             return nullptr;
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index d8930634dd37..2600a0c7ec58 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -411,7 +411,8 @@ void ScDocument::FillInfo(
         pCondFormList->startRendering();
 
     ScRange aTargetRange(nCol1, nRow1, nTab, nCol2, nRow2, nTab);
-    std::vector<const ScDBData*> aDBData = 
pDBCollection->GetAllDBsInArea(nCol1, nRow1, nCol2, nRow2, nTab);
+    std::vector<const ScDBData*> aDBData
+        = pDBCollection->GetAllNamedDBsInArea(nCol1, nRow1, nCol2, nRow2, 
nTab);
     for (const ScDBData* pDBData : aDBData)
     {
         const ScTableStyleParam* pTableStyleInfo = 
pDBData->GetTableStyleInfo();
diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx
index 978a15e930d6..6d4ee3e2e518 100644
--- a/sc/source/core/tool/dbdata.cxx
+++ b/sc/source/core/tool/dbdata.cxx
@@ -1806,6 +1806,28 @@ OUString 
lcl_IncrementNumberInNamedRange(ScDBCollection::NamedDBs& namedDBs,
     return sNewName;
 }
 
+class FindTableByCursor
+{
+    SCCOL mnCol;
+    SCROW mnRow;
+    SCTAB mnTab;
+    ScDBDataPortion mePortion;
+
+public:
+    FindTableByCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion 
ePortion)
+        : mnCol(nCol)
+        , mnRow(nRow)
+        , mnTab(nTab)
+        , mePortion(ePortion)
+    {
+    }
+
+    bool operator()(std::unique_ptr<ScDBData> const& p)
+    {
+        return p->IsDBAtCursor(mnCol, mnRow, mnTab, mePortion) && 
p->GetTableStyleInfo();
+    }
+};
+
 class FindByCursor
 {
     SCCOL mnCol;
@@ -2128,6 +2150,30 @@ ScDBCollection::ScDBCollection(ScDocument& rDocument) :
 ScDBCollection::ScDBCollection(const ScDBCollection& r) :
     rDoc(r.rDoc), nEntryIndex(r.nEntryIndex), maNamedDBs(r.maNamedDBs, *this), 
maAnonDBs(r.maAnonDBs) {}
 
+const ScDBData* ScDBCollection::GetTableDBAtCursor(SCCOL nCol, SCROW nRow, 
SCTAB nTab,
+                                             ScDBDataPortion ePortion) const
+{
+    // only search the global named db ranges since Table names can only be 
there.
+    NamedDBs::DBsType::iterator itr = find_if(maNamedDBs.begin(), 
maNamedDBs.end(),
+                                              FindTableByCursor(nCol, nRow, 
nTab, ePortion));
+    if (itr != maNamedDBs.end())
+        return itr->get();
+
+    return nullptr;
+}
+
+ScDBData* ScDBCollection::GetTableDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB 
nTab,
+                                             ScDBDataPortion ePortion)
+{
+    // only search the global named db ranges since Table names can only be 
there.
+    NamedDBs::DBsType::iterator itr = find_if(maNamedDBs.begin(), 
maNamedDBs.end(),
+                                              FindTableByCursor(nCol, nRow, 
nTab, ePortion));
+    if (itr != maNamedDBs.end())
+        return itr->get();
+
+    return nullptr;
+}
+
 const ScDBData* ScDBCollection::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB 
nTab, ScDBDataPortion ePortion) const
 {
     // First, search the global named db ranges.
@@ -2245,7 +2291,7 @@ bool intersectsRange(const ScDBData* pDBData, ScRange& 
rRange)
 
 }
 
-std::vector<const ScDBData*> ScDBCollection::GetAllDBsInArea(SCCOL nCol1, 
SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCTAB nTab) const
+std::vector<const ScDBData*> ScDBCollection::GetAllNamedDBsInArea(SCCOL nCol1, 
SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCTAB nTab) const
 {
     ScRange aTargetRange(nCol1, nRow1, nTab, nCol2, nRow2, nTab);
     std::vector<const ScDBData*> aDBData;
@@ -2259,11 +2305,6 @@ std::vector<const ScDBData*> 
ScDBCollection::GetAllDBsInArea(SCCOL nCol1, SCROW
             aDBData.emplace_back(rxNamedDB.get());
         }
     }
-    const ScDBData* pAnonDBData = rDoc.GetAnonymousDBData(nTab);
-    if (pAnonDBData && intersectsRange(pAnonDBData, aTargetRange))
-    {
-        aDBData.emplace_back(pAnonDBData);
-    }
     return aDBData;
 }
 
diff --git a/sc/source/ui/cctrl/TableStylesBox.cxx 
b/sc/source/ui/cctrl/TableStylesBox.cxx
index b239de1cc69c..f7a9b06ac6a3 100644
--- a/sc/source/ui/cctrl/TableStylesBox.cxx
+++ b/sc/source/ui/cctrl/TableStylesBox.cxx
@@ -109,12 +109,12 @@ IMPL_LINK_NOARG(TableStylesBox, SelectHdl, 
weld::ComboBox&, void)
         return;
 
     const ScAddress aAddr = pViewData->GetCurPos();
-    const ScDBData* pDBData = pViewData->GetDocument().GetDBAtCursor(
+    const ScDBData* pDBData = pViewData->GetDocument().GetTableDBAtCursor(
         aAddr.Col(), aAddr.Row(), aAddr.Tab(), ScDBDataPortion::AREA);
 
     bool bChanged = true;
     const OUString sValue = m_xCmbStyle->get_active_id();
-    if (pDBData && pDBData->GetTableStyleInfo())
+    if (pDBData)
     {
         const ScTableStyleParam* pParam = pDBData->GetTableStyleInfo();
         if (pParam->maStyleID == sValue)
diff --git a/sc/source/ui/dbgui/dbtabledlg.cxx 
b/sc/source/ui/dbgui/dbtabledlg.cxx
index 905c4f06cfe1..f9c377b81841 100644
--- a/sc/source/ui/dbgui/dbtabledlg.cxx
+++ b/sc/source/ui/dbgui/dbtabledlg.cxx
@@ -136,7 +136,7 @@ IMPL_LINK_NOARG(ScDbTableDlg, OkBtnHdl, weld::Button&, void)
             aTmpRange.aEnd.IncRow();
         theCurArea = aTmpRange;
 
-        std::vector<const ScDBData*> aDBData = rDoc.GetAllDBsInArea(
+        std::vector<const ScDBData*> aDBData = rDoc.GetAllNamedDBsInArea(
             theCurArea.aStart.Col(), theCurArea.aStart.Row(), 
theCurArea.aEnd.Col(),
             theCurArea.aEnd.Row(), theCurArea.aStart.Tab());
 
diff --git a/sc/source/ui/drawfunc/drawsh2.cxx 
b/sc/source/ui/drawfunc/drawsh2.cxx
index cd926e4b1d86..7b55b02425ec 100644
--- a/sc/source/ui/drawfunc/drawsh2.cxx
+++ b/sc/source/ui/drawfunc/drawsh2.cxx
@@ -587,9 +587,9 @@ const OUString & ScDrawShell::GetSidebarContextName()
             const ScAddress aAddr = rViewData.GetCurPos();
             if (!rDocument.HasSparkline(aAddr))
             {
-                const ScDBData* pDbData = rDocument.GetDBAtCursor(
+                const ScDBData* pDbData = rDocument.GetTableDBAtCursor(
                     aAddr.Col(), aAddr.Row(), aAddr.Tab(), 
ScDBDataPortion::AREA);
-                if (pDbData && pDbData->GetTableStyleInfo())
+                if (pDbData)
                 {
                     eContext = vcl::EnumContext::Context::Table;
                 }
diff --git a/sc/source/ui/inc/tableshell.hxx b/sc/source/ui/inc/tableshell.hxx
index 4466d190caf7..9d3cc5629b46 100644
--- a/sc/source/ui/inc/tableshell.hxx
+++ b/sc/source/ui/inc/tableshell.hxx
@@ -26,7 +26,7 @@ public:
 private:
     /// SfxInterface initializer.
     static void InitInterface_Impl();
-    const ScDBData* GetDBDataAtCursor();
+    const ScDBData* GetTableDBDataAtCursor();
 
 public:
     ScTableShell(ScTabViewShell* pView);
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index 866f6c0ec7b8..63b7e53dd10c 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -1420,14 +1420,12 @@ void ScCellShell::GetDBState( SfxItemSet& rSet )
 
                         if (!bSelected)
                         {
-                            const ScDBData* pDBData = rDoc.GetDBAtCursor(
-                                nStartCol, nStartRow, nStartTab, 
ScDBDataPortion::AREA);
-                            if (pDBData && pDBData->GetTableStyleInfo())
+                            if (rDoc.GetTableDBAtCursor(nStartCol, nStartRow, 
nStartTab, ScDBDataPortion::AREA))
                                 bDisable = true;
                         }
                         else
                         {
-                            std::vector<const ScDBData*> aDBData = 
rDoc.GetAllDBsInArea(
+                            std::vector<const ScDBData*> aDBData = 
rDoc.GetAllNamedDBsInArea(
                                 nStartCol, nStartRow, nEndCol, nEndRow, 
nStartTab);
                             for (const ScDBData* pDBData : aDBData)
                             {
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index 77ee2b7ae27c..0216b92638e6 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -706,9 +706,9 @@ void ScDBFunc::DeleteCalcTable()
 {
     ScDocShell* pDocSh = GetViewData().GetDocShell();
     ScDocument& rDoc = pDocSh->GetDocument();
-    ScDBData* pDBObj = rDoc.GetDBAtCursor(GetViewData().GetCurX(), 
GetViewData().GetCurY(),
+    ScDBData* pDBObj = rDoc.GetTableDBAtCursor(GetViewData().GetCurX(), 
GetViewData().GetCurY(),
                                           GetViewData().CurrentTabForData(), 
ScDBDataPortion::AREA);
-    if (pDBObj && pDBObj->GetTableStyleInfo())
+    if (pDBObj)
     {
         ScDBDocFunc aFunc(*pDocSh);
         aFunc.DeleteDBTable(pDBObj, true, false);
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index a6373cb356d7..66c7d4071037 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -2501,7 +2501,7 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt 
)
         pView->GetFunctionSet().SetAnchorFlag( false );    // #i5819# don't 
use AutoFill anchor flag for selection
         ScAddress aCurrentAddress = mrViewData.GetCurPos();
         ScDocument& rDocument = mrViewData.GetDocument();
-        if (ScDBData* pDBData = rDocument.GetDBAtCursor(aCurrentAddress.Col(), 
aCurrentAddress.Row(), aCurrentAddress.Tab(), ScDBDataPortion::AREA))
+        if (ScDBData* pDBData = 
rDocument.GetTableDBAtCursor(aCurrentAddress.Col(), aCurrentAddress.Row(), 
aCurrentAddress.Tab(), ScDBDataPortion::AREA))
         {
             SCTAB nTab = mrViewData.GetTabNumber();
             ScDBDocFunc aFunc( *mrViewData.GetDocShell() );
@@ -7037,9 +7037,9 @@ void ScGridWindow::UpdateDatabaseOverlay()
     ScAddress aCurrentAddress = mrViewData.GetCurPos();
     std::vector<basegfx::B2DRange> aRanges;
     ScRange aCurrRange;
-    ScDBData* pDBData = rDocument.GetDBAtCursor(aCurrentAddress.Col(), 
aCurrentAddress.Row(),
-                                                aCurrentAddress.Tab(), 
ScDBDataPortion::AREA);
-    if (pDBData && pDBData->GetTableStyleInfo())
+    const ScDBData* pDBData = 
rDocument.GetTableDBAtCursor(aCurrentAddress.Col(), aCurrentAddress.Row(),
+        aCurrentAddress.Tab(), ScDBDataPortion::AREA);
+    if (pDBData)
     {
         pDBData->GetArea(aCurrRange);
         Point aStart = mrViewData.GetScrPos(aCurrRange.aStart.Col(),
diff --git a/sc/source/ui/view/tableshell.cxx b/sc/source/ui/view/tableshell.cxx
index 0ec68d7b909d..19d3152ecfc8 100644
--- a/sc/source/ui/view/tableshell.cxx
+++ b/sc/source/ui/view/tableshell.cxx
@@ -50,12 +50,12 @@ ScTableShell::ScTableShell(ScTabViewShell* pViewShell)
 
 ScTableShell::~ScTableShell() = default;
 
-const ScDBData* ScTableShell::GetDBDataAtCursor()
+const ScDBData* ScTableShell::GetTableDBDataAtCursor()
 {
     ScViewData& rViewData = m_pViewShell->GetViewData();
     const ScAddress aAddr = rViewData.GetCurPos();
-    return rViewData.GetDocument().GetDBAtCursor(aAddr.Col(), aAddr.Row(), 
aAddr.Tab(),
-                                                 ScDBDataPortion::AREA);
+    return rViewData.GetDocument().GetTableDBAtCursor(aAddr.Col(), 
aAddr.Row(), aAddr.Tab(),
+                                                      ScDBDataPortion::AREA);
 }
 
 void ScTableShell::ExecuteDatabaseSettings(SfxRequest& rReq)
@@ -76,8 +76,7 @@ void ScTableShell::ExecuteDatabaseSettings(SfxRequest& rReq)
             {
                 const ScDatabaseSettingItem* pDBItem
                     = static_cast<const ScDatabaseSettingItem*>(pItem);
-                const ScDBData* pDBData = GetDBDataAtCursor();
-                if (pDBData && pDBData->GetTableStyleInfo())
+                if (const ScDBData* pDBData = GetTableDBDataAtCursor())
                 {
                     ScDBData aNewDBData(*pDBData);
                     aNewDBData.SetAutoFilter(pDBItem->HasShowFilters());
@@ -148,23 +147,13 @@ void ScTableShell::GetDatabaseSettings(SfxItemSet& rSet)
         {
             case SCITEM_DATABASE_SETTING:
             {
-                const ScDBData* pDBData = GetDBDataAtCursor();
-                if (pDBData)
+                if (const ScDBData* pDBData = GetTableDBDataAtCursor())
                 {
                     const ScTableStyleParam* pParam = 
pDBData->GetTableStyleInfo();
-                    if (pParam)
-                    {
-                        rSet.Put(ScDatabaseSettingItem(
-                            pDBData->HasHeader(), pDBData->HasTotals(), 
pParam->mbFirstColumn,
-                            pParam->mbLastColumn, pParam->mbRowStripes, 
pParam->mbColumnStripes,
-                            pDBData->HasAutoFilter(), pParam->maStyleID));
-                    }
-                    else
-                    {
-                        rSet.Put(ScDatabaseSettingItem(pDBData->HasHeader(), 
pDBData->HasTotals(),
-                                                       false, false, false, 
false,
-                                                       
pDBData->HasAutoFilter(), u""_ustr));
-                    }
+                    rSet.Put(ScDatabaseSettingItem(pDBData->HasHeader(), 
pDBData->HasTotals(),
+                                                   pParam->mbFirstColumn, 
pParam->mbLastColumn,
+                                                   pParam->mbRowStripes, 
pParam->mbColumnStripes,
+                                                   pDBData->HasAutoFilter(), 
pParam->maStyleID));
                 }
             }
             break;
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index f18b37685ede..4d73ec5d6e66 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -681,9 +681,10 @@ void ScTabView::CursorPosChanged()
         aViewData.GetViewShell()->SetSparklineShell(bSparkline);
         if (!bSparkline)
         {
-            const ScDBData* pDbData = rDocument.GetDBAtCursor(rAddr.Col(), 
rAddr.Row(), rAddr.Tab(), ScDBDataPortion::AREA);
-            bool bHasDBTableStyle = pDbData && pDbData->GetTableStyleInfo();
-            aViewData.GetViewShell()->SetTableShell(bHasDBTableStyle);
+            if (rDocument.GetTableDBAtCursor(rAddr.Col(), rAddr.Row(), 
rAddr.Tab(), ScDBDataPortion::AREA))
+                aViewData.GetViewShell()->SetTableShell(true);
+            else
+                aViewData.GetViewShell()->SetTableShell(false);
         }
     }
 
commit 2ac538988560f0130aaf898d8a4cd69bd9f2128b
Author:     Balazs Varga <[email protected]>
AuthorDate: Thu Dec 4 18:14:24 2025 +0100
Commit:     Balazs Varga <[email protected]>
CommitDate: Thu Jan 29 09:33:17 2026 +0100

    Table Styles: ooxml export the 'None' table style as
    
    Table context as well, to keep the necessary infos.
    
    Change-Id: I10f244f985ca21a68b262356367eeb5d1076d4d0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195036
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Balazs Varga <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196773
    Tested-by: Balazs Varga <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197999
    Tested-by: Jenkins

diff --git a/sc/source/filter/excel/xedbdata.cxx 
b/sc/source/filter/excel/xedbdata.cxx
index 0a9b89a7ffde..fad30749c746 100644
--- a/sc/source/filter/excel/xedbdata.cxx
+++ b/sc/source/filter/excel/xedbdata.cxx
@@ -320,12 +320,14 @@ void XclExpTables::SaveTableXml( XclExpXmlStream& rStrm, 
const Entry& rEntry )
 
     if (const ScTableStyleParam* pParam = rData.GetTableStyleInfo())
     {
-        const OUString& rStyleName = pParam->maStyleID;
         if (const ScTableStyles* pTableStyles = 
rStrm.GetRoot().GetDoc().GetTableStyles())
         {
-            if (pTableStyles->GetTableStyle(rStyleName))
+            if (pParam->maStyleID == u"none" || 
pTableStyles->GetTableStyle(pParam->maStyleID))
             {
-                pTableStrm->singleElement(XML_tableStyleInfo, XML_name, 
rStyleName.toUtf8(),
+                std::optional<OString> aNameAttr
+                    = (pParam->maStyleID == u"none") ? std::nullopt
+                          : std::make_optional(pParam->maStyleID.toUtf8());
+                pTableStrm->singleElement(XML_tableStyleInfo, XML_name, 
aNameAttr,
                                           XML_showFirstColumn, 
ToPsz10(pParam->mbFirstColumn),
                                           XML_showLastColumn, 
ToPsz10(pParam->mbLastColumn),
                                           XML_showRowStripes, 
ToPsz10(pParam->mbRowStripes),
diff --git a/sc/source/filter/oox/tablebuffer.cxx 
b/sc/source/filter/oox/tablebuffer.cxx
index f0e54ae8b34c..9fcd6a32f252 100644
--- a/sc/source/filter/oox/tablebuffer.cxx
+++ b/sc/source/filter/oox/tablebuffer.cxx
@@ -96,7 +96,7 @@ void Table::importTable( SequenceInputStream& rStrm, 
sal_Int16 nSheet )
 void Table::importTableStyleInfo(const AttributeList& rAttribs)
 {
     TableStyleInfo aInfo;
-    aInfo.maStyleName = rAttribs.getString(XML_name, OUString());
+    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);

Reply via email to