summaryrefslogtreecommitdiff
path: root/chart2/source/controller/dialogs/res_LegendPosition.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/controller/dialogs/res_LegendPosition.cxx')
-rw-r--r--chart2/source/controller/dialogs/res_LegendPosition.cxx76
1 files changed, 41 insertions, 35 deletions
diff --git a/chart2/source/controller/dialogs/res_LegendPosition.cxx b/chart2/source/controller/dialogs/res_LegendPosition.cxx
index 50ac0602baef..e1743886086a 100644
--- a/chart2/source/controller/dialogs/res_LegendPosition.cxx
+++ b/chart2/source/controller/dialogs/res_LegendPosition.cxx
@@ -18,9 +18,10 @@
*/
#include <res_LegendPosition.hxx>
-#include <ChartModelHelper.hxx>
+#include <Legend.hxx>
#include <LegendHelper.hxx>
#include <ChartModel.hxx>
+#include <Diagram.hxx>
#include <com/sun/star/chart2/LegendPosition.hpp>
#include <com/sun/star/chart/ChartLegendExpansion.hpp>
@@ -29,7 +30,8 @@
#include <chartview/ChartSfxItemIds.hxx>
#include <svl/intitem.hxx>
#include <svl/eitem.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
+#include <utility>
#include <vcl/weld.hxx>
namespace chart
@@ -39,22 +41,22 @@ 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"))
+ : m_xRbtLeft(rBuilder.weld_radio_button(u"left"_ustr))
+ , m_xRbtRight(rBuilder.weld_radio_button(u"right"_ustr))
+ , m_xRbtTop(rBuilder.weld_radio_button(u"top"_ustr))
+ , m_xRbtBottom(rBuilder.weld_radio_button(u"bottom"_ustr))
{
impl_setRadioButtonToggleHdl();
}
LegendPositionResources::LegendPositionResources(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"))
+ uno::Reference< uno::XComponentContext > xCC)
+ : m_xCC(std::move(xCC))
+ , m_xCbxShow(rBuilder.weld_check_button(u"show"_ustr))
+ , m_xRbtLeft(rBuilder.weld_radio_button(u"left"_ustr))
+ , m_xRbtRight(rBuilder.weld_radio_button(u"right"_ustr))
+ , m_xRbtTop(rBuilder.weld_radio_button(u"top"_ustr))
+ , m_xRbtBottom(rBuilder.weld_radio_button(u"bottom"_ustr))
{
m_xCbxShow->connect_toggled( LINK( this, LegendPositionResources, PositionEnableHdl ) );
impl_setRadioButtonToggleHdl();
@@ -72,24 +74,24 @@ LegendPositionResources::~LegendPositionResources()
{
}
-void LegendPositionResources::writeToResources( const uno::Reference< frame::XModel >& xChartModel )
+void LegendPositionResources::writeToResources( const rtl::Reference<::chart::ChartModel>& xChartModel )
{
try
{
- uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xChartModel );
- uno::Reference< beans::XPropertySet > xProp( xDiagram->getLegend(), uno::UNO_QUERY );
- if( xProp.is() )
+ rtl::Reference< Diagram > xDiagram = xChartModel->getFirstChartDiagram();
+ rtl::Reference< Legend > xLegend = xDiagram->getLegend2();
+ if( xLegend.is() )
{
//show
bool bShowLegend = false;
- xProp->getPropertyValue( "Show" ) >>= bShowLegend;
+ xLegend->getPropertyValue( u"Show"_ustr ) >>= bShowLegend;
if (m_xCbxShow)
m_xCbxShow->set_active( bShowLegend );
- PositionEnableHdl(*m_xCbxShow);
+ PositionEnable();
//position
chart2::LegendPosition ePos;
- xProp->getPropertyValue( "AnchorPosition" ) >>= ePos;
+ xLegend->getPropertyValue( u"AnchorPosition"_ustr ) >>= ePos;
switch( ePos )
{
case chart2::LegendPosition_LINE_START:
@@ -114,17 +116,17 @@ void LegendPositionResources::writeToResources( const uno::Reference< frame::XMo
}
}
-void LegendPositionResources::writeToModel( const css::uno::Reference< frame::XModel >& xChartModel ) const
+void LegendPositionResources::writeToModel( const rtl::Reference<::chart::ChartModel>& xChartModel ) const
{
try
{
bool bShowLegend = m_xCbxShow && m_xCbxShow->get_active();
- ChartModel& rModel = dynamic_cast<ChartModel&>(*xChartModel);
- uno::Reference< beans::XPropertySet > xProp(LegendHelper::getLegend(rModel, m_xCC, bShowLegend), uno::UNO_QUERY);
+ ChartModel& rModel = *xChartModel;
+ rtl::Reference< Legend > xProp = LegendHelper::getLegend(rModel, m_xCC, bShowLegend);
if( xProp.is() )
{
//show
- xProp->setPropertyValue( "Show" , uno::Any( bShowLegend ));
+ xProp->setPropertyValue( u"Show"_ustr , uno::Any( bShowLegend ));
//position
chart2::LegendPosition eNewPos;
@@ -147,9 +149,9 @@ void LegendPositionResources::writeToModel( const css::uno::Reference< frame::XM
eExp = css::chart::ChartLegendExpansion_WIDE;
}
- xProp->setPropertyValue( "AnchorPosition" , uno::Any( eNewPos ));
- xProp->setPropertyValue( "Expansion" , uno::Any( eExp ));
- xProp->setPropertyValue( "RelativePosition" , uno::Any());
+ xProp->setPropertyValue( u"AnchorPosition"_ustr , uno::Any( eNewPos ));
+ xProp->setPropertyValue( u"Expansion"_ustr , uno::Any( eExp ));
+ xProp->setPropertyValue( u"RelativePosition"_ustr , uno::Any());
}
}
catch( const uno::Exception & )
@@ -158,7 +160,12 @@ void LegendPositionResources::writeToModel( const css::uno::Reference< frame::XM
}
}
-IMPL_LINK_NOARG(LegendPositionResources, PositionEnableHdl, weld::ToggleButton&, void)
+IMPL_LINK_NOARG(LegendPositionResources, PositionEnableHdl, weld::Toggleable&, void)
+{
+ PositionEnable();
+}
+
+void LegendPositionResources::PositionEnable()
{
bool bEnable = !m_xCbxShow || m_xCbxShow->get_active();
@@ -172,10 +179,9 @@ IMPL_LINK_NOARG(LegendPositionResources, PositionEnableHdl, weld::ToggleButton&,
void LegendPositionResources::initFromItemSet( const SfxItemSet& rInAttrs )
{
- const SfxPoolItem* pPoolItem = nullptr;
- if( rInAttrs.GetItemState( SCHATTR_LEGEND_POS, true, &pPoolItem ) == SfxItemState::SET )
+ if( const SfxInt32Item* pPosItem = rInAttrs.GetItemIfSet( SCHATTR_LEGEND_POS ) )
{
- chart2::LegendPosition nLegendPosition = static_cast<chart2::LegendPosition>(static_cast<const SfxInt32Item*>(pPoolItem)->GetValue());
+ chart2::LegendPosition nLegendPosition = static_cast<chart2::LegendPosition>(pPosItem->GetValue());
switch( nLegendPosition )
{
case chart2::LegendPosition_LINE_START:
@@ -195,10 +201,10 @@ void LegendPositionResources::initFromItemSet( const SfxItemSet& rInAttrs )
}
}
- if( m_xCbxShow && rInAttrs.GetItemState( SCHATTR_LEGEND_SHOW, true, &pPoolItem ) == SfxItemState::SET )
+ const SfxBoolItem* pShowItem;
+ if( m_xCbxShow && (pShowItem = rInAttrs.GetItemIfSet( SCHATTR_LEGEND_SHOW )) )
{
- bool bShow = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
- m_xCbxShow->set_active(bShow);
+ m_xCbxShow->set_active(pShowItem->GetValue());
}
}
@@ -218,7 +224,7 @@ void LegendPositionResources::writeToItemSet( SfxItemSet& rOutAttrs ) const
rOutAttrs.Put( SfxBoolItem(SCHATTR_LEGEND_SHOW, !m_xCbxShow || m_xCbxShow->get_active()) );
}
-IMPL_LINK (LegendPositionResources, PositionChangeHdl, weld::ToggleButton&, rRadio, void)
+IMPL_LINK (LegendPositionResources, PositionChangeHdl, weld::Toggleable&, rRadio, void)
{
//for each radio click there are coming two change events
//first uncheck of previous button -> ignore that call