26#include <com/sun/star/frame/XModel.hpp>
27#include <com/sun/star/drawing/Direction3D.hpp>
28#include <com/sun/star/drawing/ProjectionMode.hpp>
29#include <com/sun/star/drawing/ShadeMode.hpp>
30#include <com/sun/star/drawing/XShape.hpp>
31#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
32#include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp>
33#include <com/sun/star/chart/ChartAxisLabelPosition.hpp>
34#include <com/sun/star/chart/ChartAxisMarkPosition.hpp>
35#include <com/sun/star/chart/ChartAxisPosition.hpp>
36#include <com/sun/star/chart/ChartLegendExpansion.hpp>
37#include <com/sun/star/chart/TimeInterval.hpp>
38#include <com/sun/star/chart/TimeUnit.hpp>
39#include <com/sun/star/chart/XChartDocument.hpp>
40#include <com/sun/star/chart/XDiagramPositioning.hpp>
41#include <com/sun/star/chart/DataLabelPlacement.hpp>
42#include <com/sun/star/chart/ErrorBarStyle.hpp>
43#include <com/sun/star/chart/MissingValueTreatment.hpp>
44#include <com/sun/star/chart2/LinearRegressionCurve.hpp>
45#include <com/sun/star/chart2/ExponentialRegressionCurve.hpp>
46#include <com/sun/star/chart2/LogarithmicRegressionCurve.hpp>
47#include <com/sun/star/chart2/PotentialRegressionCurve.hpp>
48#include <com/sun/star/chart2/PolynomialRegressionCurve.hpp>
49#include <com/sun/star/chart2/MovingAverageRegressionCurve.hpp>
50#include <com/sun/star/chart2/CartesianCoordinateSystem2d.hpp>
51#include <com/sun/star/chart2/CartesianCoordinateSystem3d.hpp>
52#include <com/sun/star/chart2/FormattedString.hpp>
53#include <com/sun/star/chart2/LogarithmicScaling.hpp>
54#include <com/sun/star/chart2/LinearScaling.hpp>
55#include <com/sun/star/chart2/PolarCoordinateSystem2d.hpp>
56#include <com/sun/star/chart2/PolarCoordinateSystem3d.hpp>
57#include <com/sun/star/chart2/XChartDocument.hpp>
58#include <com/sun/star/chart2/XDiagram.hpp>
59#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
60#include <com/sun/star/chart2/XChartTypeContainer.hpp>
61#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
62#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
63#include <com/sun/star/chart2/XTitled.hpp>
64#include <com/sun/star/chart2/AxisType.hpp>
65#include <com/sun/star/chart2/CurveStyle.hpp>
66#include <com/sun/star/chart2/DataPointGeometry3D.hpp>
67#include <com/sun/star/chart2/DataPointLabel.hpp>
68#include <com/sun/star/chart2/LegendPosition.hpp>
69#include <com/sun/star/chart2/StackingDirection.hpp>
70#include <com/sun/star/chart2/TickmarkStyle.hpp>
71#include <com/sun/star/chart2/RelativePosition.hpp>
72#include <com/sun/star/chart2/RelativeSize.hpp>
73#include <com/sun/star/chart2/data/XDataProvider.hpp>
74#include <com/sun/star/chart2/data/XDataReceiver.hpp>
75#include <com/sun/star/chart2/data/XDataSink.hpp>
76#include <com/sun/star/chart2/data/LabeledDataSequence.hpp>
86#include <document.hxx>
88#include <tokenarray.hxx>
89#include <compiler.hxx>
102using ::com::sun::star::uno::Any;
103using ::com::sun::star::uno::Reference;
104using ::com::sun::star::uno::Sequence;
105using ::com::sun::star::uno::UNO_QUERY;
106using ::com::sun::star::uno::UNO_QUERY_THROW;
107using ::com::sun::star::uno::UNO_SET_THROW;
108using ::com::sun::star::uno::Exception;
109using ::com::sun::star::beans::XPropertySet;
110using ::com::sun::star::frame::XModel;
111using ::com::sun::star::util::XNumberFormatsSupplier;
112using ::com::sun::star::drawing::XDrawPage;
113using ::com::sun::star::drawing::XDrawPageSupplier;
114using ::com::sun::star::drawing::XShape;
118using ::com::sun::star::chart2::data::XDataProvider;
119using ::com::sun::star::chart2::data::XDataReceiver;
120using ::com::sun::star::chart2::data::XDataSequence;
121using ::com::sun::star::chart2::data::XDataSink;
122using ::com::sun::star::chart2::data::XLabeledDataSequence;
123using ::com::sun::star::chart2::data::LabeledDataSequence;
125using ::formula::FormulaToken;
126using ::formula::FormulaTokenArrayPlainIterator;
127using ::std::unique_ptr;
129namespace cssc = ::com::sun::star::chart;
130namespace cssc2 = ::com::sun::star::chart2;
145void lclSetValueOrClearAny( Any& rAny,
double fValue,
bool bClear )
153void lclSetExpValueOrClearAny( Any& rAny,
double fValue,
bool bLogScale,
bool bClear )
155 if( !bClear && bLogScale )
156 fValue = pow( 10.0, fValue );
157 lclSetValueOrClearAny( rAny, fValue, bClear );
160double lclGetSerialDay(
const XclImpRoot& rRoot, sal_uInt16 nValue, sal_uInt16 nTimeUnit )
171 OSL_ENSURE(
false,
"lclGetSerialDay - unexpected time unit" );
176void lclConvertTimeValue(
const XclImpRoot& rRoot, Any& rAny, sal_uInt16 nValue,
bool bAuto, sal_uInt16 nTimeUnit )
181 rAny <<= lclGetSerialDay( rRoot, nValue, nTimeUnit );
184sal_Int32 lclGetApiTimeUnit( sal_uInt16 nTimeUnit )
191 default: OSL_ENSURE(
false,
"lclGetApiTimeUnit - unexpected time unit" );
193 return cssc::TimeUnit::DAY;
196void lclConvertTimeInterval( Any& rInterval, sal_uInt16 nValue,
bool bAuto, sal_uInt16 nTimeUnit )
198 if( bAuto || (nValue == 0) )
201 rInterval <<= cssc::TimeInterval( nValue, lclGetApiTimeUnit( nTimeUnit ) );
238 return mxChData->mxTypeInfoProv->GetTypeInfoFromRecId( nRecId );
243 return mxChData->mxFmtInfoProv->GetFormatInfo( eObjType );
271 xChartDoc->lockControllers();
274 Reference< XDataReceiver > xDataRec( xChartDoc, UNO_QUERY );
275 if( pDocShell && xDataRec.is() )
278 Reference< XDataProvider > xDataProv(
281 xDataRec->attachDataProvider( xDataProv );
283 Reference< XNumberFormatsSupplier > xNumFmtSupp( pDocShell->
GetModel(), UNO_QUERY );
284 if( xNumFmtSupp.is() )
285 xDataRec->attachNumberFormatsSupplier( xNumFmtSupp );
295 xModel->unlockControllers();
303 return mxChData->mxChartDoc->getDataProvider();
308 return mxChData->GetTitleShape( rTitleKey );
313 return static_cast< sal_Int32
>(
mxChData->mfUnitSizeX * nPosX +
mxChData->mnBorderGapX + 0.5 );
318 return static_cast< sal_Int32
>(
mxChData->mfUnitSizeY * nPosY +
mxChData->mnBorderGapY + 0.5 );
323 return css::awt::Rectangle(
335 return static_cast<double>(nPosX) / nWidth;
343 return static_cast<double >(nPosY) / nHeight;
360 rPropSet, *
mxChData->mxLineDashTable, rLineFmt, ePropMode );
375 rEscherFmt, pPicFmt, nDffFillType, ePropMode );
379 sal_uInt16 nFontIdx,
const Color* pFontColor )
const
386 sal_Int32 nApiRot = (450 - (nAngle % 360)) % 360;
404 rStrm.StartNextRecord();
409 while( bLoop &&
rStrm.StartNextRecord() )
411 sal_uInt16 nRecId =
rStrm.GetRecId();
426 OSL_ENSURE(
rStrm.GetRecId() ==
EXC_ID_CHBEGIN,
"XclImpChGroupBase::SkipBlock - no CHBEGIN record" );
429 while( bLoop &&
rStrm.StartNextRecord() )
431 sal_uInt16 nRecId =
rStrm.GetRecId();
542 switch(
rStrm.GetRecId() )
570 mxAreaFmt = std::make_shared<XclImpChAreaFormat>();
583 mxAreaFmt = std::make_shared<XclImpChAreaFormat>( aAreaFmt );
588 OSL_FAIL(
"XclImpChFrameBase::XclImpChFrameBase - unknown frame type" );
594 switch(
rStrm.GetRecId() )
601 mxAreaFmt = std::make_shared<XclImpChAreaFormat>();
615 mxLineFmt->Convert( rRoot, rPropSet, eObjType, nFormatIdx );
625 mxEscherFmt->Convert( rRoot, rPropSet, eObjType, bUsePicFmt );
627 mxAreaFmt->Convert( rRoot, rPropSet, eObjType, nFormatIdx );
693 mxAreaFmt = std::make_shared<XclImpChAreaFormat>( aAreaFmt );
707Reference< XLabeledDataSequence > lclCreateLabeledDataSequence(
712 Reference< XDataSequence > xValueSeq;
714 xValueSeq = xValueLink->CreateDataSequence( rValueRole );
715 Reference< XDataSequence > xTitleSeq;
720 Reference< XLabeledDataSequence > xLabeledSeq;
721 if( xValueSeq.is() || xTitleSeq.is() )
723 if( xLabeledSeq.is() )
726 xLabeledSeq->setValues( xValueSeq );
728 xLabeledSeq->setLabel( xTitleSeq );
766 mxString = std::make_shared<XclImpString>();
775 mxString = std::make_shared<XclImpString>();
782 mxString->SetFormats( std::move(rFormats) );
787 sal_uInt32 nCellCount = 0;
791 for(
const FormulaToken* pToken = aIter.First(); pToken; pToken = aIter.Next() )
793 switch( pToken->GetType() )
795 case ::formula::svSingleRef:
796 case ::formula::svExternalSingleRef:
800 case ::formula::svDoubleRef:
801 case ::formula::svExternalDoubleRef:
807 sal_uInt32 nTabs =
static_cast<sal_uInt32
>(aAbs2.
Tab() - aAbs1.
Tab() + 1);
808 sal_uInt32 nCols =
static_cast<sal_uInt32
>(aAbs2.
Col() - aAbs1.
Col() + 1);
809 sal_uInt32 nRows =
static_cast<sal_uInt32
>(aAbs2.
Row() - aAbs1.
Row() + 1);
810 nCellCount += nCols * nRows * nTabs;
817 return limit_cast< sal_uInt16 >( nCellCount );
834 Reference< XDataSequence > xDataSeq;
841 OUStringBuffer aRangeRep;
845 xDataSeq = xDataProv->createDataSequenceByRangeRepresentation( aRangeRep.makeStringAndClear() );
859 OUString aString(
"\"");
860 xDataSeq = xDataProv->createDataSequenceByRangeRepresentation( aString +
mxString->GetText() + aString );
872 const XclImpChRoot& rRoot, sal_uInt16 nLeadFontIdx,
const Color& rLeadFontColor )
const
874 ::std::vector< Reference< XFormattedString > > aStringVec;
881 xFmtStr->setString( aIt.GetPortionText() );
885 sal_uInt16 nFontIdx = aIt.GetPortionFont();
888 rRoot.
ConvertFont( aStringProp, nLeadFontIdx, &rLeadFontColor );
893 aStringVec.emplace_back(xFmtStr );
906 for (FormulaToken*
p = aIter.First();
p;
p = aIter.Next())
974 switch(
rStrm.GetRecId() )
977 mxFramePos = std::make_shared<XclImpChFramePos>();
981 mxFont = std::make_shared<XclImpChFont>();
1078 mxSrcLink->ConvertNumFmt( rPropSet, bPercent );
1092 bool bShowCateg = !bShowNone &&
::get_flag( nShowFlags, SHOWANYCATEG );
1093 bool bShowPercent = !bShowNone &&
::get_flag( nShowFlags, SHOWANYPERCENT );
1094 bool bShowValue = !bShowNone &&
::get_flag( nShowFlags, SHOWANYVALUE );
1095 bool bShowBubble = !bShowNone &&
::get_flag( nShowFlags, SHOWANYBUBBLE );
1099 bShowValue = bShowBubble;
1102 bool bShowAny = bShowValue || bShowPercent || bShowCateg;
1106 cssc2::DataPointLabel aPointLabel( bShowValue, bShowPercent, bShowCateg, bShowSymbol,
false,
false );
1109 if( aSep.isEmpty() )
1120 using namespace cssc::DataLabelPlacement;
1135 sal_Int32 nGlobalPlacement = 0;
1138 nPlacement = nGlobalPlacement;
1142 if( bShowPercent || bShowValue )
1148 Reference< XTitle > xTitle;
1152 Sequence< Reference< XFormattedString > > aStringSeq(
1154 if( aStringSeq.hasElements() )
1161 xTitle->setText( aStringSeq );
1178 "XclImpChText::ConvertTitlePosition - unexpected frame position mode" );
1202 Reference< XShape > xTitleShape(
GetTitleShape( rTitleKey ), UNO_SET_THROW );
1204 css::awt::Size aTitleSize = xTitleShape->getSize();
1208 double fSin = fabs( sin( fRad ) );
1210 css::awt::Point aTitlePos(
1214 if( nScRot > 18000_deg100 )
1215 aTitlePos.X +=
static_cast< sal_Int32
>( fSin * aTitleSize.Height + 0.5 );
1217 else if( nScRot > 0_deg100 )
1218 aTitlePos.Y +=
static_cast< sal_Int32
>( fSin * aTitleSize.Width + 0.5 );
1220 xTitleShape->setPosition( aTitlePos );
1235 nSepLen =
rStrm.ReaduInt16();
1246 rxText->UpdateText( xDefText );
1249 rxText = std::make_shared<XclImpChText>(*xDefText);
1259 if( !rxTitle->HasString() )
1260 rxTitle->SetString( rAutoTitle );
1261 if( rxTitle->HasString() )
1262 rxTitle->UpdateText(pDefText);
1291 ScfPropertySet& rPropSet, sal_uInt16 nFormatIdx, sal_Int16 nLineWeight )
const
1299 switch( nLineWeight )
1335 double fApiDist = ::std::min< double >(
mnPieDist / 100.0, 1.0 );
1357 using namespace ::com::sun::star::chart2::DataPointGeometry3D;
1383 xLabel = std::make_shared<XclImpChText>( *pParent );
1385 xLabel = std::make_shared<XclImpChText>(
GetChRoot() );
1386 xLabel->UpdateDataLabel(
1408 switch(
rStrm.GetRecId() )
1411 mxMarkerFmt = std::make_shared<XclImpChMarkerFormat>();
1415 mxPieFmt = std::make_shared<XclImpChPieFormat>();
1419 mxSeriesFmt = std::make_shared<XclImpChSeriesFormat>();
1423 mx3dDataFmt = std::make_shared<XclImpCh3dDataFormat>();
1476 mxAreaFmt = std::make_shared<XclImpChAreaFormat>();
1478 mxMarkerFmt = std::make_shared<XclImpChMarkerFormat>();
1540 rPropSet.
SetProperty< sal_Int32 >(
"BorderWidth", 0 );
1550 mxLabel->ConvertDataLabel( rPropSet, rTypeInfo, pGlobalPropSet );
1598 mxLabel->UpdateText(pDefText);
1622 Reference< XRegressionCurve > xRegCurve;
1661 if (bForceIntercept)
1674 pLabel->ConvertFont( aLabelProp );
1675 pLabel->ConvertFrame( aLabelProp );
1676 pLabel->ConvertNumFmt( aLabelProp,
false );
1711 Reference< XPropertySet > xErrorBar;
1723 switch( pPrimaryBar->maData.mnSourceType )
1746 Reference< XDataSink > xDataSink( xErrorBar, UNO_QUERY );
1747 if( xDataSink.is() )
1750 ::std::vector< Reference< XLabeledDataSequence > > aLabeledSeqVec;
1755 if( xValueSeq.is() )
1756 aLabeledSeqVec.push_back( xValueSeq );
1762 if( xValueSeq.is() )
1763 aLabeledSeqVec.push_back( xValueSeq );
1766 if( aLabeledSeqVec.empty() )
1778 if( pPrimaryBar->mxDataFmt && xErrorBar.is() )
1788 mnSeriesIdx( nSeriesIdx ),
1790 mbLabelDeleted( false )
1809 switch(
rStrm.GetRecId() )
1840 sal_uInt16 nPointIdx = xDataFmt->GetPointPos().mnPointIdx;
1853 pTypeGroup->SetUsedFormatIndex(xDataFmt->GetFormatIdx());
1862 XclImpChDataFormatMap::iterator itr =
maPointFmts.lower_bound(nPointIdx);
1866 itr =
maPointFmts.insert(itr, XclImpChDataFormatMap::value_type(nPointIdx, xDataFmt));
1875 sal_uInt16 nPointIdx = xLabel->GetPointPos().mnPointIdx;
1880 XclImpChTextMap::iterator itr =
maLabels.lower_bound(nPointIdx);
1884 itr =
maLabels.insert(itr, XclImpChTextMap::value_type(nPointIdx, xLabel));
1890 OSL_ENSURE( !
HasParentSeries(),
"XclImpChSeries::AddChildSeries - not allowed for child series" );
1891 if (&rSeries ==
this)
1893 SAL_WARN(
"sc.filter",
"self add attempt");
1903 m_ErrorBars.insert(std::make_pair(it.first, std::make_unique<XclImpChSerErrorBar>(*it.second)));
1923 xLabel = itr->second;
1935 trendLine->SetTrendlineName(
mxTitleLink->GetString());
1951 sal_uInt16 nFormatIdx = pTypeGroup->PopUnusedFormatIndex();
1958 sal_uInt16 nPointIdx =
label.first;
1968 XclImpChDataFormatMap::iterator itr =
maPointFmts.lower_bound(nPointIdx);
1975 itr, XclImpChDataFormatMap::value_type(nPointIdx,
p));
1979 p->SetDataLabel(
label.second);
1985 mxSeriesFmt->UpdateSeriesFormat( pTypeGroup->GetTypeInfo(), pTypeGroup->GetGroupFormat().get() );
1989 pointFormat.second->UpdatePointFormat( pTypeGroup->GetTypeInfo(),
mxSeriesFmt.get() );
1996ScfPropertySet lclGetPointPropSet( Reference< XDataSeries >
const & xDataSeries, sal_uInt16 nPointIdx )
2001 aPropSet.
Set( xDataSeries->getDataPointByIndex(
static_cast< sal_Int32
>( nPointIdx ) ) );
2005 OSL_FAIL(
"lclGetPointPropSet - no data point property set" );
2019 return lclCreateLabeledDataSequence(
mxCategLink, rCategRole );
2024 Reference< XDataSeries > xDataSeries;
2033 Reference< XDataSink > xDataSink( xDataSeries, UNO_QUERY );
2034 if( xDataSink.is() )
2037 ::std::vector< Reference< XLabeledDataSequence > > aLabeledSeqVec;
2039 Reference< XLabeledDataSequence > xYValueSeq =
2041 if( xYValueSeq.is() )
2042 aLabeledSeqVec.push_back( xYValueSeq );
2046 Reference< XLabeledDataSequence > xXValueSeq =
2048 if( xXValueSeq.is() )
2049 aLabeledSeqVec.push_back( xXValueSeq );
2053 Reference< XLabeledDataSequence > xSizeValueSeq =
2055 if( xSizeValueSeq.is() )
2056 aLabeledSeqVec.push_back( xSizeValueSeq );
2060 if( !aLabeledSeqVec.empty() )
2077 if( xErrorBarX.is() )
2080 if( xErrorBarY.is() )
2089 for( sal_uInt16 nPointIdx = 0, nPointCount =
mxValueLink->GetCellCount(); nPointIdx < nPointCount; ++nPointIdx )
2091 ScfPropertySet aPointProp = lclGetPointPropSet( xDataSeries, nPointIdx );
2099 ScfPropertySet aPointProp = lclGetPointPropSet( xDataSeries, pointFormat.first );
2100 pointFormat.second->Convert( aPointProp, rTypeInfo, &aSeriesProp );
2121 xSrcLink->ReadChSourceLink(
rStrm );
2122 switch( xSrcLink->GetDestType() )
2150 xTrendLine->ReadChSerTrendLine(
rStrm );
2157 pErrorBar->ReadChSerErrorBar(
rStrm);
2158 sal_uInt8 nBarType = pErrorBar->GetBarType();
2159 m_ErrorBars.insert(std::make_pair(nBarType, std::move(pErrorBar)));
2171 Reference< XRegressionCurveContainer > xRegCurveCont( xDataSeries, UNO_QUERY );
2172 if( !xRegCurveCont.is() )
2179 Reference< XRegressionCurve > xRegCurve = trendLine->CreateRegressionCurve();
2180 if( xRegCurve.is() )
2182 xRegCurveCont->addRegressionCurve( xRegCurve );
2187 OSL_FAIL(
"XclImpChSeries::ConvertTrendLines - cannot add regression curve" );
2194 XclImpChSerErrorBarMap::const_iterator itrPosBar =
m_ErrorBars.find(nPosBarId);
2195 XclImpChSerErrorBarMap::const_iterator itrNegBar =
m_ErrorBars.find(nNegBarId);
2196 XclImpChSerErrorBarMap::const_iterator itrEnd =
m_ErrorBars.end();
2197 if (itrPosBar == itrEnd || itrNegBar == itrEnd)
2198 return Reference<XPropertySet>();
2206 sal_uInt16 nFlags =
rStrm.ReaduInt16();
2221 sal_uInt16 nRecId =
rStrm.GetRecId();
2222 bool bKnownType =
true;
2317 bool bStacked =
false;
2337 bool bPercent =
false;
2365 Reference< XCoordinateSystem > xCoordSystem;
2369 xCoordSystem = css::chart2::PolarCoordinateSystem3d::create(xContext);
2371 xCoordSystem = css::chart2::PolarCoordinateSystem2d::create(xContext);
2376 xCoordSystem = css::chart2::CartesianCoordinateSystem3d::create(xContext);
2378 xCoordSystem = css::chart2::CartesianCoordinateSystem2d::create(xContext);
2388 return xCoordSystem;
2441 namespace cssd = ::com::sun::star::drawing;
2446 sal_Int32 nRotationY = 0;
2447 sal_Int32 nRotationX = 0;
2448 sal_Int32 nPerspective = 15;
2449 bool bRightAngled =
false;
2450 cssd::ProjectionMode eProjMode = cssd::ProjectionMode_PERSPECTIVE;
2451 Color aAmbientColor, aLightColor;
2460 nPerspective = limit_cast< sal_Int32, sal_Int32 >(
maData.
mnEyeDist, 0, 100 );
2464 bool bParallel = bRightAngled || (nPerspective == 0);
2465 eProjMode = bParallel ? cssd::ProjectionMode_PARALLEL : cssd::ProjectionMode_PERSPECTIVE;
2467 aAmbientColor =
Color( 204, 204, 204 );
2469 aLightColor =
Color( 102, 102, 102 );
2477 nRotationX = limit_cast< sal_Int32, sal_Int32 >(
maData.
mnElevation, 10, 80 ) - 90;
2479 nPerspective = limit_cast< sal_Int32, sal_Int32 >(
maData.
mnEyeDist, 0, 100 );
2481 bRightAngled =
false;
2482 eProjMode = cssd::ProjectionMode_PARALLEL;
2484 aAmbientColor =
Color( 179, 179, 179 );
2486 aLightColor =
Color( 76, 76, 76 );
2530 switch(
rStrm.GetRecId() )
2533 mxFramePos = std::make_shared<XclImpChFramePos>();
2566 mxFrame->Convert( aLegendProp );
2569 mxText->ConvertFont( aLegendProp );
2575 cssc2::LegendPosition eApiPos = cssc2::LegendPosition_LINE_END;
2576 cssc::ChartLegendExpansion eApiExpand = cssc::ChartLegendExpansion_CUSTOM;
2580 eApiPos = cssc2::LegendPosition_LINE_START;
2581 eApiExpand = cssc::ChartLegendExpansion_HIGH;
2586 eApiPos = cssc2::LegendPosition_LINE_END;
2587 eApiExpand = cssc::ChartLegendExpansion_HIGH;
2590 eApiPos = cssc2::LegendPosition_PAGE_START;
2591 eApiExpand = cssc::ChartLegendExpansion_WIDE;
2594 eApiPos = cssc2::LegendPosition_PAGE_END;
2595 eApiExpand = cssc::ChartLegendExpansion_WIDE;
2609 RelativePosition aRelPos(
2612 css::drawing::Alignment_TOP_LEFT );
2618 eApiPos = cssc2::LegendPosition_LINE_END;
2627 eApiExpand = cssc::ChartLegendExpansion_CUSTOM;
2637 cssc::ChartLegendExpansion_HIGH, cssc::ChartLegendExpansion_WIDE );
2647 mnDropBar( nDropBar ),
2687 switch(
rStrm.GetRecId() )
2690 mxChart3d = std::make_shared<XclImpChChart3d>();
2752 OSL_ENSURE( !
maUnusedFormats.empty(),
"XclImpChTypeGroup::PopUnusedFormatIndex - no more format indexes available" );
2772 return (aConLine !=
m_ChartLines.end() && aConLine->second.HasLine());
2796 OSL_ENSURE(
IsValidGroup(),
"XclImpChTypeGroup::CreateChartType - type group without series" );
2820 Reference< XLabeledDataSequence > xLabeledSeq;
2832 p->ReadRecordGroup(
rStrm);
2838 p->ReadRecordGroup(
rStrm);
2845 sal_uInt16 nLineId =
rStrm.ReaduInt16();
2858 xDataFmt->ReadRecordGroup(
rStrm );
2866 Reference< XDataSeries >
const & xSeries, sal_Int32 nApiAxesSetIdx )
const
2868 Reference< XDataSeriesContainer > xSeriesCont( xChartType, UNO_QUERY );
2869 if( !(xSeriesCont.is() && xSeries.is()) )
2873 cssc2::StackingDirection eStacking = cssc2::StackingDirection_NO_STACKING;
2876 eStacking = cssc2::StackingDirection_Y_STACKING;
2878 eStacking = cssc2::StackingDirection_Z_STACKING;
2888 xSeriesCont->addDataSeries( xSeries );
2892 OSL_FAIL(
"XclImpChTypeGroup::InsertDataSeries - cannot add data series" );
2898 bool bSpline =
false;
2901 Reference< XDataSeries > xDataSeries = elem->CreateDataSeries();
2903 bSpline |= elem->HasSpline();
2917 Reference< XDataSink > xDataSink( xDataSeries, UNO_QUERY );
2918 if( !xDataSink.is() )
2922 ::std::vector< Reference< XLabeledDataSequence > > aLabeledSeqVec;
2923 OSL_ENSURE(
maSeries.size() >= 3,
"XclImpChTypeGroup::CreateChartType - missing stock series" );
2924 int nRoleIdx = (
maSeries.size() == 3) ? 1 : 0;
2925 for(
const auto& rxSeries :
maSeries )
2936 Reference< XLabeledDataSequence > xDataSeq = rxSeries->CreateValueSequence( aRole );
2938 aLabeledSeqVec.push_back( xDataSeq );
2961 Reference<XPropertySet> xWhitePropSet;
2965 itr->second->Convert(
GetChRoot(), aBarProp);
2969 Reference<XPropertySet> xBlackPropSet;
2973 itr->second->Convert(
GetChRoot(), aBarProp);
3025 cssc::TimeIncrement& rTimeIncrement = rScaleData.TimeIncrement;
3030 rTimeIncrement.TimeResolution.clear();
3046 rScaleData.Orientation = bReverse ? cssc2::AxisOrientation_REVERSE : cssc2::AxisOrientation_MATHEMATICAL;
3058 cssc::ChartAxisPosition eAxisPos = bMaxCross ? cssc::ChartAxisPosition_END : cssc::ChartAxisPosition_VALUE;
3114 IncrementData& rIncrementData = rScaleData.IncrementData;
3115 lclSetValueOrClearAny( rIncrementData.Distance,
maData.
mfMajorStep, bAutoMajor );
3117 Sequence< SubIncrement >& rSubIncrementSeq = rIncrementData.SubIncrements;
3118 rSubIncrementSeq.realloc( 1 );
3119 Any& rIntervalCount = rSubIncrementSeq.getArray()[ 0 ].IntervalCount;
3120 rIntervalCount.clear();
3124 rIntervalCount <<= sal_Int32( 9 );
3129 if( (1.0 <= fCount) && (fCount < 1001.0) )
3130 rIntervalCount <<= static_cast< sal_Int32 >( fCount );
3132 else if( bAutoMinor )
3135 rIntervalCount <<= static_cast< sal_Int32 >( 5 );
3140 rScaleData.Orientation = bReverse ? cssc2::AxisOrientation_REVERSE : cssc2::AxisOrientation_MATHEMATICAL;
3150 cssc::ChartAxisPosition eAxisPos = bMaxCross ? cssc::ChartAxisPosition_END : cssc::ChartAxisPosition_VALUE;
3155 if( bLogScale ) fCrossingPos = pow( 10.0, fCrossingPos );
3161sal_Int32 lclGetApiTickmarks(
sal_uInt8 nXclTickPos )
3163 using namespace ::com::sun::star::chart2::TickmarkStyle;
3167 return nApiTickmarks;
3170cssc::ChartAxisLabelPosition lclGetApiLabelPosition(
sal_Int8 nXclLabelPos )
3173 switch( nXclLabelPos )
3175 case EXC_CHTICK_LOW:
return ChartAxisLabelPosition_OUTSIDE_START;
3179 return ChartAxisLabelPosition_NEAR_AXIS;
3251 switch(
rStrm.GetRecId() )
3274 mxFont = std::make_shared<XclImpChFont>();
3341 mxTick->Convert( aAxisProp );
3359 bool bLinkNumberFmtToSource =
true;
3366 bLinkNumberFmtToSource =
false;
3376 ScaleData aScaleData = xAxis->getScaleData();
3383 aScaleData.AxisType = cssc2::AxisType::CATEGORY;
3387 aScaleData.AxisType = cssc2::AxisType::REALNUMBER;
3390 aScaleData.AxisType = rTypeGroup.
IsPercent() ?
3394 aScaleData.AxisType = cssc2::AxisType::SERIES;
3398 switch( aScaleData.AxisType )
3400 case cssc2::AxisType::CATEGORY:
3401 case cssc2::AxisType::SERIES:
3406 SAL_WARN(
"sc.filter",
"missing LabelRange");
3408 case cssc2::AxisType::REALNUMBER:
3414 SAL_WARN(
"sc.filter",
"missing ValueRange");
3417 OSL_FAIL(
"XclImpChAxis::CreateAxis - unknown axis type" );
3422 aScaleData.Origin.clear();
3425 xAxis->setScaleData( aScaleData );
3435 Sequence< Reference< XPropertySet > > aSubGridPropSeq = xAxis->getSubGridProperties();
3436 if( aSubGridPropSeq.hasElements() )
3466 SAL_WARN(
"sc.filter",
"missing LabelRange");
3473 SAL_WARN(
"sc.filter",
"missing ValueRange");
3480 bool bWallFrame =
false;
3481 switch(
rStrm.ReaduInt16() )
3491 bool bLoop = pxLineFmt || bWallFrame;
3494 sal_uInt16 nRecId =
rStrm.GetNextRecId();
3498 &&
rStrm.StartNextRecord();
3504 (*pxLineFmt)->ReadChLineFormat(
rStrm );
3543 switch(
rStrm.GetRecId() )
3546 mxFramePos = std::make_shared<XclImpChFramePos>();
3573 xTypeGroup->Finalize();
3574 if( xTypeGroup->IsValidGroup() )
3575 aValidGroups.emplace(typeGroup.first, xTypeGroup);
3599 OUString aAutoTitle(
ScResId(STR_AXISTITLE));
3600 lclFinalizeTitle(
mxXAxisTitle, pDefText, aAutoTitle );
3601 lclFinalizeTitle(
mxYAxisTitle, pDefText, aAutoTitle );
3602 lclFinalizeTitle(
mxZAxisTitle, pDefText, aAutoTitle );
3611 XclImpChTypeGroupMap::const_iterator itr =
maTypeGroups.find(nGroupIdx);
3628 xLegend = rEntry.second->GetLegend();
3651 if( !xCoordSystem.is() )
3657 Reference< XCoordinateSystemContainer > xCoordSystemCont( xDiagram, UNO_QUERY_THROW );
3658 Sequence< Reference< XCoordinateSystem > > aCoordSystems = xCoordSystemCont->getCoordinateSystems();
3659 if( !aCoordSystems.hasElements() )
3660 xCoordSystemCont->addCoordinateSystem( xCoordSystem );
3664 OSL_FAIL(
"XclImpChAxesSet::Convert - cannot insert coordinate system" );
3686 xAxis->ReadRecordGroup(
rStrm );
3688 switch( xAxis->GetAxisType() )
3699 xText->ReadRecordGroup(
rStrm );
3701 switch( xText->GetLinkTarget() )
3721 xTypeGroup->ReadRecordGroup(
rStrm );
3722 sal_uInt16 nGroupIdx = xTypeGroup->GetGroupIdx();
3723 XclImpChTypeGroupMap::iterator itr =
maTypeGroups.lower_bound(nGroupIdx);
3726 itr->second = xTypeGroup;
3729 itr, XclImpChTypeGroupMap::value_type(nGroupIdx, xTypeGroup));
3734 Reference< XCoordinateSystem > xCoordSystem;
3739 Reference< XCoordinateSystemContainer > xCoordSystemCont( xDiagram, UNO_QUERY );
3740 if( xCoordSystemCont.is() )
3742 Sequence< Reference< XCoordinateSystem > > aCoordSystems = xCoordSystemCont->getCoordinateSystems();
3743 OSL_ENSURE( aCoordSystems.getLength() <= 1,
"XclImpChAxesSet::CreateCoordSystem - too many existing coordinate systems" );
3744 if( aCoordSystems.hasElements() )
3745 xCoordSystem = aCoordSystems[ 0 ];
3749 if( !xCoordSystem.is() )
3754 xCoordSystem = xTypeGroup->CreateCoordSystem();
3757 xTypeGroup->ConvertChart3d( aDiaProp );
3763 Reference< XChartTypeContainer > xChartTypeCont( xCoordSystem, UNO_QUERY );
3764 if( xChartTypeCont.is() )
3771 Reference< XChartType > xChartType = rEntry.second->CreateChartType( xDiagram, nApiAxesSetIdx );
3772 if( xChartType.is() )
3773 xChartTypeCont->addChartType( xChartType );
3777 OSL_FAIL(
"XclImpChAxesSet::CreateCoordSystem - cannot add chart type" );
3782 return xCoordSystem;
3787 Reference< XCoordinateSystem >
const & xCoordSystem,
const XclImpChAxis* pCrossingAxis )
const
3793 Reference< XAxis > xAxis =
CreateAxis( *xChAxis, pCrossingAxis );
3798 if( xChAxisTitle )
try
3800 Reference< XTitled > xTitled( xAxis, UNO_QUERY_THROW );
3801 Reference< XTitle > xTitle( xChAxisTitle->CreateTitle(), UNO_SET_THROW );
3802 xTitled->setTitleObject( xTitle );
3806 OSL_FAIL(
"XclImpChAxesSet::ConvertAxis - cannot set axis title" );
3812 sal_Int32 nApiAxisDim = xChAxis->GetApiAxisDimension();
3814 xCoordSystem->setAxisByDimension( nApiAxisDim, xAxis, nApiAxesSetIdx );
3818 OSL_FAIL(
"XclImpChAxesSet::ConvertAxis - cannot set axis" );
3824 Reference< XAxis > xAxis;
3826 xAxis = rChAxis.
CreateAxis( *pTypeGroup, pCrossingAxis );
3833 if( xTypeGroup && xTypeGroup->Is3dWallChart() )
3839 mxXAxis->ConvertWall( aWallProp );
3844 mxYAxis->ConvertWall( aFloorProp );
3876 switch(
rStrm.GetRecId() )
3905 sal_uInt16 nTextId =
rStrm.ReaduInt16();
3909 pText->ReadRecordGroup(
rStrm);
3910 m_DefTexts.insert(std::make_pair(nTextId, std::move(pText)));
3917 xDataFmt->ReadRecordGroup(
rStrm );
3921 XclImpChDataFormatMap::iterator itr =
maDataFmts.lower_bound(rPos);
3925 itr, XclImpChDataFormatMap::value_type(rPos, xDataFmt));
3936 mxFrame->UpdateObjFrame( rLineData, rFillData );
3942 if( !xTypeGroup ) xTypeGroup =
mxSecnAxesSet->GetTypeGroup( nGroupIdx );
3943 if( !xTypeGroup ) xTypeGroup =
mxPrimAxesSet->GetFirstTypeGroup();
3960 XclImpChTextMap::const_iterator
const itr =
m_DefTexts.find(nDefTextId);
3961 return itr ==
m_DefTexts.end() ? nullptr : itr->second.get();
3980 mxFrame->Convert( aFrameProp );
3986 Reference< XTitled > xTitled( xChartDoc, UNO_QUERY_THROW );
3987 Reference< XTitle > xTitle(
mxTitle->CreateTitle(), UNO_SET_THROW );
3988 xTitled->setTitleObject( xTitle );
3997 xChartDoc->setFirstDiagram( xDiagram );
4005 xDiagram->setLegend(
mxLegend->CreateLegend() );
4009 Reference< cssc::XChartDocument > xChart1Doc( xChartDoc, UNO_QUERY );
4010 if( xChart1Doc.is() )
4012 Reference< cssc::XDiagram > xDiagram1 = xChart1Doc->getDiagram();
4025 const XclChFramePos& rFramePos = xPlotAreaPos->GetFramePosData();
4028 Reference< cssc::XDiagramPositioning > xPositioning( xDiagram1, UNO_QUERY_THROW );
4033 xPositioning->setDiagramPositionExcludingAxes( aDiagramRect );
4034 else if( pFirstTypeGroup && pFirstTypeGroup->
Is3dChart() )
4035 xPositioning->setDiagramPositionIncludingAxesAndAxisTitles( aDiagramRect );
4037 xPositioning->setDiagramPositionIncludingAxes( aDiagramRect );
4057 if(!pChartCollection)
4060 std::vector< ScTokenRef > aRefTokens;
4061 for(
const auto& rxSeries :
maSeries )
4062 rxSeries->FillAllSourceLinks( aRefTokens );
4063 if( !aRefTokens.empty() )
4065 ::std::unique_ptr< ScChartListener > xListener(
new ScChartListener( rObjName, rDoc, std::move(aRefTokens) ) );
4066 xListener->SetUsed(
true );
4067 xListener->StartListeningTo();
4068 pChartCollection->
insert( xListener.release() );
4074 sal_uInt16 nNewSeriesIdx =
static_cast< sal_uInt16
>(
maSeries.size() );
4076 xSeries->ReadRecordGroup(
rStrm );
4089 xAxesSet->ReadRecordGroup(
rStrm );
4090 switch( xAxesSet->GetAxesSetId() )
4100 xText->ReadRecordGroup(
rStrm );
4101 switch( xText->GetLinkTarget() )
4108 sal_uInt16 nSeriesIdx = xText->GetPointPos().mnSeriesIdx;
4110 maSeries[ nSeriesIdx ]->SetDataLabel( xText );
4142 if( xSeries->HasParentSeries() )
4146 if( xSeries->GetParentIdx() <
maSeries.size() )
4147 maSeries[ xSeries->GetParentIdx() ]->AddChildSeries( *xSeries );
4153 pTypeGroup->AddSeries( xSeries );
4168 for(
const auto& [rPos, rDataFmt] :
maDataFmts )
4170 sal_uInt16 nSeriesIdx = rPos.mnSeriesIdx;
4172 maSeries[ nSeriesIdx ]->SetDataFormat( rDataFmt );
4179 rxSeries->FinalizeDataFormats();
4185 OUString aAutoTitle;
4191 if(
mxTitle || (!aAutoTitle.isEmpty()) )
4195 if( aAutoTitle.isEmpty() )
4196 aAutoTitle =
ScResId(STR_CHARTTITLE);
4213 using namespace cssc::MissingValueTreatment;
4214 sal_Int32 nMissingValues = LEAVE_GAP;
4228 mnScTab( rRoot.GetCurrScTab() ),
4251 Reference< XDrawPageSupplier > xDrawPageSupp( rxModel, UNO_QUERY_THROW );
4252 Reference< XDrawPage > xDrawPage( xDrawPageSupp->getDrawPage(), UNO_SET_THROW );
4253 pSdrPage = ::GetSdrPageFromXDrawPage( xDrawPage );
4261 if( pSdrModel && pSdrPage )
4288 mbOwnTab( bOwnTab ),
4289 mbIsPivotChart( false )
4303 while( bLoop &&
rStrm.StartNextRecord() )
4338 switch(
rStrm.GetRecId() )
4380 mxChartData->UpdateObjFrame( rLineData, rFillData );
4392 Reference< XChartDocument > xChartDoc(
xModel, UNO_QUERY );
4393 if( xChartDoc.is() )
4396 mxChartData->Convert( xChartDoc, rDffConv, rObjName, rChartRect );
bool insert(ScChartListener *pListener)
SC_DLLPUBLIC ScChartListenerCollection * GetChartListenerCollection() const
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
static css::uno::Sequence< Type > VectorToSequence(const ::std::vector< Type > &rVector)
Converts a non-empty vector into a UNO sequence containing elements of the same type.
static css::uno::Reference< css::uno::XInterface > CreateInstance(const css::uno::Reference< css::lang::XMultiServiceFactory > &xFactory, const OUString &rServiceName)
Creates an instance from the passed service name, using the passed service factory.
A wrapper for a UNO property set.
void SetProperty(const OUString &rPropName, const Type &rValue)
Puts the passed value into the property set.
void Set(css::uno::Reference< css::beans::XPropertySet > const &xPropSet)
Sets the passed UNO property set and releases the old UNO property set.
void SetColorProperty(const OUString &rPropName, const Color &rColor)
Puts the passed color into the property set.
void SetStringProperty(const OUString &rPropName, const OUString &rValue)
Puts the passed string into the property set.
void SetBoolProperty(const OUString &rPropName, bool bValue)
Puts the passed Boolean value into the property set.
bool GetProperty(Type &rValue, const OUString &rPropName) const
Gets the specified property from the property set.
void SetAnyProperty(const OUString &rPropName, const css::uno::Any &rValue)
Puts the passed Any into the property set.
const SfxItemPool & GetItemPool() const
SdrModel & getSdrModelFromSdrPage() const
css::uno::Reference< css::frame::XModel3 > GetModel() const
SvStream & ReadDouble(double &rDouble)
SvStream & ReadInt16(sal_Int16 &rInt16)
SvStream & ReadInt32(sal_Int32 &rInt32)
static void WriteMarkerProperties(ScfPropertySet &rPropSet, const XclChMarkerFormat &rMarkerFmt)
Writes all marker properties to the passed property set.
static void WriteRotationProperties(ScfPropertySet &rPropSet, sal_uInt16 nRotation, bool bSupportsStacked)
Writes rotation properties to the passed property set.
void WriteAreaProperties(ScfPropertySet &rPropSet, const XclChAreaFormat &rAreaFmt, XclChPropertyMode ePropMode)
Writes solid area properties to the passed property set.
void WriteEscherProperties(ScfPropertySet &rPropSet, XclChObjectTable &rGradientTable, XclChObjectTable &rBitmapTable, const XclChEscherFormat &rEscherFmt, const XclChPicFormat *pPicFmt, sal_uInt32 nDffFillType, XclChPropertyMode ePropMode)
Writes gradient or bitmap area properties to the passed property set.
void WriteLineProperties(ScfPropertySet &rPropSet, XclChObjectTable &rDashTable, const XclChLineFormat &rLineFmt, XclChPropertyMode ePropMode)
Writes all line properties to the passed property set.
static sal_uInt16 GetSeriesFillAutoColorIdx(sal_uInt16 nFormatIdx)
Returns a palette index for automatic series fill colors.
static sal_uInt16 GetSeriesLineAutoColorIdx(sal_uInt16 nFormatIdx)
Returns a palette index for automatic series line colors.
static sal_uInt8 GetSeriesFillAutoTransp(sal_uInt16 nFormatIdx)
Returns a transparency value for automatic series fill colors.
static sal_uInt16 GetAutoMarkerType(sal_uInt16 nFormatIdx)
Returns an automatic symbol index for the passed format index.
static OUString GetErrorBarValuesRole(sal_uInt8 nBarType)
Returns the role name for a manual data source for error bars.
void ReadChAttachedLabel(XclImpStream &rStrm)
Reads the CHATTACHEDLABEL record (data series/point labels).
XclImpChAttachedLabel(const XclImpChRoot &rRoot)
XclImpChTextRef CreateDataLabel(const XclImpChText *pParent) const
Creates a CHTEXT group for the label.
void ConvertBackground(css::uno::Reference< css::chart2::XDiagram > const &xDiagram) const
Writes all properties of the background area to the passed diagram.
XclImpChTextRef mxXAxisTitle
The Z axis (CHAXIS group).
::std::map< sal_uInt16, XclImpChTypeGroupRef > XclImpChTypeGroupMap
void Convert(css::uno::Reference< css::chart2::XDiagram > const &xDiagram) const
Creates a coordinate system and converts all series and axis settings.
XclImpChAxesSet(const XclImpChRoot &rRoot, sal_uInt16 nAxesSetId)
sal_Int32 GetApiAxesSetIndex() const
Returns the axes set index used by the chart API.
OUString GetSingleSeriesTitle() const
Returns series title, if the axes set contains only one single series.
void ConvertTitlePositions() const
Converts the manual positions of all axis titles.
css::uno::Reference< css::chart2::XCoordinateSystem > CreateCoordSystem(css::uno::Reference< css::chart2::XDiagram > const &xDiagram) const
Creates a coordinate system that contains all chart types for this axes set.
bool IsValidAxesSet() const
Returns true, if this axes set exists (returns false if this is a dummy object).
void Finalize()
Final processing after reading the entire chart.
XclImpChTextRef mxYAxisTitle
The X axis title (CHTEXT group).
XclImpChAxisRef mxXAxis
Outer plot area position (CHFRAMEPOS record).
XclImpChAxisRef mxZAxis
The Y axis (CHAXIS group).
XclImpChAxisRef mxYAxis
The X axis (CHAXIS group).
virtual void ReadSubRecord(XclImpStream &rStrm) override
Reads a record from the CHAXESSET group (called by base class).
void ReadChPlotFrame(XclImpStream &rStrm)
Reads the CHPLOTFRAME record group containing diagram area formatting.
void ReadChAxis(XclImpStream &rStrm)
Reads a CHAXIS record group containing a single axis.
void ReadChText(XclImpStream &rStrm)
Reads a CHTEXT record group containing an axis title.
XclImpChLegendRef GetLegend() const
Looks for a legend in all chart type groups and returns it.
css::uno::Reference< css::chart2::XAxis > CreateAxis(const XclImpChAxis &rChAxis, const XclImpChAxis *pCrossingAxis) const
Creates and returns an API axis object.
void ConvertAxis(XclImpChAxisRef const &xChAxis, XclImpChTextRef const &xChAxisTitle, css::uno::Reference< css::chart2::XCoordinateSystem > const &xCoordSystem, const XclImpChAxis *pCrossingAxis) const
Creates and inserts an axis into the container and registers the coordinate system.
sal_uInt16 GetAxesSetId() const
Returns the index