diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
index 7d3e943b92a3..b967140a304a 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
@@ -1164,6 +1164,47 @@
1
+
+
+ ~Table
+
+
+ 1
+
+
+
+
+ ~Insert Table...
+
+
+ .uno:InsertCalcTable
+
+
+ 1
+
+
+
+
+ Table...
+
+
+ Insert Table
+
+
+ 1
+
+
+
+
+ ~Remove Table...
+
+
+ Delete Table
+
+
+ 1
+
+
Sparkline...
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
index 4a25165d8f94..750c20be3e6f 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 @@
recordtrackedchanges
+
+
+ .uno:DataTableMenu
+
+
+
+
+
+ com.sun.star.comp.framework.ResourceMenuController
+
+
+ datatablemenu
+
+
.uno:WindowList
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 0ae9ceff975b..b7cdaedbf717 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -429,6 +429,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 7a4a49b63c48..e3352482f77c 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 \
@@ -124,6 +125,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 90344eb25866..dae33cacc6bc 100644
--- a/sc/inc/dbdata.hxx
+++ b/sc/inc/dbdata.hxx
@@ -372,6 +372,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 1b5bdf73c84b..1985b58e6b36 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -899,6 +899,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 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 ccf112e1e144..f386f4220adb 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", "\n\nInsert the result into the variable cell?")
#define STR_MSSG_SOLVE_2 NC_("STR_MSSG_SOLVE_2", "Goal Seek failed.\n\n")
@@ -188,6 +192,8 @@
#define STR_INVALIDTABNAME NC_("STR_INVALIDTABNAME", "Invalid sheet name.\n\nThe sheet name must not:\n• be empty\n• already exist\n• contain [ ] * ? : / \\ \n• 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 87bdc3bd96e0..9dc545881550 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -639,6 +639,8 @@ static_assert(SID_PREVIEW_END < SID_KEYFUNC_START, "calc slots ids trampling inf
#define SID_SC_OPT_LINKS TypedWhichId(SID_NEW_SLOTS + 117)
#define SID_CLEAR_AUTO_FILTER (SID_NEW_SLOTS+118)
#define SID_DATABASE_SETTINGS (SID_NEW_SLOTS+119)
+#define SID_INSERT_CALCTABLE (SID_NEW_SLOTS+120)
+#define SID_REMOVE_CALCTABLE (SID_NEW_SLOTS+121)
// idl parameter
diff --git a/sc/sdi/cellsh.sdi b/sc/sdi/cellsh.sdi
index 0f16536d1c42..f038689890a3 100644
--- a/sc/sdi/cellsh.sdi
+++ b/sc/sdi/cellsh.sdi
@@ -64,6 +64,7 @@ interface CellSelection
FID_CURRENTVALIDATION [ ExecMethod = ExecuteDB; StateMethod = GetBlockState; ]
SID_TEXT_TO_COLUMNS [ ExecMethod = ExecuteDB; StateMethod = GetDBState; ]
SID_CLEAR_AUTO_FILTER [ 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 281ea24aab09..328c2468681c 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 c8787afc83ad..d72c3ab60000 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 3573e4b83888..485aadb47c1e 100644
--- a/sc/sdi/scalc.sdi
+++ b/sc/sdi/scalc.sdi
@@ -6476,6 +6476,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 98c4531e9c08..c470eb227710 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -357,6 +357,15 @@ ScDBData* ScDocument::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nC
return nullptr;
}
+std::vector 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();
+}
+
void ScDocument::RefreshDirtyTableColumnNames()
{
if (pDBCollection)
diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx
index 5da39755b8d5..4bd5f50ecb35 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/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 b088c9292790..686c46042a4e 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..905c4f06cfe1
--- /dev/null
+++ b/sc/source/ui/dbgui/dbtabledlg.cxx
@@ -0,0 +1,222 @@
+/* -*- 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
+#include
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+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_xEdAssign->SetReferences(this, m_xAssignFrame.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(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 aDBData = rDoc.GetAllDBsInArea(
+ theCurArea.aStart.Col(), theCurArea.aStart.Row(), theCurArea.aEnd.Col(),
+ theCurArea.aEnd.Row(), theCurArea.aStart.Tab());
+
+ for (const ScDBData* pDBData : aDBData)
+ {
+ if (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 c570d0d60307..9aa821ac9b26 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 pUndoColl;
+ if (bRecord)
+ pUndoColl.reset(new ScDBCollection(*pDocColl));
+
+ std::unique_ptr 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(rDocShell, rName, true/*bInsert*/, std::move(pUndoColl),
+ std::make_unique(*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 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(rDocShell, aTableName, false/*bInsert*/, std::move(pUndoColl),
+ std::make_unique(*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 d315066ecdf3..80a833bc2ddc 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 );
+
SC_DLLPUBLIC 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 be89cab22f23..8fc61982788b 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();
void ClearAutoFilter();
diff --git a/sc/source/ui/inc/dbtabledlg.hxx b/sc/source/ui/inc/dbtabledlg.hxx
new file mode 100644
index 000000000000..c3a8cc5f191b
--- /dev/null
+++ b/sc/source/ui/inc/dbtabledlg.hxx
@@ -0,0 +1,71 @@
+/* -*- 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
+#include "anyrefdg.hxx"
+#include
+
+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 m_xAssignFrame;
+ std::unique_ptr m_xEdAssign;
+ std::unique_ptr m_xRbAssign;
+
+ std::unique_ptr m_xOptions;
+ std::unique_ptr m_xBtnHeader;
+
+ std::unique_ptr m_xBtnOk;
+ std::unique_ptr m_xBtnCancel;
+
+ std::shared_ptr 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
diff --git a/sc/source/ui/inc/undodat.hxx b/sc/source/ui/inc/undodat.hxx
index bd3fab0679ea..3475cb640c52 100644
--- a/sc/source/ui/inc/undodat.hxx
+++ b/sc/source/ui/inc/undodat.hxx
@@ -205,6 +205,30 @@ private:
std::unique_ptr xUndoDB;
};
+class ScUndoDBTable : public ScSimpleUndo
+{
+public:
+ ScUndoDBTable(ScDocShell& rNewDocShell, const OUString& rNewTable, bool bIns,
+ std::unique_ptr pNewUndoColl,
+ std::unique_ptr 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 pUndoColl;
+ std::unique_ptr 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 5fa63de4ede8..bd283fe8a000 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& rNewDocShell, const OUString& rNewTable, bool bIns,
+ std::unique_ptr pNewUndoColl,
+ std::unique_ptr pNewRedoColl ) :
+ ScSimpleUndo( rNewDocShell ),
+ 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 = rDocShell.GetDocument();
+ bool bOldAutoCalc = rDoc.GetAutoCalc();
+ rDoc.SetAutoCalc(false); // Avoid unnecessary calculations
+ rDoc.PreprocessDBDataUpdate();
+ rDoc.SetDBCollection(std::unique_ptr(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);
+
+ rDocShell.PostPaint(ScRange(0, 0, nTab, rDoc.MaxCol(), rDoc.MaxRow(), nTab),
+ PaintPartFlags::Grid | PaintPartFlags::Left | PaintPartFlags::Top
+ | PaintPartFlags::Size);
+ }
+ }
+}
+
ScUndoTableTotals::ScUndoTableTotals(ScDocShell& rNewDocShell, 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 63ee51ccc376..866f6c0ec7b8 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -763,6 +763,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 )
@@ -1380,6 +1390,61 @@ 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 aDBData = rDoc.GetAllDBsInArea(
+ nStartCol, nStartRow, nEndCol, nEndRow, nStartTab);
+ for (const ScDBData* pDBData : aDBData)
+ {
+ if (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 3082ae7ee139..77ee2b7ae27c 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -702,6 +702,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 02b5bbe0cdef..a6373cb356d7 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -2524,7 +2524,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 e0d59484182e..9136d93b218c 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 2f99da74cfaf..73b95a26b0ba 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -39,6 +39,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -260,6 +261,16 @@ std::shared_ptr ScTabViewShell::CreateRefDialogCont
xResult = std::make_shared(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(pB, pCW, pParent, GetViewData());
+ break;
+ }
case SID_OPENDLG_EDIT_PRINTAREA:
xResult = std::make_shared(pB, pCW, pParent, GetViewData());
break;
diff --git a/sc/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml
index 97b9a8b1ad43..05da857006d1 100644
--- a/sc/uiconfig/scalc/menubar/menubar.xml
+++ b/sc/uiconfig/scalc/menubar/menubar.xml
@@ -210,6 +210,7 @@
+
@@ -619,6 +620,7 @@
+
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 @@
+
+
+
+
+
+
diff --git a/sc/uiconfig/scalc/ui/definetablerangedialog.ui b/sc/uiconfig/scalc/ui/definetablerangedialog.ui
new file mode 100644
index 000000000000..093bade14ffd
--- /dev/null
+++ b/sc/uiconfig/scalc/ui/definetablerangedialog.ui
@@ -0,0 +1,207 @@
+
+
+
+
+
+
diff --git a/sc/uiconfig/scalc/ui/notebookbar.ui b/sc/uiconfig/scalc/ui/notebookbar.ui
index 0f232c03363e..9f9145fa19da 100644
--- a/sc/uiconfig/scalc/ui/notebookbar.ui
+++ b/sc/uiconfig/scalc/ui/notebookbar.ui
@@ -146,6 +146,19 @@
.uno:DeletePivotTable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ False
+ False
+ center
+ True
+ icons
+ False
+
+
+ True
+ .uno:InsertCalcTable
+
+
+ False
+ True
+
+
+
+
+ False
+ True
+ 1
+
+
True
@@ -4737,7 +4775,7 @@
False
True
- 1
+ 2
@@ -4763,7 +4801,7 @@
False
True
- 2
+ 3
diff --git a/sc/uiconfig/scalc/ui/notebookbar_groupedbar_compact.ui b/sc/uiconfig/scalc/ui/notebookbar_groupedbar_compact.ui
index 7dd91a8a6b5e..aaf38f90eb2a 100644
--- a/sc/uiconfig/scalc/ui/notebookbar_groupedbar_compact.ui
+++ b/sc/uiconfig/scalc/ui/notebookbar_groupedbar_compact.ui
@@ -2841,6 +2841,19 @@
False
+
+
+
+
+
+
diff --git a/sc/uiconfig/scalc/ui/notebookbar_groupedbar_full.ui b/sc/uiconfig/scalc/ui/notebookbar_groupedbar_full.ui
index 66cbcdb21630..8c3354c9c7f8 100644
--- a/sc/uiconfig/scalc/ui/notebookbar_groupedbar_full.ui
+++ b/sc/uiconfig/scalc/ui/notebookbar_groupedbar_full.ui
@@ -521,6 +521,19 @@
False
+
+
+
+
+
+