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 <com/sun/star/xml/sax/FastToken.hpp>
21 : #include <com/sun/star/drawing/LineStyle.hpp>
22 : #include <com/sun/star/beans/XMultiPropertySet.hpp>
23 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
24 : #include <com/sun/star/container/XNamed.hpp>
25 :
26 : #include "oox/helper/attributelist.hxx"
27 : #include "oox/drawingml/shapecontext.hxx"
28 : #include "oox/drawingml/shapestylecontext.hxx"
29 : #include "oox/drawingml/fillpropertiesgroupcontext.hxx"
30 : #include "oox/drawingml/lineproperties.hxx"
31 : #include "oox/drawingml/drawingmltypes.hxx"
32 : #include "oox/drawingml/customshapegeometry.hxx"
33 : #include "oox/drawingml/textbodycontext.hxx"
34 : #include "hyperlinkcontext.hxx"
35 :
36 : using namespace oox::core;
37 : using namespace ::com::sun::star;
38 : using namespace ::com::sun::star::uno;
39 : using namespace ::com::sun::star::drawing;
40 : using namespace ::com::sun::star::beans;
41 : using namespace ::com::sun::star::text;
42 : using namespace ::com::sun::star::xml::sax;
43 :
44 : namespace oox { namespace drawingml {
45 :
46 : // CT_Shape
47 170 : ShapeContext::ShapeContext( ContextHandler2Helper& rParent, ShapePtr pMasterShapePtr, ShapePtr pShapePtr )
48 : : ContextHandler2( rParent )
49 : , mpMasterShapePtr( pMasterShapePtr )
50 170 : , mpShapePtr( pShapePtr )
51 : {
52 170 : }
53 :
54 345 : ShapeContext::~ShapeContext()
55 : {
56 170 : if ( mpMasterShapePtr.get() && mpShapePtr.get() )
57 151 : mpMasterShapePtr->addChild( mpShapePtr );
58 175 : }
59 :
60 0 : ShapePtr ShapeContext::getShape()
61 : {
62 0 : return mpShapePtr;
63 : }
64 :
65 135 : ContextHandlerRef ShapeContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
66 : {
67 135 : switch( getBaseToken( aElementToken ) )
68 : {
69 : // nvSpPr CT_ShapeNonVisual begin
70 : // case XML_drElemPr:
71 : // break;
72 : case XML_cNvPr:
73 : {
74 27 : mpShapePtr->setHidden( rAttribs.getBool( XML_hidden, false ) );
75 27 : mpShapePtr->setId( rAttribs.getString( XML_id ).get() );
76 27 : mpShapePtr->setName( rAttribs.getString( XML_name ).get() );
77 27 : break;
78 : }
79 : case XML_hlinkMouseOver:
80 : case XML_hlinkClick:
81 0 : return new HyperLinkContext( *this, rAttribs, getShape()->getShapeProperties() );
82 : case XML_ph:
83 0 : mpShapePtr->setSubType( rAttribs.getToken( XML_type, XML_obj ) );
84 0 : if( rAttribs.hasAttribute( XML_idx ) )
85 0 : mpShapePtr->setSubTypeIndex( rAttribs.getString( XML_idx ).get().toInt32() );
86 0 : break;
87 : // nvSpPr CT_ShapeNonVisual end
88 :
89 : case XML_spPr:
90 24 : return new ShapePropertiesContext( *this, *mpShapePtr );
91 :
92 : case XML_style:
93 10 : return new ShapeStyleContext( *this, *mpShapePtr );
94 :
95 : case XML_txBody:
96 : {
97 3 : TextBodyPtr xTextBody( new TextBody );
98 3 : mpShapePtr->setTextBody( xTextBody );
99 3 : return new TextBodyContext( *this, *xTextBody );
100 : }
101 : case XML_txXfrm:
102 : {
103 3 : mpShapePtr->getTextBody()->getTextProperties().moRotation = rAttribs.getInteger( XML_rot );
104 3 : break;
105 : }
106 : }
107 :
108 98 : return this;
109 : }
110 :
111 :
112 141 : } }
113 :
114 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|