diff options
Diffstat (limited to '')
24 files changed, 2758 insertions, 0 deletions
diff --git a/oox/inc/drawingml/chart/axiscontext.hxx b/oox/inc/drawingml/chart/axiscontext.hxx new file mode 100644 index 000000000..5db36b914 --- /dev/null +++ b/oox/inc/drawingml/chart/axiscontext.hxx @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_AXISCONTEXT_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_AXISCONTEXT_HXX + +#include <drawingml/chart/chartcontextbase.hxx> + +namespace oox { +namespace drawingml { +namespace chart { + + +struct AxisDispUnitsModel; + +/** Handler for a value axis display units context (c:dispUnits element). + */ +class AxisDispUnitsContext final : public ContextBase< AxisDispUnitsModel > +{ +public: + explicit AxisDispUnitsContext( ::oox::core::ContextHandler2Helper& rParent, AxisDispUnitsModel& rModel ); + virtual ~AxisDispUnitsContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +struct AxisModel; + +/** Base class for axis context handlers (c:catAx, c:dateAx, c:serAx, c:valAx + elements). + */ +class AxisContextBase : public ContextBase< AxisModel > +{ +public: + explicit AxisContextBase( ::oox::core::ContextHandler2Helper& rParent, AxisModel& rModel ); + virtual ~AxisContextBase() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +/** Handler for a category axis context (c:catAx element). + */ +class CatAxisContext final : public AxisContextBase +{ +public: + explicit CatAxisContext( ::oox::core::ContextHandler2Helper& rParent, AxisModel& rModel ); + virtual ~CatAxisContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +/** Handler for a date axis context (c:dateAx element). + */ +class DateAxisContext final : public AxisContextBase +{ +public: + explicit DateAxisContext( ::oox::core::ContextHandler2Helper& rParent, AxisModel& rModel ); + virtual ~DateAxisContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +/** Handler for a series axis context (c:serAx element). + */ +class SerAxisContext final : public AxisContextBase +{ +public: + explicit SerAxisContext( ::oox::core::ContextHandler2Helper& rParent, AxisModel& rModel ); + virtual ~SerAxisContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +/** Handler for a value axis context (c:valAx element). + */ +class ValAxisContext final : public AxisContextBase +{ +public: + explicit ValAxisContext( ::oox::core::ContextHandler2Helper& rParent, AxisModel& rModel ); + virtual ~ValAxisContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/drawingml/chart/axisconverter.hxx b/oox/inc/drawingml/chart/axisconverter.hxx new file mode 100644 index 000000000..f647cc560 --- /dev/null +++ b/oox/inc/drawingml/chart/axisconverter.hxx @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_AXISCONVERTER_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_AXISCONVERTER_HXX + +#include <drawingml/chart/converterbase.hxx> + +namespace com::sun::star { + namespace chart2 { class XAxis; } + namespace chart2 { class XCoordinateSystem; } +} + +namespace oox { +namespace drawingml { +namespace chart { + + +struct AxisDispUnitsModel; + +class AxisDispUnitsConverter final : public ConverterBase< AxisDispUnitsModel > +{ +public: + explicit AxisDispUnitsConverter( + const ConverterRoot& rParent, + AxisDispUnitsModel& rModel ); + virtual ~AxisDispUnitsConverter() override; + + /** Creates a chart2 axis and inserts it into the passed coordinate system. */ + void convertFromModel( + const css::uno::Reference< css::chart2::XAxis >& rxAxis); +}; + +struct AxisModel; +class TypeGroupConverter; + +class AxisConverter final : public ConverterBase< AxisModel > +{ +public: + explicit AxisConverter( + const ConverterRoot& rParent, + AxisModel& rModel ); + virtual ~AxisConverter() override; + + /** Creates a chart2 axis and inserts it into the passed coordinate system. */ + void convertFromModel( + const css::uno::Reference<css::chart2::XCoordinateSystem>& rxCoordSystem, + RefVector<TypeGroupConverter>& rTypeGroups, const AxisModel* pCrossingAxis, + sal_Int32 nAxesSetIdx, sal_Int32 nAxisIdx ); +}; + + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/drawingml/chart/axismodel.hxx b/oox/inc/drawingml/chart/axismodel.hxx new file mode 100644 index 000000000..afa097d72 --- /dev/null +++ b/oox/inc/drawingml/chart/axismodel.hxx @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_AXISMODEL_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_AXISMODEL_HXX + +#include <oox/drawingml/shape.hxx> +#include <drawingml/chart/titlemodel.hxx> + +namespace oox { +namespace drawingml { +namespace chart { + +struct AxisDispUnitsModel +{ + typedef ModelRef< Shape > ShapeRef; + typedef ModelRef< TextBody > TextBodyRef; + typedef ModelRef< LayoutModel > LayoutRef; + typedef ModelRef< TextModel > TextRef; + + ShapeRef mxShapeProp; /// Label frame formatting. + TextBodyRef mxTextProp; /// Label text formatting. + LayoutRef mxLayout; /// Layout/position of the axis units label. + TextRef mxText; /// Text source of the axis units label. + double mfCustomUnit; /// Custom unit size on value axis. + OUString mnBuiltInUnit; /// Built-in unit on value axis. + + explicit AxisDispUnitsModel(); + ~AxisDispUnitsModel(); +}; + +struct AxisModel +{ + typedef ModelRef< Shape > ShapeRef; + typedef ModelRef< TextBody > TextBodyRef; + typedef ModelRef< TitleModel > TitleRef; + typedef ModelRef< AxisDispUnitsModel > AxisDispUnitsRef; + + ShapeRef mxShapeProp; /// Axis line formatting. + TextBodyRef mxTextProp; /// Axis label text formatting. + TitleRef mxTitle; /// Axis title. + AxisDispUnitsRef mxDispUnits; /// Axis units label. + ShapeRef mxMajorGridLines; /// Major grid lines formatting. + ShapeRef mxMinorGridLines; /// Minor grid lines formatting. + NumberFormat maNumberFormat; /// Number format for axis tick labels. + OptValue< double > mofCrossesAt; /// Position on this axis where another axis crosses. + OptValue< double > mofMajorUnit; /// Unit for major tick marks on date/value axis. + OptValue< double > mofMinorUnit; /// Unit for minor tick marks on date/value axis. + OptValue< double > mofLogBase; /// Logarithmic base for logarithmic axes. + OptValue< double > mofMax; /// Maximum axis value. + OptValue< double > mofMin; /// Minimum axis value. + OptValue< sal_Int32 > monBaseTimeUnit; /// Base time unit shown on a date axis. + sal_Int32 mnAxisId; /// Unique axis identifier. + sal_Int32 mnAxisPos; /// Position of the axis (top/bottom/left/right). + sal_Int32 mnCrossAxisId; /// Identifier of a crossing axis. + sal_Int32 mnCrossBetween; /// This value axis crosses between or inside category. + sal_Int32 mnCrossMode; /// Mode this axis crosses another axis (min, max, auto). + sal_Int32 mnLabelAlign; /// Tick mark label alignment. + sal_Int32 mnLabelOffset; /// Tick mark label distance from axis. + sal_Int32 mnMajorTickMark; /// Major tick mark style. + sal_Int32 mnMajorTimeUnit; /// Time unit for major tick marks on date axis. + sal_Int32 mnMinorTickMark; /// Minor tick mark style. + sal_Int32 mnMinorTimeUnit; /// Time unit for minor tick marks on date axis. + sal_Int32 mnOrientation; /// Axis orientation (value order min to max, or max to min). + sal_Int32 mnTickLabelPos; /// Position of tick mark labels relative to the axis. + sal_Int32 mnTickLabelSkip; /// Number of tick mark labels to skip. + sal_Int32 mnTickMarkSkip; /// Number of tick marks to skip. + sal_Int32 mnTypeId; /// Type identifier of this axis. + bool mbAuto; /// True = automatic selection of text/date axis type. + bool mbDeleted; /// True = axis has been deleted manually. + bool mbNoMultiLevel; /// True = no multi-level categories supported. + + explicit AxisModel( sal_Int32 nTypeId, bool bMSO2007Doc ); + ~AxisModel(); +}; + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/drawingml/chart/chartcontextbase.hxx b/oox/inc/drawingml/chart/chartcontextbase.hxx new file mode 100644 index 000000000..6669536d3 --- /dev/null +++ b/oox/inc/drawingml/chart/chartcontextbase.hxx @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_CHARTCONTEXTBASE_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_CHARTCONTEXTBASE_HXX + +#include <oox/core/fragmenthandler2.hxx> + +namespace oox::drawingml { class Shape; } + +namespace oox { +namespace drawingml { +namespace chart { + +template< typename ModelType > +class ContextBase : public ::oox::core::ContextHandler2 +{ +public: + explicit ContextBase( ::oox::core::ContextHandler2Helper& rParent, ModelType& rModel ) : + ::oox::core::ContextHandler2( rParent ), mrModel( rModel ) {} + +protected: + ModelType& mrModel; +}; + +template< typename ModelType > +class FragmentBase : public ::oox::core::FragmentHandler2 +{ +public: + explicit FragmentBase( ::oox::core::XmlFilterBase& rFilter, const OUString& rFragmentPath, ModelType& rModel ) : + ::oox::core::FragmentHandler2( rFilter, rFragmentPath, false ), mrModel( rModel ) {} + +protected: + ModelType& mrModel; +}; + +/** Help class for all contexts that have only the c:spPr child element. + */ +class ShapePrWrapperContext final : public ContextBase< Shape > +{ +public: + explicit ShapePrWrapperContext( ::oox::core::ContextHandler2Helper& rParent, Shape& rModel ); + virtual ~ShapePrWrapperContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + +struct LayoutModel; + +/** Handler for a chart layout context (c:layout element). + */ +class LayoutContext final : public ContextBase< LayoutModel > +{ +public: + explicit LayoutContext( ::oox::core::ContextHandler2Helper& rParent, LayoutModel& rModel ); + virtual ~LayoutContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/drawingml/chart/chartdrawingfragment.hxx b/oox/inc/drawingml/chart/chartdrawingfragment.hxx new file mode 100644 index 000000000..8392999fa --- /dev/null +++ b/oox/inc/drawingml/chart/chartdrawingfragment.hxx @@ -0,0 +1,107 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_CHARTDRAWINGFRAGMENT_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_CHARTDRAWINGFRAGMENT_HXX + +#include <oox/core/fragmenthandler2.hxx> +#include <oox/drawingml/shape.hxx> + +namespace oox { +namespace drawingml { +namespace chart { + + +/** Relative shape position in a chart object. */ +struct AnchorPosModel +{ + double mfX; /// X coordinate relative to chart object (0.0 to 1.0). + double mfY; /// Y coordinate relative to chart object (0.0 to 1.0). + + AnchorPosModel() : mfX( -1.0 ), mfY( -1.0 ) {} + bool isValid() const { return (0.0 <= mfX) && (mfX <= 1.0) && (0.0 <= mfY) && (mfY <= 1.0); } +}; + + +/** Absolute shape size in a chart object (in EMUs). */ +struct AnchorSizeModel : public EmuSize +{ + AnchorSizeModel() : EmuSize( -1, -1 ) {} + bool isValid() const { return (Width >= 0) && (Height >= 0); } +}; + + +/** Contains the position of a shape in the chart object. Supports different + shape anchor modes (absolute, relative). + */ +class ShapeAnchor +{ +public: + explicit ShapeAnchor( bool bRelSize ); + + /** Imports the absolute anchor size from the cdr:ext element. */ + void importExt( const AttributeList& rAttribs ); + /** Sets the relative anchor position from the cdr:from or cdr:to element. */ + void setPos( sal_Int32 nElement, sal_Int32 nParentContext, const OUString& rValue ); + + /** Calculates the resulting shape anchor in EMUs. */ + EmuRectangle calcAnchorRectEmu( const EmuRectangle& rChartRect ) const; + +private: + AnchorPosModel maFrom; /// Top-left position relative to chart object. + AnchorPosModel maTo; /// Bottom-right position relative to chart object. + AnchorSizeModel maSize; /// Shape size, if anchor has absolute size. + bool mbRelSize; /// True = relative size, false = absolute size. +}; + +/** Handler for a chart drawing fragment (c:userShapes root element). + */ +class ChartDrawingFragment final : public ::oox::core::FragmentHandler2 +{ +public: + explicit ChartDrawingFragment( + ::oox::core::XmlFilterBase& rFilter, + const OUString& rFragmentPath, + const css::uno::Reference< css::drawing::XShapes >& rxDrawPage, + const css::awt::Size& rChartSize, + const css::awt::Point& rShapesOffset, + bool bOleSupport ); + virtual ~ChartDrawingFragment() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; + virtual void onCharacters( const OUString& rChars ) override; + virtual void onEndElement() override; + +private: + css::uno::Reference< css::drawing::XShapes > + mxDrawPage; /// Drawing page of this sheet. + ::oox::drawingml::ShapePtr mxShape; /// Current top-level shape. + std::shared_ptr< ShapeAnchor > mxAnchor; /// Current anchor of top-level shape. + EmuRectangle maChartRectEmu; /// Position and size of the chart object for embedded shapes (in EMUs). + bool mbOleSupport; /// True = allow to insert OLE objects into the drawing page. +}; + + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/drawingml/chart/chartspaceconverter.hxx b/oox/inc/drawingml/chart/chartspaceconverter.hxx new file mode 100644 index 000000000..82f848374 --- /dev/null +++ b/oox/inc/drawingml/chart/chartspaceconverter.hxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_CHARTSPACECONVERTER_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_CHARTSPACECONVERTER_HXX + +#include <drawingml/chart/converterbase.hxx> + +namespace com::sun::star { + namespace drawing { class XShapes; } +} + +namespace oox { +namespace drawingml { +namespace chart { + + +struct ChartSpaceModel; + +class ChartSpaceConverter final : public ConverterBase< ChartSpaceModel > +{ +public: + explicit ChartSpaceConverter( const ConverterRoot& rParent, ChartSpaceModel& rModel ); + virtual ~ChartSpaceConverter() override; + + /** Converts the contained OOXML chart model to a chart2 document. */ + void convertFromModel( + const css::uno::Reference< css::drawing::XShapes >& rxExternalPage, + const css::awt::Point& rChartPos ); +}; + + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/drawingml/chart/chartspacefragment.hxx b/oox/inc/drawingml/chart/chartspacefragment.hxx new file mode 100644 index 000000000..503848d48 --- /dev/null +++ b/oox/inc/drawingml/chart/chartspacefragment.hxx @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_CHARTSPACEFRAGMENT_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_CHARTSPACEFRAGMENT_HXX + +#include <drawingml/chart/chartcontextbase.hxx> + +namespace oox { +namespace drawingml { +namespace chart { + + +struct ChartSpaceModel; + +/** Handler for a chart fragment (c:chartSpace root element). + */ +class ChartSpaceFragment final : public FragmentBase< ChartSpaceModel > +{ +public: + explicit ChartSpaceFragment( + ::oox::core::XmlFilterBase& rFilter, + const OUString& rFragmentPath, + ChartSpaceModel& rModel ); + virtual ~ChartSpaceFragment() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/drawingml/chart/chartspacemodel.hxx b/oox/inc/drawingml/chart/chartspacemodel.hxx new file mode 100644 index 000000000..f559d5339 --- /dev/null +++ b/oox/inc/drawingml/chart/chartspacemodel.hxx @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_CHARTSPACEMODEL_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_CHARTSPACEMODEL_HXX + +#include <oox/drawingml/shape.hxx> +#include <drawingml/chart/plotareamodel.hxx> +#include <drawingml/chart/titlemodel.hxx> + +namespace oox { +namespace drawingml { +namespace chart { + + +struct ChartSpaceModel +{ + typedef ModelRef< Shape > ShapeRef; + typedef ModelRef< TextBody > TextBodyRef; + typedef ModelRef< PlotAreaModel > PlotAreaRef; + typedef ModelRef< WallFloorModel > WallFloorRef; + typedef ModelRef< View3DModel > View3DRef; + typedef ModelRef< TitleModel > TitleRef; + typedef ModelRef< LegendModel > LegendRef; + + ShapeRef mxShapeProp; /// Chart frame formatting. + TextBodyRef mxTextProp; /// Global chart text formatting. + PlotAreaRef mxPlotArea; /// Plot area of the chart. + WallFloorRef mxFloor; /// Floor formatting in 3D charts. + WallFloorRef mxBackWall; /// Back wall formatting in 3D charts. + WallFloorRef mxSideWall; /// Side wall formatting in 3D charts. + View3DRef mxView3D; /// 3D settings. + TitleRef mxTitle; /// Chart main title. + LegendRef mxLegend; /// Chart legend. + OUString maDrawingPath; /// Path to drawing fragment with embedded shapes. + OUString maSheetPath; /// Path to embedded charts. + sal_Int32 mnDispBlanksAs; /// Mode how to display blank values. + sal_Int32 mnStyle; /// Index to default formatting. + bool mbAutoTitleDel; /// True = automatic title deleted manually. + bool mbPlotVisOnly; /// True = plot visible cells in a sheet only. + bool mbShowLabelsOverMax;/// True = show labels over chart maximum. + bool mbPivotChart; /// True = pivot chart. + + explicit ChartSpaceModel(bool bMSO2007Doc); + ~ChartSpaceModel(); +}; + + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/drawingml/chart/converterbase.hxx b/oox/inc/drawingml/chart/converterbase.hxx new file mode 100644 index 000000000..252c5314c --- /dev/null +++ b/oox/inc/drawingml/chart/converterbase.hxx @@ -0,0 +1,152 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_CONVERTERBASE_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_CONVERTERBASE_HXX + +#include <drawingml/chart/objectformatter.hxx> + +namespace com::sun::star { + namespace awt { struct Rectangle; } + namespace awt { struct Size; } + namespace chart2 { class XChartDocument; } + namespace chart2 { class XTitle; } + namespace drawing { class XShape; } + namespace uno { class XComponentContext; } +} +namespace oox::core { class XmlFilterBase; } + +namespace oox { +namespace drawingml { +namespace chart { + +class ChartConverter; +struct ChartSpaceModel; +struct ConverterData; + + +const sal_Int32 API_PRIM_AXESSET = 0; +const sal_Int32 API_SECN_AXESSET = 1; + +const sal_Int32 API_X_AXIS = 0; +const sal_Int32 API_Y_AXIS = 1; +const sal_Int32 API_Z_AXIS = 2; + + +class ConverterRoot +{ +public: + explicit ConverterRoot( + ::oox::core::XmlFilterBase& rFilter, + ChartConverter& rChartConverter, + const ChartSpaceModel& rChartModel, + const css::uno::Reference< css::chart2::XChartDocument >& rxChartDoc, + const css::awt::Size& rChartSize ); + virtual ~ConverterRoot(); + + ConverterRoot(ConverterRoot const &) = default; + ConverterRoot(ConverterRoot &&) = default; + ConverterRoot & operator =(ConverterRoot const &) = default; + ConverterRoot & operator =(ConverterRoot &&) = default; + + /** Creates an instance for the passed service name, using the process service factory. */ + css::uno::Reference< css::uno::XInterface > + createInstance( const OUString& rServiceName ) const; + css::uno::Reference< css::uno::XComponentContext > const & + getComponentContext() const; + +protected: + /** Returns the filter object of the imported/exported document. */ + ::oox::core::XmlFilterBase& getFilter() const; + /** Returns the chart converter. */ + ChartConverter& getChartConverter() const; + /** Returns the API chart document model. */ + css::uno::Reference< css::chart2::XChartDocument > const & + getChartDocument() const; + /** Returns the position and size of the chart shape in 1/100 mm. */ + const css::awt::Size& getChartSize() const; + /** Returns the default position and size of the chart shape in 1/100 mm. */ + static css::awt::Size getDefaultPageSize() { return css::awt::Size(16000, 9000); } + /** Returns the object formatter. */ + ObjectFormatter& getFormatter() const; + + /** Registers a title object and its layout data, needed for conversion of + the title position using the old Chart1 API. */ + void registerTitleLayout( + const css::uno::Reference< css::chart2::XTitle >& rxTitle, + const ModelRef< LayoutModel >& rxLayout, ObjectType eObjType, + sal_Int32 nMainIdx, sal_Int32 nSubIdx ); + /** Converts the positions of the main title and all axis titles. */ + void convertTitlePositions(); + +private: + std::shared_ptr< ConverterData > mxData; +}; + + +/** Base class of all converter classes. Holds a reference to a model structure + of the specified type. + */ +template< typename ModelType > +class ConverterBase : public ConverterRoot +{ +public: + const ModelType& getModel() const { return mrModel; } + +protected: + explicit ConverterBase( const ConverterRoot& rParent, ModelType& rModel ) : + ConverterRoot( rParent ), mrModel( rModel ) {} + virtual ~ConverterBase() override {} + +protected: + ModelType& mrModel; +}; + + +/** A layout converter calculates positions and sizes for various chart objects. + */ +class LayoutConverter final : public ConverterBase< LayoutModel > +{ +public: + explicit LayoutConverter( const ConverterRoot& rParent, LayoutModel& rModel ); + virtual ~LayoutConverter() override; + + /** Tries to calculate the absolute position and size from the contained + OOXML layout model. Returns true, if returned rectangle is valid. */ + bool calcAbsRectangle( css::awt::Rectangle& orRect ) const; + + /** Tries to set the position and size from the contained OOXML layout model. + Returns true, if a manual position and size could be calculated. */ + bool convertFromModel( PropertySet& rPropSet ); + + /** Tries to set the position from the contained OOXML layout model. */ + void convertFromModel( + const css::uno::Reference< css::drawing::XShape >& rxShape, + double fRotationAngle ); + bool getAutoLayout() const {return mrModel.mbAutoLayout;} +}; + + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/drawingml/chart/datasourcecontext.hxx b/oox/inc/drawingml/chart/datasourcecontext.hxx new file mode 100644 index 000000000..3894b545d --- /dev/null +++ b/oox/inc/drawingml/chart/datasourcecontext.hxx @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_DATASOURCECONTEXT_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_DATASOURCECONTEXT_HXX + +#include <memory> +#include <drawingml/chart/chartcontextbase.hxx> +#include <svl/zforlist.hxx> + +namespace oox { +namespace drawingml { +namespace chart { + + +struct DataSequenceModel; + +typedef ContextBase< DataSequenceModel > DataSequenceContextBase; + + +/** Handler for a double sequence context (c:numLit, c:numRef elements). + */ +class DoubleSequenceContext final : public DataSequenceContextBase +{ +public: + explicit DoubleSequenceContext( ::oox::core::ContextHandler2Helper& rParent, DataSequenceModel& rModel ); + virtual ~DoubleSequenceContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; + virtual void onCharacters( const OUString& rChars ) override; + +private: + SvNumberFormatter* getNumberFormatter(); + +private: + sal_Int32 mnPtIndex; /// Current data point index. + std::unique_ptr<SvNumberFormatter> + mpNumberFormatter; +}; + + +/** Handler for a string sequence context (c:multiLvlStrRef, c:strLit, + c:strRef elements). + */ +class StringSequenceContext final : public DataSequenceContextBase +{ +public: + explicit StringSequenceContext( ::oox::core::ContextHandler2Helper& rParent, DataSequenceModel& rModel ); + virtual ~StringSequenceContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; + virtual void onCharacters( const OUString& rChars ) override; + +private: + sal_Int32 mnPtIndex; /// Current data point index. +}; + + +struct DataSourceModel; + +/** Handler for a data source context (c:bubbleSize, c:cat, c:minus, c:plus, + c:val, c:xVal, c:yVal elements). + */ +class DataSourceContext final : public ContextBase< DataSourceModel > +{ +public: + explicit DataSourceContext( ::oox::core::ContextHandler2Helper& rParent, DataSourceModel& rModel ); + virtual ~DataSourceContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/drawingml/chart/datasourceconverter.hxx b/oox/inc/drawingml/chart/datasourceconverter.hxx new file mode 100644 index 000000000..67e1ac0c7 --- /dev/null +++ b/oox/inc/drawingml/chart/datasourceconverter.hxx @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_DATASOURCECONVERTER_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_DATASOURCECONVERTER_HXX + +#include <drawingml/chart/converterbase.hxx> + +namespace com::sun::star { + namespace chart2::data { class XDataSequence; } +} + +namespace oox { +namespace drawingml { +namespace chart { + + +struct DataSequenceModel; + +class DataSequenceConverter final : public ConverterBase< DataSequenceModel > +{ +public: + explicit DataSequenceConverter( const ConverterRoot& rParent, DataSequenceModel& rModel ); + virtual ~DataSequenceConverter() override; + + /** Creates a data sequence object from the contained formula link. */ + css::uno::Reference< css::chart2::data::XDataSequence > + createDataSequence( const OUString& rRole ); +}; + + +struct DataSourceModel; + +class DataSourceConverter final : public ConverterBase< DataSourceModel > +{ +public: + explicit DataSourceConverter( const ConverterRoot& rParent, DataSourceModel& rModel ); + virtual ~DataSourceConverter() override; + + /** Creates a data sequence object from the contained series data. */ + css::uno::Reference< css::chart2::data::XDataSequence > + createDataSequence( const OUString& rRole ); +}; + + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/drawingml/chart/objectformatter.hxx b/oox/inc/drawingml/chart/objectformatter.hxx new file mode 100644 index 000000000..9ccf5e437 --- /dev/null +++ b/oox/inc/drawingml/chart/objectformatter.hxx @@ -0,0 +1,162 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_OBJECTFORMATTER_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_OBJECTFORMATTER_HXX + +#include <oox/helper/propertyset.hxx> +#include <oox/drawingml/drawingmltypes.hxx> +#include <oox/drawingml/chart/modelbase.hxx> + +namespace com::sun::star { + namespace chart2 { class XChartDocument; } +} + +namespace oox::core { class XmlFilterBase; } + +namespace oox { +namespace drawingml { +namespace chart { + +/** Enumerates different object types for specific automatic formatting behaviour. */ +enum ObjectType +{ + OBJECTTYPE_CHARTSPACE, /// Chart background. + OBJECTTYPE_CHARTTITLE, /// Chart title. + OBJECTTYPE_LEGEND, /// Legend. + OBJECTTYPE_PLOTAREA2D, /// Plot area containing axes and data series in 2D charts. + OBJECTTYPE_PLOTAREA3D, /// Plot area containing axes and data series in 3D charts. + OBJECTTYPE_WALL, /// Background and side wall in 3D charts. + OBJECTTYPE_FLOOR, /// Floor in 3D charts. + OBJECTTYPE_AXIS, /// Axis line, labels, tick marks. + OBJECTTYPE_AXISTITLE, /// Axis title. + OBJECTTYPE_AXISUNIT, /// Axis unit label. + OBJECTTYPE_MAJORGRIDLINE, /// Axis major grid line. + OBJECTTYPE_MINORGRIDLINE, /// Axis minor grid line. + OBJECTTYPE_LINEARSERIES2D, /// Linear series in 2D line/radarline/scatter charts. + OBJECTTYPE_FILLEDSERIES2D, /// Filled series in 2D bar/area/radararea/bubble/pie/surface charts. + OBJECTTYPE_FILLEDSERIES3D, /// Filled series in 3D charts. + OBJECTTYPE_DATALABEL, /// Labels for data points. + OBJECTTYPE_TRENDLINE, /// Data series trend line. + OBJECTTYPE_TRENDLINELABEL, /// Trend line label. + OBJECTTYPE_ERRORBAR, /// Data series error indicator line. + OBJECTTYPE_SERLINE, /// Data point connector lines. + OBJECTTYPE_LEADERLINE, /// Leader lines between pie slice and data label. + OBJECTTYPE_DROPLINE, /// Drop lines between data points and X axis. + OBJECTTYPE_HILOLINE, /// High/low lines in line/stock charts. + OBJECTTYPE_UPBAR, /// Up-bar in line/stock charts. + OBJECTTYPE_DOWNBAR, /// Down-bar in line/stock charts. + OBJECTTYPE_DATATABLE /// Data table. +}; + +struct ChartSpaceModel; +struct ObjectFormatterData; +struct PictureOptionsModel; + +class ObjectFormatter +{ +public: + explicit ObjectFormatter( + const ::oox::core::XmlFilterBase& rFilter, + const css::uno::Reference< css::chart2::XChartDocument >& rxChartDoc, + const ChartSpaceModel& rChartSpace ); + ~ObjectFormatter(); + + /** Sets the maximum series index used for color cycling/fading. */ + void setMaxSeriesIndex( sal_Int32 nMaxSeriesIdx ); + /** Returns the current maximum series index used for color cycling/fading. */ + sal_Int32 getMaxSeriesIndex() const; + + /** Sets frame formatting properties to the passed property set. */ + void convertFrameFormatting( + PropertySet& rPropSet, + const ModelRef< Shape >& rxShapeProp, + ObjectType eObjType, + sal_Int32 nSeriesIdx = -1 ); + + /** Sets frame formatting properties to the passed property set. */ + void convertFrameFormatting( + PropertySet& rPropSet, + const ModelRef< Shape >& rxShapeProp, + const PictureOptionsModel& rPicOptions, + ObjectType eObjType, + sal_Int32 nSeriesIdx = -1 ); + + /** Sets text formatting properties to the passed property set. */ + void convertTextFormatting( + PropertySet& rPropSet, + const ModelRef< TextBody >& rxTextProp, + ObjectType eObjType ); + + /** Sets frame/text formatting properties to the passed property set. */ + void convertFormatting( + PropertySet& rPropSet, + const ModelRef< Shape >& rxShapeProp, + const ModelRef< TextBody >& rxTextProp, + ObjectType eObjType ); + + /** Sets text formatting properties to the passed property set. */ + void convertTextFormatting( + PropertySet& rPropSet, + const TextCharacterProperties& rTextProps, + ObjectType eObjType ); + + /** Sets text rotation properties to the passed property set. */ + static void convertTextRotation( + PropertySet& rPropSet, + const ModelRef< TextBody >& rxTextProp, + bool bSupportsStacked, sal_Int32 nDefaultRotation = 0); + + /** Sets text wrap properties to the passed property set. */ + static void convertTextWrap( + PropertySet& rPropSet, + const ModelRef< TextBody >& rxTextProp); + + /** Sets number format properties to the passed property set. */ + void convertNumberFormat( + PropertySet& rPropSet, + const NumberFormat& rNumberFormat, + bool bAxis, + bool bShowPercent = false ); + + /** Sets automatic fill properties to the passed property set. */ + void convertAutomaticFill( + PropertySet& rPropSet, + ObjectType eObjType, + sal_Int32 nSeriesIdx ); + + /** Returns true, if the passed shape properties have automatic fill mode. */ + static bool isAutomaticFill( const ModelRef< Shape >& rxShapeProp ); + + /** Returns true, if the X Axis label rotation is 0 degree. */ + static bool getTextRotation( + const ModelRef< TextBody >& rxTextProp, + sal_Int32 nDefaultRotation = 0 ); + +private: + std::shared_ptr< ObjectFormatterData > mxData; +}; + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/drawingml/chart/plotareacontext.hxx b/oox/inc/drawingml/chart/plotareacontext.hxx new file mode 100644 index 000000000..7664c05eb --- /dev/null +++ b/oox/inc/drawingml/chart/plotareacontext.hxx @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_PLOTAREACONTEXT_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_PLOTAREACONTEXT_HXX + +#include <drawingml/chart/chartcontextbase.hxx> + +namespace oox { +namespace drawingml { +namespace chart { + + +struct View3DModel; + +/** Handler for a chart plot area context (c:plotArea element). + */ +class View3DContext final : public ContextBase< View3DModel > +{ +public: + explicit View3DContext( ::oox::core::ContextHandler2Helper& rParent, View3DModel& rModel ); + virtual ~View3DContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +struct WallFloorModel; + +/** Handler for a chart wall/floor context (c:backWall, c:floor, c:sideWall + elements). + */ +class WallFloorContext final : public ContextBase< WallFloorModel > +{ +public: + explicit WallFloorContext( ::oox::core::ContextHandler2Helper& rParent, WallFloorModel& rModel ); + virtual ~WallFloorContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +struct DataTableModel; + +/** Handler for a data table context (c:dTable element). + */ +class DataTableContext final : public ContextBase< DataTableModel > +{ +public: + explicit DataTableContext( ::oox::core::ContextHandler2Helper& rParent, DataTableModel& rModel ); + virtual ~DataTableContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +struct PlotAreaModel; + +/** Handler for a chart plot area context (c:plotArea element). + */ +class PlotAreaContext final : public ContextBase< PlotAreaModel > +{ +public: + explicit PlotAreaContext( ::oox::core::ContextHandler2Helper& rParent, PlotAreaModel& rModel ); + virtual ~PlotAreaContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/drawingml/chart/plotareaconverter.hxx b/oox/inc/drawingml/chart/plotareaconverter.hxx new file mode 100644 index 000000000..5c9a93872 --- /dev/null +++ b/oox/inc/drawingml/chart/plotareaconverter.hxx @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_PLOTAREACONVERTER_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_PLOTAREACONVERTER_HXX + +#include <drawingml/chart/converterbase.hxx> + +namespace com::sun::star { + namespace chart2 { class XDiagram; } +} + +namespace oox { +namespace drawingml { +namespace chart { + + +struct View3DModel; +class TypeGroupConverter; + +class View3DConverter final : public ConverterBase< View3DModel > +{ +public: + explicit View3DConverter( const ConverterRoot& rParent, View3DModel& rModel ); + virtual ~View3DConverter() override; + + /** Converts the OOXML plot area model to a chart2 diagram. */ + void convertFromModel( + const css::uno::Reference< css::chart2::XDiagram >& rxDiagram, + TypeGroupConverter const & rTypeGroup ); +}; + + +struct WallFloorModel; + +class WallFloorConverter final : public ConverterBase< WallFloorModel > +{ +public: + explicit WallFloorConverter( const ConverterRoot& rParent, WallFloorModel& rModel ); + virtual ~WallFloorConverter() override; + + /** Converts the OOXML wall/floor model to a chart2 diagram. */ + void convertFromModel( + const css::uno::Reference< css::chart2::XDiagram >& rxDiagram, + ObjectType eObjType ); +}; + + +struct DataTableModel; + +class DataTableConverter final : public ConverterBase< DataTableModel > +{ +public: + explicit DataTableConverter( const ConverterRoot& rParent, DataTableModel& rModel ); + virtual ~DataTableConverter() override; + + /** Converts the OOXML data table model to a chart2 diagram. */ + void convertFromModel( + const css::uno::Reference< css::chart2::XDiagram >& rxDiagram); +}; + + +struct PlotAreaModel; + +class PlotAreaConverter final : public ConverterBase< PlotAreaModel > +{ +public: + explicit PlotAreaConverter( const ConverterRoot& rParent, PlotAreaModel& rModel ); + virtual ~PlotAreaConverter() override; + + /** Converts the OOXML plot area model to a chart2 diagram. */ + void convertFromModel( View3DModel& rView3DModel ); + /** Converts the manual plot area position and size, if set. */ + void convertPositionFromModel(); + + /** Returns the automatic chart title if the chart contains only one series. */ + const OUString& getAutomaticTitle() const { return maAutoTitle; } + /** Returns true, if chart type supports wall and floor format in 3D mode. */ + bool isWall3dChart() const { return mbWall3dChart; } + +private: + OUString maAutoTitle; + bool mb3dChart; + bool mbWall3dChart; + bool mbPieChart; +}; + + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/drawingml/chart/plotareamodel.hxx b/oox/inc/drawingml/chart/plotareamodel.hxx new file mode 100644 index 000000000..00d1a31cc --- /dev/null +++ b/oox/inc/drawingml/chart/plotareamodel.hxx @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_PLOTAREAMODEL_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_PLOTAREAMODEL_HXX + +#include <oox/drawingml/shape.hxx> +#include <drawingml/chart/axismodel.hxx> +#include <drawingml/chart/seriesmodel.hxx> +#include <drawingml/chart/typegroupmodel.hxx> + +namespace oox { +namespace drawingml { +namespace chart { + +struct View3DModel +{ + OptValue< sal_Int32 > monHeightPercent; /// Height of the 3D view, relative to chart width. + OptValue< sal_Int32 > monRotationX; /// Horizontal rotation in degrees. + OptValue< sal_Int32 > monRotationY; /// Vertical rotation in degrees. + sal_Int32 mnDepthPercent; /// Depth of the 3D view, relative to chart width. + sal_Int32 mnPerspective; /// Eye distance to the 3D objects. + bool mbRightAngled; /// True = right-angled axes in 3D view. + + explicit View3DModel(bool bMSO2007Doc); + ~View3DModel(); +}; + +struct WallFloorModel +{ + typedef ModelRef< Shape > ShapeRef; + typedef ModelRef< PictureOptionsModel > PictureOptionsRef; + + ShapeRef mxShapeProp; /// Wall/floor frame formatting. + PictureOptionsRef mxPicOptions; /// Fill bitmap settings. + + explicit WallFloorModel(); + ~WallFloorModel(); +}; + +struct DataTableModel +{ + bool mbShowHBorder; /// Show Horizontal Border + bool mbShowVBorder; /// Show Vertical Border + bool mbShowOutline; /// Show outline + explicit DataTableModel(); + ~DataTableModel(); +}; + +struct PlotAreaModel +{ + typedef ModelVector< TypeGroupModel > TypeGroupVector; + typedef ModelVector< AxisModel > AxisVector; + typedef ModelRef< Shape > ShapeRef; + typedef ModelRef< LayoutModel > LayoutRef; + typedef ModelRef< DataTableModel > DataTableRef; + + TypeGroupVector maTypeGroups; /// All chart type groups contained in the chart. + AxisVector maAxes; /// All axes contained in the chart. + ShapeRef mxShapeProp; /// Plot area frame formatting. + LayoutRef mxLayout; /// Layout/position of the plot area. + DataTableRef mxDataTable; /// Data table of the plot area. + + explicit PlotAreaModel(); + ~PlotAreaModel(); +}; + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/drawingml/chart/seriescontext.hxx b/oox/inc/drawingml/chart/seriescontext.hxx new file mode 100644 index 000000000..f56d51329 --- /dev/null +++ b/oox/inc/drawingml/chart/seriescontext.hxx @@ -0,0 +1,249 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_SERIESCONTEXT_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_SERIESCONTEXT_HXX + +#include <drawingml/chart/chartcontextbase.hxx> + +namespace oox { +namespace drawingml { +namespace chart { + + +struct DataLabelModel; + +/** Handler for a chart data point label context (c:dLbl element). + */ +class DataLabelContext final : public ContextBase< DataLabelModel > +{ +public: + explicit DataLabelContext( ::oox::core::ContextHandler2Helper& rParent, DataLabelModel& rModel ); + virtual ~DataLabelContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; + virtual void onCharacters( const OUString& rChars ) override; +}; + + +struct DataLabelsModel; + +/** Handler for a chart data point label context (c:dLbls element). + */ +class DataLabelsContext final : public ContextBase< DataLabelsModel > +{ +public: + explicit DataLabelsContext( ::oox::core::ContextHandler2Helper& rParent, DataLabelsModel& rModel ); + virtual ~DataLabelsContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; + virtual void onCharacters( const OUString& rChars ) override; +}; + + +struct PictureOptionsModel; + +/** Handler for fill bitmap settings (c:pictureOptions element). + */ +class PictureOptionsContext final : public ContextBase< PictureOptionsModel > +{ +public: + explicit PictureOptionsContext( ::oox::core::ContextHandler2Helper& rParent, PictureOptionsModel& rModel ); + virtual ~PictureOptionsContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +struct ErrorBarModel; + +/** Handler for a series error bar context (c:errBars element). + */ +class ErrorBarContext final : public ContextBase< ErrorBarModel > +{ +public: + explicit ErrorBarContext( ::oox::core::ContextHandler2Helper& rParent, ErrorBarModel& rModel ); + virtual ~ErrorBarContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +struct TrendlineLabelModel; + +/** Handler for a series trendline label context (c:trendlineLbl element). + */ +class TrendlineLabelContext final : public ContextBase< TrendlineLabelModel > +{ +public: + explicit TrendlineLabelContext( ::oox::core::ContextHandler2Helper& rParent, TrendlineLabelModel& rModel ); + virtual ~TrendlineLabelContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +struct TrendlineModel; + +/** Handler for a series trendline context (c:trendline element). + */ +class TrendlineContext final : public ContextBase< TrendlineModel > +{ +public: + explicit TrendlineContext( ::oox::core::ContextHandler2Helper& rParent, TrendlineModel& rModel ); + virtual ~TrendlineContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; + virtual void onCharacters( const OUString& rChars ) override; +}; + + +struct DataPointModel; + +/** Handler for a chart data point context (c:dPt element). + */ +class DataPointContext final : public ContextBase< DataPointModel > +{ +public: + explicit DataPointContext( ::oox::core::ContextHandler2Helper& rParent, DataPointModel& rModel ); + virtual ~DataPointContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +struct SeriesModel; + +/** Handler base class for chart data series contexts (c:ser element). + */ +class SeriesContextBase : public ContextBase< SeriesModel > +{ +public: + explicit SeriesContextBase( ::oox::core::ContextHandler2Helper& rParent, SeriesModel& rModel ); + virtual ~SeriesContextBase() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +/** Handler for a data series context for area chart types (c:ser element). + */ +class AreaSeriesContext final : public SeriesContextBase +{ +public: + explicit AreaSeriesContext( ::oox::core::ContextHandler2Helper& rParent, SeriesModel& rModel ); + virtual ~AreaSeriesContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +/** Handler for a data series context for bar chart types (c:ser element). + */ +class BarSeriesContext final : public SeriesContextBase +{ +public: + explicit BarSeriesContext( ::oox::core::ContextHandler2Helper& rParent, SeriesModel& rModel ); + virtual ~BarSeriesContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +/** Handler for a data series context for bubble chart types (c:ser element). + */ +class BubbleSeriesContext final : public SeriesContextBase +{ +public: + explicit BubbleSeriesContext( ::oox::core::ContextHandler2Helper& rParent, SeriesModel& rModel ); + virtual ~BubbleSeriesContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +/** Handler for a data series context for line and stock chart types (c:ser + element). + */ +class LineSeriesContext final : public SeriesContextBase +{ +public: + explicit LineSeriesContext( ::oox::core::ContextHandler2Helper& rParent, SeriesModel& rModel ); + virtual ~LineSeriesContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +/** Handler for a data series context for pie and doughnut chart types (c:ser + element). + */ +class PieSeriesContext final : public SeriesContextBase +{ +public: + explicit PieSeriesContext( ::oox::core::ContextHandler2Helper& rParent, SeriesModel& rModel ); + virtual ~PieSeriesContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +/** Handler for a data series context for radar chart types (c:ser element). + */ +class RadarSeriesContext final : public SeriesContextBase +{ +public: + explicit RadarSeriesContext( ::oox::core::ContextHandler2Helper& rParent, SeriesModel& rModel ); + virtual ~RadarSeriesContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +/** Handler for a data series context for scatter chart types (c:ser element). + */ +class ScatterSeriesContext final : public SeriesContextBase +{ +public: + explicit ScatterSeriesContext( ::oox::core::ContextHandler2Helper& rParent, SeriesModel& rModel ); + virtual ~ScatterSeriesContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +/** Handler for a data series context for scatter chart types (c:ser element). + */ +class SurfaceSeriesContext final : public SeriesContextBase +{ +public: + explicit SurfaceSeriesContext( ::oox::core::ContextHandler2Helper& rParent, SeriesModel& rModel ); + virtual ~SurfaceSeriesContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/drawingml/chart/seriesconverter.hxx b/oox/inc/drawingml/chart/seriesconverter.hxx new file mode 100644 index 000000000..afa5127f6 --- /dev/null +++ b/oox/inc/drawingml/chart/seriesconverter.hxx @@ -0,0 +1,151 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_SERIESCONVERTER_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_SERIESCONVERTER_HXX + +#include <drawingml/chart/converterbase.hxx> +#include <drawingml/chart/seriesmodel.hxx> + +namespace com::sun::star { + namespace chart2 { class XDataSeries; } + namespace chart2::data { class XLabeledDataSequence; } +} + +namespace oox { +namespace drawingml { +namespace chart { + +class TypeGroupConverter; + +// #i66858# enable this when Chart2 supports smoothed lines per data series +#define OOX_CHART_SMOOTHED_PER_SERIES 0 + + +class DataLabelConverter final : public ConverterBase< DataLabelModel > +{ +public: + explicit DataLabelConverter( const ConverterRoot& rParent, DataLabelModel& rModel ); + virtual ~DataLabelConverter() override; + + /** Converts OOXML data label settings for the passed data point. */ + void convertFromModel( + const css::uno::Reference< css::chart2::XDataSeries >& rxDataSeries, + const TypeGroupConverter& rTypeGroup ); +}; + + +class DataLabelsConverter final : public ConverterBase< DataLabelsModel > +{ +public: + explicit DataLabelsConverter( const ConverterRoot& rParent, DataLabelsModel& rModel ); + virtual ~DataLabelsConverter() override; + + /** Converts OOXML data label settings for the passed data series. */ + void convertFromModel( + const css::uno::Reference< css::chart2::XDataSeries >& rxDataSeries, + const TypeGroupConverter& rTypeGroup ); +}; + + +class ErrorBarConverter final : public ConverterBase< ErrorBarModel > +{ +public: + explicit ErrorBarConverter( const ConverterRoot& rParent, ErrorBarModel& rModel ); + virtual ~ErrorBarConverter() override; + + /** Converts an OOXML errorbar and inserts it into the passed data series. */ + void convertFromModel( + const css::uno::Reference< css::chart2::XDataSeries >& rxDataSeries ); + +private: + css::uno::Reference< css::chart2::data::XLabeledDataSequence > + createLabeledDataSequence( ErrorBarModel::SourceType eSourceType ); +}; + + +class TrendlineLabelConverter final : public ConverterBase< TrendlineLabelModel > +{ +public: + explicit TrendlineLabelConverter( const ConverterRoot& rParent, TrendlineLabelModel& rModel ); + virtual ~TrendlineLabelConverter() override; + + /** Converts the OOXML trendline label. */ + void convertFromModel( PropertySet& rPropSet ); +}; + + +class TrendlineConverter final : public ConverterBase< TrendlineModel > +{ +public: + explicit TrendlineConverter( const ConverterRoot& rParent, TrendlineModel& rModel ); + virtual ~TrendlineConverter() override; + + /** Converts an OOXML trendline and inserts it into the passed data series. */ + void convertFromModel( + const css::uno::Reference< css::chart2::XDataSeries >& rxDataSeries ); +}; + + +class DataPointConverter final : public ConverterBase< DataPointModel > +{ +public: + explicit DataPointConverter( const ConverterRoot& rParent, DataPointModel& rModel ); + virtual ~DataPointConverter() override; + + /** Converts settings for a data point in the passed series. */ + void convertFromModel( + const css::uno::Reference< css::chart2::XDataSeries >& rxDataSeries, + const TypeGroupConverter& rTypeGroup, + const SeriesModel& rSeries ); +}; + + +class SeriesConverter final : public ConverterBase< SeriesModel > +{ +public: + explicit SeriesConverter( const ConverterRoot& rParent, SeriesModel& rModel ); + virtual ~SeriesConverter() override; + + /** Creates a labeled data sequence object from category data link. */ + css::uno::Reference< css::chart2::data::XLabeledDataSequence > + createCategorySequence( const OUString& rRole ); + /** Creates a labeled data sequence object from value data link. */ + css::uno::Reference< css::chart2::data::XLabeledDataSequence > + createValueSequence( const OUString& rRole ); + /** Creates a data series object with initialized source links. */ + css::uno::Reference< css::chart2::XDataSeries > + createDataSeries( const TypeGroupConverter& rTypeGroup, bool bVaryColorsByPoint ); + +private: + css::uno::Reference< css::chart2::data::XLabeledDataSequence > + createLabeledDataSequence( + SeriesModel::SourceType eSourceType, + const OUString& rRole, + bool bUseTextLabel ); +}; + + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/drawingml/chart/seriesmodel.hxx b/oox/inc/drawingml/chart/seriesmodel.hxx new file mode 100644 index 000000000..d2fa53a5e --- /dev/null +++ b/oox/inc/drawingml/chart/seriesmodel.hxx @@ -0,0 +1,217 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_SERIESMODEL_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_SERIESMODEL_HXX + +#include <oox/drawingml/chart/datasourcemodel.hxx> +#include <drawingml/chart/titlemodel.hxx> + +namespace oox { +namespace drawingml { +namespace chart { + +struct DataLabelModelBase +{ + typedef ModelRef< Shape > ShapeRef; + typedef ModelRef< TextBody > TextBodyRef; + + ShapeRef mxShapeProp; /// Data label frame formatting. + TextBodyRef mxTextProp; /// Data label text formatting. + NumberFormat maNumberFormat; /// Number format for numeric data labels. + OptValue< OUString > moaSeparator;/// Separator between label components. + OptValue< sal_Int32 > monLabelPos; /// Data label position. + OptValue< bool > mobShowBubbleSize; /// True = show size of bubbles in bubble charts. + OptValue< bool > mobShowCatName; /// True = show category name of data points. + OptValue< bool > mobShowLegendKey; /// True = show legend key of data series. + OptValue< bool > mobShowPercent; /// True = show percentual value in pie/doughnut charts. + OptValue< bool > mobShowSerName; /// True = show series name. + OptValue< bool > mobShowVal; /// True = show data point value. + bool mbDeleted; /// True = data label(s) deleted. + + explicit DataLabelModelBase(bool bMSO2007Doc); + ~DataLabelModelBase(); +}; + +struct DataLabelModel : public DataLabelModelBase +{ + typedef ModelRef< LayoutModel > LayoutRef; + typedef ModelRef< TextModel > TextRef; + + LayoutRef mxLayout; /// Layout/position of the data point label frame. + TextRef mxText; /// Manual or linked text for this data point label. + sal_Int32 mnIndex; /// Data point index for this data label. + + explicit DataLabelModel(bool bMSO2007Doc); + ~DataLabelModel(); +}; + +struct DataLabelsModel : public DataLabelModelBase +{ + typedef ModelVector< DataLabelModel > DataLabelVector; + typedef ModelRef< Shape > ShapeRef; + + DataLabelVector maPointLabels; /// Settings for individual data point labels. + ShapeRef mxLeaderLines; /// Formatting of connector lines between data points and labels. + bool mbShowLeaderLines; /// True = show connector lines between data points and labels. + + explicit DataLabelsModel(bool bMSO2007Doc); + ~DataLabelsModel(); +}; + +struct PictureOptionsModel +{ + double mfStackUnit; /// Bitmap stacking unit. + sal_Int32 mnPictureFormat; /// Bitmap mode (stretch/tile). + bool mbApplyToFront; /// True = draw picture at front/back side of 3D data points. + bool mbApplyToSides; /// True = draw picture at left/right side of 3D data points. + bool mbApplyToEnd; /// True = draw picture at top/bottom side of 3D data points. + + explicit PictureOptionsModel(bool bMSO2007Doc); + ~PictureOptionsModel(); +}; + +struct ErrorBarModel +{ + enum SourceType + { + PLUS, /// Plus error bar values. + MINUS /// Minus error bar values. + }; + + typedef ModelMap< SourceType, DataSourceModel > DataSourceMap; + typedef ModelRef< Shape > ShapeRef; + + DataSourceMap maSources; /// Source ranges for manual error bar values. + ShapeRef mxShapeProp; /// Error line formatting. + double mfValue; /// Fixed value for several error bar types. + sal_Int32 mnDirection; /// Direction of the error bars (x/y). + sal_Int32 mnTypeId; /// Type of the error bars (plus/minus/both). + sal_Int32 mnValueType; /// Type of the values. + bool mbNoEndCap; /// True = no end cap at error bar lines. + + explicit ErrorBarModel(bool bMSO2007Doc); + ~ErrorBarModel(); +}; + +struct TrendlineLabelModel +{ + typedef ModelRef< Shape > ShapeRef; + typedef ModelRef< TextBody > TextBodyRef; + typedef ModelRef< LayoutModel > LayoutRef; + typedef ModelRef< TextModel > TextRef; + + ShapeRef mxShapeProp; /// Label frame formatting. + TextBodyRef mxTextProp; /// Label text formatting. + LayoutRef mxLayout; /// Layout/position of the frame. + TextRef mxText; /// Text source of the label. + NumberFormat maNumberFormat; /// Number format for coefficients. + + explicit TrendlineLabelModel(); + ~TrendlineLabelModel(); +}; + +struct TrendlineModel +{ + typedef ModelRef< Shape > ShapeRef; + typedef ModelRef< TrendlineLabelModel > TrendlineLabelRef; + + ShapeRef mxShapeProp; /// Trendline formatting. + TrendlineLabelRef mxLabel; /// Trendline label text object. + OUString maName; /// User-defined name of the trendline. + OptValue< double > mfBackward; /// Size of trendline before first data point. + OptValue< double > mfForward; /// Size of trendline behind last data point. + OptValue< double > mfIntercept; /// Crossing point with Y axis. + sal_Int32 mnOrder; /// Polynomial order in range [2, 6]. + sal_Int32 mnPeriod; /// Moving average period in range [2, 255]. + sal_Int32 mnTypeId; /// Type of the trendline. + bool mbDispEquation; /// True = show equation of the trendline. + bool mbDispRSquared; /// True = show R-squared of the trendline. + + explicit TrendlineModel(bool bMSO2007Doc); + ~TrendlineModel(); +}; + +struct DataPointModel +{ + typedef ModelRef< Shape > ShapeRef; + typedef ModelRef< PictureOptionsModel > PictureOptionsRef; + + ShapeRef mxShapeProp; /// Data point formatting. + PictureOptionsRef mxPicOptions; /// Fill bitmap settings. + ShapeRef mxMarkerProp; /// Data point marker formatting. + OptValue< sal_Int32 > monExplosion; /// Pie slice moved from pie center. + OptValue< sal_Int32 > monMarkerSize; /// Size of the series line marker (2...72). + OptValue< sal_Int32 > monMarkerSymbol; /// Series line marker symbol. + OptValue< bool > mobBubble3d; /// True = show bubbles with 3D shade. + sal_Int32 mnIndex; /// Unique data point index. + bool mbInvertNeg; /// True = invert negative data points (not derived from series!). + + explicit DataPointModel(bool bMSO2007Doc); + ~DataPointModel(); +}; + +struct SeriesModel +{ + enum SourceType + { + CATEGORIES, /// Data point categories. + VALUES, /// Data point values. + POINTS /// Data point size (e.g. bubble size in bubble charts). + }; + + typedef ModelMap< SourceType, DataSourceModel > DataSourceMap; + typedef ModelVector< ErrorBarModel > ErrorBarVector; + typedef ModelVector< TrendlineModel > TrendlineVector; + typedef ModelVector< DataPointModel > DataPointVector; + typedef ModelRef< Shape > ShapeRef; + typedef ModelRef< PictureOptionsModel > PictureOptionsRef; + typedef ModelRef< TextModel > TextRef; + typedef ModelRef< DataLabelsModel > DataLabelsRef; + + DataSourceMap maSources; /// Series source ranges. + ErrorBarVector maErrorBars; /// All error bars of this series. + TrendlineVector maTrendlines; /// All trendlines of this series. + DataPointVector maPoints; /// Explicit formatted data points. + ShapeRef mxShapeProp; /// Series formatting. + PictureOptionsRef mxPicOptions; /// Fill bitmap settings. + ShapeRef mxMarkerProp; /// Data point marker formatting. + TextRef mxText; /// Series title source. + DataLabelsRef mxLabels; /// Data point label settings for all points. + OptValue< sal_Int32 > monShape; /// 3D bar shape type. + sal_Int32 mnExplosion; /// Pie slice moved from pie center. + sal_Int32 mnIndex; /// Series index used for automatic formatting. + sal_Int32 mnMarkerSize; /// Size of the series line marker (2...72). + sal_Int32 mnMarkerSymbol; /// Series line marker symbol. + sal_Int32 mnOrder; /// Series order. + bool mbBubble3d; /// True = show bubbles with 3D shade. + bool mbInvertNeg; /// True = invert negative data points. + bool mbSmooth; /// True = smooth series line. + + explicit SeriesModel(bool bMSO2007Doc); + ~SeriesModel(); +}; + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/drawingml/chart/titlecontext.hxx b/oox/inc/drawingml/chart/titlecontext.hxx new file mode 100644 index 000000000..5a991109f --- /dev/null +++ b/oox/inc/drawingml/chart/titlecontext.hxx @@ -0,0 +1,91 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_TITLECONTEXT_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_TITLECONTEXT_HXX + +#include <drawingml/chart/chartcontextbase.hxx> + +namespace oox { +namespace drawingml { +namespace chart { + + +struct TextModel; + +/** Handler for a chart text context (c:tx element). + */ +class TextContext final : public ContextBase< TextModel > +{ +public: + explicit TextContext( ::oox::core::ContextHandler2Helper& rParent, TextModel& rModel ); + virtual ~TextContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; + virtual void onCharacters( const OUString& rChars ) override; +}; + + +struct TitleModel; + +/** Handler for a chart title context (c:title element). + */ +class TitleContext final : public ContextBase< TitleModel > +{ +public: + explicit TitleContext( ::oox::core::ContextHandler2Helper& rParent, TitleModel& rModel ); + virtual ~TitleContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + +struct LegendEntryModel; + +/** Handler for a chart legend entry context (c:legendEntry element). + */ +class LegendEntryContext final : public ContextBase< LegendEntryModel > +{ +public: + explicit LegendEntryContext( ::oox::core::ContextHandler2Helper& rParent, LegendEntryModel& rModel ); + virtual ~LegendEntryContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + +struct LegendModel; + +/** Handler for a chart legend context (c:legend element). + */ +class LegendContext final : public ContextBase< LegendModel > +{ +public: + explicit LegendContext( ::oox::core::ContextHandler2Helper& rParent, LegendModel& rModel ); + virtual ~LegendContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/drawingml/chart/titleconverter.hxx b/oox/inc/drawingml/chart/titleconverter.hxx new file mode 100644 index 000000000..78e671b61 --- /dev/null +++ b/oox/inc/drawingml/chart/titleconverter.hxx @@ -0,0 +1,105 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_TITLECONVERTER_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_TITLECONVERTER_HXX + +#include <drawingml/chart/converterbase.hxx> + +namespace com::sun::star { + namespace chart2 { class XDiagram; } + namespace chart2 { class XFormattedString; } + namespace chart2 { class XTitled; } + namespace chart2::data { class XDataSequence; } +} + +namespace oox::drawingml { struct TextCharacterProperties; } + +namespace oox { +namespace drawingml { +namespace chart { + + +struct TextModel; + +class TextConverter final : public ConverterBase< TextModel > +{ +public: + explicit TextConverter( const ConverterRoot& rParent, TextModel& rModel ); + virtual ~TextConverter() override; + + /** Creates a data sequence object from the contained text data. */ + css::uno::Reference< css::chart2::data::XDataSequence > + createDataSequence( const OUString& rRole ); + /** Creates a sequence of formatted string objects. */ + css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > > + createStringSequence( + const OUString& rDefaultText, + const ModelRef< TextBody >& rxTextProp, + ObjectType eObjType ); + +private: + css::uno::Reference< css::chart2::XFormattedString > + appendFormattedString( + ::std::vector< css::uno::Reference< css::chart2::XFormattedString > >& orStringVec, + const OUString& rString, + bool bAddNewLine ) const; +}; + + +struct TitleModel; + +class TitleConverter final : public ConverterBase< TitleModel > +{ +public: + explicit TitleConverter( const ConverterRoot& rParent, TitleModel& rModel ); + virtual ~TitleConverter() override; + + /** Creates a title text object and attaches it at the passed interface. */ + void convertFromModel( + const css::uno::Reference< css::chart2::XTitled >& rxTitled, + const OUString& rAutoTitle, ObjectType eObjType, + sal_Int32 nMainIdx = -1, sal_Int32 nSubIdx = -1 ); +}; + + +struct LegendModel; + +class LegendConverter final : public ConverterBase< LegendModel > +{ +public: + explicit LegendConverter( const ConverterRoot& rParent, LegendModel& rModel ); + virtual ~LegendConverter() override; + + /** Creates a legend object and attaches it at the passed diagram. */ + void convertFromModel( + const css::uno::Reference< css::chart2::XDiagram >& rxDiagram ); + +private: + void legendEntriesFormatting(const css::uno::Reference<css::chart2::XDiagram>& rxDiagram); +}; + + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/drawingml/chart/titlemodel.hxx b/oox/inc/drawingml/chart/titlemodel.hxx new file mode 100644 index 000000000..4b693e2e6 --- /dev/null +++ b/oox/inc/drawingml/chart/titlemodel.hxx @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_TITLEMODEL_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_TITLEMODEL_HXX + +#include <oox/drawingml/shape.hxx> +#include <oox/drawingml/chart/datasourcemodel.hxx> + +namespace oox { +namespace drawingml { +namespace chart { + +struct TextModel +{ + typedef ModelRef< DataSequenceModel > DataSequenceRef; + typedef ModelRef< TextBody > TextBodyRef; + + DataSequenceRef mxDataSeq; /// The string data or formula link of this text. + TextBodyRef mxTextBody; /// Rich-formatted literal text (for title objects only). + + explicit TextModel(); + ~TextModel(); +}; + +struct TitleModel +{ + typedef ModelRef< Shape > ShapeRef; + typedef ModelRef< TextBody > TextBodyRef; + typedef ModelRef< LayoutModel > LayoutRef; + typedef ModelRef< TextModel > TextRef; + + ShapeRef mxShapeProp; /// Title shape formatting. + TextBodyRef mxTextProp; /// Title text formatting. + LayoutRef mxLayout; /// Layout/position of the frame. + TextRef mxText; /// Text source of the title. + bool mbOverlay; /// True = title may overlay other objects. + sal_Int32 mnDefaultRotation; + + explicit TitleModel(sal_Int32 nDefaultRotation = 0); + ~TitleModel(); +}; + +struct LegendEntryModel +{ + sal_Int32 mnLegendEntryIdx; /// Legend entry index. + bool mbLabelDeleted; /// True = legend label deleted. + + LegendEntryModel(); + ~LegendEntryModel(); +}; + +struct LegendModel +{ + typedef ModelVector< LegendEntryModel > LegendEntryVector; + typedef ModelRef< Shape > ShapeRef; + typedef ModelRef< TextBody > TextBodyRef; + typedef ModelRef< LayoutModel > LayoutRef; + + LegendEntryVector maLegendEntries; /// Legend entries formatting. + ShapeRef mxShapeProp; /// Legend shape formatting. + TextBodyRef mxTextProp; /// Legend text formatting. + LayoutRef mxLayout; /// Layout/position of the legend. + sal_Int32 mnPosition; /// Legend position. + bool mbOverlay; /// True = legend may overlay other objects. + + explicit LegendModel(); + ~LegendModel(); +}; + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/drawingml/chart/typegroupcontext.hxx b/oox/inc/drawingml/chart/typegroupcontext.hxx new file mode 100644 index 000000000..0d23267a9 --- /dev/null +++ b/oox/inc/drawingml/chart/typegroupcontext.hxx @@ -0,0 +1,153 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_TYPEGROUPCONTEXT_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_TYPEGROUPCONTEXT_HXX + +#include <drawingml/chart/chartcontextbase.hxx> + +namespace oox { +namespace drawingml { +namespace chart { + + +struct UpDownBarsModel; + +/** Handler for an up/down bars context (c:upDownBars element). + */ +class UpDownBarsContext final : public ContextBase< UpDownBarsModel > +{ +public: + explicit UpDownBarsContext( ::oox::core::ContextHandler2Helper& rParent, UpDownBarsModel& rModel ); + virtual ~UpDownBarsContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +struct TypeGroupModel; +typedef ContextBase< TypeGroupModel > TypeGroupContextBase; + + +/** Handler for area type group contexts (c:area3DChart, c:areaChart elements). + */ +class AreaTypeGroupContext final : public TypeGroupContextBase +{ +public: + explicit AreaTypeGroupContext( ::oox::core::ContextHandler2Helper& rParent, TypeGroupModel& rModel ); + virtual ~AreaTypeGroupContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +/** Handler for bar type group contexts (c:bar3DChart, c:barChart elements). + */ +class BarTypeGroupContext final : public TypeGroupContextBase +{ +public: + explicit BarTypeGroupContext( ::oox::core::ContextHandler2Helper& rParent, TypeGroupModel& rModel ); + virtual ~BarTypeGroupContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +/** Handler for bubble type group context (c:bubbleChart element). + */ +class BubbleTypeGroupContext final : public TypeGroupContextBase +{ +public: + explicit BubbleTypeGroupContext( ::oox::core::ContextHandler2Helper& rParent, TypeGroupModel& rModel ); + virtual ~BubbleTypeGroupContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +/** Handler for line type group contexts (c:line3DChart, c:lineChart, + c:stockChart elements). + */ +class LineTypeGroupContext final : public TypeGroupContextBase +{ +public: + explicit LineTypeGroupContext( ::oox::core::ContextHandler2Helper& rParent, TypeGroupModel& rModel ); + virtual ~LineTypeGroupContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +/** Handler for pie type group contexts (c:doughnutChart, c:ofPieChart, + c:pie3DChart, c:pieChart elements). + */ +class PieTypeGroupContext final : public TypeGroupContextBase +{ +public: + explicit PieTypeGroupContext( ::oox::core::ContextHandler2Helper& rParent, TypeGroupModel& rModel ); + virtual ~PieTypeGroupContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +/** Handler for radar type group context (c:radarChart element). + */ +class RadarTypeGroupContext final : public TypeGroupContextBase +{ +public: + explicit RadarTypeGroupContext( ::oox::core::ContextHandler2Helper& rParent, TypeGroupModel& rModel ); + virtual ~RadarTypeGroupContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +/** Handler for scatter type group context (c:scatterChart element). + */ +class ScatterTypeGroupContext final : public TypeGroupContextBase +{ +public: + explicit ScatterTypeGroupContext( ::oox::core::ContextHandler2Helper& rParent, TypeGroupModel& rModel ); + virtual ~ScatterTypeGroupContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +/** Handler for surface type group contexts (c:surface3DChart, c:surfaceChart + elements). + */ +class SurfaceTypeGroupContext final : public TypeGroupContextBase +{ +public: + explicit SurfaceTypeGroupContext( ::oox::core::ContextHandler2Helper& rParent, TypeGroupModel& rModel ); + virtual ~SurfaceTypeGroupContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; +}; + + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/drawingml/chart/typegroupconverter.hxx b/oox/inc/drawingml/chart/typegroupconverter.hxx new file mode 100644 index 000000000..eeddd5fd7 --- /dev/null +++ b/oox/inc/drawingml/chart/typegroupconverter.hxx @@ -0,0 +1,181 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_TYPEGROUPCONVERTER_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_TYPEGROUPCONVERTER_HXX + +#include <drawingml/chart/converterbase.hxx> + +namespace com::sun::star { + namespace chart2 { class XChartType; } + namespace chart2 { class XCoordinateSystem; } + namespace chart2 { class XDataSeries; } + namespace chart2 { class XDiagram; } + namespace chart2::data { class XLabeledDataSequence; } +} + +namespace oox { +namespace drawingml { +namespace chart { + +/** Enumerates different chart types. */ +enum TypeId +{ + TYPEID_BAR, /// Vertical bar chart. + TYPEID_HORBAR, /// Horizontal bar chart. + TYPEID_LINE, /// Line chart. + TYPEID_AREA, /// Area chart. + TYPEID_STOCK, /// Stock chart. + TYPEID_RADARLINE, /// Linear radar chart. + TYPEID_RADARAREA, /// Filled radar chart. + TYPEID_PIE, /// Pie chart. + TYPEID_DOUGHNUT, /// Doughnut (ring) chart. + TYPEID_OFPIE, /// Pie-to-pie or pie-to-bar chart. + TYPEID_SCATTER, /// Scatter (XY) chart. + TYPEID_BUBBLE, /// Bubble chart. + TYPEID_SURFACE, /// Surface chart. + TYPEID_UNKNOWN /// Default for unknown chart types. +}; + +/** Enumerates different categories of similar chart types. */ +enum TypeCategory +{ + TYPECATEGORY_BAR, /// Bar charts (horizontal or vertical). + TYPECATEGORY_LINE, /// Line charts (line, area, stock charts). + TYPECATEGORY_RADAR, /// Radar charts (linear or filled). + TYPECATEGORY_PIE, /// Pie and donut charts. + TYPECATEGORY_SCATTER, /// Scatter and bubble charts. + TYPECATEGORY_SURFACE /// Surface charts. +}; + +/** Enumerates modes for varying point colors in a series. */ +enum VarPointMode +{ + VARPOINTMODE_NONE, /// No varied colors supported. + VARPOINTMODE_SINGLE, /// Only supported, if type group contains only one series. + VARPOINTMODE_MULTI /// Supported for multiple series in a chart type group. +}; + +/** Contains info for a chart type related to the OpenOffice.org chart module. */ +struct TypeGroupInfo +{ + TypeId meTypeId; /// Unique chart type identifier. + TypeCategory meTypeCategory; /// Category this chart type belongs to. + const char* mpcServiceName; /// Service name of the type. + VarPointMode meVarPointMode; /// Mode for varying point colors. + sal_Int32 mnDefLabelPos; /// Default data label position (API constant). + bool mbPolarCoordSystem; /// True = polar, false = cartesian. + bool mbSeriesIsFrame2d; /// True = 2D type series with area formatting. + bool mbSingleSeriesVis; /// True = only first series visible (e.g. pie charts). + bool mbCategoryAxis; /// True = X axis contains categories. + bool mbSwappedAxesSet; /// True = X axis and Y axis are swapped. + bool mbSupportsStacking; /// True = data points can be stacked on each other. + bool mbPictureOptions; /// True = bitmaps support options from c:pictureOptions. +}; + +const TypeGroupInfo& GetTypeGroupInfo( TypeId eType ); + +struct UpDownBarsModel; + +class UpDownBarsConverter final : public ConverterBase< UpDownBarsModel > +{ +public: + explicit UpDownBarsConverter( const ConverterRoot& rParent, UpDownBarsModel& rModel ); + virtual ~UpDownBarsConverter() override; + + /** Converts the OOXML up/down bars. */ + void convertFromModel( + const css::uno::Reference< css::chart2::XChartType >& rxChartType ); +}; + +struct TypeGroupModel; +struct View3DModel; + +class TypeGroupConverter final : public ConverterBase< TypeGroupModel > +{ +public: + explicit TypeGroupConverter( const ConverterRoot& rParent, TypeGroupModel& rModel ); + virtual ~TypeGroupConverter() override; + + /** Returns the type info struct that describes this chart type group. */ + const TypeGroupInfo& getTypeInfo() const { return maTypeInfo; } + + /** Returns true, if the series in this chart type group are stacked on each other (no percentage). */ + bool isStacked() const; + /** Returns true, if the series in this chart type group are stacked on each other as percentage. */ + bool isPercent() const; + /** Returns true, if the chart is three-dimensional. */ + bool is3dChart() const { return mb3dChart;} + /** Returns true, if chart type supports wall and floor format in 3D mode. */ + bool isWall3dChart() const; + /** Returns true, if the series in this chart type group are ordered on the Z axis. */ + bool isDeep3dChart() const; + + /** Returns true, if this chart type supports area formatting for its series. */ + bool isSeriesFrameFormat() const; + /** Returns the object type for a series depending on the chart type. */ + ObjectType getSeriesObjectType() const; + + /** Returns series title, if the chart type group contains only one single series. */ + OUString getSingleSeriesTitle() const; + + /** Creates a coordinate system according to the contained chart type. */ + css::uno::Reference< css::chart2::XCoordinateSystem > + createCoordinateSystem(); + /** Creates a labeled data sequence object for axis categories. */ + css::uno::Reference< css::chart2::data::XLabeledDataSequence > + createCategorySequence(); + + /** Converts the OOXML type group model into a chart2 coordinate system. */ + void convertFromModel( + const css::uno::Reference< css::chart2::XDiagram >& rxDiagram, + const css::uno::Reference< css::chart2::XCoordinateSystem >& rxCoordSystem, + sal_Int32 nAxesSetIdx, bool bSupportsVaryColorsByPoint ); + + /** Sets the passed OOXML marker style at the passed property set. */ + void convertMarker( PropertySet& rPropSet, sal_Int32 nOoxSymbol, sal_Int32 nOoxSize, + const ModelRef< Shape >& xShapeProps ) const; + /** Sets the passed OOXML line smoothing at the passed property set. */ + void convertLineSmooth( PropertySet& rPropSet, bool bOoxSmooth ) const; + /** Sets the passed OOXML bar 3D geometry at the passed property set. */ + void convertBarGeometry( PropertySet& rPropSet, sal_Int32 nOoxShape ) const; + /** Sets the passed OOXML pie rotation at the passed property set. */ + void convertPieRotation( PropertySet& rPropSet, sal_Int32 nOoxAngle ) const; + /** Sets the passed OOXML pie explosion at the passed property set. */ + void convertPieExplosion( PropertySet& rPropSet, sal_Int32 nOoxExplosion ) const; + +private: + /** Inserts the passed series into the chart type. Adds additional properties to the series. */ + void insertDataSeries( + const css::uno::Reference< css::chart2::XChartType >& rxChartType, + const css::uno::Reference< css::chart2::XDataSeries >& rxSeries, + sal_Int32 nAxesSetIdx ); + +private: + TypeGroupInfo maTypeInfo; /// Extended type info for contained chart type model. + bool mb3dChart; /// True = type is a 3D chart type. +}; + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/drawingml/chart/typegroupmodel.hxx b/oox/inc/drawingml/chart/typegroupmodel.hxx new file mode 100644 index 000000000..e790d48da --- /dev/null +++ b/oox/inc/drawingml/chart/typegroupmodel.hxx @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_TYPEGROUPMODEL_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_TYPEGROUPMODEL_HXX + +#include <drawingml/chart/seriesmodel.hxx> + +namespace oox { +namespace drawingml { +namespace chart { + +struct UpDownBarsModel +{ + typedef ModelRef< Shape > ShapeRef; + + ShapeRef mxDownBars; /// Formatting of down bars. + ShapeRef mxUpBars; /// Formatting of up bars. + sal_Int32 mnGapWidth; /// Space between up/down bars. + + explicit UpDownBarsModel(); + ~UpDownBarsModel(); +}; + +struct TypeGroupModel +{ + typedef ModelVector< SeriesModel > SeriesVector; + typedef ModelRef< DataLabelsModel > DataLabelsRef; + typedef ModelRef< UpDownBarsModel > UpDownBarsRef; + typedef ModelRef< Shape > ShapeRef; + + SeriesVector maSeries; /// Series attached to this chart type group. + std::vector<sal_Int32> + maAxisIds; /// List of axis identifiers used by this chart type. + DataLabelsRef mxLabels; /// Data point label settings for all series. + UpDownBarsRef mxUpDownBars; /// Up/down bars in stock charts. + ShapeRef mxSerLines; /// Connector lines in stacked bar charts. + ShapeRef mxDropLines; /// Drop lines connecting data points with X axis. + ShapeRef mxHiLowLines; /// High/low lines connecting lowest and highest data points. + double mfSplitPos; /// Threshold value in pie-to charts. + sal_Int32 mnBarDir; /// Bar direction in bar charts (vertical/horizontal). + sal_Int32 mnBubbleScale; /// Relative scaling of bubble size (percent). + sal_Int32 mnFirstAngle; /// Rotation angle of first slice in pie charts. + sal_Int32 mnGapDepth; /// Space between series in deep 3D charts. + sal_Int32 mnGapWidth; /// Space between bars in bar charts, or space in pie-to charts. + sal_Int32 mnGrouping; /// Series grouping mode. + sal_Int32 mnHoleSize; /// Hole size in doughnut charts. + sal_Int32 mnOfPieType; /// Pie-to-pie or pie-to-bar chart. + sal_Int32 mnOverlap; /// Bar overlap per category (2D bar charts only). + sal_Int32 mnRadarStyle; /// Type of radar chart (lines, markers, filled). + sal_Int32 mnScatterStyle; /// Type of scatter chart (lines, markers, smooth). + sal_Int32 mnSecondPieSize; /// relative size of second pie/bar in pie-to charts (percent). + sal_Int32 mnShape; /// 3D bar shape type. + sal_Int32 mnSizeRepresents; /// Bubble size represents area or width. + sal_Int32 mnSplitType; /// Split type in pie-to charts. + sal_Int32 mnTypeId; /// Chart type identifier. + bool mbBubble3d; /// True = show bubbles with 3D shade. + bool mbShowMarker; /// True = show point markers in line charts. + bool mbShowNegBubbles; /// True = show absolute value of negative bubbles. + bool mbSmooth; /// True = smooth lines in line charts. + bool mbVaryColors; /// True = different automatic colors for each point. + bool mbWireframe; /// True = wireframe surface chart, false = filled surface chart. + + explicit TypeGroupModel( sal_Int32 nTypeId, bool bMSO2007Doc ); + ~TypeGroupModel(); +}; + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |