24#include <com/sun/star/chart/ChartLegendExpansion.hpp>
25#include <com/sun/star/chart2/LegendPosition.hpp>
26#include <com/sun/star/chart2/RelativePosition.hpp>
27#include <com/sun/star/uno/XComponentContext.hpp>
31using ::com::sun::star::uno::Reference;
42 xLegend->setPropertyValue(
"Show",
uno::Any(
true) );
44 chart2::RelativePosition aRelativePosition;
45 if( !(xLegend->getPropertyValue(
"RelativePosition") >>= aRelativePosition) )
47 chart2::LegendPosition
ePos = chart2::LegendPosition_LINE_END;
48 if( !(xLegend->getPropertyValue(
"AnchorPosition") >>=
ePos ) )
49 xLegend->setPropertyValue(
"AnchorPosition",
uno::Any(
ePos ));
51 css::chart::ChartLegendExpansion eExpansion =
52 (
ePos == chart2::LegendPosition_LINE_END ||
53 ePos == chart2::LegendPosition_LINE_START )
54 ? css::chart::ChartLegendExpansion_HIGH
55 : css::chart::ChartLegendExpansion_WIDE;
56 if( !(xLegend->getPropertyValue(
"Expansion") >>= eExpansion ) )
57 xLegend->setPropertyValue(
"Expansion",
uno::Any( eExpansion ));
59 xLegend->setPropertyValue(
"RelativePosition",
uno::Any());
71 xLegend->setPropertyValue(
"Show",
uno::Any(
false) );
87 xResult = xDia->getLegend2();
88 if( bCreate && !xResult.is() && xContext.is() )
91 xDia->setLegend( xResult );
96 OSL_FAIL(
"need diagram for creation of legend");
99 catch(
const uno::Exception & )
109 bool bReturn =
false;
113 if( xLegendProp.is())
114 xLegendProp->getPropertyValue(
"Show") >>= bReturn;
css::chart::ChartAxisLabelPosition ePos
static bool hasLegend(const rtl::Reference< ::chart::Diagram > &xDiagram)
returns <FALSE>, if either there is no legend at the diagram, or there is a legend which has a "Show"...
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)
#define DBG_UNHANDLED_EXCEPTION(...)