22 #include <com/sun/star/chart/XChartDocument.hpp>
23 #include <com/sun/star/chart/XDiagramPositioning.hpp>
24 #include <com/sun/star/chart2/XChartDocument.hpp>
25 #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
26 #include <com/sun/star/chart2/XDiagram.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 <osl/diagnose.h>
36 #include <oox/token/namespaces.hxx>
37 #include <oox/token/properties.hxx>
38 #include <oox/token/tokens.hxx>
54 typedef ModelMap< sal_Int32, AxisModel > AxisMap;
59 explicit AxesSetModel() {}
66 explicit AxesSetConverter(
const ConverterRoot& rParent, AxesSetModel& rModel );
70 void convertFromModel(
71 const Reference< XDiagram >& rxDiagram,
72 View3DModel& rView3DModel,
73 sal_Int32 nAxesSetIdx,
74 bool bSupportsVaryColorsByPoint,
75 bool bUseFixedInnerSize );
78 const OUString& getAutomaticTitle()
const {
return maAutoTitle; }
80 bool is3dChart()
const {
return mb3dChart; }
93 AxesSetConverter::AxesSetConverter(
const ConverterRoot& rParent, AxesSetModel& rModel ) :
101 ModelRef< AxisModel > lclGetOrCreateAxis(
const AxesSetModel::AxisMap& rFromAxes, sal_Int32 nAxisIdx, sal_Int32 nDefTypeId,
bool bMSO2007Doc )
103 ModelRef< AxisModel > xAxis = rFromAxes.get( nAxisIdx );
105 xAxis.create( nDefTypeId, bMSO2007Doc ).mbDeleted =
true;
109 void AxesSetConverter::convertFromModel(
const Reference< XDiagram >& rxDiagram,
110 View3DModel& rView3DModel, sal_Int32 nAxesSetIdx,
111 bool bSupportsVaryColorsByPoint,
bool bUseFixedInnerSize)
114 typedef RefVector< TypeGroupConverter > TypeGroupConvVector;
115 TypeGroupConvVector aTypeGroups;
116 for (
auto const& typeGroup :
mrModel.maTypeGroups)
117 aTypeGroups.push_back( std::make_shared<TypeGroupConverter>( *
this, *typeGroup ) );
119 OSL_ENSURE( !aTypeGroups.empty(),
"AxesSetConverter::convertFromModel - no type groups in axes set" );
120 if( aTypeGroups.empty() )
126 TypeGroupConverter& rFirstTypeGroup = *aTypeGroups.front();
129 if( aTypeGroups.size() == 1 )
130 maAutoTitle = rFirstTypeGroup.getSingleSeriesTitle();
135 Reference< XCoordinateSystem > xCoordSystem;
136 Reference< XCoordinateSystemContainer > xCoordSystemCont( rxDiagram, UNO_QUERY_THROW );
137 Sequence< Reference< XCoordinateSystem > > aCoordSystems = xCoordSystemCont->getCoordinateSystems();
138 if( aCoordSystems.hasElements() )
140 OSL_ENSURE( aCoordSystems.getLength() == 1,
"AxesSetConverter::convertFromModel - too many coordinate systems" );
141 xCoordSystem = aCoordSystems[ 0 ];
142 OSL_ENSURE( xCoordSystem.is(),
"AxesSetConverter::convertFromModel - invalid coordinate system" );
146 xCoordSystem = rFirstTypeGroup.createCoordinateSystem();
147 if( xCoordSystem.is() )
148 xCoordSystemCont->addCoordinateSystem( xCoordSystem );
157 View3DConverter aView3DConv( *
this, rView3DModel );
158 aView3DConv.convertFromModel( rxDiagram, rFirstTypeGroup );
163 if( xCoordSystem.is() )
165 bool bMSO2007Doc = getFilter().isMSO2007Document();
167 ModelRef< AxisModel > xXAxis = lclGetOrCreateAxis(
mrModel.maAxes,
API_X_AXIS, rFirstTypeGroup.getTypeInfo().mbCategoryAxis ? C_TOKEN( catAx ) : C_TOKEN( valAx ), bMSO2007Doc );
168 ModelRef< AxisModel > xYAxis = lclGetOrCreateAxis(
mrModel.maAxes,
API_Y_AXIS, C_TOKEN( valAx ), bMSO2007Doc );
170 AxisConverter aXAxisConv( *
this, *xXAxis );
171 aXAxisConv.convertFromModel(xCoordSystem, aTypeGroups, xYAxis.get(), nAxesSetIdx,
173 AxisConverter aYAxisConv( *
this, *xYAxis );
174 aYAxisConv.convertFromModel(xCoordSystem, aTypeGroups, xXAxis.get(), nAxesSetIdx,
177 if( rFirstTypeGroup.isDeep3dChart() )
179 ModelRef< AxisModel > xZAxis = lclGetOrCreateAxis(
mrModel.maAxes,
API_Z_AXIS, C_TOKEN( serAx ), bMSO2007Doc );
180 AxisConverter aZAxisConv( *
this, *xZAxis );
181 aZAxisConv.convertFromModel(xCoordSystem, aTypeGroups,
nullptr, nAxesSetIdx,
186 for (
auto const& typeGroup : aTypeGroups)
187 typeGroup->convertFromModel( rxDiagram, xCoordSystem, nAxesSetIdx, bSupportsVaryColorsByPoint );
208 namespace cssd = ::com::sun::star::drawing;
211 sal_Int32 nRotationY = 0;
212 sal_Int32 nRotationX = 0;
213 bool bRightAngled =
false;
214 sal_Int32 nAmbientColor = 0;
215 sal_Int32 nLightColor = 0;
224 bRightAngled =
false;
226 nAmbientColor = 0xB3B3B3;
228 nLightColor = 0x4C4C4C;
239 nAmbientColor = 0xCCCCCC;
241 nLightColor = 0x666666;
249 sal_Int32 nPerspective = getLimitedValue< sal_Int32, sal_Int32 >(
mrModel.
mnPerspective / 2, 0, 100 );
251 bool bParallel = bRightAngled || (nPerspective == 0);
252 cssd::ProjectionMode eProjMode = bParallel ? cssd::ProjectionMode_PARALLEL : cssd::ProjectionMode_PERSPECTIVE;
255 aPropSet.
setProperty( PROP_RightAngledAxes, bRightAngled );
256 aPropSet.
setProperty( PROP_RotationVertical, nRotationY );
257 aPropSet.
setProperty( PROP_RotationHorizontal, nRotationX );
258 aPropSet.
setProperty( PROP_Perspective, nPerspective );
259 aPropSet.
setProperty( PROP_D3DScenePerspective, eProjMode );
262 aPropSet.
setProperty( PROP_D3DSceneShadeMode, cssd::ShadeMode_FLAT );
263 aPropSet.
setProperty( PROP_D3DSceneAmbientColor, nAmbientColor );
264 aPropSet.
setProperty( PROP_D3DSceneLightOn1,
false );
265 aPropSet.
setProperty( PROP_D3DSceneLightOn2,
true );
266 aPropSet.
setProperty( PROP_D3DSceneLightColor2, nLightColor );
267 aPropSet.
setProperty( PROP_D3DSceneLightDirection2, cssd::Direction3D( 0.2, 0.4, 1.0 ) );
289 default: OSL_FAIL(
"WallFloorConverter::convertFromModel - invalid object type" );
315 xDiagram.set(
createInstance(
"com.sun.star.chart2.Diagram" ), UNO_QUERY_THROW );
325 std::vector<sal_Int32>rValAxisIds;
326 std::vector<sal_Int32>rRealValAxisIds;
330 if (atypeGroup->maAxisIds.size() > 1)
333 rRealValAxisIds.push_back(atypeGroup->maAxisIds[1]);
339 OSL_ENSURE( axis->mnAxisId >= 0,
"PlotAreaConverter::convertFromModel - invalid axis identifier" );
340 OSL_ENSURE( !aAxisMap.has( axis->mnAxisId ),
"PlotAreaConverter::convertFromModel - axis identifiers not unique" );
341 if( axis->mnAxisId != -1 )
342 aAxisMap[ axis->mnAxisId ] = axis;
344 if ( axis->mnAxisId != -1 && axis->mnTypeId == C_TOKEN(valAx) )
346 for (
size_t i = 0;
i < rRealValAxisIds.size();
i++)
348 if (axis->mnAxisId == rRealValAxisIds[
i])
351 rValAxisIds.push_back(axis->mnAxisId);
359 AxesSetVector aAxesSets;
360 sal_Int32 nMaxSeriesIdx = -1;
363 if( !typeGroup->maSeries.empty() )
366 AxesSetModel* pAxesSet =
nullptr;
367 for (
auto const& axesSet : aAxesSets)
369 if( axesSet->maTypeGroups.front()->maAxisIds == typeGroup->maAxisIds )
371 pAxesSet = axesSet.get();
380 pAxesSet = &aAxesSets.create();
382 const std::vector<sal_Int32>& rAxisIds = typeGroup->maAxisIds;
383 if( !rAxisIds.empty() )
384 pAxesSet->maAxes[ API_X_AXIS ] = aAxisMap.get( rAxisIds[ 0 ] );
385 if( rAxisIds.size() >= 2 )
386 pAxesSet->maAxes[ API_Y_AXIS ] = aAxisMap.get( rAxisIds[ 1 ] );
387 if( rAxisIds.size() >= 3 )
388 pAxesSet->maAxes[
API_Z_AXIS ] = aAxisMap.get( rAxisIds[ 2 ] );
392 pAxesSet->maTypeGroups.push_back( typeGroup );
395 for (
auto const& elemSeries : typeGroup->maSeries)
396 nMaxSeriesIdx = ::std::max( nMaxSeriesIdx, elemSeries->mnIndex );
408 sal_Int32 nStartAxesSetIdx = bIsCombinedChart ? ((rValAxisIds.size() > 1 && aAxesSets.size() > 0 && aAxesSets[0]->maAxes.count( API_Y_AXIS )
409 && aAxesSets[0]->maAxes[
API_Y_AXIS ]->mnAxisId != rValAxisIds[0] ) ? 1 : 0)
411 sal_Int32 nAxesSetIdx = nStartAxesSetIdx;
413 bool bUseFixedInnerSize =
false;
417 for (
auto const& axesSet : aAxesSets)
419 AxesSetConverter aAxesSetConv(*
this, *axesSet);
420 aAxesSetConv.convertFromModel(xDiagram, rView3DModel, nAxesSetIdx,
421 bSupportsVaryColorsByPoint, bUseFixedInnerSize);
422 if(nAxesSetIdx == nStartAxesSetIdx)
433 nAxesSetIdx = 1 - nAxesSetIdx;
451 awt::Rectangle aDiagramRect;
457 namespace cssc = ::com::sun::star::chart;
465 xPositioning->setDiagramPositionExcludingAxes( aDiagramRect );
468 xPositioning->setDiagramPositionIncludingAxes( aDiagramRect );
471 OSL_FAIL(
"PlotAreaConverter::convertPositionFromModel - unknown positioning target" );
bool calcAbsRectangle(css::awt::Rectangle &orRect) const
Tries to calculate the absolute position and size from the contained OOXML layout model...
void convertPieRotation(PropertySet &rPropSet, sal_Int32 nOoxAngle) const
Sets the passed OOXML pie rotation at the passed property set.
PlotAreaConverter(const ConverterRoot &rParent, PlotAreaModel &rModel)
void convertPositionFromModel()
Converts the manual plot area position and size, if set.
OptValue< sal_Int32 > monRotationX
Height of the 3D view, relative to chart width.
TypeCategory meTypeCategory
Unique chart type identifier.
const sal_Int32 API_Y_AXIS
Base class of all converter classes.
void convertFromModel(const css::uno::Reference< css::chart2::XDiagram > &rxDiagram, ObjectType eObjType)
Converts the OOXML wall/floor model to a chart2 diagram.
PictureOptionsRef mxPicOptions
Wall/floor frame formatting.
sal_Int32 mnPerspective
Depth of the 3D view, relative to chart width.
css::uno::Reference< css::uno::XInterface > createInstance(const OUString &rServiceName) const
Creates an instance for the passed service name, using the process service factory.
void convertFromModel(View3DModel &rView3DModel)
Converts the OOXML plot area model to a chart2 diagram.
AxisMap maAxes
All type groups containing data series.
ObjectType
Enumerates different object types for specific automatic formatting behaviour.
ModelType & getOrCreate()
AxisVector maAxes
All chart type groups contained in the chart.
Plot area containing axes and data series in 3D charts.
const sal_Int32 API_X_AXIS
bool is() const
Returns true, if the contained XPropertySet interface is valid.
A wrapper for a UNO property set.
sal_Int32 mnTarget
Mode for height.
const sal_Int32 API_Z_AXIS
virtual ~View3DConverter() override
A layout converter calculates positions and sizes for various chart objects.
void convertFromModel(css::uno::Reference< css::chart2::XDiagram > const &rxDiagram)
Converts the OOXML data table model to a chart2 diagram.
OptValue< sal_Int32 > monRotationY
Horizontal rotation in degrees.
void convertFromModel(const css::uno::Reference< css::chart2::XDiagram > &rxDiagram, TypeGroupConverter const &rTypeGroup)
Converts the OOXML plot area model to a chart2 diagram.
WallFloorConverter(const ConverterRoot &rParent, WallFloorModel &rModel)
void set(const css::uno::Reference< css::beans::XPropertySet > &rxPropSet)
Sets the passed UNO property set and releases the old UNO property set.
DataTableRef mxDataTable
Layout/position of the plot area.
Radar charts (linear or filled).
TypeGroupVector maTypeGroups
virtual ~WallFloorConverter() override
virtual ~PlotAreaConverter() override
::oox::core::XmlFilterBase & getFilter() const
Returns the filter object of the imported/exported document.
bool mbRightAngled
Eye distance to the 3D objects.
std::enable_if< std::is_signed< T >::value, T >::type NormAngle180(T angle)
Background and side wall in 3D charts.
css::uno::Reference< css::chart2::XChartDocument > const & getChartDocument() const
Returns the API chart document model.
LayoutRef mxLayout
Plot area frame formatting.
TypeGroupVector maTypeGroups
bool isMSO2007Document() const
bool setProperty(sal_Int32 nPropId, const Type &rValue)
Puts the passed value into the property set.
const TypeGroupInfo & getTypeInfo() const
Returns the type info struct that describes this chart type group.
ObjectFormatter & getFormatter() const
Returns the object formatter.
ShapeRef mxShapeProp
All axes contained in the chart.
bool m_bDetectedRangeSegmentation false