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 "oox/drawingml/fillproperties.hxx"
28 #include "oox/core/xmlfilterbase.hxx"
29 #include "oox/helper/attributelist.hxx"
31 using namespace ::oox::core
;
32 using namespace ::com::sun::star
;
33 using namespace ::com::sun::star::uno
;
34 using namespace ::com::sun::star::xml::sax
;
36 namespace oox
{ namespace drawingml
{
38 Scene3DPropertiesContext::Scene3DPropertiesContext( ContextHandler2Helper
& rParent
, Shape3DProperties
& r3DProperties
) throw()
39 : ContextHandler2( rParent
)
40 , mr3DProperties( r3DProperties
)
44 ContextHandlerRef
Scene3DPropertiesContext::onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
46 switch( aElementToken
)
48 case A_TOKEN( camera
):
49 if( rAttribs
.hasAttribute( XML_fov
) )
50 mr3DProperties
.mfFieldOfVision
= rAttribs
.getInteger( XML_fov
, 0 ) / 60000.0; // 60000ths of degree
51 if( rAttribs
.hasAttribute( XML_zoom
) )
52 mr3DProperties
.mfZoom
= rAttribs
.getInteger( XML_zoom
, 100000 ) / 100000.0;
53 if( rAttribs
.hasAttribute( XML_prst
) )
54 mr3DProperties
.mnPreset
= rAttribs
.getToken( XML_prst
, XML_none
);
56 return new Scene3DRotationPropertiesContext( *this, mr3DProperties
.maCameraRotation
);
58 case A_TOKEN( lightRig
):
59 mr3DProperties
.mnLightRigDirection
= rAttribs
.getToken( XML_dir
, XML_none
);
60 mr3DProperties
.mnLightRigType
= rAttribs
.getToken( XML_rig
, XML_none
);
62 return new Scene3DRotationPropertiesContext( *this, mr3DProperties
.maLightRigRotation
);
64 case A_TOKEN( backdrop
):
65 case A_TOKEN( extLst
):
66 return 0; // TODO: later (backdrop is not supported by core anyway)
71 Shape3DPropertiesContext::Shape3DPropertiesContext( ContextHandler2Helper
& rParent
, const AttributeList
& rAttribs
, Shape3DProperties
& r3DProperties
) throw()
72 : ContextHandler2( rParent
)
73 , mr3DProperties( r3DProperties
)
75 if( rAttribs
.hasAttribute( XML_extrusionH
) )
76 mr3DProperties
.mnExtrusionH
= rAttribs
.getInteger( XML_extrusionH
, 0 );
77 if( rAttribs
.hasAttribute( XML_contourW
) )
78 mr3DProperties
.mnContourW
= rAttribs
.getInteger( XML_contourW
, 0 );
79 if( rAttribs
.hasAttribute( XML_z
) )
80 mr3DProperties
.mnShapeZ
= rAttribs
.getInteger( XML_z
, 0 );
81 if( rAttribs
.hasAttribute( XML_prstMaterial
) )
82 mr3DProperties
.mnMaterial
= rAttribs
.getToken( XML_prstMaterial
, XML_none
);
85 ContextHandlerRef
Shape3DPropertiesContext::onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
87 switch( aElementToken
)
89 case A_TOKEN( bevelT
):
90 case A_TOKEN( bevelB
):
92 BevelProperties aProps
;
93 if( rAttribs
.hasAttribute( XML_w
) )
94 aProps
.mnWidth
= rAttribs
.getInteger( XML_w
, 0 );
95 if( rAttribs
.hasAttribute( XML_h
) )
96 aProps
.mnHeight
= rAttribs
.getInteger( XML_h
, 0 );
97 if( rAttribs
.hasAttribute( XML_prst
) )
98 aProps
.mnPreset
= rAttribs
.getToken( XML_prst
, XML_none
);
100 if( aElementToken
== A_TOKEN( bevelT
) )
101 mr3DProperties
.maTopBevelProperties
.set( aProps
);
103 mr3DProperties
.maBottomBevelProperties
.set( aProps
);
107 case A_TOKEN( extrusionClr
):
108 return new ColorContext( *this, mr3DProperties
.maExtrusionColor
);
110 case A_TOKEN( contourClr
):
111 return new ColorContext( *this, mr3DProperties
.maContourColor
);
116 Scene3DRotationPropertiesContext::Scene3DRotationPropertiesContext( ContextHandler2Helper
& rParent
, RotationProperties
& rRotationProperties
) throw()
117 : ContextHandler2( rParent
)
118 , mrRotationProperties( rRotationProperties
)
122 ContextHandlerRef
Scene3DRotationPropertiesContext::onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
124 switch( aElementToken
)
127 mrRotationProperties
.mnLatitude
= rAttribs
.getInteger( XML_lat
, 0 );
128 mrRotationProperties
.mnLongitude
= rAttribs
.getInteger( XML_lon
, 0 );
129 mrRotationProperties
.mnRevolution
= rAttribs
.getInteger( XML_rev
, 0 );
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */