Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / oox / source / ppt / timetargetelementcontext.cxx
blob43f10ee05df9f74739cb03512931016ae15714ef
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
46 public:
47 ShapeTargetElementContext( FragmentHandler2 const & rParent, ShapeTargetElement & aValue )
48 : FragmentHandler2( rParent )
49 , bTargetSet(false)
50 , maShapeTarget(aValue)
53 virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) override
55 switch( aElementToken )
57 case PPT_TOKEN( bg ):
58 bTargetSet = true;
59 maShapeTarget.mnType = XML_bg;
60 return this;
61 case PPT_TOKEN( txEl ):
62 bTargetSet = true;
63 maShapeTarget.mnType = XML_txEl;
64 return this;
65 case PPT_TOKEN( subSp ):
66 bTargetSet = true;
67 maShapeTarget.mnType = XML_subSp;
68 maShapeTarget.msSubShapeId = rAttribs.getString( XML_spid, OUString() );
69 return this;
70 case PPT_TOKEN( graphicEl ):
71 return this; // needs a:dgm for the target
72 case A_TOKEN( dgm ):
73 bTargetSet = true;
74 maShapeTarget.mnType = XML_dgm;
75 maShapeTarget.msSubShapeId = rAttribs.getString( XML_id, OUString() );
76 return this;
77 case PPT_TOKEN( oleChartEl ):
78 bTargetSet = true;
79 // TODO
80 return this;
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() );
88 return this;
89 default:
90 break;
92 return this;
95 private:
96 bool bTargetSet;
97 ShapeTargetElement & maShapeTarget;
100 TimeTargetElementContext::TimeTargetElementContext( FragmentHandler2 const & rParent, const AnimTargetElementPtr & pValue )
101 : FragmentHandler2( rParent ),
102 mpTarget( pValue )
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() );
119 if( !aId.isEmpty() )
121 mpTarget->msValue = aId;
123 return this;
125 case PPT_TOKEN( sldTgt ):
126 mpTarget->mnType = XML_sldTgt;
127 return this;
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();
142 #endif
143 break;
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 );
152 default:
153 SAL_INFO(
154 "oox.ppt",
155 "unhandled tag " << getBaseToken(aElementToken)
156 << " in TL_TimeTargetElement");
157 break;
160 return this;
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */