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 <osl/diagnose.h>
25 #include <sal/log.hxx>
27 #include <oox/helper/attributelist.hxx>
28 #include <drawingml/embeddedwavaudiofile.hxx>
29 #include <oox/token/namespaces.hxx>
30 #include <oox/token/tokens.hxx>
31 #include <oox/core/xmlfilterbase.hxx>
32 #include <com/sun/star/io/XInputStream.hpp>
33 #include <avmedia/mediaitem.hxx>
36 using namespace ::com::sun::star::uno
;
37 using namespace ::oox::core
;
43 // CT_TLShapeTargetElement
44 class ShapeTargetElementContext
45 : public FragmentHandler2
48 ShapeTargetElementContext( FragmentHandler2
const & rParent
, ShapeTargetElement
& aValue
)
49 : FragmentHandler2( rParent
)
51 , maShapeTarget(aValue
)
54 virtual ::oox::core::ContextHandlerRef
onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
) override
56 switch( aElementToken
)
60 maShapeTarget
.mnType
= XML_bg
;
62 case PPT_TOKEN( txEl
):
64 maShapeTarget
.mnType
= XML_txEl
;
66 case PPT_TOKEN( subSp
):
68 maShapeTarget
.mnType
= XML_subSp
;
69 maShapeTarget
.msSubShapeId
= rAttribs
.getStringDefaulted( XML_spid
);
71 case PPT_TOKEN( graphicEl
):
72 return this; // needs a:dgm for the target
75 maShapeTarget
.mnType
= XML_dgm
;
76 maShapeTarget
.msSubShapeId
= rAttribs
.getStringDefaulted( XML_id
);
78 case PPT_TOKEN( oleChartEl
):
82 case PPT_TOKEN( charRg
):
83 case PPT_TOKEN( pRg
):
84 if( bTargetSet
&& maShapeTarget
.mnType
== XML_txEl
)
86 maShapeTarget
.mnRangeType
= getBaseToken( aElementToken
);
87 maShapeTarget
.maRange
= drawingml::GetIndexRange( rAttribs
.getFastAttributeList() );
98 ShapeTargetElement
& maShapeTarget
;
103 TimeTargetElementContext::TimeTargetElementContext( FragmentHandler2
const & rParent
, AnimTargetElementPtr pValue
)
104 : FragmentHandler2( rParent
),
105 mpTarget(std::move( pValue
))
107 OSL_ENSURE( mpTarget
, "no valid target passed" );
110 TimeTargetElementContext::~TimeTargetElementContext( ) noexcept
114 ::oox::core::ContextHandlerRef
TimeTargetElementContext::onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
116 switch( aElementToken
)
118 case PPT_TOKEN( inkTgt
):
120 mpTarget
->mnType
= XML_inkTgt
;
121 OUString aId
= rAttribs
.getStringDefaulted( XML_spid
);
124 mpTarget
->msValue
= aId
;
128 case PPT_TOKEN( sldTgt
):
129 mpTarget
->mnType
= XML_sldTgt
;
131 case PPT_TOKEN( sndTgt
):
133 mpTarget
->mnType
= XML_sndTgt
;
135 #if HAVE_FEATURE_AVMEDIA
136 OUString srcFile
= drawingml::getEmbeddedWAVAudioFile(getRelations(), rAttribs
);
137 Reference
<css::io::XInputStream
>
138 xInputStream
= getFilter().openInputStream(srcFile
);
140 if (xInputStream
.is())
142 ::avmedia::EmbedMedia(getFilter().getModel(), srcFile
, mpTarget
->msValue
, xInputStream
);
143 xInputStream
->closeInput();
148 case PPT_TOKEN( spTgt
):
150 mpTarget
->mnType
= XML_spTgt
;
151 mpTarget
->msValue
= rAttribs
.getStringDefaulted(XML_spid
);
152 return new ShapeTargetElementContext( *this, mpTarget
->maShapeTarget
);
157 "unhandled tag " << getBaseToken(aElementToken
)
158 << " in TL_TimeTargetElement");
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */