22#include <com/sun/star/chart/ChartLegendExpansion.hpp>
23#include <com/sun/star/chart2/FormattedString.hpp>
24#include <com/sun/star/chart2/LegendPosition.hpp>
25#include <com/sun/star/chart2/XDiagram.hpp>
26#include <com/sun/star/chart2/XLegend.hpp>
27#include <com/sun/star/chart2/XTitle.hpp>
28#include <com/sun/star/chart2/XTitled.hpp>
29#include <com/sun/star/chart2/XChartTypeContainer.hpp>
30#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
31#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
34#include <osl/diagnose.h>
39#include <oox/token/properties.hxx>
40#include <oox/token/tokens.hxx>
41#include <com/sun/star/chart2/RelativePosition.hpp>
42#include <com/sun/star/drawing/Alignment.hpp>
78 ::std::vector< Reference< XFormattedString > > aStringVec;
83 for( TextParagraphVector::const_iterator aPIt = rTextParas.begin(), aPEnd = rTextParas.end(); aPIt != aPEnd; ++aPIt )
87 for( TextRunVector::const_iterator aRIt = rTextPara.
getRuns().begin(), aREnd = rTextPara.
getRuns().end(); aRIt != aREnd; ++aRIt )
89 const TextRun& rTextRun = **aRIt;
90 bool bAddNewLine = ((aRIt + 1 == aREnd) && (aPIt + 1 != aPEnd)) || rTextRun.
isLineBreak();
106 if( aString.isEmpty() )
107 aString = rDefaultText;
110 if( !aString.isEmpty() )
128 xFmtStr->setString( bAddNewLine ? (rString +
"\n") : rString );
129 orStringVec.emplace_back(xFmtStr );
155 if( !aStringSeq.hasElements() )
162 xTitle->setText( aStringSeq );
163 rxTitled->setTitleObject( xTitle );
193 if( !rxDiagram.is() )
198 namespace cssc = ::com::sun::star::chart;
199 namespace cssc2 = ::com::sun::star::chart2;
203 rxDiagram->setLegend( xLegend );
211 cssc2::LegendPosition eLegendPos = cssc2::LegendPosition_LINE_END;
212 cssc::ChartLegendExpansion eLegendExpand = cssc::ChartLegendExpansion_CUSTOM;
213 RelativePosition eRelPos;
214 bool bTopRight=
false;
218 eLegendPos = cssc2::LegendPosition_LINE_START;
219 eLegendExpand = cssc::ChartLegendExpansion_HIGH;
222 eLegendPos = cssc2::LegendPosition_LINE_END;
223 eLegendExpand = cssc::ChartLegendExpansion_HIGH;
227 eRelPos.Secondary =0;
228 eRelPos.Anchor = Alignment_TOP_RIGHT;
232 eLegendPos = cssc2::LegendPosition_PAGE_START;
233 eLegendExpand = cssc::ChartLegendExpansion_WIDE;
236 eLegendPos = cssc2::LegendPosition_PAGE_END;
237 eLegendExpand = cssc::ChartLegendExpansion_WIDE;
240 bool bManualLayout=
false;
248 eLegendExpand = cssc::ChartLegendExpansion_CUSTOM;
254 aPropSet.
setProperty( PROP_AnchorPosition, eLegendPos );
255 aPropSet.
setProperty( PROP_Expansion, eLegendExpand );
257 if (bTopRight && !bManualLayout)
274 if (!xCooSysSequence.hasElements())
278 for (
const auto& rCooSys : xCooSysSequence)
285 if (!xChartTypeSequence.hasElements())
288 for (
const auto& rCT : xChartTypeSequence)
295 = rCT->getChartType().equalsIgnoreAsciiCase(
"com.sun.star.chart2.PieChartType");
303 nIndex += aDataSeriesSeq.getLength() - 1;
304 for (
const auto& rDataSeries : aDataSeriesSeq)
307 bool bVaryColorsByPoint = aSeriesProp.
getBoolProperty(PROP_VaryColorsByPoint);
309 if (bVaryColorsByPoint || bIsPie)
316 std::vector<sal_Int32> deletedLegendEntries;
318 for (
const auto& rDataSeq : aDataSeqs)
324 sal_Int32 nDataSeqSize = xValues->getData().getLength();
325 for (sal_Int32
i = 0;
i < nDataSeqSize; ++
i)
329 if (
nIndex == rLegendEntry->mnLegendEntryIdx && rLegendEntry->mbLabelDeleted)
331 deletedLegendEntries.push_back(j +
i);
339 if (deletedLegendEntries.size() > 0)
346 if (
nIndex == rLegendEntry->mnLegendEntryIdx)
348 aSeriesProp.
setProperty(PROP_ShowLegendEntry, !rLegendEntry->mbLabelDeleted);
356 nIndex += aDataSeriesSeq.getLength() + 1;
A wrapper for a UNO property set.
bool getBoolProperty(sal_Int32 nPropId) const
Gets the specified boolean property from the property set.
bool setProperty(sal_Int32 nPropId, const Type &rValue)
Puts the passed value into the property set.
TextCharacterProperties & getTextCharacterProperties()
TextParagraphProperties & getProperties()
TextRunVector & getRuns()
TextCharacterProperties & getTextCharacterProperties()
Base class of all converter classes.
void registerTitleLayout(const css::uno::Reference< css::chart2::XTitle > &rxTitle, const ModelRef< LayoutModel > &rxLayout, ObjectType eObjType, sal_Int32 nMainIdx, sal_Int32 nSubIdx)
Registers a title object and its layout data, needed for conversion of the title position using the o...
ObjectFormatter & getFormatter() const
Returns the object formatter.
css::uno::Reference< css::uno::XInterface > createInstance(const OUString &rServiceName) const
Creates an instance for the passed service name, using the process service factory.
css::uno::Reference< css::uno::XComponentContext > const & getComponentContext() const
css::uno::Reference< css::chart2::data::XDataSequence > createDataSequence(const OUString &rRole)
Creates a data sequence object from the contained formula link.
A layout converter calculates positions and sizes for various chart objects.
bool getAutoLayout() const
bool convertFromModel(PropertySet &rPropSet)
Tries to set the position and size from the contained OOXML layout model.
virtual ~LegendConverter() override
void legendEntriesFormatting(const css::uno::Reference< css::chart2::XDiagram > &rxDiagram)
void convertFromModel(const css::uno::Reference< css::chart2::XDiagram > &rxDiagram)
Creates a legend object and attaches it at the passed diagram.
LegendConverter(const ConverterRoot &rParent, LegendModel &rModel)
ModelType & getOrCreate()
css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > > createStringSequence(const OUString &rDefaultText, const ModelRef< TextBody > &rxTextProp, ObjectType eObjType)
Creates a sequence of formatted string objects.
TextConverter(const ConverterRoot &rParent, TextModel &rModel)
virtual ~TextConverter() override
css::uno::Reference< css::chart2::XFormattedString > appendFormattedString(::std::vector< css::uno::Reference< css::chart2::XFormattedString > > &orStringVec, const OUString &rString, bool bAddNewLine) const
css::uno::Reference< css::chart2::data::XDataSequence > createDataSequence(const OUString &rRole)
Creates a data sequence object from the contained text data.
void convertFromModel(const css::uno::Reference< css::chart2::XTitled > &rxTitled, const OUString &rAutoTitle, ObjectType eObjType, sal_Int32 nMainIdx=-1, sal_Int32 nSubIdx=-1)
Creates a title text object and attaches it at the passed interface.
TitleConverter(const ConverterRoot &rParent, TitleModel &rModel)
virtual ~TitleConverter() override
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
ObjectType
Enumerates different object types for specific automatic formatting behaviour.
@ OBJECTTYPE_LEGEND
Chart title.
void assignUsed(const TextCharacterProperties &rSourceProps)
Overwrites all members that are explicitly set in rSourceProps.
ShapeRef mxShapeProp
Legend entries formatting.
LayoutRef mxLayout
Legend text formatting.
TextBodyRef mxTextProp
Legend shape formatting.
bool mbOverlay
Legend position.
sal_Int32 mnPosition
Layout/position of the legend.
LegendEntryVector maLegendEntries
TextBodyRef mxTextBody
The string data or formula link of this text.
DataSequenceRef mxDataSeq
LayoutRef mxLayout
Title text formatting.
TextBodyRef mxTextProp
Title shape formatting.
sal_Int32 mnDefaultRotation
True = title may overlay other objects.
TextRef mxText
Layout/position of the frame.