LibreOffice Module oox (master) 1
timetargetelementcontext.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <config_features.h>
21
23
24#include <osl/diagnose.h>
25#include <sal/log.hxx>
26
29#include <oox/token/namespaces.hxx>
30#include <oox/token/tokens.hxx>
32#include <com/sun/star/io/XInputStream.hpp>
33#include <avmedia/mediaitem.hxx>
34#include <utility>
35
36using namespace ::com::sun::star::uno;
37using namespace ::com::sun::star::xml::sax;
38using namespace ::oox::core;
39
40namespace oox::ppt {
41
42 namespace {
43
44 // CT_TLShapeTargetElement
45 class ShapeTargetElementContext
46 : public FragmentHandler2
47 {
48 public:
49 ShapeTargetElementContext( FragmentHandler2 const & rParent, ShapeTargetElement & aValue )
50 : FragmentHandler2( rParent )
51 , bTargetSet(false)
52 , maShapeTarget(aValue)
53 {
54 }
55 virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) override
56 {
57 switch( aElementToken )
58 {
59 case PPT_TOKEN( bg ):
60 bTargetSet = true;
61 maShapeTarget.mnType = XML_bg;
62 return this;
63 case PPT_TOKEN( txEl ):
64 bTargetSet = true;
65 maShapeTarget.mnType = XML_txEl;
66 return this;
67 case PPT_TOKEN( subSp ):
68 bTargetSet = true;
69 maShapeTarget.mnType = XML_subSp;
70 maShapeTarget.msSubShapeId = rAttribs.getStringDefaulted( XML_spid);
71 return this;
72 case PPT_TOKEN( graphicEl ):
73 return this; // needs a:dgm for the target
74 case A_TOKEN( dgm ):
75 bTargetSet = true;
76 maShapeTarget.mnType = XML_dgm;
77 maShapeTarget.msSubShapeId = rAttribs.getStringDefaulted( XML_id);
78 return this;
79 case PPT_TOKEN( oleChartEl ):
80 bTargetSet = true;
81 // TODO
82 return this;
83 case PPT_TOKEN( charRg ):
84 case PPT_TOKEN( pRg ):
85 if( bTargetSet && maShapeTarget.mnType == XML_txEl )
86 {
87 maShapeTarget.mnRangeType = getBaseToken( aElementToken );
88 maShapeTarget.maRange = drawingml::GetIndexRange( rAttribs.getFastAttributeList() );
89 }
90 return this;
91 default:
92 break;
93 }
94 return this;
95 }
96
97 private:
99 ShapeTargetElement & maShapeTarget;
100 };
101
102 }
103
105 : FragmentHandler2( rParent ),
106 mpTarget(std::move( pValue ))
107 {
108 OSL_ENSURE( mpTarget, "no valid target passed" );
109 }
110
112 {
113 }
114
116 {
117 switch( aElementToken )
118 {
119 case PPT_TOKEN( inkTgt ):
120 {
121 mpTarget->mnType = XML_inkTgt;
122 OUString aId = rAttribs.getStringDefaulted( XML_spid);
123 if( !aId.isEmpty() )
124 {
125 mpTarget->msValue = aId;
126 }
127 return this;
128 }
129 case PPT_TOKEN( sldTgt ):
130 mpTarget->mnType = XML_sldTgt;
131 return this;
132 case PPT_TOKEN( sndTgt ):
133 {
134 mpTarget->mnType = XML_sndTgt;
135
136#if HAVE_FEATURE_AVMEDIA
137 OUString srcFile = drawingml::getEmbeddedWAVAudioFile(getRelations(), rAttribs);
138 Reference<css::io::XInputStream>
139 xInputStream = getFilter().openInputStream(srcFile);
140
141 if (xInputStream.is())
142 {
143 ::avmedia::EmbedMedia(getFilter().getModel(), srcFile, mpTarget->msValue, xInputStream);
144 xInputStream->closeInput();
145 }
146#endif
147 break;
148 }
149 case PPT_TOKEN( spTgt ):
150 {
151 mpTarget->mnType = XML_spTgt;
152 OUString aId = rAttribs.getStringDefaulted( XML_spid);
153 mpTarget->msValue = aId;
154 return new ShapeTargetElementContext( *this, mpTarget->maShapeTarget );
155 }
156 default:
157 SAL_INFO(
158 "oox.ppt",
159 "unhandled tag " << getBaseToken(aElementToken)
160 << " in TL_TimeTargetElement");
161 break;
162 }
163
164 return this;
165 }
166
167}
168
169/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Provides access to attribute values of an element.
OUString getStringDefaulted(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute, returns an empty string if attribute not present...
TimeTargetElementContext(::oox::core::FragmentHandler2 const &rParent, AnimTargetElementPtr aValue)
virtual ~TimeTargetElementContext() noexcept override
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 aElementToken, const AttributeList &rAttribs) override
#define SAL_INFO(area, stream)
if(aStr !=aBuf) UpdateName_Impl(m_xFollowLb.get()
::rtl::Reference< ContextHandler > ContextHandlerRef
IndexRange GetIndexRange(const Reference< XFastAttributeList > &xAttributes)
OUString getEmbeddedWAVAudioFile(const core::Relations &rRelations, const AttributeList &rAttribs)
std::shared_ptr< AnimTargetElement > AnimTargetElementPtr
sal_Int32 mnType
T * mpTarget
ShapeTargetElement & maShapeTarget