diff options
Diffstat (limited to 'include/oox/drawingml')
-rw-r--r-- | include/oox/drawingml/chart/chartconverter.hxx | 100 | ||||
-rw-r--r-- | include/oox/drawingml/chart/datasourcemodel.hxx | 66 | ||||
-rw-r--r-- | include/oox/drawingml/chart/modelbase.hxx | 121 | ||||
-rw-r--r-- | include/oox/drawingml/clrscheme.hxx | 103 | ||||
-rw-r--r-- | include/oox/drawingml/color.hxx | 167 | ||||
-rw-r--r-- | include/oox/drawingml/connectorshapecontext.hxx | 59 | ||||
-rw-r--r-- | include/oox/drawingml/diagram/diagram.hxx | 51 | ||||
-rw-r--r-- | include/oox/drawingml/drawingmltypes.hxx | 235 | ||||
-rw-r--r-- | include/oox/drawingml/graphicshapecontext.hxx | 111 | ||||
-rw-r--r-- | include/oox/drawingml/shape.hxx | 430 | ||||
-rw-r--r-- | include/oox/drawingml/shapecontext.hxx | 53 | ||||
-rw-r--r-- | include/oox/drawingml/shapegroupcontext.hxx | 45 | ||||
-rw-r--r-- | include/oox/drawingml/shapepropertymap.hxx | 168 | ||||
-rw-r--r-- | include/oox/drawingml/theme.hxx | 123 | ||||
-rw-r--r-- | include/oox/drawingml/themefragmenthandler.hxx | 57 |
15 files changed, 1889 insertions, 0 deletions
diff --git a/include/oox/drawingml/chart/chartconverter.hxx b/include/oox/drawingml/chart/chartconverter.hxx new file mode 100644 index 000000000..fcf3b2fee --- /dev/null +++ b/include/oox/drawingml/chart/chartconverter.hxx @@ -0,0 +1,100 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_CHARTCONVERTER_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_CHARTCONVERTER_HXX + +#include <com/sun/star/uno/Reference.hxx> +#include <oox/dllapi.h> +#include <rtl/ustring.hxx> + +namespace com::sun::star { + namespace awt { struct Point; } + namespace awt { struct Size; } + namespace drawing { class XShapes; } + namespace chart2 { class XChartDocument; } + namespace chart2::data { class XDataProvider; } + namespace chart2::data { class XDataSequence; } +} + +namespace oox::core { class XmlFilterBase; } + +namespace oox::drawingml::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 css::uno::Reference< css::chart2::XChartDocument >& rxChartDoc, + const css::uno::Reference< css::drawing::XShapes >& rxExternalPage, + const css::awt::Point& rChartPos, + const css::awt::Size& rChartSize ); + + /** Creates an internal data provider. Derived classes may override this + function to create an external data provider. */ + virtual void createDataProvider( + const css::uno::Reference< css::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 css::uno::Reference<css::chart2::data::XDataSequence> + createDataSequence( + const css::uno::Reference<css::chart2::data::XDataProvider>& rxDataProvider, + const DataSequenceModel& rDataSeq, const OUString& rRole, + const OUString& aRoleQualifier ); + +private: + ChartConverter( const ChartConverter& ) = delete; + ChartConverter& operator=( const ChartConverter& ) = delete; +}; + + +} // namespace oox::drawingml::chart + +#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 000000000..49b8dcd90 --- /dev/null +++ b/include/oox/drawingml/chart/datasourcemodel.hxx @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_DATASOURCEMODEL_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_DATASOURCEMODEL_HXX + +#include <map> + +#include <com/sun/star/uno/Any.hxx> +#include <oox/drawingml/chart/modelbase.hxx> +#include <rtl/ustring.hxx> +#include <sal/types.h> + +enum class SvNumFormatType : sal_Int16; + +namespace oox::drawingml::chart { + + +struct DataSequenceModel +{ + typedef ::std::map< sal_Int32, css::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. + sal_Int32 mnLevelCount; /// Number of category levels. + SvNumFormatType meFormatType; /// Type of number format in maFormatCode. + + explicit DataSequenceModel(); + ~DataSequenceModel(); +}; + + +struct DataSourceModel +{ + typedef ModelRef< DataSequenceModel > DataSequenceRef; + + DataSequenceRef mxDataSeq; /// The data sequence or formula link of this source. + + explicit DataSourceModel(); + ~DataSourceModel(); +}; + + +} // namespace oox::drawingml::chart + +#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 000000000..581713bbc --- /dev/null +++ b/include/oox/drawingml/chart/modelbase.hxx @@ -0,0 +1,121 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CHART_MODELBASE_HXX +#define INCLUDED_OOX_DRAWINGML_CHART_MODELBASE_HXX + +#include <memory> + +#include <oox/helper/refmap.hxx> +#include <oox/helper/refvector.hxx> +#include <rtl/ustring.hxx> +#include <sal/types.h> + +namespace oox { class AttributeList; } + +namespace oox::drawingml::chart { + +template< typename ModelType > +class ModelRef : public std::shared_ptr< ModelType > +{ +public: + ModelRef() {} + ModelRef( const std::shared_ptr< ModelType >& rxModel ) : std::shared_ptr< ModelType >( rxModel ) {} + + bool is() const { return this->get() != nullptr; } + + ModelType& create() { (*this) = std::make_shared<ModelType>(); return **this; } + template< typename Param1Type > + ModelType& create( const Param1Type& rParam1 ) { (*this) = std::make_shared<ModelType>( rParam1 ); return **this; } + template< typename Param1Type, typename Param2Type > + ModelType& create( const Param1Type& rParam1, const Param2Type& rParam2 ) { (*this) = std::make_shared<ModelType>( rParam1, rParam2 ); return **this; } + + ModelType& getOrCreate() { if( !*this ) (*this) = std::make_shared<ModelType>(); return **this; } + template< typename Param1Type > + ModelType& getOrCreate( const Param1Type& rParam1 ) { if( !*this ) (*this) = std::make_shared<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; + + ModelType& create() { return append( std::make_shared<ModelType>() ); } + template< typename Param1Type > + ModelType& create( const Param1Type& rParam1 ) { return append( std::make_shared<ModelType>( rParam1 ) ); } + template< typename Param1Type, typename Param2Type > + ModelType& create( const Param1Type& rParam1, const Param2Type& rParam2 ) { return append( std::make_shared<ModelType>( rParam1, rParam2 ) ); } + +private: + ModelType& append( std::shared_ptr<ModelType> pModel ) + { + assert(pModel); + auto pTmp = pModel.get(); + this->push_back( std::move(pModel) ); + return *pTmp; + } +}; + +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; + + ModelType& create( KeyType eKey ) { return insert( eKey, new ModelType ); } + +private: + 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. + + 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. + + LayoutModel(); +}; + +} // namespace oox::drawingml::chart + +#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 000000000..a4f0b6534 --- /dev/null +++ b/include/oox/drawingml/clrscheme.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 INCLUDED_OOX_DRAWINGML_CLRSCHEME_HXX +#define INCLUDED_OOX_DRAWINGML_CLRSCHEME_HXX + +#include <cstddef> +#include <map> +#include <memory> +#include <utility> +#include <vector> + +#include <oox/dllapi.h> +#include <sal/types.h> +#include <rtl/ustring.hxx> +#include <tools/color.hxx> + +namespace oox::drawingml { + +enum PredefinedClrSchemeId { + dk1 = 0, + lt1, + dk2, + lt2, + accent1, + accent2, + accent3, + accent4, + accent5, + accent6, + hlink, + folHlink, + Count +}; + +static std::map<PredefinedClrSchemeId, OUString> PredefinedClrNames = +{ + { dk1, "dk1" }, + { lt1, "lt1" }, + { dk2, "dk2" }, + { lt2, "lt2" }, + { accent1, "accent1" }, + { accent2, "accent2" }, + { accent3, "accent3" }, + { accent4, "accent4" }, + { accent5, "accent5" }, + { accent6, "accent6" }, + { hlink, "hlink" }, + { folHlink, "folHlink" } +}; + +class ClrMap +{ + std::map < sal_Int32, sal_Int32 > maClrMap; + +public: + + bool getColorMap( sal_Int32& nClrToken ); + void setColorMap( sal_Int32 nClrToken, sal_Int32 nMappedClrToken ); +}; + +typedef std::shared_ptr< ClrMap > ClrMapPtr; + +class OOX_DLLPUBLIC ClrScheme +{ + std::vector< std::pair<sal_Int32, ::Color> > maClrScheme; + OUString maName; + +public: + + bool getColor( sal_Int32 nSchemeClrToken, ::Color& rColor ) const; + void setColor( sal_Int32 nSchemeClrToken, ::Color nColor ); + + bool getColorByIndex(size_t nIndex, + ::Color& rColor) const; + + void SetName(const OUString& rName) { maName = rName; } + const OUString& GetName() const { return maName; } + + void ToAny(css::uno::Any& rVal) const; +}; + +} + +#endif // INCLUDED_OOX_DRAWINGML_CLRSCHEME_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 000000000..b28c92698 --- /dev/null +++ b/include/oox/drawingml/color.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 INCLUDED_OOX_DRAWINGML_COLOR_HXX +#define INCLUDED_OOX_DRAWINGML_COLOR_HXX + +#include <vector> + +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/uno/Sequence.hxx> +#include <oox/helper/helper.hxx> +#include <oox/dllapi.h> +#include <rtl/ustring.hxx> +#include <sal/types.h> +#include <tools/color.hxx> + +namespace oox { class GraphicHelper; } + +namespace oox::drawingml { + + +class OOX_DLLPUBLIC Color +{ +public: + Color(); + + /** Returns the RGB value for the passed DrawingML color token, or nDefaultRgb on error. */ + static ::Color getDmlPresetColor( sal_Int32 nToken, ::Color nDefaultRgb ); + /** Returns the RGB value for the passed VML color token, or nDefaultRgb on error. */ + static ::Color getVmlPresetColor( sal_Int32 nToken, ::Color nDefaultRgb ); + /** Returns the RGB value for the passed VML color token, or nDefaultRgb on error. */ + static ::Color getHighlightColor(sal_Int32 nToken, ::Color 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 ); + void setSrgbClr( ::Color 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 predefined color from the w:highlight element. */ + void setHighlight(sal_Int32 nToken); + /** Sets a scheme color from the a:schemeClr element. */ + void setSchemeClr( sal_Int32 nToken ); + /** Sets the scheme name from the a:schemeClr element for interoperability purposes */ + void setSchemeName( const OUString& sSchemeName ) { msSchemeName = sSchemeName; } + /** 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. */ + 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. */ + ::Color getColor( const GraphicHelper& rGraphicHelper, ::Color 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; + + /** Returns the scheme name from the a:schemeClr element for interoperability purposes */ + const OUString& getSchemeColorName() const { return msSchemeName; } + sal_Int16 getSchemeColorIndex() const; + sal_Int16 getTintOrShade() const; + sal_Int16 getLumMod() const; + sal_Int16 getLumOff() const; + + /** Returns the unaltered list of transformations for interoperability purposes */ + const css::uno::Sequence< css::beans::PropertyValue >& getTransformations() const { return maInteropTransformations;} + + /** Translates between color transformation tokens and their names */ + static OUString getColorTransformationName( sal_Int32 nElement ); + /** Translates between color transformation token names and the corresponding token */ + static sal_Int32 getColorTransformationToken( std::u16string_view sName ); + + /// Compares this color with rOther. + bool equals(const Color& rOther, const GraphicHelper& rGraphicHelper, ::Color nPhClr) const; + +private: + /** Internal helper for getColor(). */ + void setResolvedRgb( ::Color 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 ) {} + }; + + mutable ColorMode meMode; /// Current color mode. + mutable std::vector< Transformation > + 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). + + OUString msSchemeName; /// Scheme name from the a:schemeClr element for interoperability purposes + css::uno::Sequence< css::beans::PropertyValue > + maInteropTransformations; /// Unaltered list of transformations for interoperability purposes +}; + +} // namespace oox::drawingml + +#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 000000000..c9819ae85 --- /dev/null +++ b/include/oox/drawingml/connectorshapecontext.hxx @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_CONNECTORSHAPECONTEXT_HXX +#define INCLUDED_OOX_DRAWINGML_CONNECTORSHAPECONTEXT_HXX + +#include <oox/core/contexthandler.hxx> +#include <oox/dllapi.h> +#include <oox/drawingml/drawingmltypes.hxx> +#include <oox/drawingml/shapecontext.hxx> +#include <sal/types.h> +#include <vector> + +namespace oox { class AttributeList; } +namespace oox::core { class ContextHandler2Helper; } + +namespace oox::drawingml { + + struct ConnectorShapeProperties + { + bool mbStartShape; + OUString maDestShapeId; + sal_Int32 mnDestGlueId; + }; + +class OOX_DLLPUBLIC ConnectorShapeContext final : public ShapeContext +{ + std::vector<ConnectorShapeProperties>& mrConnectorShapePropertiesList; + ShapePtr mpConnectorShapePtr; + +public: + ConnectorShapeContext(::oox::core::ContextHandler2Helper const& rParent, + const ShapePtr& pMasterShapePtr, const ShapePtr& pGroupShapePtr, + std::vector<ConnectorShapeProperties>& rConnectorShapePropertiesList); + virtual ~ConnectorShapeContext() override; + virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) override; +}; + +} + +#endif // INCLUDED_OOX_DRAWINGML_CONNECTORSHAPECONTEXT_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 000000000..b3e79d461 --- /dev/null +++ b/include/oox/drawingml/diagram/diagram.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 INCLUDED_OOX_DRAWINGML_DIAGRAM_DIAGRAM_HXX +#define INCLUDED_OOX_DRAWINGML_DIAGRAM_DIAGRAM_HXX + +#include <rtl/ustring.hxx> +#include <oox/core/xmlfilterbase.hxx> +#include <oox/drawingml/drawingmltypes.hxx> +#include <svx/svdobj.hxx> + +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/xml/dom/XDocument.hpp> + +namespace oox::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 const & pShape, + core::XmlFilterBase& rFilter, + const OUString& rDataModelPath, + const OUString& rLayoutPath, + const OUString& rQStylePath, + const OUString& rColorStylePath, + const oox::core::Relations& rRelations ); + +} + +#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 000000000..5fe86d564 --- /dev/null +++ b/include/oox/drawingml/drawingmltypes.hxx @@ -0,0 +1,235 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_DRAWINGMLTYPES_HXX +#define INCLUDED_OOX_DRAWINGML_DRAWINGMLTYPES_HXX + +#include <memory> +#include <string_view> + +#include <com/sun/star/awt/Point.hpp> +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/drawing/TextVerticalAdjust.hpp> +#include <com/sun/star/geometry/IntegerRectangle2D.hpp> +#include <com/sun/star/style/ParagraphAdjust.hpp> +#include <com/sun/star/style/TabAlign.hpp> +#include <com/sun/star/uno/Reference.hxx> +#include <o3tl/unit_conversion.hxx> +#include <oox/dllapi.h> +#include <rtl/ustring.hxx> +#include <sal/types.h> + +namespace com::sun::star { + namespace drawing { struct Hatch; } + namespace xml::sax { class XFastAttributeList; } +} + +namespace oox::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 std::shared_ptr< LineProperties > LinePropertiesPtr; + +struct FillProperties; +typedef std::shared_ptr< FillProperties > FillPropertiesPtr; + +struct GraphicProperties; +typedef std::shared_ptr< GraphicProperties > GraphicPropertiesPtr; + +struct Shape3DProperties; +typedef std::shared_ptr< Shape3DProperties > Shape3DPropertiesPtr; + +struct TextCharacterProperties; +typedef std::shared_ptr< TextCharacterProperties > TextCharacterPropertiesPtr; + +struct EffectProperties; +typedef std::shared_ptr< EffectProperties > EffectPropertiesPtr; + +class TextBody; +typedef std::shared_ptr< TextBody > TextBodyPtr; + +class TextListStyle; +typedef std::shared_ptr< TextListStyle > TextListStylePtr; + +class Shape; +typedef std::shared_ptr< Shape > ShapePtr; +typedef std::weak_ptr< Shape > WeakShapePtr; + +class Theme; +typedef std::shared_ptr< Theme > ThemePtr; + + +namespace table { + +class TableProperties; +typedef std::shared_ptr< TableProperties > TablePropertiesPtr; + +} // namespace table + + +/** converts the attributes from a CT_TLPoint into an awt Point with 1/1000% */ +css::awt::Point GetPointPercent( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttribs ); + + +/** converts the attributes from a CT_Size2D into an awt Size with 1/100th mm */ +css::awt::Size GetSize2D( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttributes ); + +/** converts the attributes from a CT_RelativeRect to an IntegerRectangle2D */ +css::geometry::IntegerRectangle2D GetRelativeRect( const css::uno::Reference< css::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( std::u16string_view sValue ); + +/** converts 1/100mm to EMU */ +sal_Int32 GetPointFromCoordinate( sal_Int32 nValue ); + +/** converts a ST_Percentage % string into 1/1000th of % */ +sal_Int32 GetPercent( std::u16string_view sValue ); + +/** Converts a ST_PositiveFixedPercentage to a float. 1.0 == 100% */ +double GetPositiveFixedPercentage( const OUString& sValue ); + +/** converts the ST_TextFontSize to point */ +float GetTextSize( std::u16string_view rValue ); + +/** converts the ST_TextSpacingPoint to 1/100mm */ +sal_Int32 GetTextSpacingPoint( std::u16string_view sValue ); +sal_Int32 GetTextSpacingPoint( const sal_Int32 nValue ); + +/** */ +css::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 */ +css::style::ParagraphAdjust GetParaAdjust( sal_Int32 nAlign ); + +// Converts vertical adjust tokens to a TextVerticalAdjust item +css::drawing::TextVerticalAdjust GetTextVerticalAdjust( sal_Int32 nToken ); + +// Converts a TextVerticalAdjust item to string value appearing in ooxml +OOX_DLLPUBLIC const char* GetTextVerticalAdjust( css::drawing::TextVerticalAdjust eAdjust ); + +// Converts a Hatch object to an ooxml pattern. +const char* GetHatchPattern( const css::drawing::Hatch& rHatch ); + + +// CT_IndexRange +struct IndexRange { + sal_Int32 start; + sal_Int32 end; +}; + +/** retrieve the content of CT_IndexRange */ +IndexRange GetIndexRange( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttributes ); + +/** +* nRotation is a 100th of a degree and the return value is +* in a 60,000th of a degree +* +* Also rotation is in opposite directions so multiply with -1 +*/ +inline OString calcRotationValue(sal_Int32 nRotation) +{ + if (nRotation > 18000) // 180 degree + { + nRotation -= 36000; + } + nRotation *= -600; + return OString::number(nRotation); +} + +/** Converts the passed 32-bit integer value from 1/100 mm to EMUs. */ +inline sal_Int64 convertHmmToEmu( sal_Int32 nValue ) +{ + return o3tl::convert(nValue, o3tl::Length::mm100, o3tl::Length::emu); +} + +/** Converts the passed 64-bit integer value from EMUs to 1/100 mm. */ +inline sal_Int32 convertEmuToHmm( sal_Int64 nValue ) +{ + return o3tl::convertNarrowing<sal_Int32, o3tl::Length::emu, o3tl::Length::mm100>(nValue); +} + +/** Converts the passed 64-bit integer value from EMUs to Points. */ +inline float convertEmuToPoints( sal_Int64 nValue ) +{ + return o3tl::convert<double>(nValue, o3tl::Length::emu, o3tl::Length::pt); +} + +/** Converts the passed double value from points to mm. */ +inline double convertPointToMms(double fValue) +{ + return o3tl::convert(fValue, o3tl::Length::pt, o3tl::Length::mm); +} + +/** A structure for a point with 64-bit integer components. */ +struct EmuPoint +{ + sal_Int64 X; + sal_Int64 Y; + + EmuPoint() : X( 0 ), Y( 0 ) {} + explicit EmuPoint( sal_Int64 nX, sal_Int64 nY ) : X( nX ), Y( nY ) {} +}; + + +/** A structure for a size with 64-bit integer components. */ +struct EmuSize +{ + sal_Int64 Width; + sal_Int64 Height; + + EmuSize() : Width( 0 ), Height( 0 ) {} + explicit EmuSize( sal_Int64 nWidth, sal_Int64 nHeight ) : Width( nWidth ), Height( nHeight ) {} +}; + + +/** A structure for a rectangle with 64-bit integer components. */ +struct EmuRectangle : public EmuPoint, public EmuSize +{ + EmuRectangle() {} + explicit EmuRectangle( sal_Int64 nX, sal_Int64 nY, sal_Int64 nWidth, sal_Int64 nHeight ) : EmuPoint( nX, nY ), EmuSize( nWidth, nHeight ) {} + + void setPos( const EmuPoint& rPos ) { static_cast< EmuPoint& >( *this ) = rPos; } + void setSize( const EmuSize& rSize ) { static_cast< EmuSize& >( *this ) = rSize; } +}; + + +} // namespace oox::drawingml + +#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 000000000..ffd579f00 --- /dev/null +++ b/include/oox/drawingml/graphicshapecontext.hxx @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_GRAPHICSHAPECONTEXT_HXX +#define INCLUDED_OOX_DRAWINGML_GRAPHICSHAPECONTEXT_HXX + +#include <oox/core/contexthandler.hxx> +#include <oox/dllapi.h> +#include <oox/drawingml/drawingmltypes.hxx> +#include <oox/drawingml/shapecontext.hxx> +#include <rtl/ustring.hxx> +#include <sal/types.h> + +namespace oox { class AttributeList; } +namespace oox::core { class ContextHandler2Helper; } +namespace oox::vml { struct OleObjectInfo; } + +namespace oox::drawingml { + +class OOX_DLLPUBLIC GraphicShapeContext : public ShapeContext +{ +public: + GraphicShapeContext( ::oox::core::ContextHandler2Helper const & rParent, const ShapePtr& pMasterShapePtr, const ShapePtr& pShapePtr ); + + virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) override; +}; + + +class OOX_DLLPUBLIC GraphicalObjectFrameContext final : public ShapeContext +{ +public: + GraphicalObjectFrameContext( ::oox::core::ContextHandler2Helper& rParent, const ShapePtr& pMasterShapePtr, const ShapePtr& pShapePtr, bool bEmbedShapesInChart ); + + virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) override; + virtual void onEndElement() override; + +private: + bool mbEmbedShapesInChart; + ::oox::core::ContextHandler2Helper* mpParent; +}; + + +class OleObjectGraphicDataContext final : public ShapeContext +{ +public: + OleObjectGraphicDataContext( ::oox::core::ContextHandler2Helper const & rParent, const ShapePtr& pShapePtr ); + virtual ~OleObjectGraphicDataContext() override; + virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) override; + virtual void onEndElement() override; + +private: + ::oox::vml::OleObjectInfo& mrOleObjectInfo; +}; + + +class DiagramGraphicDataContext final + : public ShapeContext +{ +public: + DiagramGraphicDataContext( ::oox::core::ContextHandler2Helper const & rParent, const ShapePtr& pShapePtr ); + virtual ~DiagramGraphicDataContext() override; + virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) override; + +private: + OUString msDm; + OUString msLo; + OUString msQs; + OUString msCs; +}; + + +struct ChartShapeInfo; + +class ChartGraphicDataContext final : public ShapeContext +{ +public: + explicit ChartGraphicDataContext( + ::oox::core::ContextHandler2Helper const & rParent, + const ShapePtr& rxShape, bool bEmbedShapes ); + + virtual ::oox::core::ContextHandlerRef + onCreateContext( + sal_Int32 nElement, + const ::oox::AttributeList& rAttribs) override; + +private: + ChartShapeInfo& mrChartShapeInfo; +}; + + +} + +#endif // INCLUDED_OOX_DRAWINGML_GRAPHICSHAPECONTEXT_HXX + +/* 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 000000000..5c4f788cd --- /dev/null +++ b/include/oox/drawingml/shape.hxx @@ -0,0 +1,430 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_SHAPE_HXX +#define INCLUDED_OOX_DRAWINGML_SHAPE_HXX + +#include <map> +#include <memory> +#include <string_view> +#include <vector> + +#include <com/sun/star/awt/Point.hpp> +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Sequence.hxx> + +#include <oox/core/xmlfilterbase.hxx> +#include <oox/dllapi.h> +#include <oox/drawingml/color.hxx> +#include <oox/drawingml/connectorshapecontext.hxx> +#include <oox/drawingml/drawingmltypes.hxx> +#include <oox/helper/helper.hxx> +#include <oox/helper/propertymap.hxx> +#include <rtl/ustring.hxx> +#include <sal/types.h> + +namespace basegfx { class B2DHomMatrix; } + +namespace com::sun::star { + namespace awt { struct Rectangle; } + namespace drawing { class XShape; } + namespace drawing { class XShapes; } + namespace uno { class Any; } +} + +namespace oox::core { + class XmlFilterBase; +} + +namespace oox::vml { + struct OleObjectInfo; +} + +namespace svx::diagram { + class IDiagramHelper; +} + +namespace oox::drawingml { + +class Theme; +struct EffectProperties; +struct FillProperties; +struct GraphicProperties; +struct LineProperties; +struct Shape3DProperties; + +class CustomShapeProperties; +typedef std::shared_ptr< CustomShapeProperties > CustomShapePropertiesPtr; + +typedef ::std::map< OUString, ShapePtr > ShapeIdMap; + +typedef std::vector<ConnectorShapeProperties> ConnectorShapePropertiesList; + +struct ShapeStyleRef +{ + Color maPhClr; + sal_Int32 mnThemedIdx; + ShapeStyleRef() : mnThemedIdx(0) {} +}; + +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. + + explicit ChartShapeInfo( bool bEmbedShapes ) : mbEmbedShapes( bEmbedShapes ) {} +}; + +/// Attributes for a linked textbox. +struct LinkedTxbxAttr +{ + sal_Int32 id; + sal_Int32 seq; + LinkedTxbxAttr(): id(0),seq(0){}; +}; + +class Diagram; + +class OOX_DLLPUBLIC Shape + : public std::enable_shared_from_this< Shape > +{ +public: + + explicit Shape( const char* pServiceType = nullptr, bool bDefaultHeight = true ); + explicit Shape( const ShapePtr& pSourceShape ); + Shape(Shape const &) = default; + virtual ~Shape(); + Shape & operator =(Shape const &) = default; + + OUString& getServiceName(){ return msServiceName; } + void setServiceName( const char* pServiceName ); + + const OUString& getDiagramDataModelID() const { return msDiagramDataModelID; } + void setDiagramDataModelID( const OUString& rDiagramDataModelID ) { msDiagramDataModelID = rDiagramDataModelID; } + + PropertyMap& getShapeProperties(){ return maShapeProperties; } + + LineProperties& getLineProperties() { return *mpLinePropertiesPtr; } + const LineProperties& getLineProperties() const { return *mpLinePropertiesPtr; } + + FillProperties& getFillProperties() { return *mpFillPropertiesPtr; } + const FillProperties& getFillProperties() const { return *mpFillPropertiesPtr; } + + GraphicProperties& getGraphicProperties() { return *mpGraphicPropertiesPtr; } + const GraphicProperties& getGraphicProperties() const { return *mpGraphicPropertiesPtr; } + + CustomShapePropertiesPtr& getCustomShapeProperties(){ return mpCustomShapePropertiesPtr; } + + OUString& getConnectorName() { return msConnectorName; } + ConnectorShapePropertiesList& getConnectorShapeProperties() { return maConnectorShapePropertiesList; } + void setConnectorShape(bool bConnector) { mbConnector = bConnector; } + bool isConnectorShape() const { return mbConnector; } + + void setBookmark(bool bBookmark) { mbHasBookmark = bBookmark; } + bool hasBookmark() const { return mbHasBookmark; } + + Shape3DProperties& get3DProperties() { return *mp3DPropertiesPtr; } + const Shape3DProperties& get3DProperties() const { return *mp3DPropertiesPtr; } + + table::TablePropertiesPtr const & getTableProperties(); + + EffectProperties& getEffectProperties() const { return *mpEffectPropertiesPtr; } + + void setChildPosition( css::awt::Point nPosition ){ maChPosition = nPosition; } + void setChildSize( css::awt::Size aSize ){ maChSize = aSize; } + + void setPosition( css::awt::Point nPosition ){ maPosition = nPosition; } + const css::awt::Point& getPosition() const { return maPosition; } + + void setSize( css::awt::Size aSize ){ maSize = aSize; } + const css::awt::Size& getSize() const { return maSize; } + + void setRotation( sal_Int32 nRotation ) { mnRotation = nRotation; } + sal_Int32 getRotation() const { return mnRotation; } + void setDiagramRotation( sal_Int32 nRotation ) { mnDiagramRotation = nRotation; } + void setFlip( bool bFlipH, bool bFlipV ) { mbFlipH = bFlipH; mbFlipV = bFlipV; } + bool getFlipH() const { return mbFlipH; } + bool getFlipV() const { return mbFlipV; } + void addChild( const ShapePtr& rChildPtr ) { maChildren.push_back( rChildPtr ); } + std::vector< ShapePtr >& getChildren() { return maChildren; } + + void setName( const OUString& rName ) { msName = rName; } + const OUString& getName( ) const { return msName; } + void setInternalName( const OUString& rInternalName ) { msInternalName = rInternalName; } + const OUString& getInternalName() const { return msInternalName; } + void setId( const OUString& rId ) { msId = rId; } + const OUString& getId() const { return msId; } + void setDescription( const OUString& rDescr ) { msDescription = rDescr; } + void setHidden( bool bHidden ) { mbHidden = bHidden; } + void setHiddenMasterShape( bool bHiddenMasterShape ) { mbHiddenMasterShape = bHiddenMasterShape; } + void setLocked( bool bLocked ) { mbLocked = bLocked; } + 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(bool bHeight); + + ::oox::vml::OleObjectInfo& setOleObjectType(); + ChartShapeInfo& setChartType( bool bEmbedShapes ); + void setDiagramType(); + void setTableType(); + + void setTextBody(const TextBodyPtr & pTextBody); + const TextBodyPtr& getTextBody() const { return mpTextBody;} + void setMasterTextListStyle( const TextListStylePtr& pMasterTextListStyle ); + const TextListStylePtr& getMasterTextListStyle() const { return mpMasterTextListStyle; } + + ShapeStyleRefMap& getShapeStyleRefs() { return maShapeStyleRefs; } + const ShapeStyleRefMap& getShapeStyleRefs() const { return maShapeStyleRefs; } + const ShapeStyleRef* getShapeStyleRef( sal_Int32 nRefType ) const; + bool hasShapeStyleRefs() const { return !maShapeStyleRefs.empty(); } + + // addShape is creating and inserting the corresponding XShape. + void addShape( + ::oox::core::XmlFilterBase& rFilterBase, + const Theme* pTheme, + const css::uno::Reference< css::drawing::XShapes >& rxShapes, + const basegfx::B2DHomMatrix& aTransformation, + const FillProperties& rShapeOrParentShapeFillProps, + ShapeIdMap* pShapeMap = nullptr, + oox::drawingml::ShapePtr pParentGroupShape = nullptr); + + const css::uno::Reference< css::drawing::XShape > & + getXShape() const { return mxShape; } + + void applyShapeReference( const Shape& rReferencedShape, bool bUseText = true ); + const ::std::vector<OUString>& + getExtDrawings() const { return maExtDrawings; } + void addExtDrawingRelId( const OUString &rRelId ) { maExtDrawings.push_back( rRelId ); } + // Set font color only for extdrawings. + void setFontRefColorForNodes(const Color& rColor) { maFontRefColorForNodes = rColor; } + const Color& getFontRefColorForNodes() const { return maFontRefColorForNodes; } + void setLockedCanvas(bool bLockedCanvas); + bool getLockedCanvas() const { return mbLockedCanvas;} + void setWPGChild(bool bWPG); + bool isWPGChild() const { return mbWPGChild;} + void setWps(bool bWps); + bool getWps() const { return mbWps;} + void setTextBox(bool bTextBox); + const css::uno::Sequence<css::beans::PropertyValue> & + getDiagramDoms() const { return maDiagramDoms; } + void setDiagramDoms(const css::uno::Sequence<css::beans::PropertyValue>& rDiagramDoms) { maDiagramDoms = rDiagramDoms; } + css::uno::Sequence< css::uno::Sequence< css::uno::Any > >resolveRelationshipsOfTypeFromOfficeDoc( + core::XmlFilterBase& rFilter, const OUString& sFragment, std::u16string_view sType ); + void setLinkedTxbxAttributes(const LinkedTxbxAttr& rhs){ maLinkedTxbxAttr = rhs; }; + void setTxbxHasLinkedTxtBox( const bool rhs){ mbHasLinkedTxbx = rhs; }; + const LinkedTxbxAttr& getLinkedTxbxAttributes() const { return maLinkedTxbxAttr; }; + bool isLinkedTxbx() const { return mbHasLinkedTxbx; }; + + void setZOrder(sal_Int32 nZOrder) { mnZOrder = nZOrder; } + + sal_Int32 getZOrder() const { return mnZOrder; } + + void setZOrderOff(sal_Int32 nZOrderOff) { mnZOrderOff = nZOrderOff; } + + sal_Int32 getZOrderOff() const { return mnZOrderOff; } + + void setDataNodeType(sal_Int32 nDataNodeType) { mnDataNodeType = nDataNodeType; } + + sal_Int32 getDataNodeType() const { return mnDataNodeType; } + + void setAspectRatio(double fAspectRatio) { mfAspectRatio = fAspectRatio; } + + double getAspectRatio() const { return mfAspectRatio; } + + void setVerticalShapesCount(sal_Int32 nVerticalShapesCount) { mnVerticalShapesCount = nVerticalShapesCount; } + sal_Int32 getVerticalShapesCount() const { return mnVerticalShapesCount; } + + /// Changes reference semantics to value semantics for fill properties. + void cloneFillProperties(); + + void keepDiagramDrawing(::oox::core::XmlFilterBase& rFilterBase, const OUString& rFragmentPath); + + // Allows preparation of a local Diagram helper && propagate an eventually + // existing one to the data holder object later + void prepareDiagramHelper(const std::shared_ptr< Diagram >& rDiagramPtr, const std::shared_ptr<::oox::drawingml::Theme>& rTheme); + void propagateDiagramHelper(); + + // for Writer it is necessary to migrate an existing helper to a new Shape + void migrateDiagramHelperToNewShape(const ShapePtr& pTarget); + +protected: + + 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. + }; + + css::uno::Reference< css::drawing::XShape > const & + createAndInsert( + ::oox::core::XmlFilterBase& rFilterBase, + const OUString& rServiceName, + const Theme* pTheme, + const css::uno::Reference< css::drawing::XShapes >& rxShapes, + bool bClearText, + bool bDoNotInsertEmptyTextBody, + basegfx::B2DHomMatrix& aTransformation, + const FillProperties& rShapeOrParentShapeFillProps, + oox::drawingml::ShapePtr pParentGroupShape = nullptr + ); + + void addChildren( + ::oox::core::XmlFilterBase& rFilterBase, + Shape& rMaster, + const Theme* pTheme, + const css::uno::Reference< css::drawing::XShapes >& rxShapes, + ShapeIdMap* pShapeMap, + const basegfx::B2DHomMatrix& aTransformation ); + + void keepDiagramCompatibilityInfo(); + void convertSmartArtToMetafile( ::oox::core::XmlFilterBase const& rFilterBase ); + + css::uno::Reference< css::drawing::XShape > + renderDiagramToGraphic( ::oox::core::XmlFilterBase const & rFilterBase ); + + OUString finalizeServiceName( + ::oox::core::XmlFilterBase& rFilter, + const OUString& rServiceName, + const css::awt::Rectangle& rShapeRect ); + + virtual void finalizeXShape( + ::oox::core::XmlFilterBase& rFilter, + const css::uno::Reference< css::drawing::XShapes >& rxShapes ); + + void putPropertyToGrabBag( + const OUString& sPropertyName, const css::uno::Any& aPropertyValue ); + void putPropertyToGrabBag( + const css::beans::PropertyValue& pProperty ); + void putPropertiesToGrabBag( + const css::uno::Sequence< css::beans::PropertyValue >& aProperties ); + + FillProperties getActualFillProperties(const Theme* pTheme, const FillProperties* pParentShapeFillProps) const; + LineProperties getActualLineProperties(const Theme* pTheme) const; + EffectProperties getActualEffectProperties(const Theme* pTheme) const; + + std::vector< ShapePtr > maChildren; // only used for group shapes + css::awt::Size maChSize; // only used for group shapes + css::awt::Point maChPosition; // only used for group shapes + + TextBodyPtr mpTextBody; + LinePropertiesPtr mpLinePropertiesPtr; + LinePropertiesPtr mpShapeRefLinePropPtr; + FillPropertiesPtr mpFillPropertiesPtr; + FillPropertiesPtr mpShapeRefFillPropPtr; + GraphicPropertiesPtr mpGraphicPropertiesPtr; + CustomShapePropertiesPtr mpCustomShapePropertiesPtr; + table::TablePropertiesPtr mpTablePropertiesPtr; + Shape3DPropertiesPtr mp3DPropertiesPtr; + EffectPropertiesPtr mpEffectPropertiesPtr; + EffectPropertiesPtr mpShapeRefEffectPropPtr; + PropertyMap maShapeProperties; + PropertyMap maDefaultShapeProperties; + TextListStylePtr mpMasterTextListStyle; + css::uno::Reference< css::drawing::XShape > mxShape; + ConnectorShapePropertiesList maConnectorShapePropertiesList; + + OUString msConnectorName; + OUString msServiceName; + OUString msName; + OUString msInternalName; // used by diagram; not displayed in UI + OUString msId; + OUString msDescription; + sal_Int32 mnSubType; // if this type is not zero, then the shape is a placeholder + OptValue< sal_Int32 > moSubTypeIndex; + + ShapeStyleRefMap maShapeStyleRefs; + + css::awt::Size maSize; + css::awt::Point maPosition; + ::std::vector<OUString> maExtDrawings; + Color maFontRefColorForNodes; + + FrameType meFrameType; ///< Type for graphic frame shapes. + +private: + + typedef std::shared_ptr< ::oox::vml::OleObjectInfo > OleObjectInfoRef; + typedef std::shared_ptr< ChartShapeInfo > ChartShapeInfoRef; + + OleObjectInfoRef mxOleObjectInfo; ///< Additional data for OLE objects. + ChartShapeInfoRef mxChartShapeInfo; ///< Additional data for chart shapes. + + sal_Int32 mnRotation; + sal_Int32 mnDiagramRotation; // rotates shape prior to sizing, does not affect text rotation + bool mbFlipH; + bool mbFlipV; + bool mbHidden; + 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 + bool mbLocked; + bool mbWPGChild; // Is this shape a child of a WPG shape? + bool mbLockedCanvas; ///< Is this shape part of a locked canvas? + bool mbWps; ///< Is this a wps shape? + bool mbTextBox; ///< This shape has a textbox. + LinkedTxbxAttr maLinkedTxbxAttr; + bool mbHasLinkedTxbx; // this text box has linked text box ? + + css::uno::Sequence<css::beans::PropertyValue> maDiagramDoms; + + /// Z-Order. + sal_Int32 mnZOrder = 0; + + /// Z-Order offset. + sal_Int32 mnZOrderOff = 0; + + /// Type of data node for an in-diagram shape. + sal_Int32 mnDataNodeType = 0; + + /// Aspect ratio for an in-diagram shape. + double mfAspectRatio = 0; + + /// Number of child shapes to be layouted vertically inside org chart in-diagram shape. + sal_Int32 mnVerticalShapesCount = 0; + + // Is this a connector shape? + bool mbConnector = false; + + // Is shape has bookmark? + bool mbHasBookmark = false; + + // temporary space for DiagramHelper in preparation for collecting data + // Note: I tried to use a unique_ptr here, but existing constructor func does not allow that + svx::diagram::IDiagramHelper* mpDiagramHelper; + + // association-ID to identify the Diagram ModelData + OUString msDiagramDataModelID; +}; + +} + +#endif // INCLUDED_OOX_DRAWINGML_SHAPE_HXX + +/* 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 000000000..170f50403 --- /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 INCLUDED_OOX_DRAWINGML_SHAPECONTEXT_HXX +#define INCLUDED_OOX_DRAWINGML_SHAPECONTEXT_HXX + +#include <oox/core/contexthandler.hxx> +#include <oox/core/contexthandler2.hxx> +#include <oox/dllapi.h> +#include <oox/drawingml/drawingmltypes.hxx> +#include <sal/types.h> + +namespace oox { class AttributeList; } + +namespace oox::drawingml { + +class OOX_DLLPUBLIC ShapeContext : public ::oox::core::ContextHandler2 +{ +public: + ShapeContext( ::oox::core::ContextHandler2Helper const & rParent, ShapePtr const & pMasterShapePtr, ShapePtr const & pShapePtr ); + virtual ~ShapeContext() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) override; + + const ShapePtr& getShape() const { return mpShapePtr;} + +protected: + + ShapePtr mpMasterShapePtr; + ShapePtr mpShapePtr; +}; + +} + +#endif // INCLUDED_OOX_DRAWINGML_SHAPECONTEXT_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 000000000..d9dfcbfa5 --- /dev/null +++ b/include/oox/drawingml/shapegroupcontext.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 . + */ + +#pragma once + +#include <oox/core/contexthandler.hxx> +#include <oox/core/fragmenthandler2.hxx> +#include <oox/dllapi.h> +#include <oox/drawingml/drawingmltypes.hxx> +#include <sal/types.h> + +namespace oox { class AttributeList; } + +namespace oox::drawingml { + +class OOX_DLLPUBLIC ShapeGroupContext : public ::oox::core::FragmentHandler2 +{ +public: + ShapeGroupContext( ::oox::core::FragmentHandler2 const & rParent, ShapePtr const & pMasterShapePtr, ShapePtr const & pGroupShapePtr ); + virtual ~ShapeGroupContext() override; + virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) override; + +protected: + ShapePtr mpGroupShapePtr; +}; + +} + +/* 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 000000000..7870ddee3 --- /dev/null +++ b/include/oox/drawingml/shapepropertymap.hxx @@ -0,0 +1,168 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_SHAPEPROPERTYMAP_HXX +#define INCLUDED_OOX_DRAWINGML_SHAPEPROPERTYMAP_HXX + +#include <com/sun/star/uno/Any.hxx> +#include <o3tl/enumarray.hxx> +#include <oox/dllapi.h> +#include <oox/helper/propertymap.hxx> +#include <rtl/ustring.hxx> +#include <sal/types.h> +#include <tools/color.hxx> + +namespace oox { class ModelObjectHelper; } + +namespace oox::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. + + If you *insert* ids into this list, then update spnCommonPropIds, spnLinearPropIds + and spnFilledPropIds of oox/source/drawingml/chart/objectformatter.cxx if + the newly inserted enum is inside the range they cover + */ +enum class ShapeProperty +{ + LineStyle, + LineWidth, + LineColor, + LineTransparency, + LineDash, ///< Explicit line dash or name of a line dash stored in a global container. + LineCap, + LineJoint, + LineStart, ///< Explicit line start marker or name of a line marker stored in a global container. + LineStartWidth, + LineStartCenter, + LineEnd, ///< Explicit line end marker or name of a line marker stored in a global container. + LineEndWidth, + LineEndCenter, + FillStyle, + FillColor, + FillTransparency, + GradientTransparency, + FillGradient, ///< Explicit fill gradient or name of a fill gradient stored in a global container. + FillBitmap, ///< Explicit fill bitmap or name of a fill bitmap stored in a global container. + FillBitmapMode, + FillBitmapSizeX, + FillBitmapSizeY, + FillBitmapOffsetX, + FillBitmapOffsetY, + FillBitmapRectanglePoint, + FillHatch, ///< Explicit fill hatch or name of a fill hatch stored in a global container. + FillBackground, + FillUseSlideBackground, + FillBitmapName, + ShadowXDistance, + ShadowSizeX, + ShadowSizeY, + LAST = ShadowSizeY +}; + +typedef o3tl::enumarray<ShapeProperty, sal_Int32> ShapePropertyIds; + +struct OOX_DLLPUBLIC ShapePropertyInfo +{ + const ShapePropertyIds& mrPropertyIds; + 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 mbNamedFillBitmap; /// True = use named fill bitmap instead of explicit fill bitmap. + bool mbNamedFillHatch; /// True = use named fill hatch instead of explicit fill hatch. + + static ShapePropertyInfo DEFAULT; /// Default property info (used as default parameter of other methods). + + explicit ShapePropertyInfo(const ShapePropertyIds& rnPropertyIds, + bool bNamedLineMarker, bool bNamedLineDash, + bool bNamedFillGradient, bool bNamedFillBitmap, bool bNamedFillHatch); + + bool has(ShapeProperty ePropId) const + { + return mrPropertyIds[ePropId] >= 0; + } + sal_Int32 operator[](ShapeProperty ePropId) const + { + return mrPropertyIds[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( ShapeProperty 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( ShapeProperty ePropId, const css::uno::Any& rValue ); + + /** Sets the specified shape property to the passed value. */ + template<typename Type> + bool setProperty(ShapeProperty ePropId, const Type& rValue) + { + return setAnyProperty(ePropId, css::uno::Any(rValue)); + } + bool setProperty(ShapeProperty ePropId, const ::Color& rValue) + { + return setAnyProperty(ePropId, css::uno::Any(rValue)); + } + + using PropertyMap::setAnyProperty; + using PropertyMap::setProperty; + +private: + /** Sets an explicit line marker, or creates a named line marker. */ + bool setLineMarker( sal_Int32 nPropId, const css::uno::Any& rValue ); + /** Sets an explicit line dash, or creates a named line dash. */ + bool setLineDash( sal_Int32 nPropId, const css::uno::Any& rValue ); + /** Sets an explicit fill gradient, or creates a named fill gradient. */ + bool setFillGradient( sal_Int32 nPropId, const css::uno::Any& rValue ); + /** Creates a named transparency gradient. */ + bool setGradientTrans( sal_Int32 nPropId, const css::uno::Any& rValue ); + /** Sets an explicit fill bitmap, or creates a named fill bitmap. */ + bool setFillBitmap( sal_Int32 nPropId, const css::uno::Any& rValue ); + /** Sets an explicit fill bitmap and pushes the name to FillBitmapName */ + bool setFillBitmapName( const css::uno::Any& rValue ); + /** Sets an explicit fill hatch, or creates a named fill hatch. */ + bool setFillHatch( sal_Int32 nPropId, const css::uno::Any& rValue ); + + // not implemented, to prevent implicit conversion from enum to int + css::uno::Any& operator[]( ShapeProperty ePropId ) = delete; + const css::uno::Any& operator[]( ShapeProperty ePropId ) const = delete; + +private: + ModelObjectHelper& mrModelObjHelper; + ShapePropertyInfo maShapePropInfo; +}; + + +} // namespace oox::drawingml + +#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 000000000..6222a4264 --- /dev/null +++ b/include/oox/drawingml/theme.hxx @@ -0,0 +1,123 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_DRAWINGML_THEME_HXX +#define INCLUDED_OOX_DRAWINGML_THEME_HXX + +#include <functional> + +#include <com/sun/star/uno/Reference.hxx> +#include <oox/drawingml/clrscheme.hxx> +#include <oox/drawingml/shape.hxx> +#include <oox/dllapi.h> +#include <oox/helper/refmap.hxx> +#include <oox/helper/refvector.hxx> +#include <rtl/ustring.hxx> +#include <sal/types.h> + +namespace com::sun::star { + namespace drawing { class XDrawPage; } + namespace xml::dom { class XDocument; } +} + +namespace oox::drawingml { + +struct EffectProperties; +struct FillProperties; +struct LineProperties; +struct TextCharacterProperties; + +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 TextFont; + +class OOX_DLLPUBLIC Theme +{ +public: + void setStyleName( const OUString& rStyleName ) { maStyleName = rStyleName; } + void setThemeName(const OUString& rThemeName) { maThemeName = rThemeName; } + + ClrScheme& getClrScheme() { return maClrScheme; } + const ClrScheme& getClrScheme() const { return maClrScheme; } + + FillStyleList& getFillStyleList() { return maFillStyleList; } + const FillStyleList& getFillStyleList() const { return maFillStyleList; } + FillStyleList& getBgFillStyleList() { return maBgFillStyleList; } + 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; + + LineStyleList& getLineStyleList() { return maLineStyleList; } + 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; + + EffectStyleList& getEffectStyleList() { return maEffectStyleList; } + const EffectStyleList& getEffectStyleList() const { return maEffectStyleList; } + const EffectProperties* getEffectStyle( sal_Int32 nIndex ) const; + + FontScheme& getFontScheme() { return maFontScheme; } + 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; + + Shape& getSpDef() { return maSpDef; } + const Shape& getSpDef() const { return maSpDef; } + + Shape& getLnDef() { return maLnDef; } + const Shape& getLnDef() const { return maLnDef; } + + Shape& getTxDef() { return maTxDef; } + const Shape& getTxDef() const { return maTxDef; } + + const css::uno::Reference<css::xml::dom::XDocument>& getFragment() const { return mxFragment; } + void setFragment( const css::uno::Reference< css::xml::dom::XDocument>& xRef ) { mxFragment=xRef; } + + void addTheme(const css::uno::Reference<css::drawing::XDrawPage>& xDrawPage) const; + +private: + OUString maStyleName; + OUString maThemeName; + ClrScheme maClrScheme; + FillStyleList maFillStyleList; + FillStyleList maBgFillStyleList; + LineStyleList maLineStyleList; + EffectStyleList maEffectStyleList; + FontScheme maFontScheme; + Shape maSpDef; + Shape maLnDef; + Shape maTxDef; + css::uno::Reference< css::xml::dom::XDocument> mxFragment; +}; + + +} // namespace oox::drawingml + +#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 000000000..e433c350d --- /dev/null +++ b/include/oox/drawingml/themefragmenthandler.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 INCLUDED_OOX_DRAWINGML_THEMEFRAGMENTHANDLER_HXX +#define INCLUDED_OOX_DRAWINGML_THEMEFRAGMENTHANDLER_HXX + +#include <oox/core/contexthandler.hxx> +#include <oox/core/fragmenthandler2.hxx> +#include <oox/dllapi.h> +#include <rtl/ustring.hxx> +#include <sal/types.h> + +namespace oox { class AttributeList; } +namespace oox::core { class XmlFilterBase; } + +namespace oox::drawingml { + +class Theme; + + +class OOX_DLLPUBLIC ThemeFragmentHandler final : public ::oox::core::FragmentHandler2 +{ +public: + explicit ThemeFragmentHandler( + ::oox::core::XmlFilterBase& rFilter, + const OUString& rFragmentPath, + Theme& rTheme ); + virtual ~ThemeFragmentHandler() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; + +private: + Theme& mrTheme; +}; + + +} // namespace oox::drawingml + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |