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/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 ++--
 15 files changed, 105 insertions(+), 56 deletions(-)

New commits:
commit 9ee7c57308bbaddd5dec80ab5c9b2bbd8db6bac1
Author:     Balazs Varga <[email protected]>
AuthorDate: Thu Dec 4 18:21:29 2025 +0100
Commit:     Balazs Varga <[email protected]>
CommitDate: Fri Dec 5 20:55:17 2025 +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]>

diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx
index 49034c66b92a..98962c242d6a 100644
--- a/sc/inc/dbdata.hxx
+++ b/sc/inc/dbdata.hxx
@@ -434,13 +434,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 d8d856e26782..c77ab3acac12 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -909,11 +909,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 310606fc3f29..ade786e0a829 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -324,6 +324,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)
@@ -356,11 +372,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 11b0559e0964..b415ae76f7c9 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 988bffe77520..122012a43a70 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 aee06a745619..92fe27e4efac 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 bd00130f4c63..ea5b66694bf8 100644
--- a/sc/source/ui/dbgui/dbtabledlg.cxx
+++ b/sc/source/ui/dbgui/dbtabledlg.cxx
@@ -137,7 +137,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 843a8a049236..f3eb8055d2fc 100644
--- a/sc/source/ui/drawfunc/drawsh2.cxx
+++ b/sc/source/ui/drawfunc/drawsh2.cxx
@@ -580,9 +580,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 8225bf5ef01e..d5852db531fc 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -1360,14 +1360,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 61d1c3c65a74..64b43582e9f7 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -707,9 +707,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 5f3aec99b695..a896c2291dd0 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -2484,7 +2484,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() );
@@ -7010,9 +7010,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 3f811ef10fe3..35c52b864121 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -668,9 +668,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);
         }
     }
 

Reply via email to