1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "drawingml/scene3dcontext.hxx"
21 #include <com/sun/star/io/XInputStream.hpp>
22 #include <com/sun/star/graphic/XGraphicProvider.hpp>
23 #include <cppuhelper/exc_hlp.hxx>
24 #include <comphelper/anytostring.hxx>
25 #include "drawingml/colorchoicecontext.hxx"
26 #include "oox/drawingml/drawingmltypes.hxx"
27 #include "drawingml/fillproperties.hxx"
28 #include "oox/core/xmlfilterbase.hxx"
29 #include "oox/helper/attributelist.hxx"
30 #include <oox/token/namespaces.hxx>
31 #include <oox/token/tokens.hxx>
33 using namespace ::oox::core
;
34 using namespace ::com::sun::star
;
35 using namespace ::com::sun::star::uno
;
36 using namespace ::com::sun::star::xml::sax
;
38 namespace oox
{ namespace drawingml
{
40 Scene3DPropertiesContext::Scene3DPropertiesContext( ContextHandler2Helper
& rParent
, Shape3DProperties
& r3DProperties
) throw()
41 : ContextHandler2( rParent
)
42 , mr3DProperties( r3DProperties
)
46 ContextHandlerRef
Scene3DPropertiesContext::onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
48 switch( aElementToken
)
50 case A_TOKEN( camera
):
51 if( rAttribs
.hasAttribute( XML_fov
) )
52 mr3DProperties
.mfFieldOfVision
= rAttribs
.getInteger( XML_fov
, 0 ) / 60000.0; // 60000ths of degree
53 if( rAttribs
.hasAttribute( XML_zoom
) )
54 mr3DProperties
.mfZoom
= rAttribs
.getInteger( XML_zoom
, 100000 ) / 100000.0;
55 if( rAttribs
.hasAttribute( XML_prst
) )
56 mr3DProperties
.mnPreset
= rAttribs
.getToken( XML_prst
, XML_none
);
58 return new Scene3DRotationPropertiesContext( *this, mr3DProperties
.maCameraRotation
);
60 case A_TOKEN( lightRig
):
61 mr3DProperties
.mnLightRigDirection
= rAttribs
.getToken( XML_dir
, XML_none
);
62 mr3DProperties
.mnLightRigType
= rAttribs
.getToken( XML_rig
, XML_none
);
64 return new Scene3DRotationPropertiesContext( *this, mr3DProperties
.maLightRigRotation
);
66 case A_TOKEN( backdrop
):
67 case A_TOKEN( extLst
):
68 return nullptr; // TODO: later (backdrop is not supported by core anyway)
73 Shape3DPropertiesContext::Shape3DPropertiesContext( ContextHandler2Helper
& rParent
, const AttributeList
& rAttribs
, Shape3DProperties
& r3DProperties
) throw()
74 : ContextHandler2( rParent
)
75 , mr3DProperties( r3DProperties
)
77 if( rAttribs
.hasAttribute( XML_extrusionH
) )
78 mr3DProperties
.mnExtrusionH
= rAttribs
.getInteger( XML_extrusionH
, 0 );
79 if( rAttribs
.hasAttribute( XML_contourW
) )
80 mr3DProperties
.mnContourW
= rAttribs
.getInteger( XML_contourW
, 0 );
81 if( rAttribs
.hasAttribute( XML_z
) )
82 mr3DProperties
.mnShapeZ
= rAttribs
.getInteger( XML_z
, 0 );
83 if( rAttribs
.hasAttribute( XML_prstMaterial
) )
84 mr3DProperties
.mnMaterial
= rAttribs
.getToken( XML_prstMaterial
, XML_none
);
87 ContextHandlerRef
Shape3DPropertiesContext::onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
89 switch( aElementToken
)
91 case A_TOKEN( bevelT
):
92 case A_TOKEN( bevelB
):
94 BevelProperties aProps
;
95 if( rAttribs
.hasAttribute( XML_w
) )
96 aProps
.mnWidth
= rAttribs
.getInteger( XML_w
, 0 );
97 if( rAttribs
.hasAttribute( XML_h
) )
98 aProps
.mnHeight
= rAttribs
.getInteger( XML_h
, 0 );
99 if( rAttribs
.hasAttribute( XML_prst
) )
100 aProps
.mnPreset
= rAttribs
.getToken( XML_prst
, XML_none
);
102 if( aElementToken
== A_TOKEN( bevelT
) )
103 mr3DProperties
.maTopBevelProperties
.set( aProps
);
105 mr3DProperties
.maBottomBevelProperties
.set( aProps
);
109 case A_TOKEN( extrusionClr
):
110 return new ColorContext( *this, mr3DProperties
.maExtrusionColor
);
112 case A_TOKEN( contourClr
):
113 return new ColorContext( *this, mr3DProperties
.maContourColor
);
118 Scene3DRotationPropertiesContext::Scene3DRotationPropertiesContext( ContextHandler2Helper
& rParent
, RotationProperties
& rRotationProperties
) throw()
119 : ContextHandler2( rParent
)
120 , mrRotationProperties( rRotationProperties
)
124 ContextHandlerRef
Scene3DRotationPropertiesContext::onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
126 switch( aElementToken
)
129 mrRotationProperties
.mnLatitude
= rAttribs
.getInteger( XML_lat
, 0 );
130 mrRotationProperties
.mnLongitude
= rAttribs
.getInteger( XML_lon
, 0 );
131 mrRotationProperties
.mnRevolution
= rAttribs
.getInteger( XML_rev
, 0 );
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */