sc/inc/sc.hrc | 1 + sc/inc/tablestyle.hxx | 4 +++- sc/sdi/docsh.sdi | 1 + sc/sdi/scalc.sdi | 18 ++++++++++++++++++ sc/source/core/data/documen2.cxx | 2 +- sc/source/core/data/tablestyle.cxx | 18 ++++++++++++++++-- sc/source/ui/docshell/docsh4.cxx | 15 +++++++++++++++ sc/source/ui/view/tabvwsh4.cxx | 1 + sfx2/source/control/unoctitm.cxx | 1 + 9 files changed, 57 insertions(+), 4 deletions(-)
New commits: commit 926b024472b81f4c5dbd4922b1b33e18cde85a3d Author: Szymon Kłos <[email protected]> AuthorDate: Tue Feb 24 17:41:00 2026 +0000 Commit: Szymon Kłos <[email protected]> CommitDate: Thu Mar 5 07:15:41 2026 +0100 Table Styles: lok: send notifications on update - uno slots have already infrastructure for sending on load and invalidation Change-Id: I68011a7df15a6570a00630db8ce6333bf52d1aec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200437 Reviewed-by: Szymon Kłos <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc index 5f86b6cda7fb..0582a5e002a0 100644 --- a/sc/inc/sc.hrc +++ b/sc/inc/sc.hrc @@ -641,6 +641,7 @@ static_assert(SID_PREVIEW_END < SID_KEYFUNC_START, "calc slots ids trampling inf #define SID_DATABASE_SETTINGS (SID_NEW_SLOTS+119) #define SID_INSERT_CALCTABLE (SID_NEW_SLOTS+120) #define SID_REMOVE_CALCTABLE (SID_NEW_SLOTS+121) +#define SID_TABLE_STYLES (SID_NEW_SLOTS+122) // idl parameter diff --git a/sc/inc/tablestyle.hxx b/sc/inc/tablestyle.hxx index 2397124af9eb..c34539338557 100644 --- a/sc/inc/tablestyle.hxx +++ b/sc/inc/tablestyle.hxx @@ -113,6 +113,8 @@ public: class SC_DLLPUBLIC ScTableStyles { + SfxBindings* mpBindings; + private: ScTableStyles(ScTableStyles const&) = delete; ScTableStyles(ScTableStyles&&) = delete; @@ -122,7 +124,7 @@ private: std::unordered_map<OUString, std::unique_ptr<ScTableStyle>> maTableStyles; public: - ScTableStyles(); + ScTableStyles(SfxBindings* pBindings); void AddTableStyle(std::unique_ptr<ScTableStyle> pTableStyle); void DeleteTableStyle(const OUString& rName); diff --git a/sc/sdi/docsh.sdi b/sc/sdi/docsh.sdi index 0bc3c26e9fc1..d638fdee6fc3 100644 --- a/sc/sdi/docsh.sdi +++ b/sc/sdi/docsh.sdi @@ -54,6 +54,7 @@ interface TableDocument SID_SBA_IMPORT [ ExecMethod = Execute; StateMethod = GetState; ] SID_SC_SETTEXT [ ExecMethod = Execute; StateMethod = GetState; ] SID_TABLES_COUNT [ StateMethod = GetState; ] + SID_TABLE_STYLES [ StateMethod = GetState; ] SID_ATTR_YEAR2000 [ StateMethod = GetState; ExecMethod = Execute; ] SID_CHART_SOURCE [ ExecMethod = Execute; ] SID_CHART_ADDSOURCE [ ExecMethod = Execute; ] diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi index 3e755b1ea2ad..105a05a90edd 100644 --- a/sc/sdi/scalc.sdi +++ b/sc/sdi/scalc.sdi @@ -6475,6 +6475,24 @@ SfxBoolItem CellProtection SID_SCATTR_CELLPROTECTION GroupId = SfxGroupId::Format; ] +SfxStringItem TableStyles SID_TABLE_STYLES + +[ + AutoUpdate = FALSE, + FastCall = TRUE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + AccelConfig = FALSE, + MenuConfig = FALSE, + ToolBoxConfig = FALSE, + GroupId = SfxGroupId::Document; +] + + ScDatabaseSettingItem DatabaseSettings SID_DATABASE_SETTINGS (ScDatabaseSettingItem DatabaseSettings SID_DATABASE_SETTINGS) [ diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index 71f938dcc0f2..314b6faffe48 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -144,7 +144,7 @@ ScDocument::ScDocument( ScDocumentMode eMode, ScDocShell* pDocShell ) : pEOFormulaTree( nullptr ), pFormulaTrack( nullptr ), pEOFormulaTrack( nullptr ), - mpTableStyles(new ScTableStyles), + mpTableStyles(new ScTableStyles(GetViewBindings())), pPreviewCellStyle( nullptr ), maPreviewSelection(*mxSheetLimits), nUnoObjectId( 0 ), diff --git a/sc/source/core/data/tablestyle.cxx b/sc/source/core/data/tablestyle.cxx index e6b8643dba96..73285e0e6986 100644 --- a/sc/source/core/data/tablestyle.cxx +++ b/sc/source/core/data/tablestyle.cxx @@ -8,6 +8,10 @@ */ #include <tablestyle.hxx> +#include <sc.hrc> +#include <sfx2/bindings.hxx> +#include <sfx2/lokhelper.hxx> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> ScTableStyle::ScTableStyle(const OUString& rName, const std::optional<OUString>& rUIName) : mnFirstRowStripeSize(1) @@ -880,14 +884,24 @@ sal_Int32 ScTableStyle::GetFirstColumnStripeSize() const { return mnFirstColStri sal_Int32 ScTableStyle::GetSecondColumnStripeSize() const { return mnSecondColStripeSize; } -ScTableStyles::ScTableStyles() {} +ScTableStyles::ScTableStyles(SfxBindings* pBindings) + : mpBindings(pBindings) +{ +} void ScTableStyles::AddTableStyle(std::unique_ptr<ScTableStyle> pTableStyle) { maTableStyles.insert({ pTableStyle->GetName(), std::move(pTableStyle) }); + if (mpBindings) + mpBindings->Invalidate(SID_TABLE_STYLES); } -void ScTableStyles::DeleteTableStyle(const OUString& rName) { maTableStyles.erase(rName); } +void ScTableStyles::DeleteTableStyle(const OUString& rName) +{ + maTableStyles.erase(rName); + if (mpBindings) + mpBindings->Invalidate(SID_TABLE_STYLES); +} const ScTableStyle* ScTableStyles::GetTableStyle(const OUString& rName) const { diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index fbc627103c1c..9421bee64e30 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -108,6 +108,7 @@ #include <sheetevents.hxx> #include <formulacell.hxx> #include <documentlinkmgr.hxx> +#include <tablestyle.hxx> #include <memory> #include <sfx2/notebookbar/SfxNotebookBar.hxx> #include <helpids.h> @@ -2486,6 +2487,20 @@ void ScDocShell::GetState( SfxItemSet &rSet ) rSet.Put( SfxInt16Item( nWhich, m_pDocument->GetTableCount() ) ); break; + case SID_TABLE_STYLES: + { + ScTableStyles* pStyles = m_pDocument->GetTableStyles(); + if (pStyles) + { + tools::JsonWriter aTree; + pStyles->generateJSON(aTree); + OString aStr = aTree.finishAndGetAsOString(); + rSet.Put( + SfxStringItem( nWhich, OStringToOUString( aStr, RTL_TEXTENCODING_UTF8 ) ) ); + } + } + break; + case SID_ATTR_YEAR2000 : rSet.Put( SfxUInt16Item( nWhich, m_pDocument->GetDocOptions().GetYear2000() ) ); diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index aa3e3406cf8f..0759a238bc37 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -78,6 +78,7 @@ #include <preview.hxx> #include <documentlinkmgr.hxx> #include <gridwin.hxx> +#include <tablestyle.hxx> #include <com/sun/star/document/XDocumentProperties.hpp> #include <com/sun/star/configuration/theDefaultProvider.hpp> diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index b81e8d1cf3e5..02db1153aaa7 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -1477,6 +1477,7 @@ const std::map<std::u16string_view, KitUnoCommand>& GetKitUnoCommandList() { u"TableRowHeight", { PayloadType::TableSizePayload, false } }, { u"DatabaseSettings", { PayloadType::TableStylePayload, true } }, + { u"TableStyles", { PayloadType::StringPayload, true } }, { u"BorderInner", { PayloadType::None, true } }, { u"BorderOuter", { PayloadType::None, true } },
