officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu |   41 +
 officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu   |   14 
 sc/Library_sc.mk                                                  |    1 
 sc/UIConfig_scalc.mk                                              |    2 
 sc/inc/dbdata.hxx                                                 |    1 
 sc/inc/document.hxx                                               |    1 
 sc/inc/globstr.hrc                                                |   11 
 sc/inc/sc.hrc                                                     |    2 
 sc/sdi/cellsh.sdi                                                 |    1 
 sc/sdi/drawsh.sdi                                                 |    1 
 sc/sdi/drtxtob.sdi                                                |    1 
 sc/sdi/scalc.sdi                                                  |   36 +
 sc/sdi/tableshell.sdi                                             |    1 
 sc/source/core/data/documen3.cxx                                  |    9 
 sc/source/core/tool/dbdata.cxx                                    |    5 
 sc/source/filter/excel/xedbdata.cxx                               |    2 
 sc/source/ui/app/scdll.cxx                                        |    1 
 sc/source/ui/dbgui/dbnamdlg.cxx                                   |   22 
 sc/source/ui/dbgui/dbtabledlg.cxx                                 |  223 
++++++++++
 sc/source/ui/docshell/dbdocfun.cxx                                |  111 ++++
 sc/source/ui/inc/dbdocfun.hxx                                     |    4 
 sc/source/ui/inc/dbfunc.hxx                                       |    2 
 sc/source/ui/inc/dbtabledlg.hxx                                   |   72 +++
 sc/source/ui/inc/reffact.hxx                                      |    1 
 sc/source/ui/inc/undodat.hxx                                      |   24 +
 sc/source/ui/undo/undodat.cxx                                     |   88 +++
 sc/source/ui/view/cellsh2.cxx                                     |   66 ++
 sc/source/ui/view/dbfunc3.cxx                                     |   16 
 sc/source/ui/view/gridwin.cxx                                     |    2 
 sc/source/ui/view/reffact.cxx                                     |    2 
 sc/source/ui/view/tableshell.cxx                                  |   15 
 sc/source/ui/view/tabvwsh.cxx                                     |    1 
 sc/source/ui/view/tabvwshc.cxx                                    |   11 
 sc/uiconfig/scalc/menubar/menubar.xml                             |    2 
 sc/uiconfig/scalc/popupmenu/datatablemenu.xml                     |   13 
 sc/uiconfig/scalc/ui/definetablerangedialog.ui                    |  207 
+++++++++
 sc/uiconfig/scalc/ui/notebookbar.ui                               |   13 
 sc/uiconfig/scalc/ui/notebookbar_compact.ui                       |   42 +
 sc/uiconfig/scalc/ui/notebookbar_groupedbar_compact.ui            |   14 
 sc/uiconfig/scalc/ui/notebookbar_groupedbar_full.ui               |   13 
 sfx2/source/control/unoctitm.cxx                                  |    2 
 solenv/clang-format/excludelist                                   |    2 
 solenv/sanitizers/ui/modules/scalc.false                          |    1 
 static/CustomTarget_emscripten_fs_image.mk                        |    1 
 vcl/jsdialog/enabled.cxx                                          |    1 
 45 files changed, 1088 insertions(+), 13 deletions(-)

New commits:
commit c14cc57ac94a71e9453ec7b5ee261bd0460b2c99
Author:     Balazs Varga <[email protected]>
AuthorDate: Sun Nov 23 19:42:11 2025 +0100
Commit:     Balazs Varga <[email protected]>
CommitDate: Wed Nov 26 19:32:26 2025 +0100

    Table Style: introduce insert/delete Table... command available from
    
    menubar Insert and Data. With that command a new Table Style area (context) 
can be
    added to the sheet with a defalt table style name (Table1, Table2 etc.).
    If the default ooxml table styles are available the "TableStyleMedium2"
    style will be automatically applied (same as in Mso), which can be modified
    to any other available style after that.
    
    Also add new command for delete a table context. It is also available
    from Insert and Data menubar.
    
    For simplifying the dbrange behaviour, it will not possible to change 
DbRange
    properties of those DbRanges which has Table context. (same as in MSO)
    from the older DbRange dialog
    
    Change-Id: I98067e895d9595ba07206759deff6848dc299216
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194408
    Tested-by: Balazs Varga <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Balazs Varga <[email protected]>
    Code-Style: Balazs Varga <[email protected]>

diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu 
b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
index 6051a973ecea..fb5406a7e5b4 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
@@ -1167,6 +1167,47 @@
           <value>1</value>
         </prop>
       </node>
+      <node oor:name=".uno:DataTableMenu" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">~Table</value>
+        </prop>
+        <prop oor:name="Properties" oor:type="xs:int">
+          <value>1</value>
+        </prop>
+      </node>
+      <node oor:name=".uno:RunInsCalcTable" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">~Insert Table...</value>
+        </prop>
+        <prop oor:name="TargetURL" oor:type="xs:string">
+          <value>.uno:InsertCalcTable</value>
+        </prop>
+        <prop oor:name="Properties" oor:type="xs:int">
+          <value>1</value>
+        </prop>
+      </node>
+      <node oor:name=".uno:InsertCalcTable" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Table...</value>
+        </prop>
+        <prop oor:name="TooltipLabel" oor:type="xs:string">
+          <value xml:lang="en-US">Insert Table</value>
+        </prop>
+        <prop oor:name="Properties" oor:type="xs:int">
+          <value>1</value>
+        </prop>
+      </node>
+      <node oor:name=".uno:RemoveCalcTable" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">~Remove Table...</value>
+        </prop>
+        <prop oor:name="TooltipLabel" oor:type="xs:string">
+          <value xml:lang="en-US">Delete Table</value>
+        </prop>
+        <prop oor:name="Properties" oor:type="xs:int">
+          <value>1</value>
+        </prop>
+      </node>
       <node oor:name=".uno:InsertSparkline" oor:op="replace">
         <prop oor:name="Label" oor:type="xs:string">
           <value xml:lang="en-US">Sparkline...</value>
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu 
b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
index c6a104d3f525..348202e8e3d3 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
@@ -593,6 +593,20 @@
           <value>recordtrackedchanges</value>
         </prop>
       </node>
+      <node oor:name="c47" oor:op="replace">
+        <prop oor:name="Command">
+          <value>.uno:DataTableMenu</value>
+        </prop>
+        <prop oor:name="Module">
+          <value/>
+        </prop>
+        <prop oor:name="Controller">
+          <value>com.sun.star.comp.framework.ResourceMenuController</value>
+        </prop>
+        <prop oor:name="Value">
+          <value>datatablemenu</value>
+        </prop>
+      </node>
       <node oor:name="WindowListMenu" oor:op="replace">
         <prop oor:name="Command">
           <value>.uno:WindowList</value>
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 0fa088f7b7a4..dc46636209e6 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -424,6 +424,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
     sc/source/ui/dbgui/csvsplits \
     sc/source/ui/dbgui/csvtablebox \
     sc/source/ui/dbgui/dbnamdlg \
+    sc/source/ui/dbgui/dbtabledlg \
     sc/source/ui/dbgui/filtdlg \
     sc/source/ui/dbgui/foptmgr \
     sc/source/ui/dbgui/imoptdlg \
diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk
index 98bc564378fd..e330e6d7a8ab 100644
--- a/sc/UIConfig_scalc.mk
+++ b/sc/UIConfig_scalc.mk
@@ -22,6 +22,7 @@ $(eval $(call gb_UIConfig_add_popupmenufiles,modules/scalc,\
        sc/uiconfig/scalc/popupmenu/column_operations \
        sc/uiconfig/scalc/popupmenu/conditional \
        sc/uiconfig/scalc/popupmenu/conditional_easy \
+       sc/uiconfig/scalc/popupmenu/datatablemenu \
        sc/uiconfig/scalc/popupmenu/draw \
        sc/uiconfig/scalc/popupmenu/drawtext \
        sc/uiconfig/scalc/popupmenu/form \
@@ -123,6 +124,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
        sc/uiconfig/scalc/ui/dataproviderdlg \
        sc/uiconfig/scalc/ui/definedatabaserangedialog \
        sc/uiconfig/scalc/ui/definename \
+       sc/uiconfig/scalc/ui/definetablerangedialog \
        sc/uiconfig/scalc/ui/deletecells \
        sc/uiconfig/scalc/ui/deletecolumnentry \
        sc/uiconfig/scalc/ui/deletecontents \
diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx
index d95ad30eb83a..49034c66b92a 100644
--- a/sc/inc/dbdata.hxx
+++ b/sc/inc/dbdata.hxx
@@ -370,6 +370,7 @@ public:
         ScDBData* findByIndex(sal_uInt16 nIndex);
         ScDBData* findByUpperName(const OUString& rName);
         iterator findByUpperName2(const OUString& rName);
+        iterator findByPointer(const ScDBData* p);
         ScDBData* findByName(const OUString& rName);
 
         /** Takes ownership of p and attempts to insert it into the collection.
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index b2c2c1ab548b..d8d856e26782 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -913,6 +913,7 @@ public:
     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;
     void                         RefreshDirtyTableColumnNames();
     SC_DLLPUBLIC sc::ExternalDataMapper& GetExternalDataMapper();
 
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index b124996be1c3..d16a04581ceb 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -67,9 +67,11 @@
 #define STR_UNDO_REMOVEALLOTLNS                 NC_("STR_UNDO_REMOVEALLOTLNS", 
"Clear Outline")
 #define STR_UNDO_AUTOOUTLINE                    NC_("STR_UNDO_AUTOOUTLINE", 
"AutoOutline")
 #define STR_UNDO_SUBTOTALS                      NC_("STR_UNDO_SUBTOTALS", 
"Subtotals")
-#define STR_UNDO_TABLETOTALS                    NC_("STR_UNDO_TABLETOTALS", 
"Tabletotals")
+#define STR_UNDO_TABLETOTALS                    NC_("STR_UNDO_TABLETOTALS", 
"Table Total Row")
 #define STR_UNDO_SORT                           NC_("STR_UNDO_SORT", "Sort")
 #define STR_UNDO_QUERY                          NC_("STR_UNDO_QUERY", "Filter")
+#define STR_UNDO_DBADDTABLE                     NC_("STR_UNDO_DBTABLE", 
"Create table")
+#define STR_UNDO_DBREMTABLE                     NC_("STR_UNDO_DBTABLE", 
"Delete table")
 #define STR_UNDO_DBDATA                         NC_("STR_UNDO_DBDATA", "Change 
Database Range")
 #define STR_UNDO_IMPORTDATA                     NC_("STR_UNDO_IMPORTDATA", 
"Importing")
 #define STR_UNDO_REPEATDB                       NC_("STR_UNDO_REPEATDB", 
"Refresh range")
@@ -135,6 +137,8 @@
 #define STR_MSSG_DELETECELLS_0                  NC_("STR_MSSG_DELETECELLS_0", 
"Deleting in merged ranges not possible")
 #define STR_MSSG_MERGECELLS_0                   NC_("STR_MSSG_MERGECELLS_0", 
"Cell merge not possible if cells already merged")
 #define STR_SORT_ERR_MERGED                     NC_("STR_SORT_ERR_MERGED", 
"Ranges containing merged cells can only be sorted without formats.")
+#define STR_TABLE_ERR_ADD                       NC_("STR_TABLE_ERR_ADD", 
"Cannot add a new table to the sheet.")
+#define STR_TABLE_ERR_DEL                       NC_("STR_TABLE_ERR_DEL", 
"Cannot delete table from the sheet.")
 #define STR_MSSG_SOLVE_0                        NC_("STR_MSSG_SOLVE_0", "Goal 
Seek succeeded. Result: ")
 #define STR_MSSG_SOLVE_1                        NC_("STR_MSSG_SOLVE_1", "

Insert the result into the variable cell?")
 #define STR_MSSG_SOLVE_2                        NC_("STR_MSSG_SOLVE_2", "Goal 
Seek failed.

")
@@ -188,6 +192,8 @@
 #define STR_INVALIDTABNAME                      NC_("STR_INVALIDTABNAME", 
"Invalid sheet name.

The sheet name must not:
• be empty
• already exist
• contain [ ] * ? : / \ 
• use ' (apostrophe) as first or last character.")
 #define STR_SCENARIO                            NC_("STR_SCENARIO", "Scenario")
 #define STR_PIVOT_TABLE                         NC_("STR_PIVOT_TABLE", "Pivot 
Table")
+#define STR_CALC_TABLE                          NC_("STR_CALC_TABLE", "Table")
+#define STR_INVALIDTABLE                        NC_("STR_INVALIDTABLE", "The 
selected area is already part of another Table.")
  // Text strings for captions of subtotal functions.
 #define STR_FUN_TEXT_SUM                        NC_("STR_FUN_TEXT_SUM", "Sum")
 #define STR_FUN_TEXT_SELECTION_COUNT            
NC_("STR_FUN_TEXT_SELECTION_COUNT", "Selection count")
@@ -208,9 +214,10 @@
 #define STR_TABLE_GRAND_STDDEV                  NC_("STR_TABLE_GRAND_STDDEV", 
"Grand StdDev")
 #define STR_TABLE_GRAND_SUM                     NC_("STR_TABLE_GRAND_SUM", 
"Grand Sum")
 #define STR_TABLE_GRAND_VAR                     NC_("STR_TABLE_GRAND_VAR", 
"Grand Var")
-#define STR_TABLE_TOTAL                         NC_("STR_TABLE_TOTAL", 
"Summary")
+#define STR_TABLE_TOTAL                         NC_("STR_TABLE_TOTAL", "Total")
 #define STR_NOCHARTATCURSOR                     NC_("STR_NOCHARTATCURSOR", "No 
chart found at this position.")
 #define STR_PIVOT_NOTFOUND                      NC_("STR_PIVOT_NOTFOUND", "No 
pivot table found at this position.")
+#define STR_TABLE_NOTFOUND                      NC_("STR_TABLE_NOTFOUND", "No 
Calc Table found at this position.")
 #define STR_EMPTYDATA                           NC_("STR_EMPTYDATA", "(empty)")
 #define STR_PRINT_INVALID_AREA                  NC_("STR_PRINT_INVALID_AREA", 
"Invalid print range")
 #define STR_PAGESTYLE                           NC_("STR_PAGESTYLE", "Page 
Style")
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index 4d5ff4ad684c..aca0e1d07f50 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -638,6 +638,8 @@ static_assert(SID_PREVIEW_END < SID_KEYFUNC_START, "calc 
slots ids trampling inf
 #define SID_EDIT_SPARKLINE          (SID_NEW_SLOTS+116)
 #define SID_SC_OPT_LINKS            TypedWhichId<SfxBoolItem>(SID_NEW_SLOTS + 
117)
 #define SID_DATABASE_SETTINGS       (SID_NEW_SLOTS+118)
+#define SID_INSERT_CALCTABLE        (SID_NEW_SLOTS+119)
+#define SID_REMOVE_CALCTABLE        (SID_NEW_SLOTS+120)
 
 // idl parameter
 
diff --git a/sc/sdi/cellsh.sdi b/sc/sdi/cellsh.sdi
index 44e87cd69119..8f76817b6b46 100644
--- a/sc/sdi/cellsh.sdi
+++ b/sc/sdi/cellsh.sdi
@@ -63,6 +63,7 @@ interface CellSelection
     FID_VALIDATION          [ ExecMethod = ExecuteDB; StateMethod = 
GetBlockState; ]
     FID_CURRENTVALIDATION   [ ExecMethod = ExecuteDB; StateMethod = 
GetBlockState; ]
     SID_TEXT_TO_COLUMNS     [ ExecMethod = ExecuteDB; StateMethod = 
GetDBState; ]
+    SID_INSERT_CALCTABLE    [ ExecMethod = ExecuteDB; StateMethod = 
GetDBState; ]
 
     // } database operations
 
diff --git a/sc/sdi/drawsh.sdi b/sc/sdi/drawsh.sdi
index 1f3bcfa194a2..7e91d323178b 100644
--- a/sc/sdi/drawsh.sdi
+++ b/sc/sdi/drawsh.sdi
@@ -33,6 +33,7 @@ interface TableDraw
     SID_DEFINE_DBNAME           [ StateMethod = StateDisableItems; ]
     SID_OPENDLG_CONSOLIDATE     [ StateMethod = StateDisableItems; ]
     SID_OPENDLG_EDIT_PRINTAREA  [ StateMethod = StateDisableItems; ]
+    SID_INSERT_CALCTABLE        [ StateMethod = StateDisableItems; ]
     // others:
     SID_DRAW_CHART              [ StateMethod = StateDisableItems; ]
 
diff --git a/sc/sdi/drtxtob.sdi b/sc/sdi/drtxtob.sdi
index 5302b5bf1b63..a1a82da20611 100644
--- a/sc/sdi/drtxtob.sdi
+++ b/sc/sdi/drtxtob.sdi
@@ -30,6 +30,7 @@ interface TableDrawText
     SID_DEFINE_DBNAME           [ StateMethod = StateDisableItems; ]
     SID_OPENDLG_CONSOLIDATE     [ StateMethod = StateDisableItems; ]
     SID_OPENDLG_EDIT_PRINTAREA  [ StateMethod = StateDisableItems; ]
+    SID_INSERT_CALCTABLE        [ StateMethod = StateDisableItems; ]
     // others:
     SID_DRAW_CHART              [ StateMethod = StateDisableItems; ]
     SID_OPENDLG_FUNCTION        [ StateMethod = StateDisableItems; ]
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
index 58d577c16954..48a3e25425ec 100644
--- a/sc/sdi/scalc.sdi
+++ b/sc/sdi/scalc.sdi
@@ -6459,6 +6459,42 @@ ScDatabaseSettingItem DatabaseSettings 
SID_DATABASE_SETTINGS
 ]
 
 
+SfxVoidItem InsertCalcTable SID_INSERT_CALCTABLE
+()
+[
+    AutoUpdate = FALSE,
+    FastCall = FALSE,
+    ReadOnlyDoc = TRUE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    ToolBoxConfig = TRUE,
+    GroupId = SfxGroupId::Data;
+]
+
+
+SfxVoidItem RemoveCalcTable SID_REMOVE_CALCTABLE
+()
+[
+    AutoUpdate = FALSE,
+    FastCall = FALSE,
+    ReadOnlyDoc = TRUE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    ToolBoxConfig = TRUE,
+    GroupId = SfxGroupId::Data;
+]
+
+
 SfxVoidItem SelectArrayFormula SID_MARKARRAYFORMULA
 ()
 [
diff --git a/sc/sdi/tableshell.sdi b/sc/sdi/tableshell.sdi
index c3147e933208..f14fdb6397f5 100644
--- a/sc/sdi/tableshell.sdi
+++ b/sc/sdi/tableshell.sdi
@@ -10,6 +10,7 @@
 interface Table
 {
     SID_DATABASE_SETTINGS [ ExecMethod = ExecuteDatabaseSettings; StateMethod 
= GetDatabaseSettings; ]
+    SID_REMOVE_CALCTABLE  [ ExecMethod = ExecuteDatabaseSettings; StateMethod 
= GetDatabaseSettings; ]
 }
 
 shell ScTableShell
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 9843ccebf58d..310606fc3f29 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -356,6 +356,15 @@ 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
+{
+    if (pDBCollection)
+        return pDBCollection->GetAllDBsInArea(nCol1, nRow1, nCol2, nRow2, 
nTab);
+    else
+        return std::vector<const ScDBData*>();
+}
+
 void ScDocument::RefreshDirtyTableColumnNames()
 {
     if (pDBCollection)
diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx
index 10336fa9071a..4a2948e53ea6 100644
--- a/sc/source/core/tool/dbdata.cxx
+++ b/sc/source/core/tool/dbdata.cxx
@@ -1881,6 +1881,11 @@ auto ScDBCollection::NamedDBs::findByUpperName2(const 
OUString& rName) -> iterat
         m_DBs.begin(), m_DBs.end(), FindByUpperName(rName));
 }
 
+auto ScDBCollection::NamedDBs::findByPointer( const ScDBData* p ) -> iterator
+{
+    return find_if(m_DBs.begin(), m_DBs.end(), FindByPointer(p));
+}
+
 ScDBData* ScDBCollection::NamedDBs::findByName(const OUString& rName)
 {
     DBsType::iterator itr = find_if(m_DBs.begin(), m_DBs.end(), 
FindByName(rName));
diff --git a/sc/source/filter/excel/xedbdata.cxx 
b/sc/source/filter/excel/xedbdata.cxx
index 894c947ba759..0a9b89a7ffde 100644
--- a/sc/source/filter/excel/xedbdata.cxx
+++ b/sc/source/filter/excel/xedbdata.cxx
@@ -323,7 +323,7 @@ void XclExpTables::SaveTableXml( XclExpXmlStream& rStrm, 
const Entry& rEntry )
         const OUString& rStyleName = pParam->maStyleID;
         if (const ScTableStyles* pTableStyles = 
rStrm.GetRoot().GetDoc().GetTableStyles())
         {
-            if (const ScTableStyle* pTableStyle = 
pTableStyles->GetTableStyle(rStyleName))
+            if (pTableStyles->GetTableStyle(rStyleName))
             {
                 pTableStrm->singleElement(XML_tableStyleInfo, XML_name, 
rStyleName.toUtf8(),
                                           XML_showFirstColumn, 
ToPsz10(pParam->mbFirstColumn),
diff --git a/sc/source/ui/app/scdll.cxx b/sc/source/ui/app/scdll.cxx
index bfd87973c762..b15e3c3fd605 100644
--- a/sc/source/ui/app/scdll.cxx
+++ b/sc/source/ui/app/scdll.cxx
@@ -199,6 +199,7 @@ void ScDLL::Init()
     ScPrintAreasDlgWrapper      ::RegisterChildWindow(false, pMod);
     ScColRowNameRangesDlgWrapper::RegisterChildWindow(false, pMod);
     ScFormulaDlgWrapper         ::RegisterChildWindow(false, pMod);
+    ScTableLayoutWrapper        ::RegisterChildWindow(false, pMod);
 
     ScRandomNumberGeneratorDialogWrapper::RegisterChildWindow(false, pMod);
     ScSamplingDialogWrapper             ::RegisterChildWindow(false, pMod);
diff --git a/sc/source/ui/dbgui/dbnamdlg.cxx b/sc/source/ui/dbgui/dbnamdlg.cxx
index 3b05ca1b371e..edc8788eea9b 100644
--- a/sc/source/ui/dbgui/dbnamdlg.cxx
+++ b/sc/source/ui/dbgui/dbnamdlg.cxx
@@ -354,9 +354,18 @@ void ScDbNameDlg::UpdateDBData( const OUString& rStrName )
     }
 
     m_xBtnAdd->set_label( aStrModify );
-    m_xBtnAdd->set_sensitive(true);
-    m_xBtnRemove->set_sensitive(true);
-    m_xOptions->set_sensitive(true);
+    if (!pData->GetTableStyleInfo())
+    {
+        m_xOptions->set_sensitive(true);
+        m_xBtnAdd->set_sensitive(true);
+        m_xBtnRemove->set_sensitive(true);
+    }
+    else
+    {
+        m_xBtnAdd->set_sensitive(false);
+        m_xBtnRemove->set_sensitive(false);
+        m_xOptions->set_sensitive(false);
+    }
 }
 
 bool ScDbNameDlg::IsRefInputMode() const
@@ -591,7 +600,12 @@ IMPL_LINK_NOARG(ScDbNameDlg, NameModifyHdl, 
weld::ComboBox&, void)
             m_xBtnRemove->set_sensitive(false);
         }
 
-        m_xAssignFrame->set_sensitive(true);
+        const ScDBData* pData = aLocalDbCol.getNamedDBs().findByUpperName(
+            ScGlobal::getCharClass().uppercase(theName));
+        if (pData && pData->GetTableStyleInfo())
+            m_xAssignFrame->set_sensitive(false);
+        else
+            m_xAssignFrame->set_sensitive(true);
 
         //@BugID 54702 enable/disable in the base class only
         //SFX_APPWINDOW->set_sensitive(true);
diff --git a/sc/source/ui/dbgui/dbtabledlg.cxx 
b/sc/source/ui/dbgui/dbtabledlg.cxx
new file mode 100644
index 000000000000..9c656129e3f5
--- /dev/null
+++ b/sc/source/ui/dbgui/dbtabledlg.cxx
@@ -0,0 +1,223 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <memory>
+#include <sal/config.h>
+
+#include <cassert>
+
+#include <comphelper/string.hxx>
+#include <unotools/charclass.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/weld.hxx>
+#include <o3tl/string_view.hxx>
+
+#include <reffact.hxx>
+#include <document.hxx>
+#include <globstr.hrc>
+#include <scresid.hxx>
+#include <dbtabledlg.hxx>
+#include <dbdocfun.hxx>
+#include <tablestyle.hxx>
+
+ScDbTableDlg::ScDbTableDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* 
pParent,
+                           ScViewData& rViewData)
+    : ScAnyRefDlgController(pB, pCW, pParent, 
u"modules/scalc/ui/definetablerangedialog.ui"_ustr,
+                            u"tablerangedialog"_ustr)
+    , m_rViewData(rViewData)
+    , rDoc(rViewData.GetDocument())
+    , bRefInputMode(true)
+    , aAddrDetails(rDoc.GetAddressConvention(), 0, 0)
+    , m_xAssignFrame(m_xBuilder->weld_frame(u"rangeframe"_ustr))
+    , m_xEdAssign(new formula::RefEdit(m_xBuilder->weld_entry(u"assign"_ustr)))
+    , m_xRbAssign(new 
formula::RefButton(m_xBuilder->weld_button(u"assgnrb"_ustr)))
+    , m_xOptions(m_xBuilder->weld_widget(u"options"_ustr))
+    , m_xBtnHeader(m_xBuilder->weld_check_button(u"bheaders"_ustr))
+    , m_xBtnOk(m_xBuilder->weld_button(u"ok"_ustr))
+    , m_xBtnCancel(m_xBuilder->weld_button(u"cancel"_ustr))
+    , m_xFrameLabel(m_xAssignFrame->weld_label_widget())
+{
+    m_xEdAssign->SetReferences(this, m_xFrameLabel.get());
+    m_xRbAssign->SetReferences(this, m_xEdAssign.get());
+
+    Init();
+}
+
+ScDbTableDlg::~ScDbTableDlg()
+{
+    if (m_xInfoBox)
+        m_xInfoBox->response(RET_OK);
+}
+
+void ScDbTableDlg::Init()
+{
+    m_xBtnHeader->set_active(true); // Default: with column headers
+
+    m_xBtnOk->connect_clicked(LINK(this, ScDbTableDlg, OkBtnHdl));
+    m_xBtnCancel->connect_clicked(LINK(this, ScDbTableDlg, CancelBtnHdl));
+    m_xEdAssign->SetModifyHdl(LINK(this, ScDbTableDlg, AssModifyHdl));
+
+    SCCOL nStartCol, nEndCol = 0;
+    SCROW nStartRow, nEndRow = 0;
+    SCTAB nStartTab, nEndTab = 0;
+
+    m_rViewData.GetSimpleArea(nStartCol, nStartRow, nStartTab, nEndCol, 
nEndRow, nEndTab);
+    theCurArea = ScRange(nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, 
nEndTab);
+    OUString theAreaStr = theCurArea.Format(rDoc, ScRefFlags::RANGE_ABS_3D, 
aAddrDetails);
+    m_xEdAssign->SetText(theAreaStr);
+
+    bInvalid = false;
+}
+
+void ScDbTableDlg::SetReference(const ScRange& rRef, ScDocument& rDocP)
+{
+    if (!m_xEdAssign->GetWidget()->get_sensitive())
+        return;
+
+    if (rRef.aStart != rRef.aEnd)
+        RefInputStart(m_xEdAssign.get());
+
+    theCurArea = rRef;
+
+    OUString aRefStr(theCurArea.Format(rDocP, ScRefFlags::RANGE_ABS_3D, 
aAddrDetails));
+    m_xEdAssign->SetRefString(aRefStr);
+    m_xOptions->set_sensitive(true);
+}
+
+void ScDbTableDlg::Close() { 
DoClose(ScTableLayoutWrapper::GetChildWindowId()); }
+
+void ScDbTableDlg::SetActive()
+{
+    m_xEdAssign->GrabFocus();
+    RefInputDone();
+}
+
+bool ScDbTableDlg::IsRefInputMode() const { return bRefInputMode; }
+
+void ScDbTableDlg::ErrorBox(const OUString& rString)
+{
+    if (m_xInfoBox)
+        m_xInfoBox->response(RET_OK);
+
+    m_xInfoBox = 
std::shared_ptr<weld::MessageDialog>(Application::CreateMessageDialog(
+        m_xDialog.get(), VclMessageType::Warning, VclButtonsType::Ok, 
rString));
+
+    m_xInfoBox->runAsync(m_xInfoBox, [this](sal_Int32) { m_xInfoBox = nullptr; 
});
+}
+
+IMPL_LINK_NOARG(ScDbTableDlg, OkBtnHdl, weld::Button&, void)
+{
+    bInvalid = false;
+
+    OUString aNewArea = m_xEdAssign->GetText();
+
+    if (aNewArea.isEmpty())
+        return;
+
+    ScRange aTmpRange;
+    if (aTmpRange.ParseAny(aNewArea, rDoc, aAddrDetails) & ScRefFlags::VALID)
+    {
+        if (aTmpRange.aStart.Row() == aTmpRange.aEnd.Row()) // minimum 2 row 
height needs
+            aTmpRange.aEnd.IncRow();
+        theCurArea = aTmpRange;
+
+        std::vector<const ScDBData*> aDBData = rDoc.GetAllDBsInArea(
+            theCurArea.aStart.Col(), theCurArea.aStart.Row(), 
theCurArea.aEnd.Col(),
+            theCurArea.aEnd.Row(), theCurArea.aStart.Tab());
+
+        for (const ScDBData* pDBData : aDBData)
+        {
+            if (const ScTableStyleParam* pTableStyleInfo = 
pDBData->GetTableStyleInfo())
+            {
+                bInvalid = true;
+                theCurArea = ScRange();
+                break;
+            }
+        }
+
+        if (bInvalid)
+        {
+            ErrorBox(ScResId(STR_INVALIDTABLE));
+            m_xEdAssign->SelectAll();
+            m_xEdAssign->GrabFocus();
+            return;
+        }
+
+        //  insert new area
+        OUString aTable = ScResId(STR_CALC_TABLE);
+        tools::Long nCount = 0;
+        const ScDBData* pDummy = nullptr;
+        ScDBCollection::NamedDBs& rDBs = rDoc.GetDBCollection()->getNamedDBs();
+        OUString aNewName;
+        do
+        {
+            ++nCount;
+            aNewName = aTable + OUString::number(nCount);
+            pDummy = 
rDBs.findByUpperName(ScGlobal::getCharClass().uppercase(aNewName));
+        } while (pDummy);
+
+        OUString aDefault = u""_ustr;
+        if (const ScTableStyles* pTableStyles = rDoc.GetTableStyles())
+        {
+            const ScTableStyle* pTableStyle
+                = pTableStyles->GetTableStyle(u"TableStyleMedium2"_ustr);
+            if (pTableStyle)
+                aDefault = u"TableStyleMedium2"_ustr;
+        }
+
+        ScDBDocFunc aFunc(*m_rViewData.GetDocShell());
+        bInvalid = !aFunc.AddDBTable(aNewName, ScRange(theCurArea.aStart, 
theCurArea.aEnd),
+                                     m_xBtnHeader->get_active(), true, false, 
aDefault);
+
+        m_xEdAssign->SetText(u""_ustr);
+        m_xBtnHeader->set_active(true);
+        theCurArea = ScRange();
+    }
+    else
+    {
+        ErrorBox(ScResId(STR_ERR_INVALID_AREA));
+        m_xEdAssign->SelectAll();
+        m_xEdAssign->GrabFocus();
+        bInvalid = true;
+    }
+
+    if (!bInvalid)
+        response(RET_OK);
+}
+
+IMPL_LINK_NOARG(ScDbTableDlg, CancelBtnHdl, weld::Button&, void) { 
response(RET_CANCEL); }
+
+IMPL_LINK_NOARG(ScDbTableDlg, AssModifyHdl, formula::RefEdit&, void)
+{
+    ScRange aTmpRange;
+    OUString aText = m_xEdAssign->GetText();
+    if (aTmpRange.ParseAny(aText, rDoc, aAddrDetails) & ScRefFlags::VALID)
+        theCurArea = aTmpRange;
+
+    if (!aText.isEmpty())
+    {
+        m_xBtnHeader->set_sensitive(true);
+    }
+    else
+    {
+        m_xBtnHeader->set_sensitive(false);
+    }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/dbdocfun.cxx 
b/sc/source/ui/docshell/dbdocfun.cxx
index 0d0045c4b9cd..4cf8ef65b155 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -69,6 +69,117 @@ bool ScDBDocFunc::CheckSheetViewProtection(sc::Operation 
eOperation)
     return aSheetViewTester.check(eOperation);
 }
 
+bool ScDBDocFunc::AddDBTable(const OUString& rName, const ScRange& rRange, 
bool bHeader,
+                             bool bRecord, bool bApi, const OUString& 
rStyleName)
+{
+    ScDocShellModificator aModificator(rDocShell);
+
+    ScDocument& rDoc = rDocShell.GetDocument();
+    ScDBCollection* pDocColl = rDoc.GetDBCollection();
+    if (bRecord && !rDoc.IsUndoEnabled())
+        bRecord = false;
+
+    if (rStyleName.isEmpty())
+    {
+        if (!bApi)
+            rDocShell.ErrorMessage(STR_TABLE_ERR_ADD);
+        return false;
+    }
+
+    std::unique_ptr<ScDBCollection> pUndoColl;
+    if (bRecord)
+        pUndoColl.reset(new ScDBCollection(*pDocColl));
+
+    std::unique_ptr<ScDBData> pNew(new ScDBData(rName, rRange.aStart.Tab(), 
rRange.aStart.Col(),
+                                                rRange.aStart.Row(), 
rRange.aEnd.Col(), rRange.aEnd.Row(),
+                                                true, bHeader, false, 
u""_ustr, rStyleName));
+    if (pNew)
+    {
+        pNew->SetAutoFilter(true);
+        rDoc.ApplyFlagsTab(rRange.aStart.Col(), rRange.aStart.Row(), 
rRange.aEnd.Col(),
+                           rRange.aStart.Row(), rRange.aStart.Tab(), 
ScMF::Auto);
+    }
+
+    bool bCompile = !rDoc.IsImportingXML();
+    if (bCompile)
+        rDoc.PreprocessDBDataUpdate();
+
+    bool bOk = pDocColl->getNamedDBs().insert(std::move(pNew));
+    if (bCompile)
+        rDoc.CompileHybridFormula();
+
+    if (!bOk && !bApi)
+    {
+        rDocShell.ErrorMessage(STR_TABLE_ERR_ADD);
+        return false;
+    }
+
+    rDocShell.PostPaint(rRange, PaintPartFlags::Grid | PaintPartFlags::Left | 
PaintPartFlags::Top | PaintPartFlags::Size);
+
+    if (bRecord)
+    {
+        rDocShell.GetUndoManager()->AddUndoAction(
+            std::make_unique<ScUndoDBTable>(&rDocShell, rName, 
true/*bInsert*/, std::move(pUndoColl),
+                                           
std::make_unique<ScDBCollection>(*pDocColl)));
+    }
+
+    aModificator.SetDocumentModified();
+    SfxGetpApp()->Broadcast(SfxHint(SfxHintId::ScDbAreasChanged));
+    return true;
+}
+
+bool ScDBDocFunc::DeleteDBTable(const ScDBData* pDBObj, bool bRecord, bool 
bApi)
+{
+    bool bDone = false;
+    ScDocument& rDoc = rDocShell.GetDocument();
+    ScDBCollection* pDocColl = rDoc.GetDBCollection();
+    if (bRecord && !rDoc.IsUndoEnabled())
+        bRecord = false;
+
+    ScDBCollection::NamedDBs& rDBs = pDocColl->getNamedDBs();
+    auto const iter = rDBs.findByPointer(pDBObj);
+    if (iter != rDBs.end())
+    {
+        ScDocShellModificator aModificator(rDocShell);
+        std::unique_ptr<ScDBCollection> pUndoColl;
+        if (bRecord)
+            pUndoColl.reset(new ScDBCollection(*pDocColl));
+
+        OUString aTableName = iter->get()->GetName();
+        ScRange aRange;
+        iter->get()->GetArea(aRange);
+
+        rDoc.PreprocessDBDataUpdate();
+        rDBs.erase(iter);
+        rDoc.CompileHybridFormula();
+
+        if (aRange.IsValid())
+        {
+            rDoc.RemoveFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(), 
aRange.aEnd.Col(),
+                                aRange.aStart.Row(), aRange.aStart.Tab(), 
ScMF::Auto);
+            rDocShell.PostPaint(aRange, PaintPartFlags::Grid | 
PaintPartFlags::Left
+                                            | PaintPartFlags::Top | 
PaintPartFlags::Size);
+        }
+
+        if (bRecord)
+        {
+            rDocShell.GetUndoManager()->AddUndoAction(
+                std::make_unique<ScUndoDBTable>(&rDocShell, aTableName, 
false/*bInsert*/, std::move(pUndoColl),
+                                                
std::make_unique<ScDBCollection>(*pDocColl)));
+        }
+
+        aModificator.SetDocumentModified();
+        SfxGetpApp()->Broadcast(SfxHint(SfxHintId::ScDbAreasChanged));
+        bDone = true;
+    }
+    else if (!bApi)
+    {
+        rDocShell.ErrorMessage(STR_TABLE_ERR_DEL);
+    }
+
+    return bDone;
+}
+
 bool ScDBDocFunc::AddDBRange( const OUString& rName, const ScRange& rRange )
 {
 
diff --git a/sc/source/ui/inc/dbdocfun.hxx b/sc/source/ui/inc/dbdocfun.hxx
index 8741a05ee544..910a5130b7e3 100644
--- a/sc/source/ui/inc/dbdocfun.hxx
+++ b/sc/source/ui/inc/dbdocfun.hxx
@@ -77,6 +77,10 @@ public:
     void            DoTableSubTotals( SCTAB nTab, const ScDBData& rNewData, 
const ScSubTotalParam& rParam,
                                       bool bRecord, bool bApi );
 
+    bool AddDBTable(const OUString& rName, const ScRange& rRange, bool 
bHeader, bool bRecord,
+                    bool bApi, const OUString& rStyleName = u""_ustr);
+    bool DeleteDBTable(const ScDBData* pDBObj, bool bRecord, bool bApi );
+
     bool AddDBRange( const OUString& rName, const ScRange& rRange );
     bool DeleteDBRange( const OUString& rName );
     bool RenameDBRange( const OUString& rOld, const OUString& rNew );
diff --git a/sc/source/ui/inc/dbfunc.hxx b/sc/source/ui/inc/dbfunc.hxx
index 826b949fc9c2..9494b0896b05 100644
--- a/sc/source/ui/inc/dbfunc.hxx
+++ b/sc/source/ui/inc/dbfunc.hxx
@@ -59,6 +59,8 @@ public:
     void            DoTableSubTotals( const ScDBData& rNewData, const 
ScSubTotalParam& rParam,
                                       bool bRecord = true );
 
+    void            DeleteCalcTable();
+
     void            ToggleAutoFilter();
     void            HideAutoFilter();
 
diff --git a/sc/source/ui/inc/dbtabledlg.hxx b/sc/source/ui/inc/dbtabledlg.hxx
new file mode 100644
index 000000000000..2475e8e9674a
--- /dev/null
+++ b/sc/source/ui/inc/dbtabledlg.hxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <vector>
+#include "anyrefdg.hxx"
+#include <dbdata.hxx>
+
+class ScViewData;
+class ScDocument;
+
+class ScDbTableDlg : public ScAnyRefDlgController
+{
+public:
+    ScDbTableDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent,
+                ScViewData& rViewData);
+    virtual ~ScDbTableDlg() override;
+
+    virtual void    SetReference( const ScRange& rRef, ScDocument& rDoc ) 
override;
+
+    virtual bool    IsRefInputMode() const override;
+    virtual void    SetActive() override;
+    virtual void    Close() override;
+
+private:
+    bool            bInvalid;
+
+    ScViewData&     m_rViewData;
+    const ScDocument&     rDoc;
+    bool            bRefInputMode;
+    ScAddress::Details aAddrDetails;
+    ScRange         theCurArea;
+
+    std::unique_ptr<weld::Frame> m_xAssignFrame;
+    std::unique_ptr<formula::RefEdit> m_xEdAssign;
+    std::unique_ptr<formula::RefButton> m_xRbAssign;
+
+    std::unique_ptr<weld::Widget> m_xOptions;
+    std::unique_ptr<weld::CheckButton> m_xBtnHeader;
+
+    std::unique_ptr<weld::Button> m_xBtnOk;
+    std::unique_ptr<weld::Button> m_xBtnCancel;
+
+    std::unique_ptr<weld::Label> m_xFrameLabel;
+    std::shared_ptr<weld::MessageDialog> m_xInfoBox;
+
+    void Init();
+    void ErrorBox(const OUString& rString);
+
+    DECL_LINK( CancelBtnHdl, weld::Button&, void );
+    DECL_LINK( OkBtnHdl, weld::Button&, void );
+    DECL_LINK( AssModifyHdl, formula::RefEdit&, void );
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/reffact.hxx b/sc/source/ui/inc/reffact.hxx
index de001354bda8..f4d4a88df469 100644
--- a/sc/source/ui/inc/reffact.hxx
+++ b/sc/source/ui/inc/reffact.hxx
@@ -48,6 +48,7 @@ DECL_WRAPPER_WITHID(ScColRowNameRangesDlgWrapper)
 DECL_WRAPPER_WITHID(ScFormulaDlgWrapper)
 DECL_WRAPPER_WITHID(ScHighlightChgDlgWrapper)
 DECL_WRAPPER_WITHID(ScCondFormatDlgWrapper)
+DECL_WRAPPER_WITHID(ScTableLayoutWrapper)
 
 class ScDescriptiveStatisticsDialogWrapper :
     public ChildControllerWrapper<SID_DESCRIPTIVE_STATISTICS_DIALOG>
diff --git a/sc/source/ui/inc/undodat.hxx b/sc/source/ui/inc/undodat.hxx
index 8d9e251c6e29..7e1428429c33 100644
--- a/sc/source/ui/inc/undodat.hxx
+++ b/sc/source/ui/inc/undodat.hxx
@@ -205,6 +205,30 @@ private:
     std::unique_ptr<ScDBCollection> xUndoDB;
 };
 
+class ScUndoDBTable : public ScSimpleUndo
+{
+public:
+    ScUndoDBTable(ScDocShell* pNewDocShell, const OUString& rNewTable, bool 
bIns,
+                  std::unique_ptr<ScDBCollection> pNewUndoColl,
+                  std::unique_ptr<ScDBCollection> pNewRedoColl);
+    virtual ~ScUndoDBTable() override;
+
+    virtual void Undo() override;
+    virtual void Redo() override;
+    virtual void Repeat(SfxRepeatTarget& rTarget) override;
+    virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
+
+    virtual OUString GetComment() const override;
+
+private:
+    OUString aTableName;
+    bool bInsert;
+    std::unique_ptr<ScDBCollection> pUndoColl;
+    std::unique_ptr<ScDBCollection> pRedoColl;
+
+    void DoChange(const bool bUndo);
+};
+
 class ScUndoTableTotals: public ScDBFuncUndo
 {
 public:
diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx
index 8f6e34791a95..064c31c6351c 100644
--- a/sc/source/ui/undo/undodat.cxx
+++ b/sc/source/ui/undo/undodat.cxx
@@ -747,6 +747,94 @@ bool ScUndoSubTotals::CanRepeat(SfxRepeatTarget& /* 
rTarget */) const
     return false;     // is not possible due to column numbers
 }
 
+ScUndoDBTable::ScUndoDBTable(ScDocShell* pNewDocShell, const OUString& 
rNewTable, bool bIns,
+                             std::unique_ptr<ScDBCollection> pNewUndoColl,
+                             std::unique_ptr<ScDBCollection> pNewRedoColl ) :
+    ScSimpleUndo( pNewDocShell ),
+    aTableName( rNewTable ),
+    bInsert( bIns ),
+    pUndoColl( std::move(pNewUndoColl) ),
+    pRedoColl( std::move(pNewRedoColl) )
+{
+}
+
+ScUndoDBTable::~ScUndoDBTable()
+{
+}
+
+OUString ScUndoDBTable::GetComment() const
+{   // "Insert/Delete tables";
+    return bInsert ? ScResId(STR_UNDO_DBADDTABLE) : 
ScResId(STR_UNDO_DBREMTABLE);
+}
+
+void ScUndoDBTable::Undo()
+{
+    BeginUndo();
+    DoChange(true);
+    SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScDbAreasChanged ) );
+    EndUndo();
+}
+
+void ScUndoDBTable::Redo()
+{
+    BeginRedo();
+    DoChange(false);
+    SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScDbAreasChanged ) );
+    EndRedo();
+}
+
+void ScUndoDBTable::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+}
+
+bool ScUndoDBTable::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+    return false;    // is not possible
+}
+
+void ScUndoDBTable::DoChange(const bool bUndo)
+{
+    ScDBCollection* pWorkRefData = bUndo ? pUndoColl.get() : pRedoColl.get();
+
+    ScDocument& rDoc = pDocShell->GetDocument();
+    bool bOldAutoCalc = rDoc.GetAutoCalc();
+    rDoc.SetAutoCalc(false); // Avoid unnecessary calculations
+    rDoc.PreprocessDBDataUpdate();
+    rDoc.SetDBCollection(std::unique_ptr<ScDBCollection>(new 
ScDBCollection(*pWorkRefData)), true);
+    rDoc.CompileHybridFormula();
+    rDoc.SetAutoCalc(bOldAutoCalc);
+
+    pWorkRefData = !bInsert ? pUndoColl.get() : pRedoColl.get();
+    if (const ScDBData* pDBData = pWorkRefData->getNamedDBs().findByUpperName(
+            ScGlobal::getCharClass().uppercase(aTableName)))
+    {
+        ScRange aRange;
+        pDBData->GetArea(aRange);
+        if (!aRange.IsValid())
+            return;
+
+        if (pDBData->HasAutoFilter())
+        {
+            const bool bApply = (bInsert != bUndo);
+            auto func = bApply ? &ScDocument::ApplyFlagsTab : 
&ScDocument::RemoveFlagsTab;
+            (rDoc.*func)(aRange.aStart.Col(), aRange.aStart.Row(), 
aRange.aEnd.Col(),
+                         aRange.aStart.Row(), aRange.aStart.Tab(), ScMF::Auto);
+        }
+
+        if (ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell())
+        {
+            SCTAB nTab = aRange.aStart.Tab();
+            SCTAB nVisTab = pViewShell->GetViewData().GetTabNumber();
+            if (nVisTab != nTab)
+                pViewShell->SetTabNo(nTab);
+
+            pDocShell->PostPaint(ScRange(0, 0, nTab, rDoc.MaxCol(), 
rDoc.MaxRow(), nTab),
+                                 PaintPartFlags::Grid | PaintPartFlags::Left | 
PaintPartFlags::Top
+                                     | PaintPartFlags::Size);
+        }
+    }
+}
+
 ScUndoTableTotals::ScUndoTableTotals(ScDocShell* pNewDocShell, SCTAB nNewTab,
                                      const ScSubTotalParam& rNewParam, SCROW 
nNewEndY,
                                      ScDocumentUniquePtr pNewUndoDoc,
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index 9ca07df51670..90d8495144c6 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -744,6 +744,16 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
             }
             break;
 
+        case SID_INSERT_CALCTABLE:
+            {
+                sal_uInt16 nId = ScTableLayoutWrapper::GetChildWindowId();
+                SfxViewFrame& rViewFrm = pTabViewShell->GetViewFrame();
+                SfxChildWindow* pWnd = rViewFrm.GetChildWindow(nId);
+
+                pScMod->SetRefDialog(nId, pWnd == nullptr);
+            }
+            break;
+
         case SID_SELECT_DB:
             {
                 if ( pReqArgs )
@@ -1320,6 +1330,62 @@ void ScCellShell::GetDBState( SfxItemSet& rSet )
                     }
                 }
                 break;
+
+            case SID_INSERT_CALCTABLE:
+                {
+                    bool bDisable = false;
+                    if (!rDoc.HasTableStyles() || pDocSh->IsDocShared())
+                        bDisable = true;
+                    else
+                    {
+                        SCCOL nStartCol, nEndCol;
+                        SCROW nStartRow, nEndRow;
+                        SCTAB nStartTab, nEndTab;
+
+                        bool bSelected
+                            = (GetViewData().GetSimpleArea(nStartCol, 
nStartRow, nStartTab, nEndCol,
+                                nEndRow, nEndTab) == SC_MARK_SIMPLE);
+
+                        if (bSelected)
+                        {
+                            if (nStartCol == nEndCol && nStartRow == nEndRow)
+                                bSelected = false;
+                        }
+                        else
+                        {
+                            nStartCol = GetViewData().GetCurX();
+                            nStartRow = GetViewData().GetCurY();
+                            nStartTab = GetViewData().CurrentTabForData();
+                        }
+
+                        if (!bSelected)
+                        {
+                            const ScDBData* pDBData = rDoc.GetDBAtCursor(
+                                nStartCol, nStartRow, nStartTab, 
ScDBDataPortion::AREA);
+                            if (pDBData && pDBData->GetTableStyleInfo())
+                                bDisable = true;
+                        }
+                        else
+                        {
+                            std::vector<const ScDBData*> aDBData = 
rDoc.GetAllDBsInArea(
+                                nStartCol, nStartRow, nEndCol, nEndRow, 
nStartTab);
+                            for (const ScDBData* pDBData : aDBData)
+                            {
+                                if (const ScTableStyleParam* pTableStyleInfo
+                                    = pDBData->GetTableStyleInfo())
+                                {
+                                    bDisable = true;
+                                    break;
+                                }
+                            }
+                        }
+                    }
+
+                    if (bDisable)
+                        rSet.DisableItem( nWhich );
+                }
+                break;
+
             case SID_DATA_PROVIDER:
             break;
             case SID_DATA_PROVIDER_REFRESH:
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index 14cc7a545467..61d1c3c65a74 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -703,6 +703,22 @@ void ScDBFunc::DoTableSubTotals( const ScDBData& rNewData, 
const ScSubTotalParam
     SelectionChanged();
 }
 
+void ScDBFunc::DeleteCalcTable()
+{
+    ScDocShell* pDocSh = GetViewData().GetDocShell();
+    ScDocument& rDoc = pDocSh->GetDocument();
+    ScDBData* pDBObj = rDoc.GetDBAtCursor(GetViewData().GetCurX(), 
GetViewData().GetCurY(),
+                                          GetViewData().CurrentTabForData(), 
ScDBDataPortion::AREA);
+    if (pDBObj && pDBObj->GetTableStyleInfo())
+    {
+        ScDBDocFunc aFunc(*pDocSh);
+        aFunc.DeleteDBTable(pDBObj, true, false);
+        CursorPosChanged(); // shells may be switched
+    }
+    else
+        ErrorMessage(STR_TABLE_NOTFOUND);
+}
+
 // consolidate
 
 void ScDBFunc::Consolidate( const ScConsolidateParam& rParam )
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 2447a31c47be..5f3aec99b695 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -2507,7 +2507,7 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt 
)
                 // add/replace total row
                 aSubTotalParam.bRemoveOnly = false;
                 aSubTotalParam.bReplace = true;
-                aFunc.DoTableSubTotals(aNewDBData.GetTab(), aNewDBData, 
aSubTotalParam, true, true);
+                aFunc.DoTableSubTotals(aNewDBData.GetTab(), aNewDBData, 
aSubTotalParam, true, false);
             }
             else
             {
diff --git a/sc/source/ui/view/reffact.cxx b/sc/source/ui/view/reffact.cxx
index bf08a5d2fe4c..a4ab9cdeb715 100644
--- a/sc/source/ui/view/reffact.cxx
+++ b/sc/source/ui/view/reffact.cxx
@@ -49,6 +49,7 @@ 
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScAcceptChgDlgWrapper, FID_CHG_ACCEPT)
 SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScHighlightChgDlgWrapper, FID_CHG_SHOW)
 SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScSimpleRefDlgWrapper, WID_SIMPLE_REF)
 SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScCondFormatDlgWrapper, 
WID_CONDFRMT_REF)
+SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScTableLayoutWrapper, 
SID_INSERT_CALCTABLE)
 
 SFX_IMPL_CHILDWINDOW_WITHID(ScValidityRefChildWin, SID_VALIDITY_REFERENCE)
 
@@ -115,6 +116,7 @@ IMPL_CONTROLLER_CHILD_CTOR( ScPrintAreasDlgWrapper, 
SID_OPENDLG_EDIT_PRINTAREA )
 
 IMPL_CONTROLLER_CHILD_CTOR( ScFormulaDlgWrapper, SID_OPENDLG_FUNCTION )
 
+IMPL_CONTROLLER_CHILD_CTOR( ScTableLayoutWrapper, SID_INSERT_CALCTABLE )
 
 // ScSimpleRefDlgWrapper
 
diff --git a/sc/source/ui/view/tableshell.cxx b/sc/source/ui/view/tableshell.cxx
index 6fc243bda319..0ec68d7b909d 100644
--- a/sc/source/ui/view/tableshell.cxx
+++ b/sc/source/ui/view/tableshell.cxx
@@ -109,7 +109,7 @@ void ScTableShell::ExecuteDatabaseSettings(SfxRequest& rReq)
                             aSubTotalParam.bRemoveOnly = true;
                             aSubTotalParam.bReplace = true;
                             aFunc.DoTableSubTotals(aNewDBData.GetTab(), 
aNewDBData, aSubTotalParam,
-                                                   true, true);
+                                                   true, false);
                         }
                         else
                         {
@@ -117,7 +117,7 @@ void ScTableShell::ExecuteDatabaseSettings(SfxRequest& rReq)
                             aSubTotalParam.bRemoveOnly = false;
                             aSubTotalParam.bReplace = false;
                             aFunc.DoTableSubTotals(aNewDBData.GetTab(), 
aNewDBData, aSubTotalParam,
-                                                   true, true);
+                                                   true, false);
                         }
                     }
                     else
@@ -126,8 +126,13 @@ void ScTableShell::ExecuteDatabaseSettings(SfxRequest& 
rReq)
                     }
                 }
             }
-            break;
         }
+        break;
+        case SID_REMOVE_CALCTABLE:
+        {
+            m_pViewShell->DeleteCalcTable();
+        }
+        break;
     }
 
     rBindings.Invalidate(SID_DATABASE_SETTINGS);
@@ -142,6 +147,7 @@ void ScTableShell::GetDatabaseSettings(SfxItemSet& rSet)
         switch (nWhich)
         {
             case SCITEM_DATABASE_SETTING:
+            {
                 const ScDBData* pDBData = GetDBDataAtCursor();
                 if (pDBData)
                 {
@@ -160,6 +166,9 @@ void ScTableShell::GetDatabaseSettings(SfxItemSet& rSet)
                                                        
pDBData->HasAutoFilter(), u""_ustr));
                     }
                 }
+            }
+            break;
+            case SID_REMOVE_CALCTABLE:
                 break;
         }
         nWhich = aIter.NextWhich();
diff --git a/sc/source/ui/view/tabvwsh.cxx b/sc/source/ui/view/tabvwsh.cxx
index f64b960485a1..d7f42c1353c5 100644
--- a/sc/source/ui/view/tabvwsh.cxx
+++ b/sc/source/ui/view/tabvwsh.cxx
@@ -82,6 +82,7 @@ void ScTabViewShell::InitInterface_Impl()
     
GetStaticInterface()->RegisterChildWindow(ScValidityRefChildWin::GetChildWindowId());
     
GetStaticInterface()->RegisterChildWindow(sc::SearchResultsDlgWrapper::GetChildWindowId());
     
GetStaticInterface()->RegisterChildWindow(sc::ConditionalFormatEasyDialogWrapper::GetChildWindowId());
+    
GetStaticInterface()->RegisterChildWindow(ScTableLayoutWrapper::GetChildWindowId());
 
     
GetStaticInterface()->RegisterChildWindow(ScRandomNumberGeneratorDialogWrapper::GetChildWindowId());
     
GetStaticInterface()->RegisterChildWindow(ScSamplingDialogWrapper::GetChildWindowId());
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index 3a9d5cae1c4a..c106b43621bd 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -39,6 +39,7 @@
 #include <consdlg.hxx>
 #include <filtdlg.hxx>
 #include <dbnamdlg.hxx>
+#include <dbtabledlg.hxx>
 #include <areasdlg.hxx>
 #include <crnrdlg.hxx>
 #include <formula.hxx>
@@ -264,6 +265,16 @@ std::shared_ptr<SfxModelessDialogController> 
ScTabViewShell::CreateRefDialogCont
             xResult = std::make_shared<ScDbNameDlg>(pB, pCW, pParent, 
GetViewData());
             break;
         }
+        case SID_INSERT_CALCTABLE:
+        {
+            GetDBData(true, SC_DB_OLD);
+            const ScMarkData& rMark = GetViewData().GetMarkData();
+            if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
+                MarkDataArea( false );
+
+            xResult = std::make_shared<ScDbTableDlg>(pB, pCW, pParent, 
GetViewData());
+            break;
+        }
         case SID_OPENDLG_EDIT_PRINTAREA:
             xResult = std::make_shared<ScPrintAreasDlg>(pB, pCW, pParent);
             break;
diff --git a/sc/uiconfig/scalc/menubar/menubar.xml 
b/sc/uiconfig/scalc/menubar/menubar.xml
index 6a726f1f4e71..a21d962f4c63 100644
--- a/sc/uiconfig/scalc/menubar/menubar.xml
+++ b/sc/uiconfig/scalc/menubar/menubar.xml
@@ -210,6 +210,7 @@
       <menu:menuitem menu:id=".uno:InsertObjectChart"/>
       <menu:menuitem menu:id=".uno:InsertSparkline"/>
       <menu:menuitem menu:id=".uno:DataDataPilotRun"/>
+      <menu:menuitem menu:id=".uno:InsertCalcTable"/>
       <menu:menu menu:id=".uno:GraphicMenu">
         <menu:menupopup>
           <menu:menuitem menu:id=".uno:Gallery"/>
@@ -617,6 +618,7 @@
           <menu:menuitem menu:id=".uno:DeletePivotTable"/>
         </menu:menupopup>
       </menu:menu>
+      <menu:menu menu:id=".uno:DataTableMenu"/>
       <menu:menuseparator/>
       <menu:menu menu:id=".uno:CellContentsMenu">
         <menu:menupopup>
diff --git a/sc/uiconfig/scalc/popupmenu/datatablemenu.xml 
b/sc/uiconfig/scalc/popupmenu/datatablemenu.xml
new file mode 100644
index 000000000000..57588b509145
--- /dev/null
+++ b/sc/uiconfig/scalc/popupmenu/datatablemenu.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+-->
+<menu:menupopup xmlns:menu="http://openoffice.org/2001/menu";>
+  <menu:menuitem menu:id=".uno:RunInsCalcTable"/>
+  <menu:menuitem menu:id=".uno:RemoveCalcTable"/>
+</menu:menupopup>
diff --git a/sc/uiconfig/scalc/ui/definetablerangedialog.ui 
b/sc/uiconfig/scalc/ui/definetablerangedialog.ui
new file mode 100644
index 000000000000..a6fc22254987
--- /dev/null
+++ b/sc/uiconfig/scalc/ui/definetablerangedialog.ui
@@ -0,0 +1,207 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.38.2 -->
+<interface domain="sc">
+  <requires lib="gtk+" version="3.20"/>
+  <object class="GtkDialog" id="tablerangedialog">
+    <property name="can-focus">False</property>
+    <property name="hexpand">True</property>
+    <property name="vexpand">True</property>
+    <property name="border-width">6</property>
+    <property name="title" translatable="yes" 
context="definetablerangedialog|DefineTableRangeDialog">Create Table</property>
+    <property name="default-width">0</property>
+    <property name="default-height">0</property>
+    <property name="type-hint">dialog</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="dialog-vbox1">
+        <property name="can-focus">False</property>
+        <property name="hexpand">True</property>
+        <property name="vexpand">True</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">12</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="dialog-action_area1">
+            <property name="can-focus">False</property>
+            <property name="halign">center</property>
+            <property name="layout-style">end</property>
+            <child>
+              <object class="GtkButton" id="ok">
+                <property name="label" translatable="yes" 
context="stock">_OK</property>
+                <property name="visible">True</property>
+                <property name="can-focus">True</property>
+                <property name="can-default">True</property>
+                <property name="has-default">True</property>
+                <property name="receives-default">True</property>
+                <property name="use-underline">True</property>
+                <child internal-child="accessible">
+                  <object class="AtkObject" id="ok-atkobject">
+                    <property name="AtkObject::accessible-description" 
translatable="yes" context="definedatabaserangedialog|extended_tip|ok">Saves 
all changes and closes dialog.</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="cancel">
+                <property name="label" translatable="yes" 
context="stock">_Cancel</property>
+                <property name="visible">True</property>
+                <property name="can-focus">True</property>
+                <property name="receives-default">True</property>
+                <property name="use-underline">True</property>
+                <child internal-child="accessible">
+                  <object class="AtkObject" id="cancel-atkobject">
+                    <property name="AtkObject::accessible-description" 
translatable="yes" 
context="definedatabaserangedialog|extended_tip|cancel">Closes dialog and 
discards all changes.</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack-type">end</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="box1">
+            <property name="visible">True</property>
+            <property name="can-focus">False</property>
+            <property name="hexpand">True</property>
+            <property name="vexpand">True</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">12</property>
+            <child>
+              <object class="GtkFrame" id="rangeframe">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <property name="hexpand">True</property>
+                <property name="label-xalign">0</property>
+                <property name="shadow-type">none</property>
+                <child>
+                  <object class="GtkBox" id="box3">
+                    <property name="visible">True</property>
+                    <property name="can-focus">False</property>
+                    <property name="margin-start">12</property>
+                    <property name="margin-top">6</property>
+                    <property name="hexpand">True</property>
+                    <property name="spacing">12</property>
+                    <child>
+                      <object class="GtkEntry" id="assign">
+                        <property name="visible">True</property>
+                        <property name="can-focus">True</property>
+                        <property name="hexpand">True</property>
+                        <property name="activates-default">True</property>
+                        <property name="truncate-multiline">True</property>
+                        <child internal-child="accessible">
+                          <object class="AtkObject" id="assign-atkobject">
+                            <property name="AtkObject::accessible-description" 
translatable="yes" 
context="definedatabaserangedialog|extended_tip|assign">Click the Shrink icon 
to reduce the dialog to the size of the input field. It is then easier to mark 
the required reference in the sheet. The icons then automatically convert to 
the Maximize icon. Click it to restore the dialog to its original 
size.</property>
+                          </object>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkButton" id="assgnrb">
+                        <property name="visible">True</property>
+                        <property name="can-focus">False</property>
+                        <property name="receives-default">True</property>
+                        <child internal-child="accessible">
+                          <object class="AtkObject" id="assgnrb-atkobject">
+                            <property name="AtkObject::accessible-description" 
translatable="yes" 
context="definedatabaserangedialog|extended_tip|assignrb">Click the Shrink icon 
to reduce the dialog to the size of the input field. It is then easier to mark 
the required reference in the sheet. The icons then automatically convert to 
the Maximize icon. Click it to restore the dialog to its original 
size.</property>
+                          </object>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+                <child type="label">
+                  <object class="GtkLabel" id="range">
+                    <property name="visible">True</property>
+                    <property name="can-focus">False</property>
+                    <property name="label" translatable="yes" 
context="definetablerangedialog|range">Range</property>
+                    <attributes>
+                      <attribute name="weight" value="bold"/>
+                    </attributes>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkBox" id="options">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <property name="margin-start">12</property>
+                <property name="hexpand">True</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">3</property>
+                <child>
+                  <object class="GtkCheckButton" id="bheaders">
+                    <property name="label" translatable="yes" 
context="definetablerangedialog|containscolumnlabels">Co_ntains column 
labels</property>
+                    <property name="visible">True</property>
+                    <property name="can-focus">True</property>
+                    <property name="receives-default">False</property>
+                    <property name="use-underline">True</property>
+                    <property name="active">True</property>
+                    <property name="draw-indicator">True</property>
+                    <child internal-child="accessible">
+                      <object class="AtkObject" id="bheaders-atkobject">
+                        <property name="AtkObject::accessible-description" 
translatable="yes" 
context="definedatabaserangedialog|extended_tip|ContainsColumnLabels">Selected 
cell ranges contain labels.</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-5">ok</action-widget>
+      <action-widget response="-6">cancel</action-widget>
+    </action-widgets>
+    <child internal-child="accessible">
+      <object class="AtkObject" id="tablerangedialog-atkobject">
+        <property name="AtkObject::accessible-description" translatable="yes" 
context="definedatabaserangedialog|extended_tip|DefineDatabaseRangeDialog">Defines
 a database range based on the selected cells in your sheet.</property>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/sc/uiconfig/scalc/ui/notebookbar.ui 
b/sc/uiconfig/scalc/ui/notebookbar.ui
index 85f1dda0a3a2..012781fb25fb 100644
--- a/sc/uiconfig/scalc/ui/notebookbar.ui
+++ b/sc/uiconfig/scalc/ui/notebookbar.ui
@@ -146,6 +146,19 @@
         <property name="action_name">.uno:DeletePivotTable</property>
       </object>
     </child>
+    <child>
+      <object class="GtkSeparatorMenuItem" id="MenuData-separator411">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkMenuItem" id="MenuData-DataTableMenu">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="action_name">.uno:DataTableMenu</property>
+      </object>
+    </child>
     <child>
       <object class="GtkSeparatorMenuItem" id="MenuData-separator4">
         <property name="visible">True</property>
diff --git a/sc/uiconfig/scalc/ui/notebookbar_compact.ui 
b/sc/uiconfig/scalc/ui/notebookbar_compact.ui
index 513679ec6ce1..ddd5b790703d 100644
--- a/sc/uiconfig/scalc/ui/notebookbar_compact.ui
+++ b/sc/uiconfig/scalc/ui/notebookbar_compact.ui
@@ -146,6 +146,19 @@
         <property name="action_name">.uno:DeletePivotTable</property>
       </object>
     </child>
+    <child>
+      <object class="GtkSeparatorMenuItem" id="separator169">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkMenuItem" id="DataTableMenu">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="action_name">.uno:DataTableMenu</property>
+      </object>
+    </child>
     <child>
       <object class="GtkSeparatorMenuItem" id="separator167">
         <property name="visible">True</property>
@@ -4715,6 +4728,31 @@
                             <property name="position">0</property>
                           </packing>
                         </child>
+                        <child>
+                          <object class="sfxlo-NotebookbarToolBox" 
id="SectionBottom38c">
+                            <property name="visible">False</property> <!-- no 
icon yet -->
+                            <property name="can_focus">False</property>
+                            <property name="valign">center</property>
+                            <property name="vexpand">True</property>
+                            <property name="toolbar_style">icons</property>
+                            <property name="show_arrow">False</property>
+                            <child>
+                              <object class="GtkToolButton" id="Insert-Table">
+                                <property name="visible">True</property>
+                                <property 
name="action_name">.uno:InsertCalcTable</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="homogeneous">True</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
                         <child>
                           <object class="sfxlo-NotebookbarToolBox" 
id="SectionBottom38">
                             <property name="visible">True</property>
@@ -4737,7 +4775,7 @@
                           <packing>
                             <property name="expand">False</property>
                             <property name="fill">True</property>
-                            <property name="position">1</property>
+                            <property name="position">2</property>
                           </packing>
                         </child>
                         <child>
@@ -4762,7 +4800,7 @@
                           <packing>
                             <property name="expand">False</property>
                             <property name="fill">True</property>
-                            <property name="position">2</property>
+                            <property name="position">3</property>
                           </packing>
                         </child>
                       </object>
diff --git a/sc/uiconfig/scalc/ui/notebookbar_groupedbar_compact.ui 
b/sc/uiconfig/scalc/ui/notebookbar_groupedbar_compact.ui
index 4e35ae8f780a..a39a8e77e2c5 100644
--- a/sc/uiconfig/scalc/ui/notebookbar_groupedbar_compact.ui
+++ b/sc/uiconfig/scalc/ui/notebookbar_groupedbar_compact.ui
@@ -2841,6 +2841,19 @@
         <property name="can_focus">False</property>
       </object>
     </child>
+    <child>
+      <object class="GtkMenuItem" id="MenuData-DataTableMenu">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="action_name">.uno:DataTableMenu</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkSeparatorMenuItem" id="MenuData-separator411">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+      </object>
+    </child>
     <child>
       <object class="GtkMenuItem" id="MenuData-FormatSparklineMenu">
         <property name="visible">True</property>
@@ -4907,6 +4920,7 @@
                       <class name="context-Pivot"/>
                       <class name="context-Sparkline"/>
                       <class name="context-Trendline"/>
+                      <class name="context-Table"/>
                     </style>
                   </object>
                   <packing>
diff --git a/sc/uiconfig/scalc/ui/notebookbar_groupedbar_full.ui 
b/sc/uiconfig/scalc/ui/notebookbar_groupedbar_full.ui
index b7e91985a525..c4ec66780ee4 100644
--- a/sc/uiconfig/scalc/ui/notebookbar_groupedbar_full.ui
+++ b/sc/uiconfig/scalc/ui/notebookbar_groupedbar_full.ui
@@ -521,6 +521,19 @@
         <property name="can_focus">False</property>
       </object>
     </child>
+    <child>
+      <object class="GtkMenuItem" id="MenuData-DataTableMenu">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="action_name">.uno:DataTableMenu</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkSeparatorMenuItem" id="MenuData-separator411">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+      </object>
+    </child>
     <child>
       <object class="GtkMenuItem" id="MenuData-FormatSparklineMenu">
         <property name="visible">True</property>
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index 36353bf7f44a..4bde66ad2d4c 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -1350,6 +1350,8 @@ const std::map<std::u16string_view, KitUnoCommand>& 
GetKitUnoCommandList()
         { u"IncrementIndent", { PayloadType::EnabledPayload, true } },
         { u"DecrementIndent", { PayloadType::EnabledPayload, true } },
         { u"EditHeaderAndFooter", { PayloadType::EnabledPayload, true } },
+        { u"InsertCalcTable", { PayloadType::EnabledPayload, true } },
+        { u"RemoveCalcTable", { PayloadType::EnabledPayload, true } },
         { u"InsertSparkline", { PayloadType::EnabledPayload, true } },
         { u"DeleteSparkline", { PayloadType::EnabledPayload, true } },
         { u"DeleteSparklineGroup", { PayloadType::EnabledPayload, true } },
diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist
index 9612018ea395..7d9dd87e7251 100644
--- a/solenv/clang-format/excludelist
+++ b/solenv/clang-format/excludelist
@@ -8639,6 +8639,7 @@ sc/source/ui/dbgui/csvtablebox.cxx
 sc/source/ui/dbgui/dapidata.cxx
 sc/source/ui/dbgui/dapitype.cxx
 sc/source/ui/dbgui/dbnamdlg.cxx
+sc/source/ui/dbgui/dbtabladlg.cxx
 sc/source/ui/dbgui/dpgroupdlg.cxx
 sc/source/ui/dbgui/filtdlg.cxx
 sc/source/ui/dbgui/foptmgr.cxx
@@ -8783,6 +8784,7 @@ sc/source/ui/inc/datatransformation.hxx
 sc/source/ui/inc/dbdocfun.hxx
 sc/source/ui/inc/dbfunc.hxx
 sc/source/ui/inc/dbnamdlg.hxx
+sc/source/ui/inc/dbtabledlg.hxx
 sc/source/ui/inc/docfunc.hxx
 sc/source/ui/inc/docfuncutil.hxx
 sc/source/ui/inc/docsh.hxx
diff --git a/solenv/sanitizers/ui/modules/scalc.false 
b/solenv/sanitizers/ui/modules/scalc.false
index 7284f732888e..b4989353284b 100644
--- a/solenv/sanitizers/ui/modules/scalc.false
+++ b/solenv/sanitizers/ui/modules/scalc.false
@@ -14,6 +14,7 @@ 
sc/uiconfig/scalc/ui/covariancedialog.ui://GtkButton[@id='input-range-button'] b
 
sc/uiconfig/scalc/ui/covariancedialog.ui://GtkButton[@id='output-range-button'] 
button-no-label
 sc/uiconfig/scalc/ui/definedatabaserangedialog.ui://GtkButton[@id='assignrb'] 
button-no-label
 sc/uiconfig/scalc/ui/definename.ui://GtkButton[@id='refbutton'] button-no-label
+sc/uiconfig/scalc/ui/definetablerangedialog.ui://GtkButton[@id='assgnrb'] 
button-no-label
 
sc/uiconfig/scalc/ui/descriptivestatisticsdialog.ui://GtkButton[@id='input-range-button']
 button-no-label
 
sc/uiconfig/scalc/ui/descriptivestatisticsdialog.ui://GtkButton[@id='output-range-button']
 button-no-label
 
sc/uiconfig/scalc/ui/exponentialsmoothingdialog.ui://GtkButton[@id='input-range-button']
 button-no-label
diff --git a/static/CustomTarget_emscripten_fs_image.mk 
b/static/CustomTarget_emscripten_fs_image.mk
index 024c82f1eabd..e164f5ed0e89 100644
--- a/static/CustomTarget_emscripten_fs_image.mk
+++ b/static/CustomTarget_emscripten_fs_image.mk
@@ -951,6 +951,7 @@ gb_emscripten_fs_image_files += \
     
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/modules/scalc/ui/datetimetransformationentry.ui
 \
     
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/modules/scalc/ui/definedatabaserangedialog.ui
 \
     
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/modules/scalc/ui/definename.ui
 \
+    
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/modules/scalc/ui/definetablerangedialog.ui
 \
     
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/modules/scalc/ui/deletecells.ui
 \
     
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/modules/scalc/ui/deletecolumnentry.ui
 \
     
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/modules/scalc/ui/deletecontents.ui
 \
diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx
index 565e309fe8ec..856470d462ec 100644
--- a/vcl/jsdialog/enabled.cxx
+++ b/vcl/jsdialog/enabled.cxx
@@ -207,6 +207,7 @@ constexpr auto ScalcDialogList
         { u"modules/scalc/ui/definedatabaserangedialog.ui" },
         { u"modules/scalc/ui/selectrange.ui" },
         { u"modules/scalc/ui/selectsheetviewdialog.ui" },
+        { u"modules/scalc/ui/definetablerangedialog.ui" },
     });
 
 constexpr auto SwriterDialogList

Reply via email to