Branch data Line data Source code
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 : :
20 : : #include "oox/drawingml/transform2dcontext.hxx"
21 : : #include "oox/helper/attributelist.hxx"
22 : : #include "oox/drawingml/shape.hxx"
23 : :
24 : : using ::com::sun::star::awt::Point;
25 : : using ::com::sun::star::awt::Size;
26 : : using ::com::sun::star::uno::Reference;
27 : : using ::com::sun::star::uno::RuntimeException;
28 : : using ::com::sun::star::xml::sax::SAXException;
29 : : using ::com::sun::star::xml::sax::XFastAttributeList;
30 : : using ::com::sun::star::xml::sax::XFastContextHandler;
31 : : using ::oox::core::ContextHandler;
32 : :
33 : : namespace oox {
34 : : namespace drawingml {
35 : :
36 : : // ============================================================================
37 : :
38 : : /** context to import a CT_Transform2D */
39 : 159 : Transform2DContext::Transform2DContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, Shape& rShape ) throw()
40 : : : ContextHandler( rParent )
41 : 159 : , mrShape( rShape )
42 : : {
43 [ + - ]: 159 : AttributeList aAttributeList( xAttribs );
44 [ + - ]: 159 : mrShape.setRotation( aAttributeList.getInteger( XML_rot, 0 ) ); // 60000ths of a degree Positive angles are clockwise; negative angles are counter-clockwise
45 [ + - ][ + - ]: 159 : mrShape.setFlip( aAttributeList.getBool( XML_flipH, sal_False ), aAttributeList.getBool( XML_flipV, sal_False ) );
[ + - ]
46 : 159 : }
47 : :
48 : 384 : Reference< XFastContextHandler > Transform2DContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
49 : : {
50 [ + + + + : 384 : switch( aElementToken )
- ]
51 : : {
52 : : case A_TOKEN( off ): // horz/vert translation
53 [ + - ][ + - ]: 159 : mrShape.setPosition( Point( xAttribs->getOptionalValue( XML_x ).toInt32(), xAttribs->getOptionalValue( XML_y ).toInt32() ) );
54 : 159 : break;
55 : : case A_TOKEN( ext ): // horz/vert size
56 [ + - ][ + - ]: 159 : mrShape.setSize( Size( xAttribs->getOptionalValue( XML_cx ).toInt32(), xAttribs->getOptionalValue( XML_cy ).toInt32() ) );
57 : 159 : break;
58 : : case A_TOKEN( chOff ): // horz/vert translation of children
59 [ + - ][ + - ]: 33 : mrShape.setChildPosition( Point( xAttribs->getOptionalValue( XML_x ).toInt32(), xAttribs->getOptionalValue( XML_y ).toInt32() ) );
60 : 33 : break;
61 : : case A_TOKEN( chExt ): // horz/vert size of children
62 [ + - ][ + - ]: 33 : mrShape.setChildSize( Size( xAttribs->getOptionalValue( XML_cx ).toInt32(), xAttribs->getOptionalValue( XML_cy ).toInt32() ) );
63 : 33 : break;
64 : : }
65 : :
66 : 384 : return 0;
67 : : }
68 : :
69 : : // ============================================================================
70 : :
71 : : } // namespace drawingml
72 [ + - ][ + - ]: 285 : } // namespace oox
73 : :
74 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|