/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 | | #pragma once |
21 | | |
22 | | #include <com/sun/star/uno/Any.hxx> |
23 | | #include <o3tl/enumarray.hxx> |
24 | | #include <oox/dllapi.h> |
25 | | #include <oox/helper/propertymap.hxx> |
26 | | #include <rtl/ustring.hxx> |
27 | | #include <sal/types.h> |
28 | | #include <tools/color.hxx> |
29 | | |
30 | | namespace oox { class ModelObjectHelper; } |
31 | | |
32 | | namespace oox::drawingml { |
33 | | |
34 | | /** Enumeration for various properties related to drawing shape formatting. |
35 | | |
36 | | This is an abstraction for shape formatting properties that have different |
37 | | names in various implementations, e.g. drawing shapes vs. chart objects. |
38 | | |
39 | | If you *insert* ids into this list, then update spnCommonPropIds, spnLinearPropIds |
40 | | and spnFilledPropIds of oox/source/drawingml/chart/objectformatter.cxx if |
41 | | the newly inserted enum is inside the range they cover |
42 | | */ |
43 | | enum class ShapeProperty |
44 | | { |
45 | | LineStyle, |
46 | | LineWidth, |
47 | | LineColor, |
48 | | LineTransparency, |
49 | | LineDash, ///< Explicit line dash or name of a line dash stored in a global container. |
50 | | LineCap, |
51 | | LineJoint, |
52 | | LineStart, ///< Explicit line start marker or name of a line marker stored in a global container. |
53 | | LineStartWidth, |
54 | | LineStartCenter, |
55 | | LineEnd, ///< Explicit line end marker or name of a line marker stored in a global container. |
56 | | LineEndWidth, |
57 | | LineEndCenter, |
58 | | FillStyle, |
59 | | FillColor, |
60 | | FillTransparency, |
61 | | GradientTransparency, |
62 | | FillGradient, ///< Explicit fill gradient or name of a fill gradient stored in a global container. |
63 | | FillBitmap, ///< Explicit fill bitmap or name of a fill bitmap stored in a global container. |
64 | | FillBitmapMode, |
65 | | FillBitmapSizeX, |
66 | | FillBitmapSizeY, |
67 | | FillBitmapOffsetX, |
68 | | FillBitmapOffsetY, |
69 | | FillBitmapRectanglePoint, |
70 | | FillHatch, ///< Explicit fill hatch or name of a fill hatch stored in a global container. |
71 | | FillBackground, |
72 | | FillUseSlideBackground, |
73 | | FillBitmapName, |
74 | | ShadowXDistance, |
75 | | ShadowSizeX, |
76 | | ShadowSizeY, |
77 | | LAST = ShadowSizeY |
78 | | }; |
79 | | |
80 | | typedef o3tl::enumarray<ShapeProperty, sal_Int32> ShapePropertyIds; |
81 | | |
82 | | struct OOX_DLLPUBLIC ShapePropertyInfo |
83 | | { |
84 | | const ShapePropertyIds& mrPropertyIds; |
85 | | bool mbNamedLineMarker; /// True = use named line marker instead of explicit line marker. |
86 | | bool mbNamedLineDash; /// True = use named line dash instead of explicit line dash. |
87 | | bool mbNamedFillGradient; /// True = use named fill gradient instead of explicit fill gradient. |
88 | | bool mbNamedFillBitmap; /// True = use named fill bitmap instead of explicit fill bitmap. |
89 | | bool mbNamedFillHatch; /// True = use named fill hatch instead of explicit fill hatch. |
90 | | |
91 | | static ShapePropertyInfo DEFAULT; /// Default property info (used as default parameter of other methods). |
92 | | |
93 | | explicit ShapePropertyInfo(const ShapePropertyIds& rnPropertyIds, |
94 | | bool bNamedLineMarker, bool bNamedLineDash, |
95 | | bool bNamedFillGradient, bool bNamedFillBitmap, bool bNamedFillHatch); |
96 | | |
97 | | bool has(ShapeProperty ePropId) const |
98 | 1.98k | { |
99 | 1.98k | return mrPropertyIds[ePropId] >= 0; |
100 | 1.98k | } |
101 | | sal_Int32 operator[](ShapeProperty ePropId) const |
102 | 326k | { |
103 | 326k | return mrPropertyIds[ePropId]; |
104 | 326k | } |
105 | | }; |
106 | | |
107 | | class OOX_DLLPUBLIC ShapePropertyMap : public PropertyMap |
108 | | { |
109 | | public: |
110 | | explicit ShapePropertyMap(ModelObjectHelper& rModelObjHelper, |
111 | | const ShapePropertyInfo& rShapePropInfo = ShapePropertyInfo::DEFAULT ); |
112 | | |
113 | | /** Returns true, if the specified property is supported. */ |
114 | | bool supportsProperty( ShapeProperty ePropId ) const; |
115 | | |
116 | | /** Returns true, if named line markers are supported, and the specified |
117 | | line marker has already been inserted into the marker table. */ |
118 | | bool hasNamedLineMarkerInTable( const OUString& rMarkerName ) const; |
119 | | |
120 | | /** Sets the specified shape property to the passed value. */ |
121 | | bool setAnyProperty( ShapeProperty ePropId, const css::uno::Any& rValue ); |
122 | | |
123 | | /** Sets the specified shape property to the passed value. */ |
124 | | template<typename Type> |
125 | | bool setProperty(ShapeProperty ePropId, const Type& rValue) |
126 | 297k | { |
127 | 297k | return setAnyProperty(ePropId, css::uno::Any(rValue)); |
128 | 297k | } bool oox::drawingml::ShapePropertyMap::setProperty<bool>(oox::drawingml::ShapeProperty, bool const&) Line | Count | Source | 126 | 58.9k | { | 127 | 58.9k | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 128 | 58.9k | } |
bool oox::drawingml::ShapePropertyMap::setProperty<short>(oox::drawingml::ShapeProperty, short const&) Line | Count | Source | 126 | 343 | { | 127 | 343 | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 128 | 343 | } |
bool oox::drawingml::ShapePropertyMap::setProperty<com::sun::star::awt::Gradient2>(oox::drawingml::ShapeProperty, com::sun::star::awt::Gradient2 const&) Line | Count | Source | 126 | 1.93k | { | 127 | 1.93k | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 128 | 1.93k | } |
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 | 126 | 30 | { | 127 | 30 | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 128 | 30 | } |
bool oox::drawingml::ShapePropertyMap::setProperty<com::sun::star::drawing::RectanglePoint>(oox::drawingml::ShapeProperty, com::sun::star::drawing::RectanglePoint const&) Line | Count | Source | 126 | 30 | { | 127 | 30 | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 128 | 30 | } |
bool oox::drawingml::ShapePropertyMap::setProperty<int>(oox::drawingml::ShapeProperty, int const&) Line | Count | Source | 126 | 69.6k | { | 127 | 69.6k | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 128 | 69.6k | } |
bool oox::drawingml::ShapePropertyMap::setProperty<com::sun::star::drawing::BitmapMode>(oox::drawingml::ShapeProperty, com::sun::star::drawing::BitmapMode const&) Line | Count | Source | 126 | 30 | { | 127 | 30 | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 128 | 30 | } |
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 | 126 | 77.0k | { | 127 | 77.0k | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 128 | 77.0k | } |
bool oox::drawingml::ShapePropertyMap::setProperty<com::sun::star::beans::NamedValue>(oox::drawingml::ShapeProperty, com::sun::star::beans::NamedValue const&) Line | Count | Source | 126 | 669 | { | 127 | 669 | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 128 | 669 | } |
bool oox::drawingml::ShapePropertyMap::setProperty<com::sun::star::drawing::LineCap>(oox::drawingml::ShapeProperty, com::sun::star::drawing::LineCap const&) Line | Count | Source | 126 | 7.43k | { | 127 | 7.43k | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 128 | 7.43k | } |
bool oox::drawingml::ShapePropertyMap::setProperty<com::sun::star::drawing::LineDash>(oox::drawingml::ShapeProperty, com::sun::star::drawing::LineDash const&) Line | Count | Source | 126 | 83 | { | 127 | 83 | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 128 | 83 | } |
bool oox::drawingml::ShapePropertyMap::setProperty<com::sun::star::drawing::LineStyle>(oox::drawingml::ShapeProperty, com::sun::star::drawing::LineStyle const&) Line | Count | Source | 126 | 68.9k | { | 127 | 68.9k | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 128 | 68.9k | } |
bool oox::drawingml::ShapePropertyMap::setProperty<com::sun::star::drawing::LineJoint>(oox::drawingml::ShapeProperty, com::sun::star::drawing::LineJoint const&) Line | Count | Source | 126 | 12.0k | { | 127 | 12.0k | return setAnyProperty(ePropId, css::uno::Any(rValue)); | 128 | 12.0k | } |
|
129 | | bool setProperty(ShapeProperty ePropId, const ::Color& rValue) |
130 | 29.0k | { |
131 | 29.0k | return setAnyProperty(ePropId, css::uno::Any(rValue)); |
132 | 29.0k | } |
133 | | |
134 | | using PropertyMap::setAnyProperty; |
135 | | using PropertyMap::setProperty; |
136 | | |
137 | | private: |
138 | | /** Sets an explicit line marker, or creates a named line marker. */ |
139 | | bool setLineMarker( sal_Int32 nPropId, const css::uno::Any& rValue ); |
140 | | /** Sets an explicit line dash, or creates a named line dash. */ |
141 | | bool setLineDash( sal_Int32 nPropId, const css::uno::Any& rValue ); |
142 | | /** Sets an explicit fill gradient, or creates a named fill gradient. */ |
143 | | bool setFillGradient( sal_Int32 nPropId, const css::uno::Any& rValue ); |
144 | | /** Creates a named transparency gradient. */ |
145 | | bool setGradientTrans( sal_Int32 nPropId, const css::uno::Any& rValue ); |
146 | | /** Sets an explicit fill bitmap, or creates a named fill bitmap. */ |
147 | | bool setFillBitmap( sal_Int32 nPropId, const css::uno::Any& rValue ); |
148 | | /** Sets an explicit fill bitmap and pushes the name to FillBitmapName */ |
149 | | bool setFillBitmapName( const css::uno::Any& rValue ); |
150 | | /** Sets an explicit fill hatch, or creates a named fill hatch. */ |
151 | | bool setFillHatch( sal_Int32 nPropId, const css::uno::Any& rValue ); |
152 | | |
153 | | // not implemented, to prevent implicit conversion from enum to int |
154 | | css::uno::Any& operator[]( ShapeProperty ePropId ) = delete; |
155 | | const css::uno::Any& operator[]( ShapeProperty ePropId ) const = delete; |
156 | | |
157 | | private: |
158 | | ModelObjectHelper& mrModelObjHelper; |
159 | | ShapePropertyInfo maShapePropInfo; |
160 | | }; |
161 | | |
162 | | |
163 | | } // namespace oox::drawingml |
164 | | |
165 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |