diff options
Diffstat (limited to 'chart2/source/controller/sidebar/ChartAxisPanel.cxx')
-rw-r--r-- | chart2/source/controller/sidebar/ChartAxisPanel.cxx | 104 |
1 files changed, 49 insertions, 55 deletions
diff --git a/chart2/source/controller/sidebar/ChartAxisPanel.cxx b/chart2/source/controller/sidebar/ChartAxisPanel.cxx index c5e4d91c54e2..7554d164f11f 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,16 +35,15 @@ 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; - uno::Any aAny = xAxis->getPropertyValue("DisplayLabels"); + uno::Any aAny = xAxis->getPropertyValue(u"DisplayLabels"_ustr); if (!aAny.hasValue()) return false; @@ -54,16 +52,15 @@ 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; - xAxis->setPropertyValue("DisplayLabels", css::uno::Any(bVisible)); + xAxis->setPropertyValue(u"DisplayLabels"_ustr, css::uno::Any(bVisible)); } struct AxisLabelPosMap @@ -79,16 +76,15 @@ 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; - uno::Any aAny = xAxis->getPropertyValue("LabelPosition"); + uno::Any aAny = xAxis->getPropertyValue(u"LabelPosition"_ustr); if (!aAny.hasValue()) 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; @@ -119,13 +114,13 @@ void setLabelPosition(const css::uno::Reference<css::frame::XModel>& xModel, ePos = i.ePos; } - xAxis->setPropertyValue("LabelPosition", css::uno::Any(ePos)); + xAxis->setPropertyValue(u"LabelPosition"_ustr, 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,28 +169,28 @@ 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; - xAxis->setPropertyValue("TextRotation", css::uno::Any(nVal)); + xAxis->setPropertyValue(u"TextRotation"_ustr, 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; - css::uno::Any aAny = xAxis->getPropertyValue("TextRotation"); + css::uno::Any aAny = xAxis->getPropertyValue(u"TextRotation"_ustr); double nVal = 0; aAny >>= nVal; return nVal; @@ -206,13 +201,13 @@ double getAxisRotation(const css::uno::Reference<css::frame::XModel>& xModel, ChartAxisPanel::ChartAxisPanel( weld::Widget* pParent, ChartController* pController) - : PanelLayout(pParent, "ChartAxisPanel", "modules/schart/ui/sidebaraxis.ui") - , mxCBShowLabel(m_xBuilder->weld_check_button("checkbutton_show_label")) - , mxCBReverse(m_xBuilder->weld_check_button("checkbutton_reverse")) - , 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()) + : PanelLayout(pParent, u"ChartAxisPanel"_ustr, u"modules/schart/ui/sidebaraxis.ui"_ustr) + , mxCBShowLabel(m_xBuilder->weld_check_button(u"checkbutton_show_label"_ustr)) + , mxCBReverse(m_xBuilder->weld_check_button(u"checkbutton_reverse"_ustr)) + , mxLBLabelPos(m_xBuilder->weld_combo_box(u"comboboxtext_label_position"_ustr)) + , mxGridLabel(m_xBuilder->weld_widget(u"label_props"_ustr)) + , mxNFRotation(m_xBuilder->weld_metric_spin_button(u"spinbutton1"_ustr, FieldUnit::DEGREE)) + , 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()) @@ -278,7 +272,7 @@ std::unique_ptr<PanelLayout> ChartAxisPanel::Create ( ChartController* pController) { if (pParent == nullptr) - throw lang::IllegalArgumentException("no parent Window given to ChartAxisPanel::Create", nullptr, 0); + throw lang::IllegalArgumentException(u"no parent Window given to ChartAxisPanel::Create"_ustr, nullptr, 0); return std::make_unique<ChartAxisPanel>(pParent, pController); } @@ -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) |