20#include <com/sun/star/chart2/LegendPosition.hpp>
21#include <com/sun/star/chart/ChartLegendExpansion.hpp>
42using namespace css::uno;
65ChartModel* getChartModel(
const css::uno::Reference<css::frame::XModel>& xModel)
67 ChartModel* pModel =
dynamic_cast<ChartModel*
>(
xModel.get());
72bool isLegendVisible(
const css::uno::Reference<css::frame::XModel>& xModel)
74 ChartModel* pModel = getChartModel(xModel);
84 if( xLegendProp->getPropertyValue(
"Show") >>= bShow )
89 catch(
const uno::Exception &)
97void setLegendVisible(
const css::uno::Reference<css::frame::XModel>& xModel,
bool bVisible)
99 ChartModel* pModel = getChartModel(xModel);
109bool isLegendOverlay(
const css::uno::Reference<css::frame::XModel>& xModel)
111 ChartModel* pModel = getChartModel(xModel);
116 if( xLegendProp.is())
120 bool bOverlay =
false;
121 if(xLegendProp->getPropertyValue(
"Overlay") >>= bOverlay)
126 catch(
const uno::Exception &)
134void setLegendOverlay(
const css::uno::Reference<css::frame::XModel>& xModel,
bool bOverlay)
136 ChartModel* pModel = getChartModel(xModel);
141 if (!xLegendProp.is())
144 xLegendProp->setPropertyValue(
"Overlay", css::uno::Any(bOverlay));
153 css::uno::Any aAny = xTitle->getPropertyValue(
"Visible");
163 sal_Int32 nDimensionIndex = 0;
164 if (eType == GridType::HOR_MAJOR || eType == GridType::HOR_MINOR)
167 bool bMajor = (
eType == GridType::HOR_MAJOR ||
eType == GridType::VERT_MAJOR);
181 sal_Int32 nDimensionIndex = 0;
182 if (eType == GridType::HOR_MAJOR || eType == GridType::HOR_MINOR)
184 sal_Int32 nCooSysIndex = 0;
186 bool bMajor = (
eType == GridType::HOR_MAJOR ||
eType == GridType::VERT_MAJOR);
200 sal_Int32 nDimensionIndex = 0;
201 if (eType == AxisType::Y_MAIN || eType == AxisType::Y_SECOND)
203 else if (eType == AxisType::Z_MAIN)
206 bool bMajor = (
eType != AxisType::X_SECOND &&
eType != AxisType::Y_SECOND);
220 sal_Int32 nDimensionIndex = 0;
221 if (eType == AxisType::Y_MAIN || eType == AxisType::Y_SECOND)
223 else if (eType == AxisType::Z_MAIN)
226 bool bMajor = (
eType != AxisType::X_SECOND &&
eType != AxisType::Y_SECOND);
234sal_Int32 getLegendPos(
const css::uno::Reference<css::frame::XModel>& xModel)
236 ChartModel* pModel = getChartModel(xModel);
241 if (!xLegendProp.is())
244 chart2::LegendPosition eLegendPos = chart2::LegendPosition_LINE_END;
245 xLegendProp->getPropertyValue(
"AnchorPosition") >>= eLegendPos;
248 case chart2::LegendPosition_LINE_START:
250 case chart2::LegendPosition_LINE_END:
252 case chart2::LegendPosition_PAGE_START:
254 case chart2::LegendPosition_PAGE_END:
261void setLegendPos(
const css::uno::Reference<css::frame::XModel>& xModel, sal_Int32
nPos)
263 ChartModel* pModel = getChartModel(xModel);
268 if (!xLegendProp.is())
271 chart2::LegendPosition eLegendPos = chart2::LegendPosition_LINE_END;
272 css::chart::ChartLegendExpansion eExpansion = css::chart::ChartLegendExpansion_HIGH;
276 eLegendPos = chart2::LegendPosition_PAGE_START;
277 eExpansion = css::chart::ChartLegendExpansion_WIDE;
280 eLegendPos = chart2::LegendPosition_LINE_START;
283 eLegendPos = chart2::LegendPosition_LINE_END;
286 eLegendPos = chart2::LegendPosition_PAGE_END;
287 eExpansion = css::chart::ChartLegendExpansion_WIDE;
293 xLegendProp->setPropertyValue(
"AnchorPosition", css::uno::Any(eLegendPos));
294 xLegendProp->setPropertyValue(
"Expansion", css::uno::Any(eExpansion));
295 xLegendProp->setPropertyValue(
"RelativePosition",
uno::Any());
302 :
PanelLayout(pParent,
"ChartElementsPanel",
"modules/schart/ui/sidebarelements.ui")
303 , mxCBTitle(m_xBuilder->weld_check_button(
"checkbutton_title"))
304 , mxEditTitle(m_xBuilder->weld_entry(
"edit_title"))
305 , mxCBSubtitle(m_xBuilder->weld_check_button(
"checkbutton_subtitle"))
306 , mxEditSubtitle(m_xBuilder->weld_entry(
"edit_subtitle"))
307 , mxCBXAxis(m_xBuilder->weld_check_button(
"checkbutton_x_axis"))
308 , mxCBXAxisTitle(m_xBuilder->weld_check_button(
"checkbutton_x_axis_title"))
309 , mxCBYAxis(m_xBuilder->weld_check_button(
"checkbutton_y_axis"))
310 , mxCBYAxisTitle(m_xBuilder->weld_check_button(
"checkbutton_y_axis_title"))
311 , mxCBZAxis(m_xBuilder->weld_check_button(
"checkbutton_z_axis"))
312 , mxCBZAxisTitle(m_xBuilder->weld_check_button(
"checkbutton_z_axis_title"))
313 , mxCB2ndXAxis(m_xBuilder->weld_check_button(
"checkbutton_2nd_x_axis"))
314 , mxCB2ndXAxisTitle(m_xBuilder->weld_check_button(
"checkbutton_2nd_x_axis_title"))
315 , mxCB2ndYAxis(m_xBuilder->weld_check_button(
"checkbutton_2nd_y_axis"))
316 , mxCB2ndYAxisTitle(m_xBuilder->weld_check_button(
"checkbutton_2nd_y_axis_title"))
317 , mxCBLegend(m_xBuilder->weld_check_button(
"checkbutton_legend"))
318 , mxCBLegendNoOverlay(m_xBuilder->weld_check_button(
"checkbutton_no_overlay"))
319 , mxCBGridVerticalMajor(m_xBuilder->weld_check_button(
"checkbutton_gridline_vertical_major"))
320 , mxCBGridHorizontalMajor(m_xBuilder->weld_check_button(
"checkbutton_gridline_horizontal_major"))
321 , mxCBGridVerticalMinor(m_xBuilder->weld_check_button(
"checkbutton_gridline_vertical_minor"))
322 , mxCBGridHorizontalMinor(m_xBuilder->weld_check_button(
"checkbutton_gridline_horizontal_minor"))
323 , mxTextTitle(m_xBuilder->weld_label(
"text_title"))
324 , mxTextSubTitle(m_xBuilder->weld_label(
"text_subtitle"))
325 , mxLBAxis(m_xBuilder->weld_label(
"label_axes"))
326 , mxLBGrid(m_xBuilder->weld_label(
"label_gri"))
327 , mxLBLegendPosition(m_xBuilder->weld_combo_box(
"comboboxtext_legend"))
328 , mxBoxLegend(m_xBuilder->weld_widget(
"box_legend"))
329 ,
mxModel(pController->getChartModel())
414 const std::vector<rtl::Reference<BaseCoordinateSystem>> & xCooSysSequence(xDiagram->getBaseCoordinateSystems());
416 if (xCooSysSequence.empty())
419 const std::vector<rtl::Reference<ChartType>> & xChartTypeSequence(xCooSysSequence[0]->getChartTypes2());
421 if (xChartTypeSequence.empty())
424 return xChartTypeSequence[0];
435 sal_Int32 nDimension = 0;
437 nDimension = xDiagram->getDimension();
450 if (title != newTitle)
460 if (subtitle != newSubtitle)
482 if (bSupportsMainAxis)
531 if (pParent ==
nullptr)
532 throw lang::IllegalArgumentException(
"no parent Window given to ChartElementsPanel::Create",
nullptr, 0);
533 return std::make_unique<ChartElementsPanel>(pParent, pController);
578 ::chart::ChartModel* pModel =
dynamic_cast<::chart::ChartModel*
>(
xModel.get());
579 assert(!
xModel || pModel);
585 bool bChecked = rCheckBox.get_active();
586 if (&rCheckBox == mxCBTitle.get())
588 else if (&rCheckBox == mxCBSubtitle.get())
590 else if (&rCheckBox == mxCBXAxis.get())
591 setAxisVisible(
mxModel, AxisType::X_MAIN, bChecked);
592 else if (&rCheckBox == mxCBXAxisTitle.get())
594 else if (&rCheckBox == mxCBYAxis.get())
595 setAxisVisible(
mxModel, AxisType::Y_MAIN, bChecked);
596 else if (&rCheckBox == mxCBYAxisTitle.get())
598 else if (&rCheckBox == mxCBZAxis.get())
599 setAxisVisible(
mxModel, AxisType::Z_MAIN, bChecked);
600 else if (&rCheckBox == mxCBZAxisTitle.get())
602 else if (&rCheckBox == mxCB2ndXAxis.get())
603 setAxisVisible(
mxModel, AxisType::X_SECOND, bChecked);
604 else if (&rCheckBox == mxCB2ndXAxisTitle.get())
606 else if (&rCheckBox == mxCB2ndYAxis.get())
607 setAxisVisible(
mxModel, AxisType::Y_SECOND, bChecked);
608 else if (&rCheckBox == mxCB2ndYAxisTitle.get())
610 else if (&rCheckBox == mxCBLegend.get())
612 mxBoxLegend->set_sensitive(bChecked);
613 mxCBLegendNoOverlay->set_sensitive(bChecked);
614 setLegendVisible(
mxModel, bChecked);
616 else if (&rCheckBox == mxCBLegendNoOverlay.get())
617 setLegendOverlay(
mxModel, !bChecked);
618 else if (&rCheckBox == mxCBGridVerticalMajor.get())
619 setGridVisible(
mxModel, GridType::VERT_MAJOR, bChecked);
620 else if (&rCheckBox == mxCBGridHorizontalMajor.get())
621 setGridVisible(
mxModel, GridType::HOR_MAJOR, bChecked);
622 else if (&rCheckBox == mxCBGridVerticalMinor.get())
623 setGridVisible(
mxModel, GridType::VERT_MINOR, bChecked);
624 else if (&rCheckBox == mxCBGridHorizontalMinor.get())
625 setGridVisible(
mxModel, GridType::HOR_MINOR, bChecked);
634 if (&rEdit == mxEditSubtitle.get())
638 OUString aText(rEdit.get_text());
644 sal_Int32
nPos = mxLBLegendPosition->get_active();
css::uno::Reference< css::frame::XModel2 > mxModel
virtual void DataChanged(const DataChangedEvent &rEvent)
static bool isAxisShown(sal_Int32 nDimensionIndex, bool bMainAxis, const rtl::Reference< ::chart::Diagram > &xDiagram)
static void hideAxis(sal_Int32 nDimensionIndex, bool bMainAxis, const rtl::Reference< ::chart::Diagram > &xDiagram)
static void hideGrid(sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid, const rtl::Reference< ::chart::Diagram > &xDiagram)
static void showAxis(sal_Int32 nDimensionIndex, bool bMainAxis, const rtl::Reference< ::chart::Diagram > &xDiagram, const css::uno::Reference< css::uno::XComponentContext > &xContext, ReferenceSizeProvider *pRefSizeProvider=nullptr)
static bool isGridShown(sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid, const rtl::Reference< ::chart::Diagram > &xDiagram)
static void showGrid(sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid, const rtl::Reference< ::chart::Diagram > &xDiagram)
static bool isSupportingMainAxis(const rtl::Reference< ::chart::ChartType > &xChartType, sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex)
static rtl::Reference< ::chart::Legend > getLegend(ChartModel &rModel, const css::uno::Reference< css::uno::XComponentContext > &xContext=nullptr, bool bCreate=false)
static rtl::Reference< ::chart::Legend > showLegend(ChartModel &rModel, const css::uno::Reference< css::uno::XComponentContext > &xContext)
static void hideLegend(ChartModel &rModel)
static rtl::Reference< ::chart::Title > createOrShowTitle(eTitleType nTitleIndex, const OUString &rTitleText, const rtl::Reference< ::chart::ChartModel > &xModel, const css::uno::Reference< css::uno::XComponentContext > &xContex)
static void hideTitle(eTitleType nTitleIndex, const rtl::Reference< ::chart::ChartModel > &xModel)
static rtl::Reference< ::chart::Title > getTitle(eTitleType nTitleIndex, ChartModel &rModel)
static OUString getCompleteString(const rtl::Reference< ::chart::Title > &xTitle)
static void setCompleteString(const OUString &rNewText, const rtl::Reference< ::chart::Title > &xTitle, const css::uno::Reference< css::uno::XComponentContext > &xContext, const float *pDefaultCharHeight=nullptr)
Reference< script::XScriptListener > mxListener
#define LINK(Instance, Class, Member)
Reference< XComponentContext > getProcessComponentContext()
Reference< XModel > xModel