1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <config_features.h>
22 #include "timetargetelementcontext.hxx"
24 #include <cppuhelper/exc_hlp.hxx>
25 #include <osl/diagnose.h>
26 #include <sal/log.hxx>
28 #include <oox/helper/attributelist.hxx>
29 #include <drawingml/embeddedwavaudiofile.hxx>
30 #include <oox/token/namespaces.hxx>
31 #include <oox/token/tokens.hxx>
32 #include <oox/core/xmlfilterbase.hxx>
33 #include <com/sun/star/io/XInputStream.hpp>
34 #include <avmedia/mediaitem.hxx>
36 using namespace ::com::sun::star::uno
;
37 using namespace ::com::sun::star::xml::sax
;
38 using namespace ::oox::core
;
40 namespace oox
{ namespace ppt
{
42 // CT_TLShapeTargetElement
43 class ShapeTargetElementContext
44 : public FragmentHandler2
47 ShapeTargetElementContext( FragmentHandler2
const & rParent
, ShapeTargetElement
& aValue
)
48 : FragmentHandler2( rParent
)
50 , maShapeTarget(aValue
)
53 virtual ::oox::core::ContextHandlerRef
onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
) override
55 switch( aElementToken
)
59 maShapeTarget
.mnType
= XML_bg
;
61 case PPT_TOKEN( txEl
):
63 maShapeTarget
.mnType
= XML_txEl
;
65 case PPT_TOKEN( subSp
):
67 maShapeTarget
.mnType
= XML_subSp
;
68 maShapeTarget
.msSubShapeId
= rAttribs
.getString( XML_spid
, OUString() );
70 case PPT_TOKEN( graphicEl
):
71 return this; // needs a:dgm for the target
74 maShapeTarget
.mnType
= XML_dgm
;
75 maShapeTarget
.msSubShapeId
= rAttribs
.getString( XML_id
, OUString() );
77 case PPT_TOKEN( oleChartEl
):
81 case PPT_TOKEN( charRg
):
82 case PPT_TOKEN( pRg
):
83 if( bTargetSet
&& maShapeTarget
.mnType
== XML_txEl
)
85 maShapeTarget
.mnRangeType
= getBaseToken( aElementToken
);
86 maShapeTarget
.maRange
= drawingml::GetIndexRange( rAttribs
.getFastAttributeList() );
97 ShapeTargetElement
& maShapeTarget
;
100 TimeTargetElementContext::TimeTargetElementContext( FragmentHandler2
const & rParent
, const AnimTargetElementPtr
& pValue
)
101 : FragmentHandler2( rParent
),
104 OSL_ENSURE( mpTarget
, "no valid target passed" );
107 TimeTargetElementContext::~TimeTargetElementContext( ) throw( )
111 ::oox::core::ContextHandlerRef
TimeTargetElementContext::onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
113 switch( aElementToken
)
115 case PPT_TOKEN( inkTgt
):
117 mpTarget
->mnType
= XML_inkTgt
;
118 OUString aId
= rAttribs
.getString( XML_spid
, OUString() );
121 mpTarget
->msValue
= aId
;
125 case PPT_TOKEN( sldTgt
):
126 mpTarget
->mnType
= XML_sldTgt
;
128 case PPT_TOKEN( sndTgt
):
130 mpTarget
->mnType
= XML_sndTgt
;
132 #if HAVE_FEATURE_AVMEDIA
133 OUString srcFile
= drawingml::getEmbeddedWAVAudioFile(getRelations(), rAttribs
);
134 Reference
<css::io::XInputStream
>
135 xInputStream
= getFilter().openInputStream(srcFile
);
137 if (xInputStream
.is())
139 ::avmedia::EmbedMedia(getFilter().getModel(), srcFile
, mpTarget
->msValue
, xInputStream
);
140 xInputStream
->closeInput();
145 case PPT_TOKEN( spTgt
):
147 mpTarget
->mnType
= XML_spTgt
;
148 OUString aId
= rAttribs
.getString( XML_spid
, OUString() );
149 mpTarget
->msValue
= aId
;
150 return new ShapeTargetElementContext( *this, mpTarget
->maShapeTarget
);
155 "unhandled tag " << getBaseToken(aElementToken
)
156 << " in TL_TimeTargetElement");
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */