xref: /trunk/main/oox/source/drawingml/transform2dcontext.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include "oox/drawingml/transform2dcontext.hxx"
29 #include "oox/helper/attributelist.hxx"
30 #include "oox/drawingml/shape.hxx"
31 
32 using ::com::sun::star::awt::Point;
33 using ::com::sun::star::awt::Size;
34 using ::com::sun::star::uno::Reference;
35 using ::com::sun::star::uno::RuntimeException;
36 using ::com::sun::star::xml::sax::SAXException;
37 using ::com::sun::star::xml::sax::XFastAttributeList;
38 using ::com::sun::star::xml::sax::XFastContextHandler;
39 using ::oox::core::ContextHandler;
40 
41 namespace oox {
42 namespace drawingml {
43 
44 // ============================================================================
45 
46 /** context to import a CT_Transform2D */
47 Transform2DContext::Transform2DContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, Shape& rShape ) throw()
48 : ContextHandler( rParent )
49 , mrShape( rShape )
50 {
51     AttributeList aAttributeList( xAttribs );
52     mrShape.setRotation( aAttributeList.getInteger( XML_rot, 0 ) ); // 60000ths of a degree Positive angles are clockwise; negative angles are counter-clockwise
53     mrShape.setFlip( aAttributeList.getBool( XML_flipH, sal_False ), aAttributeList.getBool( XML_flipV, sal_False ) );
54 }
55 
56 Reference< XFastContextHandler > Transform2DContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
57 {
58     switch( aElementToken )
59     {
60     case A_TOKEN( off ):        // horz/vert translation
61         mrShape.setPosition( Point( xAttribs->getOptionalValue( XML_x ).toInt32(), xAttribs->getOptionalValue( XML_y ).toInt32() ) );
62         break;
63     case A_TOKEN( ext ):        // horz/vert size
64         mrShape.setSize( Size( xAttribs->getOptionalValue( XML_cx ).toInt32(), xAttribs->getOptionalValue( XML_cy ).toInt32() ) );
65         break;
66 /* todo: what to do?
67     case A_TOKEN( chOff ):  // horz/vert translation of children
68     case A_TOKEN( chExt ):  // horz/vert size of children
69         break;
70 */
71     }
72 
73     return 0;
74 }
75 
76 // ============================================================================
77 
78 } // namespace drawingml
79 } // namespace oox
80 
81