include/sfx2/sfxsids.hrc | 1 include/svx/ThemeColorsToolBoxControl.hxx | 19 +-- officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu | 4 sc/sdi/tabvwsh.sdi | 1 sc/source/ui/view/tabvwsh3.cxx | 26 ++++ sd/Library_sd.mk | 1 sd/sdi/_drvwsh.sdi | 5 sd/source/ui/view/drviews2.cxx | 28 ++++ sd/util/sd.component | 4 svx/Library_svx.mk | 1 svx/sdi/svx.sdi | 17 ++ svx/source/tbxctrls/ThemeColorsToolBoxControl.cxx | 60 +++------- svx/util/svx.component | 4 sw/sdi/_basesh.sdi | 7 + sw/source/uibase/shells/basesh.cxx | 25 ++++ vcl/workben/cgmfuzzer.cxx | 4 16 files changed, 147 insertions(+), 60 deletions(-)
New commits: commit ff10450486e95f6a61bf3a031e09fa39bc57c9dc Author: Samuel Mehrbrodt <[email protected]> AuthorDate: Mon Feb 9 10:47:04 2026 +0100 Commit: Szymon Kłos <[email protected]> CommitDate: Tue Feb 10 08:11:43 2026 +0100 Move Theme Colors toolbox ctrl to svx to make it available in other modules as well Change-Id: I98032532d310afaf5ee9566c8b6a1af21138ee8e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198967 Reviewed-by: Szymon Kłos <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc index 06784d09e4f3..7b1219fd840d 100644 --- a/include/sfx2/sfxsids.hrc +++ b/include/sfx2/sfxsids.hrc @@ -482,6 +482,7 @@ class SvxZoomItem; #define SID_ACCESSIBILITY_CHECK_ONLINE (SID_SFX_START + 814) #define SID_THEME_DIALOG (SID_SFX_START + 815) #define SID_ADD_THEME (SID_SFX_START + 816) +#define SID_APPLY_THEME (SID_SFX_START + 817) // default-ids for configuration #define SID_CONFIG TypedWhichId<SfxStringItem>(SID_SFX_START + 904) diff --git a/sd/source/ui/controller/ThemeColorsToolBoxControl.hxx b/include/svx/ThemeColorsToolBoxControl.hxx similarity index 80% rename from sd/source/ui/controller/ThemeColorsToolBoxControl.hxx rename to include/svx/ThemeColorsToolBoxControl.hxx index 57465b894ef5..1830c5742cbb 100644 --- a/sd/source/ui/controller/ThemeColorsToolBoxControl.hxx +++ b/include/svx/ThemeColorsToolBoxControl.hxx @@ -7,26 +7,27 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#pragma once + +#include <svx/svxdllapi.h> #include <svtools/toolboxcontroller.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/frame/XFrame.hpp> #include <vcl/vclptr.hxx> #include <vcl/InterimItemWindow.hxx> #include <svx/dialog/ThemeColorsPaneBase.hxx> -namespace sd -{ -class ViewShellBase; -} - // Used to put theme colors pane to the notebookbar -class ThemeColorsPaneWrapper final : public InterimItemWindow, public svx::ThemeColorsPaneBase +class SVX_DLLPUBLIC ThemeColorsPaneWrapper final : public InterimItemWindow, + public svx::ThemeColorsPaneBase { private: - sd::ViewShellBase& mrViewShellBase; + css::uno::Reference<css::frame::XFrame> m_xFrame; public: - ThemeColorsPaneWrapper(vcl::Window* pParent, sd::ViewShellBase& rBase); + ThemeColorsPaneWrapper(vcl::Window* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame); virtual ~ThemeColorsPaneWrapper() override; virtual void dispose() override; void SetOptimalSize(); @@ -38,7 +39,7 @@ protected: void onColorSetActivated() override; }; -class ThemeColorsToolBoxControl final +class SVX_DLLPUBLIC ThemeColorsToolBoxControl final : public cppu::ImplInheritanceHelper<svt::ToolboxController, css::lang::XServiceInfo> { VclPtr<ThemeColorsPaneWrapper> m_xVclBox; diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu index af57163c882d..c2f685959e7a 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu @@ -1135,10 +1135,10 @@ <value>.uno:ThemeSelectorPanel</value> </prop> <prop oor:name="Module"> - <value>com.sun.star.presentation.PresentationDocument</value> + <value/> </prop> <prop oor:name="Controller"> - <value>com.sun.star.comp.sd.ThemeColorsToolBoxControl</value> + <value>com.sun.star.comp.svx.ThemeColorsToolBoxControl</value> </prop> </node> <node oor:name="BulletsToolBox" oor:op="replace"> diff --git a/sc/sdi/tabvwsh.sdi b/sc/sdi/tabvwsh.sdi index b9ab9c546179..cbf2ea66e59b 100644 --- a/sc/sdi/tabvwsh.sdi +++ b/sc/sdi/tabvwsh.sdi @@ -193,6 +193,7 @@ interface TableEditView SID_PRINTPREVIEW [ ExecMethod = Execute; StateMethod = GetState; ] SID_THEME_DIALOG [ ExecMethod = Execute; StateMethod = GetState; ] + SID_APPLY_THEME [ ExecMethod = Execute; StateMethod = GetState; ] SID_NAVIGATOR_SELECT_COMMENT [ ExecMethod = ExecNavigatorWin; ] diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx index 9a1c22067e8e..61e6af646e3e 100644 --- a/sc/source/ui/view/tabvwsh3.cxx +++ b/sc/source/ui/view/tabvwsh3.cxx @@ -53,6 +53,7 @@ #include <svx/zoomslideritem.hxx> #include <svx/svxdlg.hxx> +#include <svx/ColorSets.hxx> #include <comphelper/lok.hxx> #include <comphelper/string.hxx> #include <com/sun/star/uno/Reference.h> @@ -1578,6 +1579,31 @@ void ScTabViewShell::Execute( SfxRequest& rReq ) ExecProtectTable( rReq ); break; + case SID_APPLY_THEME: + { + const SfxItemSet* pArgs = rReq.GetArgs(); + if (pArgs) + { + const SfxPoolItem* pItem; + if (pArgs->GetItemState(FN_PARAM_1, true, &pItem) == SfxItemState::SET) + { + OUString aThemeName = static_cast<const SfxStringItem*>(pItem)->GetValue(); + auto pColorSet = svx::ColorSets::get().getColorSet(aThemeName); + + if (pColorSet) + { + // Create shared pointer from raw pointer + auto pSharedColorSet = std::shared_ptr<model::ColorSet>(new model::ColorSet(*pColorSet)); + sc::ThemeColorChanger aChanger(*GetViewData().GetDocShell()); + aChanger.apply(pSharedColorSet); + } + } + } + + rReq.Done(); + } + break; + case SID_THEME_DIALOG: { MakeDrawLayer(); diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk index 4695244dea53..012c1ad49522 100644 --- a/sd/Library_sd.mk +++ b/sd/Library_sd.mk @@ -229,7 +229,6 @@ $(eval $(call gb_Library_add_exception_objects,sd,\ sd/source/ui/controller/slidelayoutcontroller \ sd/source/ui/controller/displaymodecontroller \ sd/source/ui/controller/SlideTransitionsToolBoxControl \ - sd/source/ui/controller/ThemeColorsToolBoxControl \ sd/source/ui/dlg/AnimationChildWindow \ sd/source/ui/dlg/LayerTabBar \ sd/source/ui/dlg/NavigatorChildWindow \ diff --git a/sd/sdi/_drvwsh.sdi b/sd/sdi/_drvwsh.sdi index d5719a018564..19b4bb18bdb8 100644 --- a/sd/sdi/_drvwsh.sdi +++ b/sd/sdi/_drvwsh.sdi @@ -3008,6 +3008,11 @@ interface DrawView ExecMethod = FuTemporary; StateMethod = GetAttrState; ] + SID_APPLY_THEME + [ + ExecMethod = FuTemporary; + StateMethod = GetAttrState; + ] SID_ALIGN_PAGE [ ExecMethod = FuTemporary ; diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 6be0ef4cc34b..9af25b0d11cf 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -4309,6 +4309,34 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) } break; + case SID_APPLY_THEME: + { + const SfxItemSet* pArgs = rReq.GetArgs(); + if (pArgs) + { + const SfxPoolItem* pItem; + if (pArgs->GetItemState(FN_PARAM_1, true, &pItem) == SfxItemState::SET) + { + OUString aThemeName = static_cast<const SfxStringItem*>(pItem)->GetValue(); + auto pColorSet = svx::ColorSets::get().getColorSet(aThemeName); + + if (pColorSet) + { + SdrPage* pMasterPage = &GetActualPage()->TRG_GetMasterPage(); + auto* pDocShell = GetDocSh(); + + auto pSharedColorSet = std::shared_ptr<model::ColorSet>(new model::ColorSet(*pColorSet)); + sd::ThemeColorChanger aChanger(pMasterPage, pDocShell); + aChanger.apply(pSharedColorSet); + } + } + } + + Cancel(); + rReq.Done(); + } + break; + case SID_ATTR_GLOW_COLOR: case SID_ATTR_GLOW_RADIUS: case SID_ATTR_GLOW_TRANSPARENCY: diff --git a/sd/util/sd.component b/sd/util/sd.component index 42fb776c1c3f..e20b1ebbcebb 100644 --- a/sd/util/sd.component +++ b/sd/util/sd.component @@ -65,10 +65,6 @@ constructor="com_sun_star_comp_sd_SlideTransitionsToolBoxControl_get_implementation"> <service name="com.sun.star.frame.ToolbarController"/> </implementation> - <implementation name="com.sun.star.comp.sd.ThemeColorsToolBoxControl" - constructor="com_sun_star_comp_sd_ThemeColorsToolBoxControl_get_implementation"> - <service name="com.sun.star.frame.ToolbarController"/> - </implementation> <implementation name="com.sun.star.comp.sd.SlideLayoutController" constructor="com_sun_star_comp_sd_SlideLayoutController_get_implementation"> <service name="com.sun.star.frame.ToolbarController"/> diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk index 3bb70ec04823..29a045cee4ee 100644 --- a/svx/Library_svx.mk +++ b/svx/Library_svx.mk @@ -282,6 +282,7 @@ $(eval $(call gb_Library_add_exception_objects,svx,\ svx/source/tbxctrls/tbunosearchcontrollers \ svx/source/tbxctrls/tbxcolor \ svx/source/tbxctrls/tbxdrctl \ + svx/source/tbxctrls/ThemeColorsToolBoxControl \ svx/source/tbxctrls/verttexttbxctrl \ svx/source/uitest/uiobject \ svx/source/unodraw/unoctabl \ diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi index 288c3c2c6f17..831676140d90 100644 --- a/svx/sdi/svx.sdi +++ b/svx/sdi/svx.sdi @@ -12702,6 +12702,23 @@ SfxVoidItem AddTheme SID_ADD_THEME GroupId = SfxGroupId::Format; ] +SfxVoidItem ApplyTheme SID_APPLY_THEME +(SfxStringItem ThemeName FN_PARAM_1) +[ + AutoUpdate = FALSE, + FastCall = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + AccelConfig = TRUE, + MenuConfig = TRUE, + ToolBoxConfig = TRUE, + GroupId = SfxGroupId::Format; +] + SfxBoolItem AccessibilityCheckOnline SID_ACCESSIBILITY_CHECK_ONLINE (SfxBoolItem Enable FN_PARAM_1) [ diff --git a/sd/source/ui/controller/ThemeColorsToolBoxControl.cxx b/svx/source/tbxctrls/ThemeColorsToolBoxControl.cxx similarity index 70% rename from sd/source/ui/controller/ThemeColorsToolBoxControl.cxx rename to svx/source/tbxctrls/ThemeColorsToolBoxControl.cxx index 4429764b1283..3eab0256b451 100644 --- a/sd/source/ui/controller/ThemeColorsToolBoxControl.cxx +++ b/svx/source/tbxctrls/ThemeColorsToolBoxControl.cxx @@ -7,18 +7,17 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "ThemeColorsToolBoxControl.hxx" -#include <ViewShellBase.hxx> +#include <svx/ThemeColorsToolBoxControl.hxx> #include <cppuhelper/supportsservice.hxx> #include <sfx2/viewsh.hxx> +#include <sfx2/objsh.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <vcl/svapp.hxx> -#include <svx/dialog/ThemeColorsPaneBase.hxx> -#include <theme/ThemeColorChanger.hxx> -#include <DrawDocShell.hxx> -#include <drawview.hxx> -#include <svx/svdpagv.hxx> -#include <DrawViewShell.hxx> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <comphelper/processfactory.hxx> +#include <comphelper/dispatchcommand.hxx> +#include <comphelper/propertyvalue.hxx> ThemeColorsToolBoxControl::ThemeColorsToolBoxControl() {} @@ -60,17 +59,8 @@ ThemeColorsToolBoxControl::createItemWindow(const css::uno::Reference<css::awt:: { SolarMutexGuard aSolarMutexGuard; - sd::ViewShellBase* pViewShellBase = nullptr; - if (SfxViewShell* pViewShell = SfxViewShell::Current()) - { - pViewShellBase = dynamic_cast<sd::ViewShellBase*>(pViewShell); - } - - if (pViewShellBase) - { - m_xVclBox = VclPtr<ThemeColorsPaneWrapper>::Create(pParent, *pViewShellBase); - xItemWindow = VCLUnoHelper::GetInterface(m_xVclBox.get()); - } + m_xVclBox = VclPtr<ThemeColorsPaneWrapper>::Create(pParent, m_xFrame); + xItemWindow = VCLUnoHelper::GetInterface(m_xVclBox.get()); } return xItemWindow; } @@ -79,7 +69,7 @@ void SAL_CALL ThemeColorsToolBoxControl::update() {} OUString SAL_CALL ThemeColorsToolBoxControl::getImplementationName() { - return u"com.sun.star.comp.sd.ThemeColorsToolBoxControl"_ustr; + return u"com.sun.star.comp.svx.ThemeColorsToolBoxControl"_ustr; } sal_Bool SAL_CALL ThemeColorsToolBoxControl::supportsService(const OUString& rServiceName) @@ -94,17 +84,18 @@ css::uno::Sequence<OUString> SAL_CALL ThemeColorsToolBoxControl::getSupportedSer // Export function for service registration extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* -com_sun_star_comp_sd_ThemeColorsToolBoxControl_get_implementation( +com_sun_star_comp_svx_ThemeColorsToolBoxControl_get_implementation( css::uno::XComponentContext* /*rxContext*/, css::uno::Sequence<css::uno::Any> const&) { return cppu::acquire(new ThemeColorsToolBoxControl()); } -ThemeColorsPaneWrapper::ThemeColorsPaneWrapper(vcl::Window* pParent, sd::ViewShellBase& rBase) +ThemeColorsPaneWrapper::ThemeColorsPaneWrapper( + vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame) : InterimItemWindow(pParent, u"svx/ui/themeselectorpanel.ui"_ustr, u"ThemeSelectorPanel"_ustr, true, reinterpret_cast<sal_uInt64>(SfxViewShell::Current())) , svx::ThemeColorsPaneBase(m_xBuilder->weld_icon_view(u"iconview_theme_colors"_ustr)) - , mrViewShellBase(rBase) + , m_xFrame(rxFrame) { // Override selection handler to apply theme on single click if (mxIconViewThemeColors) @@ -131,26 +122,11 @@ void ThemeColorsPaneWrapper::onColorSetActivated() { if (!mpCurrentColorSet) return; - sd::DrawViewShell* pViewShell - = dynamic_cast<sd::DrawViewShell*>(mrViewShellBase.GetMainViewShell().get()); - if (!pViewShell) - return; - SdrPageView* pPageView = pViewShell->GetDrawView()->GetSdrPageView(); - if (!pPageView) - return; - SdrPage* pPage = pPageView->GetPage(); - if (!pPage) - return; - SdrPage* pMasterPage = &pPage->TRG_GetMasterPage(); - if (!pMasterPage) - return; - sd::DrawDocShell* pDocShell = mrViewShellBase.GetDocShell(); - if (!pDocShell) - return; - // Apply the theme - sd::ThemeColorChanger aChanger(pMasterPage, pDocShell); - aChanger.apply(mpCurrentColorSet); + css::uno::Sequence<css::beans::PropertyValue> aArgs{ comphelper::makePropertyValue( + u"ThemeName"_ustr, mpCurrentColorSet->getName()) }; + + comphelper::dispatchCommand(u".uno:ApplyTheme"_ustr, m_xFrame, aArgs); } IMPL_LINK_NOARG(ThemeColorsPaneWrapper, SelectionChangedHdl, weld::IconView&, void) diff --git a/svx/util/svx.component b/svx/util/svx.component index c655da210995..1421fe01b4da 100644 --- a/svx/util/svx.component +++ b/svx/util/svx.component @@ -134,4 +134,8 @@ constructor="com_sun_star_comp_svx_VertTextToolBoxControl_get_implementation"> <service name="com.sun.star.frame.ToolbarController"/> </implementation> + <implementation name="com.sun.star.comp.svx.ThemeColorsToolBoxControl" + constructor="com_sun_star_comp_svx_ThemeColorsToolBoxControl_get_implementation"> + <service name="com.sun.star.frame.ToolbarController"/> + </implementation> </component> diff --git a/sw/sdi/_basesh.sdi b/sw/sdi/_basesh.sdi index 6967020afbcc..40f5976efa66 100644 --- a/sw/sdi/_basesh.sdi +++ b/sw/sdi/_basesh.sdi @@ -624,4 +624,11 @@ interface BaseTextSelection StateMethod = GetState; DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; ] + + SID_APPLY_THEME + [ + ExecMethod = ExecDlg; + StateMethod = GetState; + DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; + ] } diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx index 80fbf76879f6..018716bf8d7b 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -37,6 +37,7 @@ #include <editeng/langitem.hxx> #include <svx/clipfmtitem.hxx> #include <svx/contdlg.hxx> +#include <svx/ColorSets.hxx> #include <vcl/graph.hxx> #include <vcl/inputctx.hxx> #include <svl/slstitm.hxx> @@ -3053,6 +3054,30 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) } break; + case SID_APPLY_THEME: + { + if (pArgs) + { + if (pArgs->GetItemState(FN_PARAM_1, true, &pItem) == SfxItemState::SET) + { + OUString aThemeName = static_cast<const SfxStringItem*>(pItem)->GetValue(); + auto pColorSet = svx::ColorSets::get().getColorSet(aThemeName); + auto* pDocument = rSh.GetDoc(); + auto* pDocumentShell = pDocument->GetDocShell(); + + if (pColorSet && pDocumentShell) + { + auto pSharedColorSet = std::shared_ptr<model::ColorSet>(new model::ColorSet(*pColorSet)); + std::shared_ptr<svx::IThemeColorChanger> xChanger(new sw::ThemeColorChanger(pDocumentShell)); + xChanger->apply(pSharedColorSet); + } + } + } + + rReq.Done(); + } + break; + default:OSL_FAIL("wrong Dispatcher (basesh.cxx)"); } if(!bDone) diff --git a/vcl/workben/cgmfuzzer.cxx b/vcl/workben/cgmfuzzer.cxx index 12383df54e95..b4fa1fef9f98 100644 --- a/vcl/workben/cgmfuzzer.cxx +++ b/vcl/workben/cgmfuzzer.cxx @@ -65,7 +65,7 @@ void com_sun_star_comp_sd_InsertSlideController_get_implementation( void ); void com_sun_star_comp_sd_SlideLayoutController_get_implementation( void ); void com_sun_star_comp_sd_DisplayModeController_get_implementation( void ); void com_sun_star_comp_sd_SlideTransitionsToolBoxControl_get_implementation( void ); -void com_sun_star_comp_sd_ThemeColorsToolBoxControl_get_implementation( void ); +void com_sun_star_comp_svx_ThemeColorsToolBoxControl_get_implementation( void ); void ucb_UcbCommandEnvironment_get_implementation( void ); void ucb_UcbContentProviderProxyFactory_get_implementation( void ); void ucb_UcbPropertiesManager_get_implementation( void ); @@ -137,7 +137,7 @@ lo_get_constructor_map(void) { "com_sun_star_comp_sd_SlideLayoutController_get_implementation", com_sun_star_comp_sd_SlideLayoutController_get_implementation }, { "com_sun_star_comp_sd_DisplayModeController_get_implementation", com_sun_star_comp_sd_DisplayModeController_get_implementation }, { "com_sun_star_comp_sd_SlideTransitionsToolBoxControl_get_implementation", com_sun_star_comp_sd_SlideTransitionsToolBoxControl_get_implementation }, - { "com_sun_star_comp_sd_ThemeColorsToolBoxControl_get_implementation", com_sun_star_comp_sd_ThemeColorsToolBoxControl_get_implementation }, + { "com_sun_star_comp_svx_ThemeColorsToolBoxControl_get_implementation", com_sun_star_comp_svx_ThemeColorsToolBoxControl_get_implementation }, { "ucb_UcbCommandEnvironment_get_implementation", ucb_UcbCommandEnvironment_get_implementation, }, { "ucb_UcbContentProviderProxyFactory_get_implementation", ucb_UcbContentProviderProxyFactory_get_implementation }, { "ucb_UcbPropertiesManager_get_implementation", ucb_UcbPropertiesManager_get_implementation },
