diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-01-10 20:21:31 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-01-14 12:26:15 +0000 |
commit | d4e4a2b96a787b4f99d68d7a417c37c97b47c170 (patch) | |
tree | 06e850a80368b237eac5fc68cefd4d97f1376ece /sw | |
parent | ef3c34596ebc6e6e3b85c4093a28d48fe328c1a7 (diff) |
ThemeDialog added which allows to change the theme used by the doc.
ThemeDialog is a common dialog that can be used to select the
theme used by the document. Currently it only implements colors
but in the future also the fonts and formats (for shapes) will
be adde.
The IThemeColorChanger interface is used by the dialog to change
the actual color values inside the document. For the writer the
existing ThemeColorChanger is now implementing the interface.
The dialog is accessible in Writer at Format -> Theme... in the
main menu.
Change-Id: I23c7dc9668cdc5427f36d604a76c433d6dbef497
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145264
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/sdi/_basesh.sdi | 7 | ||||
-rw-r--r-- | sw/source/core/inc/ThemeColorChanger.hxx | 7 | ||||
-rw-r--r-- | sw/source/core/model/ThemeColorChanger.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/shells/basesh.cxx | 26 | ||||
-rw-r--r-- | sw/uiconfig/sglobal/menubar/menubar.xml | 1 | ||||
-rw-r--r-- | sw/uiconfig/swriter/menubar/menubar.xml | 1 |
6 files changed, 42 insertions, 2 deletions
diff --git a/sw/sdi/_basesh.sdi b/sw/sdi/_basesh.sdi index 5ac4cb001eb3..a1468ffac8b1 100644 --- a/sw/sdi/_basesh.sdi +++ b/sw/sdi/_basesh.sdi @@ -617,4 +617,11 @@ interface BaseTextSelection StateMethod = GetState; DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; ] + + SID_THEME_DIALOG + [ + ExecMethod = ExecDlg; + StateMethod = GetState; + DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; + ] } diff --git a/sw/source/core/inc/ThemeColorChanger.hxx b/sw/source/core/inc/ThemeColorChanger.hxx index 0698126da3e9..d4ba7a9fcad5 100644 --- a/sw/source/core/inc/ThemeColorChanger.hxx +++ b/sw/source/core/inc/ThemeColorChanger.hxx @@ -11,10 +11,11 @@ #include <docsh.hxx> #include <svx/ColorSets.hxx> +#include <svx/theme/IThemeColorChanger.hxx> namespace sw { -class ThemeColorChanger +class ThemeColorChanger : public svx::IThemeColorChanger { private: SwDocShell* mpDocSh; @@ -25,7 +26,9 @@ public: { } - void apply(svx::ColorSet const& rColorSet); + virtual ~ThemeColorChanger() override; + + void apply(svx::ColorSet const& rColorSet) override; }; } // end sw namespace diff --git a/sw/source/core/model/ThemeColorChanger.cxx b/sw/source/core/model/ThemeColorChanger.cxx index ff59c474748b..4c739547685b 100644 --- a/sw/source/core/model/ThemeColorChanger.cxx +++ b/sw/source/core/model/ThemeColorChanger.cxx @@ -229,6 +229,8 @@ void changeColor(SwFormat* pFormat, svx::ColorSet const& rColorSet, SwDoc* pDocu } // end anonymous namespace +ThemeColorChanger::~ThemeColorChanger() {} + void ThemeColorChanger::apply(svx::ColorSet const& rColorSet) { SwDoc* pDocument = mpDocSh->GetDoc(); diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx index 2e7489fda6de..44759890e695 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -80,8 +80,11 @@ #include <strings.hrc> #include <unotxdoc.hxx> #include <doc.hxx> +#include <drawdoc.hxx> #include <IDocumentSettingAccess.hxx> +#include <IDocumentDrawModelAccess.hxx> #include <IDocumentUndoRedo.hxx> +#include <ThemeColorChanger.hxx> #include <swabstdlg.hxx> #include <modcfg.hxx> #include <svx/fmshell.hxx> @@ -94,6 +97,7 @@ #include <memory> #include <svx/unobrushitemhelper.hxx> +#include <svx/dialog/ThemeDialog.hxx> #include <comphelper/scopeguard.hxx> #include <comphelper/lok.hxx> #include <osl/diagnose.h> @@ -2203,6 +2207,10 @@ void SwBaseShell::GetState( SfxItemSet &rSet ) rSet.DisableItem(nWhich); } break; + case SID_THEME_DIALOG: + { + } + break; } nWhich = aIter.NextWhich(); } @@ -3028,6 +3036,24 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) } break; + case SID_THEME_DIALOG: + { + auto* pDocument = rSh.GetDoc(); + auto* pDocumentShell = pDocument->GetDocShell(); + if (pDocumentShell) + { + SdrPage* pPage = pDocument->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); + svx::Theme* pTheme = pPage->getSdrPageProperties().GetTheme(); + if (pTheme) + { + std::shared_ptr<svx::IThemeColorChanger> pChanger(new sw::ThemeColorChanger(pDocumentShell)); + auto pDialog = std::make_shared<svx::ThemeDialog>(pMDI, pTheme, pChanger); + weld::DialogController::runAsync(pDialog, [](int) {}); + } + } + } + break; + default:OSL_FAIL("wrong Dispatcher (basesh.cxx)"); } if(!bDone) diff --git a/sw/uiconfig/sglobal/menubar/menubar.xml b/sw/uiconfig/sglobal/menubar/menubar.xml index b933889b88f2..9b9d37689f10 100644 --- a/sw/uiconfig/sglobal/menubar/menubar.xml +++ b/sw/uiconfig/sglobal/menubar/menubar.xml @@ -443,6 +443,7 @@ <menu:menuitem menu:id=".uno:FontDialog"/> <menu:menuitem menu:id=".uno:ParagraphDialog"/> <menu:menuitem menu:id=".uno:OutlineBullet"/> + <menu:menuitem menu:id=".uno:ThemeDialog"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:PageDialog"/> <menu:menuitem menu:id=".uno:TitlePageDialog" menu:style="text"/> diff --git a/sw/uiconfig/swriter/menubar/menubar.xml b/sw/uiconfig/swriter/menubar/menubar.xml index 3b48071edb82..295dfe7280c6 100644 --- a/sw/uiconfig/swriter/menubar/menubar.xml +++ b/sw/uiconfig/swriter/menubar/menubar.xml @@ -454,6 +454,7 @@ </menu:menupopup> </menu:menu> <menu:menuitem menu:id=".uno:OutlineBullet"/> + <menu:menuitem menu:id=".uno:ThemeDialog"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:PageDialog"/> <menu:menuitem menu:id=".uno:TitlePageDialog"/> |