summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-10-13 21:20:32 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-10-14 15:03:25 +0200
commit60c5c3576a3dc2907e308aa8272e90a6b2d2b38a (patch)
tree1c53689e7f6f6792fcff748a3b4e9f19cbfe8d2f
parent21a6a6832bbbb57e7d2d9f372ab7f2eec6525f22 (diff)
weld SchLegendPosTabPage
Change-Id: Iee0b2a028119d3d65eb613ce65f05c9ab3f778fc Reviewed-on: https://gerrit.libreoffice.org/61752 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--chart2/source/controller/dialogs/res_LegendPosition.cxx64
-rw-r--r--chart2/source/controller/dialogs/tp_LegendPosition.cxx25
-rw-r--r--chart2/source/controller/dialogs/tp_LegendPosition.hxx9
-rw-r--r--chart2/source/controller/inc/res_LegendPosition.hxx7
-rw-r--r--chart2/uiconfig/ui/tp_LegendPosition.ui25
5 files changed, 93 insertions, 37 deletions
diff --git a/chart2/source/controller/dialogs/res_LegendPosition.cxx b/chart2/source/controller/dialogs/res_LegendPosition.cxx
index 85750e4b6e71..0d6963266ec9 100644
--- a/chart2/source/controller/dialogs/res_LegendPosition.cxx
+++ b/chart2/source/controller/dialogs/res_LegendPosition.cxx
@@ -240,6 +240,17 @@ void LegendPositionResources::SetChangeHdl( const Link<LinkParamNone*,void>& rLi
m_aChangeLink = rLink;
}
+SchLegendPositionResources::SchLegendPositionResources(weld::Builder& rBuilder)
+ : m_xCC() // unused in this scenario
+ , m_xCbxShow() // unused in this scenario, assumed to be visible
+ , m_xRbtLeft(rBuilder.weld_radio_button("left"))
+ , m_xRbtRight(rBuilder.weld_radio_button("right"))
+ , m_xRbtTop(rBuilder.weld_radio_button("top"))
+ , m_xRbtBottom(rBuilder.weld_radio_button("bottom"))
+{
+ impl_setRadioButtonToggleHdl();
+}
+
SchLegendPositionResources::SchLegendPositionResources(weld::Builder& rBuilder,
const uno::Reference< uno::XComponentContext >& xCC)
: m_xCC(xCC)
@@ -367,6 +378,54 @@ IMPL_LINK_NOARG(SchLegendPositionResources, PositionEnableHdl, weld::ToggleButto
m_aChangeLink.Call(nullptr);
}
+void SchLegendPositionResources::initFromItemSet( const SfxItemSet& rInAttrs )
+{
+ const SfxPoolItem* pPoolItem = nullptr;
+ if( rInAttrs.GetItemState( SCHATTR_LEGEND_POS, true, &pPoolItem ) == SfxItemState::SET )
+ {
+ chart2::LegendPosition nLegendPosition = static_cast<chart2::LegendPosition>(static_cast<const SfxInt32Item*>(pPoolItem)->GetValue());
+ switch( nLegendPosition )
+ {
+ case chart2::LegendPosition_LINE_START:
+ m_xRbtLeft->set_active(true);
+ break;
+ case chart2::LegendPosition_PAGE_START:
+ m_xRbtTop->set_active(true);
+ break;
+ case chart2::LegendPosition_LINE_END:
+ m_xRbtRight->set_active(true);
+ break;
+ case chart2::LegendPosition_PAGE_END:
+ m_xRbtBottom->set_active(true);
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (m_xCbxShow && rInAttrs.GetItemState( SCHATTR_LEGEND_SHOW, true, &pPoolItem ) == SfxItemState::SET)
+ {
+ bool bShow = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
+ m_xCbxShow->set_active(bShow);
+ }
+}
+
+void SchLegendPositionResources::writeToItemSet( SfxItemSet& rOutAttrs ) const
+{
+ chart2::LegendPosition nLegendPosition = chart2::LegendPosition_CUSTOM;
+ if( m_xRbtLeft->get_active() )
+ nLegendPosition = chart2::LegendPosition_LINE_START;
+ else if( m_xRbtTop->get_active() )
+ nLegendPosition = chart2::LegendPosition_PAGE_START;
+ else if( m_xRbtRight->get_active() )
+ nLegendPosition = chart2::LegendPosition_LINE_END;
+ else if( m_xRbtBottom->get_active() )
+ nLegendPosition = chart2::LegendPosition_PAGE_END;
+ rOutAttrs.Put( SfxInt32Item(SCHATTR_LEGEND_POS, static_cast<sal_Int32>(nLegendPosition) ) );
+
+ rOutAttrs.Put( SfxBoolItem(SCHATTR_LEGEND_SHOW, !m_xCbxShow || m_xCbxShow->get_active()) );
+}
+
IMPL_LINK(SchLegendPositionResources, PositionChangeHdl, weld::ToggleButton&, rRadio, void )
{
//for each radio click there are coming two change events
@@ -376,6 +435,11 @@ IMPL_LINK(SchLegendPositionResources, PositionChangeHdl, weld::ToggleButton&, rR
m_aChangeLink.Call(nullptr);
}
+void SchLegendPositionResources::SetChangeHdl( const Link<LinkParamNone*,void>& rLink )
+{
+ m_aChangeLink = rLink;
+}
+
} //namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/dialogs/tp_LegendPosition.cxx b/chart2/source/controller/dialogs/tp_LegendPosition.cxx
index e572d8076816..a16aec38a439 100644
--- a/chart2/source/controller/dialogs/tp_LegendPosition.cxx
+++ b/chart2/source/controller/dialogs/tp_LegendPosition.cxx
@@ -28,16 +28,11 @@
namespace chart
{
-SchLegendPosTabPage::SchLegendPosTabPage(vcl::Window* pWindow, const SfxItemSet& rInAttrs)
- : SfxTabPage( pWindow
- ,"tp_LegendPosition"
- ,"modules/schart/ui/tp_LegendPosition.ui"
- , &rInAttrs )
- , m_aLegendPositionResources(*this)
+SchLegendPosTabPage::SchLegendPosTabPage(TabPageParent pWindow, const SfxItemSet& rInAttrs)
+ : SfxTabPage(pWindow, "modules/schart/ui/tp_LegendPosition.ui", "tp_LegendPosition", &rInAttrs)
+ , m_aLegendPositionResources(*m_xBuilder)
+ , m_xLbTextDirection(new SchTextDirectionListBox(m_xBuilder->weld_combo_box("LB_LEGEND_TEXTDIR")))
{
- get(m_pLbTextDirection,"LB_LEGEND_TEXTDIR");
-
- m_pLbTextDirection->SetDropDownLineCount(3);
}
SchLegendPosTabPage::~SchLegendPosTabPage()
@@ -47,22 +42,22 @@ SchLegendPosTabPage::~SchLegendPosTabPage()
void SchLegendPosTabPage::dispose()
{
- m_pLbTextDirection.clear();
+ m_xLbTextDirection.reset();
SfxTabPage::dispose();
}
-VclPtr<SfxTabPage> SchLegendPosTabPage::Create(TabPageParent pWindow, const SfxItemSet* rOutAttrs)
+VclPtr<SfxTabPage> SchLegendPosTabPage::Create(TabPageParent pParent, const SfxItemSet* rOutAttrs)
{
- return VclPtr<SchLegendPosTabPage>::Create(pWindow.pParent, *rOutAttrs);
+ return VclPtr<SchLegendPosTabPage>::Create(pParent, *rOutAttrs);
}
bool SchLegendPosTabPage::FillItemSet(SfxItemSet* rOutAttrs)
{
m_aLegendPositionResources.writeToItemSet(*rOutAttrs);
- if( m_pLbTextDirection->GetSelectedEntryCount() > 0 )
- rOutAttrs->Put( SvxFrameDirectionItem( m_pLbTextDirection->GetSelectEntryValue(), EE_PARA_WRITINGDIR ) );
+ if (m_xLbTextDirection->get_active() != -1)
+ rOutAttrs->Put(SvxFrameDirectionItem(m_xLbTextDirection->get_active_id(), EE_PARA_WRITINGDIR));
return true;
}
@@ -73,7 +68,7 @@ void SchLegendPosTabPage::Reset(const SfxItemSet* rInAttrs)
const SfxPoolItem* pPoolItem = nullptr;
if( rInAttrs->GetItemState( EE_PARA_WRITINGDIR, true, &pPoolItem ) == SfxItemState::SET )
- m_pLbTextDirection->SelectEntryValue( static_cast<const SvxFrameDirectionItem*>(pPoolItem)->GetValue() );
+ m_xLbTextDirection->set_active_id( static_cast<const SvxFrameDirectionItem*>(pPoolItem)->GetValue() );
}
} //namespace chart
diff --git a/chart2/source/controller/dialogs/tp_LegendPosition.hxx b/chart2/source/controller/dialogs/tp_LegendPosition.hxx
index 7fd77f9c877c..77d1773cf598 100644
--- a/chart2/source/controller/dialogs/tp_LegendPosition.hxx
+++ b/chart2/source/controller/dialogs/tp_LegendPosition.hxx
@@ -20,8 +20,7 @@
#define INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_TP_LEGENDPOSITION_HXX
#include <sfx2/tabdlg.hxx>
-#include <vcl/fixed.hxx>
-
+#include <vcl/weld.hxx>
#include <res_LegendPosition.hxx>
#include <TextDirectionListBox.hxx>
@@ -32,11 +31,11 @@ class SchLegendPosTabPage : public SfxTabPage
{
private:
- LegendPositionResources m_aLegendPositionResources;
- VclPtr<TextDirectionListBox> m_pLbTextDirection;
+ SchLegendPositionResources m_aLegendPositionResources;
+ std::unique_ptr<SchTextDirectionListBox> m_xLbTextDirection;
public:
- SchLegendPosTabPage(vcl::Window* pParent, const SfxItemSet& rInAttrs);
+ SchLegendPosTabPage(TabPageParent pParent, const SfxItemSet& rInAttrs);
virtual ~SchLegendPosTabPage() override;
virtual void dispose() override;
diff --git a/chart2/source/controller/inc/res_LegendPosition.hxx b/chart2/source/controller/inc/res_LegendPosition.hxx
index 9dc6f6fef230..1568781e4818 100644
--- a/chart2/source/controller/inc/res_LegendPosition.hxx
+++ b/chart2/source/controller/inc/res_LegendPosition.hxx
@@ -74,6 +74,8 @@ class SchLegendPositionResources final
{
public:
+ //constructor without Display checkbox
+ SchLegendPositionResources(weld::Builder& rBuilder);
//constructor inclusive Display checkbox
SchLegendPositionResources(weld::Builder& rBuilder, const css::uno::Reference<
css::uno::XComponentContext>& xCC );
@@ -82,6 +84,11 @@ public:
void writeToResources( const css::uno::Reference< css::frame::XModel >& xChartModel );
void writeToModel( const css::uno::Reference< css::frame::XModel >& xChartModel ) const;
+ void initFromItemSet( const SfxItemSet& rInAttrs );
+ void writeToItemSet( SfxItemSet& rOutAttrs ) const;
+
+ void SetChangeHdl( const Link<LinkParamNone*,void>& rLink );
+
DECL_LINK(PositionEnableHdl, weld::ToggleButton&, void);
DECL_LINK(PositionChangeHdl, weld::ToggleButton&, void);
diff --git a/chart2/uiconfig/ui/tp_LegendPosition.ui b/chart2/uiconfig/ui/tp_LegendPosition.ui
index 53302b506877..5ea8d662fbf6 100644
--- a/chart2/uiconfig/ui/tp_LegendPosition.ui
+++ b/chart2/uiconfig/ui/tp_LegendPosition.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
<interface domain="chart">
- <!-- interface-requires gtk+ 3.0 -->
- <!-- interface-requires LibreOffice 1.0 -->
+ <requires lib="gtk+" version="3.18"/>
<object class="GtkBox" id="tp_LegendPosition">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -34,13 +34,10 @@
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
- <property name="group">right</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>
@@ -52,13 +49,11 @@
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
- <property name="group">top</property>
+ <property name="group">left</property>
</object>
<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>
@@ -70,13 +65,11 @@
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
- <property name="group">bottom</property>
+ <property name="group">left</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>
@@ -93,8 +86,6 @@
<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>
@@ -105,8 +96,8 @@
<object class="GtkLabel" id="TXT_POSITION">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="tp_LegendPosition|TXT_POSITION">Position</property>
+ <property name="xalign">0</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
@@ -140,9 +131,9 @@
<object class="GtkLabel" id="FT_LEGEND_TEXTDIR">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="tp_LegendPosition|FT_LEGEND_TEXTDIR">Te_xt direction</property>
<property name="use_underline">True</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
@@ -151,7 +142,7 @@
</packing>
</child>
<child>
- <object class="chartcontrollerlo-TextDirectionListBox" id="LB_LEGEND_TEXTDIR">
+ <object class="GtkComboBoxText" id="LB_LEGEND_TEXTDIR">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
@@ -169,8 +160,8 @@
<object class="GtkLabel" id="TXT_ORIENTATION">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="tp_LegendPosition|TXT_ORIENTATION">Text Orientation</property>
+ <property name="xalign">0</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>