1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <drawingml/shape3dproperties.hxx>
#include <com/sun/star/drawing/BitmapMode.hpp>
#include <com/sun/star/graphic/XGraphicTransformer.hpp>
#include <comphelper/propertyvalue.hxx>
#include <oox/token/tokens.hxx>
#include <sal/log.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::drawing;
using namespace ::com::sun::star::graphic;
namespace oox::drawingml {
OUString Generic3DProperties::getCameraPrstName( sal_Int32 nElement )
{
switch( nElement )
{
case XML_legacyObliqueTopLeft: return "legacyObliqueTopLeft";
case XML_legacyObliqueTop: return "legacyObliqueTop";
case XML_legacyObliqueTopRight: return "legacyObliqueTopRight";
case XML_legacyObliqueLeft: return "legacyObliqueLeft";
case XML_legacyObliqueFront: return "legacyObliqueFront";
case XML_legacyObliqueRight: return "legacyObliqueRight";
case XML_legacyObliqueBottomLeft: return "legacyObliqueBottomLeft";
case XML_legacyObliqueBottom: return "legacyObliqueBottom";
case XML_legacyObliqueBottomRight: return "legacyObliqueBottomRight";
case XML_legacyPerspectiveTopLeft: return "legacyPerspectiveTopLeft";
case XML_legacyPerspectiveTop: return "legacyPerspectiveTop";
case XML_legacyPerspectiveTopRight: return "legacyPerspectiveTopRight";
case XML_legacyPerspectiveLeft: return "legacyPerspectiveLeft";
case XML_legacyPerspectiveFront: return "legacyPerspectiveFront";
case XML_legacyPerspectiveRight: return "legacyPerspectiveRight";
case XML_legacyPerspectiveBottomLeft: return "legacyPerspectiveBottomLeft";
case XML_legacyPerspectiveBottom: return "legacyPerspectiveBottom";
case XML_legacyPerspectiveBottomRight: return "legacyPerspectiveBottomRight";
case XML_orthographicFront: return "orthographicFront";
case XML_isometricTopUp: return "isometricTopUp";
case XML_isometricTopDown: return "isometricTopDown";
case XML_isometricBottomUp: return "isometricBottomUp";
case XML_isometricBottomDown: return "isometricBottomDown";
case XML_isometricLeftUp: return "isometricLeftUp";
case XML_isometricLeftDown: return "isometricLeftDown";
case XML_isometricRightUp: return "isometricRightUp";
case XML_isometricRightDown: return "isometricRightDown";
case XML_isometricOffAxis1Left: return "isometricOffAxis1Left";
case XML_isometricOffAxis1Right: return "isometricOffAxis1Right";
case XML_isometricOffAxis1Top: return "isometricOffAxis1Top";
case XML_isometricOffAxis2Left: return "isometricOffAxis2Left";
case XML_isometricOffAxis2Right: return "isometricOffAxis2Right";
case XML_isometricOffAxis2Top: return "isometricOffAxis2Top";
case XML_isometricOffAxis3Left: return "isometricOffAxis3Left";
case XML_isometricOffAxis3Right: return "isometricOffAxis3Right";
case XML_isometricOffAxis3Bottom: return "isometricOffAxis3Bottom";
case XML_isometricOffAxis4Left: return "isometricOffAxis4Left";
case XML_isometricOffAxis4Right: return "isometricOffAxis4Right";
case XML_isometricOffAxis4Bottom: return "isometricOffAxis4Bottom";
case XML_obliqueTopLeft: return "obliqueTopLeft";
case XML_obliqueTop: return "obliqueTop";
case XML_obliqueTopRight: return "obliqueTopRight";
case XML_obliqueLeft: return "obliqueLeft";
case XML_obliqueRight: return "obliqueRight";
case XML_obliqueBottomLeft: return "obliqueBottomLeft";
case XML_obliqueBottom: return "obliqueBottom";
case XML_obliqueBottomRight: return "obliqueBottomRight";
case XML_perspectiveFront: return "perspectiveFront";
case XML_perspectiveLeft: return "perspectiveLeft";
case XML_perspectiveRight: return "perspectiveRight";
case XML_perspectiveAbove: return "perspectiveAbove";
case XML_perspectiveBelow: return "perspectiveBelow";
case XML_perspectiveAboveLeftFacing: return "perspectiveAboveLeftFacing";
case XML_perspectiveAboveRightFacing: return "perspectiveAboveRightFacing";
case XML_perspectiveContrastingLeftFacing: return "perspectiveContrastingLeftFacing";
case XML_perspectiveContrastingRightFacing: return "perspectiveContrastingRightFacing";
case XML_perspectiveHeroicLeftFacing: return "perspectiveHeroicLeftFacing";
case XML_perspectiveHeroicRightFacing: return "perspectiveHeroicRightFacing";
case XML_perspectiveHeroicExtremeLeftFacing: return "perspectiveHeroicExtremeLeftFacing";
case XML_perspectiveHeroicExtremeRightFacing: return "perspectiveHeroicExtremeRightFacing";
case XML_perspectiveRelaxed: return "perspectiveRelaxed";
case XML_perspectiveRelaxedModerately: return "perspectiveRelaxedModerately";
}
SAL_WARN( "oox.drawingml", "Generic3DProperties::getCameraPrstName - unexpected prst type" );
return OUString();
}
OUString Generic3DProperties::getLightRigName( sal_Int32 nElement )
{
switch( nElement )
{
case XML_legacyFlat1: return "legacyFlat1";
case XML_legacyFlat2: return "legacyFlat2";
case XML_legacyFlat3: return "legacyFlat3";
case XML_legacyFlat4: return "legacyFlat4";
case XML_legacyNormal1: return "legacyNormal1";
case XML_legacyNormal2: return "legacyNormal2";
case XML_legacyNormal3: return "legacyNormal3";
case XML_legacyNormal4: return "legacyNormal4";
case XML_legacyHarsh1: return "legacyHarsh1";
case XML_legacyHarsh2: return "legacyHarsh2";
case XML_legacyHarsh3: return "legacyHarsh3";
case XML_legacyHarsh4: return "legacyHarsh4";
case XML_threePt: return "threePt";
case XML_balanced: return "balanced";
case XML_soft: return "soft";
case XML_harsh: return "harsh";
case XML_flood: return "flood";
case XML_contrasting: return "contrasting";
case XML_morning: return "morning";
case XML_sunrise: return "sunrise";
case XML_sunset: return "sunset";
case XML_chilly: return "chilly";
case XML_freezing: return "freezing";
case XML_flat: return "flat";
case XML_twoPt: return "twoPt";
case XML_glow: return "glow";
case XML_brightRoom: return "brightRoom";
}
SAL_WARN( "oox.drawingml", "Generic3DProperties::getLightRigName - unexpected token" );
return OUString();
}
OUString Generic3DProperties::getLightRigDirName( sal_Int32 nElement )
{
switch( nElement )
{
case XML_tl: return "tl";
case XML_t: return "t";
case XML_tr: return "tr";
case XML_l: return "l";
case XML_r: return "r";
case XML_bl: return "bl";
case XML_b: return "b";
case XML_br: return "br";
}
SAL_WARN( "oox.drawingml", "Generic3DProperties::getLightRigDirName - unexpected token" );
return OUString();
}
OUString Generic3DProperties::getBevelPresetTypeString( sal_Int32 nType )
{
switch (nType)
{
case XML_relaxedInset: return "relaxedInset";
case XML_circle: return "circle";
case XML_slope: return "slope";
case XML_cross: return "cross";
case XML_angle: return "angle";
case XML_softRound: return "softRound";
case XML_convex: return "convex";
case XML_coolSlant: return "coolSlant";
case XML_divot: return "divot";
case XML_riblet: return "riblet";
case XML_hardEdge: return "hardEdge";
case XML_artDeco: return "artDeco";
}
SAL_WARN( "oox.drawingml", "Generic3DProperties::getBevelPresetTypeString - unexpected token" );
return OUString();
}
OUString Generic3DProperties::getPresetMaterialTypeString( sal_Int32 nType )
{
switch (nType)
{
case XML_legacyMatte: return "legacyMatte";
case XML_legacyPlastic: return "legacyPlastic";
case XML_legacyMetal: return "legacyMetal";
case XML_legacyWireframe: return "legacyWireframe";
case XML_matte: return "matte";
case XML_plastic: return "plastic";
case XML_metal: return "metal";
case XML_warmMatte: return "warmMatte";
case XML_translucentPowder: return "translucentPowder";
case XML_powder: return "powder";
case XML_dkEdge: return "dkEdge";
case XML_softEdge: return "softEdge";
case XML_clear: return "clear";
case XML_flat: return "flat";
case XML_softmetal: return "softmetal";
case XML_none: return "none";
}
SAL_WARN( "oox.drawingml", "Generic3DProperties::getPresetMaterialTypeString - unexpected token" );
return OUString();
}
css::uno::Sequence< css::beans::PropertyValue > Generic3DProperties::getCameraAttributes()
{
css::uno::Sequence<css::beans::PropertyValue> aSeq(6);
auto pSeq = aSeq.getArray();
sal_Int32 nSize = 0;
if( mfFieldOfVision.has_value() )
{
pSeq[nSize].Name = "fov";
pSeq[nSize].Value <<= *mfFieldOfVision;
nSize++;
}
if( mfZoom.has_value() )
{
pSeq[nSize].Name = "zoom";
pSeq[nSize].Value <<= *mfZoom;
nSize++;
}
if( mnPreset.has_value() )
{
pSeq[nSize].Name = "prst";
pSeq[nSize].Value <<= getCameraPrstName( *mnPreset );
nSize++;
}
if( maCameraRotation.mnLatitude.has_value() )
{
pSeq[nSize].Name = "rotLat";
pSeq[nSize].Value <<= *maCameraRotation.mnLatitude;
nSize++;
}
if( maCameraRotation.mnLongitude.has_value() )
{
pSeq[nSize].Name = "rotLon";
pSeq[nSize].Value <<= *maCameraRotation.mnLongitude;
nSize++;
}
if( maCameraRotation.mnRevolution.has_value() )
{
pSeq[nSize].Name = "rotRev";
pSeq[nSize].Value <<= *maCameraRotation.mnRevolution;
nSize++;
}
aSeq.realloc( nSize );
return aSeq;
}
css::uno::Sequence< css::beans::PropertyValue > Generic3DProperties::getLightRigAttributes()
{
css::uno::Sequence<css::beans::PropertyValue> aSeq(5);
auto pSeq = aSeq.getArray();
sal_Int32 nSize = 0;
if( mnLightRigDirection.has_value() )
{
pSeq[nSize].Name = "dir";
pSeq[nSize].Value <<= getLightRigDirName( *mnLightRigDirection );
nSize++;
}
if( mnLightRigType.has_value() )
{
pSeq[nSize].Name = "rig";
pSeq[nSize].Value <<= getLightRigName( *mnLightRigType );
nSize++;
}
if( maLightRigRotation.mnLatitude.has_value() )
{
pSeq[nSize].Name = "rotLat";
pSeq[nSize].Value <<= *maLightRigRotation.mnLatitude;
nSize++;
}
if( maLightRigRotation.mnLongitude.has_value() )
{
pSeq[nSize].Name = "rotLon";
pSeq[nSize].Value <<= *maLightRigRotation.mnLongitude;
nSize++;
}
if( maLightRigRotation.mnRevolution.has_value() )
{
pSeq[nSize].Name = "rotRev";
pSeq[nSize].Value <<= *maLightRigRotation.mnRevolution;
nSize++;
}
aSeq.realloc( nSize );
return aSeq;
}
css::uno::Sequence< css::beans::PropertyValue > Generic3DProperties::getBevelAttributes( BevelProperties rProps )
{
css::uno::Sequence<css::beans::PropertyValue> aSeq(3);
auto pSeq = aSeq.getArray();
sal_Int32 nSize = 0;
if( rProps.mnPreset.has_value() )
{
pSeq[nSize].Name = "prst";
pSeq[nSize].Value <<= getBevelPresetTypeString( *rProps.mnPreset );
nSize++;
}
if( rProps.mnWidth.has_value() )
{
pSeq[nSize].Name = "w";
pSeq[nSize].Value <<= *rProps.mnWidth;
nSize++;
}
if( rProps.mnHeight.has_value() )
{
pSeq[nSize].Name = "h";
pSeq[nSize].Value <<= *rProps.mnHeight;
nSize++;
}
aSeq.realloc( nSize );
return aSeq;
}
css::uno::Sequence< css::beans::PropertyValue > Generic3DProperties::getColorAttributes(
const Color& rColor, const GraphicHelper& rGraphicHelper, ::Color rPhClr )
{
const OUString& sColorScheme = rColor.getSchemeColorName();
if( sColorScheme.isEmpty() )
{
// RGB color and transparency value
return { comphelper::makePropertyValue("rgbClr", rColor.getColor( rGraphicHelper, rPhClr )),
comphelper::makePropertyValue("rgbClrTransparency", rColor.getTransparency()) };
}
// scheme color with name and transformations
return { comphelper::makePropertyValue("schemeClr", sColorScheme),
comphelper::makePropertyValue("schemeClrTransformations",
rColor.getTransformations()) };
}
css::uno::Sequence< css::beans::PropertyValue > Generic3DProperties::getShape3DAttributes(
const GraphicHelper& rGraphicHelper, ::Color rPhClr )
{
css::uno::Sequence<css::beans::PropertyValue> aSeq(8);
auto pSeq = aSeq.getArray();
sal_Int32 nSize = 0;
if( mnExtrusionH.has_value() )
{
pSeq[nSize].Name = "extrusionH";
pSeq[nSize].Value <<= *mnExtrusionH;
nSize++;
}
if( mnContourW.has_value() )
{
pSeq[nSize].Name = "contourW";
pSeq[nSize].Value <<= *mnContourW;
nSize++;
}
if( mnShapeZ.has_value() )
{
pSeq[nSize].Name = "z";
pSeq[nSize].Value <<= *mnShapeZ;
nSize++;
}
if( mnMaterial.has_value() )
{
pSeq[nSize].Name = "prstMaterial";
pSeq[nSize].Value <<= getPresetMaterialTypeString( *mnMaterial );
nSize++;
}
if( maTopBevelProperties.has_value() )
{
pSeq[nSize].Name = "bevelT";
pSeq[nSize].Value <<= getBevelAttributes( *maTopBevelProperties );
nSize++;
}
if( maBottomBevelProperties.has_value() )
{
pSeq[nSize].Name = "bevelB";
pSeq[nSize].Value <<= getBevelAttributes( *maBottomBevelProperties );
nSize++;
}
if( maExtrusionColor.isUsed() )
{
pSeq[nSize].Name = "extrusionClr";
pSeq[nSize].Value <<= getColorAttributes( maExtrusionColor, rGraphicHelper, rPhClr );
nSize++;
}
if( maContourColor.isUsed() )
{
pSeq[nSize].Name = "contourClr";
pSeq[nSize].Value <<= getColorAttributes( maContourColor, rGraphicHelper, rPhClr );
nSize++;
}
aSeq.realloc( nSize );
return aSeq;
}
} // namespace oox
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|