xref: /AOO41X/main/oox/source/drawingml/transform2dcontext.cxx (revision ca5ec2004b000a7d9aaa8381be8ac2853e3b1dc7)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include "oox/drawingml/transform2dcontext.hxx"
25 #include "oox/helper/attributelist.hxx"
26 #include "oox/drawingml/shape.hxx"
27 
28 using ::com::sun::star::awt::Point;
29 using ::com::sun::star::awt::Size;
30 using ::com::sun::star::uno::Reference;
31 using ::com::sun::star::uno::RuntimeException;
32 using ::com::sun::star::xml::sax::SAXException;
33 using ::com::sun::star::xml::sax::XFastAttributeList;
34 using ::com::sun::star::xml::sax::XFastContextHandler;
35 using ::oox::core::ContextHandler;
36 
37 namespace oox {
38 namespace drawingml {
39 
40 // ============================================================================
41 
42 /** context to import a CT_Transform2D */
Transform2DContext(ContextHandler & rParent,const Reference<XFastAttributeList> & xAttribs,Shape & rShape)43 Transform2DContext::Transform2DContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, Shape& rShape ) throw()
44 : ContextHandler( rParent )
45 , mrShape( rShape )
46 {
47     AttributeList aAttributeList( xAttribs );
48     mrShape.setRotation( aAttributeList.getInteger( XML_rot, 0 ) ); // 60000ths of a degree Positive angles are clockwise; negative angles are counter-clockwise
49     mrShape.setFlip( aAttributeList.getBool( XML_flipH, sal_False ), aAttributeList.getBool( XML_flipV, sal_False ) );
50 }
51 
createFastChildContext(sal_Int32 aElementToken,const Reference<XFastAttributeList> & xAttribs)52 Reference< XFastContextHandler > Transform2DContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
53 {
54     switch( aElementToken )
55     {
56     case A_TOKEN( off ):        // horz/vert translation
57         mrShape.setPosition( Point( xAttribs->getOptionalValue( XML_x ).toInt32(), xAttribs->getOptionalValue( XML_y ).toInt32() ) );
58         break;
59     case A_TOKEN( ext ):        // horz/vert size
60         mrShape.setSize( Size( xAttribs->getOptionalValue( XML_cx ).toInt32(), xAttribs->getOptionalValue( XML_cy ).toInt32() ) );
61         break;
62 /* todo: what to do?
63     case A_TOKEN( chOff ):  // horz/vert translation of children
64     case A_TOKEN( chExt ):  // horz/vert size of children
65         break;
66 */
67     }
68 
69     return 0;
70 }
71 
72 // ============================================================================
73 
74 } // namespace drawingml
75 } // namespace oox
76 
77