Branch data Line data Source code
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 OOX_DRAWINGML_SHAPEPROPERTYMAP_HXX
21 : : #define OOX_DRAWINGML_SHAPEPROPERTYMAP_HXX
22 : :
23 : : #include "oox/helper/propertymap.hxx"
24 : : #include "oox/dllapi.h"
25 : :
26 : : namespace oox { class ModelObjectHelper; }
27 : :
28 : : namespace oox {
29 : : namespace drawingml {
30 : :
31 : : // ============================================================================
32 : :
33 : : /** Enumeration for various properties related to drawing shape formatting.
34 : :
35 : : This is an abstraction for shape formatting properties that have different
36 : : names in various implementations, e.g. drawing shapes vs. chart objects.
37 : : */
38 : : enum ShapePropertyId
39 : : {
40 : : SHAPEPROP_LineStyle,
41 : : SHAPEPROP_LineWidth,
42 : : SHAPEPROP_LineColor,
43 : : SHAPEPROP_LineTransparency,
44 : : SHAPEPROP_LineDash, /// Explicit line dash or name of a line dash stored in a global container.
45 : : SHAPEPROP_LineJoint,
46 : : SHAPEPROP_LineStart, /// Explicit line start marker or name of a line marker stored in a global container.
47 : : SHAPEPROP_LineStartWidth,
48 : : SHAPEPROP_LineStartCenter,
49 : : SHAPEPROP_LineEnd, /// Explicit line end marker or name of a line marker stored in a global container.
50 : : SHAPEPROP_LineEndWidth,
51 : : SHAPEPROP_LineEndCenter,
52 : : SHAPEPROP_FillStyle,
53 : : SHAPEPROP_FillColor,
54 : : SHAPEPROP_FillTransparency,
55 : : SHAPEPROP_GradientTransparency,
56 : : SHAPEPROP_FillGradient, /// Explicit fill gradient or name of a fill gradient stored in a global container.
57 : : SHAPEPROP_FillBitmapUrl, /// Explicit fill bitmap URL or name of a fill bitmap URL stored in a global container.
58 : : SHAPEPROP_FillBitmapMode,
59 : : SHAPEPROP_FillBitmapSizeX,
60 : : SHAPEPROP_FillBitmapSizeY,
61 : : SHAPEPROP_FillBitmapOffsetX,
62 : : SHAPEPROP_FillBitmapOffsetY,
63 : : SHAPEPROP_FillBitmapRectanglePoint,
64 : : SHAPEPROP_END
65 : : };
66 : :
67 : : // ============================================================================
68 : :
69 : : struct OOX_DLLPUBLIC ShapePropertyInfo
70 : : {
71 : : const sal_Int32* mpnPropertyIds; /// Pointer to array of property identifiers for all SHAPEPROP properties.
72 : : bool mbNamedLineMarker; /// True = use named line marker instead of explicit line marker.
73 : : bool mbNamedLineDash; /// True = use named line dash instead of explicit line dash.
74 : : bool mbNamedFillGradient; /// True = use named fill gradient instead of explicit fill gradient.
75 : : bool mbNamedFillBitmapUrl; /// True = use named fill bitmap URL instead of explicit fill bitmap URL.
76 : :
77 : : static ShapePropertyInfo DEFAULT; /// Default property info (used as default parameter of other methods).
78 : :
79 : : explicit ShapePropertyInfo(
80 : : const sal_Int32* pnPropertyIds,
81 : : bool bNamedLineMarker,
82 : : bool bNamedLineDash,
83 : : bool bNamedFillGradient,
84 : : bool bNamedFillBitmapUrl );
85 : :
86 : 0 : inline bool has( ShapePropertyId ePropId ) const { return mpnPropertyIds[ ePropId ] >= 0; }
87 : 582 : inline sal_Int32 operator[]( ShapePropertyId ePropId ) const { return mpnPropertyIds[ ePropId ]; }
88 : : };
89 : :
90 : : // ============================================================================
91 : :
92 : 129 : class OOX_DLLPUBLIC ShapePropertyMap : public PropertyMap
93 : : {
94 : : public:
95 : : explicit ShapePropertyMap(
96 : : ModelObjectHelper& rModelObjHelper,
97 : : const ShapePropertyInfo& rShapePropInfo = ShapePropertyInfo::DEFAULT );
98 : :
99 : : /** Returns true, if the specified property is supported. */
100 : : bool supportsProperty( ShapePropertyId ePropId ) const;
101 : :
102 : : /** Returns true, if named line markers are supported, and the specified
103 : : line marker has already been inserted into the marker table. */
104 : : bool hasNamedLineMarkerInTable( const ::rtl::OUString& rMarkerName ) const;
105 : :
106 : : /** Sets the specified shape property to the passed value. */
107 : : bool setAnyProperty( ShapePropertyId ePropId, const ::com::sun::star::uno::Any& rValue );
108 : :
109 : : /** Sets the specified shape property to the passed value. */
110 : : template< typename Type >
111 : 582 : inline bool setProperty( ShapePropertyId ePropId, const Type& rValue )
112 [ + - ][ + - ]: 582 : { return setAnyProperty( ePropId, ::com::sun::star::uno::Any( rValue ) ); }
[ + - ][ # # ]
[ + - ][ # # ]
[ + - ]
113 : :
114 : : using PropertyMap::setAnyProperty;
115 : : using PropertyMap::setProperty;
116 : : using PropertyMap::operator[];
117 : :
118 : : private:
119 : : /** Sets an explicit line marker, or creates a named line marker. */
120 : : bool setLineMarker( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue );
121 : : /** Sets an explicit line dash, or creates a named line dash. */
122 : : bool setLineDash( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue );
123 : : /** Sets an explicit fill gradient, or creates a named fill gradient. */
124 : : bool setFillGradient( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue );
125 : : /** Creates a named transparency gradient. */
126 : : bool setGradientTrans( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue );
127 : : /** Sets an explicit fill bitmap URL, or creates a named fill bitmap URL. */
128 : : bool setFillBitmapUrl( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue );
129 : :
130 : : // not implemented, to prevent implicit conversion from enum to int
131 : : ::com::sun::star::uno::Any& operator[]( ShapePropertyId ePropId );
132 : : const ::com::sun::star::uno::Any& operator[]( ShapePropertyId ePropId ) const;
133 : :
134 : : private:
135 : : ModelObjectHelper& mrModelObjHelper;
136 : : ShapePropertyInfo maShapePropInfo;
137 : : };
138 : :
139 : : // ============================================================================
140 : :
141 : : } // namespace drawingml
142 : : } // namespace oox
143 : :
144 : : #endif
145 : :
146 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|