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 $
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"
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
59 ShapeTargetElementContext( ContextHandler
& rParent
, ShapeTargetElement
& aValue
)
60 : ContextHandler( rParent
)
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
)
75 maShapeTarget
.mnType
= XML_bg
;
77 case NMSP_PPT
|XML_txEl
:
79 maShapeTarget
.mnType
= XML_txEl
;
81 case NMSP_PPT
|XML_subSp
:
83 maShapeTarget
.mnType
= XML_subSp
;
84 maShapeTarget
.msSubShapeId
= xAttribs
->getOptionalValue( XML_spid
);
86 case NMSP_PPT
|XML_graphicEl
:
87 case NMSP_PPT
|XML_oleChartEl
:
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
);
109 ShapeTargetElement
& maShapeTarget
;
114 TimeTargetElementContext::TimeTargetElementContext( ContextHandler
& rParent
, const AnimTargetElementPtr
& pValue
)
115 : ContextHandler( rParent
),
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
;
146 case NMSP_PPT
|XML_sldTgt
:
147 mpTarget
->mnType
= XML_sldTgt
;
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
;
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
) );
168 OSL_TRACE( "OOX: unhandled tag %ld in TL_TimeTargetElement.", getToken( aElementToken
) );