summaryrefslogtreecommitdiff
path: root/chart2/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-10-27 19:13:59 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-10-27 21:43:32 +0200
commitecb7a18aef839056b038e9699d48c918102f389b (patch)
tree5b226182901da0dd79f86ea5e572cbe45fe24578 /chart2/source
parent4eecab2520d432f05bf398cff9abfdd64d55a3d9 (diff)
merge SchLegendPositionResources/LegendPositionResources back together
Change-Id: I53b5bc65313a6f5e661c3f6804db256d18037c74 Reviewed-on: https://gerrit.libreoffice.org/62437 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'chart2/source')
-rw-r--r--chart2/source/controller/dialogs/dlg_InsertLegend.cxx2
-rw-r--r--chart2/source/controller/dialogs/res_LegendPosition.cxx169
-rw-r--r--chart2/source/controller/dialogs/tp_LegendPosition.hxx2
-rw-r--r--chart2/source/controller/inc/dlg_InsertLegend.hxx2
-rw-r--r--chart2/source/controller/inc/res_LegendPosition.hxx35
5 files changed, 34 insertions, 176 deletions
diff --git a/chart2/source/controller/dialogs/dlg_InsertLegend.cxx b/chart2/source/controller/dialogs/dlg_InsertLegend.cxx
index 51b95fe3f46a..65dc9010e294 100644
--- a/chart2/source/controller/dialogs/dlg_InsertLegend.cxx
+++ b/chart2/source/controller/dialogs/dlg_InsertLegend.cxx
@@ -27,7 +27,7 @@ using namespace ::com::sun::star;
SchLegendDlg::SchLegendDlg(weld::Window* pWindow, const uno::Reference< uno::XComponentContext>& xCC)
: GenericDialogController(pWindow, "modules/schart/ui/dlg_InsertLegend.ui", "dlg_InsertLegend")
- , m_xLegendPositionResources(new SchLegendPositionResources(*m_xBuilder, xCC))
+ , m_xLegendPositionResources(new LegendPositionResources(*m_xBuilder, xCC))
{
}
diff --git a/chart2/source/controller/dialogs/res_LegendPosition.cxx b/chart2/source/controller/dialogs/res_LegendPosition.cxx
index 089bec1100fd..68e64d84f34a 100644
--- a/chart2/source/controller/dialogs/res_LegendPosition.cxx
+++ b/chart2/source/controller/dialogs/res_LegendPosition.cxx
@@ -39,6 +39,15 @@ namespace chart
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
+LegendPositionResources::LegendPositionResources(weld::Builder& rBuilder)
+ : 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();
+}
+
LegendPositionResources::LegendPositionResources(weld::Builder& rBuilder,
const uno::Reference< uno::XComponentContext >& xCC)
: m_xCC(xCC)
@@ -165,147 +174,7 @@ IMPL_LINK_NOARG(LegendPositionResources, PositionEnableHdl, weld::ToggleButton&,
m_aChangeLink.Call(nullptr);
}
-IMPL_LINK (LegendPositionResources, PositionChangeHdl, weld::ToggleButton&, rRadio, void)
-{
- //for each radio click there are coming two change events
- //first uncheck of previous button -> ignore that call
- //the second call gives the check of the new button
- if( rRadio.get_active() )
- m_aChangeLink.Call(nullptr);
-}
-
-void LegendPositionResources::SetChangeHdl( const Link<LinkParamNone*,void>& rLink )
-{
- 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"))
-{
-}
-
-SchLegendPositionResources::SchLegendPositionResources(weld::Builder& rBuilder,
- const uno::Reference< uno::XComponentContext >& xCC)
- : m_xCC(xCC)
- , m_xCbxShow(rBuilder.weld_check_button("show"))
- , 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"))
-{
- m_xCbxShow->connect_toggled(LINK(this, SchLegendPositionResources, PositionEnableHdl));
-}
-
-SchLegendPositionResources::~SchLegendPositionResources()
-{
-}
-
-void SchLegendPositionResources::writeToResources( const uno::Reference< frame::XModel >& xChartModel )
-{
- try
- {
- uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xChartModel );
- uno::Reference< beans::XPropertySet > xProp( xDiagram->getLegend(), uno::UNO_QUERY );
- if( xProp.is() )
- {
- //show
- bool bShowLegend = false;
- xProp->getPropertyValue( "Show" ) >>= bShowLegend;
- if (m_xCbxShow)
- m_xCbxShow->set_active(bShowLegend);
- PositionEnableHdl(*m_xCbxShow);
-
- //position
- chart2::LegendPosition ePos;
- xProp->getPropertyValue( "AnchorPosition" ) >>= ePos;
- switch( ePos )
- {
- case chart2::LegendPosition_LINE_START:
- m_xRbtLeft->set_active(true);
- break;
- case chart2::LegendPosition_LINE_END:
- m_xRbtRight->set_active(true);
- break;
- case chart2::LegendPosition_PAGE_START:
- m_xRbtTop->set_active(true);
- break;
- case chart2::LegendPosition_PAGE_END:
- m_xRbtBottom->set_active(true);
- break;
-
- case chart2::LegendPosition_CUSTOM:
- default:
- m_xRbtRight->set_active(true);
- break;
- }
- }
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-}
-
-void SchLegendPositionResources::writeToModel( const css::uno::Reference< frame::XModel >& xChartModel ) const
-{
- try
- {
- bool bShowLegend = m_xCbxShow && m_xCbxShow->get_active();
- ChartModel& rModel = dynamic_cast<ChartModel&>(*xChartModel.get());
- uno::Reference< beans::XPropertySet > xProp(LegendHelper::getLegend(rModel, m_xCC, bShowLegend), uno::UNO_QUERY);
- if( xProp.is() )
- {
- //show
- xProp->setPropertyValue( "Show" , uno::Any( bShowLegend ));
-
- //position
- chart2::LegendPosition eNewPos;
- css::chart::ChartLegendExpansion eExp = css::chart::ChartLegendExpansion_HIGH;
-
- if( m_xRbtLeft->get_active() )
- eNewPos = chart2::LegendPosition_LINE_START;
- else if( m_xRbtRight->get_active() )
- {
- eNewPos = chart2::LegendPosition_LINE_END;
- }
- else if( m_xRbtTop->get_active() )
- {
- eNewPos = chart2::LegendPosition_PAGE_START;
- eExp = css::chart::ChartLegendExpansion_WIDE;
- }
- else if( m_xRbtBottom->get_active() )
- {
- eNewPos = chart2::LegendPosition_PAGE_END;
- eExp = css::chart::ChartLegendExpansion_WIDE;
- }
-
- xProp->setPropertyValue( "AnchorPosition" , uno::Any( eNewPos ));
- xProp->setPropertyValue( "Expansion" , uno::Any( eExp ));
- xProp->setPropertyValue( "RelativePosition" , uno::Any());
- }
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2" );
- }
-}
-
-IMPL_LINK_NOARG(SchLegendPositionResources, PositionEnableHdl, weld::ToggleButton&, void)
-{
- bool bEnable = !m_xCbxShow || m_xCbxShow->get_active();
-
- m_xRbtLeft->set_sensitive( bEnable );
- m_xRbtTop->set_sensitive( bEnable );
- m_xRbtRight->set_sensitive( bEnable );
- m_xRbtBottom->set_sensitive( bEnable );
-}
-
-void SchLegendPositionResources::initFromItemSet( const SfxItemSet& rInAttrs )
+void LegendPositionResources::initFromItemSet( const SfxItemSet& rInAttrs )
{
const SfxPoolItem* pPoolItem = nullptr;
if( rInAttrs.GetItemState( SCHATTR_LEGEND_POS, true, &pPoolItem ) == SfxItemState::SET )
@@ -330,14 +199,14 @@ void SchLegendPositionResources::initFromItemSet( const SfxItemSet& rInAttrs )
}
}
- if (m_xCbxShow && rInAttrs.GetItemState( SCHATTR_LEGEND_SHOW, true, &pPoolItem ) == SfxItemState::SET)
+ 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
+void LegendPositionResources::writeToItemSet( SfxItemSet& rOutAttrs ) const
{
chart2::LegendPosition nLegendPosition = chart2::LegendPosition_CUSTOM;
if( m_xRbtLeft->get_active() )
@@ -353,6 +222,20 @@ void SchLegendPositionResources::writeToItemSet( SfxItemSet& rOutAttrs ) const
rOutAttrs.Put( SfxBoolItem(SCHATTR_LEGEND_SHOW, !m_xCbxShow || m_xCbxShow->get_active()) );
}
+IMPL_LINK (LegendPositionResources, PositionChangeHdl, weld::ToggleButton&, rRadio, void)
+{
+ //for each radio click there are coming two change events
+ //first uncheck of previous button -> ignore that call
+ //the second call gives the check of the new button
+ if( rRadio.get_active() )
+ m_aChangeLink.Call(nullptr);
+}
+
+void LegendPositionResources::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.hxx b/chart2/source/controller/dialogs/tp_LegendPosition.hxx
index 7e0491bfdb7e..b1c58effa821 100644
--- a/chart2/source/controller/dialogs/tp_LegendPosition.hxx
+++ b/chart2/source/controller/dialogs/tp_LegendPosition.hxx
@@ -31,7 +31,7 @@ class SchLegendPosTabPage : public SfxTabPage
{
private:
- SchLegendPositionResources m_aLegendPositionResources;
+ LegendPositionResources m_aLegendPositionResources;
std::unique_ptr<TextDirectionListBox> m_xLbTextDirection;
public:
diff --git a/chart2/source/controller/inc/dlg_InsertLegend.hxx b/chart2/source/controller/inc/dlg_InsertLegend.hxx
index 1b8ff7b4429f..a2c8e50d6172 100644
--- a/chart2/source/controller/inc/dlg_InsertLegend.hxx
+++ b/chart2/source/controller/inc/dlg_InsertLegend.hxx
@@ -34,7 +34,7 @@ namespace chart
class SchLegendDlg : public weld::GenericDialogController
{
private:
- std::unique_ptr<SchLegendPositionResources> m_xLegendPositionResources;
+ std::unique_ptr<LegendPositionResources> m_xLegendPositionResources;
public:
SchLegendDlg(weld::Window* pParent, const css::uno::Reference< css::uno::XComponentContext>& xCC);
diff --git a/chart2/source/controller/inc/res_LegendPosition.hxx b/chart2/source/controller/inc/res_LegendPosition.hxx
index c9105f7dd1af..f5e9ab9445b7 100644
--- a/chart2/source/controller/inc/res_LegendPosition.hxx
+++ b/chart2/source/controller/inc/res_LegendPosition.hxx
@@ -32,6 +32,8 @@ class LegendPositionResources final
{
public:
+ //constructor without Display checkbox
+ LegendPositionResources(weld::Builder& rBuilder);
//constructor inclusive Display checkbox
LegendPositionResources(weld::Builder& rBuilder, const css::uno::Reference<
css::uno::XComponentContext>& xCC );
@@ -40,6 +42,9 @@ 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 );
@@ -59,36 +64,6 @@ private:
std::unique_ptr<weld::RadioButton> m_xRbtBottom;
};
-
-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 );
- ~SchLegendPositionResources();
-
- 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;
-
- DECL_LINK(PositionEnableHdl, weld::ToggleButton&, void);
-
-private:
- css::uno::Reference< css::uno::XComponentContext> m_xCC;
-
- std::unique_ptr<weld::CheckButton> m_xCbxShow;
- std::unique_ptr<weld::RadioButton> m_xRbtLeft;
- std::unique_ptr<weld::RadioButton> m_xRbtRight;
- std::unique_ptr<weld::RadioButton> m_xRbtTop;
- std::unique_ptr<weld::RadioButton> m_xRbtBottom;
-};
-
} //namespace chart
#endif