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 #include <FillProperties.hxx>
21 #include <com/sun/star/beans/PropertyAttribute.hpp>
22 #include <com/sun/star/drawing/BitmapMode.hpp>
23 #include <com/sun/star/drawing/FillStyle.hpp>
24 #include <com/sun/star/drawing/RectanglePoint.hpp>
25
26 using namespace ::com::sun::star;
27
28 using ::com::sun::star::beans::Property;
29
30 namespace chart
31 {
32
33 namespace
34 {
35
lcl_AddPropertiesToVector_without_BitmapProperties(std::vector<css::beans::Property> & rOutProperties)36 void lcl_AddPropertiesToVector_without_BitmapProperties( std::vector< css::beans::Property > & rOutProperties )
37 {
38 rOutProperties.emplace_back( "FillStyle",
39 FillProperties::PROP_FILL_STYLE,
40 cppu::UnoType<drawing::FillStyle>::get(),
41 beans::PropertyAttribute::BOUND
42 | beans::PropertyAttribute::MAYBEDEFAULT );
43
44 rOutProperties.emplace_back( "FillColor",
45 FillProperties::PROP_FILL_COLOR,
46 cppu::UnoType<sal_Int32>::get(),
47 beans::PropertyAttribute::BOUND
48 | beans::PropertyAttribute::MAYBEVOID // "maybe auto"
49 | beans::PropertyAttribute::MAYBEDEFAULT );
50
51 rOutProperties.emplace_back( "FillTransparence",
52 FillProperties::PROP_FILL_TRANSPARENCE,
53 cppu::UnoType<sal_Int16>::get(),
54 beans::PropertyAttribute::BOUND
55 | beans::PropertyAttribute::MAYBEDEFAULT );
56
57 rOutProperties.emplace_back( "FillTransparenceGradientName",
58 FillProperties::PROP_FILL_TRANSPARENCE_GRADIENT_NAME,
59 cppu::UnoType<OUString>::get(),
60 beans::PropertyAttribute::BOUND
61 | beans::PropertyAttribute::MAYBEVOID
62 | beans::PropertyAttribute::MAYBEDEFAULT );
63
64 rOutProperties.emplace_back( "FillGradientName",
65 FillProperties::PROP_FILL_GRADIENT_NAME,
66 cppu::UnoType<OUString>::get(),
67 beans::PropertyAttribute::BOUND
68 | beans::PropertyAttribute::MAYBEVOID
69 | beans::PropertyAttribute::MAYBEDEFAULT );
70
71 rOutProperties.emplace_back( "FillGradientStepCount",
72 FillProperties::PROP_FILL_GRADIENT_STEPCOUNT,
73 cppu::UnoType<sal_Int16>::get(),
74 beans::PropertyAttribute::BOUND
75 | beans::PropertyAttribute::MAYBEVOID );
76
77 rOutProperties.emplace_back( "FillHatchName",
78 FillProperties::PROP_FILL_HATCH_NAME,
79 cppu::UnoType<OUString>::get(),
80 beans::PropertyAttribute::BOUND
81 | beans::PropertyAttribute::MAYBEVOID
82 | beans::PropertyAttribute::MAYBEDEFAULT );
83
84 //bitmap properties see lcl_AddPropertiesToVector_only_BitmapProperties()
85
86 rOutProperties.emplace_back( "FillBackground",
87 FillProperties::PROP_FILL_BACKGROUND,
88 cppu::UnoType<sal_Bool>::get(),
89 beans::PropertyAttribute::BOUND
90 | beans::PropertyAttribute::MAYBEDEFAULT );
91 }
92
lcl_AddPropertiesToVector_only_BitmapProperties(std::vector<css::beans::Property> & rOutProperties)93 void lcl_AddPropertiesToVector_only_BitmapProperties( std::vector< css::beans::Property > & rOutProperties )
94 {
95 rOutProperties.emplace_back( "FillBitmapName",
96 FillProperties::PROP_FILL_BITMAP_NAME,
97 cppu::UnoType<OUString>::get(),
98 beans::PropertyAttribute::BOUND
99 | beans::PropertyAttribute::MAYBEVOID
100 | beans::PropertyAttribute::MAYBEDEFAULT );
101
102 rOutProperties.emplace_back( "FillBitmapOffsetX",
103 FillProperties::PROP_FILL_BITMAP_OFFSETX,
104 cppu::UnoType<sal_Int16>::get(),
105 beans::PropertyAttribute::BOUND
106 | beans::PropertyAttribute::MAYBEDEFAULT );
107
108 rOutProperties.emplace_back( "FillBitmapOffsetY",
109 FillProperties::PROP_FILL_BITMAP_OFFSETY,
110 cppu::UnoType<sal_Int16>::get(),
111 beans::PropertyAttribute::BOUND
112 | beans::PropertyAttribute::MAYBEDEFAULT );
113
114 rOutProperties.emplace_back( "FillBitmapPositionOffsetX",
115 FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETX,
116 cppu::UnoType<sal_Int16>::get(),
117 beans::PropertyAttribute::BOUND
118 | beans::PropertyAttribute::MAYBEDEFAULT );
119
120 rOutProperties.emplace_back( "FillBitmapPositionOffsetY",
121 FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETY,
122 cppu::UnoType<sal_Int16>::get(),
123 beans::PropertyAttribute::BOUND
124 | beans::PropertyAttribute::MAYBEDEFAULT );
125
126 rOutProperties.emplace_back( "FillBitmapRectanglePoint",
127 FillProperties::PROP_FILL_BITMAP_RECTANGLEPOINT,
128 cppu::UnoType<drawing::RectanglePoint>::get(),
129 beans::PropertyAttribute::BOUND
130 | beans::PropertyAttribute::MAYBEDEFAULT );
131
132 rOutProperties.emplace_back( "FillBitmapLogicalSize",
133 FillProperties::PROP_FILL_BITMAP_LOGICALSIZE,
134 cppu::UnoType<sal_Bool>::get(),
135 beans::PropertyAttribute::BOUND
136 | beans::PropertyAttribute::MAYBEDEFAULT );
137
138 rOutProperties.emplace_back( "FillBitmapSizeX",
139 FillProperties::PROP_FILL_BITMAP_SIZEX,
140 cppu::UnoType<sal_Int32>::get(),
141 beans::PropertyAttribute::BOUND
142 | beans::PropertyAttribute::MAYBEDEFAULT );
143
144 rOutProperties.emplace_back( "FillBitmapSizeY",
145 FillProperties::PROP_FILL_BITMAP_SIZEY,
146 cppu::UnoType<sal_Int32>::get(),
147 beans::PropertyAttribute::BOUND
148 | beans::PropertyAttribute::MAYBEDEFAULT );
149
150 rOutProperties.emplace_back( "FillBitmapMode",
151 FillProperties::PROP_FILL_BITMAP_MODE,
152 cppu::UnoType<drawing::BitmapMode>::get(),
153 beans::PropertyAttribute::BOUND
154 | beans::PropertyAttribute::MAYBEDEFAULT );
155 }
156
lcl_AddDefaultsToMap_without_BitmapProperties(::chart::tPropertyValueMap & rOutMap)157 void lcl_AddDefaultsToMap_without_BitmapProperties(
158 ::chart::tPropertyValueMap & rOutMap )
159 {
160 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_STYLE, drawing::FillStyle_SOLID );
161 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, FillProperties::PROP_FILL_COLOR, 0xd9d9d9 ); // gray85
162 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, FillProperties::PROP_FILL_TRANSPARENCE, 0 );
163 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BACKGROUND, false );
164 }
165
lcl_AddDefaultsToMap_only_BitmapProperties(::chart::tPropertyValueMap & rOutMap)166 void lcl_AddDefaultsToMap_only_BitmapProperties(
167 ::chart::tPropertyValueMap & rOutMap )
168 {
169 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, FillProperties::PROP_FILL_BITMAP_OFFSETX, 0 );
170 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, FillProperties::PROP_FILL_BITMAP_OFFSETY, 0 );
171 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETX, 0 );
172 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETY, 0 );
173
174 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_RECTANGLEPOINT, drawing::RectanglePoint_MIDDLE_MIDDLE );
175 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_LOGICALSIZE, true );
176 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, FillProperties::PROP_FILL_BITMAP_SIZEX, 0 );
177 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, FillProperties::PROP_FILL_BITMAP_SIZEY, 0 );
178 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_MODE, drawing::BitmapMode_REPEAT );
179 }
180
181 }//end anonymous namespace
182
AddPropertiesToVector(std::vector<Property> & rOutProperties)183 void FillProperties::AddPropertiesToVector(
184 std::vector< Property > & rOutProperties )
185 {
186 // Fill Properties see service drawing::FillProperties
187 lcl_AddPropertiesToVector_without_BitmapProperties( rOutProperties );
188 lcl_AddPropertiesToVector_only_BitmapProperties( rOutProperties );
189 }
190
AddDefaultsToMap(::chart::tPropertyValueMap & rOutMap)191 void FillProperties::AddDefaultsToMap(
192 ::chart::tPropertyValueMap & rOutMap )
193 {
194 lcl_AddDefaultsToMap_without_BitmapProperties( rOutMap );
195 lcl_AddDefaultsToMap_only_BitmapProperties( rOutMap );
196 }
197
198 } // namespace chart
199
200 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
201