Resolves: tdf#130035 reuse toolbar for arrow styles in sidebar
Change-Id: I8fdbf97a2e3f535767f0163a87c99ead8a3198cb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87139
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/compilerplugins/clang/unusedfields.writeonly.results b/compilerplugins/clang/unusedfields.writeonly.results
index 43366b5..4f6409b 100644
--- a/compilerplugins/clang/unusedfields.writeonly.results
+++ b/compilerplugins/clang/unusedfields.writeonly.results
@@ -772,12 +772,6 @@ svx/source/sidebar/line/LinePropertyPanel.hxx:85
svx::sidebar::LinePropertyPanel maStyleControl sfx2::sidebar::ControllerItem
svx/source/sidebar/line/LinePropertyPanel.hxx:86
svx::sidebar::LinePropertyPanel maDashControl sfx2::sidebar::ControllerItem
svx/source/sidebar/line/LinePropertyPanel.hxx:88
svx::sidebar::LinePropertyPanel maStartControl sfx2::sidebar::ControllerItem
svx/source/sidebar/line/LinePropertyPanel.hxx:89
svx::sidebar::LinePropertyPanel maEndControl sfx2::sidebar::ControllerItem
svx/source/sidebar/line/LinePropertyPanel.hxx:90
svx::sidebar::LinePropertyPanel maLineEndListControl sfx2::sidebar::ControllerItem
svx/source/sidebar/line/LinePropertyPanel.hxx:91
svx::sidebar::LinePropertyPanel maLineStyleListControl sfx2::sidebar::ControllerItem
svx/source/sidebar/line/LinePropertyPanel.hxx:92
diff --git a/include/svx/sidebar/LinePropertyPanelBase.hxx b/include/svx/sidebar/LinePropertyPanelBase.hxx
index c91c2dd..1a68126 100644
--- a/include/svx/sidebar/LinePropertyPanelBase.hxx
+++ b/include/svx/sidebar/LinePropertyPanelBase.hxx
@@ -77,19 +77,15 @@ protected:
virtual void setLineJoint(const XLineJointItem* pItem) = 0;
virtual void setLineCap(const XLineCapItem* pItem) = 0;
void updateLineStyle(bool bDisabled, bool bSetOrDefault, const SfxPoolItem* pItem);
void updateLineDash(bool bDisabled, bool bSetOrDefault, const SfxPoolItem* pItem);
void updateLineTransparence(bool bDisabled, bool bSetOrDefault, const SfxPoolItem* pItem);
void updateLineWidth(bool bDisabled, bool bSetOrDefault, const SfxPoolItem* pItem);
void updateLineStart(bool bDisabled, bool bSetOrDefault, const SfxPoolItem* pItem);
void updateLineEnd(bool bDisabled, bool bSetOrDefault, const SfxPoolItem* pItem);
void updateLineJoint(bool bDisabled, bool bSetOrDefault, const SfxPoolItem* pItem);
void updateLineCap(bool bDisabled, bool bSetOrDefault, const SfxPoolItem* pItem);
void FillLineEndList();
void FillLineStyleList();
void SelectEndStyle(bool bStart);
void SelectLineStyle();
void ActivateControls();
@@ -110,8 +106,8 @@ private:
std::unique_ptr<SvxLineLB> mxLBStyle;
std::unique_ptr<weld::Label> mxFTTransparency;
std::unique_ptr<weld::MetricSpinButton> mxMFTransparent;
std::unique_ptr<SvxLineEndLB> mxLBStart;
std::unique_ptr<SvxLineEndLB> mxLBEnd;
std::unique_ptr<weld::Toolbar> mxArrowsTB;
std::unique_ptr<ToolbarUnoDispatcher> mxArrowsDispatch;
std::unique_ptr<weld::Label> mxFTEdgeStyle;
std::unique_ptr<weld::ComboBox> mxLBEdgeStyle;
std::unique_ptr<weld::Label> mxFTCapStyle;
@@ -127,10 +123,7 @@ private:
sal_uInt16 mnTrans;
MapUnit meMapUnit;
sal_Int32 mnWidthCoreValue;
XLineEndListRef mxLineEndList;
XDashListRef mxLineStyleList;
std::unique_ptr<XLineStartItem> mpStartItem;
std::unique_ptr<XLineEndItem> mpEndItem;
// images from resource
OUString maIMGNone;
diff --git a/svx/source/sidebar/line/LinePropertyPanel.cxx b/svx/source/sidebar/line/LinePropertyPanel.cxx
index 2667ffe..cf6dc55 100644
--- a/svx/source/sidebar/line/LinePropertyPanel.cxx
+++ b/svx/source/sidebar/line/LinePropertyPanel.cxx
@@ -54,9 +54,6 @@ LinePropertyPanel::LinePropertyPanel(
maStyleControl(SID_ATTR_LINE_STYLE, *pBindings, *this),
maDashControl (SID_ATTR_LINE_DASH, *pBindings, *this),
maWidthControl(SID_ATTR_LINE_WIDTH, *pBindings, *this),
maStartControl(SID_ATTR_LINE_START, *pBindings, *this),
maEndControl(SID_ATTR_LINE_END, *pBindings, *this),
maLineEndListControl(SID_LINEEND_LIST, *pBindings, *this),
maLineStyleListControl(SID_DASH_LIST, *pBindings, *this),
maTransControl(SID_ATTR_LINE_TRANSPARENCE, *pBindings, *this),
maEdgeStyle(SID_ATTR_LINE_JOINT, *pBindings, *this),
@@ -77,9 +74,6 @@ void LinePropertyPanel::dispose()
maStyleControl.dispose();
maDashControl.dispose();
maWidthControl.dispose();
maStartControl.dispose();
maEndControl.dispose();
maLineEndListControl.dispose();
maLineStyleListControl.dispose();
maTransControl.dispose();
maEdgeStyle.dispose();
@@ -133,23 +127,6 @@ void LinePropertyPanel::NotifyItemUpdate(
updateLineWidth(bDisabled, bSetOrDefault, pState);
break;
}
case SID_ATTR_LINE_START:
{
updateLineStart(bDisabled, bSetOrDefault, pState);
break;
}
case SID_ATTR_LINE_END:
{
updateLineEnd(bDisabled, bSetOrDefault, pState);
break;
}
case SID_LINEEND_LIST:
{
FillLineEndList();
SelectEndStyle(true);
SelectEndStyle(false);
break;
}
case SID_DASH_LIST:
{
FillLineStyleList();
diff --git a/svx/source/sidebar/line/LinePropertyPanel.hxx b/svx/source/sidebar/line/LinePropertyPanel.hxx
index 99c1aee..0058529 100644
--- a/svx/source/sidebar/line/LinePropertyPanel.hxx
+++ b/svx/source/sidebar/line/LinePropertyPanel.hxx
@@ -85,9 +85,6 @@ private:
sfx2::sidebar::ControllerItem maStyleControl;
sfx2::sidebar::ControllerItem maDashControl;
sfx2::sidebar::ControllerItem maWidthControl;
sfx2::sidebar::ControllerItem maStartControl;
sfx2::sidebar::ControllerItem maEndControl;
sfx2::sidebar::ControllerItem maLineEndListControl;
sfx2::sidebar::ControllerItem maLineStyleListControl;
sfx2::sidebar::ControllerItem maTransControl;
sfx2::sidebar::ControllerItem maEdgeStyle;
diff --git a/svx/source/sidebar/line/LinePropertyPanelBase.cxx b/svx/source/sidebar/line/LinePropertyPanelBase.cxx
index 91b6b69..cee744e 100644
--- a/svx/source/sidebar/line/LinePropertyPanelBase.cxx
+++ b/svx/source/sidebar/line/LinePropertyPanelBase.cxx
@@ -66,8 +66,8 @@ LinePropertyPanelBase::LinePropertyPanelBase(
mxLBStyle(new SvxLineLB(m_xBuilder->weld_combo_box("linestyle"))),
mxFTTransparency(m_xBuilder->weld_label("translabel")),
mxMFTransparent(m_xBuilder->weld_metric_spin_button("linetransparency", FieldUnit::PERCENT)),
mxLBStart(new SvxLineEndLB(m_xBuilder->weld_combo_box("beginarrowstyle"))),
mxLBEnd(new SvxLineEndLB(m_xBuilder->weld_combo_box("endarrowstyle"))),
mxArrowsTB(m_xBuilder->weld_toolbar("arrowheads")),
mxArrowsDispatch(new ToolbarUnoDispatcher(*mxArrowsTB, rxFrame)),
mxFTEdgeStyle(m_xBuilder->weld_label("cornerlabel")),
mxLBEdgeStyle(m_xBuilder->weld_combo_box("edgestyle")),
mxFTCapStyle(m_xBuilder->weld_label("caplabel")),
@@ -80,8 +80,6 @@ LinePropertyPanelBase::LinePropertyPanelBase(
mnTrans(0),
meMapUnit(MapUnit::MapMM),
mnWidthCoreValue(0),
mpStartItem(),
mpEndItem(),
maIMGNone(BMP_NONE_ICON),
mbWidthValuable(true),
mbArrowSupported(true)
@@ -104,8 +102,8 @@ void LinePropertyPanelBase::dispose()
mxLBStyle.reset();
mxFTTransparency.reset();
mxMFTransparent.reset();
mxLBStart.reset();
mxLBEnd.reset();
mxArrowsDispatch.reset();
mxArrowsTB.reset();
mxFTEdgeStyle.reset();
mxLBEdgeStyle.reset();
mxFTCapStyle.reset();
@@ -136,12 +134,6 @@ void LinePropertyPanelBase::Initialize()
mxTBWidth->set_item_icon_name(SELECTWIDTH, maIMGWidthIcon[0]);
mxTBWidth->connect_clicked(LINK(this, LinePropertyPanelBase, ToolboxWidthSelectHdl));
FillLineEndList();
SelectEndStyle(true);
SelectEndStyle(false);
mxLBStart->connect_changed( LINK( this, LinePropertyPanelBase, ChangeStartHdl ) );
mxLBEnd->connect_changed( LINK( this, LinePropertyPanelBase, ChangeEndHdl ) );
mxMFTransparent->connect_value_changed(LINK(this, LinePropertyPanelBase, ChangeTransparentHdl));
mxLBEdgeStyle->connect_changed( LINK( this, LinePropertyPanelBase, ChangeEdgeStyleHdl ) );
@@ -262,54 +254,6 @@ void LinePropertyPanelBase::updateLineWidth(bool bDisabled, bool bSetOrDefault,
SetWidthIcon();
}
void LinePropertyPanelBase::updateLineStart(bool bDisabled, bool bSetOrDefault,
const SfxPoolItem* pItem)
{
if(bDisabled)
{
mxLBStart->set_sensitive(false);
}
else
{
if (mbArrowSupported)
mxLBStart->set_sensitive(true);
}
if(bSetOrDefault && pItem)
{
mpStartItem.reset(static_cast<XLineStartItem*>(pItem->Clone()));
SelectEndStyle(true);
return;
}
mpStartItem.reset();
SelectEndStyle(true);
}
void LinePropertyPanelBase::updateLineEnd(bool bDisabled, bool bSetOrDefault,
const SfxPoolItem* pItem)
{
if(bDisabled)
{
mxLBEnd->set_sensitive(false);
}
else
{
if (mbArrowSupported)
mxLBEnd->set_sensitive(true);
}
if(bSetOrDefault && pItem)
{
mpEndItem.reset(static_cast<XLineEndItem*>(pItem->Clone()));
SelectEndStyle(false);
return;
}
mpEndItem.reset();
SelectEndStyle(false);
}
void LinePropertyPanelBase::updateLineJoint(bool bDisabled, bool bSetOrDefault,
const SfxPoolItem* pState)
{
@@ -460,34 +404,6 @@ IMPL_LINK_NOARG(LinePropertyPanelBase, ChangeLineStyleHdl, weld::ComboBox&, void
ActivateControls();
}
IMPL_LINK_NOARG(LinePropertyPanelBase, ChangeStartHdl, weld::ComboBox&, void)
{
sal_Int32 nPos = mxLBStart->get_active();
if (nPos != -1 && mxLBStart->get_value_changed_from_saved())
{
std::unique_ptr<XLineStartItem> pItem;
if( nPos == 0 )
pItem.reset(new XLineStartItem());
else if( mxLineEndList.is() && mxLineEndList->Count() > static_cast<long>( nPos - 1 ) )
pItem.reset(new XLineStartItem( mxLBStart->get_active_text(),mxLineEndList->GetLineEnd( nPos - 1 )->GetLineEnd() ));
setLineStartStyle(pItem.get());
}
}
IMPL_LINK_NOARG(LinePropertyPanelBase, ChangeEndHdl, weld::ComboBox&, void)
{
sal_Int32 nPos = mxLBEnd->get_active();
if (nPos != -1 && mxLBEnd->get_value_changed_from_saved())
{
std::unique_ptr<XLineEndItem> pItem;
if( nPos == 0 )
pItem.reset(new XLineEndItem());
else if( mxLineEndList.is() && mxLineEndList->Count() > static_cast<long>( nPos - 1 ) )
pItem.reset(new XLineEndItem( mxLBEnd->get_active_text(), mxLineEndList->GetLineEnd( nPos - 1 )->GetLineEnd() ));
setLineEndStyle(pItem.get());
}
}
IMPL_LINK_NOARG(LinePropertyPanelBase, ChangeEdgeStyleHdl, weld::ComboBox&, void)
{
const sal_Int32 nPos(mxLBEdgeStyle->get_active());
@@ -617,35 +533,6 @@ void LinePropertyPanelBase::SetWidth(long nWidth)
mxLineWidthPopup->SetWidthSelect(mnWidthCoreValue, mbWidthValuable, meMapUnit);
}
void LinePropertyPanelBase::FillLineEndList()
{
SfxObjectShell* pSh = SfxObjectShell::Current();
if ( pSh && pSh->GetItem( SID_LINEEND_LIST ) )
{
mxLBStart->set_sensitive(true);
mxLBStart->clear();
mxLBEnd->clear();
mxLineEndList = pSh->GetItem( SID_LINEEND_LIST )->GetLineEndList();
if (mxLineEndList.is())
{
OUString sNone(SvxResId(RID_SVXSTR_NONE));
mxLBStart->append_text(sNone);
mxLBStart->Fill(mxLineEndList, true);
mxLBEnd->append_text(sNone);
mxLBEnd->Fill(mxLineEndList, false);
}
mxLBStart->set_active(0);
mxLBEnd->set_active(0);
}
else
{
mxLBStart->set_sensitive(false);
mxLBEnd->set_sensitive(false);
}
}
void LinePropertyPanelBase::FillLineStyleList()
{
SfxObjectShell* pSh = SfxObjectShell::Current();
@@ -711,70 +598,6 @@ void LinePropertyPanelBase::SelectLineStyle()
ActivateControls();
}
void LinePropertyPanelBase::SelectEndStyle(bool bStart)
{
bool bSelected(false);
if(bStart)
{
if (!mpStartItem)
{
mxLBStart->set_active(-1);
mxLBStart->set_sensitive(false);
return;
}
if (mxLineEndList.is())
{
const basegfx::B2DPolyPolygon& rItemPolygon = mpStartItem->GetLineStartValue();
for(long a(0);!bSelected && a < mxLineEndList->Count(); a++)
{
const XLineEndEntry* pEntry = mxLineEndList->GetLineEnd(a);
const basegfx::B2DPolyPolygon& rEntryPolygon = pEntry->GetLineEnd();
if(rItemPolygon == rEntryPolygon)
{
mxLBStart->set_active(a + 1);
bSelected = true;
}
}
}
if(!bSelected)
{
mxLBStart->set_active( 0 );
}
}
else
{
if (!mpEndItem)
{
mxLBEnd->set_active(-1);
mxLBEnd->set_sensitive(false);
return;
}
if (mxLineEndList.is())
{
const basegfx::B2DPolyPolygon& rItemPolygon = mpEndItem->GetLineEndValue();
for(long a(0);!bSelected && a < mxLineEndList->Count(); a++)
{
const XLineEndEntry* pEntry = mxLineEndList->GetLineEnd(a);
const basegfx::B2DPolyPolygon& rEntryPolygon = pEntry->GetLineEnd();
if(rItemPolygon == rEntryPolygon)
{
mxLBEnd->set_active(a + 1);
bSelected = true;
}
}
}
if(!bSelected)
{
mxLBEnd->set_active( 0 );
}
}
}
void LinePropertyPanelBase::ActivateControls()
{
const sal_Int32 nPos(mxLBStyle->get_active());
@@ -782,8 +605,7 @@ void LinePropertyPanelBase::ActivateControls()
mxGridLineProps->set_sensitive( bLineStyle );
mxBoxArrowProps->set_sensitive( bLineStyle );
mxLBStart->set_sensitive( bLineStyle && mbArrowSupported );
mxLBEnd->set_sensitive( bLineStyle && mbArrowSupported );
mxArrowsTB->set_sensitive( bLineStyle && mbArrowSupported );
}
void LinePropertyPanelBase::setMapUnit(MapUnit eMapUnit)
diff --git a/svx/uiconfig/ui/sidebarline.ui b/svx/uiconfig/ui/sidebarline.ui
index d18b522..997255f 100644
--- a/svx/uiconfig/ui/sidebarline.ui
+++ b/svx/uiconfig/ui/sidebarline.ui
@@ -7,18 +7,6 @@
<property name="step_increment">10</property>
<property name="page_increment">20</property>
</object>
<object class="GtkListStore" id="liststore4">
<columns>
<!-- column-name text -->
<column type="gchararray"/>
<!-- column-name id -->
<column type="gchararray"/>
<!-- column-name image -->
<column type="GdkPixbuf"/>
<!-- column-name surface -->
<column type="CairoSurface"/>
</columns>
</object>
<object class="GtkListStore" id="liststore5">
<columns>
<!-- column-name text -->
@@ -31,18 +19,6 @@
<column type="CairoSurface"/>
</columns>
</object>
<object class="GtkListStore" id="liststore6">
<columns>
<!-- column-name text -->
<column type="gchararray"/>
<!-- column-name id -->
<column type="gchararray"/>
<!-- column-name image -->
<column type="GdkPixbuf"/>
<!-- column-name surface -->
<column type="CairoSurface"/>
</columns>
</object>
<object class="GtkGrid" id="LinePropertyPanel">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -64,48 +40,14 @@
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">3</property>
<child>
<object class="GtkComboBox" id="beginarrowstyle">
<property name="width_request">65</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes" context="sidebarline|beginarrowstyle|tooltip_text">Select the style of the beginning arrowhead.</property>
<property name="hexpand">True</property>
<property name="model">liststore4</property>
<property name="entry_text_column">0</property>
<property name="id_column">1</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
<child>
<object class="GtkCellRendererPixbuf" id="cellrenderertext2"/>
<attributes>
<attribute name="surface">3</attribute>
</attributes>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="beginarrowstyle-atkobject">
<property name="AtkObject::accessible-name" translatable="yes" context="sidebarline|beginarrowstyle-atkobject">Beginning Style</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="linestyle">
<property name="width_request">105</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes" context="sidebarline|linestyle|tooltip_text">Select the style of the line.</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="model">liststore5</property>
<property name="entry_text_column">0</property>
@@ -131,41 +73,39 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="endarrowstyle">
<property name="width_request">65</property>
<object class="GtkToolbar" id="arrowheads">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="model">liststore6</property>
<property name="tooltip_text" translatable="yes" context="sidebarline|endarrowstyle|tooltip_text">Select the style of the ending arrowhead.</property>
<property name="entry_text_column">0</property>
<property name="hexpand">True</property>
<property name="id_column">1</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes" context="sidebarline|arrowheads|tooltip_text">Select the style of the arrowheads.</property>
<property name="toolbar_style">icons</property>
<property name="show_arrow">False</property>
<property name="icon_size">2</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext5"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
<child>
<object class="GtkCellRendererPixbuf" id="cellrenderertext6"/>
<attributes>
<attribute name="surface">3</attribute>
</attributes>
<object class="GtkMenuToolButton" id=".uno:LineEndStyle">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes" context="sidebarline|arrowheads|tooltip_text">Select the style of the arrowheads.</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">False</property>
</packing>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="endarrowstyle-atkobject">
<property name="AtkObject::accessible-name" translatable="yes" context="sidebarline|endarrowstyle-atkobject">Ending Style</property>
<object class="AtkObject" id="arrowheads-atkobject">
<property name="AtkObject::accessible-name" context="sidebarline|arrowheads-atkobject" translatable="yes">Arrow Styles</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
<property name="position">1</property>
</packing>
</child>
</object>
@@ -306,13 +246,13 @@
</child>
<child>
<object class="GtkBox" id="arrowproperties">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="visible">True</property>
<child>
<object class="GtkGrid" id="grid5">
<property name="can_focus">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="row_spacing">6</property>
<property name="column_spacing">6</property>
<property name="column_homogeneous">True</property>