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 : #include "oox/drawingml/textbody.hxx"
24 :
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::ContextHandlerRef;
32 :
33 : namespace oox {
34 : namespace drawingml {
35 :
36 : /** context to import a CT_Transform2D */
37 178 : Transform2DContext::Transform2DContext( ContextHandler2Helper& rParent, const AttributeList& rAttribs, Shape& rShape, bool btxXfrm ) throw()
38 : : ContextHandler2( rParent )
39 : , mrShape( rShape )
40 178 : , mbtxXfrm ( btxXfrm )
41 : {
42 178 : if( !btxXfrm )
43 : {
44 178 : mrShape.setRotation( rAttribs.getInteger( XML_rot, 0 ) ); // 60000ths of a degree Positive angles are clockwise; negative angles are counter-clockwise
45 178 : mrShape.setFlip( rAttribs.getBool( XML_flipH, sal_False ), rAttribs.getBool( XML_flipV, sal_False ) );
46 : }
47 : else
48 : {
49 0 : mrShape.getTextBody()->getTextProperties().moRotation = rAttribs.getInteger( XML_rot );
50 : }
51 178 : }
52 :
53 420 : ContextHandlerRef Transform2DContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
54 : {
55 420 : if( mbtxXfrm )
56 : {
57 0 : switch( aElementToken )
58 : {
59 : case A_TOKEN( off ):
60 : {
61 0 : OUString sXValue = rAttribs.getString( XML_x ).get();
62 0 : OUString sYValue = rAttribs.getString( XML_y ).get();
63 0 : if( !sXValue.isEmpty() )
64 0 : mrShape.getTextBody()->getTextProperties().moTextOffX = GetCoordinate( sXValue.toInt32() - mrShape.getPosition().X );
65 0 : if( !sYValue.isEmpty() )
66 0 : mrShape.getTextBody()->getTextProperties().moTextOffY = GetCoordinate( sYValue.toInt32() - mrShape.getPosition().Y );
67 : }
68 0 : break;
69 : case A_TOKEN( ext ):
70 0 : break;
71 : }
72 0 : return 0;
73 : }
74 :
75 420 : switch( aElementToken )
76 : {
77 : case A_TOKEN( off ): // horz/vert translation
78 178 : mrShape.setPosition( awt::Point( rAttribs.getString( XML_x ).get().toInt32(), rAttribs.getString( XML_y ).get().toInt32() ) );
79 178 : break;
80 : case A_TOKEN( ext ): // horz/vert size
81 178 : mrShape.setSize( awt::Size( rAttribs.getString( XML_cx ).get().toInt32(), rAttribs.getString( XML_cy ).get().toInt32() ) );
82 178 : break;
83 : case A_TOKEN( chOff ): // horz/vert translation of children
84 32 : mrShape.setChildPosition( awt::Point( rAttribs.getString( XML_x ).get().toInt32(), rAttribs.getString( XML_y ).get().toInt32() ) );
85 32 : break;
86 : case A_TOKEN( chExt ): // horz/vert size of children
87 32 : mrShape.setChildSize( awt::Size( rAttribs.getString( XML_cx ).get().toInt32(), rAttribs.getString( XML_cy ).get().toInt32() ) );
88 32 : break;
89 : }
90 :
91 420 : return 0;
92 : }
93 :
94 : } // namespace drawingml
95 141 : } // namespace oox
96 :
97 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|