tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / include / oox / drawingml / shapepropertymap.hxx
blob7870ddee304b2f831333ff7c1753fa0b25029726
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_OOX_DRAWINGML_SHAPEPROPERTYMAP_HXX
21 #define INCLUDED_OOX_DRAWINGML_SHAPEPROPERTYMAP_HXX
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>
31 namespace oox { class ModelObjectHelper; }
33 namespace oox::drawingml {
35 /** Enumeration for various properties related to drawing shape formatting.
37 This is an abstraction for shape formatting properties that have different
38 names in various implementations, e.g. drawing shapes vs. chart objects.
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
44 enum class ShapeProperty
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
81 typedef o3tl::enumarray<ShapeProperty, sal_Int32> ShapePropertyIds;
83 struct OOX_DLLPUBLIC ShapePropertyInfo
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.
92 static ShapePropertyInfo DEFAULT; /// Default property info (used as default parameter of other methods).
94 explicit ShapePropertyInfo(const ShapePropertyIds& rnPropertyIds,
95 bool bNamedLineMarker, bool bNamedLineDash,
96 bool bNamedFillGradient, bool bNamedFillBitmap, bool bNamedFillHatch);
98 bool has(ShapeProperty ePropId) const
100 return mrPropertyIds[ePropId] >= 0;
102 sal_Int32 operator[](ShapeProperty ePropId) const
104 return mrPropertyIds[ePropId];
108 class OOX_DLLPUBLIC ShapePropertyMap : public PropertyMap
110 public:
111 explicit ShapePropertyMap(ModelObjectHelper& rModelObjHelper,
112 const ShapePropertyInfo& rShapePropInfo = ShapePropertyInfo::DEFAULT );
114 /** Returns true, if the specified property is supported. */
115 bool supportsProperty( ShapeProperty ePropId ) const;
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;
121 /** Sets the specified shape property to the passed value. */
122 bool setAnyProperty( ShapeProperty ePropId, const css::uno::Any& rValue );
124 /** Sets the specified shape property to the passed value. */
125 template<typename Type>
126 bool setProperty(ShapeProperty ePropId, const Type& rValue)
128 return setAnyProperty(ePropId, css::uno::Any(rValue));
130 bool setProperty(ShapeProperty ePropId, const ::Color& rValue)
132 return setAnyProperty(ePropId, css::uno::Any(rValue));
135 using PropertyMap::setAnyProperty;
136 using PropertyMap::setProperty;
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 );
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;
158 private:
159 ModelObjectHelper& mrModelObjHelper;
160 ShapePropertyInfo maShapePropInfo;
164 } // namespace oox::drawingml
166 #endif
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */