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 "oox/drawingml/textbodypropertiescontext.hxx"
35 : #include "hyperlinkcontext.hxx"
36 :
37 : using namespace oox::core;
38 : using namespace ::com::sun::star;
39 : using namespace ::com::sun::star::uno;
40 : using namespace ::com::sun::star::drawing;
41 : using namespace ::com::sun::star::beans;
42 : using namespace ::com::sun::star::text;
43 : using namespace ::com::sun::star::xml::sax;
44 :
45 : namespace oox { namespace drawingml {
46 :
47 : // CT_Shape
48 0 : ShapeContext::ShapeContext( ContextHandler2Helper& rParent, ShapePtr pMasterShapePtr, ShapePtr pShapePtr )
49 : : ContextHandler2( rParent )
50 : , mpMasterShapePtr( pMasterShapePtr )
51 0 : , mpShapePtr( pShapePtr )
52 : {
53 0 : }
54 :
55 0 : ShapeContext::~ShapeContext()
56 : {
57 0 : if ( mpMasterShapePtr.get() && mpShapePtr.get() )
58 0 : mpMasterShapePtr->addChild( mpShapePtr );
59 0 : }
60 :
61 0 : ShapePtr ShapeContext::getShape()
62 : {
63 0 : return mpShapePtr;
64 : }
65 :
66 0 : ContextHandlerRef ShapeContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
67 : {
68 0 : switch( getBaseToken( aElementToken ) )
69 : {
70 : // nvSpPr CT_ShapeNonVisual begin
71 : // case XML_drElemPr:
72 : // break;
73 : case XML_cNvPr:
74 : {
75 0 : mpShapePtr->setHidden( rAttribs.getBool( XML_hidden, false ) );
76 0 : mpShapePtr->setId( rAttribs.getString( XML_id ).get() );
77 0 : mpShapePtr->setName( rAttribs.getString( XML_name ).get() );
78 0 : break;
79 : }
80 : case XML_hlinkMouseOver:
81 : case XML_hlinkClick:
82 0 : return new HyperLinkContext( *this, rAttribs, getShape()->getShapeProperties() );
83 : case XML_ph:
84 0 : mpShapePtr->setSubType( rAttribs.getToken( XML_type, XML_obj ) );
85 0 : if( rAttribs.hasAttribute( XML_idx ) )
86 0 : mpShapePtr->setSubTypeIndex( rAttribs.getString( XML_idx ).get().toInt32() );
87 0 : break;
88 : // nvSpPr CT_ShapeNonVisual end
89 :
90 : case XML_spPr:
91 0 : return new ShapePropertiesContext( *this, *mpShapePtr );
92 :
93 : case XML_style:
94 0 : return new ShapeStyleContext( *this, *mpShapePtr );
95 :
96 : case XML_txBody:
97 : case XML_txbxContent:
98 : {
99 0 : if (!mpShapePtr->getTextBody())
100 0 : mpShapePtr->setTextBody( TextBodyPtr(new TextBody) );
101 0 : return new TextBodyContext( *this, *mpShapePtr->getTextBody() );
102 : }
103 : case XML_txXfrm:
104 : {
105 0 : mpShapePtr->getTextBody()->getTextProperties().moRotation = rAttribs.getInteger( XML_rot );
106 0 : return 0;
107 : break;
108 : }
109 : case XML_cNvSpPr:
110 0 : break;
111 : case XML_spLocks:
112 0 : break;
113 : case XML_bodyPr:
114 0 : if (!mpShapePtr->getTextBody())
115 0 : mpShapePtr->setTextBody( TextBodyPtr(new TextBody) );
116 0 : return new TextBodyPropertiesContext( *this, rAttribs, mpShapePtr->getTextBody()->getTextProperties() );
117 : break;
118 : case XML_txbx:
119 0 : break;
120 : case XML_cNvPicPr:
121 0 : break;
122 : case XML_nvPicPr:
123 0 : break;
124 : case XML_relIds:
125 0 : break;
126 : case XML_nvSpPr:
127 0 : break;
128 : default:
129 : SAL_WARN("oox", "ShapeContext::onCreateContext: unhandled element: " << getBaseToken(aElementToken));
130 0 : break;
131 : }
132 :
133 0 : return this;
134 : }
135 :
136 :
137 0 : } }
138 :
139 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|