diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-06-14 09:51:44 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-06-15 10:30:53 +0200 |
commit | dd5bf12193471f064bf7f581dd1b21783390e735 (patch) | |
tree | 08fe1f42c67ef57eea478ac76c94aab519ac2169 /svx | |
parent | 2bccb7e67b637c6312a0df610f870c8621eb296f (diff) |
editengine-columns: add sidebar property panel
Change-Id: I90aefc10f9ddddeb64a65799480777bc4287abae
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117107
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/Library_svx.mk | 1 | ||||
-rw-r--r-- | svx/UIConfig_svx.mk | 1 | ||||
-rw-r--r-- | svx/sdi/svx.sdi | 34 | ||||
-rw-r--r-- | svx/source/sidebar/PanelFactory.cxx | 5 | ||||
-rw-r--r-- | svx/source/sidebar/textcolumns/TextColumnsPropertyPanel.cxx | 119 | ||||
-rw-r--r-- | svx/source/sidebar/textcolumns/TextColumnsPropertyPanel.hxx | 48 | ||||
-rw-r--r-- | svx/uiconfig/ui/sidebartextcolumnspanel.ui | 107 |
7 files changed, 315 insertions, 0 deletions
diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk index 5ff8a89f6196..b6b97a76e0e6 100644 --- a/svx/Library_svx.mk +++ b/svx/Library_svx.mk @@ -211,6 +211,7 @@ $(eval $(call gb_Library_add_exception_objects,svx,\ svx/source/sidebar/possize/PosSizePropertyPanel \ svx/source/sidebar/shapes/DefaultShapesPanel \ svx/source/sidebar/shapes/ShapesUtil \ + svx/source/sidebar/textcolumns/TextColumnsPropertyPanel \ svx/source/sidebar/tools/ValueSetWithTextControl \ svx/source/stbctrls/pszctrl \ svx/source/stbctrls/insctrl \ diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk index d2471496c956..d7343541b2fe 100644 --- a/svx/UIConfig_svx.mk +++ b/svx/UIConfig_svx.mk @@ -130,6 +130,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\ svx/uiconfig/ui/sidebarlists \ svx/uiconfig/ui/sidebarpossize \ svx/uiconfig/ui/sidebarstylespanel \ + svx/uiconfig/ui/sidebartextcolumnspanel \ svx/uiconfig/ui/sidebartextpanel \ svx/uiconfig/ui/stylemenu \ svx/uiconfig/ui/surfacewindow \ diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi index 7093e9cd9e0b..4cb657ee48b5 100644 --- a/svx/sdi/svx.sdi +++ b/svx/sdi/svx.sdi @@ -12511,3 +12511,37 @@ SfxVoidItem MoveShapeHandle SID_MOVE_SHAPE_HANDLE ToolBoxConfig = FALSE, GroupId = SfxGroupId::Format; ] + +SfxInt16Item TextColumnsNumber SID_ATTR_TEXTCOLUMNS_NUMBER + +[ + AutoUpdate = TRUE, + FastCall = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + AccelConfig = FALSE, + MenuConfig = FALSE, + ToolBoxConfig = FALSE, + GroupId = SfxGroupId::Format; +] + +SdrMetricItem TextColumnsSpacing SID_ATTR_TEXTCOLUMNS_SPACING + +[ + AutoUpdate = TRUE, + FastCall = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + AccelConfig = FALSE, + MenuConfig = FALSE, + ToolBoxConfig = FALSE, + GroupId = SfxGroupId::Format; +] diff --git a/svx/source/sidebar/PanelFactory.cxx b/svx/source/sidebar/PanelFactory.cxx index 1817088fc534..163414ef4798 100644 --- a/svx/source/sidebar/PanelFactory.cxx +++ b/svx/source/sidebar/PanelFactory.cxx @@ -30,6 +30,7 @@ #include "graphic/GraphicPropertyPanel.hxx" #include "line/LinePropertyPanel.hxx" #include "possize/PosSizePropertyPanel.hxx" +#include "textcolumns/TextColumnsPropertyPanel.hxx" #include <DefaultShapesPanel.hxx> #if HAVE_FEATURE_AVMEDIA #include "media/MediaPlaybackPanel.hxx" @@ -192,6 +193,10 @@ Reference<ui::XUIElement> SAL_CALL PanelFactory::createUIElement ( xControl = std::make_unique<EmptyPanel>(pParent); aLayoutSize = ui::LayoutSize(20,-1, 50); } + else if (rsResourceURL.endsWith("/TextColumnsPropertyPanel")) + { + xControl = TextColumnsPropertyPanel::Create(pParent, pBindings); + } if (xControl) { diff --git a/svx/source/sidebar/textcolumns/TextColumnsPropertyPanel.cxx b/svx/source/sidebar/textcolumns/TextColumnsPropertyPanel.cxx new file mode 100644 index 000000000000..c1614bed24e2 --- /dev/null +++ b/svx/source/sidebar/textcolumns/TextColumnsPropertyPanel.cxx @@ -0,0 +1,119 @@ +/* -*- 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 "TextColumnsPropertyPanel.hxx" + +#include <sfx2/app.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/module.hxx> +#include <sfx2/objsh.hxx> +#include <svtools/unitconv.hxx> +#include <svx/sdmetitm.hxx> +#include <svx/svddef.hxx> +#include <svx/svxids.hrc> +#include <svx/unoshprp.hxx> + +#include <com/sun/star/lang/IllegalArgumentException.hpp> + +namespace +{ +MapUnit GetUnit(const SfxBindings* pBindings, sal_uInt16 nWhich) +{ + assert(pBindings); + + SfxObjectShell* pSh = nullptr; + if (auto pShell = pBindings->GetDispatcher()->GetShell(0)) + pSh = pShell->GetObjectShell(); + if (!pSh) + pSh = SfxObjectShell::Current(); + SfxItemPool& rPool = pSh ? pSh->GetPool() : SfxGetpApp()->GetPool(); + return rPool.GetMetric(nWhich); +} +} + +namespace svx::sidebar +{ +TextColumnsPropertyPanel::TextColumnsPropertyPanel(weld::Widget* pParent, SfxBindings* pBindings) + : PanelLayout(pParent, "TextColumnsPropertyPanel", "svx/ui/sidebartextcolumnspanel.ui") + , mpBindings(pBindings) + , m_xColumnsNumber(m_xBuilder->weld_spin_button("FLD_COL_NUMBER")) + , m_xColumnsSpacing(m_xBuilder->weld_metric_spin_button("MTR_FLD_COL_SPACING", FieldUnit::CM)) + , maColumnsNumberController(SID_ATTR_TEXTCOLUMNS_NUMBER, *pBindings, *this) + , maColumnsSpacingController(SID_ATTR_TEXTCOLUMNS_SPACING, *pBindings, *this) +{ + m_xColumnsNumber->connect_value_changed( + LINK(this, TextColumnsPropertyPanel, ModifyColumnsNumberHdl)); + m_xColumnsSpacing->connect_value_changed( + LINK(this, TextColumnsPropertyPanel, ModifyColumnsSpacingHdl)); +} + +TextColumnsPropertyPanel::~TextColumnsPropertyPanel() +{ + maColumnsSpacingController.dispose(); + maColumnsNumberController.dispose(); + + m_xColumnsSpacing.reset(); + m_xColumnsNumber.reset(); +} + +IMPL_LINK_NOARG(TextColumnsPropertyPanel, ModifyColumnsNumberHdl, weld::SpinButton&, void) +{ + SfxInt16Item aItem(SDRATTR_TEXTCOLUMNS_NUMBER, m_xColumnsNumber->get_value()); + mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_TEXTCOLUMNS_NUMBER, SfxCallMode::RECORD, + { &aItem }); +} + +IMPL_LINK_NOARG(TextColumnsPropertyPanel, ModifyColumnsSpacingHdl, weld::MetricSpinButton&, void) +{ + const MapUnit aUnit = GetUnit(mpBindings, SDRATTR_TEXTCOLUMNS_SPACING); + SdrMetricItem aItem(SDRATTR_TEXTCOLUMNS_SPACING, GetCoreValue(*m_xColumnsSpacing, aUnit)); + mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_TEXTCOLUMNS_SPACING, SfxCallMode::RECORD, + { &aItem }); +} + +void TextColumnsPropertyPanel::NotifyItemUpdate(sal_uInt16 nSID, SfxItemState eState, + const SfxPoolItem* pState) +{ + switch (nSID) + { + case SID_ATTR_TEXTCOLUMNS_NUMBER: + if (eState >= SfxItemState::DEFAULT) + { + if (const auto pItem = dynamic_cast<const SfxInt16Item*>(pState)) + m_xColumnsNumber->set_value(pItem->GetValue()); + } + break; + case SID_ATTR_TEXTCOLUMNS_SPACING: + if (eState >= SfxItemState::DEFAULT) + { + const MapUnit aUnit = GetUnit(mpBindings, SDRATTR_TEXTCOLUMNS_SPACING); + if (const auto pItem = dynamic_cast<const SdrMetricItem*>(pState)) + SetMetricValue(*m_xColumnsSpacing, pItem->GetValue(), aUnit); + } + break; + } +} + +std::unique_ptr<PanelLayout> TextColumnsPropertyPanel::Create(weld::Widget* pParent, + SfxBindings* pBindings) +{ + if (pParent == nullptr) + throw css::lang::IllegalArgumentException( + "no parent Window given to TextColumnsPropertyPanel::Create", nullptr, 0); + if (pBindings == nullptr) + throw css::lang::IllegalArgumentException( + "no SfxBindings given to TextColumnsPropertyPanel::Create", nullptr, 2); + + return std::make_unique<TextColumnsPropertyPanel>(pParent, pBindings); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/svx/source/sidebar/textcolumns/TextColumnsPropertyPanel.hxx b/svx/source/sidebar/textcolumns/TextColumnsPropertyPanel.hxx new file mode 100644 index 000000000000..e9c27fcc6c27 --- /dev/null +++ b/svx/source/sidebar/textcolumns/TextColumnsPropertyPanel.hxx @@ -0,0 +1,48 @@ +/* -*- 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 <sfx2/sidebar/ControllerItem.hxx> +#include <sfx2/sidebar/PanelLayout.hxx> + +class ColorListBox; + +namespace svx::sidebar +{ +class TextColumnsPropertyPanel : public PanelLayout, + public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface +{ +public: + TextColumnsPropertyPanel(weld::Widget* pParent, SfxBindings* pBindings); + virtual ~TextColumnsPropertyPanel() override; + + static std::unique_ptr<PanelLayout> Create(weld::Widget* pParent, SfxBindings* pBindings); + + virtual void NotifyItemUpdate(const sal_uInt16 nSId, const SfxItemState eState, + const SfxPoolItem* pState) override; + + virtual void GetControlState(const sal_uInt16 /*nSId*/, + boost::property_tree::ptree& /*rState*/) override{}; + +private: + SfxBindings* mpBindings; + + std::unique_ptr<weld::SpinButton> m_xColumnsNumber; + std::unique_ptr<weld::MetricSpinButton> m_xColumnsSpacing; + + sfx2::sidebar::ControllerItem maColumnsNumberController; + sfx2::sidebar::ControllerItem maColumnsSpacingController; + + DECL_LINK(ModifyColumnsNumberHdl, weld::SpinButton&, void); + DECL_LINK(ModifyColumnsSpacingHdl, weld::MetricSpinButton&, void); +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/svx/uiconfig/ui/sidebartextcolumnspanel.ui b/svx/uiconfig/ui/sidebartextcolumnspanel.ui new file mode 100644 index 000000000000..42b93c64f213 --- /dev/null +++ b/svx/uiconfig/ui/sidebartextcolumnspanel.ui @@ -0,0 +1,107 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.38.2 --> +<interface domain="svx"> + <requires lib="gtk+" version="3.20"/> + <object class="GtkAdjustment" id="adjustmentColNumber"> + <property name="lower">1</property> + <!-- MSO has an upper limit of 16 in UI --> + <property name="upper">16</property> + <property name="step-increment">1</property> + <property name="page-increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustmentColSpacing"> + <property name="lower">0</property> + <property name="upper">2147483647</property> + <property name="step-increment">1</property> + <property name="page-increment">10</property> + </object> + <!-- n-columns=1 n-rows=1 --> + <object class="GtkGrid" id="TextColumnsPropertyPanel"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <child> + <!-- n-columns=2 n-rows=2 --> + <object class="GtkGrid" id="grid1"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="border-width">6</property> + <property name="row-spacing">3</property> + <property name="column-spacing">12</property> + <child> + <object class="GtkLabel" id="labelColNumber"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes" context="sidebartextcolumns|labelColNumber">_Number of columns:</property> + <property name="use-underline">True</property> + <property name="mnemonic-widget">FLD_COL_NUMBER</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="labelColSpacing"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes" context="sidebartextcolumns|labelColSpacing">_Spacing:</property> + <property name="use-underline">True</property> + <property name="mnemonic-widget">MTR_FLD_COL_SPACING</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">1</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="FLD_COL_NUMBER"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="hexpand">True</property> + <property name="activates-default">True</property> + <property name="truncate-multiline">True</property> + <property name="adjustment">adjustmentColNumber</property> + <property name="value">1</property> + <child internal-child="accessible"> + <object class="AtkObject" id="FLD_COL_NUMBER-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="sidebartextcolumns|extended_tip|FLD_COL_NUMBER">Enter the number of columns to use for the text.</property> + </object> + </child> + </object> + <packing> + <property name="left-attach">1</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="MTR_FLD_COL_SPACING"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="hexpand">True</property> + <property name="activates-default">True</property> + <property name="truncate-multiline">True</property> + <property name="adjustment">adjustmentColSpacing</property> + <property name="digits">2</property> + <child internal-child="accessible"> + <object class="AtkObject" id="MTR_FLD_COL_SPACING-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="sidebartextcolumns|extended_tip|MTR_FLD_COL_SPACING">Enter the amount of space to leave between the columns.</property> + </object> + </child> + </object> + <packing> + <property name="left-attach">1</property> + <property name="top-attach">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + </object> +</interface> |