LibreOffice Module oox (master)  1
shapepropertymap.hxx
Go to the documentation of this file.
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 INCLUDED_OOX_DRAWINGML_SHAPEPROPERTYMAP_HXX
21 #define INCLUDED_OOX_DRAWINGML_SHAPEPROPERTYMAP_HXX
22 
23 #include <com/sun/star/uno/Any.hxx>
24 #include <o3tl/enumarray.hxx>
25 #include <oox/dllapi.h>
27 #include <rtl/ustring.hxx>
28 #include <sal/types.h>
29 #include <tools/color.hxx>
30 
31 namespace oox { class ModelObjectHelper; }
32 
33 namespace oox::drawingml {
34 
44 enum class ShapeProperty
45 {
46  LineStyle,
47  LineWidth,
48  LineColor,
50  LineDash,
51  LineCap,
52  LineJoint,
53  LineStart,
56  LineEnd,
59  FillStyle,
60  FillColor,
63  FillGradient,
64  FillBitmap,
71  FillHatch,
77  LAST = ShadowSizeY
78 };
79 
81 
83 {
84  const ShapePropertyIds& mrPropertyIds;
90 
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  {
99  return mrPropertyIds[ePropId] >= 0;
100  }
101  sal_Int32 operator[](ShapeProperty ePropId) const
102  {
103  return mrPropertyIds[ePropId];
104  }
105 };
106 
108 {
109 public:
110  explicit ShapePropertyMap(ModelObjectHelper& rModelObjHelper,
111  const ShapePropertyInfo& rShapePropInfo = ShapePropertyInfo::DEFAULT );
112 
114  bool supportsProperty( ShapeProperty ePropId ) const;
115 
118  bool hasNamedLineMarkerInTable( const OUString& rMarkerName ) const;
119 
121  bool setAnyProperty( ShapeProperty ePropId, const css::uno::Any& rValue );
122 
124  template<typename Type>
125  bool setProperty(ShapeProperty ePropId, const Type& rValue)
126  {
127  return setAnyProperty(ePropId, css::uno::Any(rValue));
128  }
129  bool setProperty(ShapeProperty ePropId, const ::Color& rValue)
130  {
131  return setAnyProperty(ePropId, css::uno::makeAny(rValue));
132  }
133 
136 
137 private:
139  bool setLineMarker( sal_Int32 nPropId, const css::uno::Any& rValue );
141  bool setLineDash( sal_Int32 nPropId, const css::uno::Any& rValue );
143  bool setFillGradient( sal_Int32 nPropId, const css::uno::Any& rValue );
145  bool setGradientTrans( sal_Int32 nPropId, const css::uno::Any& rValue );
147  bool setFillBitmap( sal_Int32 nPropId, const css::uno::Any& rValue );
149  bool setFillBitmapName( const css::uno::Any& rValue );
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:
160 };
161 
162 
163 } // namespace oox::drawingml
164 
165 #endif
166 
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Type
bool has(ShapeProperty ePropId) const
bool mbNamedLineDash
True = use named line marker instead of explicit line marker.
A helper that maps property identifiers to property values.
Definition: propertymap.hxx:52
bool setProperty(ShapeProperty ePropId, const ::Color &rValue)
bool setProperty(ShapeProperty ePropId, const Type &rValue)
Sets the specified shape property to the passed value.
o3tl::enumarray< ShapeProperty, sal_Int32 > ShapePropertyIds
bool setProperty(sal_Int32 nPropId, Type &&rValue)
Sets the specified property to the passed value.
Definition: propertymap.hxx:70
bool mbNamedFillHatch
True = use named fill bitmap instead of explicit fill bitmap.
static ShapePropertyInfo DEFAULT
True = use named fill hatch instead of explicit fill hatch.
Explicit fill bitmap or name of a fill bitmap stored in a global container.
Contains tables for named drawing objects for a document model.
bool setAnyProperty(sal_Int32 nPropId, const css::uno::Any &rValue)
Sets the specified property to the passed value.
const ShapePropertyIds & mrPropertyIds
Explicit fill gradient or name of a fill gradient stored in a global container.
ShapeProperty
Enumeration for various properties related to drawing shape formatting.
bool mbNamedFillBitmap
True = use named fill gradient instead of explicit fill gradient.
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
Explicit fill hatch or name of a fill hatch stored in a global container.
sal_Int32 operator[](ShapeProperty ePropId) const
Explicit line dash or name of a line dash stored in a global container.
Explicit line start marker or name of a line marker stored in a global container. ...
bool mbNamedFillGradient
True = use named line dash instead of explicit line dash.
Explicit line end marker or name of a line marker stored in a global container.