summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-12-14 09:55:45 +0100
committerMiklos Vajna <vmiklos@collabora.com>2022-06-29 09:05:40 +0200
commit5b63e62271b36b2109d35961acfca29546c13e59 (patch)
treedd45fc4d4fa17d74c53864b6bdebda3099f724e9 /cui
parent8259a1ac609aaed4cea9c1d4e77c99d50037d287 (diff)
sd: add initial theme UI for master slides
Click Sidebar -> properties -> slide -> master view, then launch the Slide -> Slide properties menu item, this adds a new Theme tab page there. This is just an initial UI, only the theme name can be edited as a start. (cherry picked from commit 64fcf278830a33114f0fa5884767f24edf32cb12) Change-Id: Ia2faa828c57a0e858881fb8640431f046b5739a8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136529 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'cui')
-rw-r--r--cui/Library_cui.mk1
-rw-r--r--cui/Module_cui.mk1
-rw-r--r--cui/UIConfig_cui.mk1
-rw-r--r--cui/UITest_cui_tabpages.mk16
-rw-r--r--cui/qa/uitest/tabpages/themepage.py47
-rw-r--r--cui/source/factory/dlgfact.cxx5
-rw-r--r--cui/source/inc/themepage.hxx38
-rw-r--r--cui/source/tabpages/themepage.cxx95
-rw-r--r--cui/uiconfig/ui/themetabpage.ui72
9 files changed, 276 insertions, 0 deletions
diff --git a/cui/Library_cui.mk b/cui/Library_cui.mk
index 1e8023cc819c..d455a64ab266 100644
--- a/cui/Library_cui.mk
+++ b/cui/Library_cui.mk
@@ -219,6 +219,7 @@ $(eval $(call gb_Library_add_exception_objects,cui,\
cui/source/tabpages/textanim \
cui/source/tabpages/textattr \
cui/source/tabpages/TextColumnsPage \
+ cui/source/tabpages/themepage \
cui/source/tabpages/tparea \
cui/source/tabpages/tpbitmap \
cui/source/tabpages/tpcolor \
diff --git a/cui/Module_cui.mk b/cui/Module_cui.mk
index e4ff28c8fabe..53492ef291a4 100644
--- a/cui/Module_cui.mk
+++ b/cui/Module_cui.mk
@@ -29,6 +29,7 @@ $(eval $(call gb_Module_add_screenshot_targets,cui,\
$(eval $(call gb_Module_add_uicheck_targets,cui,\
UITest_cui_dialogs \
+ UITest_cui_tabpages \
))
# vim: set noet sw=4 ts=4:
diff --git a/cui/UIConfig_cui.mk b/cui/UIConfig_cui.mk
index a4ad452bdfee..806779daaa9d 100644
--- a/cui/UIConfig_cui.mk
+++ b/cui/UIConfig_cui.mk
@@ -213,6 +213,7 @@ $(eval $(call gb_UIConfig_add_uifiles,cui,\
cui/uiconfig/ui/textcolumnstabpage \
cui/uiconfig/ui/textdialog \
cui/uiconfig/ui/textflowpage \
+ cui/uiconfig/ui/themetabpage \
cui/uiconfig/ui/thesaurus \
cui/uiconfig/ui/toolbarmodedialog \
cui/uiconfig/ui/transparencytabpage \
diff --git a/cui/UITest_cui_tabpages.mk b/cui/UITest_cui_tabpages.mk
new file mode 100644
index 000000000000..4458e9859e23
--- /dev/null
+++ b/cui/UITest_cui_tabpages.mk
@@ -0,0 +1,16 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_UITest_UITest,cui_tabpages))
+
+$(eval $(call gb_UITest_add_modules,cui_tabpages,$(SRCDIR)/cui/qa/uitest,\
+ tabpages/ \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/cui/qa/uitest/tabpages/themepage.py b/cui/qa/uitest/tabpages/themepage.py
new file mode 100644
index 000000000000..eb97205d19ab
--- /dev/null
+++ b/cui/qa/uitest/tabpages/themepage.py
@@ -0,0 +1,47 @@
+#
+# 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/.
+#
+
+from libreoffice.uno.propertyvalue import convert_property_values_to_dict
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.framework import UITestCase
+from uitest.uihelper.common import get_state_as_dict
+from uitest.uihelper.common import select_pos
+
+# Test for cui/source/tabpages/themepage.cxx.
+class Test(UITestCase):
+
+ def testThemePage(self):
+ # Given an Impress document with a master page that has a theme:
+ with self.ui_test.create_doc_in_start_center("impress") as component:
+ template = self.xUITest.getTopFocusWindow()
+ self.ui_test.close_dialog_through_button(template.getChild("close"))
+ doc = self.xUITest.getTopFocusWindow()
+ editWin = doc.getChild("impress_win")
+ drawPage = component.getDrawPages().getByIndex(0)
+ master = drawPage.MasterPage
+ theme = mkPropertyValues({
+ "Name": "nameA"
+ })
+ master.Theme = theme
+
+ # When changing the name of the theme:
+ self.xUITest.executeCommand(".uno:SlideMasterPage")
+ with self.ui_test.execute_dialog_through_command(".uno:PageSetup") as xDialog:
+ xTabs = xDialog.getChild("tabcontrol")
+ # Select RID_SVXPAGE_THEME.
+ select_pos(xTabs, "3")
+ themeName = xDialog.getChild("themeName")
+ themeName.executeAction("TYPE", mkPropertyValues({"TEXT": "nameB"}))
+
+ # Then make sure the doc model is updated accordingly:
+ # Without the accompanying fix in place, this test would have failed with:
+ # AssertionError: 'nameA' != 'nameB'
+ # i.e. the UI didn't update the theme name.
+ theme = convert_property_values_to_dict(master.Theme)
+ self.assertEqual(theme["Name"], "nameB")
+
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index 4496b8e8799d..8cb265781907 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -93,6 +93,7 @@
#include <DiagramDialog.hxx>
#include <fileextcheckdlg.hxx>
#include <TextColumnsPage.hxx>
+#include <themepage.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::frame;
@@ -1291,6 +1292,8 @@ CreateTabPage AbstractDialogFactory_Impl::GetTabPageCreatorFunc( sal_uInt16 nId
return SfxMacroTabPage::Create;
case RID_SVXPAGE_TEXTCOLUMNS:
return SvxTextColumnsPage::Create;
+ case RID_SVXPAGE_THEME:
+ return SvxThemePage::Create;
default:
break;
}
@@ -1356,6 +1359,8 @@ GetTabPageRanges AbstractDialogFactory_Impl::GetTabPageRangesFunc( sal_uInt16 nI
return SvxAsianLayoutPage::GetRanges;
case RID_SVXPAGE_TEXTCOLUMNS:
return SvxTextColumnsPage::GetRanges;
+ case RID_SVXPAGE_THEME:
+ return SvxThemePage::GetRanges;
default:
break;
}
diff --git a/cui/source/inc/themepage.hxx b/cui/source/inc/themepage.hxx
new file mode 100644
index 000000000000..6596cd227244
--- /dev/null
+++ b/cui/source/inc/themepage.hxx
@@ -0,0 +1,38 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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 <sal/config.h>
+
+#include <sfx2/tabdlg.hxx>
+
+#include <memory>
+
+/// Tab page for themes
+class SvxThemePage : public SfxTabPage
+{
+ static const WhichRangesContainer m_pRanges;
+
+ std::unique_ptr<weld::Entry> m_xThemeName;
+
+public:
+ SvxThemePage(weld::Container* pPage, weld::DialogController* pController,
+ const SfxItemSet& rInAttrs);
+ virtual ~SvxThemePage() override;
+
+ static std::unique_ptr<SfxTabPage>
+ Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet*);
+ static WhichRangesContainer GetRanges() { return m_pRanges; }
+
+ virtual bool FillItemSet(SfxItemSet*) override;
+ virtual void Reset(const SfxItemSet*) override;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/cui/source/tabpages/themepage.cxx b/cui/source/tabpages/themepage.cxx
new file mode 100644
index 000000000000..4c2cd18716b9
--- /dev/null
+++ b/cui/source/tabpages/themepage.cxx
@@ -0,0 +1,95 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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 <sal/config.h>
+
+#include <com/sun/star/beans/PropertyValues.hpp>
+
+#include <comphelper/sequenceashashmap.hxx>
+#include <editeng/editids.hrc>
+#include <sal/log.hxx>
+#include <svl/grabbagitem.hxx>
+
+#include <themepage.hxx>
+
+using namespace com::sun::star;
+
+const WhichRangesContainer
+ SvxThemePage::m_pRanges(svl::Items<SID_ATTR_CHAR_GRABBAG, SID_ATTR_CHAR_GRABBAG>);
+
+SvxThemePage::SvxThemePage(weld::Container* pPage, weld::DialogController* pController,
+ const SfxItemSet& rInAttrs)
+ : SfxTabPage(pPage, pController, "cui/ui/themetabpage.ui", "ThemePage", &rInAttrs)
+ , m_xThemeName(m_xBuilder->weld_entry("themeName"))
+{
+}
+
+SvxThemePage::~SvxThemePage() = default;
+
+void SvxThemePage::Reset(const SfxItemSet* pAttrs)
+{
+ const SfxPoolItem* pItem = nullptr;
+ if (!pAttrs->HasItem(SID_ATTR_CHAR_GRABBAG, &pItem))
+ {
+ SAL_WARN("cui.tabpages", "SvxThemePage::Reset: no SfxGrabBagItem");
+ return;
+ }
+
+ const auto& rGrabBagItem = static_cast<const SfxGrabBagItem&>(*pItem);
+ auto itTheme = rGrabBagItem.GetGrabBag().find("Theme");
+ if (itTheme == rGrabBagItem.GetGrabBag().end())
+ {
+ SAL_WARN("cui.tabpages", "SvxThemePage::Reset: no Theme");
+ return;
+ }
+
+ comphelper::SequenceAsHashMap aMap(itTheme->second);
+ auto it = aMap.find("Name");
+ if (it != aMap.end())
+ {
+ OUString aName;
+ it->second >>= aName;
+ m_xThemeName->set_text(aName);
+ }
+}
+
+bool SvxThemePage::FillItemSet(SfxItemSet* pAttrs)
+{
+ const SfxItemSet& rOldSet = GetItemSet();
+
+ if (rOldSet.HasItem(SID_ATTR_CHAR_GRABBAG))
+ {
+ SfxGrabBagItem aGrabBagItem(
+ static_cast<const SfxGrabBagItem&>(rOldSet.Get(SID_ATTR_CHAR_GRABBAG)));
+
+ comphelper::SequenceAsHashMap aMap;
+ auto it = aGrabBagItem.GetGrabBag().find("Theme");
+ if (it != aGrabBagItem.GetGrabBag().end())
+ {
+ aMap << it->second;
+ }
+
+ aMap["Name"] <<= m_xThemeName->get_text();
+
+ beans::PropertyValues aTheme = aMap.getAsConstPropertyValueList();
+ aGrabBagItem.GetGrabBag()["Theme"] <<= aTheme;
+ pAttrs->Put(aGrabBagItem);
+ }
+
+ return true;
+}
+
+std::unique_ptr<SfxTabPage> SvxThemePage::Create(weld::Container* pPage,
+ weld::DialogController* pController,
+ const SfxItemSet* rAttrs)
+{
+ return std::make_unique<SvxThemePage>(pPage, pController, *rAttrs);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/cui/uiconfig/ui/themetabpage.ui b/cui/uiconfig/ui/themetabpage.ui
new file mode 100644
index 000000000000..c94c6093958b
--- /dev/null
+++ b/cui/uiconfig/ui/themetabpage.ui
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface domain="cui">
+ <requires lib="gtk+" version="3.20"/>
+ <object class="GtkBox" id="ThemePage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">6</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkFrame" id="frmGeneral">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkGrid" id="gdGeneral">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_start">6</property>
+ <property name="margin_end">6</property>
+ <property name="row_spacing">3</property>
+ <property name="column_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="lbThemeName">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="themetabpage|lbThemeName">Name:</property>
+ <accessibility>
+ <relation type="label-for" target="themeName"/>
+ </accessibility>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="themeName">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <accessibility>
+ <relation type="labelled-by" target="lbThemeName"/>
+ </accessibility>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="general">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="themetabpage|general">General</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+</interface>