diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc index 49349a9103e2..04d8213f0b42 100644 --- a/include/sfx2/sfxsids.hrc +++ b/include/sfx2/sfxsids.hrc @@ -485,6 +485,7 @@ class SvxZoomItem; #define SID_THEME_DIALOG (SID_SFX_START + 815) #define SID_REDACT_IMAGE (SID_SFX_START + 816) #define SID_ADD_THEME (SID_SFX_START + 817) +#define SID_APPLY_THEME (SID_SFX_START + 818) // default-ids for configuration #define SID_CONFIG TypedWhichId(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 #include #include +#include #include #include #include -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 m_xFrame; public: - ThemeColorsPaneWrapper(vcl::Window* pParent, sd::ViewShellBase& rBase); + ThemeColorsPaneWrapper(vcl::Window* pParent, + const css::uno::Reference& 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 { VclPtr m_xVclBox; diff --git a/include/svx/dialog/ThemeColorsPaneBase.hxx b/include/svx/dialog/ThemeColorsPaneBase.hxx index 4ae2e0d609a3..0b4deeda42e8 100644 --- a/include/svx/dialog/ThemeColorsPaneBase.hxx +++ b/include/svx/dialog/ThemeColorsPaneBase.hxx @@ -11,6 +11,7 @@ #include #include +#include #include #include #include diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu index 750c20be3e6f..8c1e90092f03 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 @@ .uno:ThemeSelectorPanel - com.sun.star.presentation.PresentationDocument + - com.sun.star.comp.sd.ThemeColorsToolBoxControl + com.sun.star.comp.svx.ThemeColorsToolBoxControl diff --git a/sc/sdi/tabvwsh.sdi b/sc/sdi/tabvwsh.sdi index 42c6018edf1b..8700efcd5b8b 100644 --- a/sc/sdi/tabvwsh.sdi +++ b/sc/sdi/tabvwsh.sdi @@ -223,6 +223,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 f34218a50e0e..086155215c72 100644 --- a/sc/source/ui/view/tabvwsh3.cxx +++ b/sc/source/ui/view/tabvwsh3.cxx @@ -54,6 +54,7 @@ #include #include +#include #include #include #include @@ -1586,6 +1587,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(pItem)->GetValue(); + auto pColorSet = svx::ColorSets::get().getColorSet(aThemeName); + + if (pColorSet) + { + // Create shared pointer from raw pointer + auto pSharedColorSet = std::shared_ptr(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 5b086b085966..4c6140046464 100644 --- a/sd/Library_sd.mk +++ b/sd/Library_sd.mk @@ -231,7 +231,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 3478d268a8b6..3636c3f02485 100644 --- a/sd/sdi/_drvwsh.sdi +++ b/sd/sdi/_drvwsh.sdi @@ -3048,6 +3048,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 e8b1b7f64edc..dfde8fed839e 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(pItem)->GetValue(); + auto pColorSet = svx::ColorSets::get().getColorSet(aThemeName); + + if (pColorSet) + { + SdrPage* pMasterPage = &GetActualPage()->TRG_GetMasterPage(); + auto* pDocShell = GetDocSh(); + + auto pSharedColorSet = std::shared_ptr(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 d8bbdf995752..2c7f94763b24 100644 --- a/sd/util/sd.component +++ b/sd/util/sd.component @@ -49,10 +49,6 @@ constructor="com_sun_star_comp_sd_SlideTransitionsToolBoxControl_get_implementation"> - - - diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk index e7e72400ad84..8004b3602d58 100644 --- a/svx/Library_svx.mk +++ b/svx/Library_svx.mk @@ -284,6 +284,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 cdaab0ad1e75..57990f287977 100644 --- a/svx/sdi/svx.sdi +++ b/svx/sdi/svx.sdi @@ -13342,6 +13342,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 4386ae8cf9a3..cacfe9343d84 100644 --- a/sd/source/ui/controller/ThemeColorsToolBoxControl.cxx +++ b/svx/source/tbxctrls/ThemeColorsToolBoxControl.cxx @@ -7,19 +7,18 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "ThemeColorsToolBoxControl.hxx" -#include +#include +#include #include #include +#include #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include ThemeColorsToolBoxControl::ThemeColorsToolBoxControl() {} @@ -61,17 +60,8 @@ ThemeColorsToolBoxControl::createItemWindow(const css::uno::Reference(pViewShell); - } - - if (pViewShellBase) - { - m_xVclBox = VclPtr::Create(pParent, *pViewShellBase); - xItemWindow = VCLUnoHelper::GetInterface(m_xVclBox.get()); - } + m_xVclBox = VclPtr::Create(pParent, m_xFrame); + xItemWindow = VCLUnoHelper::GetInterface(m_xVclBox.get()); } return xItemWindow; } @@ -80,7 +70,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) @@ -95,17 +85,18 @@ css::uno::Sequence 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 const&) { return cppu::acquire(new ThemeColorsToolBoxControl()); } -ThemeColorsPaneWrapper::ThemeColorsPaneWrapper(vcl::Window* pParent, sd::ViewShellBase& rBase) +ThemeColorsPaneWrapper::ThemeColorsPaneWrapper( + vcl::Window* pParent, const css::uno::Reference& rxFrame) : InterimItemWindow(pParent, u"svx/ui/themeselectorpanel.ui"_ustr, u"ThemeSelectorPanel"_ustr, true, reinterpret_cast(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) @@ -132,26 +123,11 @@ void ThemeColorsPaneWrapper::onColorSetActivated() { if (!mpCurrentColorSet) return; - sd::DrawViewShell* pViewShell - = dynamic_cast(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 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 4788ab737145..e1ca0b49d316 100644 --- a/svx/util/svx.component +++ b/svx/util/svx.component @@ -134,4 +134,8 @@ constructor="com_sun_star_comp_svx_VertTextToolBoxControl_get_implementation"> + + + diff --git a/sw/sdi/_basesh.sdi b/sw/sdi/_basesh.sdi index 0f2935267d37..93ffc70378be 100644 --- a/sw/sdi/_basesh.sdi +++ b/sw/sdi/_basesh.sdi @@ -619,6 +619,13 @@ interface BaseTextSelection DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; ] + SID_APPLY_THEME + [ + ExecMethod = ExecDlg; + StateMethod = GetState; + DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; + ] + SID_PROTECTPOS [ ExecMethod = Execute ; diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx index 77340ecfed24..7f50de6a74d0 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -3056,6 +3057,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(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(new model::ColorSet(*pColorSet)); + std::shared_ptr 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 6ff52549e194..0d0c802a497f 100644 --- a/vcl/workben/cgmfuzzer.cxx +++ b/vcl/workben/cgmfuzzer.cxx @@ -62,7 +62,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 ); @@ -131,7 +131,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 },