Revert "sw: DOCX export: don't export numPr to style from outline numrule"
[LibreOffice.git] / include / oox / drawingml / shapepropertymap.hxx
bloba9e4ea4052736a8a51b5f40e6731e714b9d5277b
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 FillBitmapName,
74 ShadowXDistance,
75 ShadowSizeX,
76 ShadowSizeY,
77 LAST = ShadowSizeY
80 typedef o3tl::enumarray<ShapeProperty, sal_Int32> ShapePropertyIds;
82 struct OOX_DLLPUBLIC ShapePropertyInfo
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.
91 static ShapePropertyInfo DEFAULT; /// Default property info (used as default parameter of other methods).
93 explicit ShapePropertyInfo(const ShapePropertyIds& rnPropertyIds,
94 bool bNamedLineMarker, bool bNamedLineDash,
95 bool bNamedFillGradient, bool bNamedFillBitmap, bool bNamedFillHatch);
97 bool has(ShapeProperty ePropId) const
99 return mrPropertyIds[ePropId] >= 0;
101 sal_Int32 operator[](ShapeProperty ePropId) const
103 return mrPropertyIds[ePropId];
107 class OOX_DLLPUBLIC ShapePropertyMap : public PropertyMap
109 public:
110 explicit ShapePropertyMap(ModelObjectHelper& rModelObjHelper,
111 const ShapePropertyInfo& rShapePropInfo = ShapePropertyInfo::DEFAULT );
113 /** Returns true, if the specified property is supported. */
114 bool supportsProperty( ShapeProperty ePropId ) const;
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;
120 /** Sets the specified shape property to the passed value. */
121 bool setAnyProperty( ShapeProperty ePropId, const css::uno::Any& rValue );
123 /** Sets the specified shape property to the passed value. */
124 template<typename Type>
125 bool setProperty(ShapeProperty ePropId, const Type& rValue)
127 return setAnyProperty(ePropId, css::uno::Any(rValue));
129 bool setProperty(ShapeProperty ePropId, const ::Color& rValue)
131 return setAnyProperty(ePropId, css::uno::makeAny(rValue));
134 using PropertyMap::setAnyProperty;
135 using PropertyMap::setProperty;
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 );
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;
157 private:
158 ModelObjectHelper& mrModelObjHelper;
159 ShapePropertyInfo maShapePropInfo;
163 } // namespace oox::drawingml
165 #endif
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */