/src/libreoffice/include/oox/drawingml/shapepropertymap.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
11 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | | * contributor license agreements. See the NOTICE file distributed |
13 | | * with this work for additional information regarding copyright |
14 | | * ownership. The ASF licenses this file to you under the Apache |
15 | | * License, Version 2.0 (the "License"); you may not use this file |
16 | | * except in compliance with the License. You may obtain a copy of |
17 | | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | | */ |
19 | | |
20 | | #ifndef INCLUDED_OOX_DRAWINGML_SHAPEPROPERTYMAP_HXX |
21 | | #define INCLUDED_OOX_DRAWINGML_SHAPEPROPERTYMAP_HXX |
22 | | |
23 | | #include <com/sun/star/uno/Any.hxx> |
24 | | #include <o3tl/enumarray.hxx> |
25 | | #include <oox/dllapi.h> |
26 | | #include <oox/helper/propertymap.hxx> |
27 | | #include <rtl/ustring.hxx> |
28 | | #include <sal/types.h> |
29 | | #include <tools/color.hxx> |
30 | | |
31 | | namespace oox { class ModelObjectHelper; } |
32 | | |
33 | | namespace oox::drawingml { |
34 | | |
35 | | /** Enumeration for various properties related to drawing shape formatting. |
36 | | |
37 | | This is an abstraction for shape formatting properties that have different |
38 | | names in various implementations, e.g. drawing shapes vs. chart objects. |
39 | | |
40 | | If you *insert* ids into this list, then update spnCommonPropIds, spnLinearPropIds |
41 | | and spnFilledPropIds of oox/source/drawingml/chart/objectformatter.cxx if |
42 | | the newly inserted enum is inside the range they cover |
43 | | */ |
44 | | enum class ShapeProperty |
45 | | { |
46 | | LineStyle, |
47 | | LineWidth, |
48 | | LineColor, |
49 | | LineTransparency, |
50 | | LineDash, ///< Explicit line dash or name of a line dash stored in a global container. |
51 | | LineCap, |
52 | | LineJoint, |
53 | | LineStart, ///< Explicit line start marker or name of a line marker stored in a global container. |
54 | | LineStartWidth, |
55 | | LineStartCenter, |
56 | | LineEnd, ///< Explicit line end marker or name of a line marker stored in a global container. |
57 | | LineEndWidth, |
58 | | LineEndCenter, |
59 | | FillStyle, |
60 | | FillColor, |
61 | | FillTransparency, |
62 | | GradientTransparency, |
63 | | FillGradient, ///< Explicit fill gradient or name of a fill gradient stored in a global container. |
64 | | FillBitmap, ///< Explicit fill bitmap or name of a fill bitmap stored in a global container. |
65 | | FillBitmapMode, |
66 | | FillBitmapSizeX, |
67 | | FillBitmapSizeY, |
68 | | FillBitmapOffsetX, |
69 | | FillBitmapOffsetY, |
70 | | FillBitmapRectanglePoint, |
71 | | FillHatch, ///< Explicit fill hatch or name of a fill hatch stored in a global container. |
72 | | FillBackground, |
73 | | FillUseSlideBackground, |
74 | | FillBitmapName, |
75 | | ShadowXDistance, |
76 | | ShadowSizeX, |
77 | | ShadowSizeY, |
78 | | LAST = ShadowSizeY |
79 | | }; |
80 | | |
81 | | typedef o3tl::enumarray<ShapeProperty, sal_Int32> ShapePropertyIds; |
82 | | |
83 | | struct OOX_DLLPUBLIC ShapePropertyInfo |
84 | | { |
85 | | const ShapePropertyIds& mrPropertyIds; |
86 | | bool mbNamedLineMarker; /// True = use named line marker instead of explicit line marker. |
87 | | bool mbNamedLineDash; /// True = use named line dash instead of explicit line dash. |
88 | | bool mbNamedFillGradient; /// True = use named fill gradient instead of explicit fill gradient. |
89 | | bool mbNamedFillBitmap; /// True = use named fill bitmap instead of explicit fill bitmap. |
90 | | bool mbNamedFillHatch; /// True = use named fill hatch instead of explicit fill hatch. |
91 | | |
92 | | static ShapePropertyInfo DEFAULT; /// Default property info (used as default parameter of other methods). |
93 | | |
94 | | explicit ShapePropertyInfo(const ShapePropertyIds& rnPropertyIds, |
95 | | bool bNamedLineMarker, bool bNamedLineDash, |
96 | | bool bNamedFillGradient, bool bNamedFillBitmap, bool bNamedFillHatch); |
97 | | |
98 | | bool has(ShapeProperty ePropId) const |
99 | 1.71k | { |
100 | 1.71k | return mrPropertyIds[ePropId] >= 0; |
101 | 1.71k | } |
102 | | sal_Int32 operator[](ShapeProperty ePropId) const |
103 | 358k | { |
104 | 358k | return mrPropertyIds[ePropId]; |
105 | 358k | } |
106 | | }; |
107 | | |
108 | | class OOX_DLLPUBLIC ShapePropertyMap : public PropertyMap |
109 | | { |
110 | | public: |
111 | | explicit ShapePropertyMap(ModelObjectHelper& rModelObjHelper, |
112 | | const ShapePropertyInfo& rShapePropInfo = ShapePropertyInfo::DEFAULT ); |
113 | | |
114 | | /** Returns true, if the specified property is supported. */ |
115 | | bool supportsProperty( ShapeProperty ePropId ) const; |
116 | | |
117 | | /** Returns true, if named line markers are supported, and the specified |
118 | | line marker has already been inserted into the marker table. */ |
119 | | bool hasNamedLineMarkerInTable( const OUString& rMarkerName ) const; |
120 | | |
121 | | /** Sets the specified shape property to the passed value. */ |
122 | | bool setAnyProperty( ShapeProperty ePropId, const css::uno::Any& rValue ); |
123 | | |
124 | | /** Sets the specified shape property to the passed value. */ |
125 | | template<typename Type> |
126 | | bool setProperty(ShapeProperty ePropId, const Type& rValue) |
127 | 327k | { |
128 | 327k | return setAnyProperty(ePropId, css::uno::Any(rValue)); |
129 | 327k | } bool oox::drawingml::ShapePropertyMap::setProperty<bool>(oox::drawingml::ShapeProperty, bool const&) Line | Count | Source | 127 | 66.2k | { | 128 | 66.2k | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 129 | 66.2k | } |
bool oox::drawingml::ShapePropertyMap::setProperty<short>(oox::drawingml::ShapeProperty, short const&) Line | Count | Source | 127 | 457 | { | 128 | 457 | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 129 | 457 | } |
bool oox::drawingml::ShapePropertyMap::setProperty<com::sun::star::awt::Gradient2>(oox::drawingml::ShapeProperty, com::sun::star::awt::Gradient2 const&) Line | Count | Source | 127 | 1.66k | { | 128 | 1.66k | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 129 | 1.66k | } |
bool oox::drawingml::ShapePropertyMap::setProperty<com::sun::star::uno::Reference<com::sun::star::graphic::XGraphic> >(oox::drawingml::ShapeProperty, com::sun::star::uno::Reference<com::sun::star::graphic::XGraphic> const&) Line | Count | Source | 127 | 31 | { | 128 | 31 | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 129 | 31 | } |
bool oox::drawingml::ShapePropertyMap::setProperty<com::sun::star::drawing::RectanglePoint>(oox::drawingml::ShapeProperty, com::sun::star::drawing::RectanglePoint const&) Line | Count | Source | 127 | 31 | { | 128 | 31 | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 129 | 31 | } |
bool oox::drawingml::ShapePropertyMap::setProperty<int>(oox::drawingml::ShapeProperty, int const&) Line | Count | Source | 127 | 76.6k | { | 128 | 76.6k | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 129 | 76.6k | } |
bool oox::drawingml::ShapePropertyMap::setProperty<com::sun::star::drawing::BitmapMode>(oox::drawingml::ShapeProperty, com::sun::star::drawing::BitmapMode const&) Line | Count | Source | 127 | 31 | { | 128 | 31 | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 129 | 31 | } |
Unexecuted instantiation: bool oox::drawingml::ShapePropertyMap::setProperty<com::sun::star::drawing::Hatch>(oox::drawingml::ShapeProperty, com::sun::star::drawing::Hatch const&) bool oox::drawingml::ShapePropertyMap::setProperty<com::sun::star::drawing::FillStyle>(oox::drawingml::ShapeProperty, com::sun::star::drawing::FillStyle const&) Line | Count | Source | 127 | 85.8k | { | 128 | 85.8k | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 129 | 85.8k | } |
bool oox::drawingml::ShapePropertyMap::setProperty<com::sun::star::beans::NamedValue>(oox::drawingml::ShapeProperty, com::sun::star::beans::NamedValue const&) Line | Count | Source | 127 | 759 | { | 128 | 759 | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 129 | 759 | } |
bool oox::drawingml::ShapePropertyMap::setProperty<com::sun::star::drawing::LineCap>(oox::drawingml::ShapeProperty, com::sun::star::drawing::LineCap const&) Line | Count | Source | 127 | 7.67k | { | 128 | 7.67k | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 129 | 7.67k | } |
bool oox::drawingml::ShapePropertyMap::setProperty<com::sun::star::drawing::LineDash>(oox::drawingml::ShapeProperty, com::sun::star::drawing::LineDash const&) Line | Count | Source | 127 | 101 | { | 128 | 101 | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 129 | 101 | } |
bool oox::drawingml::ShapePropertyMap::setProperty<com::sun::star::drawing::LineStyle>(oox::drawingml::ShapeProperty, com::sun::star::drawing::LineStyle const&) Line | Count | Source | 127 | 75.8k | { | 128 | 75.8k | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 129 | 75.8k | } |
bool oox::drawingml::ShapePropertyMap::setProperty<com::sun::star::drawing::LineJoint>(oox::drawingml::ShapeProperty, com::sun::star::drawing::LineJoint const&) Line | Count | Source | 127 | 12.1k | { | 128 | 12.1k | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 129 | 12.1k | } |
|
130 | | bool setProperty(ShapeProperty ePropId, const ::Color& rValue) |
131 | 31.1k | { |
132 | 31.1k | return setAnyProperty(ePropId, css::uno::Any(rValue)); |
133 | 31.1k | } |
134 | | |
135 | | using PropertyMap::setAnyProperty; |
136 | | using PropertyMap::setProperty; |
137 | | |
138 | | private: |
139 | | /** Sets an explicit line marker, or creates a named line marker. */ |
140 | | bool setLineMarker( sal_Int32 nPropId, const css::uno::Any& rValue ); |
141 | | /** Sets an explicit line dash, or creates a named line dash. */ |
142 | | bool setLineDash( sal_Int32 nPropId, const css::uno::Any& rValue ); |
143 | | /** Sets an explicit fill gradient, or creates a named fill gradient. */ |
144 | | bool setFillGradient( sal_Int32 nPropId, const css::uno::Any& rValue ); |
145 | | /** Creates a named transparency gradient. */ |
146 | | bool setGradientTrans( sal_Int32 nPropId, const css::uno::Any& rValue ); |
147 | | /** Sets an explicit fill bitmap, or creates a named fill bitmap. */ |
148 | | bool setFillBitmap( sal_Int32 nPropId, const css::uno::Any& rValue ); |
149 | | /** Sets an explicit fill bitmap and pushes the name to FillBitmapName */ |
150 | | bool setFillBitmapName( const css::uno::Any& rValue ); |
151 | | /** Sets an explicit fill hatch, or creates a named fill hatch. */ |
152 | | bool setFillHatch( sal_Int32 nPropId, const css::uno::Any& rValue ); |
153 | | |
154 | | // not implemented, to prevent implicit conversion from enum to int |
155 | | css::uno::Any& operator[]( ShapeProperty ePropId ) = delete; |
156 | | const css::uno::Any& operator[]( ShapeProperty ePropId ) const = delete; |
157 | | |
158 | | private: |
159 | | ModelObjectHelper& mrModelObjHelper; |
160 | | ShapePropertyInfo maShapePropInfo; |
161 | | }; |
162 | | |
163 | | |
164 | | } // namespace oox::drawingml |
165 | | |
166 | | #endif |
167 | | |
168 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |