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())
979 switch(
rStrm.GetRecId() )
982 mxFramePos = std::make_shared<XclImpChFramePos>();
986 mxFont = std::make_shared<XclImpChFont>();
1083 mxSrcLink->ConvertNumFmt( rPropSet, bPercent );
1097 bool bShowCateg = !bShowNone &&
::get_flag( nShowFlags, SHOWANYCATEG );
1098 bool bShowPercent = !bShowNone &&
::get_flag( nShowFlags, SHOWANYPERCENT );
1099 bool bShowValue = !bShowNone &&
::get_flag( nShowFlags, SHOWANYVALUE );
1100 bool bShowBubble = !bShowNone &&
::get_flag( nShowFlags, SHOWANYBUBBLE );
1104 bShowValue = bShowBubble;
1107 bool bShowAny = bShowValue || bShowPercent || bShowCateg;
1111 cssc2::DataPointLabel aPointLabel( bShowValue, bShowPercent, bShowCateg, bShowSymbol,
false,
false );
1114 if( aSep.isEmpty() )
1125 using namespace cssc::DataLabelPlacement;
1140 sal_Int32 nGlobalPlacement = 0;
1143 nPlacement = nGlobalPlacement;
1147 if( bShowPercent || bShowValue )
1153 Reference< XTitle > xTitle;
1157 Sequence< Reference< XFormattedString > > aStringSeq(
1159 if( aStringSeq.hasElements() )
1166 xTitle->setText( aStringSeq );
1183 "XclImpChText::ConvertTitlePosition - unexpected frame position mode" );
1207 Reference< XShape > xTitleShape(
GetTitleShape( rTitleKey ), UNO_SET_THROW );
1209 css::awt::Size aTitleSize = xTitleShape->getSize();
1213 double fSin = fabs( sin( fRad ) );
1215 css::awt::Point aTitlePos(
1219 if( nScRot > 18000_deg100 )
1220 aTitlePos.X +=
static_cast< sal_Int32
>( fSin * aTitleSize.Height + 0.5 );
1222 else if( nScRot > 0_deg100 )
1223 aTitlePos.Y +=
static_cast< sal_Int32
>( fSin * aTitleSize.Width + 0.5 );
1225 xTitleShape->setPosition( aTitlePos );
1240 nSepLen =
rStrm.ReaduInt16();
1251 rxText->UpdateText( xDefText );
1254 rxText = std::make_shared<XclImpChText>(*xDefText);
1264 if( !rxTitle->HasString() )
1265 rxTitle->SetString( rAutoTitle );
1266 if( rxTitle->HasString() )
1267 rxTitle->UpdateText(pDefText);
1296 ScfPropertySet& rPropSet, sal_uInt16 nFormatIdx, sal_Int16 nLineWeight )
const
1304 switch( nLineWeight )
1340 double fApiDist = ::std::min< double >(
mnPieDist / 100.0, 1.0 );
1362 using namespace ::com::sun::star::chart2::DataPointGeometry3D;
1388 xLabel = std::make_shared<XclImpChText>( *pParent );
1390 xLabel = std::make_shared<XclImpChText>(
GetChRoot() );
1391 xLabel->UpdateDataLabel(
1413 switch(
rStrm.GetRecId() )
1416 mxMarkerFmt = std::make_shared<XclImpChMarkerFormat>();
1420 mxPieFmt = std::make_shared<XclImpChPieFormat>();
1424 mxSeriesFmt = std::make_shared<XclImpChSeriesFormat>();
1428 mx3dDataFmt = std::make_shared<XclImpCh3dDataFormat>();
1481 mxAreaFmt = std::make_shared<XclImpChAreaFormat>();
1483 mxMarkerFmt = std::make_shared<XclImpChMarkerFormat>();
1545 rPropSet.
SetProperty< sal_Int32 >(
"BorderWidth", 0 );
1555 mxLabel->ConvertDataLabel( rPropSet, rTypeInfo, pGlobalPropSet );
1603 mxLabel->UpdateText(pDefText);
1627 Reference< XRegressionCurve > xRegCurve;
1666 if (bForceIntercept)
1679 pLabel->ConvertFont( aLabelProp );
1680 pLabel->ConvertFrame( aLabelProp );
1681 pLabel->ConvertNumFmt( aLabelProp,
false );
1716 Reference< XPropertySet > xErrorBar;
1728 switch( pPrimaryBar->maData.mnSourceType )
1751 Reference< XDataSink > xDataSink( xErrorBar, UNO_QUERY );
1752 if( xDataSink.is() )
1755 ::std::vector< Reference< XLabeledDataSequence > > aLabeledSeqVec;
1760 if( xValueSeq.is() )
1761 aLabeledSeqVec.push_back( xValueSeq );
1767 if( xValueSeq.is() )
1768 aLabeledSeqVec.push_back( xValueSeq );
1771 if( aLabeledSeqVec.empty() )
1783 if( pPrimaryBar->mxDataFmt && xErrorBar.is() )
1793 mnSeriesIdx( nSeriesIdx ),
1795 mbLabelDeleted( false )
1814 switch(
rStrm.GetRecId() )
1845 sal_uInt16 nPointIdx = xDataFmt->GetPointPos().mnPointIdx;
1858 pTypeGroup->SetUsedFormatIndex(xDataFmt->GetFormatIdx());
1867 XclImpChDataFormatMap::iterator itr =
maPointFmts.lower_bound(nPointIdx);
1871 itr =
maPointFmts.insert(itr, XclImpChDataFormatMap::value_type(nPointIdx, xDataFmt));
1880 sal_uInt16 nPointIdx = xLabel->GetPointPos().mnPointIdx;
1885 XclImpChTextMap::iterator itr =
maLabels.lower_bound(nPointIdx);
1889 itr =
maLabels.insert(itr, XclImpChTextMap::value_type(nPointIdx, xLabel));
1895 OSL_ENSURE( !
HasParentSeries(),
"XclImpChSeries::AddChildSeries - not allowed for child series" );
1896 if (&rSeries ==
this)
1898 SAL_WARN(
"sc.filter",
"self add attempt");
1908 m_ErrorBars.insert(std::make_pair(it.first, std::make_unique<XclImpChSerErrorBar>(*it.second)));
1928 xLabel = itr->second;
1940 trendLine->SetTrendlineName(
mxTitleLink->GetString());
1956 sal_uInt16 nFormatIdx = pTypeGroup->PopUnusedFormatIndex();
1963 sal_uInt16 nPointIdx =
label.first;
1973 XclImpChDataFormatMap::iterator itr =
maPointFmts.lower_bound(nPointIdx);
1980 itr, XclImpChDataFormatMap::value_type(nPointIdx,
p));
1984 p->SetDataLabel(
label.second);
1990 mxSeriesFmt->UpdateSeriesFormat( pTypeGroup->GetTypeInfo(), pTypeGroup->GetGroupFormat().get() );
1994 pointFormat.second->UpdatePointFormat( pTypeGroup->GetTypeInfo(),
mxSeriesFmt.get() );
2001ScfPropertySet lclGetPointPropSet( Reference< XDataSeries >
const & xDataSeries, sal_uInt16 nPointIdx )
2006 aPropSet.
Set( xDataSeries->getDataPointByIndex(
static_cast< sal_Int32
>( nPointIdx ) ) );
2010 OSL_FAIL(
"lclGetPointPropSet - no data point property set" );
2024 return lclCreateLabeledDataSequence(
mxCategLink, rCategRole );
2029 Reference< XDataSeries > xDataSeries;
2038 Reference< XDataSink > xDataSink( xDataSeries, UNO_QUERY );
2039 if( xDataSink.is() )
2042 ::std::vector< Reference< XLabeledDataSequence > > aLabeledSeqVec;
2044 Reference< XLabeledDataSequence > xYValueSeq =
2046 if( xYValueSeq.is() )
2047 aLabeledSeqVec.push_back( xYValueSeq );
2051 Reference< XLabeledDataSequence > xXValueSeq =
2053 if( xXValueSeq.is() )
2054 aLabeledSeqVec.push_back( xXValueSeq );
2058 Reference< XLabeledDataSequence > xSizeValueSeq =
2060 if( xSizeValueSeq.is() )
2061 aLabeledSeqVec.push_back( xSizeValueSeq );
2065 if( !aLabeledSeqVec.empty() )
2082 if( xErrorBarX.is() )
2085 if( xErrorBarY.is() )
2094 for( sal_uInt16 nPointIdx = 0, nPointCount =
mxValueLink->GetCellCount(); nPointIdx < nPointCount; ++nPointIdx )
2096 ScfPropertySet aPointProp = lclGetPointPropSet( xDataSeries, nPointIdx );
2104 ScfPropertySet aPointProp = lclGetPointPropSet( xDataSeries, pointFormat.first );
2105 pointFormat.second->Convert( aPointProp, rTypeInfo, &aSeriesProp );
2126 xSrcLink->ReadChSourceLink(
rStrm );
2127 switch( xSrcLink->GetDestType() )
2155 xTrendLine->ReadChSerTrendLine(
rStrm );
2162 pErrorBar->ReadChSerErrorBar(
rStrm);
2163 sal_uInt8 nBarType = pErrorBar->GetBarType();
2164 m_ErrorBars.insert(std::make_pair(nBarType, std::move(pErrorBar)));
2176 Reference< XRegressionCurveContainer > xRegCurveCont( xDataSeries, UNO_QUERY );
2177 if( !xRegCurveCont.is() )
2184 Reference< XRegressionCurve > xRegCurve = trendLine->CreateRegressionCurve();
2185 if( xRegCurve.is() )
2187 xRegCurveCont->addRegressionCurve( xRegCurve );
2192 OSL_FAIL(
"XclImpChSeries::ConvertTrendLines - cannot add regression curve" );
2199 XclImpChSerErrorBarMap::const_iterator itrPosBar =
m_ErrorBars.find(nPosBarId);
2200 XclImpChSerErrorBarMap::const_iterator itrNegBar =
m_ErrorBars.find(nNegBarId);
2201 XclImpChSerErrorBarMap::const_iterator itrEnd =
m_ErrorBars.end();
2202 if (itrPosBar == itrEnd || itrNegBar == itrEnd)
2203 return Reference<XPropertySet>();
2211 sal_uInt16 nFlags =
rStrm.ReaduInt16();
2226 sal_uInt16 nRecId =
rStrm.GetRecId();
2227 bool bKnownType =
true;
2322 bool bStacked =
false;
2342 bool bPercent =
false;
2370 Reference< XCoordinateSystem > xCoordSystem;
2374 xCoordSystem = css::chart2::PolarCoordinateSystem3d::create(xContext);
2376 xCoordSystem = css::chart2::PolarCoordinateSystem2d::create(xContext);
2381 xCoordSystem = css::chart2::CartesianCoordinateSystem3d::create(xContext);
2383 xCoordSystem = css::chart2::CartesianCoordinateSystem2d::create(xContext);
2393 return xCoordSystem;
2446 namespace cssd = ::com::sun::star::drawing;
2451 sal_Int32 nRotationY = 0;
2452 sal_Int32 nRotationX = 0;
2453 sal_Int32 nPerspective = 15;
2454 bool bRightAngled =
false;
2455 cssd::ProjectionMode eProjMode = cssd::ProjectionMode_PERSPECTIVE;
2456 Color aAmbientColor, aLightColor;
2465 nPerspective = limit_cast< sal_Int32, sal_Int32 >(
maData.
mnEyeDist, 0, 100 );
2469 bool bParallel = bRightAngled || (nPerspective == 0);
2470 eProjMode = bParallel ? cssd::ProjectionMode_PARALLEL : cssd::ProjectionMode_PERSPECTIVE;
2472 aAmbientColor =
Color( 204, 204, 204 );
2474 aLightColor =
Color( 102, 102, 102 );
2482 nRotationX = limit_cast< sal_Int32, sal_Int32 >(
maData.
mnElevation, 10, 80 ) - 90;
2484 nPerspective = limit_cast< sal_Int32, sal_Int32 >(
maData.
mnEyeDist, 0, 100 );
2486 bRightAngled =
false;
2487 eProjMode = cssd::ProjectionMode_PARALLEL;
2489 aAmbientColor =
Color( 179, 179, 179 );
2491 aLightColor =
Color( 76, 76, 76 );
2535 switch(
rStrm.GetRecId() )
2538 mxFramePos = std::make_shared<XclImpChFramePos>();
2571 mxFrame->Convert( aLegendProp );
2574 mxText->ConvertFont( aLegendProp );
2580 cssc2::LegendPosition eApiPos = cssc2::LegendPosition_LINE_END;
2581 cssc::ChartLegendExpansion eApiExpand = cssc::ChartLegendExpansion_CUSTOM;
2585 eApiPos = cssc2::LegendPosition_LINE_START;
2586 eApiExpand = cssc::ChartLegendExpansion_HIGH;
2591 eApiPos = cssc2::LegendPosition_LINE_END;
2592 eApiExpand = cssc::ChartLegendExpansion_HIGH;
2595 eApiPos = cssc2::LegendPosition_PAGE_START;
2596 eApiExpand = cssc::ChartLegendExpansion_WIDE;
2599 eApiPos = cssc2::LegendPosition_PAGE_END;
2600 eApiExpand = cssc::ChartLegendExpansion_WIDE;
2614 RelativePosition aRelPos(
2617 css::drawing::Alignment_TOP_LEFT );
2623 eApiPos = cssc2::LegendPosition_LINE_END;
2632 eApiExpand = cssc::ChartLegendExpansion_CUSTOM;
2642 cssc::ChartLegendExpansion_HIGH, cssc::ChartLegendExpansion_WIDE );
2652 mnDropBar( nDropBar ),
2692 switch(
rStrm.GetRecId() )
2695 mxChart3d = std::make_shared<XclImpChChart3d>();
2757 OSL_ENSURE( !
maUnusedFormats.empty(),
"XclImpChTypeGroup::PopUnusedFormatIndex - no more format indexes available" );
2777 return (aConLine !=
m_ChartLines.end() && aConLine->second.HasLine());
2801 OSL_ENSURE(
IsValidGroup(),
"XclImpChTypeGroup::CreateChartType - type group without series" );
2825 Reference< XLabeledDataSequence > xLabeledSeq;
2837 p->ReadRecordGroup(
rStrm);
2843 p->ReadRecordGroup(
rStrm);
2850 sal_uInt16 nLineId =
rStrm.ReaduInt16();
2863 xDataFmt->ReadRecordGroup(
rStrm );
2871 Reference< XDataSeries >
const & xSeries, sal_Int32 nApiAxesSetIdx )
const
2873 Reference< XDataSeriesContainer > xSeriesCont( xChartType, UNO_QUERY );
2874 if( !(xSeriesCont.is() && xSeries.is()) )
2878 cssc2::StackingDirection eStacking = cssc2::StackingDirection_NO_STACKING;
2881 eStacking = cssc2::StackingDirection_Y_STACKING;
2883 eStacking = cssc2::StackingDirection_Z_STACKING;
2893 xSeriesCont->addDataSeries( xSeries );
2897 OSL_FAIL(
"XclImpChTypeGroup::InsertDataSeries - cannot add data series" );
2903 bool bSpline =
false;
2906 Reference< XDataSeries > xDataSeries = elem->CreateDataSeries();
2908 bSpline |= elem->HasSpline();
2922 Reference< XDataSink > xDataSink( xDataSeries, UNO_QUERY );
2923 if( !xDataSink.is() )
2927 ::std::vector< Reference< XLabeledDataSequence > > aLabeledSeqVec;
2928 OSL_ENSURE(
maSeries.size() >= 3,
"XclImpChTypeGroup::CreateChartType - missing stock series" );
2929 int nRoleIdx = (
maSeries.size() == 3) ? 1 : 0;
2930 for(
const auto& rxSeries :
maSeries )
2941 Reference< XLabeledDataSequence > xDataSeq = rxSeries->CreateValueSequence( aRole );
2943 aLabeledSeqVec.push_back( xDataSeq );
2966 Reference<XPropertySet> xWhitePropSet;
2970 itr->second->Convert(
GetChRoot(), aBarProp);
2974 Reference<XPropertySet> xBlackPropSet;
2978 itr->second->Convert(
GetChRoot(), aBarProp);
3030 cssc::TimeIncrement& rTimeIncrement = rScaleData.TimeIncrement;
3035 rTimeIncrement.TimeResolution.clear();
3051 rScaleData.Orientation = bReverse ? cssc2::AxisOrientation_REVERSE : cssc2::AxisOrientation_MATHEMATICAL;
3063 cssc::ChartAxisPosition eAxisPos = bMaxCross ? cssc::ChartAxisPosition_END : cssc::ChartAxisPosition_VALUE;
3119 IncrementData& rIncrementData = rScaleData.IncrementData;
3120 lclSetValueOrClearAny( rIncrementData.Distance,
maData.
mfMajorStep, bAutoMajor );
3122 Sequence< SubIncrement >& rSubIncrementSeq = rIncrementData.SubIncrements;
3123 rSubIncrementSeq.realloc( 1 );
3124 Any& rIntervalCount = rSubIncrementSeq.getArray()[ 0 ].IntervalCount;
3125 rIntervalCount.clear();
3129 rIntervalCount <<= sal_Int32( 9 );
3134 if( (1.0 <= fCount) && (fCount < 1001.0) )
3135 rIntervalCount <<= static_cast< sal_Int32 >( fCount );
3137 else if( bAutoMinor )
3140 rIntervalCount <<= static_cast< sal_Int32 >( 5 );
3145 rScaleData.Orientation = bReverse ? cssc2::AxisOrientation_REVERSE : cssc2::AxisOrientation_MATHEMATICAL;
3155 cssc::ChartAxisPosition eAxisPos = bMaxCross ? cssc::ChartAxisPosition_END : cssc::ChartAxisPosition_VALUE;
3160 if( bLogScale ) fCrossingPos = pow( 10.0, fCrossingPos );
3166sal_Int32 lclGetApiTickmarks(
sal_uInt8 nXclTickPos )
3168 using namespace ::com::sun::star::chart2::TickmarkStyle;
3172 return nApiTickmarks;
3175cssc::ChartAxisLabelPosition lclGetApiLabelPosition(
sal_Int8 nXclLabelPos )
3178 switch( nXclLabelPos )
3180 case EXC_CHTICK_LOW:
return ChartAxisLabelPosition_OUTSIDE_START;
3184 return ChartAxisLabelPosition_NEAR_AXIS;
3258 switch(
rStrm.GetRecId() )
3281 mxFont = std::make_shared<XclImpChFont>();
3348 mxTick->Convert( aAxisProp );
3366 bool bLinkNumberFmtToSource =
true;
3373 bLinkNumberFmtToSource =
false;
3383 ScaleData aScaleData = xAxis->getScaleData();
3390 aScaleData.AxisType = cssc2::AxisType::CATEGORY;
3394 aScaleData.AxisType = cssc2::AxisType::REALNUMBER;
3397 aScaleData.AxisType = rTypeGroup.
IsPercent() ?
3401 aScaleData.AxisType = cssc2::AxisType::SERIES;
3405 switch( aScaleData.AxisType )
3407 case cssc2::AxisType::CATEGORY:
3408 case cssc2::AxisType::SERIES:
3413 SAL_WARN(
"sc.filter",
"missing LabelRange");
3415 case cssc2::AxisType::REALNUMBER:
3421 SAL_WARN(
"sc.filter",
"missing ValueRange");
3424 OSL_FAIL(
"XclImpChAxis::CreateAxis - unknown axis type" );
3429 aScaleData.Origin.clear();
3432 xAxis->setScaleData( aScaleData );
3442 Sequence< Reference< XPropertySet > > aSubGridPropSeq = xAxis->getSubGridProperties();
3443 if( aSubGridPropSeq.hasElements() )
3473 SAL_WARN(
"sc.filter",
"missing LabelRange");
3480 SAL_WARN(
"sc.filter",
"missing ValueRange");
3487 bool bWallFrame =
false;
3488 switch(
rStrm.ReaduInt16() )
3498 bool bLoop = pxLineFmt || bWallFrame;
3501 sal_uInt16 nRecId =
rStrm.GetNextRecId();
3505 &&
rStrm.StartNextRecord();
3511 (*pxLineFmt)->ReadChLineFormat(
rStrm );
3550 switch(
rStrm.GetRecId() )
3553 mxFramePos = std::make_shared<XclImpChFramePos>();
3580 xTypeGroup->Finalize();
3581 if( xTypeGroup->IsValidGroup() )
3582 aValidGroups.emplace(typeGroup.first, xTypeGroup);
3606 OUString aAutoTitle(
ScResId(STR_AXISTITLE));
3607 lclFinalizeTitle(
mxXAxisTitle, pDefText, aAutoTitle );
3608 lclFinalizeTitle(
mxYAxisTitle, pDefText, aAutoTitle );
3609 lclFinalizeTitle(
mxZAxisTitle, pDefText, aAutoTitle );
3618 XclImpChTypeGroupMap::const_iterator itr =
maTypeGroups.find(nGroupIdx);
3635 xLegend = rEntry.second->GetLegend();
3658 if( !xCoordSystem.is() )
3664 Reference< XCoordinateSystemContainer > xCoordSystemCont( xDiagram, UNO_QUERY_THROW );
3665 Sequence< Reference< XCoordinateSystem > > aCoordSystems = xCoordSystemCont->getCoordinateSystems();
3666 if( !aCoordSystems.hasElements() )
3667 xCoordSystemCont->addCoordinateSystem( xCoordSystem );
3671 OSL_FAIL(
"XclImpChAxesSet::Convert - cannot insert coordinate system" );
3693 xAxis->ReadRecordGroup(
rStrm );
3695 switch( xAxis->GetAxisType() )
3706 xText->ReadRecordGroup(
rStrm );
3708 switch( xText->GetLinkTarget() )
3728 xTypeGroup->ReadRecordGroup(
rStrm );
3729 sal_uInt16 nGroupIdx = xTypeGroup->GetGroupIdx();
3730 XclImpChTypeGroupMap::iterator itr =
maTypeGroups.lower_bound(nGroupIdx);
3733 itr->second = xTypeGroup;
3736 itr, XclImpChTypeGroupMap::value_type(nGroupIdx, xTypeGroup));
3741 Reference< XCoordinateSystem > xCoordSystem;
3746 Reference< XCoordinateSystemContainer > xCoordSystemCont( xDiagram, UNO_QUERY );
3747 if( xCoordSystemCont.is() )
3749 Sequence< Reference< XCoordinateSystem > > aCoordSystems = xCoordSystemCont->getCoordinateSystems();
3750 OSL_ENSURE( aCoordSystems.getLength() <= 1,
"XclImpChAxesSet::CreateCoordSystem - too many existing coordinate systems" );
3751 if( aCoordSystems.hasElements() )
3752 xCoordSystem = aCoordSystems[ 0 ];
3756 if( !xCoordSystem.is() )
3761 xCoordSystem = xTypeGroup->CreateCoordSystem();
3764 xTypeGroup->ConvertChart3d( aDiaProp );
3770 Reference< XChartTypeContainer > xChartTypeCont( xCoordSystem, UNO_QUERY );
3771 if( xChartTypeCont.is() )
3778 Reference< XChartType > xChartType = rEntry.second->CreateChartType( xDiagram, nApiAxesSetIdx );
3779 if( xChartType.is() )
3780 xChartTypeCont->addChartType( xChartType );
3784 OSL_FAIL(
"XclImpChAxesSet::CreateCoordSystem - cannot add chart type" );
3789 return xCoordSystem;
3794 Reference< XCoordinateSystem >
const & xCoordSystem,
const XclImpChAxis* pCrossingAxis )
const
3800 Reference< XAxis > xAxis =
CreateAxis( *xChAxis, pCrossingAxis );
3805 if( xChAxisTitle )
try
3807 Reference< XTitled > xTitled( xAxis, UNO_QUERY_THROW );
3808 Reference< XTitle > xTitle( xChAxisTitle->CreateTitle(), UNO_SET_THROW );
3809 xTitled->setTitleObject( xTitle );
3813 OSL_FAIL(
"XclImpChAxesSet::ConvertAxis - cannot set axis title" );
3819 sal_Int32 nApiAxisDim = xChAxis->GetApiAxisDimension();
3821 xCoordSystem->setAxisByDimension( nApiAxisDim, xAxis, nApiAxesSetIdx );
3825 OSL_FAIL(
"XclImpChAxesSet::ConvertAxis - cannot set axis" );
3831 Reference< XAxis > xAxis;
3833 xAxis = rChAxis.
CreateAxis( *pTypeGroup, pCrossingAxis );
3840 if( xTypeGroup && xTypeGroup->Is3dWallChart() )
3846 mxXAxis->ConvertWall( aWallProp );
3851 mxYAxis->ConvertWall( aFloorProp );
3883 switch(
rStrm.GetRecId() )
3912 sal_uInt16 nTextId =
rStrm.ReaduInt16();
3916 pText->ReadRecordGroup(
rStrm);
3917 m_DefTexts.insert(std::make_pair(nTextId, std::move(pText)));
3924 xDataFmt->ReadRecordGroup(
rStrm );
3928 XclImpChDataFormatMap::iterator itr =
maDataFmts.lower_bound(rPos);
3932 itr, XclImpChDataFormatMap::value_type(rPos, xDataFmt));
3943 mxFrame->UpdateObjFrame( rLineData, rFillData );
3949 if( !xTypeGroup ) xTypeGroup =
mxSecnAxesSet->GetTypeGroup( nGroupIdx );
3950 if( !xTypeGroup ) xTypeGroup =
mxPrimAxesSet->GetFirstTypeGroup();
3967 XclImpChTextMap::const_iterator
const itr =
m_DefTexts.find(nDefTextId);
3968 return itr ==
m_DefTexts.end() ? nullptr : itr->second.get();
3987 mxFrame->Convert( aFrameProp );
3993 Reference< XTitled > xTitled( xChartDoc, UNO_QUERY_THROW );
3994 Reference< XTitle > xTitle(
mxTitle->CreateTitle(), UNO_SET_THROW );
3995 xTitled->setTitleObject( xTitle );
4004 xChartDoc->setFirstDiagram( xDiagram );
4012 xDiagram->setLegend(
mxLegend->CreateLegend() );
4016 Reference< cssc::XChartDocument > xChart1Doc( xChartDoc, UNO_QUERY );
4017 if( xChart1Doc.is() )
4019 Reference< cssc::XDiagram > xDiagram1 = xChart1Doc->getDiagram();
4032 const XclChFramePos& rFramePos = xPlotAreaPos->GetFramePosData();
4035 Reference< cssc::XDiagramPositioning > xPositioning( xDiagram1, UNO_QUERY_THROW );
4040 xPositioning->setDiagramPositionExcludingAxes( aDiagramRect );
4041 else if( pFirstTypeGroup && pFirstTypeGroup->
Is3dChart() )
4042 xPositioning->setDiagramPositionIncludingAxesAndAxisTitles( aDiagramRect );
4044 xPositioning->setDiagramPositionIncludingAxes( aDiagramRect );
4064 if(!pChartCollection)
4067 std::vector< ScTokenRef > aRefTokens;
4068 for(
const auto& rxSeries :
maSeries )
4069 rxSeries->FillAllSourceLinks( aRefTokens );
4070 if( !aRefTokens.empty() )
4072 ::std::unique_ptr< ScChartListener > xListener(
new ScChartListener( rObjName, rDoc, std::move(aRefTokens) ) );
4073 xListener->SetUsed(
true );
4074 xListener->StartListeningTo();
4075 pChartCollection->
insert( xListener.release() );
4081 sal_uInt16 nNewSeriesIdx =
static_cast< sal_uInt16
>(
maSeries.size() );
4083 xSeries->ReadRecordGroup(
rStrm );
4096 xAxesSet->ReadRecordGroup(
rStrm );
4097 switch( xAxesSet->GetAxesSetId() )
4107 xText->ReadRecordGroup(
rStrm );
4108 switch( xText->GetLinkTarget() )
4115 sal_uInt16 nSeriesIdx = xText->GetPointPos().mnSeriesIdx;
4117 maSeries[ nSeriesIdx ]->SetDataLabel( xText );
4149 if( xSeries->HasParentSeries() )
4153 if( xSeries->GetParentIdx() <
maSeries.size() )
4154 maSeries[ xSeries->GetParentIdx() ]->AddChildSeries( *xSeries );
4160 pTypeGroup->AddSeries( xSeries );
4175 for(
const auto& [rPos, rDataFmt] :
maDataFmts )
4177 sal_uInt16 nSeriesIdx = rPos.mnSeriesIdx;
4179 maSeries[ nSeriesIdx ]->SetDataFormat( rDataFmt );
4186 rxSeries->FinalizeDataFormats();
4192 OUString aAutoTitle;
4198 if(
mxTitle || (!aAutoTitle.isEmpty()) )
4202 if( aAutoTitle.isEmpty() )
4203 aAutoTitle =
ScResId(STR_CHARTTITLE);
4220 using namespace cssc::MissingValueTreatment;
4221 sal_Int32 nMissingValues = LEAVE_GAP;
4235 mnScTab( rRoot.GetCurrScTab() ),
4258 Reference< XDrawPageSupplier > xDrawPageSupp( rxModel, UNO_QUERY_THROW );
4259 Reference< XDrawPage > xDrawPage( xDrawPageSupp->getDrawPage(), UNO_SET_THROW );
4260 pSdrPage = ::GetSdrPageFromXDrawPage( xDrawPage );
4268 if( pSdrModel && pSdrPage )
4295 mbOwnTab( bOwnTab ),
4296 mbIsPivotChart( false )
4310 while( bLoop &&
rStrm.StartNextRecord() )
4345 switch(
rStrm.GetRecId() )
4387 mxChartData->UpdateObjFrame( rLineData, rFillData );
4399 Reference< XChartDocument > xChartDoc(
xModel, UNO_QUERY );
4400 if( xChartDoc.is() )
4403 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.