LibreOffice Module oox (master) 1
scene3dcontext.cxx
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
23#include <oox/token/namespaces.hxx>
24#include <oox/token/tokens.hxx>
25
26using namespace ::oox::core;
27using namespace ::com::sun::star;
28using namespace ::com::sun::star::uno;
29using namespace ::com::sun::star::xml::sax;
30
31namespace oox::drawingml {
32
33Scene3DPropertiesContext::Scene3DPropertiesContext( ContextHandler2Helper const & rParent, Shape3DProperties& r3DProperties ) noexcept
34: ContextHandler2( rParent )
35, mr3DProperties( r3DProperties )
36{
37}
38
40{
41 switch( aElementToken )
42 {
43 case A_TOKEN( camera ):
44 if( rAttribs.hasAttribute( XML_fov ) )
45 mr3DProperties.mfFieldOfVision = rAttribs.getInteger( XML_fov, 0 ) / 60000.0; // 60000ths of degree
46 if( rAttribs.hasAttribute( XML_zoom ) )
47 mr3DProperties.mfZoom = rAttribs.getInteger( XML_zoom, 100000 ) / 100000.0;
48 if( rAttribs.hasAttribute( XML_prst ) )
49 mr3DProperties.mnPreset = rAttribs.getToken( XML_prst, XML_none );
50
52
53 case A_TOKEN( lightRig ):
55 mr3DProperties.mnLightRigType = rAttribs.getToken( XML_rig, XML_none );
56
58
59 case A_TOKEN( backdrop ):
60 case A_TOKEN( extLst ):
61 return nullptr; // TODO: later (backdrop is not supported by core anyway)
62 }
63 return nullptr;
64}
65
66SceneText3DPropertiesContext::SceneText3DPropertiesContext( ContextHandler2Helper const & rParent, Text3DProperties& r3DProperties ) noexcept
67: ContextHandler2( rParent )
68, mr3DProperties( r3DProperties )
69{
70}
71
73{
74 switch( aElementToken )
75 {
76 case A_TOKEN( camera ):
77 if( rAttribs.hasAttribute( XML_fov ) )
78 mr3DProperties.mfFieldOfVision = rAttribs.getInteger( XML_fov, 0 ) / 60000.0; // 60000ths of degree
79 if( rAttribs.hasAttribute( XML_zoom ) )
80 mr3DProperties.mfZoom = rAttribs.getInteger( XML_zoom, 100000 ) / 100000.0;
81 if( rAttribs.hasAttribute( XML_prst ) )
82 mr3DProperties.mnPreset = rAttribs.getToken( XML_prst, XML_none );
83
85
86 case A_TOKEN( lightRig ):
88 mr3DProperties.mnLightRigType = rAttribs.getToken( XML_rig, XML_none );
89
91
92 case A_TOKEN( backdrop ):
93 case A_TOKEN( extLst ):
94 return nullptr; // TODO: later (backdrop is not supported by core anyway)
95
96 case A_TOKEN( bevelT ):
97 case A_TOKEN( bevelB ):
98 {
99 BevelProperties aProps;
100 if( rAttribs.hasAttribute( XML_w ) )
101 aProps.mnWidth = rAttribs.getInteger( XML_w, 0 );
102 if( rAttribs.hasAttribute( XML_h ) )
103 aProps.mnHeight = rAttribs.getInteger( XML_h, 0 );
104 if( rAttribs.hasAttribute( XML_prst ) )
105 aProps.mnPreset = rAttribs.getToken( XML_prst, XML_none );
106
107 if( aElementToken == A_TOKEN( bevelT ) )
109 else
111 break;
112 }
113
114 case A_TOKEN( extrusionClr ):
115 return new ColorContext( *this, mr3DProperties.maExtrusionColor );
116
117 case A_TOKEN( contourClr ):
118 return new ColorContext( *this, mr3DProperties.maContourColor );
119 }
120 return nullptr;
121}
122
123Shape3DPropertiesContext::Shape3DPropertiesContext( ContextHandler2Helper const & rParent, const AttributeList& rAttribs, Shape3DProperties& r3DProperties ) noexcept
124: ContextHandler2( rParent )
125, mr3DProperties( r3DProperties )
126{
127 if( rAttribs.hasAttribute( XML_extrusionH ) )
128 mr3DProperties.mnExtrusionH = rAttribs.getInteger( XML_extrusionH, 0 );
129 if( rAttribs.hasAttribute( XML_contourW ) )
130 mr3DProperties.mnContourW = rAttribs.getInteger( XML_contourW, 0 );
131 if( rAttribs.hasAttribute( XML_z ) )
132 mr3DProperties.mnShapeZ = rAttribs.getInteger( XML_z, 0 );
133 if( rAttribs.hasAttribute( XML_prstMaterial ) )
134 mr3DProperties.mnMaterial = rAttribs.getToken( XML_prstMaterial, XML_none );
135}
136
138{
139 switch( aElementToken )
140 {
141 case A_TOKEN( bevelT ):
142 case A_TOKEN( bevelB ):
143 {
144 BevelProperties aProps;
145 if( rAttribs.hasAttribute( XML_w ) )
146 aProps.mnWidth = rAttribs.getInteger( XML_w, 0 );
147 if( rAttribs.hasAttribute( XML_h ) )
148 aProps.mnHeight = rAttribs.getInteger( XML_h, 0 );
149 if( rAttribs.hasAttribute( XML_prst ) )
150 aProps.mnPreset = rAttribs.getToken( XML_prst, XML_none );
151
152 if( aElementToken == A_TOKEN( bevelT ) )
154 else
156
157 break;
158 }
159 case A_TOKEN( extrusionClr ):
160 return new ColorContext( *this, mr3DProperties.maExtrusionColor );
161
162 case A_TOKEN( contourClr ):
163 return new ColorContext( *this, mr3DProperties.maContourColor );
164 }
165 return nullptr;
166}
167
168Scene3DRotationPropertiesContext::Scene3DRotationPropertiesContext( ContextHandler2Helper const & rParent, RotationProperties& rRotationProperties ) noexcept
169: ContextHandler2( rParent )
170, mrRotationProperties( rRotationProperties )
171{
172}
173
175{
176 switch( aElementToken )
177 {
178 case A_TOKEN( rot ):
179 mrRotationProperties.mnLatitude = rAttribs.getInteger( XML_lat, 0 );
180 mrRotationProperties.mnLongitude = rAttribs.getInteger( XML_lon, 0 );
181 mrRotationProperties.mnRevolution = rAttribs.getInteger( XML_rev, 0 );
182 break;
183 }
184 return nullptr;
185}
186
187}
188
189/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Provides access to attribute values of an element.
bool hasAttribute(sal_Int32 nAttrToken) const
Returns true, if the specified attribute is present.
std::optional< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
Returns the 32-bit signed integer value of the specified attribute (decimal).
std::optional< sal_Int32 > getToken(sal_Int32 nAttrToken) const
Returns the token identifier of the value of the specified attribute.
Context handler for elements that contain a color value element (a:scrgbClr, a:srgbClr,...
::oox::core::ContextHandlerRef onCreateContext(::sal_Int32 Element, const ::oox::AttributeList &rAttribs) override
Scene3DPropertiesContext(::oox::core::ContextHandler2Helper const &rParent, Shape3DProperties &rShape3DProperties) noexcept
Scene3DRotationPropertiesContext(::oox::core::ContextHandler2Helper const &rParent, RotationProperties &rRotationProperties) noexcept
::oox::core::ContextHandlerRef onCreateContext(::sal_Int32 Element, const ::oox::AttributeList &rAttribs) override
SceneText3DPropertiesContext(::oox::core::ContextHandler2Helper const &rParent, Text3DProperties &rText3DProperties) noexcept
::oox::core::ContextHandlerRef onCreateContext(::sal_Int32 Element, const ::oox::AttributeList &rAttribs) override
Shape3DPropertiesContext(::oox::core::ContextHandler2Helper const &rParent, const ::oox::AttributeList &rAttribs, Shape3DProperties &r3DProperties) noexcept
::oox::core::ContextHandlerRef onCreateContext(::sal_Int32 Element, const ::oox::AttributeList &rAttribs) override
XML_none
std::optional< sal_Int32 > mnHeight
std::optional< sal_Int32 > mnPreset
std::optional< sal_Int32 > mnWidth
std::optional< BevelProperties > maBottomBevelProperties
std::optional< sal_Int32 > mnLightRigDirection
std::optional< sal_Int32 > mnPreset
std::optional< sal_Int32 > mnLightRigType
std::optional< BevelProperties > maTopBevelProperties
std::optional< sal_Int32 > mnLongitude
std::optional< sal_Int32 > mnLatitude
std::optional< sal_Int32 > mnRevolution