Update ooo320-m1
[ooovba.git] / oox / source / ppt / timetargetelementcontext.cxx
blob59a544df951e2dada14998906032c56519ca32e4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: timetargetelementcontext.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "timetargetelementcontext.hxx"
33 #include "comphelper/anytostring.hxx"
34 #include "cppuhelper/exc_hlp.hxx"
35 #include <osl/diagnose.h>
37 #include <com/sun/star/uno/Any.hxx>
39 #include "oox/helper/attributelist.hxx"
40 #include "oox/core/namespaces.hxx"
41 #include "oox/drawingml/embeddedwavaudiofile.hxx"
42 #include "tokens.hxx"
44 using namespace ::com::sun::star::uno;
45 using namespace ::com::sun::star::xml::sax;
46 using namespace ::oox::core;
48 using ::rtl::OUString;
50 namespace oox { namespace ppt {
54 // CT_TLShapeTargetElement
55 class ShapeTargetElementContext
56 : public ContextHandler
58 public:
59 ShapeTargetElementContext( ContextHandler& rParent, ShapeTargetElement & aValue )
60 : ContextHandler( rParent )
61 , bTargetSet(false)
62 , maShapeTarget(aValue)
65 virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken,
66 const Reference< XFastAttributeList >& xAttribs )
67 throw ( SAXException, RuntimeException )
69 Reference< XFastContextHandler > xRet;
71 switch( aElementToken )
73 case NMSP_PPT|XML_bg:
74 bTargetSet = true;
75 maShapeTarget.mnType = XML_bg;
76 break;
77 case NMSP_PPT|XML_txEl:
78 bTargetSet = true;
79 maShapeTarget.mnType = XML_txEl;
80 break;
81 case NMSP_PPT|XML_subSp:
82 bTargetSet = true;
83 maShapeTarget.mnType = XML_subSp;
84 maShapeTarget.msSubShapeId = xAttribs->getOptionalValue( XML_spid );
85 break;
86 case NMSP_PPT|XML_graphicEl:
87 case NMSP_PPT|XML_oleChartEl:
88 bTargetSet = true;
89 // TODO
90 break;
91 case NMSP_PPT|XML_charRg:
92 case NMSP_PPT|XML_pRg:
93 if( bTargetSet && maShapeTarget.mnType == XML_txEl )
95 maShapeTarget.mnRangeType = getToken( aElementToken );
96 maShapeTarget.maRange = drawingml::GetIndexRange( xAttribs );
98 break;
99 default:
100 break;
102 if( !xRet.is() )
103 xRet.set( this );
104 return xRet;
107 private:
108 bool bTargetSet;
109 ShapeTargetElement & maShapeTarget;
114 TimeTargetElementContext::TimeTargetElementContext( ContextHandler& rParent, const AnimTargetElementPtr & pValue )
115 : ContextHandler( rParent ),
116 mpTarget( pValue )
118 OSL_ENSURE( mpTarget, "no valid target passed" );
122 TimeTargetElementContext::~TimeTargetElementContext( ) throw( )
126 void SAL_CALL TimeTargetElementContext::endFastElement( sal_Int32 /*aElement*/ ) throw ( SAXException, RuntimeException)
130 Reference< XFastContextHandler > SAL_CALL TimeTargetElementContext::createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw ( SAXException, RuntimeException )
132 Reference< XFastContextHandler > xRet;
134 switch( aElementToken )
136 case NMSP_PPT|XML_inkTgt:
138 mpTarget->mnType = XML_inkTgt;
139 OUString aId = xAttribs->getOptionalValue( XML_spid );
140 if( aId.getLength() )
142 mpTarget->msValue = aId;
144 break;
146 case NMSP_PPT|XML_sldTgt:
147 mpTarget->mnType = XML_sldTgt;
148 break;
149 case NMSP_PPT|XML_sndTgt:
151 mpTarget->mnType = XML_sndTgt;
152 drawingml::EmbeddedWAVAudioFile aAudio;
153 drawingml::getEmbeddedWAVAudioFile( getRelations(), xAttribs, aAudio);
155 OUString sSndName = ( aAudio.mbBuiltIn ? aAudio.msName : aAudio.msEmbed );
156 mpTarget->msValue = sSndName;
157 break;
159 case NMSP_PPT|XML_spTgt:
161 mpTarget->mnType = XML_spTgt;
162 OUString aId = xAttribs->getOptionalValue( XML_spid );
163 mpTarget->msValue = aId;
164 xRet.set( new ShapeTargetElementContext( *this, mpTarget->maShapeTarget ) );
165 break;
167 default:
168 OSL_TRACE( "OOX: unhandled tag %ld in TL_TimeTargetElement.", getToken( aElementToken ) );
169 break;
172 if( !xRet.is() )
173 xRet.set( this );
175 return xRet;