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 "timetargetelementcontext.hxx"
21 :
22 : #include "comphelper/anytostring.hxx"
23 : #include "cppuhelper/exc_hlp.hxx"
24 : #include <osl/diagnose.h>
25 :
26 : #include <com/sun/star/uno/Any.hxx>
27 :
28 : #include "oox/helper/attributelist.hxx"
29 : #include "oox/drawingml/embeddedwavaudiofile.hxx"
30 :
31 : using namespace ::com::sun::star::uno;
32 : using namespace ::com::sun::star::xml::sax;
33 : using namespace ::oox::core;
34 :
35 : namespace oox { namespace ppt {
36 :
37 :
38 :
39 : // CT_TLShapeTargetElement
40 0 : class ShapeTargetElementContext
41 : : public FragmentHandler2
42 : {
43 : public:
44 0 : ShapeTargetElementContext( FragmentHandler2& rParent, ShapeTargetElement & aValue )
45 : : FragmentHandler2( rParent )
46 : , bTargetSet(false)
47 0 : , maShapeTarget(aValue)
48 : {
49 0 : }
50 0 : virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) SAL_OVERRIDE
51 : {
52 0 : switch( aElementToken )
53 : {
54 : case PPT_TOKEN( bg ):
55 0 : bTargetSet = true;
56 0 : maShapeTarget.mnType = XML_bg;
57 0 : return this;
58 : case PPT_TOKEN( txEl ):
59 0 : bTargetSet = true;
60 0 : maShapeTarget.mnType = XML_txEl;
61 0 : return this;
62 : case PPT_TOKEN( subSp ):
63 0 : bTargetSet = true;
64 0 : maShapeTarget.mnType = XML_subSp;
65 0 : maShapeTarget.msSubShapeId = rAttribs.getString( XML_spid, OUString() );
66 0 : return this;
67 : case PPT_TOKEN( graphicEl ):
68 0 : return this; // needs a:dgm for the target
69 : case A_TOKEN( dgm ):
70 0 : bTargetSet = true;
71 0 : maShapeTarget.mnType = XML_dgm;
72 0 : maShapeTarget.msSubShapeId = rAttribs.getString( XML_id, OUString() );
73 0 : return this;
74 : case PPT_TOKEN( oleChartEl ):
75 0 : bTargetSet = true;
76 : // TODO
77 0 : return this;
78 : case PPT_TOKEN( charRg ):
79 : case PPT_TOKEN( pRg ):
80 0 : if( bTargetSet && maShapeTarget.mnType == XML_txEl )
81 : {
82 0 : maShapeTarget.mnRangeType = getBaseToken( aElementToken );
83 0 : maShapeTarget.maRange = drawingml::GetIndexRange( rAttribs.getFastAttributeList() );
84 : }
85 0 : return this;
86 : default:
87 0 : break;
88 : }
89 0 : return this;
90 : }
91 :
92 : private:
93 : bool bTargetSet;
94 : ShapeTargetElement & maShapeTarget;
95 : };
96 :
97 :
98 :
99 0 : TimeTargetElementContext::TimeTargetElementContext( FragmentHandler2& rParent, const AnimTargetElementPtr & pValue )
100 : : FragmentHandler2( rParent ),
101 0 : mpTarget( pValue )
102 : {
103 : OSL_ENSURE( mpTarget, "no valid target passed" );
104 0 : }
105 :
106 :
107 0 : TimeTargetElementContext::~TimeTargetElementContext( ) throw( )
108 : {
109 0 : }
110 :
111 0 : ::oox::core::ContextHandlerRef TimeTargetElementContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
112 : {
113 0 : switch( aElementToken )
114 : {
115 : case PPT_TOKEN( inkTgt ):
116 : {
117 0 : mpTarget->mnType = XML_inkTgt;
118 0 : OUString aId = rAttribs.getString( XML_spid, OUString() );
119 0 : if( !aId.isEmpty() )
120 : {
121 0 : mpTarget->msValue = aId;
122 : }
123 0 : return this;
124 : }
125 : case PPT_TOKEN( sldTgt ):
126 0 : mpTarget->mnType = XML_sldTgt;
127 0 : return this;
128 : case PPT_TOKEN( sndTgt ):
129 : {
130 0 : mpTarget->mnType = XML_sndTgt;
131 0 : drawingml::EmbeddedWAVAudioFile aAudio;
132 0 : drawingml::getEmbeddedWAVAudioFile( getRelations(), rAttribs.getFastAttributeList(), aAudio);
133 :
134 0 : OUString sSndName = ( aAudio.mbBuiltIn ? aAudio.msName : aAudio.msEmbed );
135 0 : mpTarget->msValue = sSndName;
136 0 : break;
137 : }
138 : case PPT_TOKEN( spTgt ):
139 : {
140 0 : mpTarget->mnType = XML_spTgt;
141 0 : OUString aId = rAttribs.getString( XML_spid, OUString() );
142 0 : mpTarget->msValue = aId;
143 0 : return new ShapeTargetElementContext( *this, mpTarget->maShapeTarget );
144 : }
145 : default:
146 : OSL_TRACE( "OOX: unhandled tag %ld in TL_TimeTargetElement.", getBaseToken( aElementToken ) );
147 0 : break;
148 : }
149 :
150 0 : return this;
151 : }
152 :
153 :
154 0 : } }
155 :
156 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|