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 | 164 +++++-- 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 | 222 ++++++++++ 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 | 71 +++ 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/tabview3.cxx | 1 sc/source/ui/view/tabvwsh.cxx | 1 sc/source/ui/view/tabvwsh4.cxx | 2 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 47 files changed, 1214 insertions(+), 47 deletions(-)
New commits: commit f36a5e3f17d451cc498efd7ee783d6bbd2f579a2 Author: Balazs Varga <[email protected]> AuthorDate: Wed Nov 26 08:55:38 2025 +0100 Commit: Balazs Varga <[email protected]> CommitDate: Wed Jan 7 17:17:22 2026 +0100 Table Styles: fix wrongly handled ScDatabaseSettingItem::QueryValue and ScDatabaseSettingItem::PutValue functions after commit: f1fcfc86d0b85ca2f01b0ee908226c2689bf1f27 (add sidebar entry for calc database ranges) Also do not force table shell update when we move between tables, only notify if the database settings are changed. Change-Id: I6b2fb8b3c9a05f2d1328d14bb79ed46595e5b0cb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194546 Reviewed-by: Balazs Varga <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196769 Tested-by: Balazs Varga <[email protected]> diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx index 4bd5f50ecb35..978a15e930d6 100644 --- a/sc/source/core/tool/dbdata.cxx +++ b/sc/source/core/tool/dbdata.cxx @@ -32,20 +32,25 @@ #include <document.hxx> #include <queryparam.hxx> #include <queryentry.hxx> +#include <mid.h> #include <globstr.hrc> #include <scresid.hxx> #include <subtotalparam.hxx> #include <sortparam.hxx> #include <dociter.hxx> #include <brdcst.hxx> +#include <osl/diagnose.h> #include <comphelper/stl_types.hxx> +#include <comphelper/propertyvalue.hxx> #include <memory> #include <utility> using namespace com::sun::star; +constexpr int DBSETTING_PARAMS = 8; + ScDatabaseSettingItem::ScDatabaseSettingItem(): SfxPoolItem(SCITEM_DATABASE_SETTING), mbHeaderRow(false), @@ -93,80 +98,168 @@ ScDatabaseSettingItem::~ScDatabaseSettingItem() bool ScDatabaseSettingItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId ) const { + nMemberId &= ~CONVERT_TWIPS; switch (nMemberId) { case 0: + { + css::uno::Sequence<css::beans::PropertyValue> aSeq{ + comphelper::makePropertyValue(u"ContainsHeader"_ustr, mbHeaderRow), + comphelper::makePropertyValue(u"TotalsRow"_ustr, mbTotalRow), + comphelper::makePropertyValue(u"UseFirstColumnFormatting"_ustr, mbFirstCol), + comphelper::makePropertyValue(u"UseLastColumnFormatting"_ustr, mbLastCol), + comphelper::makePropertyValue(u"UseRowStripes"_ustr, mbStripedRows), + comphelper::makePropertyValue(u"UseColStripes"_ustr, mbStripedCols), + comphelper::makePropertyValue(u"AutoFilter"_ustr, mbShowFilters), + comphelper::makePropertyValue(u"TableStyleName"_ustr, maStyleID) + }; + assert(aSeq.getLength() == DBSETTING_PARAMS); + rVal <<= aSeq; + break; + } + case MID_1: rVal <<= mbHeaderRow; break; - case 1: + case MID_2: rVal <<= mbTotalRow; break; - case 2: + case MID_3: rVal <<= mbFirstCol; break; - case 3: + case MID_4: rVal <<= mbLastCol; break; - case 4: + case MID_5: rVal <<= mbStripedRows; break; - case 5: + case MID_6: rVal <<= mbStripedCols; break; - case 6: + case MID_7: rVal <<= mbShowFilters; break; - case 7: + case MID_8: rVal <<= maStyleID; break; default: + OSL_FAIL("Wrong MemberID!"); return false; } return true; } -bool ScDatabaseSettingItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId ) +bool ScDatabaseSettingItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId) { bool bVal = false; bool bRet = false; - OUString aStyleID; - if (nMemberId == 7) - bRet = (rVal >>= aStyleID); - else - bRet = (rVal >>= bVal); - - if(!bRet) - return false; - + nMemberId &= ~CONVERT_TWIPS; switch (nMemberId) { case 0: - mbHeaderRow = bVal; - break; - case 1: - mbTotalRow = bVal; + { + css::uno::Sequence<css::beans::PropertyValue> aSeq; + if ((rVal >>= aSeq) && (aSeq.getLength() == DBSETTING_PARAMS)) + { + OUString sTmpID; + bool bTmpHRow(false); + bool bTmpTRow(false); + bool bTmpFCol(false); + bool bTmpLCol(false); + bool bTmpSRows(false); + bool bTmpSCols(false); + bool bTmpFilt(false); + + bool bAllConverted(true); + sal_Int16 nConvertedCount(0); + for (const auto& rProp : aSeq) + { + if (rProp.Name == u"ContainsHeader") + { + bAllConverted &= (rProp.Value >>= bTmpHRow); + ++nConvertedCount; + } + else if (rProp.Name == u"TotalsRow") + { + bAllConverted &= (rProp.Value >>= bTmpTRow); + ++nConvertedCount; + } + else if (rProp.Name == u"UseFirstColumnFormatting") + { + bAllConverted &= (rProp.Value >>= bTmpFCol); + ++nConvertedCount; + } + else if (rProp.Name == u"UseLastColumnFormatting") + { + bAllConverted &= (rProp.Value >>= bTmpLCol); + ++nConvertedCount; + } + else if (rProp.Name == u"UseRowStripes") + { + bAllConverted &= (rProp.Value >>= bTmpSRows); + ++nConvertedCount; + } + else if (rProp.Name == u"UseColStripes") + { + bAllConverted &= (rProp.Value >>= bTmpSCols); + ++nConvertedCount; + } + else if (rProp.Name == u"AutoFilter") + { + bAllConverted &= (rProp.Value >>= bTmpFilt); + ++nConvertedCount; + } + else if (rProp.Name == u"TableStyleName") + { + bAllConverted &= (rProp.Value >>= sTmpID); + ++nConvertedCount; + } + } + + if (bAllConverted && nConvertedCount == DBSETTING_PARAMS) + { + mbHeaderRow = bTmpHRow; + mbTotalRow = bTmpTRow; + mbFirstCol = bTmpFCol; + mbLastCol = bTmpLCol; + mbStripedRows = bTmpSRows; + mbStripedCols = bTmpSCols; + mbShowFilters = bTmpFilt; + maStyleID = sTmpID; + return true; + } + } + return false; + } + case MID_1: + bRet = (rVal >>= bVal); if (bRet) mbHeaderRow=bVal; break; break; - case 2: - mbFirstCol = bVal; + case MID_2: + bRet = (rVal >>= bVal); if (bRet) mbTotalRow=bVal; break; break; - case 3: - mbLastCol = bVal; + case MID_3: + bRet = (rVal >>= bVal); if (bRet) mbFirstCol=bVal; break; break; - case 4: - mbStripedRows = bVal; + case MID_4: + bRet = (rVal >>= bVal); if (bRet) mbLastCol=bVal; break; break; - case 5: - mbStripedCols = bVal; + case MID_5: + bRet = (rVal >>= bVal); if (bRet) mbStripedRows=bVal; break; break; - case 6: - mbShowFilters = bVal; + case MID_6: + bRet = (rVal >>= bVal); if (bRet) mbStripedCols=bVal; break; break; - case 7: - maStyleID = std::move(aStyleID); + case MID_7: + bRet = (rVal >>= bVal); if (bRet) mbShowFilters=bVal; break; break; + case MID_8: + { + OUString aVal; + bRet = (rVal >>= aVal); if (bRet) maStyleID = std::move(aVal); break; + } default: + OSL_FAIL("Wrong MemberID!"); return false; } diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx index d5bbdb0576c6..c061505fdec7 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -318,6 +318,7 @@ void ScTabView::InvalidateAttribs() rBindings.Invalidate( SID_ATTR_BORDER_DIAG_TLBR ); rBindings.Invalidate( SID_ATTR_BORDER_DIAG_BLTR ); rBindings.Invalidate( SID_NUMBER_TYPE_FORMAT ); + rBindings.Invalidate( SID_DATABASE_SETTINGS ); } rBindings.Invalidate( SID_BACKGROUND_COLOR ); diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index bffa6e1dcb71..dfdb9cd95e64 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -731,7 +731,7 @@ void ScTabViewShell::SetTableShell(bool bActive) bActiveMediaSh=false; bActiveOleObjectSh=false; bActiveChartSh=false; - SetCurSubShell(OST_Table, true); + SetCurSubShell(OST_Table); } else SetCurSubShell(OST_Cell); commit e4a719d2f82e308f1d7b1f87df166de85acc71b8 Author: Balazs Varga <[email protected]> AuthorDate: Sun Nov 23 19:42:11 2025 +0100 Commit: Balazs Varga <[email protected]> CommitDate: Wed Jan 7 17:17:12 2026 +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]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196768 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 @@ <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 c358d6666a30..c11de24276a0 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 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 a100c9345b72..63edbe5517d3 100644 --- a/sc/inc/dbdata.hxx +++ b/sc/inc/dbdata.hxx @@ -371,6 +371,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<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 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", " 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 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<SfxBoolItem>(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 dc13528984e0..6ba67aca132e 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 d3b03dfef575..af172baadf60 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<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 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/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 98b208d822ac..1a03834aab79 100644 --- a/sc/source/ui/app/scdll.cxx +++ b/sc/source/ui/app/scdll.cxx @@ -202,6 +202,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 7c23f950140b..8db1b94eea41 100644 --- a/sc/source/ui/dbgui/dbnamdlg.cxx +++ b/sc/source/ui/dbgui/dbnamdlg.cxx @@ -353,9 +353,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 @@ -590,7 +599,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..76ac9a624f10 --- /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 <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_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<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 fb657667c4fa..c975f41510a3 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 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 <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::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 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<ScDBCollection> xUndoDB; }; +class ScUndoDBTable : public ScSimpleUndo +{ +public: + ScUndoDBTable(ScDocShell& rNewDocShell, 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 50dbf18dca52..d78e530f4300 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<ScDBCollection> pNewUndoColl, + std::unique_ptr<ScDBCollection> 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<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); + + 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..1d346ec357e0 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,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 adbeb64d4d70..48ba0694506d 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 72e626f326aa..1e6b7fd4a17a 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -2509,7 +2509,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 <consdlg.hxx> #include <filtdlg.hxx> #include <dbnamdlg.hxx> +#include <dbtabledlg.hxx> #include <areasdlg.hxx> #include <crnrdlg.hxx> #include <formula.hxx> @@ -260,6 +261,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, GetViewData()); break; diff --git a/sc/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml index 38f17e20d33b..a5e8ae6515ae 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"/> @@ -619,6 +620,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..7f154b489c77 --- /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.24"/> + <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 0f232c03363e..9f9145fa19da 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 cc25e67776a2..a68cf18b9032 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> @@ -4763,7 +4801,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 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 @@ <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 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 @@ <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 ec456a103d58..99eeb924c931 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -1351,6 +1351,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 3b62dcaed9af..413bce1d64df 100644 --- a/solenv/clang-format/excludelist +++ b/solenv/clang-format/excludelist @@ -8483,6 +8483,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 @@ -8626,6 +8627,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 2fca3b748f1b..f1f5323eec4e 100644 --- a/static/CustomTarget_emscripten_fs_image.mk +++ b/static/CustomTarget_emscripten_fs_image.mk @@ -1248,6 +1248,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 d5052c3fbd9d..c0a83a9cc371 100644 --- a/vcl/jsdialog/enabled.cxx +++ b/vcl/jsdialog/enabled.cxx @@ -206,6 +206,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
