diff options
Diffstat (limited to 'chart2/source/controller/sidebar/ChartAxisPanel.cxx')
-rw-r--r-- | chart2/source/controller/sidebar/ChartAxisPanel.cxx | 78 |
1 files changed, 36 insertions, 42 deletions
diff --git a/chart2/source/controller/sidebar/ChartAxisPanel.cxx b/chart2/source/controller/sidebar/ChartAxisPanel.cxx index c5e4d91c54e2..48a4620684b3 100644 --- a/chart2/source/controller/sidebar/ChartAxisPanel.cxx +++ b/chart2/source/controller/sidebar/ChartAxisPanel.cxx @@ -17,17 +17,16 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/chart/ChartAxisLabelPosition.hpp> #include <com/sun/star/chart2/AxisOrientation.hpp> -#include <com/sun/star/chart2/XAxis.hpp> -#include <com/sun/star/util/XModifyBroadcaster.hpp> #include <vcl/svapp.hxx> #include <sal/log.hxx> #include "ChartAxisPanel.hxx" #include <ChartController.hxx> +#include <ChartModel.hxx> +#include <Axis.hxx> using namespace css; using namespace css::uno; @@ -36,11 +35,10 @@ namespace chart::sidebar { namespace { -bool isLabelShown(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID) +bool isLabelShown(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID) { - css::uno::Reference< css::beans::XPropertySet > xAxis( - ObjectIdentifier::getAxisForCID(rCID, xModel), uno::UNO_QUERY ); + rtl::Reference< ::chart::Axis > xAxis = ObjectIdentifier::getAxisForCID(rCID, xModel); if (!xAxis.is()) return false; @@ -54,11 +52,10 @@ bool isLabelShown(const css::uno::Reference<css::frame::XModel>& xModel, return bVisible; } -void setLabelShown(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID, bool bVisible) +void setLabelShown(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID, bool bVisible) { - css::uno::Reference< css::beans::XPropertySet > xAxis( - ObjectIdentifier::getAxisForCID(rCID, xModel), uno::UNO_QUERY ); + rtl::Reference< ::chart::Axis > xAxis = ObjectIdentifier::getAxisForCID(rCID, xModel); if (!xAxis.is()) return; @@ -79,11 +76,10 @@ AxisLabelPosMap const aLabelPosMap[] = { { 3, css::chart::ChartAxisLabelPosition_OUTSIDE_END } }; -sal_Int32 getLabelPosition(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID) +sal_Int32 getLabelPosition(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID) { - css::uno::Reference< css::beans::XPropertySet > xAxis( - ObjectIdentifier::getAxisForCID(rCID, xModel), uno::UNO_QUERY ); + rtl::Reference< ::chart::Axis > xAxis = ObjectIdentifier::getAxisForCID(rCID, xModel); if (!xAxis.is()) return 0; @@ -103,11 +99,10 @@ sal_Int32 getLabelPosition(const css::uno::Reference<css::frame::XModel>& xModel return 0; } -void setLabelPosition(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID, sal_Int32 nPos) +void setLabelPosition(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID, sal_Int32 nPos) { - css::uno::Reference< css::beans::XPropertySet > xAxis( - ObjectIdentifier::getAxisForCID(rCID, xModel), uno::UNO_QUERY ); + rtl::Reference< ::chart::Axis > xAxis = ObjectIdentifier::getAxisForCID(rCID, xModel); if (!xAxis.is()) return; @@ -122,10 +117,10 @@ void setLabelPosition(const css::uno::Reference<css::frame::XModel>& xModel, xAxis->setPropertyValue("LabelPosition", css::uno::Any(ePos)); } -bool isReverse(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID) +bool isReverse(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID) { - css::uno::Reference< css::chart2::XAxis > xAxis = + rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID(rCID, xModel); if (!xAxis.is()) @@ -136,10 +131,10 @@ bool isReverse(const css::uno::Reference<css::frame::XModel>& xModel, return aData.Orientation == css::chart2::AxisOrientation_REVERSE; } -void setReverse(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID, bool bReverse) +void setReverse(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID, bool bReverse) { - css::uno::Reference< css::chart2::XAxis > xAxis = + rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID(rCID, xModel); if (!xAxis.is()) @@ -174,11 +169,11 @@ OUString getCID(const css::uno::Reference<css::frame::XModel>& xModel) return aCID; } -void setAxisRotation(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID, double nVal) +void setAxisRotation(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID, double nVal) { - css::uno::Reference< css::beans::XPropertySet > xAxis( - ObjectIdentifier::getAxisForCID(rCID, xModel), uno::UNO_QUERY ); + rtl::Reference< ::chart::Axis > xAxis = + ObjectIdentifier::getAxisForCID(rCID, xModel); if (!xAxis.is()) return; @@ -186,11 +181,11 @@ void setAxisRotation(const css::uno::Reference<css::frame::XModel>& xModel, xAxis->setPropertyValue("TextRotation", css::uno::Any(nVal)); } -double getAxisRotation(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID) +double getAxisRotation(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID) { - css::uno::Reference< css::beans::XPropertySet > xAxis( - ObjectIdentifier::getAxisForCID(rCID, xModel), uno::UNO_QUERY ); + rtl::Reference< ::chart::Axis > xAxis = + ObjectIdentifier::getAxisForCID(rCID, xModel); if (!xAxis.is()) return 0; @@ -212,7 +207,7 @@ ChartAxisPanel::ChartAxisPanel( , mxLBLabelPos(m_xBuilder->weld_combo_box("comboboxtext_label_position")) , mxGridLabel(m_xBuilder->weld_widget("label_props")) , mxNFRotation(m_xBuilder->weld_metric_spin_button("spinbutton1", FieldUnit::DEGREE)) - , mxModel(pController->getModel()) + , mxModel(pController->getChartModel()) , mxModifyListener(new ChartSidebarModifyListener(this)) , mxSelectionListener(new ChartSidebarSelectionListener(this, OBJECTTYPE_AXIS)) , mbModelValid(true) @@ -235,8 +230,7 @@ ChartAxisPanel::~ChartAxisPanel() void ChartAxisPanel::Initialize() { - css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW); - xBroadcaster->addModifyListener(mxModifyListener); + mxModel->addModifyListener(mxModifyListener); css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY); if (xSelectionSupplier.is()) @@ -306,12 +300,11 @@ void ChartAxisPanel::modelInvalid() mbModelValid = false; } -void ChartAxisPanel::doUpdateModel(css::uno::Reference<css::frame::XModel> xModel) +void ChartAxisPanel::doUpdateModel(const rtl::Reference<::chart::ChartModel>& xModel) { if (mbModelValid) { - css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW); - xBroadcaster->removeModifyListener(mxModifyListener); + mxModel->removeModifyListener(mxModifyListener); css::uno::Reference<css::view::XSelectionSupplier> oldSelectionSupplier( mxModel->getCurrentController(), css::uno::UNO_QUERY); @@ -326,8 +319,7 @@ void ChartAxisPanel::doUpdateModel(css::uno::Reference<css::frame::XModel> xMode if (!mbModelValid) return; - css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW); - xBroadcasterNew->addModifyListener(mxModifyListener); + mxModel->addModifyListener(mxModifyListener); css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY); if (xSelectionSupplier.is()) @@ -336,7 +328,9 @@ void ChartAxisPanel::doUpdateModel(css::uno::Reference<css::frame::XModel> xMode void ChartAxisPanel::updateModel(css::uno::Reference<css::frame::XModel> xModel) { - doUpdateModel(xModel); + ::chart::ChartModel* pModel = dynamic_cast<::chart::ChartModel*>(xModel.get()); + assert(!xModel || pModel); + doUpdateModel(pModel); } void ChartAxisPanel::selectionChanged(bool bCorrectType) |