From dd5bf12193471f064bf7f581dd1b21783390e735 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Mon, 14 Jun 2021 09:51:44 +0300 Subject: 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 --- include/svx/svxids.hrc | 3 + .../data/org/openoffice/Office/UI/Sidebar.xcu | 33 ++++++ sc/sdi/drawsh.sdi | 2 + sc/source/ui/drawfunc/drawsh.cxx | 2 + sc/source/ui/drawfunc/drawsh2.cxx | 15 ++- sd/sdi/_drvwsh.sdi | 11 ++ sd/source/ui/view/drviews2.cxx | 2 + sd/source/ui/view/drviewsf.cxx | 12 +++ svx/Library_svx.mk | 1 + svx/UIConfig_svx.mk | 1 + svx/sdi/svx.sdi | 34 ++++++ svx/source/sidebar/PanelFactory.cxx | 5 + .../textcolumns/TextColumnsPropertyPanel.cxx | 119 +++++++++++++++++++++ .../textcolumns/TextColumnsPropertyPanel.hxx | 48 +++++++++ svx/uiconfig/ui/sidebartextcolumnspanel.ui | 107 ++++++++++++++++++ sw/sdi/drawsh.sdi | 14 +++ sw/source/uibase/shells/drawdlg.cxx | 19 +++- 17 files changed, 426 insertions(+), 2 deletions(-) create mode 100644 svx/source/sidebar/textcolumns/TextColumnsPropertyPanel.cxx create mode 100644 svx/source/sidebar/textcolumns/TextColumnsPropertyPanel.hxx create mode 100644 svx/uiconfig/ui/sidebartextcolumnspanel.ui diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc index 0627c29e1500..6b23b3176f17 100644 --- a/include/svx/svxids.hrc +++ b/include/svx/svxids.hrc @@ -438,6 +438,9 @@ class SdrAngleItem; //#define SID_SIDEBAR ( SID_SVX_START + 336 ) -> sfxsids.hrc +#define SID_ATTR_TEXTCOLUMNS_NUMBER ( SID_SVX_START + 337 ) +#define SID_ATTR_TEXTCOLUMNS_SPACING ( SID_SVX_START + 338 ) + #define SID_SB_CONNECTIONPOOLING ( SID_SVX_START + 348 ) #define SID_SB_DBREGISTEROPTIONS ( SID_SVX_START + 349 ) #define SID_BMPMASK ( SID_SVX_START + 350 ) diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu index daeecf5bbaed..6876d922072d 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu @@ -1843,6 +1843,39 @@ + + + Columns + + + TextColumnsPropertyPanel + + + PropertyDeck + + + + Calc, Draw, hidden ; + Calc, Graphic, hidden ; + Calc, Media, hidden ; + DrawImpress, Draw, hidden ; + DrawImpress, Graphic, hidden ; + DrawImpress, TextObject, hidden ; + WriterVariants, Draw, hidden ; + WriterVariants, Graphic, hidden ; + + + + private:resource/toolpanel/SvxPanelFactory/TextColumnsPropertyPanel + + + 800 + + + false + + + diff --git a/sc/sdi/drawsh.sdi b/sc/sdi/drawsh.sdi index b1d5ecec44a8..e097df04036a 100644 --- a/sc/sdi/drawsh.sdi +++ b/sc/sdi/drawsh.sdi @@ -231,6 +231,8 @@ interface TableDraw SID_ATTR_SOFTEDGE_RADIUS [ ExecMethod = ExecDrawAttr; StateMethod = GetDrawAttrState; ] SID_MOVE_SHAPE_HANDLE [ ExecMethod = ExecDrawAttr; ] + SID_ATTR_TEXTCOLUMNS_NUMBER [ ExecMethod = ExecDrawAttr; StateMethod = GetDrawAttrState; ] + SID_ATTR_TEXTCOLUMNS_SPACING [ ExecMethod = ExecDrawAttr; StateMethod = GetDrawAttrState; ] } diff --git a/sc/source/ui/drawfunc/drawsh.cxx b/sc/source/ui/drawfunc/drawsh.cxx index f60fba27b4d2..2be55f8100ab 100644 --- a/sc/source/ui/drawfunc/drawsh.cxx +++ b/sc/source/ui/drawfunc/drawsh.cxx @@ -417,6 +417,8 @@ void ScDrawShell::ExecDrawAttr( SfxRequest& rReq ) case SID_ATTR_GLOW_RADIUS: case SID_ATTR_GLOW_TRANSPARENCY: case SID_ATTR_SOFTEDGE_RADIUS: + case SID_ATTR_TEXTCOLUMNS_NUMBER: + case SID_ATTR_TEXTCOLUMNS_SPACING: if (const SfxItemSet* pNewArgs = rReq.GetArgs()) pView->SetAttrToMarked(*pNewArgs, false); rReq.Done(); diff --git a/sc/source/ui/drawfunc/drawsh2.cxx b/sc/source/ui/drawfunc/drawsh2.cxx index 22f28e52efe8..82609b657959 100644 --- a/sc/source/ui/drawfunc/drawsh2.cxx +++ b/sc/source/ui/drawfunc/drawsh2.cxx @@ -389,7 +389,20 @@ void ScDrawShell::GetDrawAttrState( SfxItemSet& rSet ) if( bHasMarked ) { - rSet.Put( pDrView->GetAttrFromMarked(false), false ); + SfxAllItemSet aSet(pDrView->GetAttrFromMarked(false)); + if (const SfxPoolItem * pItem; + aSet.GetItemState(SDRATTR_TEXTCOLUMNS_NUMBER, false, &pItem) >= SfxItemState::DEFAULT + && pItem) + { + aSet.Put(pItem->CloneSetWhich(SID_ATTR_TEXTCOLUMNS_NUMBER)); + } + if (const SfxPoolItem * pItem; + aSet.GetItemState(SDRATTR_TEXTCOLUMNS_SPACING, false, &pItem) >= SfxItemState::DEFAULT + && pItem) + { + aSet.Put(pItem->CloneSetWhich(SID_ATTR_TEXTCOLUMNS_SPACING)); + } + rSet.Put(aSet, false); } else { diff --git a/sd/sdi/_drvwsh.sdi b/sd/sdi/_drvwsh.sdi index bbbfdaabc332..7060d8dd6434 100644 --- a/sd/sdi/_drvwsh.sdi +++ b/sd/sdi/_drvwsh.sdi @@ -2927,4 +2927,15 @@ interface DrawView [ ExecMethod = FuTemporary ; ] + SID_ATTR_TEXTCOLUMNS_NUMBER + [ + ExecMethod = FuTemporary; + StateMethod = GetAttrState; + ] + SID_ATTR_TEXTCOLUMNS_SPACING + [ + ExecMethod = FuTemporary; + StateMethod = GetAttrState; + ] + } diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 094cbb806d2b..5a68e30abab9 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -3538,6 +3538,8 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) case SID_ATTR_GLOW_RADIUS: case SID_ATTR_GLOW_TRANSPARENCY: case SID_ATTR_SOFTEDGE_RADIUS: + case SID_ATTR_TEXTCOLUMNS_NUMBER: + case SID_ATTR_TEXTCOLUMNS_SPACING: if (const SfxItemSet* pNewArgs = rReq.GetArgs()) mpDrawView->SetAttributes(*pNewArgs); rReq.Done(); diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx index 23bdffa57239..3afa8848ef2b 100644 --- a/sd/source/ui/view/drviewsf.cxx +++ b/sd/source/ui/view/drviewsf.cxx @@ -444,6 +444,18 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet ) } break; + case SID_ATTR_TEXTCOLUMNS_NUMBER: + case SID_ATTR_TEXTCOLUMNS_SPACING: + { + SfxItemSet aAttrs(GetDoc()->GetPool()); + mpDrawView->GetAttributes(aAttrs); + const sal_uInt16 nActWhich = nSlotId == SID_ATTR_TEXTCOLUMNS_NUMBER + ? SDRATTR_TEXTCOLUMNS_NUMBER + : SDRATTR_TEXTCOLUMNS_SPACING; + rSet.Put(aAttrs.Get(nActWhich).CloneSetWhich(nSlotId)); + } + break; + case SID_HYPHENATION: { SfxItemSet aAttrs( GetDoc()->GetPool() ); 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 #if HAVE_FEATURE_AVMEDIA #include "media/MediaPlaybackPanel.hxx" @@ -192,6 +193,10 @@ Reference SAL_CALL PanelFactory::createUIElement ( xControl = std::make_unique(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 + +#include "TextColumnsPropertyPanel.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +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(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(pState)) + SetMetricValue(*m_xColumnsSpacing, pItem->GetValue(), aUnit); + } + break; + } +} + +std::unique_ptr 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(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 +#include + +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 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 m_xColumnsNumber; + std::unique_ptr 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 @@ + + + + + + 1 + + 16 + 1 + 10 + + + 0 + 2147483647 + 1 + 10 + + + + True + False + + + + True + False + True + 6 + 3 + 12 + + + True + False + _Number of columns: + True + FLD_COL_NUMBER + 0 + + + 0 + 0 + + + + + True + False + _Spacing: + True + MTR_FLD_COL_SPACING + 0 + + + 0 + 1 + + + + + True + True + True + True + True + adjustmentColNumber + 1 + + + Enter the number of columns to use for the text. + + + + + 1 + 0 + + + + + True + True + True + True + True + adjustmentColSpacing + 2 + + + Enter the amount of space to leave between the columns. + + + + + 1 + 1 + + + + + False + True + 0 + + + + diff --git a/sw/sdi/drawsh.sdi b/sw/sdi/drawsh.sdi index a4e999872e48..6655b6fb2eda 100644 --- a/sw/sdi/drawsh.sdi +++ b/sw/sdi/drawsh.sdi @@ -421,6 +421,20 @@ interface TextDraw : TextDrawBase [ StateMethod = StateDisableItems ; ] + + SID_ATTR_TEXTCOLUMNS_NUMBER + [ + ExecMethod = ExecDrawAttrArgs ; + StateMethod = GetDrawAttrState ; + DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; + ] + + SID_ATTR_TEXTCOLUMNS_SPACING + [ + ExecMethod = ExecDrawAttrArgs ; + StateMethod = GetDrawAttrState ; + DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; + ] } shell SwDrawShell : SwDrawBaseShell diff --git a/sw/source/uibase/shells/drawdlg.cxx b/sw/source/uibase/shells/drawdlg.cxx index 47b4064642e0..b18ce9327b68 100644 --- a/sw/source/uibase/shells/drawdlg.cxx +++ b/sw/source/uibase/shells/drawdlg.cxx @@ -368,7 +368,24 @@ void SwDrawShell::GetDrawAttrState(SfxItemSet& rSet) if( !bDisable ) { - pSdrView->GetAttributes( rSet ); + SfxItemSet aSet(rSet); + aSet.MergeRange(SDRATTR_TEXTCOLUMNS_NUMBER, SDRATTR_TEXTCOLUMNS_SPACING); + pSdrView->GetAttributes(aSet); + if (const SfxPoolItem * pItem; + aSet.GetItemState(SDRATTR_TEXTCOLUMNS_NUMBER, false, &pItem) + >= SfxItemState::DEFAULT + && pItem) + { + aSet.Put(pItem->CloneSetWhich(SID_ATTR_TEXTCOLUMNS_NUMBER)); + } + if (const SfxPoolItem * pItem; + aSet.GetItemState(SDRATTR_TEXTCOLUMNS_SPACING, false, &pItem) + >= SfxItemState::DEFAULT + && pItem) + { + aSet.Put(pItem->CloneSetWhich(SID_ATTR_TEXTCOLUMNS_SPACING)); + } + rSet.Put(aSet, false); if (comphelper::LibreOfficeKit::isActive()) lcl_unifyFillTransparencyItems(rSet); } -- cgit v1.2.3