1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
31 #include "SceneProperties.hxx"
33 #include "ChartTypeHelper.hxx"
34 #include "ThreeDHelper.hxx"
35 #include <com/sun/star/beans/PropertyAttribute.hpp>
36 #include <com/sun/star/drawing/HomogenMatrix.hpp>
37 #include <com/sun/star/drawing/ShadeMode.hpp>
38 #include <com/sun/star/drawing/Direction3D.hpp>
39 #include <com/sun/star/drawing/ProjectionMode.hpp>
40 #include <com/sun/star/drawing/CameraGeometry.hpp>
43 #include <tools/solar.h>
45 using namespace ::com::sun::star
;
47 using ::com::sun::star::beans::Property
;
52 void SceneProperties::AddPropertiesToVector(
53 ::std::vector
< Property
> & rOutProperties
)
55 // transformation matrix
56 rOutProperties
.push_back(
57 Property( C2U( "D3DTransformMatrix" ),
58 PROP_SCENE_TRANSF_MATRIX
,
59 ::getCppuType( reinterpret_cast< const drawing::HomogenMatrix
* >(0)),
60 beans::PropertyAttribute::BOUND
61 | beans::PropertyAttribute::MAYBEVOID
62 | beans::PropertyAttribute::MAYBEDEFAULT
));
64 // distance: deprecated ( this is not used by the chart view; it's only here for compatibility with old chart )
65 rOutProperties
.push_back(
66 Property( C2U( "D3DSceneDistance" ),
68 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
69 beans::PropertyAttribute::BOUND
70 | beans::PropertyAttribute::MAYBEVOID
71 | beans::PropertyAttribute::MAYBEDEFAULT
));
73 // focalLength: deprecated ( this is not used by the chart view; it's only here for compatibility with old chart )
74 rOutProperties
.push_back(
75 Property( C2U( "D3DSceneFocalLength" ),
76 PROP_SCENE_FOCAL_LENGTH
,
77 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
78 beans::PropertyAttribute::BOUND
79 | beans::PropertyAttribute::MAYBEVOID
80 | beans::PropertyAttribute::MAYBEDEFAULT
));
83 rOutProperties
.push_back(
84 Property( C2U( "D3DSceneShadowSlant" ),
85 PROP_SCENE_SHADOW_SLANT
,
86 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
87 beans::PropertyAttribute::BOUND
88 | beans::PropertyAttribute::MAYBEVOID
89 | beans::PropertyAttribute::MAYBEDEFAULT
));
92 rOutProperties
.push_back(
93 Property( C2U( "D3DSceneShadeMode" ),
94 PROP_SCENE_SHADE_MODE
,
95 ::getCppuType( reinterpret_cast< const drawing::ShadeMode
* >(0)),
96 beans::PropertyAttribute::BOUND
97 | beans::PropertyAttribute::MAYBEVOID
98 | beans::PropertyAttribute::MAYBEDEFAULT
));
101 rOutProperties
.push_back(
102 Property( C2U( "D3DSceneAmbientColor" ),
103 PROP_SCENE_AMBIENT_COLOR
,
104 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
105 beans::PropertyAttribute::BOUND
106 | beans::PropertyAttribute::MAYBEVOID
107 | beans::PropertyAttribute::MAYBEDEFAULT
));
110 rOutProperties
.push_back(
111 Property( C2U( "D3DSceneTwoSidedLighting" ),
112 PROP_SCENE_TWO_SIDED_LIGHTING
,
113 ::getBooleanCppuType(),
114 beans::PropertyAttribute::BOUND
115 | beans::PropertyAttribute::MAYBEVOID
116 | beans::PropertyAttribute::MAYBEDEFAULT
));
119 rOutProperties
.push_back(
120 Property( C2U( "D3DCameraGeometry" ),
121 PROP_SCENE_CAMERA_GEOMETRY
,
122 ::getCppuType( reinterpret_cast< const drawing::CameraGeometry
* >(0)),
123 beans::PropertyAttribute::BOUND
124 | beans::PropertyAttribute::MAYBEVOID
125 | beans::PropertyAttribute::MAYBEDEFAULT
));
128 rOutProperties
.push_back(
129 Property( C2U( "D3DScenePerspective" ),
130 PROP_SCENE_PERSPECTIVE
,
131 ::getCppuType( reinterpret_cast< const drawing::ProjectionMode
* >(0)),
132 beans::PropertyAttribute::BOUND
133 | beans::PropertyAttribute::MAYBEVOID
134 | beans::PropertyAttribute::MAYBEDEFAULT
));
140 rOutProperties
.push_back(
141 Property( C2U( "D3DSceneLightColor1" ),
142 PROP_SCENE_LIGHT_COLOR_1
,
143 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
144 beans::PropertyAttribute::BOUND
145 | beans::PropertyAttribute::MAYBEVOID
146 | beans::PropertyAttribute::MAYBEDEFAULT
));
147 rOutProperties
.push_back(
148 Property( C2U( "D3DSceneLightDirection1" ),
149 PROP_SCENE_LIGHT_DIRECTION_1
,
150 ::getCppuType( reinterpret_cast< const drawing::Direction3D
* >(0)),
151 beans::PropertyAttribute::BOUND
152 | beans::PropertyAttribute::MAYBEVOID
153 | beans::PropertyAttribute::MAYBEDEFAULT
));
154 rOutProperties
.push_back(
155 Property( C2U( "D3DSceneLightOn1" ),
156 PROP_SCENE_LIGHT_ON_1
,
157 ::getBooleanCppuType(),
158 beans::PropertyAttribute::BOUND
159 | beans::PropertyAttribute::MAYBEVOID
160 | beans::PropertyAttribute::MAYBEDEFAULT
));
162 rOutProperties
.push_back(
163 Property( C2U( "D3DSceneLightColor2" ),
164 PROP_SCENE_LIGHT_COLOR_2
,
165 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
166 beans::PropertyAttribute::BOUND
167 | beans::PropertyAttribute::MAYBEVOID
168 | beans::PropertyAttribute::MAYBEDEFAULT
));
169 rOutProperties
.push_back(
170 Property( C2U( "D3DSceneLightDirection2" ),
171 PROP_SCENE_LIGHT_DIRECTION_2
,
172 ::getCppuType( reinterpret_cast< const drawing::Direction3D
* >(0)),
173 beans::PropertyAttribute::BOUND
174 | beans::PropertyAttribute::MAYBEVOID
175 | beans::PropertyAttribute::MAYBEDEFAULT
));
176 rOutProperties
.push_back(
177 Property( C2U( "D3DSceneLightOn2" ),
178 PROP_SCENE_LIGHT_ON_2
,
179 ::getBooleanCppuType(),
180 beans::PropertyAttribute::BOUND
181 | beans::PropertyAttribute::MAYBEVOID
182 | beans::PropertyAttribute::MAYBEDEFAULT
));
184 rOutProperties
.push_back(
185 Property( C2U( "D3DSceneLightColor3" ),
186 PROP_SCENE_LIGHT_COLOR_3
,
187 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
188 beans::PropertyAttribute::BOUND
189 | beans::PropertyAttribute::MAYBEVOID
190 | beans::PropertyAttribute::MAYBEDEFAULT
));
191 rOutProperties
.push_back(
192 Property( C2U( "D3DSceneLightDirection3" ),
193 PROP_SCENE_LIGHT_DIRECTION_3
,
194 ::getCppuType( reinterpret_cast< const drawing::Direction3D
* >(0)),
195 beans::PropertyAttribute::BOUND
196 | beans::PropertyAttribute::MAYBEVOID
197 | beans::PropertyAttribute::MAYBEDEFAULT
));
198 rOutProperties
.push_back(
199 Property( C2U( "D3DSceneLightOn3" ),
200 PROP_SCENE_LIGHT_ON_3
,
201 ::getBooleanCppuType(),
202 beans::PropertyAttribute::BOUND
203 | beans::PropertyAttribute::MAYBEVOID
204 | beans::PropertyAttribute::MAYBEDEFAULT
));
206 rOutProperties
.push_back(
207 Property( C2U( "D3DSceneLightColor4" ),
208 PROP_SCENE_LIGHT_COLOR_4
,
209 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
210 beans::PropertyAttribute::BOUND
211 | beans::PropertyAttribute::MAYBEVOID
212 | beans::PropertyAttribute::MAYBEDEFAULT
));
213 rOutProperties
.push_back(
214 Property( C2U( "D3DSceneLightDirection4" ),
215 PROP_SCENE_LIGHT_DIRECTION_4
,
216 ::getCppuType( reinterpret_cast< const drawing::Direction3D
* >(0)),
217 beans::PropertyAttribute::BOUND
218 | beans::PropertyAttribute::MAYBEVOID
219 | beans::PropertyAttribute::MAYBEDEFAULT
));
220 rOutProperties
.push_back(
221 Property( C2U( "D3DSceneLightOn4" ),
222 PROP_SCENE_LIGHT_ON_4
,
223 ::getBooleanCppuType(),
224 beans::PropertyAttribute::BOUND
225 | beans::PropertyAttribute::MAYBEVOID
226 | beans::PropertyAttribute::MAYBEDEFAULT
));
228 rOutProperties
.push_back(
229 Property( C2U( "D3DSceneLightColor5" ),
230 PROP_SCENE_LIGHT_COLOR_5
,
231 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
232 beans::PropertyAttribute::BOUND
233 | beans::PropertyAttribute::MAYBEVOID
234 | beans::PropertyAttribute::MAYBEDEFAULT
));
235 rOutProperties
.push_back(
236 Property( C2U( "D3DSceneLightDirection5" ),
237 PROP_SCENE_LIGHT_DIRECTION_5
,
238 ::getCppuType( reinterpret_cast< const drawing::Direction3D
* >(0)),
239 beans::PropertyAttribute::BOUND
240 | beans::PropertyAttribute::MAYBEVOID
241 | beans::PropertyAttribute::MAYBEDEFAULT
));
242 rOutProperties
.push_back(
243 Property( C2U( "D3DSceneLightOn5" ),
244 PROP_SCENE_LIGHT_ON_5
,
245 ::getBooleanCppuType(),
246 beans::PropertyAttribute::BOUND
247 | beans::PropertyAttribute::MAYBEVOID
248 | beans::PropertyAttribute::MAYBEDEFAULT
));
250 rOutProperties
.push_back(
251 Property( C2U( "D3DSceneLightColor6" ),
252 PROP_SCENE_LIGHT_COLOR_6
,
253 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
254 beans::PropertyAttribute::BOUND
255 | beans::PropertyAttribute::MAYBEVOID
256 | beans::PropertyAttribute::MAYBEDEFAULT
));
257 rOutProperties
.push_back(
258 Property( C2U( "D3DSceneLightDirection6" ),
259 PROP_SCENE_LIGHT_DIRECTION_6
,
260 ::getCppuType( reinterpret_cast< const drawing::Direction3D
* >(0)),
261 beans::PropertyAttribute::BOUND
262 | beans::PropertyAttribute::MAYBEVOID
263 | beans::PropertyAttribute::MAYBEDEFAULT
));
264 rOutProperties
.push_back(
265 Property( C2U( "D3DSceneLightOn6" ),
266 PROP_SCENE_LIGHT_ON_6
,
267 ::getBooleanCppuType(),
268 beans::PropertyAttribute::BOUND
269 | beans::PropertyAttribute::MAYBEVOID
270 | beans::PropertyAttribute::MAYBEDEFAULT
));
272 rOutProperties
.push_back(
273 Property( C2U( "D3DSceneLightColor7" ),
274 PROP_SCENE_LIGHT_COLOR_7
,
275 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
276 beans::PropertyAttribute::BOUND
277 | beans::PropertyAttribute::MAYBEVOID
278 | beans::PropertyAttribute::MAYBEDEFAULT
));
279 rOutProperties
.push_back(
280 Property( C2U( "D3DSceneLightDirection7" ),
281 PROP_SCENE_LIGHT_DIRECTION_7
,
282 ::getCppuType( reinterpret_cast< const drawing::Direction3D
* >(0)),
283 beans::PropertyAttribute::BOUND
284 | beans::PropertyAttribute::MAYBEVOID
285 | beans::PropertyAttribute::MAYBEDEFAULT
));
286 rOutProperties
.push_back(
287 Property( C2U( "D3DSceneLightOn7" ),
288 PROP_SCENE_LIGHT_ON_7
,
289 ::getBooleanCppuType(),
290 beans::PropertyAttribute::BOUND
291 | beans::PropertyAttribute::MAYBEVOID
292 | beans::PropertyAttribute::MAYBEDEFAULT
));
294 rOutProperties
.push_back(
295 Property( C2U( "D3DSceneLightColor8" ),
296 PROP_SCENE_LIGHT_COLOR_8
,
297 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
298 beans::PropertyAttribute::BOUND
299 | beans::PropertyAttribute::MAYBEVOID
300 | beans::PropertyAttribute::MAYBEDEFAULT
));
301 rOutProperties
.push_back(
302 Property( C2U( "D3DSceneLightDirection8" ),
303 PROP_SCENE_LIGHT_DIRECTION_8
,
304 ::getCppuType( reinterpret_cast< const drawing::Direction3D
* >(0)),
305 beans::PropertyAttribute::BOUND
306 | beans::PropertyAttribute::MAYBEVOID
307 | beans::PropertyAttribute::MAYBEDEFAULT
));
308 rOutProperties
.push_back(
309 Property( C2U( "D3DSceneLightOn8" ),
310 PROP_SCENE_LIGHT_ON_8
,
311 ::getBooleanCppuType(),
312 beans::PropertyAttribute::BOUND
313 | beans::PropertyAttribute::MAYBEVOID
314 | beans::PropertyAttribute::MAYBEDEFAULT
));
317 void SceneProperties::AddDefaultsToMap(
318 ::chart::tPropertyValueMap
& rOutMap
)
321 drawing::HomogenMatrix aMtx
;
322 aMtx
.Line1
.Column1
= aMtx
.Line2
.Column2
=
323 aMtx
.Line3
.Column3
= aMtx
.Line4
.Column4
= 1.0;
324 aMtx
.Line1
.Column2
= aMtx
.Line1
.Column3
= aMtx
.Line1
.Column4
=
325 aMtx
.Line2
.Column1
= aMtx
.Line2
.Column3
= aMtx
.Line2
.Column4
=
326 aMtx
.Line3
.Column1
= aMtx
.Line3
.Column2
= aMtx
.Line3
.Column4
=
327 aMtx
.Line4
.Column1
= aMtx
.Line4
.Column2
= aMtx
.Line4
.Column3
= 0.0;
329 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_TRANSF_MATRIX
, aMtx
);
330 ::chart::PropertyHelper::setPropertyValueDefault
< sal_Int32
>( rOutMap
, PROP_SCENE_DISTANCE
, 4200 );
331 ::chart::PropertyHelper::setPropertyValueDefault
< sal_Int32
>( rOutMap
, PROP_SCENE_FOCAL_LENGTH
, 8000 );
333 // PROP_SCENE_SHADOW_SLANT;
334 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_SHADE_MODE
, drawing::ShadeMode_SMOOTH
);
336 ::chart::PropertyHelper::setPropertyValueDefault
< sal_Int32
>(
337 rOutMap
, PROP_SCENE_AMBIENT_COLOR
, ChartTypeHelper::getDefaultAmbientLightColor(ThreeDLookScheme_Simple
,0));
339 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_TWO_SIDED_LIGHTING
, true );
341 drawing::Position3D
vrp( 0.0, 0.0, 1.0 );
342 drawing::Direction3D
vpn( 0.0, 0.0, 1.0 );
343 drawing::Direction3D
vup( 0.0, 1.0, 0.0 );
344 drawing::CameraGeometry
aDefaultCameraGeometry( vrp
, vpn
, vup
);
346 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_CAMERA_GEOMETRY
, aDefaultCameraGeometry
);
347 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_PERSPECTIVE
, drawing::ProjectionMode_PERSPECTIVE
);
351 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_ON_1
, false );
352 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_ON_2
, true );
353 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_ON_3
, false );
354 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_ON_4
, false );
355 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_ON_5
, false );
356 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_ON_6
, false );
357 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_ON_7
, false );
358 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_ON_8
, false );
360 uno::Any
aDefaultLightDirection( uno::makeAny( drawing::Direction3D( 0.0, 0.0, 1.0 ) ) );
361 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_DIRECTION_1
, aDefaultLightDirection
);
362 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_DIRECTION_2
, ChartTypeHelper::getDefaultSimpleLightDirection(0));
363 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_DIRECTION_3
, aDefaultLightDirection
);
364 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_DIRECTION_4
, aDefaultLightDirection
);
365 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_DIRECTION_5
, aDefaultLightDirection
);
366 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_DIRECTION_6
, aDefaultLightDirection
);
367 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_DIRECTION_7
, aDefaultLightDirection
);
368 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_DIRECTION_8
, aDefaultLightDirection
);
370 uno::Any aDefaultLightColor
;
371 aDefaultLightColor
<<= ChartTypeHelper::getDefaultDirectLightColor(ThreeDLookScheme_Simple
,0);
372 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_COLOR_1
, aDefaultLightColor
);
373 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_COLOR_2
, aDefaultLightColor
);
374 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_COLOR_3
, aDefaultLightColor
);
375 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_COLOR_4
, aDefaultLightColor
);
376 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_COLOR_5
, aDefaultLightColor
);
377 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_COLOR_6
, aDefaultLightColor
);
378 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_COLOR_7
, aDefaultLightColor
);
379 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_COLOR_8
, aDefaultLightColor
);