summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-01-08 20:58:35 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-01-09 12:34:35 +0100
commit1f1de88b3acb388082f689229d487956bd5050b0 (patch)
tree138b99dd5c6a644308de5a1fef12cd7a4934f6e9
parent16bf838ef479b8db371dbe97335e035e2e22f6ce (diff)
weld ParaLineSpacingControl
Change-Id: Idce812f348187fd35accc69fba8bdf293e267a74 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86457 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--include/svx/ParaLineSpacingPopup.hxx2
-rw-r--r--solenv/sanitizers/ui/svx.suppr4
-rw-r--r--svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx213
-rw-r--r--svx/source/sidebar/paragraph/ParaLineSpacingControl.hxx42
-rw-r--r--svx/source/sidebar/paragraph/ParaLineSpacingPopup.cxx39
-rw-r--r--svx/uiconfig/ui/paralinespacingcontrol.ui127
6 files changed, 210 insertions, 217 deletions
diff --git a/include/svx/ParaLineSpacingPopup.hxx b/include/svx/ParaLineSpacingPopup.hxx
index 835fbb6fca23..743894ce31e0 100644
--- a/include/svx/ParaLineSpacingPopup.hxx
+++ b/include/svx/ParaLineSpacingPopup.hxx
@@ -30,6 +30,8 @@ public:
explicit SvxLineSpacingToolBoxControl( const css::uno::Reference<css::uno::XComponentContext>& rContext );
virtual ~SvxLineSpacingToolBoxControl() override;
+ virtual void SAL_CALL execute(sal_Int16 KeyModifier) override;
+
using svt::ToolboxController::createPopupWindow;
virtual VclPtr<vcl::Window> createPopupWindow( vcl::Window* pParent ) override;
diff --git a/solenv/sanitizers/ui/svx.suppr b/solenv/sanitizers/ui/svx.suppr
index 04829fc63161..5061b07311e3 100644
--- a/solenv/sanitizers/ui/svx.suppr
+++ b/solenv/sanitizers/ui/svx.suppr
@@ -49,8 +49,8 @@ svx/uiconfig/ui/oldcolorwindow.ui://GtkComboBox[@id='palette_listbox'] no-labell
svx/uiconfig/ui/oldcolorwindow.ui://GtkLabel[@id='label1'] orphan-label
svx/uiconfig/ui/optgridpage.ui://GtkLabel[@id='label4'] orphan-label
svx/uiconfig/ui/optgridpage.ui://GtkLabel[@id='label5'] orphan-label
-svx/uiconfig/ui/paralinespacingcontrol.ui://GtkSpinButton[@id='percent_box:0%'] no-labelled-by
-svx/uiconfig/ui/paralinespacingcontrol.ui://GtkSpinButton[@id='metric_box:0.00cm'] no-labelled-by
+svx/uiconfig/ui/paralinespacingcontrol.ui://GtkSpinButton[@id='percent_box'] no-labelled-by
+svx/uiconfig/ui/paralinespacingcontrol.ui://GtkSpinButton[@id='metric_box'] no-labelled-by
svx/uiconfig/ui/profileexporteddialog.ui://GtkLabel[@id='label'] orphan-label
svx/uiconfig/ui/redlinefilterpage.ui://GtkCheckButton[@id='comment'] missing-labelled-by
svx/uiconfig/ui/redlinefilterpage.ui://GtkComboBoxText[@id='actionlist'] missing-label-for
diff --git a/svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx b/svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx
index ccb4359b0ef2..6a7b7b578222 100644
--- a/svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx
+++ b/svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx
@@ -42,7 +42,7 @@
#define LINESPACE_2 200
#define LINESPACE_115 115
-// values of the mpLineDist listbox
+// values of the mxLineDist listbox
#define LLINESPACE_1 0
#define LLINESPACE_115 1
#define LLINESPACE_15 2
@@ -56,72 +56,65 @@
using namespace svx;
-ParaLineSpacingControl::ParaLineSpacingControl(SvxLineSpacingToolBoxControl* pControl, vcl::Window* pParent)
- : ToolbarPopup( pControl->getFrameInterface(), pParent, "ParaLineSpacingControl", "svx/ui/paralinespacingcontrol.ui"),
- meLNSpaceUnit(MapUnit::Map100thMM),
- mpSpacing1Button(get<PushButton>("spacing_1")),
- mpSpacing115Button(get<PushButton>("spacing_115")),
- mpSpacing15Button(get<PushButton>("spacing_15")),
- mpSpacing2Button(get<PushButton>("spacing_2")),
- mpLineDist(get<ListBox>("line_dist")),
- mpLineDistLabel(get<FixedText>("value_label")),
- mpLineDistAtPercentBox(get<MetricField>("percent_box")),
- mpLineDistAtMetricBox(get<MetricField>("metric_box")),
- mpActLineDistFld(mpLineDistAtPercentBox.get())
+ParaLineSpacingControl::ParaLineSpacingControl(SvxLineSpacingToolBoxControl* pControl, weld::Widget* pParent)
+ : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/paralinespacingcontrol.ui", "ParaLineSpacingControl")
+ , mxControl(pControl)
+ , meLNSpaceUnit(MapUnit::Map100thMM)
+ , mxSpacing1Button(m_xBuilder->weld_button("spacing_1"))
+ , mxSpacing115Button(m_xBuilder->weld_button("spacing_115"))
+ , mxSpacing15Button(m_xBuilder->weld_button("spacing_15"))
+ , mxSpacing2Button(m_xBuilder->weld_button("spacing_2"))
+ , mxLineDist(m_xBuilder->weld_combo_box("line_dist"))
+ , mxLineDistLabel(m_xBuilder->weld_label("value_label"))
+ , mxLineDistAtPercentBox(m_xBuilder->weld_metric_spin_button("percent_box", FieldUnit::PERCENT))
+ , mxLineDistAtMetricBox(m_xBuilder->weld_metric_spin_button("metric_box", FieldUnit::CM))
+ , mpActLineDistFld(mxLineDistAtPercentBox.get())
{
- Link<Button*,void> aLink = LINK(this, ParaLineSpacingControl, PredefinedValuesHandler);
- mpSpacing1Button->SetClickHdl(aLink);
- mpSpacing115Button->SetClickHdl(aLink);
- mpSpacing15Button->SetClickHdl(aLink);
- mpSpacing2Button->SetClickHdl(aLink);
-
- Link<ListBox&,void> aLink3 = LINK( this, ParaLineSpacingControl, LineSPDistHdl_Impl );
- mpLineDist->SetSelectHdl(aLink3);
+ Link<weld::Button&,void> aLink = LINK(this, ParaLineSpacingControl, PredefinedValuesHandler);
+ mxSpacing1Button->connect_clicked(aLink);
+ mxSpacing115Button->connect_clicked(aLink);
+ mxSpacing15Button->connect_clicked(aLink);
+ mxSpacing2Button->connect_clicked(aLink);
+
+ Link<weld::ComboBox&,void> aLink3 = LINK( this, ParaLineSpacingControl, LineSPDistHdl_Impl );
+ mxLineDist->connect_changed(aLink3);
SelectEntryPos(LLINESPACE_1);
- Link<Edit&,void> aLink2 = LINK( this, ParaLineSpacingControl, LineSPDistAtHdl_Impl );
- mpLineDistAtPercentBox->SetModifyHdl( aLink2 );
- mpLineDistAtMetricBox->SetModifyHdl( aLink2 );
+ Link<weld::MetricSpinButton&,void> aLink2 = LINK( this, ParaLineSpacingControl, LineSPDistAtHdl_Impl );
+ mxLineDistAtPercentBox->connect_value_changed( aLink2 );
+ mxLineDistAtMetricBox->connect_value_changed( aLink2 );
FieldUnit eUnit = FieldUnit::INCH;
const SfxPoolItem* pItem = nullptr;
- if (SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_METRIC, pItem) >= SfxItemState::DEFAULT)
+ SfxViewFrame* pCurrent = SfxViewFrame::Current();
+ if (pCurrent && pCurrent->GetBindings().GetDispatcher()->QueryState(SID_ATTR_METRIC, pItem) >= SfxItemState::DEFAULT)
eUnit = static_cast<FieldUnit>(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
else
eUnit = SfxModule::GetCurrentFieldUnit();
- SetFieldUnit(*mpLineDistAtMetricBox, eUnit);
+ SetFieldUnit(*mxLineDistAtMetricBox, eUnit);
- Initialize();
+ SyncFromDocument();
}
-ParaLineSpacingControl::~ParaLineSpacingControl()
+void ParaLineSpacingControl::GrabFocus()
{
- disposeOnce();
+ mxSpacing1Button->grab_focus();
}
-void ParaLineSpacingControl::dispose()
+ParaLineSpacingControl::~ParaLineSpacingControl()
{
- mpActLineDistFld.clear();
- mpSpacing1Button.clear();
- mpSpacing115Button.clear();
- mpSpacing15Button.clear();
- mpSpacing2Button.clear();
- mpLineDist.clear();
- mpLineDistLabel.clear();
- mpLineDistAtPercentBox.clear();
- mpLineDistAtMetricBox.clear();
- ToolbarPopup::dispose();
}
-void ParaLineSpacingControl::Initialize()
+void ParaLineSpacingControl::SyncFromDocument()
{
- const SfxPoolItem* pItem;
- SfxItemState eState = SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PARA_LINESPACE, pItem);
+ const SfxPoolItem* pItem(nullptr);
+ SfxViewFrame* pCurrent = SfxViewFrame::Current();
+ SfxItemState eState = pCurrent ? pCurrent->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PARA_LINESPACE, pItem) : SfxItemState::UNKNOWN;
const SvxLineSpacingItem* currSPItem = static_cast<const SvxLineSpacingItem*>(pItem);
- mpLineDist->Enable();
+ mxLineDist->set_sensitive(true);
if( eState >= SfxItemState::DEFAULT )
{
@@ -161,7 +154,7 @@ void ParaLineSpacingControl::Initialize()
else
{
SelectEntryPos(LLINESPACE_PROP);
- mpLineDistAtPercentBox->SetValue(mpLineDistAtPercentBox->Normalize(currSPItem->GetPropLineSpace()));
+ mxLineDistAtPercentBox->set_value(mxLineDistAtPercentBox->normalize(currSPItem->GetPropLineSpace()), FieldUnit::PERCENT);
}
}
break;
@@ -169,7 +162,7 @@ void ParaLineSpacingControl::Initialize()
case SvxInterLineSpaceRule::Fix:
{
SelectEntryPos(LLINESPACE_DURCH);
- SetMetricValue(*mpLineDistAtMetricBox, currSPItem->GetInterLineSpace(), eUnit);
+ SetMetricValue(*mxLineDistAtMetricBox, currSPItem->GetInterLineSpace(), eUnit);
}
break;
default:
@@ -180,14 +173,14 @@ void ParaLineSpacingControl::Initialize()
case SvxLineSpaceRule::Fix:
{
SelectEntryPos(LLINESPACE_FIX);
- SetMetricValue(*mpLineDistAtMetricBox, currSPItem->GetLineHeight(), eUnit);
+ SetMetricValue(*mxLineDistAtMetricBox, currSPItem->GetLineHeight(), eUnit);
}
break;
case SvxLineSpaceRule::Min:
{
SelectEntryPos(LLINESPACE_MIN);
- SetMetricValue(*mpLineDistAtMetricBox, currSPItem->GetLineHeight(), eUnit);
+ SetMetricValue(*mxLineDistAtMetricBox, currSPItem->GetLineHeight(), eUnit);
}
break;
default:
@@ -196,123 +189,123 @@ void ParaLineSpacingControl::Initialize()
}
else if( eState == SfxItemState::DISABLED )
{
- mpLineDist->Disable();
- mpLineDistLabel->Disable();
- mpActLineDistFld->Disable();
- mpActLineDistFld->SetText("");
+ mxLineDist->set_sensitive(false);
+ mxLineDistLabel->set_sensitive(false);
+ mpActLineDistFld->set_sensitive(false);
+ mpActLineDistFld->set_text("");
}
else
{
- mpLineDistLabel->Disable();
- mpActLineDistFld->Disable();
- mpActLineDistFld->SetText("");
- mpLineDist->SetNoSelection();
+ mxLineDistLabel->set_sensitive(false);
+ mpActLineDistFld->set_sensitive(false);
+ mpActLineDistFld->set_text("");
+ mxLineDist->set_active(-1);
}
- mpLineDist->SaveValue();
+ mxLineDist->save_value();
}
void ParaLineSpacingControl::UpdateMetricFields()
{
- switch (mpLineDist->GetSelectedEntryPos())
+ switch (mxLineDist->get_active())
{
case LLINESPACE_1:
case LLINESPACE_115:
case LLINESPACE_15:
case LLINESPACE_2:
- if (mpActLineDistFld == mpLineDistAtPercentBox)
- mpLineDistAtMetricBox->Hide();
+ if (mpActLineDistFld == mxLineDistAtPercentBox.get())
+ mxLineDistAtMetricBox->hide();
else
- mpLineDistAtPercentBox->Hide();
+ mxLineDistAtPercentBox->hide();
- mpLineDistLabel->Disable();
- mpActLineDistFld->Show();
- mpActLineDistFld->Disable();
- mpActLineDistFld->SetText("");
+ mxLineDistLabel->set_sensitive(false);
+ mpActLineDistFld->show();
+ mpActLineDistFld->set_sensitive(false);
+ mpActLineDistFld->set_text("");
break;
case LLINESPACE_DURCH:
- mpLineDistAtPercentBox->Hide();
+ mxLineDistAtPercentBox->hide();
- mpActLineDistFld = mpLineDistAtMetricBox.get();
- mpLineDistAtMetricBox->SetMin(0);
+ mpActLineDistFld = mxLineDistAtMetricBox.get();
+ mxLineDistAtMetricBox->set_min(0, FieldUnit::NONE);
- if (mpLineDistAtMetricBox->GetText().isEmpty())
- mpLineDistAtMetricBox->SetValue(mpLineDistAtMetricBox->Normalize(0));
+ if (mxLineDistAtMetricBox->get_text().isEmpty())
+ mxLineDistAtMetricBox->set_value(mxLineDistAtMetricBox->normalize(0), FieldUnit::NONE);
- mpLineDistLabel->Enable();
- mpActLineDistFld->Show();
- mpActLineDistFld->Enable();
+ mxLineDistLabel->set_sensitive(true);
+ mpActLineDistFld->show();
+ mpActLineDistFld->set_sensitive(true);
break;
case LLINESPACE_MIN:
- mpLineDistAtPercentBox->Hide();
+ mxLineDistAtPercentBox->hide();
- mpActLineDistFld = mpLineDistAtMetricBox.get();
- mpLineDistAtMetricBox->SetMin(0);
+ mpActLineDistFld = mxLineDistAtMetricBox.get();
+ mxLineDistAtMetricBox->set_min(0, FieldUnit::NONE);
- if (mpLineDistAtMetricBox->GetText().isEmpty())
- mpLineDistAtMetricBox->SetValue(mpLineDistAtMetricBox->Normalize(0), FieldUnit::TWIP);
+ if (mxLineDistAtMetricBox->get_text().isEmpty())
+ mxLineDistAtMetricBox->set_value(mxLineDistAtMetricBox->normalize(0), FieldUnit::TWIP);
- mpLineDistLabel->Enable();
- mpActLineDistFld->Show();
- mpActLineDistFld->Enable();
+ mxLineDistLabel->set_sensitive(true);
+ mpActLineDistFld->show();
+ mpActLineDistFld->set_sensitive(true);
break;
case LLINESPACE_PROP:
- mpLineDistAtMetricBox->Hide();
+ mxLineDistAtMetricBox->hide();
- mpActLineDistFld = mpLineDistAtPercentBox.get();
+ mpActLineDistFld = mxLineDistAtPercentBox.get();
- if (mpLineDistAtPercentBox->GetText().isEmpty())
- mpLineDistAtPercentBox->SetValue(mpLineDistAtPercentBox->Normalize(100), FieldUnit::TWIP);
+ if (mxLineDistAtPercentBox->get_text().isEmpty())
+ mxLineDistAtPercentBox->set_value(mxLineDistAtPercentBox->normalize(100), FieldUnit::TWIP);
- mpLineDistLabel->Enable();
- mpActLineDistFld->Show();
- mpActLineDistFld->Enable();
+ mxLineDistLabel->set_sensitive(true);
+ mpActLineDistFld->show();
+ mpActLineDistFld->set_sensitive(true);
break;
case LLINESPACE_FIX:
- mpLineDistAtPercentBox->Hide();
+ mxLineDistAtPercentBox->hide();
- mpActLineDistFld = mpLineDistAtMetricBox.get();
- sal_Int64 nTemp = mpLineDistAtMetricBox->GetValue();
- mpLineDistAtMetricBox->SetMin(mpLineDistAtMetricBox->Normalize(MIN_FIXED_DISTANCE), FieldUnit::TWIP);
+ mpActLineDistFld = mxLineDistAtMetricBox.get();
+ sal_Int64 nTemp = mxLineDistAtMetricBox->get_value(FieldUnit::NONE);
+ mxLineDistAtMetricBox->set_min(mxLineDistAtMetricBox->normalize(MIN_FIXED_DISTANCE), FieldUnit::TWIP);
- if (mpLineDistAtMetricBox->GetValue() != nTemp)
- SetMetricValue(*mpLineDistAtMetricBox, FIX_DIST_DEF, MapUnit::MapTwip);
+ if (mxLineDistAtMetricBox->get_value(FieldUnit::NONE) != nTemp)
+ SetMetricValue(*mxLineDistAtMetricBox, FIX_DIST_DEF, MapUnit::MapTwip);
- mpLineDistLabel->Enable();
- mpActLineDistFld->Show();
- mpActLineDistFld->Enable();
+ mxLineDistLabel->set_sensitive(true);
+ mpActLineDistFld->show();
+ mpActLineDistFld->set_sensitive(true);
break;
}
}
void ParaLineSpacingControl::SelectEntryPos(sal_Int32 nPos)
{
- mpLineDist->SelectEntryPos(nPos);
+ mxLineDist->set_active(nPos);
UpdateMetricFields();
}
-IMPL_LINK_NOARG(ParaLineSpacingControl, LineSPDistHdl_Impl, ListBox&, void)
+IMPL_LINK_NOARG(ParaLineSpacingControl, LineSPDistHdl_Impl, weld::ComboBox&, void)
{
UpdateMetricFields();
ExecuteLineSpace();
}
-IMPL_LINK_NOARG( ParaLineSpacingControl, LineSPDistAtHdl_Impl, Edit&, void )
+IMPL_LINK_NOARG( ParaLineSpacingControl, LineSPDistAtHdl_Impl, weld::MetricSpinButton&, void )
{
ExecuteLineSpace();
}
void ParaLineSpacingControl::ExecuteLineSpace()
{
- mpLineDist->SaveValue();
+ mxLineDist->save_value();
SvxLineSpacingItem aSpacing(DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE);
- const sal_Int32 nPos = mpLineDist->GetSelectedEntryPos();
+ const sal_Int32 nPos = mxLineDist->get_active();
switch ( nPos )
{
@@ -324,13 +317,13 @@ void ParaLineSpacingControl::ExecuteLineSpace()
break;
case LLINESPACE_PROP:
- SetLineSpace(aSpacing, nPos, mpLineDistAtPercentBox->Denormalize(static_cast<long>(mpLineDistAtPercentBox->GetValue())));
+ SetLineSpace(aSpacing, nPos, mxLineDistAtPercentBox->denormalize(static_cast<long>(mxLineDistAtPercentBox->get_value(FieldUnit::PERCENT))));
break;
case LLINESPACE_MIN:
case LLINESPACE_DURCH:
case LLINESPACE_FIX:
- SetLineSpace(aSpacing, nPos, GetCoreValue(*mpLineDistAtMetricBox, meLNSpaceUnit));
+ SetLineSpace(aSpacing, nPos, GetCoreValue(*mxLineDistAtMetricBox, meLNSpaceUnit));
break;
default:
@@ -388,21 +381,21 @@ void ParaLineSpacingControl::SetLineSpace(SvxLineSpacingItem& rLineSpace, sal_In
}
}
-IMPL_LINK(ParaLineSpacingControl, PredefinedValuesHandler, Button*, pControl, void)
+IMPL_LINK(ParaLineSpacingControl, PredefinedValuesHandler, weld::Button&, rControl, void)
{
- if (pControl == mpSpacing1Button)
+ if (&rControl == mxSpacing1Button.get())
{
ExecuteLineSpacing(LLINESPACE_1);
}
- else if (pControl == mpSpacing115Button)
+ else if (&rControl == mxSpacing115Button.get())
{
ExecuteLineSpacing(LLINESPACE_115);
}
- else if (pControl == mpSpacing15Button)
+ else if (&rControl == mxSpacing15Button.get())
{
ExecuteLineSpacing(LLINESPACE_15);
}
- else if (pControl == mpSpacing2Button)
+ else if (&rControl == mxSpacing2Button.get())
{
ExecuteLineSpacing(LLINESPACE_2);
}
@@ -418,7 +411,7 @@ void ParaLineSpacingControl::ExecuteLineSpacing(sal_Int32 nEntry)
SID_ATTR_PARA_LINESPACE, SfxCallMode::RECORD, { &aSpacing });
// close when the user used the buttons
- EndPopupMode();
+ mxControl->EndPopupMode();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sidebar/paragraph/ParaLineSpacingControl.hxx b/svx/source/sidebar/paragraph/ParaLineSpacingControl.hxx
index 5e7501406605..6d999159212f 100644
--- a/svx/source/sidebar/paragraph/ParaLineSpacingControl.hxx
+++ b/svx/source/sidebar/paragraph/ParaLineSpacingControl.hxx
@@ -21,42 +21,42 @@
#include <svtools/toolbarmenu.hxx>
#include <sfx2/tbxctrl.hxx>
-#include <vcl/field.hxx>
-#include <vcl/fixed.hxx>
class SvxLineSpacingItem;
-class Button;
namespace svx {
class SvxLineSpacingToolBoxControl;
-class ParaLineSpacingControl : public svtools::ToolbarPopup
+class ParaLineSpacingControl : public WeldToolbarPopup
{
public:
- explicit ParaLineSpacingControl(SvxLineSpacingToolBoxControl* pControl, vcl::Window* pParent);
+ explicit ParaLineSpacingControl(SvxLineSpacingToolBoxControl* pControl, weld::Widget* pParent);
virtual ~ParaLineSpacingControl() override;
- virtual void dispose() override;
+
+ /// Setup the widgets with values from the document.
+ void SyncFromDocument();
+
+ virtual void GrabFocus() override;
private:
+ rtl::Reference<SvxLineSpacingToolBoxControl> mxControl;
+
MapUnit meLNSpaceUnit;
- VclPtr<PushButton> mpSpacing1Button;
- VclPtr<PushButton> mpSpacing115Button;
- VclPtr<PushButton> mpSpacing15Button;
- VclPtr<PushButton> mpSpacing2Button;
+ std::unique_ptr<weld::Button> mxSpacing1Button;
+ std::unique_ptr<weld::Button> mxSpacing115Button;
+ std::unique_ptr<weld::Button> mxSpacing15Button;
+ std::unique_ptr<weld::Button> mxSpacing2Button;
- VclPtr<ListBox> mpLineDist;
+ std::unique_ptr<weld::ComboBox> mxLineDist;
- VclPtr<FixedText> mpLineDistLabel;
- VclPtr<MetricField> mpLineDistAtPercentBox;
- VclPtr<MetricField> mpLineDistAtMetricBox;
- VclPtr<Edit> mpActLineDistFld;
+ std::unique_ptr<weld::Label> mxLineDistLabel;
+ std::unique_ptr<weld::MetricSpinButton> mxLineDistAtPercentBox;
+ std::unique_ptr<weld::MetricSpinButton> mxLineDistAtMetricBox;
+ weld::MetricSpinButton* mpActLineDistFld;
private:
- /// Setup the widgets with values from the document.
- void Initialize();
-
/// Take the values from the widgets, and update the paragraph accordingly.
void ExecuteLineSpace();
@@ -72,9 +72,9 @@ private:
/// Set the entry and update the metric fields.
void SelectEntryPos(sal_Int32 nPos);
- DECL_LINK(LineSPDistHdl_Impl, ListBox&, void);
- DECL_LINK(LineSPDistAtHdl_Impl, Edit&, void);
- DECL_LINK(PredefinedValuesHandler, Button*, void);
+ DECL_LINK(LineSPDistHdl_Impl, weld::ComboBox&, void);
+ DECL_LINK(LineSPDistAtHdl_Impl, weld::MetricSpinButton&, void);
+ DECL_LINK(PredefinedValuesHandler, weld::Button&, void);
};
}
diff --git a/svx/source/sidebar/paragraph/ParaLineSpacingPopup.cxx b/svx/source/sidebar/paragraph/ParaLineSpacingPopup.cxx
index eb7d70c38b79..90099ac75511 100644
--- a/svx/source/sidebar/paragraph/ParaLineSpacingPopup.cxx
+++ b/svx/source/sidebar/paragraph/ParaLineSpacingPopup.cxx
@@ -39,13 +39,48 @@ void SvxLineSpacingToolBoxControl::initialize( const css::uno::Sequence< css::un
ToolBox* pToolBox = nullptr;
sal_uInt16 nId = 0;
- if (getToolboxId(nId, &pToolBox) && pToolBox->GetItemCommand(nId) == m_aCommandURL)
+ bool bVcl = getToolboxId(nId, &pToolBox);
+
+ weld::Widget* pParent;
+ if (pToolBox)
+ pParent = pToolBox->GetFrameWeld();
+ else
+ pParent = m_pToolbar;
+ mxPopover = std::make_unique<ParaLineSpacingControl>(this, pParent);
+
+ if (bVcl && pToolBox->GetItemCommand(nId) == m_aCommandURL)
pToolBox->SetItemBits(nId, ToolBoxItemBits::DROPDOWNONLY | pToolBox->GetItemBits(nId));
+ else if (m_pToolbar)
+ {
+ const OString aId(m_aCommandURL.toUtf8());
+ m_pToolbar->set_item_popover(aId, mxPopover->getTopLevel());
+ }
+}
+
+void SAL_CALL SvxLineSpacingToolBoxControl::execute(sal_Int16 /*KeyModifier*/)
+{
+ if (m_pToolbar)
+ {
+ // Toggle the popup also when toolbutton is activated
+ const OString aId(m_aCommandURL.toUtf8());
+ m_pToolbar->set_menu_item_active(aId, !m_pToolbar->get_menu_item_active(aId));
+ }
+ else
+ {
+ // Open the popup also when Enter key is pressed.
+ createPopupWindow();
+ }
}
VclPtr<vcl::Window> SvxLineSpacingToolBoxControl::createPopupWindow( vcl::Window* pParent )
{
- return VclPtr<ParaLineSpacingControl>::Create(this, pParent);
+ dynamic_cast<ParaLineSpacingControl&>(*mxPopover).SyncFromDocument();
+
+ mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent, mxPopover.get());
+
+ mxInterimPopover->Show();
+
+ return mxInterimPopover;
}
OUString SvxLineSpacingToolBoxControl::getImplementationName()
diff --git a/svx/uiconfig/ui/paralinespacingcontrol.ui b/svx/uiconfig/ui/paralinespacingcontrol.ui
index 2582c01394d3..1d9df96ca14a 100644
--- a/svx/uiconfig/ui/paralinespacingcontrol.ui
+++ b/svx/uiconfig/ui/paralinespacingcontrol.ui
@@ -1,64 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
<interface domain="svx">
<requires lib="gtk+" version="3.18"/>
- <object class="GtkAdjustment" id="adjustment1">
- <property name="lower">6</property>
- <property name="upper">65535</property>
- <property name="value">100</property>
- <property name="step_increment">10</property>
- <property name="page_increment">10</property>
- </object>
- <object class="GtkAdjustment" id="adjustment2">
- <property name="lower">0.01</property>
- <property name="upper">9999</property>
- <property name="value">0.5</property>
- <property name="step_increment">0.10000000000000001</property>
- <property name="page_increment">1</property>
- </object>
- <object class="GtkImage" id="image_spacing_1">
- <property name="visible">True</property>
+ <object class="GtkPopover" id="ParaLineSpacingControl">
<property name="can_focus">False</property>
- <property name="pixbuf">cmd/lc_spacepara1.png</property>
- </object>
- <object class="GtkImage" id="image_spacing_115">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_right">6</property>
- <property name="xalign">0</property>
- <property name="pixbuf">cmd/lc_spacepara1.png</property>
- <property name="icon-size">1</property>
- </object>
- <object class="GtkImage" id="image_spacing_15">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_right">6</property>
- <property name="xalign">0</property>
- <property name="pixbuf">cmd/lc_spacepara15.png</property>
- <property name="icon-size">1</property>
- </object>
- <object class="GtkImage" id="image_spacing_2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_right">6</property>
- <property name="xalign">0</property>
- <property name="pixbuf">cmd/lc_spacepara2.png</property>
- <property name="icon-size">1</property>
- </object>
- <object class="GtkWindow" id="ParaLineSpacingControl">
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
+ <property name="no_show_all">True</property>
<property name="border_width">4</property>
- <property name="resizable">False</property>
- <property name="destroy_with_parent">True</property>
- <property name="type_hint">popup-menu</property>
- <property name="skip_pager_hint">True</property>
- <property name="deletable">False</property>
<child>
- <object class="GtkGrid" id="grid2">
+ <object class="GtkGrid" id="container">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="margin_right">6</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child>
@@ -75,8 +26,6 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -93,8 +42,6 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -111,8 +58,6 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -129,15 +74,12 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame1">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="margin_left">3</property>
<property name="margin_top">6</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
@@ -159,16 +101,14 @@
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="paralinespacingcontrol|label3">Line Spacing:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">line_dist</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -176,8 +116,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
- <property name="entry_text_column">0</property>
- <property name="id_column">1</property>
<items>
<item translatable="yes" context="paralinespacingcontrol|line_dist">Single</item>
<item translatable="yes" context="paralinespacingcontrol|line_dist">1.15 Lines</item>
@@ -192,24 +130,20 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="value_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="paralinespacingcontrol|value_label">Value:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">grid1</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -219,7 +153,7 @@
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child>
- <object class="GtkSpinButton" id="percent_box:0%">
+ <object class="GtkSpinButton" id="percent_box">
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="adjustment">adjustment1</property>
@@ -227,12 +161,10 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
- <object class="GtkSpinButton" id="metric_box:0.00cm">
+ <object class="GtkSpinButton" id="metric_box">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
@@ -242,16 +174,12 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
</object>
@@ -272,11 +200,46 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
</object>
</child>
</object>
+ <object class="GtkAdjustment" id="adjustment1">
+ <property name="lower">6</property>
+ <property name="upper">65535</property>
+ <property name="value">100</property>
+ <property name="step_increment">10</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment2">
+ <property name="lower">0.01</property>
+ <property name="upper">9999</property>
+ <property name="value">0.5</property>
+ <property name="step_increment">0.10000000000000001</property>
+ <property name="page_increment">1</property>
+ </object>
+ <object class="GtkImage" id="image_spacing_1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">cmd/lc_spacepara1.png</property>
+ </object>
+ <object class="GtkImage" id="image_spacing_115">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">cmd/lc_spacepara1.png</property>
+ <property name="icon_size">1</property>
+ </object>
+ <object class="GtkImage" id="image_spacing_15">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">cmd/lc_spacepara15.png</property>
+ <property name="icon_size">1</property>
+ </object>
+ <object class="GtkImage" id="image_spacing_2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">cmd/lc_spacepara2.png</property>
+ <property name="icon_size">1</property>
+ </object>
</interface>