Coverage Report

Created: 2026-09-28 10:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/chart2/source/tools/SceneProperties.cxx
Line
Count
Source
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 <SceneProperties.hxx>
21
#include <ChartTypeHelper.hxx>
22
#include <com/sun/star/beans/PropertyAttribute.hpp>
23
#include <com/sun/star/drawing/HomogenMatrix.hpp>
24
#include <com/sun/star/drawing/ShadeMode.hpp>
25
#include <com/sun/star/drawing/Direction3D.hpp>
26
#include <com/sun/star/drawing/ProjectionMode.hpp>
27
#include <com/sun/star/drawing/CameraGeometry.hpp>
28
29
using namespace ::com::sun::star;
30
31
using ::com::sun::star::beans::Property;
32
33
namespace chart
34
{
35
36
void SceneProperties::AddPropertiesToVector(
37
    std::vector< Property > & rOutProperties )
38
0
{
39
    // transformation matrix
40
0
    rOutProperties.emplace_back( "D3DTransformMatrix",
41
0
                  PROP_SCENE_TRANSF_MATRIX,
42
0
                  cppu::UnoType<drawing::HomogenMatrix>::get(),
43
0
                  beans::PropertyAttribute::BOUND
44
0
                  | beans::PropertyAttribute::MAYBEVOID
45
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
46
47
    // distance: deprecated ( this is not used by the chart view; it's only here for compatibility with old chart  )
48
0
    rOutProperties.emplace_back( "D3DSceneDistance",
49
0
                  PROP_SCENE_DISTANCE,
50
0
                  cppu::UnoType<sal_Int32>::get(),
51
0
                  beans::PropertyAttribute::BOUND
52
0
                  | beans::PropertyAttribute::MAYBEVOID
53
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
54
55
    // focalLength: deprecated ( this is not used by the chart view; it's only here for compatibility with old chart  )
56
0
    rOutProperties.emplace_back( "D3DSceneFocalLength",
57
0
                  PROP_SCENE_FOCAL_LENGTH,
58
0
                  cppu::UnoType<sal_Int32>::get(),
59
0
                  beans::PropertyAttribute::BOUND
60
0
                  | beans::PropertyAttribute::MAYBEVOID
61
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
62
63
    // shadowSlant
64
0
    rOutProperties.emplace_back( "D3DSceneShadowSlant",
65
0
                  PROP_SCENE_SHADOW_SLANT,
66
0
                  cppu::UnoType<sal_Int32>::get(),
67
0
                  beans::PropertyAttribute::BOUND
68
0
                  | beans::PropertyAttribute::MAYBEVOID
69
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
70
71
    // shadeMode
72
0
    rOutProperties.emplace_back( "D3DSceneShadeMode",
73
0
                  PROP_SCENE_SHADE_MODE,
74
0
                  cppu::UnoType<drawing::ShadeMode>::get(),
75
0
                  beans::PropertyAttribute::BOUND
76
0
                  | beans::PropertyAttribute::MAYBEVOID
77
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
78
79
    // ambientColor
80
0
    rOutProperties.emplace_back( "D3DSceneAmbientColor",
81
0
                  PROP_SCENE_AMBIENT_COLOR,
82
0
                  cppu::UnoType<sal_Int32>::get(),
83
0
                  beans::PropertyAttribute::BOUND
84
0
                  | beans::PropertyAttribute::MAYBEVOID
85
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
86
87
    // lightingMode
88
0
    rOutProperties.emplace_back( "D3DSceneTwoSidedLighting",
89
0
                  PROP_SCENE_TWO_SIDED_LIGHTING,
90
0
                  cppu::UnoType<bool>::get(),
91
0
                  beans::PropertyAttribute::BOUND
92
0
                  | beans::PropertyAttribute::MAYBEVOID
93
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
94
95
    // camera geometry
96
0
    rOutProperties.emplace_back( "D3DCameraGeometry",
97
0
                  PROP_SCENE_CAMERA_GEOMETRY,
98
0
                  cppu::UnoType<drawing::CameraGeometry>::get(),
99
0
                  beans::PropertyAttribute::BOUND
100
0
                  | beans::PropertyAttribute::MAYBEVOID
101
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
102
103
    // perspective
104
0
    rOutProperties.emplace_back( "D3DScenePerspective",
105
0
                  PROP_SCENE_PERSPECTIVE,
106
0
                  cppu::UnoType<drawing::ProjectionMode>::get(),
107
0
                  beans::PropertyAttribute::BOUND
108
0
                  | beans::PropertyAttribute::MAYBEVOID
109
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
110
111
    // Light Sources
112
    // light source 1
113
0
    rOutProperties.emplace_back( "D3DSceneLightColor1",
114
0
                  PROP_SCENE_LIGHT_COLOR_1,
115
0
                  cppu::UnoType<sal_Int32>::get(),
116
0
                  beans::PropertyAttribute::BOUND
117
0
                  | beans::PropertyAttribute::MAYBEVOID
118
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
119
0
    rOutProperties.emplace_back( "D3DSceneLightDirection1",
120
0
                  PROP_SCENE_LIGHT_DIRECTION_1,
121
0
                  cppu::UnoType<drawing::Direction3D>::get(),
122
0
                  beans::PropertyAttribute::BOUND
123
0
                  | beans::PropertyAttribute::MAYBEVOID
124
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
125
0
    rOutProperties.emplace_back( "D3DSceneLightOn1",
126
0
                  PROP_SCENE_LIGHT_ON_1,
127
0
                  cppu::UnoType<bool>::get(),
128
0
                  beans::PropertyAttribute::BOUND
129
0
                  | beans::PropertyAttribute::MAYBEVOID
130
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
131
    // light source 2
132
0
    rOutProperties.emplace_back( "D3DSceneLightColor2",
133
0
                  PROP_SCENE_LIGHT_COLOR_2,
134
0
                  cppu::UnoType<sal_Int32>::get(),
135
0
                  beans::PropertyAttribute::BOUND
136
0
                  | beans::PropertyAttribute::MAYBEVOID
137
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
138
0
    rOutProperties.emplace_back( "D3DSceneLightDirection2",
139
0
                  PROP_SCENE_LIGHT_DIRECTION_2,
140
0
                  cppu::UnoType<drawing::Direction3D>::get(),
141
0
                  beans::PropertyAttribute::BOUND
142
0
                  | beans::PropertyAttribute::MAYBEVOID
143
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
144
0
    rOutProperties.emplace_back( "D3DSceneLightOn2",
145
0
                  PROP_SCENE_LIGHT_ON_2,
146
0
                  cppu::UnoType<bool>::get(),
147
0
                  beans::PropertyAttribute::BOUND
148
0
                  | beans::PropertyAttribute::MAYBEVOID
149
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
150
    // light source 3
151
0
    rOutProperties.emplace_back( "D3DSceneLightColor3",
152
0
                  PROP_SCENE_LIGHT_COLOR_3,
153
0
                  cppu::UnoType<sal_Int32>::get(),
154
0
                  beans::PropertyAttribute::BOUND
155
0
                  | beans::PropertyAttribute::MAYBEVOID
156
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
157
0
    rOutProperties.emplace_back( "D3DSceneLightDirection3",
158
0
                  PROP_SCENE_LIGHT_DIRECTION_3,
159
0
                  cppu::UnoType<drawing::Direction3D>::get(),
160
0
                  beans::PropertyAttribute::BOUND
161
0
                  | beans::PropertyAttribute::MAYBEVOID
162
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
163
0
    rOutProperties.emplace_back( "D3DSceneLightOn3",
164
0
                  PROP_SCENE_LIGHT_ON_3,
165
0
                  cppu::UnoType<bool>::get(),
166
0
                  beans::PropertyAttribute::BOUND
167
0
                  | beans::PropertyAttribute::MAYBEVOID
168
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
169
    // light source 4
170
0
    rOutProperties.emplace_back( "D3DSceneLightColor4",
171
0
                  PROP_SCENE_LIGHT_COLOR_4,
172
0
                  cppu::UnoType<sal_Int32>::get(),
173
0
                  beans::PropertyAttribute::BOUND
174
0
                  | beans::PropertyAttribute::MAYBEVOID
175
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
176
0
    rOutProperties.emplace_back( "D3DSceneLightDirection4",
177
0
                  PROP_SCENE_LIGHT_DIRECTION_4,
178
0
                  cppu::UnoType<drawing::Direction3D>::get(),
179
0
                  beans::PropertyAttribute::BOUND
180
0
                  | beans::PropertyAttribute::MAYBEVOID
181
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
182
0
    rOutProperties.emplace_back( "D3DSceneLightOn4",
183
0
                  PROP_SCENE_LIGHT_ON_4,
184
0
                  cppu::UnoType<bool>::get(),
185
0
                  beans::PropertyAttribute::BOUND
186
0
                  | beans::PropertyAttribute::MAYBEVOID
187
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
188
    // light source 5
189
0
    rOutProperties.emplace_back( "D3DSceneLightColor5",
190
0
                  PROP_SCENE_LIGHT_COLOR_5,
191
0
                  cppu::UnoType<sal_Int32>::get(),
192
0
                  beans::PropertyAttribute::BOUND
193
0
                  | beans::PropertyAttribute::MAYBEVOID
194
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
195
0
    rOutProperties.emplace_back( "D3DSceneLightDirection5",
196
0
                  PROP_SCENE_LIGHT_DIRECTION_5,
197
0
                  cppu::UnoType<drawing::Direction3D>::get(),
198
0
                  beans::PropertyAttribute::BOUND
199
0
                  | beans::PropertyAttribute::MAYBEVOID
200
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
201
0
    rOutProperties.emplace_back( "D3DSceneLightOn5",
202
0
                  PROP_SCENE_LIGHT_ON_5,
203
0
                  cppu::UnoType<bool>::get(),
204
0
                  beans::PropertyAttribute::BOUND
205
0
                  | beans::PropertyAttribute::MAYBEVOID
206
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
207
    // light source 6
208
0
    rOutProperties.emplace_back( "D3DSceneLightColor6",
209
0
                  PROP_SCENE_LIGHT_COLOR_6,
210
0
                  cppu::UnoType<sal_Int32>::get(),
211
0
                  beans::PropertyAttribute::BOUND
212
0
                  | beans::PropertyAttribute::MAYBEVOID
213
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
214
0
    rOutProperties.emplace_back( "D3DSceneLightDirection6",
215
0
                  PROP_SCENE_LIGHT_DIRECTION_6,
216
0
                  cppu::UnoType<drawing::Direction3D>::get(),
217
0
                  beans::PropertyAttribute::BOUND
218
0
                  | beans::PropertyAttribute::MAYBEVOID
219
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
220
0
    rOutProperties.emplace_back( "D3DSceneLightOn6",
221
0
                  PROP_SCENE_LIGHT_ON_6,
222
0
                  cppu::UnoType<bool>::get(),
223
0
                  beans::PropertyAttribute::BOUND
224
0
                  | beans::PropertyAttribute::MAYBEVOID
225
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
226
    // light source 7
227
0
    rOutProperties.emplace_back( "D3DSceneLightColor7",
228
0
                  PROP_SCENE_LIGHT_COLOR_7,
229
0
                  cppu::UnoType<sal_Int32>::get(),
230
0
                  beans::PropertyAttribute::BOUND
231
0
                  | beans::PropertyAttribute::MAYBEVOID
232
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
233
0
    rOutProperties.emplace_back( "D3DSceneLightDirection7",
234
0
                  PROP_SCENE_LIGHT_DIRECTION_7,
235
0
                  cppu::UnoType<drawing::Direction3D>::get(),
236
0
                  beans::PropertyAttribute::BOUND
237
0
                  | beans::PropertyAttribute::MAYBEVOID
238
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
239
0
    rOutProperties.emplace_back( "D3DSceneLightOn7",
240
0
                  PROP_SCENE_LIGHT_ON_7,
241
0
                  cppu::UnoType<bool>::get(),
242
0
                  beans::PropertyAttribute::BOUND
243
0
                  | beans::PropertyAttribute::MAYBEVOID
244
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
245
    // light source 8
246
0
    rOutProperties.emplace_back( "D3DSceneLightColor8",
247
0
                  PROP_SCENE_LIGHT_COLOR_8,
248
0
                  cppu::UnoType<sal_Int32>::get(),
249
0
                  beans::PropertyAttribute::BOUND
250
0
                  | beans::PropertyAttribute::MAYBEVOID
251
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
252
0
    rOutProperties.emplace_back( "D3DSceneLightDirection8",
253
0
                  PROP_SCENE_LIGHT_DIRECTION_8,
254
0
                  cppu::UnoType<drawing::Direction3D>::get(),
255
0
                  beans::PropertyAttribute::BOUND
256
0
                  | beans::PropertyAttribute::MAYBEVOID
257
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
258
0
    rOutProperties.emplace_back( "D3DSceneLightOn8",
259
0
                  PROP_SCENE_LIGHT_ON_8,
260
0
                  cppu::UnoType<bool>::get(),
261
0
                  beans::PropertyAttribute::BOUND
262
0
                  | beans::PropertyAttribute::MAYBEVOID
263
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
264
0
}
265
266
void SceneProperties::AddDefaultsToMap(
267
    ::chart::tPropertyValueMap & rOutMap )
268
0
{
269
    // Identity Matrix
270
0
    drawing::HomogenMatrix aMtx;
271
0
    aMtx.Line1.Column1 = aMtx.Line2.Column2 =
272
0
        aMtx.Line3.Column3 = aMtx.Line4.Column4 = 1.0;
273
0
    aMtx.Line1.Column2 = aMtx.Line1.Column3 = aMtx.Line1.Column4 =
274
0
        aMtx.Line2.Column1 = aMtx.Line2.Column3 = aMtx.Line2.Column4 =
275
0
        aMtx.Line3.Column1 = aMtx.Line3.Column2 = aMtx.Line3.Column4 =
276
0
        aMtx.Line4.Column1 = aMtx.Line4.Column2 = aMtx.Line4.Column3 = 0.0;
277
278
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_TRANSF_MATRIX, aMtx );
279
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_DISTANCE, sal_Int32(4200) );
280
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_FOCAL_LENGTH, sal_Int32(8000) );
281
282
//     PROP_SCENE_SHADOW_SLANT;
283
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_SHADE_MODE, drawing::ShadeMode_SMOOTH );
284
285
0
    ::chart::PropertyHelper::setPropertyValueDefault(
286
0
        rOutMap, PROP_SCENE_AMBIENT_COLOR, ChartTypeHelper::getDefaultAmbientLightColor(false,nullptr));
287
288
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_TWO_SIDED_LIGHTING, true );
289
290
0
    drawing::Position3D vrp( 0.0, 0.0, 1.0 );
291
0
    drawing::Direction3D vpn( 0.0, 0.0, 1.0 );
292
0
    drawing::Direction3D vup( 0.0, 1.0, 0.0 );
293
0
    drawing::CameraGeometry aDefaultCameraGeometry( vrp, vpn, vup );
294
295
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_CAMERA_GEOMETRY, aDefaultCameraGeometry );
296
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_PERSPECTIVE, drawing::ProjectionMode_PERSPECTIVE );
297
298
    // Light Sources
299
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_1, false );
300
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_2, true );
301
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_3, false );
302
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_4, false );
303
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_5, false );
304
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_6, false );
305
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_7, false );
306
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_8, false );
307
308
0
    uno::Any aDefaultLightDirection( drawing::Direction3D( 0.0, 0.0, 1.0 ) );
309
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_1, aDefaultLightDirection );
310
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_2, ChartTypeHelper::getDefaultSimpleLightDirection(nullptr));
311
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_3, aDefaultLightDirection );
312
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_4, aDefaultLightDirection );
313
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_5, aDefaultLightDirection );
314
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_6, aDefaultLightDirection );
315
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_7, aDefaultLightDirection );
316
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_8, aDefaultLightDirection );
317
318
0
    uno::Any aDefaultLightColor;
319
0
    aDefaultLightColor <<= ChartTypeHelper::getDefaultDirectLightColor(false,nullptr);
320
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_1, aDefaultLightColor );
321
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_2, aDefaultLightColor );
322
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_3, aDefaultLightColor );
323
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_4, aDefaultLightColor );
324
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_5, aDefaultLightColor );
325
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_6, aDefaultLightColor );
326
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_7, aDefaultLightColor );
327
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_8, aDefaultLightColor );
328
0
}
329
330
} //  namespace chart
331
332
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */