diff options
Diffstat (limited to 'chart2/source/controller/sidebar/ChartElementsPanel.cxx')
-rw-r--r-- | chart2/source/controller/sidebar/ChartElementsPanel.cxx | 128 |
1 files changed, 64 insertions, 64 deletions
diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.cxx b/chart2/source/controller/sidebar/ChartElementsPanel.cxx index 572ea7de4bd3..89dd339f9a48 100644 --- a/chart2/source/controller/sidebar/ChartElementsPanel.cxx +++ b/chart2/source/controller/sidebar/ChartElementsPanel.cxx @@ -19,8 +19,6 @@ #include <com/sun/star/chart2/LegendPosition.hpp> #include <com/sun/star/chart/ChartLegendExpansion.hpp> -#include <com/sun/star/chart2/XChartTypeContainer.hpp> -#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> #include <vcl/svapp.hxx> @@ -28,11 +26,11 @@ #include <ChartController.hxx> #include <comphelper/processfactory.hxx> +#include <Legend.hxx> #include <LegendHelper.hxx> -#include <ChartModelHelper.hxx> #include <AxisHelper.hxx> -#include <DiagramHelper.hxx> #include <Diagram.hxx> +#include <ChartType.hxx> #include <ChartTypeHelper.hxx> #include <ChartModel.hxx> #include <BaseCoordinateSystem.hxx> @@ -75,13 +73,13 @@ bool isLegendVisible(const css::uno::Reference<css::frame::XModel>& xModel) if (!pModel) return false; - Reference< beans::XPropertySet > xLegendProp( LegendHelper::getLegend(*pModel), uno::UNO_QUERY ); + rtl::Reference< Legend > xLegendProp = LegendHelper::getLegend(*pModel); if( xLegendProp.is()) { try { bool bShow = false; - if( xLegendProp->getPropertyValue( "Show") >>= bShow ) + if( xLegendProp->getPropertyValue( u"Show"_ustr) >>= bShow ) { return bShow; } @@ -112,13 +110,13 @@ bool isLegendOverlay(const css::uno::Reference<css::frame::XModel>& xModel) if (!pModel) return false; - Reference< beans::XPropertySet > xLegendProp(LegendHelper::getLegend(*pModel), uno::UNO_QUERY); + rtl::Reference< Legend > xLegendProp = LegendHelper::getLegend(*pModel); if( xLegendProp.is()) { try { bool bOverlay = false; - if(xLegendProp->getPropertyValue("Overlay") >>= bOverlay) + if(xLegendProp->getPropertyValue(u"Overlay"_ustr) >>= bOverlay) { return bOverlay; } @@ -137,28 +135,27 @@ void setLegendOverlay(const css::uno::Reference<css::frame::XModel>& xModel, boo if (!pModel) return; - Reference<beans::XPropertySet> xLegendProp(LegendHelper::getLegend(*pModel), uno::UNO_QUERY); + rtl::Reference<Legend> xLegendProp = LegendHelper::getLegend(*pModel); if (!xLegendProp.is()) return; - xLegendProp->setPropertyValue("Overlay", css::uno::Any(bOverlay)); + xLegendProp->setPropertyValue(u"Overlay"_ustr, css::uno::Any(bOverlay)); } bool isTitleVisible(const rtl::Reference<::chart::ChartModel>& xModel, TitleHelper::eTitleType eTitle) { - css::uno::Reference<css::uno::XInterface> xTitle = TitleHelper::getTitle(eTitle, xModel); + rtl::Reference<Title> xTitle = TitleHelper::getTitle(eTitle, xModel); if (!xTitle.is()) return false; - css::uno::Reference<css::beans::XPropertySet> xPropSet(xTitle, css::uno::UNO_QUERY_THROW); - css::uno::Any aAny = xPropSet->getPropertyValue("Visible"); + css::uno::Any aAny = xTitle->getPropertyValue(u"Visible"_ustr); bool bVisible = aAny.get<bool>(); return bVisible; } bool isGridVisible(const rtl::Reference<::chart::ChartModel>& xModel, GridType eType) { - rtl::Reference< Diagram > xDiagram(ChartModelHelper::findDiagram(xModel)); + rtl::Reference< Diagram > xDiagram(xModel->getFirstChartDiagram()); if(xDiagram.is()) { sal_Int32 nDimensionIndex = 0; @@ -175,7 +172,7 @@ bool isGridVisible(const rtl::Reference<::chart::ChartModel>& xModel, GridType e void setGridVisible(const rtl::Reference<::chart::ChartModel>& xModel, GridType eType, bool bVisible) { - rtl::Reference< Diagram > xDiagram(ChartModelHelper::findDiagram(xModel)); + rtl::Reference< Diagram > xDiagram(xModel->getFirstChartDiagram()); if(!xDiagram.is()) return; @@ -195,7 +192,7 @@ void setGridVisible(const rtl::Reference<::chart::ChartModel>& xModel, GridType bool isAxisVisible(const rtl::Reference<::chart::ChartModel>& xModel, AxisType eType) { - rtl::Reference< Diagram > xDiagram(ChartModelHelper::findDiagram(xModel)); + rtl::Reference< Diagram > xDiagram(xModel->getFirstChartDiagram()); if(xDiagram.is()) { sal_Int32 nDimensionIndex = 0; @@ -214,7 +211,7 @@ bool isAxisVisible(const rtl::Reference<::chart::ChartModel>& xModel, AxisType e void setAxisVisible(const rtl::Reference<::chart::ChartModel>& xModel, AxisType eType, bool bVisible) { - rtl::Reference< Diagram > xDiagram(ChartModelHelper::findDiagram(xModel)); + rtl::Reference< Diagram > xDiagram(xModel->getFirstChartDiagram()); if(!xDiagram.is()) return; @@ -238,12 +235,12 @@ sal_Int32 getLegendPos(const css::uno::Reference<css::frame::XModel>& xModel) if (!pModel) return -1; - Reference< beans::XPropertySet > xLegendProp( LegendHelper::getLegend(*pModel), uno::UNO_QUERY ); + rtl::Reference< Legend > xLegendProp = LegendHelper::getLegend(*pModel); if (!xLegendProp.is()) return -1; chart2::LegendPosition eLegendPos = chart2::LegendPosition_LINE_END; - xLegendProp->getPropertyValue("AnchorPosition") >>= eLegendPos; + xLegendProp->getPropertyValue(u"AnchorPosition"_ustr) >>= eLegendPos; switch(eLegendPos) { case chart2::LegendPosition_LINE_START: @@ -265,7 +262,7 @@ void setLegendPos(const css::uno::Reference<css::frame::XModel>& xModel, sal_Int if (!pModel) return; - Reference< beans::XPropertySet > xLegendProp( LegendHelper::getLegend(*pModel), uno::UNO_QUERY ); + rtl::Reference< Legend > xLegendProp = LegendHelper::getLegend(*pModel); if (!xLegendProp.is()) return; @@ -291,42 +288,42 @@ void setLegendPos(const css::uno::Reference<css::frame::XModel>& xModel, sal_Int assert(false); } - xLegendProp->setPropertyValue("AnchorPosition", css::uno::Any(eLegendPos)); - xLegendProp->setPropertyValue("Expansion", css::uno::Any(eExpansion)); - xLegendProp->setPropertyValue("RelativePosition", uno::Any()); + xLegendProp->setPropertyValue(u"AnchorPosition"_ustr, css::uno::Any(eLegendPos)); + xLegendProp->setPropertyValue(u"Expansion"_ustr, css::uno::Any(eExpansion)); + xLegendProp->setPropertyValue(u"RelativePosition"_ustr, uno::Any()); } } ChartElementsPanel::ChartElementsPanel( weld::Widget* pParent, ChartController* pController) - : PanelLayout(pParent, "ChartElementsPanel", "modules/schart/ui/sidebarelements.ui") - , mxCBTitle(m_xBuilder->weld_check_button("checkbutton_title")) - , mxEditTitle(m_xBuilder->weld_entry("edit_title")) - , mxCBSubtitle(m_xBuilder->weld_check_button("checkbutton_subtitle")) - , mxEditSubtitle(m_xBuilder->weld_entry("edit_subtitle")) - , mxCBXAxis(m_xBuilder->weld_check_button("checkbutton_x_axis")) - , mxCBXAxisTitle(m_xBuilder->weld_check_button("checkbutton_x_axis_title")) - , mxCBYAxis(m_xBuilder->weld_check_button("checkbutton_y_axis")) - , mxCBYAxisTitle(m_xBuilder->weld_check_button("checkbutton_y_axis_title")) - , mxCBZAxis(m_xBuilder->weld_check_button("checkbutton_z_axis")) - , mxCBZAxisTitle(m_xBuilder->weld_check_button("checkbutton_z_axis_title")) - , mxCB2ndXAxis(m_xBuilder->weld_check_button("checkbutton_2nd_x_axis")) - , mxCB2ndXAxisTitle(m_xBuilder->weld_check_button("checkbutton_2nd_x_axis_title")) - , mxCB2ndYAxis(m_xBuilder->weld_check_button("checkbutton_2nd_y_axis")) - , mxCB2ndYAxisTitle(m_xBuilder->weld_check_button("checkbutton_2nd_y_axis_title")) - , mxCBLegend(m_xBuilder->weld_check_button("checkbutton_legend")) - , mxCBLegendNoOverlay(m_xBuilder->weld_check_button("checkbutton_no_overlay")) - , mxCBGridVerticalMajor(m_xBuilder->weld_check_button("checkbutton_gridline_vertical_major")) - , mxCBGridHorizontalMajor(m_xBuilder->weld_check_button("checkbutton_gridline_horizontal_major")) - , mxCBGridVerticalMinor(m_xBuilder->weld_check_button("checkbutton_gridline_vertical_minor")) - , mxCBGridHorizontalMinor(m_xBuilder->weld_check_button("checkbutton_gridline_horizontal_minor")) - , mxTextTitle(m_xBuilder->weld_label("text_title")) - , mxTextSubTitle(m_xBuilder->weld_label("text_subtitle")) - , mxLBAxis(m_xBuilder->weld_label("label_axes")) - , mxLBGrid(m_xBuilder->weld_label("label_gri")) - , mxLBLegendPosition(m_xBuilder->weld_combo_box("comboboxtext_legend")) - , mxBoxLegend(m_xBuilder->weld_widget("box_legend")) + : PanelLayout(pParent, u"ChartElementsPanel"_ustr, u"modules/schart/ui/sidebarelements.ui"_ustr) + , mxCBTitle(m_xBuilder->weld_check_button(u"checkbutton_title"_ustr)) + , mxEditTitle(m_xBuilder->weld_entry(u"edit_title"_ustr)) + , mxCBSubtitle(m_xBuilder->weld_check_button(u"checkbutton_subtitle"_ustr)) + , mxEditSubtitle(m_xBuilder->weld_entry(u"edit_subtitle"_ustr)) + , mxCBXAxis(m_xBuilder->weld_check_button(u"checkbutton_x_axis"_ustr)) + , mxCBXAxisTitle(m_xBuilder->weld_check_button(u"checkbutton_x_axis_title"_ustr)) + , mxCBYAxis(m_xBuilder->weld_check_button(u"checkbutton_y_axis"_ustr)) + , mxCBYAxisTitle(m_xBuilder->weld_check_button(u"checkbutton_y_axis_title"_ustr)) + , mxCBZAxis(m_xBuilder->weld_check_button(u"checkbutton_z_axis"_ustr)) + , mxCBZAxisTitle(m_xBuilder->weld_check_button(u"checkbutton_z_axis_title"_ustr)) + , mxCB2ndXAxis(m_xBuilder->weld_check_button(u"checkbutton_2nd_x_axis"_ustr)) + , mxCB2ndXAxisTitle(m_xBuilder->weld_check_button(u"checkbutton_2nd_x_axis_title"_ustr)) + , mxCB2ndYAxis(m_xBuilder->weld_check_button(u"checkbutton_2nd_y_axis"_ustr)) + , mxCB2ndYAxisTitle(m_xBuilder->weld_check_button(u"checkbutton_2nd_y_axis_title"_ustr)) + , mxCBLegend(m_xBuilder->weld_check_button(u"checkbutton_legend"_ustr)) + , mxCBLegendNoOverlay(m_xBuilder->weld_check_button(u"checkbutton_no_overlay"_ustr)) + , mxCBGridVerticalMajor(m_xBuilder->weld_check_button(u"checkbutton_gridline_vertical_major"_ustr)) + , mxCBGridHorizontalMajor(m_xBuilder->weld_check_button(u"checkbutton_gridline_horizontal_major"_ustr)) + , mxCBGridVerticalMinor(m_xBuilder->weld_check_button(u"checkbutton_gridline_vertical_minor"_ustr)) + , mxCBGridHorizontalMinor(m_xBuilder->weld_check_button(u"checkbutton_gridline_horizontal_minor"_ustr)) + , mxTextTitle(m_xBuilder->weld_label(u"text_title"_ustr)) + , mxTextSubTitle(m_xBuilder->weld_label(u"text_subtitle"_ustr)) + , mxLBAxis(m_xBuilder->weld_label(u"label_axes"_ustr)) + , mxLBGrid(m_xBuilder->weld_label(u"label_gri"_ustr)) + , mxLBLegendPosition(m_xBuilder->weld_combo_box(u"comboboxtext_legend"_ustr)) + , mxBoxLegend(m_xBuilder->weld_widget(u"box_legend"_ustr)) , mxModel(pController->getChartModel()) , mxListener(new ChartSidebarModifyListener(this)) , mbModelValid(true) @@ -406,21 +403,21 @@ void ChartElementsPanel::Initialize() namespace { -css::uno::Reference<css::chart2::XChartType> getChartType(const rtl::Reference<ChartModel>& xModel) +rtl::Reference<ChartType> getChartType(const rtl::Reference<ChartModel>& xModel) { rtl::Reference<Diagram > xDiagram = xModel->getFirstChartDiagram(); if (!xDiagram.is()) - return css::uno::Reference<css::chart2::XChartType>(); + return nullptr; - const std::vector<rtl::Reference<BaseCoordinateSystem>> & xCooSysSequence(xDiagram->getBaseCoordinateSystems()); + const std::vector<rtl::Reference<BaseCoordinateSystem>> xCooSysSequence(xDiagram->getBaseCoordinateSystems()); if (xCooSysSequence.empty()) - return css::uno::Reference<css::chart2::XChartType>(); + return nullptr; - css::uno::Sequence<css::uno::Reference<css::chart2::XChartType>> xChartTypeSequence(xCooSysSequence[0]->getChartTypes()); + const std::vector<rtl::Reference<ChartType>> & xChartTypeSequence(xCooSysSequence[0]->getChartTypes2()); - if (!xChartTypeSequence.hasElements()) - return css::uno::Reference<css::chart2::XChartType>(); + if (xChartTypeSequence.empty()) + return nullptr; return xChartTypeSequence[0]; } @@ -432,8 +429,10 @@ void ChartElementsPanel::updateData() if (!mbModelValid) return; - rtl::Reference< Diagram > xDiagram(ChartModelHelper::findDiagram(mxModel)); - sal_Int32 nDimension = DiagramHelper::getDimension(xDiagram); + rtl::Reference< Diagram > xDiagram(mxModel->getFirstChartDiagram()); + sal_Int32 nDimension = 0; + if (xDiagram) + nDimension = xDiagram->getDimension(); SolarMutexGuard aGuard; mxCBLegend->set_active(isLegendVisible(mxModel)); @@ -476,8 +475,8 @@ void ChartElementsPanel::updateData() mxCB2ndXAxis->set_active(isAxisVisible(mxModel, AxisType::X_SECOND)); mxCB2ndYAxis->set_active(isAxisVisible(mxModel, AxisType::Y_SECOND)); - bool bSupportsMainAxis = ChartTypeHelper::isSupportingMainAxis( - getChartType(mxModel), 0, 0); + auto xChartType = getChartType(mxModel); + bool bSupportsMainAxis = xChartType.is() ? xChartType->isSupportingMainAxis(0, 0) : true; if (bSupportsMainAxis) { mxCBXAxis->show(); @@ -528,7 +527,7 @@ std::unique_ptr<PanelLayout> ChartElementsPanel::Create ( ChartController* pController) { if (pParent == nullptr) - throw lang::IllegalArgumentException("no parent Window given to ChartElementsPanel::Create", nullptr, 0); + throw lang::IllegalArgumentException(u"no parent Window given to ChartElementsPanel::Create"_ustr, nullptr, 0); return std::make_unique<ChartElementsPanel>(pParent, pController); } @@ -556,7 +555,7 @@ void ChartElementsPanel::modelInvalid() mbModelValid = false; } -void ChartElementsPanel::doUpdateModel(rtl::Reference<::chart::ChartModel> xModel) +void ChartElementsPanel::doUpdateModel(const rtl::Reference<::chart::ChartModel>& xModel) { if (mbModelValid) { @@ -635,7 +634,8 @@ IMPL_LINK(ChartElementsPanel, EditHdl, weld::Entry&, rEdit, void) // set it OUString aText(rEdit.get_text()); - TitleHelper::setCompleteString(aText, TitleHelper::getTitle(aTitleType, mxModel), comphelper::getProcessComponentContext()); + TitleHelper::setCompleteString(aText, TitleHelper::getTitle(aTitleType, mxModel), + comphelper::getProcessComponentContext(), nullptr, true); } IMPL_LINK_NOARG(ChartElementsPanel, LegendPosHdl, weld::ComboBox&, void) |