1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: transform2dcontext.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "oox/drawingml/transform2dcontext.hxx"
32 #include "oox/core/namespaces.hxx"
33 #include "oox/helper/attributelist.hxx"
34 #include "oox/drawingml/shape.hxx"
36 using ::com::sun::star::awt::Point
;
37 using ::com::sun::star::awt::Size
;
38 using ::com::sun::star::uno::Reference
;
39 using ::com::sun::star::uno::RuntimeException
;
40 using ::com::sun::star::xml::sax::SAXException
;
41 using ::com::sun::star::xml::sax::XFastAttributeList
;
42 using ::com::sun::star::xml::sax::XFastContextHandler
;
43 using ::oox::core::ContextHandler
;
48 // ============================================================================
50 /** context to import a CT_Transform2D */
51 Transform2DContext::Transform2DContext( ContextHandler
& rParent
, const Reference
< XFastAttributeList
>& xAttribs
, Shape
& rShape
) throw()
52 : ContextHandler( rParent
)
55 AttributeList
aAttributeList( xAttribs
);
56 mrShape
.setRotation( aAttributeList
.getInteger( XML_rot
, 0 ) ); // 60000ths of a degree Positive angles are clockwise; negative angles are counter-clockwise
57 mrShape
.setFlip( aAttributeList
.getBool( XML_flipH
, sal_False
), aAttributeList
.getBool( XML_flipV
, sal_False
) );
60 Reference
< XFastContextHandler
> Transform2DContext::createFastChildContext( sal_Int32 aElementToken
, const Reference
< XFastAttributeList
>& xAttribs
) throw (SAXException
, RuntimeException
)
62 switch( aElementToken
)
64 case NMSP_DRAWINGML
|XML_off
: // horz/vert translation
65 mrShape
.setPosition( Point( xAttribs
->getOptionalValue( XML_x
).toInt32(), xAttribs
->getOptionalValue( XML_y
).toInt32() ) );
67 case NMSP_DRAWINGML
|XML_ext
: // horz/vert size
68 mrShape
.setSize( Size( xAttribs
->getOptionalValue( XML_cx
).toInt32(), xAttribs
->getOptionalValue( XML_cy
).toInt32() ) );
71 case NMSP_DRAWINGML|XML_chOff: // horz/vert translation of children
72 case NMSP_DRAWINGML|XML_chExt: // horz/vert size of children
80 // ============================================================================
82 } // namespace drawingml