Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / oox / source / ppt / timetargetelementcontext.cxx
blob07ae4fa31379678ae0e5f759d3489925558e5d82
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 "timetargetelementcontext.hxx"
22 #include <cppuhelper/exc_hlp.hxx>
23 #include <osl/diagnose.h>
25 #include <oox/helper/attributelist.hxx>
26 #include <drawingml/embeddedwavaudiofile.hxx>
27 #include <oox/token/namespaces.hxx>
28 #include <oox/token/tokens.hxx>
30 using namespace ::com::sun::star::uno;
31 using namespace ::com::sun::star::xml::sax;
32 using namespace ::oox::core;
34 namespace oox { namespace ppt {
36 // CT_TLShapeTargetElement
37 class ShapeTargetElementContext
38 : public FragmentHandler2
40 public:
41 ShapeTargetElementContext( FragmentHandler2 const & rParent, ShapeTargetElement & aValue )
42 : FragmentHandler2( rParent )
43 , bTargetSet(false)
44 , maShapeTarget(aValue)
47 virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) override
49 switch( aElementToken )
51 case PPT_TOKEN( bg ):
52 bTargetSet = true;
53 maShapeTarget.mnType = XML_bg;
54 return this;
55 case PPT_TOKEN( txEl ):
56 bTargetSet = true;
57 maShapeTarget.mnType = XML_txEl;
58 return this;
59 case PPT_TOKEN( subSp ):
60 bTargetSet = true;
61 maShapeTarget.mnType = XML_subSp;
62 maShapeTarget.msSubShapeId = rAttribs.getString( XML_spid, OUString() );
63 return this;
64 case PPT_TOKEN( graphicEl ):
65 return this; // needs a:dgm for the target
66 case A_TOKEN( dgm ):
67 bTargetSet = true;
68 maShapeTarget.mnType = XML_dgm;
69 maShapeTarget.msSubShapeId = rAttribs.getString( XML_id, OUString() );
70 return this;
71 case PPT_TOKEN( oleChartEl ):
72 bTargetSet = true;
73 // TODO
74 return this;
75 case PPT_TOKEN( charRg ):
76 case PPT_TOKEN( pRg ):
77 if( bTargetSet && maShapeTarget.mnType == XML_txEl )
79 maShapeTarget.mnRangeType = getBaseToken( aElementToken );
80 maShapeTarget.maRange = drawingml::GetIndexRange( rAttribs.getFastAttributeList() );
82 return this;
83 default:
84 break;
86 return this;
89 private:
90 bool bTargetSet;
91 ShapeTargetElement & maShapeTarget;
94 TimeTargetElementContext::TimeTargetElementContext( FragmentHandler2 const & rParent, const AnimTargetElementPtr & pValue )
95 : FragmentHandler2( rParent ),
96 mpTarget( pValue )
98 OSL_ENSURE( mpTarget, "no valid target passed" );
101 TimeTargetElementContext::~TimeTargetElementContext( ) throw( )
105 ::oox::core::ContextHandlerRef TimeTargetElementContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
107 switch( aElementToken )
109 case PPT_TOKEN( inkTgt ):
111 mpTarget->mnType = XML_inkTgt;
112 OUString aId = rAttribs.getString( XML_spid, OUString() );
113 if( !aId.isEmpty() )
115 mpTarget->msValue = aId;
117 return this;
119 case PPT_TOKEN( sldTgt ):
120 mpTarget->mnType = XML_sldTgt;
121 return this;
122 case PPT_TOKEN( sndTgt ):
124 mpTarget->mnType = XML_sndTgt;
125 mpTarget->msValue = drawingml::getEmbeddedWAVAudioFile( getRelations(), rAttribs );
126 break;
128 case PPT_TOKEN( spTgt ):
130 mpTarget->mnType = XML_spTgt;
131 OUString aId = rAttribs.getString( XML_spid, OUString() );
132 mpTarget->msValue = aId;
133 return new ShapeTargetElementContext( *this, mpTarget->maShapeTarget );
135 default:
136 SAL_INFO(
137 "oox.ppt",
138 "unhandled tag " << getBaseToken(aElementToken)
139 << " in TL_TimeTargetElement");
140 break;
143 return this;
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */