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>
This commit is contained in:
parent
ef3c34596e
commit
d4e4a2b96a
@ -469,6 +469,7 @@ class SvxZoomItem;
|
||||
#define SID_ACCESSIBILITY_CHECK (SID_SFX_START + 812)
|
||||
#define SID_ASYNCHRON (SID_SFX_START + 813)
|
||||
#define SID_ACCESSIBILITY_CHECK_ONLINE (SID_SFX_START + 814)
|
||||
#define SID_THEME_DIALOG (SID_SFX_START + 815)
|
||||
|
||||
// default-ids for configuration
|
||||
#define SID_CONFIG (SID_SFX_START + 904)
|
||||
|
42
include/svx/dialog/ThemeDialog.hxx
Normal file
42
include/svx/dialog/ThemeDialog.hxx
Normal file
@ -0,0 +1,42 @@
|
||||
/* -*- 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/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <svx/svxdllapi.h>
|
||||
#include <vcl/weld.hxx>
|
||||
#include <svx/ColorSets.hxx>
|
||||
#include <svx/svdpage.hxx>
|
||||
#include <svx/theme/IThemeColorChanger.hxx>
|
||||
#include <svx/dialog/ThemeColorValueSet.hxx>
|
||||
|
||||
namespace svx
|
||||
{
|
||||
class SVX_DLLPUBLIC ThemeDialog final : public weld::GenericDialogController
|
||||
{
|
||||
private:
|
||||
svx::Theme* mpTheme;
|
||||
svx::ColorSets maColorSets;
|
||||
std::shared_ptr<IThemeColorChanger> mpChanger;
|
||||
|
||||
std::unique_ptr<svx::ThemeColorValueSet> mxValueSetThemeColors;
|
||||
std::unique_ptr<weld::CustomWeld> mxValueSetThemeColorsWindow;
|
||||
|
||||
public:
|
||||
ThemeDialog(weld::Window* pParent, svx::Theme* pTheme,
|
||||
std::shared_ptr<IThemeColorChanger> const& pChanger);
|
||||
virtual ~ThemeDialog() override;
|
||||
|
||||
DECL_LINK(DoubleClickValueSetHdl, ValueSet*, void);
|
||||
void DoubleClickHdl();
|
||||
};
|
||||
|
||||
} // end svx namespace
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
26
include/svx/theme/IThemeColorChanger.hxx
Normal file
26
include/svx/theme/IThemeColorChanger.hxx
Normal file
@ -0,0 +1,26 @@
|
||||
/* -*- 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/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <svx/svxdllapi.h>
|
||||
#include <svx/ColorSets.hxx>
|
||||
|
||||
namespace svx
|
||||
{
|
||||
class SVX_DLLPUBLIC IThemeColorChanger
|
||||
{
|
||||
public:
|
||||
virtual ~IThemeColorChanger() = default;
|
||||
virtual void apply(svx::ColorSet const& rColorSet) = 0;
|
||||
};
|
||||
|
||||
} // end svx namespace
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
@ -7465,6 +7465,14 @@ bit 3 (0x8): #define UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON 8
|
||||
<value>1</value>
|
||||
</prop>
|
||||
</node>
|
||||
<node oor:name=".uno:ThemeDialog" oor:op="replace">
|
||||
<prop oor:name="Label" oor:type="xs:string">
|
||||
<value xml:lang="en-US">Theme...</value>
|
||||
</prop>
|
||||
<prop oor:name="Properties" oor:type="xs:int">
|
||||
<value>1</value>
|
||||
</prop>
|
||||
</node>
|
||||
<node oor:name=".uno:SidebarDeck.PropertyDeck" oor:op="replace">
|
||||
<prop oor:name="Label" oor:type="xs:string">
|
||||
<value xml:lang="en-US">Open the Properties Deck</value>
|
||||
|
@ -175,6 +175,7 @@ $(eval $(call gb_Library_add_exception_objects,svx,\
|
||||
svx/source/dialog/swframeexample \
|
||||
svx/source/dialog/swframeposstrings \
|
||||
svx/source/dialog/ThemeColorValueSet \
|
||||
svx/source/dialog/ThemeDialog \
|
||||
svx/source/dialog/txencbox \
|
||||
svx/source/dialog/txenctab \
|
||||
svx/source/dialog/weldeditview \
|
||||
|
@ -142,6 +142,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\
|
||||
svx/uiconfig/ui/textcontrolchardialog \
|
||||
svx/uiconfig/ui/textcontrolparadialog \
|
||||
svx/uiconfig/ui/textunderlinecontrol \
|
||||
svx/uiconfig/ui/themedialog \
|
||||
svx/uiconfig/ui/toolbarpopover \
|
||||
svx/uiconfig/ui/xmlsecstatmenu \
|
||||
svx/uiconfig/ui/xformspage \
|
||||
|
@ -12529,6 +12529,23 @@ SfxVoidItem GraphicSizeCheck SID_GRAPHIC_SIZE_CHECK
|
||||
GroupId = SfxGroupId::Modify;
|
||||
]
|
||||
|
||||
SfxVoidItem ThemeDialog SID_THEME_DIALOG
|
||||
()
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
FastCall = FALSE,
|
||||
ReadOnlyDoc = TRUE,
|
||||
Toggle = FALSE,
|
||||
Container = FALSE,
|
||||
RecordAbsolute = FALSE,
|
||||
RecordPerSet;
|
||||
|
||||
AccelConfig = FALSE,
|
||||
MenuConfig = FALSE,
|
||||
ToolBoxConfig = FALSE,
|
||||
GroupId = SfxGroupId::Modify;
|
||||
]
|
||||
|
||||
SfxVoidItem AccessibilityCheck SID_ACCESSIBILITY_CHECK
|
||||
()
|
||||
[
|
||||
|
63
svx/source/dialog/ThemeDialog.cxx
Normal file
63
svx/source/dialog/ThemeDialog.cxx
Normal file
@ -0,0 +1,63 @@
|
||||
/* -*- 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/.
|
||||
*/
|
||||
|
||||
#include <svx/dialog/ThemeDialog.hxx>
|
||||
#include <docmodel/theme/ThemeColor.hxx>
|
||||
#include <vcl/svapp.hxx>
|
||||
|
||||
namespace svx
|
||||
{
|
||||
ThemeDialog::ThemeDialog(weld::Window* pParent, svx::Theme* pTheme,
|
||||
std::shared_ptr<IThemeColorChanger> const& pChanger)
|
||||
: GenericDialogController(pParent, "svx/ui/themedialog.ui", "ThemeDialog")
|
||||
, mpTheme(pTheme)
|
||||
, mpChanger(pChanger)
|
||||
, mxValueSetThemeColors(new svx::ThemeColorValueSet)
|
||||
, mxValueSetThemeColorsWindow(
|
||||
new weld::CustomWeld(*m_xBuilder, "valueset_theme_colors", *mxValueSetThemeColors))
|
||||
{
|
||||
mxValueSetThemeColors->SetColCount(2);
|
||||
mxValueSetThemeColors->SetLineCount(6);
|
||||
mxValueSetThemeColors->SetColor(Application::GetSettings().GetStyleSettings().GetFaceColor());
|
||||
mxValueSetThemeColors->SetDoubleClickHdl(LINK(this, ThemeDialog, DoubleClickValueSetHdl));
|
||||
|
||||
maColorSets.init();
|
||||
maColorSets.insert(*mpTheme->GetColorSet());
|
||||
|
||||
for (auto const& rColorSet : maColorSets.getColorSets())
|
||||
{
|
||||
mxValueSetThemeColors->insert(rColorSet);
|
||||
}
|
||||
|
||||
mxValueSetThemeColors->SetOptimalSize();
|
||||
|
||||
if (!maColorSets.getColorSets().empty())
|
||||
mxValueSetThemeColors->SelectItem(1); // ItemId 1, position 0
|
||||
}
|
||||
|
||||
ThemeDialog::~ThemeDialog() = default;
|
||||
|
||||
IMPL_LINK_NOARG(ThemeDialog, DoubleClickValueSetHdl, ValueSet*, void) { DoubleClickHdl(); }
|
||||
|
||||
void ThemeDialog::DoubleClickHdl()
|
||||
{
|
||||
sal_uInt32 nItemId = mxValueSetThemeColors->GetSelectedItemId();
|
||||
if (!nItemId)
|
||||
return;
|
||||
|
||||
sal_uInt32 nIndex = nItemId - 1;
|
||||
|
||||
svx::ColorSet const& rColorSet = maColorSets.getColorSet(nIndex);
|
||||
|
||||
mpChanger->apply(rColorSet);
|
||||
}
|
||||
|
||||
} // end svx namespace
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
145
svx/uiconfig/ui/themedialog.ui
Normal file
145
svx/uiconfig/ui/themedialog.ui
Normal file
@ -0,0 +1,145 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.40.0 -->
|
||||
<interface domain="svx">
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkDialog" id="ThemeDialog">
|
||||
<property name="width-request">640</property>
|
||||
<property name="height-request">480</property>
|
||||
<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="themedialog|Title">Theme</property>
|
||||
<property name="type-hint">dialog</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkBox" id="dialogBox1">
|
||||
<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="dialogButtons">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="layout-style">end</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="help">
|
||||
<property name="label" translatable="yes" context="stock">_Help</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<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>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</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>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack-type">end</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkNotebook">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="hexpand">False</property>
|
||||
<property name="vexpand">True</property>
|
||||
<child>
|
||||
<!-- n-columns=1 n-rows=1 -->
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="scroll_window">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="hexpand">False</property>
|
||||
<property name="vexpand">False</property>
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<property name="vscrollbar-policy">never</property>
|
||||
<property name="shadow-type">in</property>
|
||||
<child>
|
||||
<object class="GtkViewport">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkDrawingArea" id="valueset_theme_colors">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="tab">
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes" context="themedialog|tab-label">Colors</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="tab-fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<action-widgets>
|
||||
<action-widget response="-11">help</action-widget>
|
||||
<action-widget response="-5">ok</action-widget>
|
||||
<action-widget response="-6">cancel</action-widget>
|
||||
</action-widgets>
|
||||
</object>
|
||||
</interface>
|
@ -617,4 +617,11 @@ interface BaseTextSelection
|
||||
StateMethod = GetState;
|
||||
DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
|
||||
]
|
||||
|
||||
SID_THEME_DIALOG
|
||||
[
|
||||
ExecMethod = ExecDlg;
|
||||
StateMethod = GetState;
|
||||
DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
|
||||
]
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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)
|
||||
|
@ -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"/>
|
||||
|
@ -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"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user