1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
26 #include <com/sun/star/uno/Any.hxx>
27 #include <o3tl/enumarray.hxx>
28 #include <oox/dllapi.h>
29 #include <oox/helper/propertymap.hxx>
30 #include <rtl/ustring.hxx>
31 #include <sal/types.h>
33 namespace oox
{ class ModelObjectHelper
; }
38 /** Enumeration for various properties related to drawing shape formatting.
40 This is an abstraction for shape formatting properties that have different
41 names in various implementations, e.g. drawing shapes vs. chart objects.
43 If you *insert* ids into this list, then update spnCommonPropIds, spnLinearPropIds
44 and spnFilledPropIds of oox/source/drawingml/chart/objectformatter.cxx if
45 the newly inserted enum is inside the range they cover
47 enum class ShapeProperty
53 LineDash
, /// Explicit line dash or name of a line dash stored in a global container.
55 LineStart
, /// Explicit line start marker or name of a line marker stored in a global container.
58 LineEnd
, /// Explicit line end marker or name of a line marker stored in a global container.
65 FillGradient
, /// Explicit fill gradient or name of a fill gradient stored in a global container.
66 FillBitmapUrl
, /// Explicit fill bitmap URL or name of a fill bitmap URL stored in a global container.
72 FillBitmapRectanglePoint
,
75 FillBitmapNameFromUrl
,
76 LAST
= FillBitmapNameFromUrl
79 typedef o3tl::enumarray
<ShapeProperty
, sal_Int32
> ShapePropertyIds
;
81 struct OOX_DLLPUBLIC ShapePropertyInfo
83 const ShapePropertyIds
& mrPropertyIds
;
84 bool mbNamedLineMarker
; /// True = use named line marker instead of explicit line marker.
85 bool mbNamedLineDash
; /// True = use named line dash instead of explicit line dash.
86 bool mbNamedFillGradient
; /// True = use named fill gradient instead of explicit fill gradient.
87 bool mbNamedFillBitmapUrl
; /// True = use named fill bitmap URL instead of explicit fill bitmap URL.
89 static ShapePropertyInfo DEFAULT
; /// Default property info (used as default parameter of other methods).
91 explicit ShapePropertyInfo(
92 const ShapePropertyIds
& rnPropertyIds
,
93 bool bNamedLineMarker
,
95 bool bNamedFillGradient
,
96 bool bNamedFillBitmapUrl
);
98 bool has( ShapeProperty ePropId
) const { return mrPropertyIds
[ ePropId
] >= 0; }
99 sal_Int32
operator[]( ShapeProperty ePropId
) const { return mrPropertyIds
[ ePropId
]; }
103 class OOX_DLLPUBLIC ShapePropertyMap
: public PropertyMap
106 explicit ShapePropertyMap(
107 ModelObjectHelper
& rModelObjHelper
,
108 const ShapePropertyInfo
& rShapePropInfo
= ShapePropertyInfo::DEFAULT
);
110 /** Returns true, if the specified property is supported. */
111 bool supportsProperty( ShapeProperty ePropId
) const;
113 /** Returns true, if named line markers are supported, and the specified
114 line marker has already been inserted into the marker table. */
115 bool hasNamedLineMarkerInTable( const OUString
& rMarkerName
) const;
117 /** Sets the specified shape property to the passed value. */
118 bool setAnyProperty( ShapeProperty ePropId
, const css::uno::Any
& rValue
);
120 /** Sets the specified shape property to the passed value. */
121 template< typename Type
>
122 bool setProperty( ShapeProperty ePropId
, const Type
& rValue
)
123 { return setAnyProperty( ePropId
, css::uno::Any( rValue
) ); }
125 using PropertyMap::setAnyProperty
;
126 using PropertyMap::setProperty
;
129 /** Sets an explicit line marker, or creates a named line marker. */
130 bool setLineMarker( sal_Int32 nPropId
, const css::uno::Any
& rValue
);
131 /** Sets an explicit line dash, or creates a named line dash. */
132 bool setLineDash( sal_Int32 nPropId
, const css::uno::Any
& rValue
);
133 /** Sets an explicit fill gradient, or creates a named fill gradient. */
134 bool setFillGradient( sal_Int32 nPropId
, const css::uno::Any
& rValue
);
135 /** Creates a named transparency gradient. */
136 bool setGradientTrans( sal_Int32 nPropId
, const css::uno::Any
& rValue
);
137 /** Sets an explicit fill bitmap URL, or creates a named fill bitmap URL. */
138 bool setFillBitmapUrl( sal_Int32 nPropId
, const css::uno::Any
& rValue
);
139 /** Sets an explicit fill bitmap URL and pushes the name to FillBitmapName */
140 bool setFillBitmapNameFromUrl( const css::uno::Any
& rValue
);
142 // not implemented, to prevent implicit conversion from enum to int
143 css::uno::Any
& operator[]( ShapeProperty ePropId
) = delete;
144 const css::uno::Any
& operator[]( ShapeProperty ePropId
) const = delete;
147 ModelObjectHelper
& mrModelObjHelper
;
148 ShapePropertyInfo maShapePropInfo
;
152 } // namespace drawingml
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */