summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-04-21 18:43:03 +0900
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-04-22 12:41:15 +0900
commitb48025af032a4c252f0f4111d5a4d37e679acfad (patch)
treed53d189cb098a51296de5c321fc0965687c6d003
parentcb09f4daa018274c8d0cdd1a91b7c3038cbc8cb9 (diff)
add "Style Presets" sidebar panel (experimental) to writer
Style presets is a list of bundled & user defined styles presets that can be applied to the current document. The styles are taken from tempalte files that are in "styles" template folder. This is for now only added as an experimental feature. Change-Id: If6d1128ca7e2f61efd13bb8ae3baee5cb357d286
-rw-r--r--officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu26
-rw-r--r--sw/Library_sw.mk1
-rw-r--r--sw/UIConfig_swriter.mk1
-rw-r--r--sw/source/uibase/sidebar/StylePresetsPanel.cxx122
-rw-r--r--sw/source/uibase/sidebar/StylePresetsPanel.hxx90
-rw-r--r--sw/source/uibase/sidebar/SwPanelFactory.cxx7
-rw-r--r--sw/uiconfig/swriter/ui/sidebarstylepresets.ui43
7 files changed, 289 insertions, 1 deletions
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu
index 834364da5b65..dc4a50d1b939 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu
@@ -1002,7 +1002,31 @@
<value>100</value>
</prop>
</node>
-
+ <node oor:name="StylePresetsPanel" oor:op="replace">
+ <prop oor:name="Title" oor:type="xs:string">
+ <value xml:lang="en-US">Style Presets</value>
+ </prop>
+ <prop oor:name="Id" oor:type="xs:string">
+ <value>StylePresetsPanel</value>
+ </prop>
+ <prop oor:name="DeckId" oor:type="xs:string">
+ <value>DesignDeck</value>
+ </prop>
+ <prop oor:name="ContextList">
+ <value oor:separator=";">
+ WriterVariants, any, visible ;
+ </value>
+ </prop>
+ <prop oor:name="ImplementationURL" oor:type="xs:string">
+ <value>private:resource/toolpanel/SwPanelFactory/StylePresetsPanel</value>
+ </prop>
+ <prop oor:name="OrderIndex" oor:type="xs:int">
+ <value>1</value>
+ </prop>
+ <prop oor:name="IsExperimental" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
</node>
</node>
</oor:component-data>
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 24bde65dd1c7..76ddb5c89f8e 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -675,6 +675,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
sw/source/uibase/shells/txtattr \
sw/source/uibase/shells/txtcrsr \
sw/source/uibase/shells/txtnum \
+ sw/source/uibase/sidebar/StylePresetsPanel \
sw/source/uibase/sidebar/PageOrientationControl \
sw/source/uibase/sidebar/PageMarginControl \
sw/source/uibase/sidebar/PageSizeControl \
diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk
index 706f87644a7e..762d3ffe0c33 100644
--- a/sw/UIConfig_swriter.mk
+++ b/sw/UIConfig_swriter.mk
@@ -205,6 +205,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\
sw/uiconfig/swriter/ui/selecttabledialog \
sw/uiconfig/swriter/ui/sidebarpage \
sw/uiconfig/swriter/ui/sidebarwrap \
+ sw/uiconfig/swriter/ui/sidebarstylepresets \
sw/uiconfig/swriter/ui/sortdialog \
sw/uiconfig/swriter/ui/splittable \
sw/uiconfig/swriter/ui/statisticsinfopage \
diff --git a/sw/source/uibase/sidebar/StylePresetsPanel.cxx b/sw/source/uibase/sidebar/StylePresetsPanel.cxx
new file mode 100644
index 000000000000..ead31d610595
--- /dev/null
+++ b/sw/source/uibase/sidebar/StylePresetsPanel.cxx
@@ -0,0 +1,122 @@
+/* -*- 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 <sal/config.h>
+
+#include "StylePresetsPanel.hxx"
+
+#include <swtypes.hxx>
+#include <cmdid.h>
+
+#include <svl/intitem.hxx>
+#include <svx/svxids.hrc>
+#include <svx/dlgutil.hxx>
+#include <svx/rulritem.hxx>
+
+#include <sfx2/sidebar/ControlFactory.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/objsh.hxx>
+
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/frame/DocumentTemplates.hpp>
+#include <com/sun/star/frame/XDocumentTemplates.hpp>
+#include <com/sun/star/document/XUndoManagerSupplier.hpp>
+
+#include <sfx2/doctempl.hxx>
+
+#include "shellio.hxx"
+#include "docsh.hxx"
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/documentconstants.hxx>
+#include <comphelper/string.hxx>
+
+namespace sw { namespace sidebar {
+
+StylePresetsPanel* StylePresetsPanel::Create (vcl::Window* pParent,
+ const css::uno::Reference<css::frame::XFrame>& rxFrame,
+ SfxBindings* pBindings)
+{
+ if (pParent == NULL)
+ throw css::lang::IllegalArgumentException("no parent Window given to PagePropertyPanel::Create", NULL, 0);
+ if (!rxFrame.is())
+ throw css::lang::IllegalArgumentException("no XFrame given to PagePropertyPanel::Create", NULL, 1);
+ if (pBindings == NULL)
+ throw css::lang::IllegalArgumentException("no SfxBindings given to PagePropertyPanel::Create", NULL, 2);
+
+ return new StylePresetsPanel(pParent, rxFrame, pBindings);
+}
+
+StylePresetsPanel::StylePresetsPanel(vcl::Window* pParent,
+ const css::uno::Reference<css::frame::XFrame>& rxFrame,
+ SfxBindings* pBindings)
+ : PanelLayout(pParent, "StylePresetsPanel", "modules/swriter/ui/sidebarstylepresets.ui", rxFrame)
+ , mpBindings(pBindings)
+{
+
+ get(mpListBox, "listbox");
+
+ mpListBox->SetDoubleClickHdl(LINK(this, StylePresetsPanel, DoubleClickHdl));
+
+
+ SfxDocumentTemplates aTemplates;
+
+ sal_uInt16 nCount = aTemplates.GetRegionCount();
+ for (sal_uInt16 i = 0; i < nCount; ++i)
+ {
+ OUString aRegionName(aTemplates.GetFullRegionName(i));
+ if (aRegionName == "styles")
+ {
+ for (sal_uInt16 j = 0; j < aTemplates.GetCount(i); ++j)
+ {
+ OUString aName = aTemplates.GetName(i,j);
+ OUString aURL = aTemplates.GetPath(i,j);
+ sal_Int32 nIndex = mpListBox->InsertEntry(aName);
+ maTemplateEntries.push_back(std::unique_ptr<TemplateEntry>(new TemplateEntry(aName, aURL)));
+ mpListBox->SetEntryData(nIndex, maTemplateEntries.back().get());
+ }
+ }
+ }
+}
+
+StylePresetsPanel::~StylePresetsPanel()
+{
+}
+
+IMPL_LINK_NOARG(StylePresetsPanel, DoubleClickHdl)
+{
+ sal_Int32 nIndex = mpListBox->GetSelectEntryPos();
+ TemplateEntry* pEntry = static_cast<TemplateEntry*>(mpListBox->GetEntryData(nIndex));
+
+ SwDocShell* pDocSh = static_cast<SwDocShell*>(SfxObjectShell::Current());
+ if (pDocSh)
+ {
+ SwgReaderOption aOption;
+ aOption.SetTxtFmts(true);
+ aOption.SetNumRules(true);
+ pDocSh->LoadStylesFromFile(pEntry->maURL, aOption, false);
+ }
+
+ return 1;
+}
+
+void StylePresetsPanel::NotifyItemUpdate(const sal_uInt16 /*nSId*/,
+ const SfxItemState /*eState*/,
+ const SfxPoolItem* /*pState*/,
+ const bool /*bIsEnabled*/)
+{
+}
+
+}} // end of namespace ::sw::sidebar
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/sidebar/StylePresetsPanel.hxx b/sw/source/uibase/sidebar/StylePresetsPanel.hxx
new file mode 100644
index 000000000000..9560da8a6919
--- /dev/null
+++ b/sw/source/uibase/sidebar/StylePresetsPanel.hxx
@@ -0,0 +1,90 @@
+/* -*- 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/.
+ *
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UIBASE_SIDEBAR_STYLEPRESETSPANEL_HXX
+#define INCLUDED_SW_SOURCE_UIBASE_SIDEBAR_STYLEPRESETSPANEL_HXX
+
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/document/XUndoManager.hpp>
+
+#include <svx/sidebar/Popup.hxx>
+#include <svx/sidebar/PanelLayout.hxx>
+
+#include <sfx2/sidebar/ControllerItem.hxx>
+
+#include <svx/pageitem.hxx>
+#include <svx/rulritem.hxx>
+#include <editeng/sizeitem.hxx>
+
+#include <vcl/ctrl.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/button.hxx>
+#include <vcl/toolbox.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/field.hxx>
+#include <svl/intitem.hxx>
+#include <svl/lstner.hxx>
+
+#include <svx/fntctrl.hxx>
+
+#include "docstyle.hxx"
+
+namespace sw { namespace sidebar {
+
+class StylePresetsPanel : public PanelLayout,
+ public sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
+{
+public:
+ static StylePresetsPanel* Create(vcl::Window* pParent,
+ const css::uno::Reference<css::frame::XFrame>& rxFrame,
+ SfxBindings* pBindings);
+
+ virtual void NotifyItemUpdate(const sal_uInt16 nSId,
+ const SfxItemState eState,
+ const SfxPoolItem* pState,
+ const bool bIsEnabled) SAL_OVERRIDE;
+
+ SfxBindings* GetBindings() const
+ {
+ return mpBindings;
+ }
+
+private:
+ struct TemplateEntry
+ {
+ TemplateEntry(OUString& rName, OUString& rURL)
+ : maName(rName)
+ , maURL(rURL)
+ {}
+
+ OUString maName;
+ OUString maURL;
+ };
+
+ StylePresetsPanel(vcl::Window* pParent,
+ const css::uno::Reference<css::frame::XFrame>& rxFrame,
+ SfxBindings* pBindings);
+
+ virtual ~StylePresetsPanel();
+
+ SfxBindings* mpBindings;
+
+ ListBox* mpListBox;
+
+ std::vector<std::unique_ptr<TemplateEntry>> maTemplateEntries;
+
+ DECL_LINK(DoubleClickHdl, void*);
+};
+
+}} // end of namespace sw::sidebar
+
+#endif // INCLUDED_SW_SOURCE_UIBASE_SIDEBAR_STYLEPRESETSPANEL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/sidebar/SwPanelFactory.cxx b/sw/source/uibase/sidebar/SwPanelFactory.cxx
index 2df61c244c27..e2e04f7a84ed 100644
--- a/sw/source/uibase/sidebar/SwPanelFactory.cxx
+++ b/sw/source/uibase/sidebar/SwPanelFactory.cxx
@@ -19,6 +19,7 @@
#include <com/sun/star/ui/XUIElementFactory.hpp>
+#include <StylePresetsPanel.hxx>
#include <PagePropertyPanel.hxx>
#include <WrapPropertyPanel.hxx>
#include <navipi.hxx>
@@ -153,6 +154,12 @@ Reference<ui::XUIElement> SAL_CALL SwPanelFactory::createUIElement (
pPanel,
ui::LayoutSize(-1,-1,-1));
}
+ else if (rsResourceURL.endsWith("/StylePresetsPanel"))
+ {
+ sw::sidebar::StylePresetsPanel* pPanel = sw::sidebar::StylePresetsPanel::Create(pParentWindow, xFrame, pBindings);
+ xElement = sfx2::sidebar::SidebarPanelBase::Create(
+ rsResourceURL, xFrame, pPanel, ui::LayoutSize(-1,-1,-1));
+ }
return xElement;
}
diff --git a/sw/uiconfig/swriter/ui/sidebarstylepresets.ui b/sw/uiconfig/swriter/ui/sidebarstylepresets.ui
new file mode 100644
index 000000000000..071e9e57ec29
--- /dev/null
+++ b/sw/uiconfig/swriter/ui/sidebarstylepresets.ui
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.3 -->
+<interface>
+ <requires lib="gtk+" version="3.0"/>
+ <object class="GtkGrid" id="StylePresetsPanel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_homogeneous">True</property>
+ <property name="column_homogeneous">True</property>
+ <child>
+ <object class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkGrid" id="grid1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">6</property>
+ <child>
+ <object class="GtkTreeView" id="listbox">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="treeview-selection1"/>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ </object>
+</interface>