diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-04-18 18:26:28 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-04-23 22:20:31 +0200 |
commit | b9337e22ce1dbf2eba0e8c8db294ae99f4111f91 (patch) | |
tree | 53ee1bd3dfd213815a21579151983cb997922b05 /include/oox/drawingml | |
parent | move global headers script (diff) | |
download | core-b9337e22ce1dbf2eba0e8c8db294ae99f4111f91.tar.gz core-b9337e22ce1dbf2eba0e8c8db294ae99f4111f91.zip |
execute move of global headers
see https://gerrit.libreoffice.org/#/c/3367/
and Change-Id: I00c96fa77d04b33a6f8c8cd3490dfcd9bdc9e84a for details
Change-Id: I199a75bc4042af20817265d5ef85b1134a96ff5a
Diffstat (limited to 'include/oox/drawingml')
90 files changed, 7920 insertions, 0 deletions
diff --git a/include/oox/drawingml/chart/axiscontext.hxx b/include/oox/drawingml/chart/axiscontext.hxx new file mode 100644 index 000000000000..d22a53f23227 --- /dev/null +++ b/include/oox/drawingml/chart/axiscontext.hxx @@ -0,0 +1,120 @@ +/* -*- 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 OOX_DRAWINGML_CHART_AXISCONTEXT_HXX +#define OOX_DRAWINGML_CHART_AXISCONTEXT_HXX + +#include "oox/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 : public ContextBase< AxisDispUnitsModel > +{ +public: + explicit AxisDispUnitsContext( ::oox::core::ContextHandler2Helper& rParent, AxisDispUnitsModel& rModel ); + virtual ~AxisDispUnitsContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +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(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +/** Handler for a category axis context (c:catAx element). + */ +class CatAxisContext : public AxisContextBase +{ +public: + explicit CatAxisContext( ::oox::core::ContextHandler2Helper& rParent, AxisModel& rModel ); + virtual ~CatAxisContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +/** Handler for a date axis context (c:dateAx element). + */ +class DateAxisContext : public AxisContextBase +{ +public: + explicit DateAxisContext( ::oox::core::ContextHandler2Helper& rParent, AxisModel& rModel ); + virtual ~DateAxisContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +/** Handler for a series axis context (c:serAx element). + */ +class SerAxisContext : public AxisContextBase +{ +public: + explicit SerAxisContext( ::oox::core::ContextHandler2Helper& rParent, AxisModel& rModel ); + virtual ~SerAxisContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +/** Handler for a value axis context (c:valAx element). + */ +class ValAxisContext : public AxisContextBase +{ +public: + explicit ValAxisContext( ::oox::core::ContextHandler2Helper& rParent, AxisModel& rModel ); + virtual ~ValAxisContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/chart/axisconverter.hxx b/include/oox/drawingml/chart/axisconverter.hxx new file mode 100644 index 000000000000..fac1d67c8997 --- /dev/null +++ b/include/oox/drawingml/chart/axisconverter.hxx @@ -0,0 +1,64 @@ +/* -*- 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 OOX_DRAWINGML_CHART_AXISCONVERTER_HXX +#define OOX_DRAWINGML_CHART_AXISCONVERTER_HXX + +#include "oox/drawingml/chart/converterbase.hxx" + +namespace com { namespace sun { namespace star { + namespace chart2 { class XAxis; } + namespace chart2 { class XCoordinateSystem; } +} } } + +namespace oox { +namespace drawingml { +namespace chart { + +// ============================================================================ + +struct AxisModel; +class TypeGroupConverter; + +class AxisConverter : public ConverterBase< AxisModel > +{ +public: + explicit AxisConverter( + const ConverterRoot& rParent, + AxisModel& rModel ); + virtual ~AxisConverter(); + + /** Creates a chart2 axis and inserts it into the passed coordinate system. */ + void convertFromModel( + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem >& rxCoordSystem, + TypeGroupConverter& rTypeGroup, + 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/include/oox/drawingml/chart/axismodel.hxx b/include/oox/drawingml/chart/axismodel.hxx new file mode 100644 index 000000000000..30ceae499b0a --- /dev/null +++ b/include/oox/drawingml/chart/axismodel.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 OOX_DRAWINGML_CHART_AXISMODEL_HXX +#define OOX_DRAWINGML_CHART_AXISMODEL_HXX + +#include "oox/drawingml/shape.hxx" +#include "oox/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. + sal_Int32 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; /// Mainor 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 ); + ~AxisModel(); +}; + +// ============================================================================ + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/chart/chartcontextbase.hxx b/include/oox/drawingml/chart/chartcontextbase.hxx new file mode 100644 index 000000000000..218e7bf4406e --- /dev/null +++ b/include/oox/drawingml/chart/chartcontextbase.hxx @@ -0,0 +1,95 @@ +/* -*- 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 OOX_DRAWINGML_CHART_CHARTCONTEXTBASE_HXX +#define OOX_DRAWINGML_CHART_CHARTCONTEXTBASE_HXX + +#include "oox/core/fragmenthandler2.hxx" + +namespace oox { namespace drawingml { class Shape; } } + +namespace oox { +namespace drawingml { +namespace chart { + +// ============================================================================ + +template< typename ModelType > +class ContextBase : public ::oox::core::ContextHandler2 +{ +public: + inline explicit ContextBase( ::oox::core::ContextHandler2Helper& rParent, ModelType& rModel ) : + ::oox::core::ContextHandler2( rParent ), mrModel( rModel ) {} + virtual ~ContextBase() {} + +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 ) {} + virtual ~FragmentBase() {} + +protected: + ModelType& mrModel; +}; + +// ============================================================================ + +/** Help class for all contexts that have only the c:spPr child element. + */ +class ShapePrWrapperContext : public ContextBase< Shape > +{ +public: + explicit ShapePrWrapperContext( ::oox::core::ContextHandler2Helper& rParent, Shape& rModel ); + virtual ~ShapePrWrapperContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +struct LayoutModel; + +/** Handler for a chart layout context (c:layout element). + */ +class LayoutContext : public ContextBase< LayoutModel > +{ +public: + explicit LayoutContext( ::oox::core::ContextHandler2Helper& rParent, LayoutModel& rModel ); + virtual ~LayoutContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/chart/chartconverter.hxx b/include/oox/drawingml/chart/chartconverter.hxx new file mode 100644 index 000000000000..bbc7e0fafd28 --- /dev/null +++ b/include/oox/drawingml/chart/chartconverter.hxx @@ -0,0 +1,104 @@ +/* -*- 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 OOX_DRAWINGML_CHART_CHARTCONVERTER_HXX +#define OOX_DRAWINGML_CHART_CHARTCONVERTER_HXX + +#include <com/sun/star/uno/Reference.hxx> +#include <oox/dllapi.h> + +namespace com { namespace sun { namespace star { + namespace awt { struct Point; } + namespace awt { struct Size; } + namespace drawing { class XShapes; } + namespace chart2 { class XChartDocument; } + namespace chart2 { namespace data { class XDataProvider; } } + namespace chart2 { namespace data { class XDataSequence; } } +} } } + +namespace oox { namespace core { class XmlFilterBase; } } + +namespace oox { +namespace drawingml { +namespace chart { + +struct ChartSpaceModel; +struct DataSequenceModel; + +// ============================================================================ + +class OOX_DLLPUBLIC ChartConverter +{ +public: + explicit ChartConverter(); + virtual ~ChartConverter(); + + /** Converts the passed OOXML chart model to the passed chart2 document. + + @param rChartModel The filled MSOOXML chart model structure. + + @param rxChartDoc The UNO chart document model to be initialized. + + @param rxExternalPage If null, all embedded shapes will be inserted + into the internal drawing page of the chart document. If not null, + all embedded shapes will be inserted into this shapes collection. + + @param rChartPos The position of the chart shape in its drawing page, + in 1/100 mm. Will be used only, if parameter rxExternalPage is not + null, for correct positioning of the embedded shapes in the + external drawing page. + + @param rChartSize The size of the chart shape in 1/100 mm. Needed for + calculation of position and size of the chart elements (diagram, + titles, legend, etc.) and embedded shapes. + */ + void convertFromModel( + ::oox::core::XmlFilterBase& rFilter, + ChartSpaceModel& rChartModel, + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& rxChartDoc, + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxExternalPage, + const ::com::sun::star::awt::Point& rChartPos, + const ::com::sun::star::awt::Size& rChartSize ); + + /** Creates an internal data provider. Derived classes may override this + function to create an external data provider. */ + virtual void createDataProvider( + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& rxChartDoc ); + + /** Creates a data sequence from a formula. Dummy implementation. Derived + classes have to override this function to actually parse the formula. */ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence > + createDataSequence( + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider >& rxDataProvider, + const DataSequenceModel& rDataSeq ); + +private: + ChartConverter( const ChartConverter& ); + ChartConverter& operator=( const ChartConverter& ); +}; + +// ============================================================================ + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/chart/chartdrawingfragment.hxx b/include/oox/drawingml/chart/chartdrawingfragment.hxx new file mode 100644 index 000000000000..43d27f586514 --- /dev/null +++ b/include/oox/drawingml/chart/chartdrawingfragment.hxx @@ -0,0 +1,115 @@ +/* -*- 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 OOX_DRAWINGML_CHART_CHARTDRAWINGFRAGMENT_HXX +#define 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). + + inline explicit AnchorPosModel() : mfX( -1.0 ), mfY( -1.0 ) {} + inline 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 +{ + inline explicit AnchorSizeModel() : EmuSize( -1, -1 ) {} + inline 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 an 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. +}; + +typedef ::boost::shared_ptr< ShapeAnchor > ShapeAnchorRef; + +// ============================================================================ + +/** Handler for a chart drawing fragment (c:userShapes root element). + */ +class ChartDrawingFragment : public ::oox::core::FragmentHandler2 +{ +public: + explicit ChartDrawingFragment( + ::oox::core::XmlFilterBase& rFilter, + const OUString& rFragmentPath, + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxDrawPage, + const ::com::sun::star::awt::Size& rChartSize, + const ::com::sun::star::awt::Point& rShapesOffset, + bool bOleSupport ); + virtual ~ChartDrawingFragment(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); + virtual void onCharacters( const OUString& rChars ); + virtual void onEndElement(); + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > + mxDrawPage; /// Drawing page of this sheet. + ::oox::drawingml::ShapePtr mxShape; /// Current top-level shape. + ShapeAnchorRef 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/include/oox/drawingml/chart/chartspaceconverter.hxx b/include/oox/drawingml/chart/chartspaceconverter.hxx new file mode 100644 index 000000000000..2bdeb013b1b3 --- /dev/null +++ b/include/oox/drawingml/chart/chartspaceconverter.hxx @@ -0,0 +1,57 @@ +/* -*- 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 OOX_DRAWINGML_CHART_CHARTSPACECONVERTER_HXX +#define OOX_DRAWINGML_CHART_CHARTSPACECONVERTER_HXX + +#include "oox/drawingml/chart/converterbase.hxx" + +namespace com { namespace sun { namespace star { + namespace drawing { class XShapes; } +} } } + +namespace oox { +namespace drawingml { +namespace chart { + +// ============================================================================ + +struct ChartSpaceModel; + +class ChartSpaceConverter : public ConverterBase< ChartSpaceModel > +{ +public: + explicit ChartSpaceConverter( const ConverterRoot& rParent, ChartSpaceModel& rModel ); + virtual ~ChartSpaceConverter(); + + /** Converts the contained OOXML chart model to a chart2 document. */ + void convertFromModel( + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxExternalPage, + const ::com::sun::star::awt::Point& rChartPos ); +}; + +// ============================================================================ + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/chart/chartspacefragment.hxx b/include/oox/drawingml/chart/chartspacefragment.hxx new file mode 100644 index 000000000000..c9b1e0c6b776 --- /dev/null +++ b/include/oox/drawingml/chart/chartspacefragment.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 OOX_DRAWINGML_CHART_CHARTSPACEFRAGMENT_HXX +#define OOX_DRAWINGML_CHART_CHARTSPACEFRAGMENT_HXX + +#include "oox/drawingml/chart/chartcontextbase.hxx" + +namespace oox { +namespace drawingml { +namespace chart { + +// ============================================================================ + +struct ChartSpaceModel; + +/** Handler for a chart fragment (c:chartSpace root element). + */ +class ChartSpaceFragment : public FragmentBase< ChartSpaceModel > +{ +public: + explicit ChartSpaceFragment( + ::oox::core::XmlFilterBase& rFilter, + const OUString& rFragmentPath, + ChartSpaceModel& rModel ); + virtual ~ChartSpaceFragment(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/chart/chartspacemodel.hxx b/include/oox/drawingml/chart/chartspacemodel.hxx new file mode 100644 index 000000000000..b3d3405c4670 --- /dev/null +++ b/include/oox/drawingml/chart/chartspacemodel.hxx @@ -0,0 +1,72 @@ +/* -*- 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 OOX_DRAWINGML_CHART_CHARTSPACEMODEL_HXX +#define OOX_DRAWINGML_CHART_CHARTSPACEMODEL_HXX + +#include "oox/drawingml/shape.hxx" +#include "oox/drawingml/chart/plotareamodel.hxx" +#include "oox/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. + 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(); + ~ChartSpaceModel(); +}; + +// ============================================================================ + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/chart/converterbase.hxx b/include/oox/drawingml/chart/converterbase.hxx new file mode 100644 index 000000000000..21a03441e803 --- /dev/null +++ b/include/oox/drawingml/chart/converterbase.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 OOX_DRAWINGML_CHART_CONVERTERBASE_HXX +#define OOX_DRAWINGML_CHART_CONVERTERBASE_HXX + +#include "oox/drawingml/chart/chartcontextbase.hxx" +#include "oox/drawingml/chart/objectformatter.hxx" + +namespace com { namespace sun { namespace star { + namespace awt { struct Rectangle; } + namespace awt { struct Size; } + namespace chart2 { class XChartDocument; } + namespace chart2 { class XTitle; } + namespace drawing { class XShape; } +} } } + +namespace oox { namespace 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 ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& rxChartDoc, + const ::com::sun::star::awt::Size& rChartSize ); + virtual ~ConverterRoot(); + + /** Creates an instance for the passed service name, using the process service factory. */ + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > + createInstance( const OUString& rServiceName ) const; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > + 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. */ + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > + getChartDocument() const; + /** Returns the position and size of the chart shape in 1/100 mm. */ + const ::com::sun::star::awt::Size& getChartSize() const; + /** 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 ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTitle >& rxTitle, + const ModelRef< LayoutModel >& rxLayout, ObjectType eObjType, + sal_Int32 nMainIdx = -1, sal_Int32 nSubIdx = -1 ); + /** Converts the positions of the main title and all axis titles. */ + void convertTitlePositions(); + +private: + ::boost::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: + inline const ModelType& getModel() const { return mrModel; } + +protected: + inline explicit ConverterBase( const ConverterRoot& rParent, ModelType& rModel ) : + ConverterRoot( rParent ), mrModel( rModel ) {} + virtual ~ConverterBase() {} + +protected: + ModelType& mrModel; +}; + +// ============================================================================ + +/** A layout converter calculates positions and sizes for various chart objects. + */ +class LayoutConverter : public ConverterBase< LayoutModel > +{ +public: + explicit LayoutConverter( const ConverterRoot& rParent, LayoutModel& rModel ); + virtual ~LayoutConverter(); + + /** Tries to calculate the absolute position and size from the contained + OOXML layout model. Returns true, if returned rectangle is valid. */ + bool calcAbsRectangle( ::com::sun::star::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. + Returns true, if a manual position could be calculated. */ + bool convertFromModel( + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape, + double fRotationAngle ); +}; + +// ============================================================================ + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/chart/datasourcecontext.hxx b/include/oox/drawingml/chart/datasourcecontext.hxx new file mode 100644 index 000000000000..163b99c868e4 --- /dev/null +++ b/include/oox/drawingml/chart/datasourcecontext.hxx @@ -0,0 +1,94 @@ +/* -*- 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 OOX_DRAWINGML_CHART_DATASOURCECONTEXT_HXX +#define OOX_DRAWINGML_CHART_DATASOURCECONTEXT_HXX + +#include "oox/drawingml/chart/chartcontextbase.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 : public DataSequenceContextBase +{ +public: + explicit DoubleSequenceContext( ::oox::core::ContextHandler2Helper& rParent, DataSequenceModel& rModel ); + virtual ~DoubleSequenceContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); + virtual void onCharacters( const OUString& rChars ); + +private: + sal_Int32 mnPtIndex; /// Current data point index. +}; + +// ============================================================================ + +/** Handler for a string sequence context (c:multiLvlStrRef, c:strLit, + c:strRef elements). + */ +class StringSequenceContext : public DataSequenceContextBase +{ +public: + explicit StringSequenceContext( ::oox::core::ContextHandler2Helper& rParent, DataSequenceModel& rModel ); + virtual ~StringSequenceContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); + virtual void onCharacters( const OUString& rChars ); + +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 : public ContextBase< DataSourceModel > +{ +public: + explicit DataSourceContext( ::oox::core::ContextHandler2Helper& rParent, DataSourceModel& rModel ); + virtual ~DataSourceContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/chart/datasourceconverter.hxx b/include/oox/drawingml/chart/datasourceconverter.hxx new file mode 100644 index 000000000000..e8b5649e1bef --- /dev/null +++ b/include/oox/drawingml/chart/datasourceconverter.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 OOX_DRAWINGML_CHART_DATASOURCECONVERTER_HXX +#define OOX_DRAWINGML_CHART_DATASOURCECONVERTER_HXX + +#include "oox/drawingml/chart/converterbase.hxx" + +namespace com { namespace sun { namespace star { + namespace chart2 { namespace data { class XDataSequence; } } +} } } + +namespace oox { +namespace drawingml { +namespace chart { + +// ============================================================================ + +struct DataSequenceModel; + +class DataSequenceConverter : public ConverterBase< DataSequenceModel > +{ +public: + explicit DataSequenceConverter( const ConverterRoot& rParent, DataSequenceModel& rModel ); + virtual ~DataSequenceConverter(); + + /** Creates a data sequence object from the contained formula link. */ + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence > + createDataSequence( const OUString& rRole ); +}; + +// ============================================================================ + +struct DataSourceModel; + +class DataSourceConverter : public ConverterBase< DataSourceModel > +{ +public: + explicit DataSourceConverter( const ConverterRoot& rParent, DataSourceModel& rModel ); + virtual ~DataSourceConverter(); + + /** Creates a data sequence object from the contained series data. */ + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence > + createDataSequence( const OUString& rRole ); +}; + +// ============================================================================ + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/chart/datasourcemodel.hxx b/include/oox/drawingml/chart/datasourcemodel.hxx new file mode 100644 index 000000000000..d43048ef071c --- /dev/null +++ b/include/oox/drawingml/chart/datasourcemodel.hxx @@ -0,0 +1,65 @@ +/* -*- 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 OOX_DRAWINGML_CHART_DATASOURCEMODEL_HXX +#define OOX_DRAWINGML_CHART_DATASOURCEMODEL_HXX + +#include <com/sun/star/uno/Any.hxx> +#include "oox/drawingml/chart/modelbase.hxx" + +namespace oox { +namespace drawingml { +namespace chart { + +// ============================================================================ + +struct DataSequenceModel +{ + typedef ::std::map< sal_Int32, ::com::sun::star::uno::Any > AnyMap; + + AnyMap maData; /// Map of values, indexed by point identifier. + OUString maFormula; /// Formula reference, e.g. into a spreadsheet. + OUString maFormatCode; /// Number format for double values. + sal_Int32 mnPointCount; /// Number of points in this series source. + + explicit DataSequenceModel(); + ~DataSequenceModel(); +}; + +// ============================================================================ + +struct DataSourceModel +{ + typedef ModelRef< DataSequenceModel > DataSequenceRef; + + DataSequenceRef mxDataSeq; /// The data sequence or formula link of this source. + + explicit DataSourceModel(); + ~DataSourceModel(); +}; + +// ============================================================================ + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/chart/modelbase.hxx b/include/oox/drawingml/chart/modelbase.hxx new file mode 100644 index 000000000000..985221ec394b --- /dev/null +++ b/include/oox/drawingml/chart/modelbase.hxx @@ -0,0 +1,134 @@ +/* -*- 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 OOX_DRAWINGML_CHART_MODELBASE_HXX +#define OOX_DRAWINGML_CHART_MODELBASE_HXX + +#include "oox/helper/helper.hxx" +#include "oox/helper/refmap.hxx" +#include "oox/helper/refvector.hxx" + +namespace oox { class AttributeList; } + +namespace oox { +namespace drawingml { +namespace chart { + +// ============================================================================ + +template< typename ModelType > +class ModelRef : public ::boost::shared_ptr< ModelType > +{ +public: + inline explicit ModelRef() {} + inline ModelRef( const ::boost::shared_ptr< ModelType >& rxModel ) : ::boost::shared_ptr< ModelType >( rxModel ) {} + inline ~ModelRef() {} + + inline bool is() const { return this->get() != 0; } + + inline ModelType& create() { this->reset( new ModelType ); return **this; } + template< typename Param1Type > + inline ModelType& create( const Param1Type& rParam1 ) { this->reset( new ModelType( rParam1 ) ); return **this; } + + inline ModelType& getOrCreate() { if( !*this ) this->reset( new ModelType ); return **this; } + template< typename Param1Type > + inline ModelType& getOrCreate( const Param1Type& rParam1 ) { if( !*this ) this->reset( new ModelType( rParam1 ) ); return **this; } +}; + +// ============================================================================ + +template< typename ModelType > +class ModelVector : public RefVector< ModelType > +{ +public: + typedef typename RefVector< ModelType >::value_type value_type; + typedef typename RefVector< ModelType >::size_type size_type; + + inline explicit ModelVector() {} + inline ~ModelVector() {} + + inline ModelType& create() { return append( new ModelType ); } + template< typename Param1Type > + inline ModelType& create( const Param1Type& rParam1 ) { return append( new ModelType( rParam1 ) ); } + +private: + inline ModelType& append( ModelType* pModel ) { this->push_back( value_type( pModel ) ); return *pModel; } +}; + +// ============================================================================ + +template< typename KeyType, typename ModelType > +class ModelMap : public RefMap< KeyType, ModelType > +{ +public: + typedef typename RefMap< KeyType, ModelType >::key_type key_type; + typedef typename RefMap< KeyType, ModelType >::mapped_type mapped_type; + typedef typename RefMap< KeyType, ModelType >::value_type value_type; + + inline explicit ModelMap() {} + inline ~ModelMap() {} + + inline ModelType& create( KeyType eKey ) { return insert( eKey, new ModelType ); } + template< typename Param1Type > + inline ModelType& create( KeyType eKey, const Param1Type& rParam1 ) { return insert( eKey, new ModelType( rParam1 ) ); } + +private: + inline ModelType& insert( KeyType eKey, ModelType* pModel ) { (*this)[ eKey ].reset( pModel ); return *pModel; } +}; + +// ============================================================================ + +struct NumberFormat +{ + OUString maFormatCode; /// Number format code. + bool mbSourceLinked; /// True = number format linked to source data. + + explicit NumberFormat(); + + void setAttributes( const AttributeList& rAttribs ); +}; + +// ============================================================================ + +struct LayoutModel +{ + double mfX; /// Left position of this object. + double mfY; /// Top position of this object. + double mfW; /// Width of this object. + double mfH; /// Height of this object. + sal_Int32 mnXMode; /// Mode for left position. + sal_Int32 mnYMode; /// Mode for top position. + sal_Int32 mnWMode; /// Mode for width. + sal_Int32 mnHMode; /// Mode for height. + sal_Int32 mnTarget; /// Layout target for plot area. + bool mbAutoLayout; /// True = automatic positioning. + + explicit LayoutModel(); + ~LayoutModel(); +}; + +// ============================================================================ + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/chart/objectformatter.hxx b/include/oox/drawingml/chart/objectformatter.hxx new file mode 100644 index 000000000000..5b2bb727f4fd --- /dev/null +++ b/include/oox/drawingml/chart/objectformatter.hxx @@ -0,0 +1,157 @@ +/* -*- 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 OOX_DRAWINGML_CHART_OBJECTFORMATTER_HXX +#define OOX_DRAWINGML_CHART_OBJECTFORMATTER_HXX + +#include "oox/helper/propertyset.hxx" +#include "oox/drawingml/drawingmltypes.hxx" +#include "oox/drawingml/chart/modelbase.hxx" + +namespace com { namespace sun { namespace star { + namespace chart2 { class XChartDocument; } +} } } + +namespace oox { namespace 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 ::com::sun::star::uno::Reference< ::com::sun::star::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. */ + void convertTextRotation( + PropertySet& rPropSet, + const ModelRef< TextBody >& rxTextProp, + bool bSupportsStacked ); + + /** Sets number format properties to the passed property set. */ + void convertNumberFormat( + PropertySet& rPropSet, + const NumberFormat& rNumberFormat, + bool bPercentFormat = false ); + + /** Sets automatic fill properties to the passed property set. */ + void convertAutomaticFill( + PropertySet& rPropSet, + ObjectType eObjType, + sal_Int32 nSeriesIdx = -1 ); + + /** Returns true, if the passed shape properties have automatic fill mode. */ + static bool isAutomaticFill( const ModelRef< Shape >& rxShapeProp ); + +private: + ::boost::shared_ptr< ObjectFormatterData > mxData; +}; + +// ============================================================================ + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/chart/plotareacontext.hxx b/include/oox/drawingml/chart/plotareacontext.hxx new file mode 100644 index 000000000000..d9966a8d8bf4 --- /dev/null +++ b/include/oox/drawingml/chart/plotareacontext.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 OOX_DRAWINGML_CHART_PLOTAREACONTEXT_HXX +#define OOX_DRAWINGML_CHART_PLOTAREACONTEXT_HXX + +#include "oox/drawingml/chart/chartcontextbase.hxx" + +namespace oox { +namespace drawingml { +namespace chart { + +// ============================================================================ + +struct View3DModel; + +/** Handler for a chart plot area context (c:plotArea element). + */ +class View3DContext : public ContextBase< View3DModel > +{ +public: + explicit View3DContext( ::oox::core::ContextHandler2Helper& rParent, View3DModel& rModel ); + virtual ~View3DContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +struct WallFloorModel; + +/** Handler for a chart wall/floor context (c:backWall, c:floor, c:sideWall + elements). + */ +class WallFloorContext : public ContextBase< WallFloorModel > +{ +public: + explicit WallFloorContext( ::oox::core::ContextHandler2Helper& rParent, WallFloorModel& rModel ); + virtual ~WallFloorContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +struct PlotAreaModel; + +/** Handler for a chart plot area context (c:plotArea element). + */ +class PlotAreaContext : public ContextBase< PlotAreaModel > +{ +public: + explicit PlotAreaContext( ::oox::core::ContextHandler2Helper& rParent, PlotAreaModel& rModel ); + virtual ~PlotAreaContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/chart/plotareaconverter.hxx b/include/oox/drawingml/chart/plotareaconverter.hxx new file mode 100644 index 000000000000..6796ffbd6a1c --- /dev/null +++ b/include/oox/drawingml/chart/plotareaconverter.hxx @@ -0,0 +1,103 @@ +/* -*- 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 OOX_DRAWINGML_CHART_PLOTAREACONVERTER_HXX +#define OOX_DRAWINGML_CHART_PLOTAREACONVERTER_HXX + +#include "oox/drawingml/chart/converterbase.hxx" + +namespace com { namespace sun { namespace star { + namespace chart2 { class XDiagram; } +} } } + +namespace oox { +namespace drawingml { +namespace chart { + +// ============================================================================ + +struct View3DModel; +class TypeGroupConverter; + +class View3DConverter : public ConverterBase< View3DModel > +{ +public: + explicit View3DConverter( const ConverterRoot& rParent, View3DModel& rModel ); + virtual ~View3DConverter(); + + /** Converts the OOXML plot area model to a chart2 diagram. */ + void convertFromModel( + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& rxDiagram, + TypeGroupConverter& rTypeGroup ); +}; + +// ============================================================================ + +struct WallFloorModel; + +class WallFloorConverter : public ConverterBase< WallFloorModel > +{ +public: + explicit WallFloorConverter( const ConverterRoot& rParent, WallFloorModel& rModel ); + virtual ~WallFloorConverter(); + + /** Converts the OOXML wall/floor model to a chart2 diagram. */ + void convertFromModel( + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& rxDiagram, + ObjectType eObjType ); +}; + +// ============================================================================ + +struct PlotAreaModel; + +class PlotAreaConverter : public ConverterBase< PlotAreaModel > +{ +public: + explicit PlotAreaConverter( const ConverterRoot& rParent, PlotAreaModel& rModel ); + virtual ~PlotAreaConverter(); + + /** 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. */ + inline const OUString& getAutomaticTitle() const { return maAutoTitle; } + /** Returns true, if the chart is three-dimensional. */ + inline bool is3dChart() const { return mb3dChart; } + /** Returns true, if chart type supports wall and floor format in 3D mode. */ + inline 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/include/oox/drawingml/chart/plotareamodel.hxx b/include/oox/drawingml/chart/plotareamodel.hxx new file mode 100644 index 000000000000..2afd6ccdd1da --- /dev/null +++ b/include/oox/drawingml/chart/plotareamodel.hxx @@ -0,0 +1,87 @@ +/* -*- 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 OOX_DRAWINGML_CHART_PLOTAREAMODEL_HXX +#define OOX_DRAWINGML_CHART_PLOTAREAMODEL_HXX + +#include "oox/drawingml/shape.hxx" +#include "oox/drawingml/chart/axismodel.hxx" +#include "oox/drawingml/chart/seriesmodel.hxx" +#include "oox/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(); + ~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 PlotAreaModel +{ + typedef ModelVector< TypeGroupModel > TypeGroupVector; + typedef ModelVector< AxisModel > AxisVector; + typedef ModelRef< Shape > ShapeRef; + typedef ModelRef< LayoutModel > LayoutRef; + + 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. + + explicit PlotAreaModel(); + ~PlotAreaModel(); +}; + +// ============================================================================ + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/chart/seriescontext.hxx b/include/oox/drawingml/chart/seriescontext.hxx new file mode 100644 index 000000000000..e31156dd2796 --- /dev/null +++ b/include/oox/drawingml/chart/seriescontext.hxx @@ -0,0 +1,266 @@ +/* -*- 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 OOX_DRAWINGML_CHART_SERIESCONTEXT_HXX +#define OOX_DRAWINGML_CHART_SERIESCONTEXT_HXX + +#include "oox/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 : public ContextBase< DataLabelModel > +{ +public: + explicit DataLabelContext( ::oox::core::ContextHandler2Helper& rParent, DataLabelModel& rModel ); + virtual ~DataLabelContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); + virtual void onCharacters( const OUString& rChars ); +}; + +// ============================================================================ + +struct DataLabelsModel; + +/** Handler for a chart data point label context (c:dLbl element). + */ +class DataLabelsContext : public ContextBase< DataLabelsModel > +{ +public: + explicit DataLabelsContext( ::oox::core::ContextHandler2Helper& rParent, DataLabelsModel& rModel ); + virtual ~DataLabelsContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); + virtual void onCharacters( const OUString& rChars ); +}; + +// ============================================================================ + +struct PictureOptionsModel; + +/** Handler for fill bitmap settings (c:pictureOptions element). + */ +class PictureOptionsContext : public ContextBase< PictureOptionsModel > +{ +public: + explicit PictureOptionsContext( ::oox::core::ContextHandler2Helper& rParent, PictureOptionsModel& rModel ); + virtual ~PictureOptionsContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +struct ErrorBarModel; + +/** Handler for a series error bar context (c:errBars element). + */ +class ErrorBarContext : public ContextBase< ErrorBarModel > +{ +public: + explicit ErrorBarContext( ::oox::core::ContextHandler2Helper& rParent, ErrorBarModel& rModel ); + virtual ~ErrorBarContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +struct TrendlineLabelModel; + +/** Handler for a series trendline label context (c:trendlineLbl element). + */ +class TrendlineLabelContext : public ContextBase< TrendlineLabelModel > +{ +public: + explicit TrendlineLabelContext( ::oox::core::ContextHandler2Helper& rParent, TrendlineLabelModel& rModel ); + virtual ~TrendlineLabelContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +struct TrendlineModel; + +/** Handler for a series trendline context (c:trendline element). + */ +class TrendlineContext : public ContextBase< TrendlineModel > +{ +public: + explicit TrendlineContext( ::oox::core::ContextHandler2Helper& rParent, TrendlineModel& rModel ); + virtual ~TrendlineContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); + virtual void onCharacters( const OUString& rChars ); +}; + +// ============================================================================ + +struct DataPointModel; + +/** Handler for a chart data point context (c:dPt element). + */ +class DataPointContext : public ContextBase< DataPointModel > +{ +public: + explicit DataPointContext( ::oox::core::ContextHandler2Helper& rParent, DataPointModel& rModel ); + virtual ~DataPointContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +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(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +/** Handler for a data series context for area chart types (c:ser element). + */ +class AreaSeriesContext : public SeriesContextBase +{ +public: + explicit AreaSeriesContext( ::oox::core::ContextHandler2Helper& rParent, SeriesModel& rModel ); + virtual ~AreaSeriesContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +/** Handler for a data series context for bar chart types (c:ser element). + */ +class BarSeriesContext : public SeriesContextBase +{ +public: + explicit BarSeriesContext( ::oox::core::ContextHandler2Helper& rParent, SeriesModel& rModel ); + virtual ~BarSeriesContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +/** Handler for a data series context for bubble chart types (c:ser element). + */ +class BubbleSeriesContext : public SeriesContextBase +{ +public: + explicit BubbleSeriesContext( ::oox::core::ContextHandler2Helper& rParent, SeriesModel& rModel ); + virtual ~BubbleSeriesContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +/** Handler for a data series context for line and stock chart types (c:ser + element). + */ +class LineSeriesContext : public SeriesContextBase +{ +public: + explicit LineSeriesContext( ::oox::core::ContextHandler2Helper& rParent, SeriesModel& rModel ); + virtual ~LineSeriesContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +/** Handler for a data series context for pie and doughnut chart types (c:ser + element). + */ +class PieSeriesContext : public SeriesContextBase +{ +public: + explicit PieSeriesContext( ::oox::core::ContextHandler2Helper& rParent, SeriesModel& rModel ); + virtual ~PieSeriesContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +/** Handler for a data series context for radar chart types (c:ser element). + */ +class RadarSeriesContext : public SeriesContextBase +{ +public: + explicit RadarSeriesContext( ::oox::core::ContextHandler2Helper& rParent, SeriesModel& rModel ); + virtual ~RadarSeriesContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +/** Handler for a data series context for scatter chart types (c:ser element). + */ +class ScatterSeriesContext : public SeriesContextBase +{ +public: + explicit ScatterSeriesContext( ::oox::core::ContextHandler2Helper& rParent, SeriesModel& rModel ); + virtual ~ScatterSeriesContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +/** Handler for a data series context for scatter chart types (c:ser element). + */ +class SurfaceSeriesContext : public SeriesContextBase +{ +public: + explicit SurfaceSeriesContext( ::oox::core::ContextHandler2Helper& rParent, SeriesModel& rModel ); + virtual ~SurfaceSeriesContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/chart/seriesconverter.hxx b/include/oox/drawingml/chart/seriesconverter.hxx new file mode 100644 index 000000000000..073073c5bbe7 --- /dev/null +++ b/include/oox/drawingml/chart/seriesconverter.hxx @@ -0,0 +1,167 @@ +/* -*- 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 OOX_DRAWINGML_CHART_SERIESCONVERTER_HXX +#define OOX_DRAWINGML_CHART_SERIESCONVERTER_HXX + +#include "oox/drawingml/chart/converterbase.hxx" +#include "oox/drawingml/chart/seriesmodel.hxx" + +namespace com { namespace sun { namespace star { + namespace chart2 { class XDataSeries; } + namespace chart2 { namespace 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 : public ConverterBase< DataLabelModel > +{ +public: + explicit DataLabelConverter( const ConverterRoot& rParent, DataLabelModel& rModel ); + virtual ~DataLabelConverter(); + + /** Converts OOXML data label settings for the passed data point. */ + void convertFromModel( + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries >& rxDataSeries, + const TypeGroupConverter& rTypeGroup ); + + /** Conversion helper for data series and data points. */ + static void convertLabelFormatting( + PropertySet& rPropSet, + ObjectFormatter& rFormatter, + const DataLabelModelBase& rDataLabel, + const TypeGroupConverter& rTypeGroup, + bool bDataSeriesLabel ); +}; + +// ============================================================================ + +class DataLabelsConverter : public ConverterBase< DataLabelsModel > +{ +public: + explicit DataLabelsConverter( const ConverterRoot& rParent, DataLabelsModel& rModel ); + virtual ~DataLabelsConverter(); + + /** Converts OOXML data label settings for the passed data series. */ + void convertFromModel( + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries >& rxDataSeries, + const TypeGroupConverter& rTypeGroup ); +}; + +// ============================================================================ + +class ErrorBarConverter : public ConverterBase< ErrorBarModel > +{ +public: + explicit ErrorBarConverter( const ConverterRoot& rParent, ErrorBarModel& rModel ); + virtual ~ErrorBarConverter(); + + /** Converts an OOXML errorbar and inserts it into the passed data series. */ + void convertFromModel( + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries >& rxDataSeries ); + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > + createLabeledDataSequence( ErrorBarModel::SourceType eSourceType ); +}; + +// ============================================================================ + +class TrendlineLabelConverter : public ConverterBase< TrendlineLabelModel > +{ +public: + explicit TrendlineLabelConverter( const ConverterRoot& rParent, TrendlineLabelModel& rModel ); + virtual ~TrendlineLabelConverter(); + + /** Converts the OOXML trendline label. */ + void convertFromModel( PropertySet& rPropSet ); +}; + +// ============================================================================ + +class TrendlineConverter : public ConverterBase< TrendlineModel > +{ +public: + explicit TrendlineConverter( const ConverterRoot& rParent, TrendlineModel& rModel ); + virtual ~TrendlineConverter(); + + /** Converts an OOXML trendline and inserts it into the passed data series. */ + void convertFromModel( + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries >& rxDataSeries ); +}; + +// ============================================================================ + +class DataPointConverter : public ConverterBase< DataPointModel > +{ +public: + explicit DataPointConverter( const ConverterRoot& rParent, DataPointModel& rModel ); + virtual ~DataPointConverter(); + + /** Converts settings for a data point in the passed series. */ + void convertFromModel( + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries >& rxDataSeries, + const TypeGroupConverter& rTypeGroup, + const SeriesModel& rSeries ); +}; + +// ============================================================================ + +class SeriesConverter : public ConverterBase< SeriesModel > +{ +public: + explicit SeriesConverter( const ConverterRoot& rParent, SeriesModel& rModel ); + virtual ~SeriesConverter(); + + /** Creates a labeled data sequence object from category data link. */ + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > + createCategorySequence( const OUString& rRole ); + /** Creates a labeled data sequence object from value data link. */ + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > + createValueSequence( const OUString& rRole ); + /** Creates a data series object with initialized source links. */ + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > + createDataSeries( const TypeGroupConverter& rTypeGroup, bool bVaryColorsByPoint ); + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::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/include/oox/drawingml/chart/seriesmodel.hxx b/include/oox/drawingml/chart/seriesmodel.hxx new file mode 100644 index 000000000000..998065f7f8ad --- /dev/null +++ b/include/oox/drawingml/chart/seriesmodel.hxx @@ -0,0 +1,237 @@ +/* -*- 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 OOX_DRAWINGML_CHART_SERIESMODEL_HXX +#define OOX_DRAWINGML_CHART_SERIESMODEL_HXX + +#include "oox/drawingml/chart/datasourcemodel.hxx" +#include "oox/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(); + ~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(); + ~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(); + ~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(); + ~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(); + ~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(); + ~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(); + ~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(); + ~SeriesModel(); +}; + +// ============================================================================ + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/chart/titlecontext.hxx b/include/oox/drawingml/chart/titlecontext.hxx new file mode 100644 index 000000000000..b00a9ed45b6d --- /dev/null +++ b/include/oox/drawingml/chart/titlecontext.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 OOX_DRAWINGML_CHART_TITLECONTEXT_HXX +#define OOX_DRAWINGML_CHART_TITLECONTEXT_HXX + +#include "oox/drawingml/chart/chartcontextbase.hxx" + +namespace oox { +namespace drawingml { +namespace chart { + +// ============================================================================ + +struct TextModel; + +/** Handler for a chart text context (c:tx element). + */ +class TextContext : public ContextBase< TextModel > +{ +public: + explicit TextContext( ::oox::core::ContextHandler2Helper& rParent, TextModel& rModel ); + virtual ~TextContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); + virtual void onCharacters( const OUString& rChars ); +}; + +// ============================================================================ + +struct TitleModel; + +/** Handler for a chart title context (c:title element). + */ +class TitleContext : public ContextBase< TitleModel > +{ +public: + explicit TitleContext( ::oox::core::ContextHandler2Helper& rParent, TitleModel& rModel ); + virtual ~TitleContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +struct LegendModel; + +/** Handler for a chart legend context (c:legend element). + */ +class LegendContext : public ContextBase< LegendModel > +{ +public: + explicit LegendContext( ::oox::core::ContextHandler2Helper& rParent, LegendModel& rModel ); + virtual ~LegendContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/chart/titleconverter.hxx b/include/oox/drawingml/chart/titleconverter.hxx new file mode 100644 index 000000000000..ad3694568efe --- /dev/null +++ b/include/oox/drawingml/chart/titleconverter.hxx @@ -0,0 +1,106 @@ +/* -*- 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 OOX_DRAWINGML_CHART_TITLECONVERTER_HXX +#define OOX_DRAWINGML_CHART_TITLECONVERTER_HXX + +#include "oox/drawingml/chart/converterbase.hxx" + +namespace com { namespace sun { namespace star { + namespace chart2 { class XDiagram; } + namespace chart2 { class XFormattedString; } + namespace chart2 { class XTitled; } + namespace chart2 { namespace data { class XDataSequence; } } +} } } + +namespace oox { namespace drawingml { struct TextCharacterProperties; } } + +namespace oox { +namespace drawingml { +namespace chart { + +// ============================================================================ + +struct TextModel; + +class TextConverter : public ConverterBase< TextModel > +{ +public: + explicit TextConverter( const ConverterRoot& rParent, TextModel& rModel ); + virtual ~TextConverter(); + + /** Creates a data sequence object from the contained text data. */ + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence > + createDataSequence( const OUString& rRole ); + /** Creates a sequence of formatted string objects. */ + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XFormattedString > > + createStringSequence( + const OUString& rDefaultText, + const ModelRef< TextBody >& rxTextProp, + ObjectType eObjType ); + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XFormattedString > + appendFormattedString( + ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XFormattedString > >& orStringVec, + const OUString& rString, + bool bAddNewLine ) const; +}; + +// ============================================================================ + +struct TitleModel; + +class TitleConverter : public ConverterBase< TitleModel > +{ +public: + explicit TitleConverter( const ConverterRoot& rParent, TitleModel& rModel ); + virtual ~TitleConverter(); + + /** Creates a title text object and attaches it at the passed interface. */ + void convertFromModel( + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTitled >& rxTitled, + const OUString& rAutoTitle, ObjectType eObjType, + sal_Int32 nMainIdx = -1, sal_Int32 nSubIdx = -1 ); +}; + +// ============================================================================ + +struct LegendModel; + +class LegendConverter : public ConverterBase< LegendModel > +{ +public: + explicit LegendConverter( const ConverterRoot& rParent, LegendModel& rModel ); + virtual ~LegendConverter(); + + /** Creates a legend object and attaches it at the passed diagram. */ + void convertFromModel( + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& rxDiagram ); +}; + +// ============================================================================ + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/chart/titlemodel.hxx b/include/oox/drawingml/chart/titlemodel.hxx new file mode 100644 index 000000000000..f365d0b6ec89 --- /dev/null +++ b/include/oox/drawingml/chart/titlemodel.hxx @@ -0,0 +1,89 @@ +/* -*- 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 OOX_DRAWINGML_CHART_TITLEMODEL_HXX +#define 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. + + explicit TitleModel(); + ~TitleModel(); +}; + +// ============================================================================ + +struct LegendModel +{ + typedef ModelRef< Shape > ShapeRef; + typedef ModelRef< TextBody > TextBodyRef; + typedef ModelRef< LayoutModel > LayoutRef; + + 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/include/oox/drawingml/chart/typegroupcontext.hxx b/include/oox/drawingml/chart/typegroupcontext.hxx new file mode 100644 index 000000000000..52667817ff0d --- /dev/null +++ b/include/oox/drawingml/chart/typegroupcontext.hxx @@ -0,0 +1,164 @@ +/* -*- 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 OOX_DRAWINGML_CHART_TYPEGROUPCONTEXT_HXX +#define OOX_DRAWINGML_CHART_TYPEGROUPCONTEXT_HXX + +#include "oox/drawingml/chart/chartcontextbase.hxx" + +namespace oox { +namespace drawingml { +namespace chart { + +// ============================================================================ + +struct UpDownBarsModel; + +/** Handler for an up/down bars context (c:upDownBars element). + */ +class UpDownBarsContext : public ContextBase< UpDownBarsModel > +{ +public: + explicit UpDownBarsContext( ::oox::core::ContextHandler2Helper& rParent, UpDownBarsModel& rModel ); + virtual ~UpDownBarsContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +struct TypeGroupModel; +typedef ContextBase< TypeGroupModel > TypeGroupContextBase; + +// ============================================================================ + +/** Handler for area type group contexts (c:area3DChart, c:areaChart elements). + */ +class AreaTypeGroupContext : public TypeGroupContextBase +{ +public: + explicit AreaTypeGroupContext( ::oox::core::ContextHandler2Helper& rParent, TypeGroupModel& rModel ); + virtual ~AreaTypeGroupContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +/** Handler for bar type group contexts (c:bar3DChart, c:barChart elements). + */ +class BarTypeGroupContext : public TypeGroupContextBase +{ +public: + explicit BarTypeGroupContext( ::oox::core::ContextHandler2Helper& rParent, TypeGroupModel& rModel ); + virtual ~BarTypeGroupContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +/** Handler for bubble type group context (c:bubbleChart element). + */ +class BubbleTypeGroupContext : public TypeGroupContextBase +{ +public: + explicit BubbleTypeGroupContext( ::oox::core::ContextHandler2Helper& rParent, TypeGroupModel& rModel ); + virtual ~BubbleTypeGroupContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +/** Handler for line type group contexts (c:line3DChart, c:lineChart, + c:stockChart elements). + */ +class LineTypeGroupContext : public TypeGroupContextBase +{ +public: + explicit LineTypeGroupContext( ::oox::core::ContextHandler2Helper& rParent, TypeGroupModel& rModel ); + virtual ~LineTypeGroupContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +/** Handler for pie type group contexts (c:doughnutChart, c:ofPieChart, + c:pie3DChart, c:pieChart elements). + */ +class PieTypeGroupContext : public TypeGroupContextBase +{ +public: + explicit PieTypeGroupContext( ::oox::core::ContextHandler2Helper& rParent, TypeGroupModel& rModel ); + virtual ~PieTypeGroupContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +/** Handler for radar type group context (c:radarChart element). + */ +class RadarTypeGroupContext : public TypeGroupContextBase +{ +public: + explicit RadarTypeGroupContext( ::oox::core::ContextHandler2Helper& rParent, TypeGroupModel& rModel ); + virtual ~RadarTypeGroupContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +/** Handler for scatter type group context (c:scatterChart element). + */ +class ScatterTypeGroupContext : public TypeGroupContextBase +{ +public: + explicit ScatterTypeGroupContext( ::oox::core::ContextHandler2Helper& rParent, TypeGroupModel& rModel ); + virtual ~ScatterTypeGroupContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +/** Handler for surface type group contexts (c:surface3DChart, c:surfaceChart + elements). + */ +class SurfaceTypeGroupContext : public TypeGroupContextBase +{ +public: + explicit SurfaceTypeGroupContext( ::oox::core::ContextHandler2Helper& rParent, TypeGroupModel& rModel ); + virtual ~SurfaceTypeGroupContext(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; + +// ============================================================================ + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/chart/typegroupconverter.hxx b/include/oox/drawingml/chart/typegroupconverter.hxx new file mode 100644 index 000000000000..dfce05065c18 --- /dev/null +++ b/include/oox/drawingml/chart/typegroupconverter.hxx @@ -0,0 +1,198 @@ +/* -*- 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 OOX_DRAWINGML_CHART_TYPEGROUPCONVERTER_HXX +#define OOX_DRAWINGML_CHART_TYPEGROUPCONVERTER_HXX + +#include "oox/drawingml/chart/converterbase.hxx" + +namespace com { namespace sun { namespace star { + namespace chart2 { class XChartType; } + namespace chart2 { class XCoordinateSystem; } + namespace chart2 { class XDataSeries; } + namespace chart2 { class XDiagram; } + namespace chart2 { namespace 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 sal_Char* mpcServiceName; /// Service name of the type. + VarPointMode meVarPointMode; /// Mode for varying point colors. + sal_Int32 mnDefLabelPos; /// Default data label position (API constant). + bool mbCombinable2d; /// True = types can be combined in one axes set. + bool mbSupports3d; /// True = 3D type allowed, false = only 2D type. + 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 mbReverseSeries; /// True = insert unstacked series in reverse order. + bool mbTicksBetweenCateg; /// True = X axis ticks between categories. + bool mbPictureOptions; /// True = bitmaps support options from c:pictureOptions. +}; + +// ============================================================================ + +struct UpDownBarsModel; + +class UpDownBarsConverter : public ConverterBase< UpDownBarsModel > +{ +public: + explicit UpDownBarsConverter( const ConverterRoot& rParent, UpDownBarsModel& rModel ); + virtual ~UpDownBarsConverter(); + + /** Converts the OOXML up/down bars. */ + void convertFromModel( + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& rxChartType ); +}; + +// ============================================================================ + +struct TypeGroupModel; +struct View3DModel; + +class TypeGroupConverter : public ConverterBase< TypeGroupModel > +{ +public: + explicit TypeGroupConverter( const ConverterRoot& rParent, TypeGroupModel& rModel ); + virtual ~TypeGroupConverter(); + + /** Returns the type info struct that describes this chart type group. */ + inline 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; + /** 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 true, if this chart type has to reverse its series order. */ + bool isReverseSeries() 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. */ + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem > + createCoordinateSystem(); + /** Creates a labeled data sequence object for axis categories. */ + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > + createCategorySequence(); + + /** Converts the OOXML type group model into a chart2 coordinate system. */ + void convertFromModel( + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& rxDiagram, + const ::com::sun::star::uno::Reference< ::com::sun::star::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; + /** 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 ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& rxChartType, + const ::com::sun::star::uno::Reference< ::com::sun::star::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/include/oox/drawingml/chart/typegroupmodel.hxx b/include/oox/drawingml/chart/typegroupmodel.hxx new file mode 100644 index 000000000000..1949a3ee892e --- /dev/null +++ b/include/oox/drawingml/chart/typegroupmodel.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 OOX_DRAWINGML_CHART_TYPEGROUPMODEL_HXX +#define OOX_DRAWINGML_CHART_TYPEGROUPMODEL_HXX + +#include "oox/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 ::std::vector< sal_Int32 > AxisIdVector; + typedef ModelRef< DataLabelsModel > DataLabelsRef; + typedef ModelRef< UpDownBarsModel > UpDownBarsRef; + typedef ModelRef< Shape > ShapeRef; + + SeriesVector maSeries; /// Series attached to this chart type group. + AxisIdVector 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 ); + ~TypeGroupModel(); +}; + +// ============================================================================ + +} // namespace chart +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/clrscheme.hxx b/include/oox/drawingml/clrscheme.hxx new file mode 100644 index 000000000000..7c4f0106cb43 --- /dev/null +++ b/include/oox/drawingml/clrscheme.hxx @@ -0,0 +1,62 @@ +/* -*- 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 OOX_DRAWINGML_CLRSCHEME_HXX +#define OOX_DRAWINGML_CLRSCHEME_HXX + +#include <boost/shared_ptr.hpp> +#include <map> +#include <vector> +#include "oox/drawingml/color.hxx" +#include "oox/dllapi.h" + +namespace oox { namespace drawingml { + +class ClrMap +{ + std::map < sal_Int32, sal_Int32 > maClrMap; + +public: + + sal_Bool getColorMap( sal_Int32& nClrToken ); + void setColorMap( sal_Int32 nClrToken, sal_Int32 nMappedClrToken ); +}; + +typedef boost::shared_ptr< ClrMap > ClrMapPtr; + +class OOX_DLLPUBLIC ClrScheme +{ + std::map < sal_Int32, sal_Int32 > maClrScheme; + +public: + + ClrScheme(); + ~ClrScheme(); + + sal_Bool getColor( sal_Int32 nSchemeClrToken, sal_Int32& rColor ) const; + void setColor( sal_Int32 nSchemeClrToken, sal_Int32 nColor ); +}; + +typedef boost::shared_ptr< ClrScheme > ClrSchemePtr; + +} } + +#endif // OOX_DRAWINGML_CLRSCHEME_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/clrschemecontext.hxx b/include/oox/drawingml/clrschemecontext.hxx new file mode 100644 index 000000000000..466b852a37cf --- /dev/null +++ b/include/oox/drawingml/clrschemecontext.hxx @@ -0,0 +1,62 @@ +/* -*- 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 OOX_DRAWINGML_CLRSCHEMECONTEXT_HXX +#define OOX_DRAWINGML_CLRSCHEMECONTEXT_HXX + +#include "oox/core/contexthandler.hxx" +#include "oox/drawingml/clrscheme.hxx" +#include "oox/drawingml/color.hxx" +#include "oox/drawingml/colorchoicecontext.hxx" + +namespace oox { namespace drawingml { + +class clrMapContext : public oox::core::ContextHandler +{ +public: + clrMapContext( ::oox::core::ContextHandler& rParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, ClrMap& rClrMap ); +}; + +class clrSchemeColorContext : private Color, public ColorContext +{ +public: + clrSchemeColorContext( ::oox::core::ContextHandler& rParent, ClrScheme& rClrScheme, sal_Int32 nColorToken ); + virtual ~clrSchemeColorContext(); + +private: + ClrScheme& mrClrScheme; + sal_Int32 mnColorToken; +}; + +class clrSchemeContext : public oox::core::ContextHandler +{ +public: + clrSchemeContext( ::oox::core::ContextHandler& rParent, ClrScheme& rClrScheme ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +private: + ClrScheme& mrClrScheme; +}; + +} } + +#endif // OOX_DRAWINGML_CLRSCHEMECONTEXT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/color.hxx b/include/oox/drawingml/color.hxx new file mode 100644 index 000000000000..b58f0b8ae5b3 --- /dev/null +++ b/include/oox/drawingml/color.hxx @@ -0,0 +1,144 @@ +/* -*- 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 OOX_DRAWINGML_COLOR_HXX +#define OOX_DRAWINGML_COLOR_HXX + +#include <vector> +#include <boost/shared_ptr.hpp> +#include <sal/types.h> +#include <rtl/instance.hxx> +#include <rtl/ustring.hxx> +#include "oox/helper/helper.hxx" +#include "oox/dllapi.h" + +namespace oox { class GraphicHelper; } + +namespace oox { +namespace drawingml { + +// ============================================================================ + +class OOX_DLLPUBLIC Color +{ +public: + Color(); + ~Color(); + + /** Returns the RGB value for the passed DrawingML color token, or nDefaultRgb on error. */ + static sal_Int32 getDmlPresetColor( sal_Int32 nToken, sal_Int32 nDefaultRgb ); + /** Returns the RGB value for the passed VML color token, or nDefaultRgb on error. */ + static sal_Int32 getVmlPresetColor( sal_Int32 nToken, sal_Int32 nDefaultRgb ); + + /** Sets the color to unused state. */ + void setUnused(); + /** Sets an RGB value (hexadecimal RRGGBB) from the a:srgbClr element. */ + void setSrgbClr( sal_Int32 nRgb ); + /** Sets the percentual RGB values from the a:scrgbClr element. */ + void setScrgbClr( sal_Int32 nR, sal_Int32 nG, sal_Int32 nB ); + /** Sets the HSL values from the a:hslClr element. */ + void setHslClr( sal_Int32 nHue, sal_Int32 nSat, sal_Int32 nLum ); + /** Sets a predefined color from the a:prstClr element. */ + void setPrstClr( sal_Int32 nToken ); + /** Sets a scheme color from the a:schemeClr element. */ + void setSchemeClr( sal_Int32 nToken ); + /** Sets a system color from the a:sysClr element. */ + void setSysClr( sal_Int32 nToken, sal_Int32 nLastRgb ); + /** Sets a palette color index. */ + void setPaletteClr( sal_Int32 nPaletteIdx ); + + /** Inserts the passed color transformation. */ + void addTransformation( sal_Int32 nElement, sal_Int32 nValue = -1 ); + /** Inserts Chart specific color tint (-1.0...0.0 = shade, 0.0...1.0 = tint). */ + void addChartTintTransformation( double fTint ); + /** Inserts Excel specific color tint (-1.0...0.0 = shade, 0.0...1.0 = tint). */ + void addExcelTintTransformation( double fTint ); + /** Removes all color transformations. */ + void clearTransformations(); + /** Removes transparence from the color. */ + void clearTransparence(); + + /** Overwrites this color with the passed color, if it is used. */ + inline void assignIfUsed( const Color& rColor ) { if( rColor.isUsed() ) *this = rColor; } + + /** Returns true, if the color is initialized. */ + bool isUsed() const { return meMode != COLOR_UNUSED; } + /** Returns true, if the color is a placeholder color in theme style lists. */ + bool isPlaceHolder() const { return meMode == COLOR_PH; } + /** Returns the final RGB color value. + @param nPhClr Actual color for the phClr placeholder color used in theme style lists. */ + sal_Int32 getColor( const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; + + /** Returns true, if the color is transparent. */ + bool hasTransparency() const; + /** Returns the transparency of the color (0 = opaque, 100 = full transparent). */ + sal_Int16 getTransparency() const; + +private: + /** Internal helper for getColor(). */ + void setResolvedRgb( sal_Int32 nRgb ) const; + + /** Converts the color components to RGB values. */ + void toRgb() const; + /** Converts the color components to CRGB values (gamma corrected percentage). */ + void toCrgb() const; + /** Converts the color components to HSL values. */ + void toHsl() const; + +private: + enum ColorMode + { + COLOR_UNUSED, /// Color is not used, or undefined. + COLOR_RGB, /// Absolute RGB (r/g/b: 0...255). + COLOR_CRGB, /// Relative RGB (r/g/b: 0...100000). + COLOR_HSL, /// HSL (hue: 0...21600000, sat/lum: 0...100000). + COLOR_SCHEME, /// Color from scheme. + COLOR_PALETTE, /// Color from application defined palette. + COLOR_SYSTEM, /// Color from system palette. + COLOR_PH, /// Placeholder color in theme style lists. + COLOR_FINAL /// Finalized RGB color. + }; + + struct Transformation + { + sal_Int32 mnToken; + sal_Int32 mnValue; + + explicit Transformation( sal_Int32 nToken, sal_Int32 nValue ) : mnToken( nToken ), mnValue( nValue ) {} + }; + typedef ::std::vector< Transformation > TransformVec; + + mutable ColorMode meMode; /// Current color mode. + mutable TransformVec maTransforms; /// Color transformations. + mutable sal_Int32 mnC1; /// Red, red%, hue, scheme token, palette index, system token, or final RGB. + mutable sal_Int32 mnC2; /// Green, green%, saturation, or system default RGB. + mutable sal_Int32 mnC3; /// Blue, blue%, or luminance. + sal_Int32 mnAlpha; /// Alpha value (color opacity). +}; + +typedef boost::shared_ptr< Color > ColorPtr; + +// ============================================================================ + +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/colorchoicecontext.hxx b/include/oox/drawingml/colorchoicecontext.hxx new file mode 100644 index 000000000000..aaacfd44d5b7 --- /dev/null +++ b/include/oox/drawingml/colorchoicecontext.hxx @@ -0,0 +1,80 @@ +/* -*- 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 OOX_DRAWINGML_COLORCHOICECONTEXT_HXX +#define OOX_DRAWINGML_COLORCHOICECONTEXT_HXX + +#include "oox/core/contexthandler.hxx" + +namespace oox { +namespace drawingml { + +class Color; + +// ============================================================================ + +/** Context handler for the different color value elements (a:scrgbClr, + a:srgbClr, a:hslClr, a:sysClr, a:schemeClr, a:prstClr). */ +class ColorValueContext : public ::oox::core::ContextHandler +{ +public: + explicit ColorValueContext( ::oox::core::ContextHandler& rParent, Color& rColor ); + + virtual void SAL_CALL startFastElement( + sal_Int32 nElement, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) + throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext( + sal_Int32 nElement, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) + throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +private: + Color& mrColor; +}; + +// ============================================================================ + +/** Context handler for elements that *contain* a color value element + (a:scrgbClr, a:srgbClr, a:hslClr, a:sysClr, a:schemeClr, a:prstClr). */ +class ColorContext : public ::oox::core::ContextHandler +{ +public: + explicit ColorContext( ::oox::core::ContextHandler& rParent, Color& rColor ); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext( + sal_Int32 nElement, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) + throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +private: + Color& mrColor; +}; + +// ============================================================================ + +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/connectorshapecontext.hxx b/include/oox/drawingml/connectorshapecontext.hxx new file mode 100644 index 000000000000..48a03ae317af --- /dev/null +++ b/include/oox/drawingml/connectorshapecontext.hxx @@ -0,0 +1,41 @@ +/* -*- 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 OOX_DRAWINGML_CONNECTORSHAPECONTEXT_HXX +#define OOX_DRAWINGML_CONNECTORSHAPECONTEXT_HXX + +#include "oox/drawingml/shape.hxx" +#include "oox/drawingml/shapecontext.hxx" +#include "oox/dllapi.h" + +namespace oox { namespace drawingml { + +class OOX_DLLPUBLIC ConnectorShapeContext : public ShapeContext +{ +public: + ConnectorShapeContext( ::oox::core::ContextHandler& rParent, ShapePtr pMasterShapePtr, ShapePtr pGroupShapePtr ); + virtual ~ConnectorShapeContext(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); +}; + +} } + +#endif // OOX_DRAWINGML_CONNECTORSHAPECONTEXT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/customshapegeometry.hxx b/include/oox/drawingml/customshapegeometry.hxx new file mode 100644 index 000000000000..3920881f123a --- /dev/null +++ b/include/oox/drawingml/customshapegeometry.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 OOX_DRAWINGML_CUSTOMSHAPEGEOMETRY_HXX +#define OOX_DRAWINGML_CUSTOMSHAPEGEOMETRY_HXX + +#include <com/sun/star/beans/XPropertySet.hpp> +#include "oox/helper/propertymap.hxx" +#include "oox/core/contexthandler.hxx" +#include "oox/drawingml/shape.hxx" + +namespace oox { namespace drawingml { + + +// --------------------------------------------------------------------- +// CT_CustomGeometry2D +class CustomShapeGeometryContext : public ::oox::core::ContextHandler +{ +public: + CustomShapeGeometryContext( ::oox::core::ContextHandler& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, CustomShapeProperties& rCustomShapeProperties ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +private: + CustomShapeProperties& mrCustomShapeProperties; +}; + +// --------------------------------------------------------------------- +// CT_PresetGeometry2D +class PresetShapeGeometryContext : public ::oox::core::ContextHandler +{ +public: + PresetShapeGeometryContext( ::oox::core::ContextHandler& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, CustomShapeProperties& rCustomShapeProperties ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +private: + CustomShapeProperties& mrCustomShapeProperties; +}; + +// --------------------------------------------------------------------- +// CT_PresetTextShape +class PresetTextShapeContext : public ::oox::core::ContextHandler +{ +public: + PresetTextShapeContext( ::oox::core::ContextHandler& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, CustomShapeProperties& rCustomShapeProperties ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +private: + CustomShapeProperties& mrCustomShapeProperties; +}; + +} } + +#endif // OOX_DRAWINGML_CUSTOMSHAPEGEOMETRY_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/customshapeproperties.hxx b/include/oox/drawingml/customshapeproperties.hxx new file mode 100644 index 000000000000..e44f20db95e2 --- /dev/null +++ b/include/oox/drawingml/customshapeproperties.hxx @@ -0,0 +1,189 @@ +/* -*- 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 OOX_DRAWINGML_CUSTOMSHAPEPROPERTIES_HXX +#define OOX_DRAWINGML_CUSTOMSHAPEPROPERTIES_HXX + +#include <boost/shared_ptr.hpp> +#include <boost/unordered_map.hpp> +#include <vector> +#include <map> +#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeGluePointType.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeTextPathMode.hpp> +#include <com/sun/star/beans/PropertyValues.hpp> +#include <com/sun/star/drawing/ProjectionMode.hpp> +#include <com/sun/star/drawing/XShape.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> +#include "oox/core/xmlfilterbase.hxx" +#include "oox/drawingml/color.hxx" +#include "oox/helper/helper.hxx" +#include "oox/helper/propertymap.hxx" +#include "oox/token/tokens.hxx" + +namespace oox { namespace drawingml { + +class CustomShapeProperties; + +typedef boost::shared_ptr< CustomShapeProperties > CustomShapePropertiesPtr; + +struct CustomShapeGuide +{ + OUString maName; + OUString maFormula; +}; + +struct AdjustHandle +{ + sal_Bool polar; + com::sun::star::drawing::EnhancedCustomShapeParameterPair + pos; + + // depending to the type (polar or not): + OptValue< OUString > gdRef1; // gdRefX or gdRefR + OptValue< com::sun::star::drawing::EnhancedCustomShapeParameter > + min1; // minX or minR + OptValue< com::sun::star::drawing::EnhancedCustomShapeParameter > + max1; // maxX or maxR + OptValue< OUString > gdRef2; // gdRefY or gdRefAng + OptValue< com::sun::star::drawing::EnhancedCustomShapeParameter > + min2; // minX or minAng + OptValue< com::sun::star::drawing::EnhancedCustomShapeParameter > + max2; // maxY or maxAng + + AdjustHandle( sal_Bool bPolar ) : polar( bPolar ) {}; +}; + +struct ConnectionSite +{ + com::sun::star::drawing::EnhancedCustomShapeParameterPair + pos; + com::sun::star::drawing::EnhancedCustomShapeParameter + ang; +}; + +struct GeomRect +{ + com::sun::star::drawing::EnhancedCustomShapeParameter l; + com::sun::star::drawing::EnhancedCustomShapeParameter t; + com::sun::star::drawing::EnhancedCustomShapeParameter r; + com::sun::star::drawing::EnhancedCustomShapeParameter b; +}; + +struct Path2D +{ + sal_Int64 w; + sal_Int64 h; + sal_Int32 fill; + sal_Bool stroke; + sal_Bool extrusionOk; + std::vector< com::sun::star::drawing::EnhancedCustomShapeParameterPair > parameter; + + Path2D() : w( 0 ), h( 0 ), fill( XML_norm ), stroke( sal_True ), extrusionOk( sal_True ) {}; +}; + + +class CustomShapeProvider { +protected: + struct ParameterPairData { + sal_uInt16 nFirstType; + sal_uInt16 nSecondType; + sal_uInt32 nFirstValue; + sal_uInt32 nSecondValue; + }; + static com::sun::star::uno::Any createStringSequence( size_t nStrings, const char **pStrings ); + static com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment > createSegmentSequence( size_t nElems, const sal_uInt16 *pValues ); + static com::sun::star::drawing::EnhancedCustomShapeParameterPair createParameterPair( const ParameterPairData *pData ); + static com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair > createParameterPairSequence( size_t nElems, const ParameterPairData *pData ); +public: + virtual ~CustomShapeProvider() {} + virtual PropertyMap getProperties() = 0; +}; + +class CustomShapeProperties +{ +public: + + CustomShapeProperties(); + virtual ~CustomShapeProperties(); + + void pushToPropSet( const ::oox::core::FilterBase& rFilterBase, + const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > & xPropSet, + const ::com::sun::star::uno::Reference < ::com::sun::star::drawing::XShape > & xShape); + + sal_Int32 getShapePresetType() const { return mnShapePresetType; } + OUString getShapePresetTypeName() const; + void setShapePresetType( sal_Int32 nShapePresetType ){ mnShapePresetType = nShapePresetType; }; + + std::vector< CustomShapeGuide >& getAdjustmentGuideList(){ return maAdjustmentGuideList; }; + std::vector< CustomShapeGuide >& getGuideList(){ return maGuideList; }; + std::vector< AdjustHandle >& getAdjustHandleList(){ return maAdjustHandleList; }; + std::vector< ConnectionSite >& getConnectionSiteList(){ return maConnectionSiteList; }; + OptValue< GeomRect >& getTextRect(){ return maTextRect; }; + std::vector< Path2D >& getPath2DList(){ return maPath2DList; }; + std::vector< com::sun::star::drawing::EnhancedCustomShapeSegment >& getSegments(){ return maSegments; }; + void setMirroredX( sal_Bool bMirroredX ) { mbMirroredX = bMirroredX; }; + void setMirroredY( sal_Bool bMirroredY ) { mbMirroredY = bMirroredY; }; + void setTextRotateAngle( sal_Int32 nAngle ) { mnTextRotateAngle = nAngle; }; + + static sal_Int32 SetCustomShapeGuideValue( std::vector< CustomShapeGuide >& rGuideList, const CustomShapeGuide& rGuide ); + static sal_Int32 GetCustomShapeGuideValue( const std::vector< CustomShapeGuide >& rGuideList, const OUString& rFormulaName ); + + sal_Int32 getArcNum() { return mnArcNum++; } + +private: + + sal_Int32 mnShapePresetType; + std::vector< CustomShapeGuide > maAdjustmentGuideList; + std::vector< CustomShapeGuide > maGuideList; + std::vector< AdjustHandle > maAdjustHandleList; + std::vector< ConnectionSite > maConnectionSiteList; + OptValue< GeomRect > maTextRect; + std::vector< Path2D > maPath2DList; + + std::vector< com::sun::star::drawing::EnhancedCustomShapeSegment > + maSegments; + sal_Bool mbMirroredX; + sal_Bool mbMirroredY; + sal_Int32 mnTextRotateAngle; + + typedef boost::unordered_map< sal_Int32, CustomShapeProvider * > PresetsMap; + + static PresetsMap maPresetsMap; + static void initializePresetsMap(); + static void initializePresetsMap1(); + static void initializePresetsMap2(); + static void initializePresetsMap3(); + static void initializePresetsMap4(); + static void initializePresetsMap5(); + static void initializePresetsMap6(); + + sal_Int32 mnArcNum; +}; + +} } + +#endif // OOX_DRAWINGML_CUSTOMSHAPEPROPERTIES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/diagram/diagram.hxx b/include/oox/drawingml/diagram/diagram.hxx new file mode 100644 index 000000000000..e37c1a44e42f --- /dev/null +++ b/include/oox/drawingml/diagram/diagram.hxx @@ -0,0 +1,58 @@ +/* -*- 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 OOX_DRAWINGML_DIAGRAM_HXX +#define OOX_DRAWINGML_DIAGRAM_HXX + +#include <rtl/ustring.hxx> +#include "oox/drawingml/shape.hxx" +#include "oox/core/xmlfilterbase.hxx" + +#include <com/sun/star/xml/dom/XDocument.hpp> + +namespace oox { namespace drawingml { + +/** load diagram data, and put resulting graphic into shape + + This method loads the diagram data fragments from the given paths, + generate and layout the shapes, and push it as children into the + referenced shape. + */ +void loadDiagram( ShapePtr& pShape, + core::XmlFilterBase& rFilter, + const OUString& rDataModelPath, + const OUString& rLayoutPath, + const OUString& rQStylePath, + const OUString& rColorStylePath ); + +void loadDiagram( const ShapePtr& pShape, + core::XmlFilterBase& rFilter, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::dom::XDocument>& rXDataModelDom, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::dom::XDocument>& rXLayoutDom, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::dom::XDocument>& rXQStyleDom, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::dom::XDocument>& rXColorStyleDom ); +} } + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/drawingmltypes.hxx b/include/oox/drawingml/drawingmltypes.hxx new file mode 100644 index 000000000000..5df664ee66a4 --- /dev/null +++ b/include/oox/drawingml/drawingmltypes.hxx @@ -0,0 +1,200 @@ +/* -*- 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 OOX_DRAWINGML_TYPES_HXX +#define OOX_DRAWINGML_TYPES_HXX + +#include <boost/shared_ptr.hpp> +#include <com/sun/star/style/TabAlign.hpp> +#include <com/sun/star/drawing/TextVerticalAdjust.hpp> +#include <com/sun/star/geometry/IntegerRectangle2D.hpp> +#include <com/sun/star/awt/Point.hpp> +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/xml/sax/XFastAttributeList.hpp> +#include "oox/helper/helper.hxx" + +namespace oox { +namespace drawingml { + +// ============================================================================ + +const sal_Int32 PER_PERCENT = 1000; +const sal_Int32 MAX_PERCENT = 100 * PER_PERCENT; + +const sal_Int32 PER_DEGREE = 60000; +const sal_Int32 MAX_DEGREE = 360 * PER_DEGREE; + +// ============================================================================ + +struct LineProperties; +typedef ::boost::shared_ptr< LineProperties > LinePropertiesPtr; + +struct FillProperties; +typedef ::boost::shared_ptr< FillProperties > FillPropertiesPtr; + +struct GraphicProperties; +typedef ::boost::shared_ptr< GraphicProperties > GraphicPropertiesPtr; + +struct Shape3DProperties; +typedef ::boost::shared_ptr< Shape3DProperties > Shape3DPropertiesPtr; + +struct TextCharacterProperties; +typedef ::boost::shared_ptr< TextCharacterProperties > TextCharacterPropertiesPtr; + +struct TextBodyProperties; +typedef ::boost::shared_ptr< TextBodyProperties > TextBodyPropertiesPtr; + +struct EffectProperties; +typedef ::boost::shared_ptr< EffectProperties > EffectPropertiesPtr; + +class TextBody; +typedef ::boost::shared_ptr< TextBody > TextBodyPtr; + +class Shape; +typedef ::boost::shared_ptr< Shape > ShapePtr; + +class Theme; +typedef ::boost::shared_ptr< Theme > ThemePtr; + +// --------------------------------------------------------------------------- + +namespace table { + +class TableProperties; +typedef ::boost::shared_ptr< TableProperties > TablePropertiesPtr; + +} // namespace table + +// ============================================================================ + +/** converts the attributes from an CT_TLPoint into an awt Point with 1/1000% */ +com::sun::star::awt::Point GetPointPercent( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs ); + + +/** converts the attributes from an CT_Size2D into an awt Size with 1/100th mm */ +com::sun::star::awt::Size GetSize2D( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes ); + +/** converts the attributes from a CT_RelativeRect to an IntegerRectangle2D */ +com::sun::star::geometry::IntegerRectangle2D GetRelativeRect( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes ); + +/** converts EMUs into 1/100th mmm */ +sal_Int32 GetCoordinate( sal_Int32 nValue ); + +/** converts an emu string into 1/100th mmm */ +sal_Int32 GetCoordinate( const OUString& sValue ); + +/** converts a ST_Percentage % string into 1/1000th of % */ +sal_Int32 GetPercent( const OUString& sValue ); + +/** Converts a ST_PositiveFixedPercentage to a float. 1.0 == 100% */ +double GetPositiveFixedPercentage( const OUString& sValue ); + +/** converts the ST_TextFontSize to point */ +float GetTextSize( const OUString& rValue ); + +/** converts the ST_TextSpacingPoint to 1/100mm */ +sal_Int32 GetTextSpacingPoint( const OUString& sValue ); +sal_Int32 GetTextSpacingPoint( const sal_Int32 nValue ); + +/** */ +::com::sun::star::style::TabAlign GetTabAlign( ::sal_Int32 aToken ); + +float GetFontHeight( sal_Int32 nHeight ); + +sal_Int16 GetFontUnderline( sal_Int32 nToken ); + +sal_Int16 GetFontStrikeout( sal_Int32 nToken ); + +sal_Int16 GetCaseMap( sal_Int32 nToken ); + +/** converts a paragraph align to a ParaAdjust */ +sal_Int16 GetParaAdjust( sal_Int32 nAlign ); + +// ============================================================================ + +// CT_IndexRange +struct IndexRange { + sal_Int32 start; + sal_Int32 end; +}; + +/** retrieve the content of CT_IndexRange */ +IndexRange GetIndexRange( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes ); + +// ============================================================================ + +const sal_Int32 EMU_PER_HMM = 360; /// 360 EMUs per 1/100 mm. + +/** Converts the passed 32-bit integer value from 1/100 mm to EMUs. */ +inline sal_Int64 convertHmmToEmu( sal_Int32 nValue ) +{ + return static_cast< sal_Int64 >( nValue ) * EMU_PER_HMM; +} + +/** Converts the passed 64-bit integer value from EMUs to 1/100 mm. */ +inline sal_Int32 convertEmuToHmm( sal_Int64 nValue ) +{ + return getLimitedValue< sal_Int32, sal_Int64 >( (nValue + EMU_PER_HMM / 2) / EMU_PER_HMM, SAL_MIN_INT32, SAL_MAX_INT32 ); +} + +// ============================================================================ + +/** A structure for a point with 64-bit interger components. */ +struct EmuPoint +{ + sal_Int64 X; + sal_Int64 Y; + + inline explicit EmuPoint() : X( 0 ), Y( 0 ) {} + inline explicit EmuPoint( sal_Int64 nX, sal_Int64 nY ) : X( nX ), Y( nY ) {} +}; + +// ============================================================================ + +/** A structure for a size with 64-bit interger components. */ +struct EmuSize +{ + sal_Int64 Width; + sal_Int64 Height; + + inline explicit EmuSize() : Width( 0 ), Height( 0 ) {} + inline explicit EmuSize( sal_Int64 nWidth, sal_Int64 nHeight ) : Width( nWidth ), Height( nHeight ) {} +}; + +// ============================================================================ + +/** A structure for a rectangle with 64-bit interger components. */ +struct EmuRectangle : public EmuPoint, public EmuSize +{ + inline explicit EmuRectangle() {} + inline explicit EmuRectangle( const EmuPoint& rPos, const EmuSize& rSize ) : EmuPoint( rPos ), EmuSize( rSize ) {} + inline explicit EmuRectangle( sal_Int64 nX, sal_Int64 nY, sal_Int64 nWidth, sal_Int64 nHeight ) : EmuPoint( nX, nY ), EmuSize( nWidth, nHeight ) {} + + inline void setPos( const EmuPoint& rPos ) { static_cast< EmuPoint& >( *this ) = rPos; } + inline void setSize( const EmuSize& rSize ) { static_cast< EmuSize& >( *this ) = rSize; } +}; + +// ============================================================================ + +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/effectproperties.hxx b/include/oox/drawingml/effectproperties.hxx new file mode 100644 index 000000000000..55c5ec34a20f --- /dev/null +++ b/include/oox/drawingml/effectproperties.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/. + */ + +#ifndef OOX_DRAWINGML_EFFECTPROPERTIES_HXX +#define OOX_DRAWINGML_EFFECTPROPERTIES_HXX + +#include "oox/drawingml/fillproperties.hxx" + +namespace oox { +namespace drawingml { + +// ============================================================================ + +struct EffectShadowProperties +{ + OptValue< sal_Int64 > moShadowDist; + OptValue< sal_Int64 > moShadowDir; + OptValue< sal_Int64 > moShadowAlpha; + Color moShadowColor; + + /** Overwrites all members that are explicitly set in rSourceProps. */ + void assignUsed( const EffectShadowProperties& rSourceProps ); +}; + +// ============================================================================ + +struct OOX_DLLPUBLIC EffectProperties +{ + EffectShadowProperties maShadow; + + /** Overwrites all members that are explicitly set in rSourceProps. */ + void assignUsed( const EffectProperties& rSourceProps ); + + /** Writes the properties to the passed property map. */ + void pushToPropMap( + PropertyMap& rPropMap, + const GraphicHelper& rGraphicHelper ) const; +}; + +// ============================================================================ + +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/effectpropertiescontext.hxx b/include/oox/drawingml/effectpropertiescontext.hxx new file mode 100644 index 000000000000..cd5e2eba28f5 --- /dev/null +++ b/include/oox/drawingml/effectpropertiescontext.hxx @@ -0,0 +1,41 @@ +/* -*- 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/. + */ + +#ifndef OOX_DRAWINGML_EFFECTPROPERTIESCONTEXT_HXX +#define OOX_DRAWINGML_EFFECTPROPERTIESCONTEXT_HXX + +#include "oox/core/contexthandler.hxx" +#include "oox/dllapi.h" + +namespace oox { namespace drawingml { + +// --------------------------------------------------------------------- + +struct EffectProperties; + +class OOX_DLLPUBLIC EffectPropertiesContext : public ::oox::core::ContextHandler +{ +public: + EffectPropertiesContext( ::oox::core::ContextHandler& rParent, + EffectProperties& rEffectProperties ) throw(); + ~EffectPropertiesContext(); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) + throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +protected: + EffectProperties& mrEffectProperties; +}; + +} } + +#endif // OOX_DRAWINGML_EFFECTPROPERTIESCONTEXT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/embeddedwavaudiofile.hxx b/include/oox/drawingml/embeddedwavaudiofile.hxx new file mode 100644 index 000000000000..97cebd54947b --- /dev/null +++ b/include/oox/drawingml/embeddedwavaudiofile.hxx @@ -0,0 +1,51 @@ +/* -*- 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 OOX_DRAWINGML_EMBEDDEDWAVAUDIOFILE_HXX +#define OOX_DRAWINGML_EMBEDDEDWAVAUDIOFILE_HXX + +#include <rtl/ustring.hxx> +#include <com/sun/star/xml/sax/XFastAttributeList.hpp> + +#include "oox/core/fragmenthandler.hxx" + +namespace oox { namespace drawingml { + + struct EmbeddedWAVAudioFile + { + EmbeddedWAVAudioFile() + : mbBuiltIn(false) + { + } + bool mbBuiltIn; + OUString msName; + OUString msEmbed; + }; + + void getEmbeddedWAVAudioFile( + const ::oox::core::Relations& rRelations, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs, + EmbeddedWAVAudioFile & aAudio ); + +} } + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/fillproperties.hxx b/include/oox/drawingml/fillproperties.hxx new file mode 100644 index 000000000000..fb9aa849e92e --- /dev/null +++ b/include/oox/drawingml/fillproperties.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 OOX_DRAWINGML_FILLPROPERTIES_HXX +#define OOX_DRAWINGML_FILLPROPERTIES_HXX + +#include <map> +#include <com/sun/star/graphic/XGraphic.hpp> +#include <com/sun/star/geometry/IntegerRectangle2D.hpp> +#include "oox/drawingml/color.hxx" +#include "oox/helper/helper.hxx" +#include "oox/drawingml/embeddedwavaudiofile.hxx" + +namespace oox { + class GraphicHelper; + class PropertyMap; + class PropertySet; +} + +namespace oox { +namespace drawingml { + +class ShapePropertyMap; + +// ============================================================================ + +struct GradientFillProperties +{ + typedef ::std::map< double, Color > GradientStopMap; + + GradientStopMap maGradientStops; /// Gradient stops (colors/transparence). + OptValue< ::com::sun::star::geometry::IntegerRectangle2D > moFillToRect; + OptValue< ::com::sun::star::geometry::IntegerRectangle2D > moTileRect; + OptValue< sal_Int32 > moGradientPath; /// If set, gradient follows rectangle, circle, or shape. + OptValue< sal_Int32 > moShadeAngle; /// Rotation angle of linear gradients. + OptValue< sal_Int32 > moShadeFlip; /// Flip mode of gradient, if not stretched to shape. + OptValue< bool > moShadeScaled; /// True = scale gradient into shape. + OptValue< bool > moRotateWithShape; /// True = rotate gradient with shape. + + /** Overwrites all members that are explicitly set in rSourceProps. */ + void assignUsed( const GradientFillProperties& rSourceProps ); +}; + +// ============================================================================ + +struct PatternFillProperties +{ + Color maPattFgColor; /// Pattern foreground color. + Color maPattBgColor; /// Pattern background color. + OptValue< sal_Int32 > moPattPreset; /// Preset pattern type. + + /** Overwrites all members that are explicitly set in rSourceProps. */ + void assignUsed( const PatternFillProperties& rSourceProps ); +}; + +// ============================================================================ + +struct BlipFillProperties +{ + ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > + mxGraphic; /// The fill graphic. + OptValue< sal_Int32 > moBitmapMode; /// Bitmap tile or stretch. + OptValue< ::com::sun::star::geometry::IntegerRectangle2D > + moFillRect; /// Stretch fill offsets. + OptValue< ::com::sun::star::geometry::IntegerRectangle2D > + moClipRect; + OptValue< sal_Int32 > moTileOffsetX; /// Width of bitmap tiles (EMUs). + OptValue< sal_Int32 > moTileOffsetY; /// Height of bitmap tiles (EMUs). + OptValue< sal_Int32 > moTileScaleX; /// Horizontal scaling of bitmap tiles (1/1000 percent). + OptValue< sal_Int32 > moTileScaleY; /// Vertical scaling of bitmap tiles (1/1000 percent). + OptValue< sal_Int32 > moTileAlign; /// Anchor point inside bitmap. + OptValue< sal_Int32 > moTileFlip; /// Flip mode of bitmap tiles. + OptValue< bool > moRotateWithShape; /// True = rotate bitmap with shape. + // effects + OptValue< sal_Int32 > moColorEffect; /// XML token for a color effect. + OptValue< sal_Int32 > moBrightness; /// Brightness in the range [-100000,100000]. + OptValue< sal_Int32 > moContrast; /// Contrast in the range [-100000,100000]. + Color maColorChangeFrom; /// Start color of color transformation. + Color maColorChangeTo; /// Destination color of color transformation. + + /** Overwrites all members that are explicitly set in rSourceProps. */ + void assignUsed( const BlipFillProperties& rSourceProps ); +}; + +// ============================================================================ + +struct OOX_DLLPUBLIC FillProperties +{ + OptValue< sal_Int32 > moFillType; /// Fill type (OOXML token). + Color maFillColor; /// Solid fill color and transparence. + GradientFillProperties maGradientProps; /// Properties for gradient fills. + PatternFillProperties maPatternProps; /// Properties for pattern fills. + BlipFillProperties maBlipProps; /// Properties for bitmap fills. + + /** Overwrites all members that are explicitly set in rSourceProps. */ + void assignUsed( const FillProperties& rSourceProps ); + + /** Tries to resolve current settings to a solid color, e.g. returns the + start color of a gradient. */ + Color getBestSolidColor() const; + + /** Writes the properties to the passed property map. */ + void pushToPropMap( + ShapePropertyMap& rPropMap, + const GraphicHelper& rGraphicHelper, + sal_Int32 nShapeRotation = 0, + sal_Int32 nPhClr = API_RGB_TRANSPARENT, + bool bFlipH = false, + bool bFlipV = false ) const; +}; + +// ============================================================================ + +struct GraphicProperties +{ + BlipFillProperties maBlipProps; /// Properties for the graphic. + EmbeddedWAVAudioFile maAudio; /// Audio file details + + /** Overwrites all members that are explicitly set in rSourceProps. */ + void assignUsed( const GraphicProperties& rSourceProps ); + + /** Writes the properties to the passed property map. */ + void pushToPropMap( + PropertyMap& rPropMap, + const GraphicHelper& rGraphicHelper, + sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; +}; + +// ============================================================================ + +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/fillpropertiesgroupcontext.hxx b/include/oox/drawingml/fillpropertiesgroupcontext.hxx new file mode 100644 index 000000000000..81d8a6e0db20 --- /dev/null +++ b/include/oox/drawingml/fillpropertiesgroupcontext.hxx @@ -0,0 +1,208 @@ +/* -*- 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 OOX_DRAWINGML_FILLPROPERTIESGROUPCONTEXT_HPP +#define OOX_DRAWINGML_FILLPROPERTIESGROUPCONTEXT_HPP + +#include "oox/drawingml/colorchoicecontext.hxx" +#include "oox/drawingml/fillproperties.hxx" + +namespace oox { +namespace drawingml { + +// ============================================================================ + +/** Context handler that imports the a:solidFill element. */ +class SolidFillContext : public ColorContext +{ +public: + explicit SolidFillContext( + ::oox::core::ContextHandler& rParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs, + FillProperties& rFillProps ); +}; + +// ============================================================================ + +/** Context handler that imports the a:gradFill element. */ +class GradientFillContext : public ::oox::core::ContextHandler +{ +public: + explicit GradientFillContext( + ::oox::core::ContextHandler& rParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs, + GradientFillProperties& rGradientProps ); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext( + sal_Int32 nElement, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) + throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + +private: + GradientFillProperties& mrGradientProps; +}; + +// ============================================================================ + +/** Context handler that imports the a:pattFill element. */ +class PatternFillContext : public ::oox::core::ContextHandler +{ +public: + explicit PatternFillContext( + ::oox::core::ContextHandler& rParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs, + PatternFillProperties& rPatternProps ); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext( + sal_Int32 nElement, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) + throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + +private: + PatternFillProperties& mrPatternProps; +}; + +// ============================================================================ +// ============================================================================ + +/** Context handler that imports the a:clrChange element containing the colors + of a bitmap color change transformation. */ +class ColorChangeContext : public ::oox::core::ContextHandler +{ +public: + explicit ColorChangeContext( + ::oox::core::ContextHandler& rParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs, + BlipFillProperties& rBlipProps ); + virtual ~ColorChangeContext(); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext( + sal_Int32 nElement, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) + throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + +private: + BlipFillProperties& mrBlipProps; + bool mbUseAlpha; +}; + +// ============================================================================ + +/** Context handler that imports the a:blip element containing the fill bitmap + and bitmap color transformation settings. */ +class BlipContext : public ::oox::core::ContextHandler +{ +public: + explicit BlipContext( + ::oox::core::ContextHandler& rParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs, + BlipFillProperties& rBlipProps ); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext( + sal_Int32 nElement, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) + throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + +private: + BlipFillProperties& mrBlipProps; +}; + +// ============================================================================ + +/** Context handler that imports the a:blipFill element. */ +class BlipFillContext : public ::oox::core::ContextHandler +{ +public: + explicit BlipFillContext( + ::oox::core::ContextHandler& rParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs, + BlipFillProperties& rBlipProps ); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext( + sal_Int32 nElement, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) + throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + +private: + BlipFillProperties& mrBlipProps; +}; + +// ============================================================================ +// ============================================================================ + +/** Context handler for elements that contain a fill property element + (a:noFill, a:solidFill, a:gradFill, a:pattFill, a:blipFill, a:grpFill). */ +class FillPropertiesContext : public ::oox::core::ContextHandler +{ +public: + explicit FillPropertiesContext( + ::oox::core::ContextHandler& rParent, + FillProperties& rFillProps ); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext( + sal_Int32 nElement, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) + throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + + static ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > + createFillContext( + ::oox::core::ContextHandler& rParent, + sal_Int32 nElement, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs, + FillProperties& rFillProps ); + +protected: + FillProperties& mrFillProps; +}; + +// ============================================================================ + +/** Context handler for elements that contain a fill property element + (a:noFill, a:solidFill, a:gradFill, a:pattFill, a:blipFill, a:grpFill). + + This context handler takes a simple color instead of a fill properties + struct. The imported fill properties are converted automatically to the + best fitting solid color. + */ +class SimpleFillPropertiesContext : private FillProperties, public FillPropertiesContext +{ +public: + explicit SimpleFillPropertiesContext( + ::oox::core::ContextHandler& rParent, + Color& rColor ); + virtual ~SimpleFillPropertiesContext(); + +protected: + Color& mrColor; +}; + +// ============================================================================ + +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/graphicshapecontext.hxx b/include/oox/drawingml/graphicshapecontext.hxx new file mode 100644 index 000000000000..c5984d503363 --- /dev/null +++ b/include/oox/drawingml/graphicshapecontext.hxx @@ -0,0 +1,110 @@ +/* -*- 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 OOX_DRAWINGML_GRAPHICSHAPECONTEXT_HXX +#define OOX_DRAWINGML_GRAPHICSHAPECONTEXT_HXX + +#include "oox/drawingml/shape.hxx" +#include "oox/drawingml/shapecontext.hxx" +#include "oox/dllapi.h" + +namespace oox { namespace vml { struct OleObjectInfo; } } + +namespace oox { namespace drawingml { + +class OOX_DLLPUBLIC GraphicShapeContext : public ShapeContext +{ +public: + GraphicShapeContext( ::oox::core::ContextHandler& rParent, ShapePtr pMasterShapePtr, ShapePtr pShapePtr ); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +}; + +// ==================================================================== + +class OOX_DLLPUBLIC GraphicalObjectFrameContext : public ShapeContext +{ +public: + GraphicalObjectFrameContext( ::oox::core::ContextHandler& rParent, ShapePtr pMasterShapePtr, ShapePtr pShapePtr, bool bEmbedShapesInChart ); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +private: + bool mbEmbedShapesInChart; +}; + +// ==================================================================== + +class OleObjectGraphicDataContext : public ShapeContext +{ +public: + OleObjectGraphicDataContext( ::oox::core::ContextHandler& rParent, ShapePtr pShapePtr ); + ~OleObjectGraphicDataContext(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +private: + ::oox::vml::OleObjectInfo& mrOleObjectInfo; +}; + +// ==================================================================== + +class Diagram; + +class DiagramGraphicDataContext + : public ShapeContext +{ +public: + DiagramGraphicDataContext( ::oox::core::ContextHandler& rParent, ShapePtr pShapePtr ); + virtual ~DiagramGraphicDataContext(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +private: + OUString msDm; + OUString msLo; + OUString msQs; + OUString msCs; +}; + +// ==================================================================== + +class ChartGraphicDataContext : public ShapeContext +{ +public: + explicit ChartGraphicDataContext( + ::oox::core::ContextHandler& rParent, + const ShapePtr& rxShape, bool bEmbedShapes ); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext( + sal_Int32 nElement, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) + throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +private: + ChartShapeInfo& mrChartShapeInfo; +}; + +// ==================================================================== + +} } + +#endif // OOX_DRAWINGML_GRAPHICSHAPECONTEXT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/guidcontext.hxx b/include/oox/drawingml/guidcontext.hxx new file mode 100644 index 000000000000..8a60bf20ab5c --- /dev/null +++ b/include/oox/drawingml/guidcontext.hxx @@ -0,0 +1,43 @@ +/* -*- 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 OOX_DRAWINGML_GUIDCONTEXT_HXX +#define OOX_DRAWINGML_GUIDCONTEXT_HXX + +#include "oox/core/contexthandler.hxx" + +namespace oox { namespace drawingml { + + class GuidContext : public ::oox::core::ContextHandler + { + + public: + GuidContext( ::oox::core::ContextHandler& rParent, OUString& rGuidId ); + virtual void SAL_CALL characters( const OUString& aChars ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + + private: + + OUString& mrGuidId; + }; + +} } + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/lineproperties.hxx b/include/oox/drawingml/lineproperties.hxx new file mode 100644 index 000000000000..7ffdc04230a0 --- /dev/null +++ b/include/oox/drawingml/lineproperties.hxx @@ -0,0 +1,74 @@ +/* -*- 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 OOX_DRAWINGML_LINEPROPERTIES_HXX +#define OOX_DRAWINGML_LINEPROPERTIES_HXX + +#include "oox/drawingml/fillproperties.hxx" + +namespace oox { +namespace drawingml { + +// ============================================================================ + +struct LineArrowProperties +{ + OptValue< sal_Int32 > moArrowType; + OptValue< sal_Int32 > moArrowWidth; + OptValue< sal_Int32 > moArrowLength; + + /** Overwrites all members that are explicitly set in rSourceProps. */ + void assignUsed( const LineArrowProperties& rSourceProps ); +}; + +// ============================================================================ + +struct OOX_DLLPUBLIC LineProperties +{ + typedef ::std::pair< sal_Int32, sal_Int32 > DashStop; + typedef ::std::vector< DashStop > DashStopVector; + + LineArrowProperties maStartArrow; /// Start line arrow style. + LineArrowProperties maEndArrow; /// End line arrow style. + FillProperties maLineFill; /// Line fill (solid, gradient, ...). + DashStopVector maCustomDash; /// User-defined line dash style. + OptValue< sal_Int32 > moLineWidth; /// Line width (EMUs). + OptValue< sal_Int32 > moPresetDash; /// Preset dash (OOXML token). + OptValue< sal_Int32 > moLineCompound; /// Line compound type (OOXML token). + OptValue< sal_Int32 > moLineCap; /// Line cap (OOXML token). + OptValue< sal_Int32 > moLineJoint; /// Line joint type (OOXML token). + + /** Overwrites all members that are explicitly set in rSourceProps. */ + void assignUsed( const LineProperties& rSourceProps ); + + /** Writes the properties to the passed property map. */ + void pushToPropMap( + ShapePropertyMap& rPropMap, + const GraphicHelper& rGraphicHelper, + sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; +}; + +// ============================================================================ + +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/linepropertiescontext.hxx b/include/oox/drawingml/linepropertiescontext.hxx new file mode 100644 index 000000000000..e0454ddb2250 --- /dev/null +++ b/include/oox/drawingml/linepropertiescontext.hxx @@ -0,0 +1,52 @@ +/* -*- 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 OOX_DRAWINGML_LINEPROPERTIESCONTEXT_HXX +#define OOX_DRAWINGML_LINEPROPERTIESCONTEXT_HXX + +#include "oox/core/contexthandler.hxx" +#include "oox/dllapi.h" + +namespace oox { namespace drawingml { + +// --------------------------------------------------------------------- + +struct LineProperties; + +class OOX_DLLPUBLIC LinePropertiesContext : public ::oox::core::ContextHandler +{ +public: + LinePropertiesContext( ::oox::core::ContextHandler& rParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, + LineProperties& rLineProperties ) throw(); + ~LinePropertiesContext(); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) + throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +protected: + LineProperties& mrLineProperties; +}; + +} } + +#endif // OOX_DRAWINGML_LINEPROPERTIESCONTEXT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/objectdefaultcontext.hxx b/include/oox/drawingml/objectdefaultcontext.hxx new file mode 100644 index 000000000000..b8b1d5b95ede --- /dev/null +++ b/include/oox/drawingml/objectdefaultcontext.hxx @@ -0,0 +1,43 @@ +/* -*- 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 OOX_DRAWINGML_OBJECTDEFAULTCONTEXT_HXX +#define OOX_DRAWINGML_OBJECTDEFAULTCONTEXT_HXX + +#include "oox/core/contexthandler.hxx" + +namespace oox { namespace drawingml { + +class Theme; + +class objectDefaultContext : public oox::core::ContextHandler +{ +public: + objectDefaultContext( ::oox::core::ContextHandler& rParent, Theme& rTheme ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +protected: + Theme& mrTheme; +}; + +} } + +#endif // OOX_DRAWINGML_OBJECTDEFAULTCONTEXT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/scene3dcontext.hxx b/include/oox/drawingml/scene3dcontext.hxx new file mode 100644 index 000000000000..cc3341ddf310 --- /dev/null +++ b/include/oox/drawingml/scene3dcontext.hxx @@ -0,0 +1,47 @@ +/* -*- 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 OOX_DRAWINGML_SCENE3DPROPERTIESCONTEXT_HPP +#define OOX_DRAWINGML_SCENE3DPROPERTIESCONTEXT_HPP + +#include "oox/core/contexthandler.hxx" + +namespace oox { namespace drawingml { + +struct Shape3DProperties; + +// --------------------------------------------------------------------- + +class Scene3DPropertiesContext : public ::oox::core::ContextHandler +{ +public: + Scene3DPropertiesContext( ::oox::core::ContextHandler& rParent, Shape3DProperties& r3DProperties ) throw(); + + ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) + throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + +private: + Shape3DProperties& mr3DProperties; +}; + +} } + +#endif // OOX_DRAWINGML_SCENE3DPROPERTIESCONTEXT_HPP + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx new file mode 100644 index 000000000000..f8a58ec5340b --- /dev/null +++ b/include/oox/drawingml/shape.hxx @@ -0,0 +1,273 @@ +/* -*- 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 OOX_DRAWINGML_SHAPE_HXX +#define OOX_DRAWINGML_SHAPE_HXX + +#include "oox/helper/propertymap.hxx" +#include "oox/drawingml/drawingmltypes.hxx" +#include "oox/drawingml/customshapeproperties.hxx" +#include "oox/drawingml/textliststyle.hxx" +#include "oox/drawingml/shape3dproperties.hxx" + +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/drawing/XDrawPage.hpp> +#include <boost/shared_ptr.hpp> +#include <boost/enable_shared_from_this.hpp> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <vector> +#include <map> +#include "oox/dllapi.h" + +namespace oox { namespace vml { + struct OleObjectInfo; +} } + +namespace oox { namespace drawingml { + +class CustomShapeProperties; +typedef boost::shared_ptr< CustomShapeProperties > CustomShapePropertiesPtr; + +typedef ::std::map< OUString, ShapePtr > ShapeIdMap; + +struct ShapeStyleRef +{ + Color maPhClr; + sal_Int32 mnThemedIdx; +}; + +typedef ::std::map< sal_Int32, ShapeStyleRef > ShapeStyleRefMap; + +// ============================================================================ + +/** Additional information for a chart embedded in a drawing shape. */ +struct ChartShapeInfo +{ + OUString maFragmentPath; ///< Path to related XML stream, e.g. for charts. + bool mbEmbedShapes; ///< True = load chart shapes into chart, false = load into parent drawpage. + + inline explicit ChartShapeInfo( bool bEmbedShapes ) : mbEmbedShapes( bEmbedShapes ) {} +}; + +// ============================================================================ + +class OOX_DLLPUBLIC Shape + : public boost::enable_shared_from_this< Shape > +{ +public: + + explicit Shape( const sal_Char* pServiceType = 0 ); + explicit Shape( const ShapePtr& pSourceShape ); + virtual ~Shape(); + + OUString& getServiceName(){ return msServiceName; } + void setServiceName( const sal_Char* pServiceName ); + + PropertyMap& getShapeProperties(){ return maShapeProperties; } + + inline LineProperties& getLineProperties() { return *mpLinePropertiesPtr; } + inline const LineProperties& getLineProperties() const { return *mpLinePropertiesPtr; } + + inline FillProperties& getFillProperties() { return *mpFillPropertiesPtr; } + inline const FillProperties& getFillProperties() const { return *mpFillPropertiesPtr; } + + inline GraphicProperties& getGraphicProperties() { return *mpGraphicPropertiesPtr; } + inline const GraphicProperties& getGraphicProperties() const { return *mpGraphicPropertiesPtr; } + + CustomShapePropertiesPtr getCustomShapeProperties(){ return mpCustomShapePropertiesPtr; } + + Shape3DProperties& get3DProperties() { return *mp3DPropertiesPtr; } + const Shape3DProperties& get3DProperties() const { return *mp3DPropertiesPtr; } + + table::TablePropertiesPtr getTableProperties(); + + inline EffectProperties& getEffectProperties() { return *mpEffectPropertiesPtr; } + + void setChildPosition( com::sun::star::awt::Point nPosition ){ maChPosition = nPosition; } + void setChildSize( com::sun::star::awt::Size aSize ){ maChSize = aSize; } + void moveAllToPosition( const com::sun::star::awt::Point &rPoint ); + + void setPosition( com::sun::star::awt::Point nPosition ){ maPosition = nPosition; } + const com::sun::star::awt::Point& getPosition() const { return maPosition; } + + void setSize( com::sun::star::awt::Size aSize ){ maSize = aSize; } + const com::sun::star::awt::Size& getSize() const { return maSize; } + + void setRotation( sal_Int32 nRotation ) { mnRotation = nRotation; } + void setFlip( sal_Bool bFlipH, sal_Bool bFlipV ) { mbFlipH = bFlipH; mbFlipV = bFlipV; } + void addChild( const ShapePtr pChildPtr ) { maChildren.push_back( pChildPtr ); } + std::vector< ShapePtr >& getChildren() { return maChildren; } + + void setName( const OUString& rName ) { msName = rName; } + OUString getName( ) { return msName; } + void setId( const OUString& rId ) { msId = rId; } + OUString getId() { return msId; } + void setHidden( sal_Bool bHidden ) { mbHidden = bHidden; } + sal_Bool getHidden() const { return mbHidden; }; + void setHiddenMasterShape( sal_Bool bHiddenMasterShape ) { mbHiddenMasterShape = bHiddenMasterShape; } + void setSubType( sal_Int32 nSubType ) { mnSubType = nSubType; } + sal_Int32 getSubType() const { return mnSubType; } + void setSubTypeIndex( sal_Int32 nSubTypeIndex ) { moSubTypeIndex = nSubTypeIndex; } + const OptValue< sal_Int32 >& getSubTypeIndex() const { return moSubTypeIndex; } + + // setDefaults has to be called if styles are imported (OfficeXML is not storing properties having the default value) + void setDefaults(); + + ::oox::vml::OleObjectInfo& setOleObjectType(); + ChartShapeInfo& setChartType( bool bEmbedShapes ); + void setDiagramType(); + void setTableType(); + + void setTextBody(const TextBodyPtr & pTextBody); + TextBodyPtr getTextBody(); + void setMasterTextListStyle( const TextListStylePtr& pMasterTextListStyle ); + TextListStylePtr getMasterTextListStyle() const { return mpMasterTextListStyle; } + + inline ShapeStyleRefMap& getShapeStyleRefs() { return maShapeStyleRefs; } + inline const ShapeStyleRefMap& getShapeStyleRefs() const { return maShapeStyleRefs; } + const ShapeStyleRef* getShapeStyleRef( sal_Int32 nRefType ) const; + + // addShape is creating and inserting the corresponding XShape. + void addShape( + ::oox::core::XmlFilterBase& rFilterBase, + const Theme* pTheme, + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes, + basegfx::B2DHomMatrix& aTransformation, + FillProperties& rShapeOrParentShapeFillProps, + const ::com::sun::star::awt::Rectangle* pShapeRect = 0, + ShapeIdMap* pShapeMap = 0 ); + + void dropChildren() { maChildren.clear(); } + + void addChildren( + ::oox::core::XmlFilterBase& rFilterBase, + const Theme* pTheme, + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes, + basegfx::B2DHomMatrix& aTransformation, + const ::com::sun::star::awt::Rectangle* pShapeRect = 0, + ShapeIdMap* pShapeMap = 0 ); + + void setXShape( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rXShape ) + { mxShape = rXShape; }; + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & + getXShape() const { return mxShape; } + + virtual void applyShapeReference( const Shape& rReferencedShape, bool bUseText = true ); + const ::std::vector<OUString>& + getExtDrawings() { return maExtDrawings; } + void addExtDrawingRelId( const OUString &rRelId ) { maExtDrawings.push_back( rRelId ); } + +protected: + + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > + createAndInsert( + ::oox::core::XmlFilterBase& rFilterBase, + const OUString& rServiceName, + const Theme* pTheme, + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes, + const ::com::sun::star::awt::Rectangle* pShapeRect, + sal_Bool bClearText, + sal_Bool bDoNotInsertEmptyTextBody, + basegfx::B2DHomMatrix& aTransformation, + FillProperties& rShapeOrParentShapeFillProps + ); + + void addChildren( + ::oox::core::XmlFilterBase& rFilterBase, + Shape& rMaster, + const Theme* pTheme, + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes, + const ::com::sun::star::awt::Rectangle& rClientRect, + ShapeIdMap* pShapeMap, + basegfx::B2DHomMatrix& aTransformation ); + + virtual OUString finalizeServiceName( + ::oox::core::XmlFilterBase& rFilter, + const OUString& rServiceName, + const ::com::sun::star::awt::Rectangle& rShapeRect ); + + virtual void finalizeXShape( + ::oox::core::XmlFilterBase& rFilter, + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes ); + + std::vector< ShapePtr > maChildren; // only used for group shapes + com::sun::star::awt::Size maChSize; // only used for group shapes + com::sun::star::awt::Point maChPosition; // only used for group shapes + com::sun::star::awt::Size maAbsoluteSize; // only used for group shapes + com::sun::star::awt::Point maAbsolutePosition; // only used for group shapes + sal_Bool mbIsChild; + + TextBodyPtr mpTextBody; + LinePropertiesPtr mpLinePropertiesPtr; + FillPropertiesPtr mpFillPropertiesPtr; + GraphicPropertiesPtr mpGraphicPropertiesPtr; + CustomShapePropertiesPtr mpCustomShapePropertiesPtr; + table::TablePropertiesPtr mpTablePropertiesPtr; + Shape3DPropertiesPtr mp3DPropertiesPtr; + EffectPropertiesPtr mpEffectPropertiesPtr; + PropertyMap maShapeProperties; + PropertyMap maDefaultShapeProperties; + TextListStylePtr mpMasterTextListStyle; + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > mxShape; + + OUString msServiceName; + OUString msName; + OUString msId; + sal_Int32 mnSubType; // if this type is not zero, then the shape is a placeholder + OptValue< sal_Int32 > moSubTypeIndex; + + ShapeStyleRefMap maShapeStyleRefs; + + com::sun::star::awt::Size maSize; + com::sun::star::awt::Point maPosition; + ::std::vector<OUString> maExtDrawings; + +private: + enum FrameType + { + FRAMETYPE_GENERIC, ///< Generic shape, no special type. + FRAMETYPE_OLEOBJECT, ///< OLE object embedded in a shape. + FRAMETYPE_CHART, ///< Chart embedded in a shape. + FRAMETYPE_DIAGRAM, ///< Complex diagram drawing shape. + FRAMETYPE_TABLE ///< A table embedded in a shape. + }; + + typedef ::boost::shared_ptr< ::oox::vml::OleObjectInfo > OleObjectInfoRef; + typedef ::boost::shared_ptr< ChartShapeInfo > ChartShapeInfoRef; + + FrameType meFrameType; ///< Type for graphic frame shapes. + OleObjectInfoRef mxOleObjectInfo; ///< Additional data for OLE objects. + ChartShapeInfoRef mxChartShapeInfo; ///< Additional data for chart shapes. + + sal_Int32 mnRotation; + sal_Bool mbFlipH; + sal_Bool mbFlipV; + sal_Bool mbHidden; + sal_Bool mbHiddenMasterShape; // master shapes can be hidden in layout slides + // we need separate flag because we don't want + // to propagate it when applying reference shape +}; + +// ============================================================================ + +} } + +#endif // OOX_DRAWINGML_SHAPE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/shape3dproperties.hxx b/include/oox/drawingml/shape3dproperties.hxx new file mode 100644 index 000000000000..d1891402757c --- /dev/null +++ b/include/oox/drawingml/shape3dproperties.hxx @@ -0,0 +1,125 @@ +/* -*- 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 OOX_DRAWINGML_SHAPE3DPROPERTIES_HXX +#define OOX_DRAWINGML_SHAPE3DPROPERTIES_HXX + +#include <map> +#include <com/sun/star/graphic/XGraphic.hpp> +#include <com/sun/star/geometry/IntegerRectangle2D.hpp> +#include "oox/core/xmlfilterbase.hxx" +#include "oox/drawingml/color.hxx" +#include "oox/helper/helper.hxx" + +namespace oox { class PropertyMap; } +namespace oox { class PropertySet; } +namespace oox { namespace core { class ModelObjectContainer; } } + +namespace oox { +namespace drawingml { + +// ============================================================================ + +struct Shape3DPropertyNames +{ + OUString maFillStyle; + OUString maFillColor; + OUString maFillTransparence; + OUString maFillGradient; + OUString maFillBitmap; + OUString maFillBitmapMode; + OUString maFillBitmapTile; + OUString maFillBitmapStretch; + OUString maFillBitmapLogicalSize; + OUString maFillBitmapSizeX; + OUString maFillBitmapSizeY; + OUString maFillBitmapOffsetX; + OUString maFillBitmapOffsetY; + OUString maFillBitmapRectanglePoint; + bool mbNamedFillGradient; + bool mbNamedFillBitmap; + bool mbTransformGraphic; + + Shape3DPropertyNames(); +}; + +// ============================================================================ + +struct Shape3DProperties +{ + typedef ::std::map< double, Color > GradientStopMap; + + OptValue< sal_Int32 > moFillType; /// Fill type (OOXML token). + OptValue< bool > moRotateWithShape; /// True = rotate gradient/bitmap with shape. + Color maFillColor; /// Solid fill color and transparence. + GradientStopMap maGradientStops; /// Gradient stops (colors/transparence). + OptValue< sal_Int32 > moGradientPath; /// If set, gradient follows rectangle, circle, or shape. + OptValue< sal_Int32 > moShadeAngle; /// Rotation angle of linear gradients. + OptValue< bool > moShadeScaled; + OptValue< sal_Int32 > moFlipModeToken; + OptValue< com::sun::star::geometry::IntegerRectangle2D > moFillToRect; + OptValue< com::sun::star::geometry::IntegerRectangle2D > moTileRect; + OptValue< sal_Int32 > moPattPreset; /// Preset pattern type. + Color maPattFgColor; /// Pattern foreground color. + Color maPattBgColor; /// Pattern background color. + ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > mxGraphic; + Color maColorChangeFrom; /// Start color of color transformation. + Color maColorChangeTo; /// Destination color of color transformation. + OptValue< sal_Int32 > moBitmapMode; /// Bitmap tile or stretch. + OptValue< sal_Int32 > moTileX; /// Width of bitmap tiles. + OptValue< sal_Int32 > moTileY; /// Height of bitmap tiles. + OptValue< sal_Int32 > moTileSX; + OptValue< sal_Int32 > moTileSY; + OptValue< sal_Int32 > moTileAlign; /// Anchor point inside bitmap. + + static Shape3DPropertyNames DEFAULTNAMES; /// Default fill property names for shape fill. + static Shape3DPropertyNames DEFAULTPICNAMES; /// Default fill property names for pictures. + + /** Overwrites all members that are explicitly set in rSourceProps. */ + void assignUsed( const Shape3DProperties& rSourceProps ); + + /** Tries to resolve current settings to a solid color, e.g. returns the + start color of a gradient. */ + Color getBestSolidColor() const; + + /** Writes the properties to the passed property map. */ + void pushToPropMap( + PropertyMap& rPropMap, + const Shape3DPropertyNames& rPropNames, + const ::oox::core::XmlFilterBase& rFilter, + ::oox::core::ModelObjectContainer& rObjContainer, + sal_Int32 nShapeRotation, sal_Int32 nPhClr ) const; + + /** Writes the properties to the passed property set. */ + void pushToPropSet( + PropertySet& rPropSet, + const Shape3DPropertyNames& rPropNames, + const ::oox::core::XmlFilterBase& rFilter, + ::oox::core::ModelObjectContainer& rObjContainer, + sal_Int32 nShapeRotation, sal_Int32 nPhClr ) const; +}; + +// ============================================================================ + +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/shapecontext.hxx b/include/oox/drawingml/shapecontext.hxx new file mode 100644 index 000000000000..277ee91017ec --- /dev/null +++ b/include/oox/drawingml/shapecontext.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 OOX_DRAWINGML_SHAPECONTEXT_HXX +#define OOX_DRAWINGML_SHAPECONTEXT_HXX + +#include <com/sun/star/drawing/XShapes.hpp> + +#include "oox/core/contexthandler.hxx" +#include "oox/drawingml/shape.hxx" +#include "oox/drawingml/shapepropertiescontext.hxx" +#include "oox/dllapi.h" + +namespace oox { namespace drawingml { + +class OOX_DLLPUBLIC ShapeContext : public ::oox::core::ContextHandler +{ +public: + ShapeContext( ::oox::core::ContextHandler& rParent, ShapePtr pMasterShapePtr, ShapePtr pShapePtr ); + virtual ~ShapeContext(); + + virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + + ShapePtr getShape(); + +protected: + + ShapePtr mpMasterShapePtr; + ShapePtr mpShapePtr; +}; + +} } + +#endif // OOX_DRAWINGML_SHAPEGROUPCONTEXT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/shapegroupcontext.hxx b/include/oox/drawingml/shapegroupcontext.hxx new file mode 100644 index 000000000000..65b86ac99567 --- /dev/null +++ b/include/oox/drawingml/shapegroupcontext.hxx @@ -0,0 +1,46 @@ +/* -*- 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 OOX_DRAWINGML_SHAPEGROUPCONTEXT_HXX +#define OOX_DRAWINGML_SHAPEGROUPCONTEXT_HXX + +#include "oox/drawingml/shape.hxx" +#include "oox/drawingml/shapecontext.hxx" +#include "oox/dllapi.h" + +namespace oox { namespace drawingml { + +class OOX_DLLPUBLIC ShapeGroupContext : public ::oox::core::ContextHandler +{ +public: + ShapeGroupContext( ::oox::core::ContextHandler& rParent, ShapePtr pMasterShapePtr, ShapePtr pGroupShapePtr ); + virtual ~ShapeGroupContext(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +protected: + + ShapePtr mpGroupShapePtr; + ShapePtr mpMasterShapePtr; +}; + +} } + +#endif // OOX_DRAWINGML_SHAPEGROUPCONTEXT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/shapepropertiescontext.hxx b/include/oox/drawingml/shapepropertiescontext.hxx new file mode 100644 index 000000000000..31da8a9c0f23 --- /dev/null +++ b/include/oox/drawingml/shapepropertiescontext.hxx @@ -0,0 +1,43 @@ +/* -*- 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 OOX_DRAWINGML_SHAPEPROPERTIESCONTEXT_HXX +#define OOX_DRAWINGML_SHAPEPROPERTIESCONTEXT_HXX + +#include "oox/core/contexthandler.hxx" +#include "oox/drawingml/shape.hxx" + +namespace oox { namespace drawingml { + +class ShapePropertiesContext : public ::oox::core::ContextHandler +{ +public: + ShapePropertiesContext( ::oox::core::ContextHandler& rParent, Shape& rShape ); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +protected: + Shape& mrShape; +}; + +} } + +#endif // OOX_DRAWINGML_SHAPEPROPERTIESCONTEXT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/shapepropertymap.hxx b/include/oox/drawingml/shapepropertymap.hxx new file mode 100644 index 000000000000..a5cc12f5484c --- /dev/null +++ b/include/oox/drawingml/shapepropertymap.hxx @@ -0,0 +1,147 @@ +/* -*- 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 OOX_DRAWINGML_SHAPEPROPERTYMAP_HXX +#define OOX_DRAWINGML_SHAPEPROPERTYMAP_HXX + +#include "oox/helper/propertymap.hxx" +#include "oox/dllapi.h" + +namespace oox { class ModelObjectHelper; } + +namespace oox { +namespace drawingml { + +// ============================================================================ + +/** Enumeration for various properties related to drawing shape formatting. + + This is an abstraction for shape formatting properties that have different + names in various implementations, e.g. drawing shapes vs. chart objects. + */ +enum ShapePropertyId +{ + SHAPEPROP_LineStyle, + SHAPEPROP_LineWidth, + SHAPEPROP_LineColor, + SHAPEPROP_LineTransparency, + SHAPEPROP_LineDash, /// Explicit line dash or name of a line dash stored in a global container. + SHAPEPROP_LineJoint, + SHAPEPROP_LineStart, /// Explicit line start marker or name of a line marker stored in a global container. + SHAPEPROP_LineStartWidth, + SHAPEPROP_LineStartCenter, + SHAPEPROP_LineEnd, /// Explicit line end marker or name of a line marker stored in a global container. + SHAPEPROP_LineEndWidth, + SHAPEPROP_LineEndCenter, + SHAPEPROP_FillStyle, + SHAPEPROP_FillColor, + SHAPEPROP_FillTransparency, + SHAPEPROP_GradientTransparency, + SHAPEPROP_FillGradient, /// Explicit fill gradient or name of a fill gradient stored in a global container. + SHAPEPROP_FillBitmapUrl, /// Explicit fill bitmap URL or name of a fill bitmap URL stored in a global container. + SHAPEPROP_FillBitmapMode, + SHAPEPROP_FillBitmapSizeX, + SHAPEPROP_FillBitmapSizeY, + SHAPEPROP_FillBitmapOffsetX, + SHAPEPROP_FillBitmapOffsetY, + SHAPEPROP_FillBitmapRectanglePoint, + SHAPEPROP_ShadowXDistance, + SHAPEPROP_END +}; + +// ============================================================================ + +struct OOX_DLLPUBLIC ShapePropertyInfo +{ + const sal_Int32* mpnPropertyIds; /// Pointer to array of property identifiers for all SHAPEPROP properties. + bool mbNamedLineMarker; /// True = use named line marker instead of explicit line marker. + bool mbNamedLineDash; /// True = use named line dash instead of explicit line dash. + bool mbNamedFillGradient; /// True = use named fill gradient instead of explicit fill gradient. + bool mbNamedFillBitmapUrl; /// True = use named fill bitmap URL instead of explicit fill bitmap URL. + + static ShapePropertyInfo DEFAULT; /// Default property info (used as default parameter of other methods). + + explicit ShapePropertyInfo( + const sal_Int32* pnPropertyIds, + bool bNamedLineMarker, + bool bNamedLineDash, + bool bNamedFillGradient, + bool bNamedFillBitmapUrl ); + + inline bool has( ShapePropertyId ePropId ) const { return mpnPropertyIds[ ePropId ] >= 0; } + inline sal_Int32 operator[]( ShapePropertyId ePropId ) const { return mpnPropertyIds[ ePropId ]; } +}; + +// ============================================================================ + +class OOX_DLLPUBLIC ShapePropertyMap : public PropertyMap +{ +public: + explicit ShapePropertyMap( + ModelObjectHelper& rModelObjHelper, + const ShapePropertyInfo& rShapePropInfo = ShapePropertyInfo::DEFAULT ); + + /** Returns true, if the specified property is supported. */ + bool supportsProperty( ShapePropertyId ePropId ) const; + + /** Returns true, if named line markers are supported, and the specified + line marker has already been inserted into the marker table. */ + bool hasNamedLineMarkerInTable( const OUString& rMarkerName ) const; + + /** Sets the specified shape property to the passed value. */ + bool setAnyProperty( ShapePropertyId ePropId, const ::com::sun::star::uno::Any& rValue ); + + /** Sets the specified shape property to the passed value. */ + template< typename Type > + inline bool setProperty( ShapePropertyId ePropId, const Type& rValue ) + { return setAnyProperty( ePropId, ::com::sun::star::uno::Any( rValue ) ); } + + using PropertyMap::setAnyProperty; + using PropertyMap::setProperty; + using PropertyMap::operator[]; + +private: + /** Sets an explicit line marker, or creates a named line marker. */ + bool setLineMarker( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue ); + /** Sets an explicit line dash, or creates a named line dash. */ + bool setLineDash( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue ); + /** Sets an explicit fill gradient, or creates a named fill gradient. */ + bool setFillGradient( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue ); + /** Creates a named transparency gradient. */ + bool setGradientTrans( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue ); + /** Sets an explicit fill bitmap URL, or creates a named fill bitmap URL. */ + bool setFillBitmapUrl( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue ); + + // not implemented, to prevent implicit conversion from enum to int + ::com::sun::star::uno::Any& operator[]( ShapePropertyId ePropId ); + const ::com::sun::star::uno::Any& operator[]( ShapePropertyId ePropId ) const; + +private: + ModelObjectHelper& mrModelObjHelper; + ShapePropertyInfo maShapePropInfo; +}; + +// ============================================================================ + +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/shapestylecontext.hxx b/include/oox/drawingml/shapestylecontext.hxx new file mode 100644 index 000000000000..88338a16b59a --- /dev/null +++ b/include/oox/drawingml/shapestylecontext.hxx @@ -0,0 +1,45 @@ +/* -*- 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 OOX_DRAWINGML_SHAPESTYLECONTEXT_HXX +#define OOX_DRAWINGML_SHAPESTYLECONTEXT_HXX + +#include "oox/drawingml/shape.hxx" +#include "oox/core/contexthandler.hxx" + +namespace oox { namespace drawingml { + +class ShapeStyleContext : public ::oox::core::ContextHandler +{ +public: + ShapeStyleContext( ::oox::core::ContextHandler& rParent, Shape& rShape ); + ~ShapeStyleContext(); + + virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +protected: + Shape& mrShape; +}; + +} } + +#endif // OOX_DRAWINGML_SHAPESTYLECONTEXT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/spdefcontext.hxx b/include/oox/drawingml/spdefcontext.hxx new file mode 100644 index 000000000000..1fa773fb57dc --- /dev/null +++ b/include/oox/drawingml/spdefcontext.hxx @@ -0,0 +1,42 @@ +/* -*- 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 OOX_DRAWINGML_SPDEFCONTEXT_HXX +#define OOX_DRAWINGML_SPDEFCONTEXT_HXX + +#include "oox/drawingml/shape.hxx" +#include "oox/core/contexthandler.hxx" + +namespace oox { namespace drawingml { + +class spDefContext : public oox::core::ContextHandler +{ +public: + spDefContext( ::oox::core::ContextHandler& rParent, Shape& rDefaultObject ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +protected: + Shape& mrDefaultObject; +}; + +} } + +#endif // OOX_DRAWINGML_SPDEFCONTEXT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/table/tablebackgroundstylecontext.hxx b/include/oox/drawingml/table/tablebackgroundstylecontext.hxx new file mode 100644 index 000000000000..185987df8ad7 --- /dev/null +++ b/include/oox/drawingml/table/tablebackgroundstylecontext.hxx @@ -0,0 +1,47 @@ +/* -*- 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 OOX_DRAWINGML_TABLEBACKGROUNDSTYLECONTEXT +#define OOX_DRAWINGML_TABLEBACKGROUNDSTYLECONTEXT + +#include "oox/core/contexthandler.hxx" +#include "oox/drawingml/table/tablestyle.hxx" + +namespace oox { namespace drawingml { namespace table { + +class TableBackgroundStyleContext : public ::oox::core::ContextHandler +{ +public: + TableBackgroundStyleContext( ::oox::core::ContextHandler& rParent, TableStyle& rTableStyle ); + ~TableBackgroundStyleContext(); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +private: + + TableStyle& mrTableStyle; +}; + +} } } + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/table/tablecell.hxx b/include/oox/drawingml/table/tablecell.hxx new file mode 100644 index 000000000000..9bb721f8599a --- /dev/null +++ b/include/oox/drawingml/table/tablecell.hxx @@ -0,0 +1,115 @@ +/* -*- 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 OOX_DRAWINGML_TABLECELL_HXX +#define OOX_DRAWINGML_TABLECELL_HXX + +#include "oox/helper/propertymap.hxx" +#include "oox/drawingml/color.hxx" +#include "oox/drawingml/drawingmltypes.hxx" +#include "oox/drawingml/lineproperties.hxx" +#include "oox/drawingml/fillproperties.hxx" +#include "oox/drawingml/textliststyle.hxx" +#include <com/sun/star/table/XCell.hpp> + +#include <boost/shared_ptr.hpp> +#include <boost/optional.hpp> +#include <vector> +#include <map> + +namespace oox { namespace drawingml { namespace table { + +class TableCellContext; +class TableProperties; +class TableStyle; + +class TableCell +{ + friend class TableCellContext; + +public: + + TableCell(); + ~TableCell(); + + sal_Int32 getRowSpan() const { return mnRowSpan; }; + void setRowSpan( sal_Int32 nRowSpan ){ mnRowSpan = nRowSpan; }; + sal_Int32 getGridSpan() const { return mnGridSpan; }; + void setGridSpan( sal_Int32 nGridSpan ){ mnGridSpan = nGridSpan; }; + sal_Bool gethMerge() const { return mbhMerge; }; + void sethMerge( sal_Bool bhMerge ){ mbhMerge = bhMerge; }; + sal_Bool getvMerge() const { return mbvMerge; }; + void setvMerge( sal_Bool bvMerge ){ mbvMerge = bvMerge; }; + sal_Int32 getLeftMargin() const { return mnMarL; }; + void setLeftMargin( sal_Int32 nMargin ){ mnMarL = nMargin; }; + sal_Int32 getRightMargin() const { return mnMarR; }; + void setRightMargin( sal_Int32 nMargin ){ mnMarR = nMargin; }; + sal_Int32 getTopMargin() const { return mnMarT; }; + void setTopMargin( sal_Int32 nMargin ){ mnMarT = nMargin; }; + sal_Int32 getBottomMargin() const { return mnMarB; }; + void setBottomMargin( sal_Int32 nMargin ){ mnMarB = nMargin; }; + sal_Int32 getVertToken() const { return mnVertToken; }; + void setVertToken( sal_Int32 nToken ){ mnVertToken = nToken; }; + sal_Int32 getAnchorToken() const { return mnAnchorToken; }; + void setAnchorToken( sal_Int32 nToken ){ mnAnchorToken = nToken; }; + sal_Bool getAnchorCtr() const { return mbAnchorCtr; }; + void setAnchorCtr( sal_Bool bAnchorCtr ){ mbAnchorCtr = bAnchorCtr; }; + sal_Int32 getHorzOverflowToken() const { return mnHorzOverflowToken; }; + void setHorzOverflowToken( sal_Int32 nToken ){ mnHorzOverflowToken = nToken; }; + + void setTextBody( const oox::drawingml::TextBodyPtr& pTextBody ){ mpTextBody = pTextBody; }; + oox::drawingml::TextBodyPtr getTextBody(){ return mpTextBody; }; + + void pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oox::drawingml::TextListStylePtr pMasterTextListStyle, + const ::com::sun::star::uno::Reference < ::com::sun::star::table::XCell >& rxCell, const TableProperties& rTableProperties, + const TableStyle& rTable, sal_Int32 nColumn, sal_Int32 nMaxColumn, sal_Int32 nRow, sal_Int32 nMaxRow ); + +private: + + oox::drawingml::TextBodyPtr mpTextBody; + + oox::drawingml::LineProperties maLinePropertiesLeft; + oox::drawingml::LineProperties maLinePropertiesRight; + oox::drawingml::LineProperties maLinePropertiesTop; + oox::drawingml::LineProperties maLinePropertiesBottom; + oox::drawingml::LineProperties maLinePropertiesTopLeftToBottomRight; + oox::drawingml::LineProperties maLinePropertiesBottomLeftToTopRight; + + oox::drawingml::FillProperties maFillProperties; + + sal_Int32 mnRowSpan; + sal_Int32 mnGridSpan; + sal_Bool mbhMerge; + sal_Bool mbvMerge; + + sal_Int32 mnMarL; + sal_Int32 mnMarR; + sal_Int32 mnMarT; + sal_Int32 mnMarB; + sal_Int32 mnVertToken; + sal_Int32 mnAnchorToken; + sal_Bool mbAnchorCtr; + sal_Int32 mnHorzOverflowToken; +}; + +} } } + +#endif // OOX_DRAWINGML_TABLECELL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/table/tablecellcontext.hxx b/include/oox/drawingml/table/tablecellcontext.hxx new file mode 100644 index 000000000000..a2c04bbff9a7 --- /dev/null +++ b/include/oox/drawingml/table/tablecellcontext.hxx @@ -0,0 +1,48 @@ +/* -*- 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 OOX_DRAWINGML_TABLECELLCONTEXT +#define OOX_DRAWINGML_TABLECELLCONTEXT + +#include "oox/drawingml/shapecontext.hxx" +#include "oox/drawingml/table/tablecell.hxx" + +namespace oox { namespace drawingml { namespace table { + +class TableCellContext : public ::oox::core::ContextHandler +{ +public: + TableCellContext( ::oox::core::ContextHandler& rParent, + const com::sun::star::uno::Reference< com::sun::star::xml::sax::XFastAttributeList >& xAttribs, TableCell& rTableCell ); + ~TableCellContext(); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +private: + + TableCell& mrTableCell; +}; + +} } } + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/table/tablecontext.hxx b/include/oox/drawingml/table/tablecontext.hxx new file mode 100644 index 000000000000..175f7f84cb43 --- /dev/null +++ b/include/oox/drawingml/table/tablecontext.hxx @@ -0,0 +1,48 @@ +/* -*- 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 OOX_DRAWINGML_TABLECONTEXT +#define OOX_DRAWINGML_TABLECONTEXT + +#include "oox/drawingml/shapecontext.hxx" + +namespace oox { namespace drawingml { namespace table { + +class TableProperties; + +class TableContext : public ShapeContext +{ +public: + TableContext( ::oox::core::ContextHandler& rParent, ShapePtr pShapePtr ); + ~TableContext(); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +private: + + TableProperties& mrTableProperties; +}; + +} } } + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/table/tablepartstylecontext.hxx b/include/oox/drawingml/table/tablepartstylecontext.hxx new file mode 100644 index 000000000000..14b38547d9f4 --- /dev/null +++ b/include/oox/drawingml/table/tablepartstylecontext.hxx @@ -0,0 +1,47 @@ +/* -*- 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 OOX_DRAWINGML_TABLEPARTSTYLECONTEXT +#define OOX_DRAWINGML_TABLEPARTSTYLECONTEXT + +#include "oox/core/contexthandler.hxx" +#include "oox/drawingml/table/tablestylepart.hxx" + +namespace oox { namespace drawingml { namespace table { + +class TablePartStyleContext : public ::oox::core::ContextHandler +{ +public: + TablePartStyleContext( ::oox::core::ContextHandler& rParent, TableStylePart& rTableStylePart ); + ~TablePartStyleContext(); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +private: + + TableStylePart& mrTableStylePart; +}; + +} } } + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/table/tableproperties.hxx b/include/oox/drawingml/table/tableproperties.hxx new file mode 100644 index 000000000000..8c584b1f8959 --- /dev/null +++ b/include/oox/drawingml/table/tableproperties.hxx @@ -0,0 +1,80 @@ +/* -*- 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 OOX_DRAWINGML_TABLEPROPERTIES_HXX +#define OOX_DRAWINGML_TABLEPROPERTIES_HXX + +#include "oox/drawingml/table/tablerow.hxx" +#include "oox/drawingml/table/tablestyle.hxx" +#include "oox/helper/propertymap.hxx" +#include "oox/drawingml/color.hxx" + +#include <boost/shared_ptr.hpp> +#include <boost/optional.hpp> +#include <vector> +#include <map> + +namespace oox { namespace drawingml { namespace table { + +class TableProperties +{ +public: + + TableProperties(); + ~TableProperties(); + + std::vector< sal_Int32 >& getTableGrid() { return mvTableGrid; }; + std::vector< TableRow >& getTableRows() { return mvTableRows; }; + + OUString& getStyleId(){ return maStyleId; }; + boost::shared_ptr< TableStyle >& getTableStyle(){ return mpTableStyle; }; + sal_Bool& isRtl(){ return mbRtl; }; + sal_Bool& isFirstRow(){ return mbFirstRow; }; + sal_Bool& isFirstCol(){ return mbFirstCol; }; + sal_Bool& isLastRow(){ return mbLastRow; }; + sal_Bool& isLastCol(){ return mbLastCol; }; + sal_Bool& isBandRow(){ return mbBandRow; }; + sal_Bool& isBandCol(){ return mbBandCol; }; + + void pushToPropSet( const ::oox::core::XmlFilterBase& rFilterBase, + const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > & xPropSet, ::oox::drawingml::TextListStylePtr pMasterTextListStyle ); + +private: + + const TableStyle& getUsedTableStyle( const ::oox::core::XmlFilterBase& rFilterBase ); + + OUString maStyleId; // either StyleId is available + boost::shared_ptr< TableStyle > mpTableStyle; // or the complete TableStyle + std::vector< sal_Int32 > mvTableGrid; + std::vector< TableRow > mvTableRows; + + sal_Bool mbRtl; + sal_Bool mbFirstRow; + sal_Bool mbFirstCol; + sal_Bool mbLastRow; + sal_Bool mbLastCol; + sal_Bool mbBandRow; + sal_Bool mbBandCol; +}; + +} } } + +#endif // OOX_DRAWINGML_TABLEPROPERTIES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/table/tablerow.hxx b/include/oox/drawingml/table/tablerow.hxx new file mode 100644 index 000000000000..299ffabfd8b1 --- /dev/null +++ b/include/oox/drawingml/table/tablerow.hxx @@ -0,0 +1,49 @@ +/* -*- 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 OOX_DRAWINGML_TABLEROW_HXX +#define OOX_DRAWINGML_TABLEROW_HXX + +#include "oox/drawingml/table/tablecell.hxx" +#include <vector> + +namespace oox { namespace drawingml { namespace table { + +class TableRow +{ +public: + + TableRow(); + ~TableRow(); + + void setHeight( sal_Int32 nHeight ){ mnHeight = nHeight; }; + sal_Int32 getHeight() const { return mnHeight; }; + std::vector< TableCell >& getTableCells() { return mvTableCells; }; + +private: + + sal_Int32 mnHeight; + std::vector< TableCell > mvTableCells; +}; + +} } } + +#endif // OOX_DRAWINGML_TABLEROW_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/table/tablerowcontext.hxx b/include/oox/drawingml/table/tablerowcontext.hxx new file mode 100644 index 000000000000..58ab0da0cd3a --- /dev/null +++ b/include/oox/drawingml/table/tablerowcontext.hxx @@ -0,0 +1,49 @@ +/* -*- 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 OOX_DRAWINGML_TABLEROWCONTEXT +#define OOX_DRAWINGML_TABLEROWCONTEXT + +#include "oox/core/contexthandler.hxx" + +namespace oox { namespace drawingml { namespace table { + +class TableRow; + +class TableRowContext : public ::oox::core::ContextHandler +{ +public: + TableRowContext( ::oox::core::ContextHandler& rParent, + const com::sun::star::uno::Reference< com::sun::star::xml::sax::XFastAttributeList >& xAttribs, TableRow& rTableRow ); + ~TableRowContext(); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +private: + + TableRow& mrTableRow; +}; + +} } } + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/table/tablestyle.hxx b/include/oox/drawingml/table/tablestyle.hxx new file mode 100644 index 000000000000..b31b5891a32b --- /dev/null +++ b/include/oox/drawingml/table/tablestyle.hxx @@ -0,0 +1,85 @@ +/* -*- 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 OOX_DRAWINGML_TABLESTYLE_HXX +#define OOX_DRAWINGML_TABLESTYLE_HXX + +#include "oox/drawingml/table/tablestylepart.hxx" +#include "oox/drawingml/drawingmltypes.hxx" +#include "oox/drawingml/shape.hxx" + +namespace oox { namespace drawingml { namespace table { + +class TableStyle +{ +public: + + TableStyle(); + ~TableStyle(); + + OUString& getStyleId(){ return maStyleId; } + OUString& getStyleName() { return maStyleName; } + + ::oox::drawingml::ShapeStyleRef& getBackgroundFillStyleRef(){ return maFillStyleRef; } + + ::oox::drawingml::FillPropertiesPtr& getBackgroundFillProperties(){ return mpFillProperties; } + + TableStylePart& getWholeTbl() { return maWholeTbl; } + TableStylePart& getBand1H() { return maBand1H; } + TableStylePart& getBand2H() { return maBand2H; } + TableStylePart& getBand1V() { return maBand1V; } + TableStylePart& getBand2V() { return maBand2V; } + TableStylePart& getLastCol() { return maLastCol; } + TableStylePart& getFirstCol() { return maFirstCol; } + TableStylePart& getLastRow() { return maLastRow; } + TableStylePart& getSeCell() { return maSeCell; } + TableStylePart& getSwCell() { return maSwCell; } + TableStylePart& getFirstRow() { return maFirstRow; } + TableStylePart& getNeCell() { return maNeCell; } + TableStylePart& getNwCell() { return maNwCell; } + +private: + + OUString maStyleId; + OUString maStyleName; + + ::oox::drawingml::ShapeStyleRef maFillStyleRef; + + ::oox::drawingml::FillPropertiesPtr mpFillProperties; + + TableStylePart maWholeTbl; + TableStylePart maBand1H; + TableStylePart maBand2H; + TableStylePart maBand1V; + TableStylePart maBand2V; + TableStylePart maLastCol; + TableStylePart maFirstCol; + TableStylePart maLastRow; + TableStylePart maSeCell; + TableStylePart maSwCell; + TableStylePart maFirstRow; + TableStylePart maNeCell; + TableStylePart maNwCell; +}; + +} } } + +#endif // OOX_DRAWINGML_TABLESTYLE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/table/tablestylecellstylecontext.hxx b/include/oox/drawingml/table/tablestylecellstylecontext.hxx new file mode 100644 index 000000000000..ae0997ab6d88 --- /dev/null +++ b/include/oox/drawingml/table/tablestylecellstylecontext.hxx @@ -0,0 +1,48 @@ +/* -*- 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 OOX_DRAWINGML_TABLESTYLECELLSTYLECONTEXT +#define OOX_DRAWINGML_TABLESTYLECELLSTYLECONTEXT + +#include "oox/core/contexthandler.hxx" +#include "oox/drawingml/table/tablestylepart.hxx" + +namespace oox { namespace drawingml { namespace table { + +class TableStyleCellStyleContext : public ::oox::core::ContextHandler +{ +public: + TableStyleCellStyleContext( ::oox::core::ContextHandler& rParent, TableStylePart& rTableStylePart ); + ~TableStyleCellStyleContext(); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +private: + + TableStylePart& mrTableStylePart; + sal_Int32 mnLineType; +}; + +} } } + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/table/tablestylecontext.hxx b/include/oox/drawingml/table/tablestylecontext.hxx new file mode 100644 index 000000000000..f9600d38365c --- /dev/null +++ b/include/oox/drawingml/table/tablestylecontext.hxx @@ -0,0 +1,49 @@ +/* -*- 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 OOX_DRAWINGML_TABLESTYLECONTEXT +#define OOX_DRAWINGML_TABLESTYLECONTEXT + +#include "oox/core/contexthandler.hxx" +#include "oox/drawingml/table/tablestyle.hxx" + +namespace oox { namespace drawingml { namespace table { + +class TableStyleContext : public ::oox::core::ContextHandler +{ +public: + TableStyleContext( ::oox::core::ContextHandler& rParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs, + TableStyle& rTableStyle ); + ~TableStyleContext(); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +private: + + TableStyle& mrTableStyle; +}; + +} } } + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/table/tablestylelist.hxx b/include/oox/drawingml/table/tablestylelist.hxx new file mode 100644 index 000000000000..320609d064d9 --- /dev/null +++ b/include/oox/drawingml/table/tablestylelist.hxx @@ -0,0 +1,54 @@ +/* -*- 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 OOX_DRAWINGML_TABLESTYLELIST_HXX +#define OOX_DRAWINGML_TABLESTYLELIST_HXX + +#include <rtl/ustring.hxx> +#include <boost/shared_ptr.hpp> +#include <vector> + +namespace oox { namespace drawingml { namespace table { + +class TableStyle; + +class TableStyleList +{ +public: + + TableStyleList(); + ~TableStyleList(); + + OUString& getDefaultStyleId() { return maDefaultStyleId; }; + std::vector< TableStyle >& getTableStyles(){ return maTableStyles; }; + +private: + + OUString maDefaultStyleId; + std::vector< TableStyle > maTableStyles; + +}; + +typedef boost::shared_ptr< TableStyleList > TableStyleListPtr; + +} } } + +#endif // OOX_DRAWINGML_TABLESTYLELIST_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/table/tablestylelistfragmenthandler.hxx b/include/oox/drawingml/table/tablestylelistfragmenthandler.hxx new file mode 100644 index 000000000000..d6ef77f8614c --- /dev/null +++ b/include/oox/drawingml/table/tablestylelistfragmenthandler.hxx @@ -0,0 +1,56 @@ +/* -*- 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 OOX_DRAWINGML_TABLESTYLELISTFRAGMENTHANDLER_HXX +#define OOX_DRAWINGML_TABLESTYLELISTFRAGMENTHANDLER_HXX + +#include "oox/drawingml/table/tablestylelist.hxx" +#include "oox/core/fragmenthandler2.hxx" + +namespace oox { +namespace drawingml { +namespace table { + +// ============================================================================ + +class TableStyleListFragmentHandler : public ::oox::core::FragmentHandler2 +{ +public: + explicit TableStyleListFragmentHandler( + ::oox::core::XmlFilterBase& rFilter, + const OUString& rFragmentPath, + TableStyleList& rTableStyleList ); + virtual ~TableStyleListFragmentHandler(); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +private: + + TableStyleList& mrTableStyleList; +}; + +// ============================================================================ + +} // namespace table +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/table/tablestylepart.hxx b/include/oox/drawingml/table/tablestylepart.hxx new file mode 100644 index 000000000000..abfb21c890d9 --- /dev/null +++ b/include/oox/drawingml/table/tablestylepart.hxx @@ -0,0 +1,73 @@ +/* -*- 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 OOX_DRAWINGML_TABLESTYLEPART_HXX +#define OOX_DRAWINGML_TABLESTYLEPART_HXX + +#include <rtl/ustring.hxx> +#include <boost/optional.hpp> +#include "oox/drawingml/color.hxx" +#include "oox/drawingml/textfont.hxx" +#include "oox/drawingml/fillproperties.hxx" +#include "oox/drawingml/lineproperties.hxx" +#include "oox/drawingml/shape.hxx" +#include <map> + +namespace oox { namespace drawingml { namespace table { + +class TableStylePart +{ +public: + + TableStylePart(); + ~TableStylePart(); + + ::oox::drawingml::Color& getTextColor(){ return maTextColor; } + ::boost::optional< sal_Bool >& getTextBoldStyle(){ return maTextBoldStyle; } + ::boost::optional< sal_Bool >& getTextItalicStyle(){ return maTextItalicStyle; } + ::oox::drawingml::TextFont& getAsianFont(){ return maAsianFont; } + ::oox::drawingml::TextFont& getComplexFont(){ return maComplexFont; } + ::oox::drawingml::TextFont& getSymbolFont(){ return maSymbolFont; } + ::oox::drawingml::TextFont& getLatinFont(){ return maLatinFont; } + + ::oox::drawingml::FillPropertiesPtr& getFillProperties(){ return mpFillProperties; } + std::map < sal_Int32, ::oox::drawingml::LinePropertiesPtr >& getLineBorders(){ return maLineBorders; } + + ::oox::drawingml::ShapeStyleRefMap& getStyleRefs(){ return maStyleRefs; } + +private: + + ::oox::drawingml::Color maTextColor; + ::boost::optional< sal_Bool > maTextBoldStyle; + ::boost::optional< sal_Bool > maTextItalicStyle; + ::oox::drawingml::TextFont maAsianFont; + ::oox::drawingml::TextFont maComplexFont; + ::oox::drawingml::TextFont maSymbolFont; + ::oox::drawingml::TextFont maLatinFont; + + ::oox::drawingml::FillPropertiesPtr mpFillProperties; + std::map < sal_Int32, ::oox::drawingml::LinePropertiesPtr > maLineBorders; + ::oox::drawingml::ShapeStyleRefMap maStyleRefs; +}; + +} } } + +#endif // OOX_DRAWINGML_TABLESTYLEPART_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/table/tablestyletextstylecontext.hxx b/include/oox/drawingml/table/tablestyletextstylecontext.hxx new file mode 100644 index 000000000000..10714743ad58 --- /dev/null +++ b/include/oox/drawingml/table/tablestyletextstylecontext.hxx @@ -0,0 +1,49 @@ +/* -*- 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 OOX_DRAWINGML_TABLESTYLETEXTSTYLECONTEXT +#define OOX_DRAWINGML_TABLESTYLETEXTSTYLECONTEXT + +#include "oox/core/contexthandler.hxx" +#include "oox/drawingml/table/tablestylepart.hxx" + +namespace oox { namespace drawingml { namespace table { + +class TableStyleTextStyleContext : public ::oox::core::ContextHandler +{ +public: + TableStyleTextStyleContext( ::oox::core::ContextHandler& rParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs, + TableStylePart& rTableStylePart ); + ~TableStyleTextStyleContext(); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +private: + + TableStylePart& mrTableStylePart; +}; + +} } } + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/textbody.hxx b/include/oox/drawingml/textbody.hxx new file mode 100644 index 000000000000..2d77cf277df6 --- /dev/null +++ b/include/oox/drawingml/textbody.hxx @@ -0,0 +1,73 @@ +/* -*- 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 OOX_DRAWINGML_TEXTBODY_HXX +#define OOX_DRAWINGML_TEXTBODY_HXX + +#include "oox/drawingml/drawingmltypes.hxx" +#include "oox/drawingml/textbodyproperties.hxx" +#include "oox/drawingml/textliststyle.hxx" + +namespace com { namespace sun { namespace star { + namespace text { class XText; } + namespace text { class XTextCursor; } +} } } + +namespace oox { namespace core { class XmlFilterBase; } } + +namespace oox { namespace drawingml { + +class TextParagraph; +typedef RefVector< TextParagraph > TextParagraphVector; + +class TextBody +{ +public: + TextBody(); + TextBody( TextBodyPtr pBody ); + ~TextBody(); + + inline const TextParagraphVector& getParagraphs() const { return maParagraphs; } + TextParagraph& addParagraph(); + + inline const TextListStyle& getTextListStyle() const { return maTextListStyle; } + inline TextListStyle& getTextListStyle() { return maTextListStyle; } + + inline const TextBodyProperties& getTextProperties() const { return maTextProperties; } + inline TextBodyProperties& getTextProperties() { return maTextProperties; } + + /** insert the text body at the text cursor */ + void insertAt( + const ::oox::core::XmlFilterBase& rFilterBase, + const ::com::sun::star::uno::Reference < ::com::sun::star::text::XText > & xText, + const ::com::sun::star::uno::Reference < ::com::sun::star::text::XTextCursor > & xAt, + const TextCharacterProperties& rTextStyleProperties, + const TextListStylePtr& pMasterTextListStyle ) const; + bool isEmpty(); +protected: + TextParagraphVector maParagraphs; + TextBodyProperties maTextProperties; + TextListStyle maTextListStyle; +}; + +} } + +#endif // OOX_DRAWINGML_TEXTBODY_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/textbodycontext.hxx b/include/oox/drawingml/textbodycontext.hxx new file mode 100644 index 000000000000..d46272e853a6 --- /dev/null +++ b/include/oox/drawingml/textbodycontext.hxx @@ -0,0 +1,63 @@ +/* -*- 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 OOX_DRAWINGML_TEXTBODYCONTEXT_HXX +#define OOX_DRAWINGML_TEXTBODYCONTEXT_HXX + +#include <com/sun/star/text/XText.hpp> + +#include "oox/drawingml/textbody.hxx" +#include "oox/drawingml/textrun.hxx" +#include "oox/core/contexthandler.hxx" + +namespace oox { namespace drawingml { + +class TextBodyContext : public ::oox::core::ContextHandler +{ +public: + TextBodyContext( ::oox::core::ContextHandler& rParent, TextBody& rTextBody ); + + virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +protected: + TextBody& mrTextBody; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > mxText; +}; + +// CT_RegularTextRun +class RegularTextRunContext : public ::oox::core::ContextHandler +{ +public: + RegularTextRunContext( ::oox::core::ContextHandler& rParent, TextRunPtr pRunPtr ); + + virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL characters( const OUString& aChars ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +protected: + TextRunPtr mpRunPtr; + bool mbIsInText; +}; + +} } + +#endif // OOX_DRAWINGML_TEXTBODYCONTEXT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/textbodyproperties.hxx b/include/oox/drawingml/textbodyproperties.hxx new file mode 100644 index 000000000000..f8800be29659 --- /dev/null +++ b/include/oox/drawingml/textbodyproperties.hxx @@ -0,0 +1,56 @@ +/* -*- 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 OOX_DRAWINGML_TEXTBODYPROPERTIES_HXX +#define OOX_DRAWINGML_TEXTBODYPROPERTIES_HXX + +#include <com/sun/star/drawing/TextVerticalAdjust.hpp> +#include "oox/helper/helper.hxx" +#include "oox/helper/propertymap.hxx" +#include <boost/optional.hpp> + +namespace oox { +namespace drawingml { + +// ============================================================================ + +struct TextBodyProperties +{ + PropertyMap maPropertyMap; + OptValue< sal_Int32 > moRotation; + OptValue< sal_Int32 > moVert; + boost::optional< sal_Int32 > moInsets[4]; + boost::optional< sal_Int32 > moTextOffX; + boost::optional< sal_Int32 > moTextOffY; + ::com::sun::star::drawing::TextVerticalAdjust meVA; + + explicit TextBodyProperties(); + + void pushRotationAdjustments( sal_Int32 nRotation ); + void pushVertSimulation(); +}; + +// ============================================================================ + +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/textbodypropertiescontext.hxx b/include/oox/drawingml/textbodypropertiescontext.hxx new file mode 100644 index 000000000000..e907a60b94d8 --- /dev/null +++ b/include/oox/drawingml/textbodypropertiescontext.hxx @@ -0,0 +1,47 @@ +/* -*- 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 OOX_DRAWINGML_TEXTBODYPROPERTIESCONTEXT_HXX +#define OOX_DRAWINGML_TEXTBODYPROPERTIESCONTEXT_HXX + +#include "oox/core/contexthandler.hxx" + +namespace oox { namespace drawingml { + +struct TextBodyProperties; + +class TextBodyPropertiesContext : public ::oox::core::ContextHandler +{ +public: + TextBodyPropertiesContext( ::oox::core::ContextHandler& rParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, + TextBodyProperties& rTextBodyProp ); + + virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +protected: + TextBodyProperties& mrTextBodyProp; +}; + +} } + +#endif // OOX_DRAWINGML_TEXTBODYPROPERTIESCONTEXT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/textcharacterproperties.hxx b/include/oox/drawingml/textcharacterproperties.hxx new file mode 100644 index 000000000000..99792fe7725d --- /dev/null +++ b/include/oox/drawingml/textcharacterproperties.hxx @@ -0,0 +1,84 @@ +/* -*- 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 OOX_DRAWINGML_TEXTCHARACTERPROPERTIES_HXX +#define OOX_DRAWINGML_TEXTCHARACTERPROPERTIES_HXX + +#include "oox/helper/helper.hxx" +#include "oox/helper/propertymap.hxx" +#include "oox/drawingml/color.hxx" +#include "oox/drawingml/textfont.hxx" + +namespace oox { class PropertySet; } + +namespace oox { +namespace drawingml { + +// ============================================================================ + +struct TextCharacterProperties +{ + PropertyMap maHyperlinkPropertyMap; + TextFont maLatinFont; + TextFont maAsianFont; + TextFont maComplexFont; + TextFont maSymbolFont; + Color maCharColor; + Color maUnderlineColor; + Color maHighlightColor; + OptValue< OUString > moLang; + OptValue< sal_Int32 > moHeight; + OptValue< sal_Int32 > moSpacing; + OptValue< sal_Int32 > moUnderline; + OptValue< sal_Int32 > moStrikeout; + OptValue< sal_Int32 > moCaseMap; + OptValue< bool > moBold; + OptValue< bool > moItalic; + OptValue< bool > moUnderlineLineFollowText; + OptValue< bool > moUnderlineFillFollowText; + + /** Overwrites all members that are explicitly set in rSourceProps. */ + void assignUsed( const TextCharacterProperties& rSourceProps ); + + /** Returns the current character size. If possible the masterstyle should + have been applied before, otherwise the character size can be zero and + the default value is returned. */ + float getCharHeightPoints( float fDefault ) const; + + /** Writes the properties to the passed property map. */ + void pushToPropMap( + PropertyMap& rPropMap, + const ::oox::core::XmlFilterBase& rFilter, + bool bUseOptional = false ) const; + + /** Writes the properties to the passed property set. */ + void pushToPropSet( + PropertySet& rPropSet, + const ::oox::core::XmlFilterBase& rFilter, + bool bUseOptional = false ) const; +}; + +// ============================================================================ + +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/textcharacterpropertiescontext.hxx b/include/oox/drawingml/textcharacterpropertiescontext.hxx new file mode 100644 index 000000000000..f31e86b27ca4 --- /dev/null +++ b/include/oox/drawingml/textcharacterpropertiescontext.hxx @@ -0,0 +1,48 @@ +/* -*- 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 OOX_DRAWINGML_TEXTCHARACTERPROPERTIESCONTEXT_HXX +#define OOX_DRAWINGML_TEXTCHARACTERPROPERTIESCONTEXT_HXX + +#include "oox/core/contexthandler.hxx" + +namespace oox { namespace drawingml { + +struct TextCharacterProperties; + +class TextCharacterPropertiesContext : public ::oox::core::ContextHandler +{ +public: + TextCharacterPropertiesContext( ::oox::core::ContextHandler& rParent, + const com::sun::star::uno::Reference< com::sun::star::xml::sax::XFastAttributeList >& rXAttributes, + TextCharacterProperties& rTextCharacterProperties ); + virtual ~TextCharacterPropertiesContext(); + + virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +protected: + TextCharacterProperties& mrTextCharacterProperties; +}; + +} } + +#endif // OOX_DRAWINGML_TEXTCHARACTERPROPERTIESCONTEXT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/textfield.hxx b/include/oox/drawingml/textfield.hxx new file mode 100644 index 000000000000..df98b0302560 --- /dev/null +++ b/include/oox/drawingml/textfield.hxx @@ -0,0 +1,62 @@ +/* -*- 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 OOX_DRAWINGML_TEXTFIELD_HXX +#define OOX_DRAWINGML_TEXTFIELD_HXX + +#include <boost/shared_ptr.hpp> + +#include "oox/drawingml/textrun.hxx" +#include "oox/drawingml/textparagraphproperties.hxx" + +namespace oox { namespace drawingml { + +struct TextCharacterProperties; + +class TextField + : public TextRun +{ +public: + TextField(); + + inline TextParagraphProperties& getTextParagraphProperties() { return maTextParagraphProperties; } + inline const TextParagraphProperties& getTextParagraphProperties() const { return maTextParagraphProperties; } + + inline void setType( const OUString& sType ) { msType = sType; } + inline void setUuid( const OUString & sUuid ) { msUuid = sUuid; } + + virtual sal_Int32 insertAt( + const ::oox::core::XmlFilterBase& rFilterBase, + const ::com::sun::star::uno::Reference < ::com::sun::star::text::XText > & xText, + const ::com::sun::star::uno::Reference < ::com::sun::star::text::XTextCursor > &xAt, + const TextCharacterProperties& rTextCharacterStyle ) const; + +private: + TextParagraphProperties maTextParagraphProperties; + OUString msType; + OUString msUuid; +}; + +typedef boost::shared_ptr< TextField > TextFieldPtr; + +} } + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/textfieldcontext.hxx b/include/oox/drawingml/textfieldcontext.hxx new file mode 100644 index 000000000000..3a50ea93620f --- /dev/null +++ b/include/oox/drawingml/textfieldcontext.hxx @@ -0,0 +1,52 @@ +/* -*- 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 OOX_DRAWINGML_TEXTFIELDCONTEXT_HXX +#define OOX_DRAWINGML_TEXTFIELDCONTEXT_HXX + +#include "oox/core/contexthandler.hxx" + +namespace oox { namespace drawingml { + +class TextField; + +class TextFieldContext + : public ::oox::core::ContextHandler +{ +public: + TextFieldContext( ::oox::core::ContextHandler& rParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rXAttributes, + TextField& rTextField); + virtual void SAL_CALL endFastElement( sal_Int32 aElementToken ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL characters( const OUString& aChars ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( + sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rXAttributes ) + throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +private: + TextField& mrTextField; + bool mbIsInText; +}; + +} } + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/textfont.hxx b/include/oox/drawingml/textfont.hxx new file mode 100644 index 000000000000..95a7a1716a0d --- /dev/null +++ b/include/oox/drawingml/textfont.hxx @@ -0,0 +1,73 @@ +/* -*- 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 OOX_DRAWINGNML_TEXTFONT_HXX +#define OOX_DRAWINGNML_TEXTFONT_HXX + +#include <rtl/ustring.hxx> + +namespace oox { class AttributeList; } +namespace oox { namespace core { class XmlFilterBase; } } + +namespace oox { +namespace drawingml { + +// ============================================================================ + +/** carries a CT_TextFont*/ +class TextFont +{ +public: + explicit TextFont(); + + /** Sets attributes from the passed attribute list. */ + void setAttributes( const AttributeList& rAttribs ); + + /** Overwrites this text font with the passed text font, if it is used. */ + void assignIfUsed( const TextFont& rTextFont ); + + /** Returns the font name, pitch, and family; tries to resolve theme + placeholder names, e.g. '+mj-lt' for the major latin theme font. */ + bool getFontData( + OUString& rFontName, + sal_Int16& rnFontPitch, + sal_Int16& rnFontFamily, + const ::oox::core::XmlFilterBase& rFilter ) const; + +private: + bool implGetFontData( + OUString& rFontName, + sal_Int16& rnFontPitch, + sal_Int16& rnFontFamily ) const; + +private: + OUString maTypeface; + OUString maPanose; + sal_Int32 mnPitch; + sal_Int32 mnCharset; +}; + +// ============================================================================ + +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/textliststyle.hxx b/include/oox/drawingml/textliststyle.hxx new file mode 100644 index 000000000000..851c506af17e --- /dev/null +++ b/include/oox/drawingml/textliststyle.hxx @@ -0,0 +1,61 @@ +/* -*- 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 OOX_DRAWINGML_TEXTLISTSTYLE_HXX +#define OOX_DRAWINGML_TEXTLISTSTYLE_HXX + +#include "oox/drawingml/textparagraphproperties.hxx" +#include "oox/helper/refvector.hxx" + +namespace oox { namespace drawingml { + +typedef RefVector< TextParagraphProperties > TextParagraphPropertiesVector; + +class TextListStyle +{ +public: + + TextListStyle(); + ~TextListStyle(); + + void apply( const TextListStyle& rTextListStyle ); + + inline const TextParagraphPropertiesVector& getListStyle() const { return maListStyle; }; + inline TextParagraphPropertiesVector& getListStyle() { return maListStyle; }; + + inline const TextParagraphPropertiesVector& getAggregationListStyle() const { return maAggregationListStyle; }; + inline TextParagraphPropertiesVector& getAggregationListStyle() { return maAggregationListStyle; }; + +#if defined(DBG_UTIL) && OSL_DEBUG_LEVEL > 1 + void dump() const; +#endif + +protected: + + TextParagraphPropertiesVector maListStyle; + TextParagraphPropertiesVector maAggregationListStyle; +}; + +typedef boost::shared_ptr< TextListStyle > TextListStylePtr; + +} } + +#endif // OOX_DRAWINGML_TEXTLISTSTYLE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/textliststylecontext.hxx b/include/oox/drawingml/textliststylecontext.hxx new file mode 100644 index 000000000000..2d480c709be5 --- /dev/null +++ b/include/oox/drawingml/textliststylecontext.hxx @@ -0,0 +1,45 @@ +/* -*- 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 OOX_DRAWINGML_TEXTLISTSTYLECONTEXT_HXX +#define OOX_DRAWINGML_TEXTLISTSTYLECONTEXT_HXX + +#include "oox/drawingml/textliststyle.hxx" +#include "oox/core/contexthandler.hxx" + +namespace oox { namespace drawingml { + +class TextListStyleContext : public ::oox::core::ContextHandler +{ +public: + TextListStyleContext( ::oox::core::ContextHandler& rParent, TextListStyle& rTextListStyle ); + ~TextListStyleContext(); + + virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +protected: + TextListStyle& mrTextListStyle; +}; + +} } + +#endif // OOX_DRAWINGML_TEXTLISTSTYLECONTEXT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/textparagraph.hxx b/include/oox/drawingml/textparagraph.hxx new file mode 100644 index 000000000000..37c53268b001 --- /dev/null +++ b/include/oox/drawingml/textparagraph.hxx @@ -0,0 +1,73 @@ +/* -*- 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 OOX_DRAWINGML_TEXTPARAGRAPH_HXX +#define OOX_DRAWINGML_TEXTPARAGRAPH_HXX + +#include <com/sun/star/text/XTextCursor.hpp> +#include <com/sun/star/text/XText.hpp> + +#include "oox/core/xmlfilterbase.hxx" +#include "oox/drawingml/textrun.hxx" +#include "oox/drawingml/textliststyle.hxx" +#include "oox/drawingml/textparagraphproperties.hxx" + +namespace oox { namespace drawingml { + +typedef RefVector< TextRun > TextRunVector; + +class TextParagraph +{ +public: + TextParagraph(); + ~TextParagraph(); + + inline TextRunVector& getRuns() { return maRuns; } + inline const TextRunVector& getRuns() const { return maRuns; } + inline void addRun( const TextRunPtr & pRun ) { maRuns.push_back( pRun ); } + + inline TextParagraphProperties& getProperties() { return maProperties; } + inline const TextParagraphProperties& getProperties() const { return maProperties; } + + inline TextCharacterProperties& getEndProperties() { return maEndProperties; } + inline const TextCharacterProperties& getEndProperties() const { return maEndProperties; } + + //inline void setProperties( TextParagraphPropertiesPtr pProps ) { mpProperties = pProps; } + + void insertAt( + const ::oox::core::XmlFilterBase& rFilterBase, + const ::com::sun::star::uno::Reference < ::com::sun::star::text::XText > & xText, + const ::com::sun::star::uno::Reference < ::com::sun::star::text::XTextCursor > &xAt, + const TextCharacterProperties& rTextStyleProperties, + const TextListStyle& rTextListStyle, + bool bFirst = false ) const; + +private: + TextParagraphProperties maProperties; + TextCharacterProperties maEndProperties; + TextRunVector maRuns; +}; + +typedef boost::shared_ptr< TextParagraph > TextParagraphPtr; + +} } + +#endif // OOX_DRAWINGML_TEXTPARAGRAPH_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/textparagraphproperties.hxx b/include/oox/drawingml/textparagraphproperties.hxx new file mode 100644 index 000000000000..1cb8215a3fc1 --- /dev/null +++ b/include/oox/drawingml/textparagraphproperties.hxx @@ -0,0 +1,128 @@ +/* -*- 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 OOX_DRAWINGML_TEXTPARAGRAPHPROPERTIES_HXX +#define OOX_DRAWINGML_TEXTPARAGRAPHPROPERTIES_HXX + +#include <com/sun/star/beans/XPropertySet.hpp> +#include "oox/drawingml/fillpropertiesgroupcontext.hxx" +#include "oox/drawingml/textcharacterproperties.hxx" +#include <com/sun/star/style/NumberingType.hpp> +#include "oox/drawingml/textfont.hxx" +#include "textspacing.hxx" +#include <boost/optional.hpp> + +namespace com { namespace sun { namespace star { + namespace graphic { class XGraphic; } +} } } + +namespace oox { namespace drawingml { + +class TextParagraphProperties; + +typedef boost::shared_ptr< TextParagraphProperties > TextParagraphPropertiesPtr; + +class BulletList +{ +public: + BulletList( ); + bool is() const; + void apply( const BulletList& ); + void pushToPropMap( const ::oox::core::XmlFilterBase* pFilterBase, PropertyMap& xPropMap ) const; + void setBulletChar( const OUString & sChar ); + void setStartAt( sal_Int32 nStartAt ){ mnStartAt <<= static_cast< sal_Int16 >( nStartAt ); } + void setType( sal_Int32 nType ); + void setNone( ); + void setSuffixParenBoth(); + void setSuffixParenRight(); + void setSuffixPeriod(); + void setSuffixNone(); + void setSuffixMinusRight(); + void setBulletSize(sal_Int16 nSize); + void setFontSize(sal_Int16 nSize); + void setStyleName( const OUString& rStyleName ) { maStyleName <<= rStyleName; } + void setGraphic( ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& rXGraphic ); + + ::oox::drawingml::ColorPtr maBulletColorPtr; + ::com::sun::star::uno::Any mbBulletColorFollowText; + ::com::sun::star::uno::Any mbBulletFontFollowText; + ::oox::drawingml::TextFont maBulletFont; + ::com::sun::star::uno::Any msBulletChar; + ::com::sun::star::uno::Any mnStartAt; + ::com::sun::star::uno::Any mnNumberingType; + ::com::sun::star::uno::Any msNumberingPrefix; + ::com::sun::star::uno::Any msNumberingSuffix; + ::com::sun::star::uno::Any mnSize; + ::com::sun::star::uno::Any mnFontSize; + ::com::sun::star::uno::Any maStyleName; + ::com::sun::star::uno::Any maGraphic; + boost::optional< float > maFollowFontSize; +}; + +class TextParagraphProperties +{ +public: + + TextParagraphProperties(); + ~TextParagraphProperties(); + + void setLevel( sal_Int16 nLevel ) { mnLevel = nLevel; } + sal_Int16 getLevel( ) const { return mnLevel; } + PropertyMap& getTextParagraphPropertyMap() { return maTextParagraphPropertyMap; } + BulletList& getBulletList() { return maBulletList; } + TextCharacterProperties& getTextCharacterProperties() { return maTextCharacterProperties; } + const TextCharacterProperties& getTextCharacterProperties() const { return maTextCharacterProperties; } + + TextSpacing& getParaTopMargin() { return maParaTopMargin; } + TextSpacing& getParaBottomMargin() { return maParaBottomMargin; } + boost::optional< sal_Int32 >& getParaLeftMargin(){ return moParaLeftMargin; } + boost::optional< sal_Int32 >& getFirstLineIndentation(){ return moFirstLineIndentation; } + + void apply( const TextParagraphProperties& rSourceProps ); + void pushToPropSet( const ::oox::core::XmlFilterBase* pFilterBase, + const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > & xPropSet, + PropertyMap& rioBulletList, const BulletList* pMasterBuList, sal_Bool bApplyBulletList, float fFontSize, bool bPushDefaultValues = false ) const; + void pushToPropSet( const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > & xPropSet) const; + + /** Returns the largest character size of this paragraph. If possible the + masterstyle should have been applied before, otherwise the character + size can be zero and the default value is returned. */ + float getCharHeightPoints( float fDefault ) const; + +#ifdef DBG_UTIL + void dump() const; +#endif + +protected: + + TextCharacterProperties maTextCharacterProperties; + PropertyMap maTextParagraphPropertyMap; + BulletList maBulletList; + TextSpacing maParaTopMargin; + TextSpacing maParaBottomMargin; + boost::optional< sal_Int32 > moParaLeftMargin; + boost::optional< sal_Int32 > moFirstLineIndentation; + sal_Int16 mnLevel; +}; + +} } + +#endif // OOX_DRAWINGML_TEXTPARAGRAPHPROPERTIES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/textparagraphpropertiescontext.hxx b/include/oox/drawingml/textparagraphpropertiescontext.hxx new file mode 100644 index 000000000000..db0f3426a680 --- /dev/null +++ b/include/oox/drawingml/textparagraphpropertiescontext.hxx @@ -0,0 +1,58 @@ +/* -*- 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 OOX_DRAWINGML_TEXTPARAGRAPHPROPERTIESCONTEXT_HXX +#define OOX_DRAWINGML_TEXTPARAGRAPHPROPERTIESCONTEXT_HXX + +#include <list> + +#include <com/sun/star/style/TabStop.hpp> +#include "oox/drawingml/drawingmltypes.hxx" +#include "oox/drawingml/textparagraphproperties.hxx" +#include "oox/drawingml/textspacing.hxx" +#include "oox/core/contexthandler.hxx" + +namespace oox { namespace drawingml { + +class TextParagraphPropertiesContext : public ::oox::core::ContextHandler +{ +public: + TextParagraphPropertiesContext( ::oox::core::ContextHandler& rParent, + const com::sun::star::uno::Reference< com::sun::star::xml::sax::XFastAttributeList >& rXAttributes, + TextParagraphProperties& rTextParagraphProperties ); + ~TextParagraphPropertiesContext(); + + virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +protected: + TextParagraphProperties& mrTextParagraphProperties; + TextSpacing maLineSpacing; + TextSpacing& mrSpaceBefore; + TextSpacing& mrSpaceAfter; + BulletList& mrBulletList; + ::std::list< ::com::sun::star::style::TabStop > maTabList; + ::boost::shared_ptr< BlipFillProperties > mxBlipProps; +}; + +} } + +#endif // OOX_DRAWINGML_TEXTPARAGRAPHPROPERTIESCONTEXT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/textrun.hxx b/include/oox/drawingml/textrun.hxx new file mode 100644 index 000000000000..0e215bf68973 --- /dev/null +++ b/include/oox/drawingml/textrun.hxx @@ -0,0 +1,62 @@ +/* -*- 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 OOX_DRAWINGML_TEXTRUN_HXX +#define OOX_DRAWINGML_TEXTRUN_HXX + +#include <com/sun/star/text/XTextCursor.hpp> +#include <com/sun/star/text/XText.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include "oox/drawingml/textcharacterproperties.hxx" + +namespace oox { namespace drawingml { + +class TextRun +{ +public: + TextRun(); + virtual ~TextRun(); + + inline OUString& getText() { return msText; } + inline const OUString& getText() const { return msText; } + + inline TextCharacterProperties& getTextCharacterProperties() { return maTextCharacterProperties; } + inline const TextCharacterProperties& getTextCharacterProperties() const { return maTextCharacterProperties; } + + inline void setLineBreak() { mbIsLineBreak = true; } + + virtual sal_Int32 insertAt( + const ::oox::core::XmlFilterBase& rFilterBase, + const ::com::sun::star::uno::Reference < ::com::sun::star::text::XText >& xText, + const ::com::sun::star::uno::Reference < ::com::sun::star::text::XTextCursor >& xAt, + const TextCharacterProperties& rTextCharacterStyle ) const; + +private: + OUString msText; + TextCharacterProperties maTextCharacterProperties; + bool mbIsLineBreak; +}; + +typedef boost::shared_ptr< TextRun > TextRunPtr; + +} } + +#endif // OOX_DRAWINGML_TEXTRUN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/textspacing.hxx b/include/oox/drawingml/textspacing.hxx new file mode 100644 index 000000000000..c85936283b4b --- /dev/null +++ b/include/oox/drawingml/textspacing.hxx @@ -0,0 +1,69 @@ +/* -*- 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 OOX_DRAWINGNML__TEXTSPACING_HXX +#define OOX_DRAWINGNML__TEXTSPACING_HXX + +#include <rtl/ustring.hxx> + +#include <com/sun/star/style/LineSpacing.hpp> +#include <com/sun/star/style/LineSpacingMode.hpp> + +namespace oox { namespace drawingml { + + + /** carries a CT_TextSpacing */ + class TextSpacing + { + public: + enum { + POINTS = 0, + PERCENT + }; + TextSpacing() + : nUnit( POINTS ), nValue( 0 ), bHasValue( false ) + { + } + TextSpacing( sal_Int32 nPoints ) : nUnit( POINTS ), nValue( nPoints ), bHasValue( true ){}; + ::com::sun::star::style::LineSpacing toLineSpacing() const + { + ::com::sun::star::style::LineSpacing aSpacing; + aSpacing.Mode = ( nUnit == PERCENT + ? ::com::sun::star::style::LineSpacingMode::PROP + : ::com::sun::star::style::LineSpacingMode::MINIMUM ); + aSpacing.Height = static_cast< sal_Int16 >( nUnit == PERCENT ? nValue / 1000 : nValue ); + return aSpacing; + } + sal_Int32 toMargin( float fFontSize ) const + { + if ( nUnit == PERCENT ) + return (sal_Int32) ((((fFontSize*nValue)/1000)*254 + 360)/720); + else + return nValue; + } + sal_Int32 nUnit; + sal_Int32 nValue; + bool bHasValue; + }; + +} } + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/theme.hxx b/include/oox/drawingml/theme.hxx new file mode 100644 index 000000000000..f167c43a4fd4 --- /dev/null +++ b/include/oox/drawingml/theme.hxx @@ -0,0 +1,116 @@ +/* -*- 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 OOX_DRAWINGML_THEME_HXX +#define OOX_DRAWINGML_THEME_HXX + +#include "oox/drawingml/clrscheme.hxx" +#include "oox/drawingml/shape.hxx" +#include "oox/drawingml/textfont.hxx" +#include <com/sun/star/xml/dom/XDocument.hpp> +#include "oox/dllapi.h" + +namespace oox { +namespace drawingml { + +// ============================================================================ + +const sal_Int32 THEMED_STYLE_SUBTLE = 1; +const sal_Int32 THEMED_STYLE_MODERATE = 2; +const sal_Int32 THEMED_STYLE_INTENSE = 3; + +typedef RefVector< FillProperties > FillStyleList; +typedef RefVector< LineProperties > LineStyleList; +typedef RefVector< EffectProperties > EffectStyleList; +typedef RefMap< sal_Int32, TextCharacterProperties > FontScheme; + +// ============================================================================ + +class OOX_DLLPUBLIC Theme +{ +public: + explicit Theme(); + ~Theme(); + + inline void setStyleName( const OUString& rStyleName ) { maStyleName = rStyleName; } + inline const OUString& getStyleName() const { return maStyleName; } + + inline ClrScheme& getClrScheme() { return maClrScheme; } + inline const ClrScheme& getClrScheme() const { return maClrScheme; } + + inline FillStyleList& getFillStyleList() { return maFillStyleList; } + inline const FillStyleList& getFillStyleList() const { return maFillStyleList; } + inline FillStyleList& getBgFillStyleList() { return maBgFillStyleList; } + inline const FillStyleList& getBgFillStyleList() const { return maBgFillStyleList; } + /** Returns the fill properties of the passed one-based themed style index. */ + const FillProperties* getFillStyle( sal_Int32 nIndex ) const; + + inline LineStyleList& getLineStyleList() { return maLineStyleList; } + inline const LineStyleList& getLineStyleList() const { return maLineStyleList; } + /** Returns the line properties of the passed one-based themed style index. */ + const LineProperties* getLineStyle( sal_Int32 nIndex ) const; + + inline EffectStyleList& getEffectStyleList() { return maEffectStyleList; } + inline const EffectStyleList& getEffectStyleList() const { return maEffectStyleList; } + const EffectProperties* getEffectStyle( sal_Int32 nIndex ) const; + + inline FontScheme& getFontScheme() { return maFontScheme; } + inline const FontScheme& getFontScheme() const { return maFontScheme; } + /** Returns theme font properties by scheme type (major/minor). */ + const TextCharacterProperties* getFontStyle( sal_Int32 nSchemeType ) const; + /** Returns theme font by placeholder name, e.g. the major latin theme font for the font name '+mj-lt'. */ + const TextFont* resolveFont( const OUString& rName ) const; + + inline Shape& getSpDef() { return maSpDef; } + inline const Shape& getSpDef() const { return maSpDef; } + + inline Shape& getLnDef() { return maLnDef; } + inline const Shape& getLnDef() const { return maLnDef; } + + inline Shape& getTxDef() { return maTxDef; } + inline const Shape& getTxDef() const { return maTxDef; } + + void setFragment( const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::dom::XDocument>& xRef ) { mxFragment=xRef; } + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::dom::XDocument>& getFragment() const { return mxFragment; } + +private: + OUString maStyleName; + ClrScheme maClrScheme; + FillStyleList maFillStyleList; + FillStyleList maBgFillStyleList; + LineStyleList maLineStyleList; + EffectStyleList maEffectStyleList; + FontScheme maFontScheme; + Shape maSpDef; + Shape maLnDef; + Shape maTxDef; + ::com::sun::star::uno::Reference< + ::com::sun::star::xml::dom::XDocument> mxFragment; +}; + +// ============================================================================ + +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/themeelementscontext.hxx b/include/oox/drawingml/themeelementscontext.hxx new file mode 100644 index 000000000000..a3d36a9d8225 --- /dev/null +++ b/include/oox/drawingml/themeelementscontext.hxx @@ -0,0 +1,51 @@ +/* -*- 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 OOX_DRAWINGML_THEMEELEMENTSCONTEXT_HXX +#define OOX_DRAWINGML_THEMEELEMENTSCONTEXT_HXX + +#include "oox/core/contexthandler.hxx" + +namespace oox { +namespace drawingml { + +class Theme; + +// ============================================================================ + +class ThemeElementsContext : public oox::core::ContextHandler +{ +public: + ThemeElementsContext( ::oox::core::ContextHandler& rParent, Theme& rTheme ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 nElement, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) + throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +private: + Theme& mrTheme; +}; + +// ============================================================================ + +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/themefragmenthandler.hxx b/include/oox/drawingml/themefragmenthandler.hxx new file mode 100644 index 000000000000..61062775fa37 --- /dev/null +++ b/include/oox/drawingml/themefragmenthandler.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 OOX_DRAWINGML_THEMEFRAGMENTHANDLER_HXX +#define OOX_DRAWINGML_THEMEFRAGMENTHANDLER_HXX + +#include "oox/core/fragmenthandler2.hxx" +#include "oox/dllapi.h" + +namespace oox { +namespace drawingml { + +class Theme; + +// ============================================================================ + +class OOX_DLLPUBLIC ThemeFragmentHandler : public ::oox::core::FragmentHandler2 +{ +public: + explicit ThemeFragmentHandler( + ::oox::core::XmlFilterBase& rFilter, + const OUString& rFragmentPath, + Theme& rTheme ); + virtual ~ThemeFragmentHandler(); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); + +private: + Theme& mrTheme; +}; + +// ============================================================================ + +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/transform2dcontext.hxx b/include/oox/drawingml/transform2dcontext.hxx new file mode 100644 index 000000000000..6bbbe191e77c --- /dev/null +++ b/include/oox/drawingml/transform2dcontext.hxx @@ -0,0 +1,52 @@ +/* -*- 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 OOX_DRAWINGML_TRANSFORM2DCONTEXT_HXX +#define OOX_DRAWINGML_TRANSFORM2DCONTEXT_HXX + +#include "oox/core/contexthandler.hxx" + +namespace oox { +namespace drawingml { + +// ============================================================================ + +class Shape; + +/** context to import a CT_Transform2D */ +class Transform2DContext : public ::oox::core::ContextHandler +{ +public: + Transform2DContext( ::oox::core::ContextHandler& rParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, Shape& rShape, bool btxXfrm = false ) throw(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + +protected: + Shape& mrShape; + bool mbtxXfrm; +}; + +// ============================================================================ + +} // namespace drawingml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |