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 "oox/drawingml/transform2dcontext.hxx"
21 #include "oox/helper/attributelist.hxx"
22 #include "oox/drawingml/shape.hxx"
23 #include "oox/drawingml/textbody.hxx"
25 using namespace ::com::sun::star
;
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
;
36 // ============================================================================
38 /** context to import a CT_Transform2D */
39 Transform2DContext::Transform2DContext( ContextHandler
& rParent
, const Reference
< XFastAttributeList
>& xAttribs
, Shape
& rShape
, bool btxXfrm
) throw()
40 : ContextHandler( rParent
)
42 , mbtxXfrm ( btxXfrm
)
44 AttributeList
aAttributeList( xAttribs
);
47 mrShape
.setRotation( aAttributeList
.getInteger( XML_rot
, 0 ) ); // 60000ths of a degree Positive angles are clockwise; negative angles are counter-clockwise
48 mrShape
.setFlip( aAttributeList
.getBool( XML_flipH
, sal_False
), aAttributeList
.getBool( XML_flipV
, sal_False
) );
52 mrShape
.getTextBody()->getTextProperties().moRotation
= aAttributeList
.getInteger( XML_rot
);
56 Reference
< XFastContextHandler
> Transform2DContext::createFastChildContext( sal_Int32 aElementToken
, const Reference
< XFastAttributeList
>& xAttribs
) throw (SAXException
, RuntimeException
)
60 switch( aElementToken
)
64 OUString sXValue
= xAttribs
->getOptionalValue( XML_x
);
65 OUString sYValue
= xAttribs
->getOptionalValue( XML_y
);
66 if( !sXValue
.isEmpty() )
67 mrShape
.getTextBody()->getTextProperties().moTextOffX
= GetCoordinate( sXValue
.toInt32() - mrShape
.getPosition().X
);
68 if( !sYValue
.isEmpty() )
69 mrShape
.getTextBody()->getTextProperties().moTextOffY
= GetCoordinate( sYValue
.toInt32() - mrShape
.getPosition().Y
);
78 switch( aElementToken
)
80 case A_TOKEN( off
): // horz/vert translation
81 mrShape
.setPosition( awt::Point( xAttribs
->getOptionalValue( XML_x
).toInt32(), xAttribs
->getOptionalValue( XML_y
).toInt32() ) );
83 case A_TOKEN( ext
): // horz/vert size
84 mrShape
.setSize( awt::Size( xAttribs
->getOptionalValue( XML_cx
).toInt32(), xAttribs
->getOptionalValue( XML_cy
).toInt32() ) );
86 case A_TOKEN( chOff
): // horz/vert translation of children
87 mrShape
.setChildPosition( awt::Point( xAttribs
->getOptionalValue( XML_x
).toInt32(), xAttribs
->getOptionalValue( XML_y
).toInt32() ) );
89 case A_TOKEN( chExt
): // horz/vert size of children
90 mrShape
.setChildSize( awt::Size( xAttribs
->getOptionalValue( XML_cx
).toInt32(), xAttribs
->getOptionalValue( XML_cy
).toInt32() ) );
97 // ============================================================================
99 } // namespace drawingml
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */