GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / oox / source / ppt / animationspersist.cxx
blob1405a6ecc3760288ea7c4b2c9a44e5b00020a79d
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 "oox/ppt/animationspersist.hxx"
22 #include <rtl/ustring.hxx>
23 #include <com/sun/star/uno/Any.hxx>
24 #include <com/sun/star/drawing/XShape.hpp>
25 #include <com/sun/star/text/XText.hpp>
26 #include <com/sun/star/presentation/ParagraphTarget.hpp>
27 #include <com/sun/star/presentation/ShapeAnimationSubType.hpp>
29 #include "oox/drawingml/shape.hxx"
31 using namespace ::com::sun::star::uno;
32 using namespace ::com::sun::star::presentation;
33 using namespace ::com::sun::star::drawing;
34 using namespace ::com::sun::star::text;
36 namespace oox { namespace ppt {
38 void ShapeTargetElement::convert( ::com::sun::star::uno::Any & rTarget, sal_Int16 & rSubType ) const
40 switch(mnType)
42 case XML_subSp:
43 rSubType = ShapeAnimationSubType::AS_WHOLE;
44 break;
45 case XML_bg:
46 rSubType = ShapeAnimationSubType::ONLY_BACKGROUND;
47 break;
48 case XML_txEl:
50 ParagraphTarget aParaTarget;
51 Reference< XShape > xShape;
52 rTarget >>= xShape;
53 aParaTarget.Shape = xShape;
54 rSubType = ShapeAnimationSubType::ONLY_TEXT;
56 Reference< XText > xText( xShape, UNO_QUERY );
57 if( xText.is() )
59 switch(mnRangeType)
61 case XML_charRg:
62 // TODO calculate the corresponding paragraph for the text range....
63 SAL_INFO("oox.ppt", "OOX: TODO calculate the corresponding paragraph for the text range..." );
64 break;
65 case XML_pRg:
66 aParaTarget.Paragraph = static_cast< sal_Int16 >( maRange.start );
67 // TODO what to do with more than one.
68 SAL_INFO("oox.ppt", "OOX: TODO what to do with more than one" );
69 break;
71 rTarget = makeAny( aParaTarget );
73 break;
75 default:
76 break;
81 Any AnimTargetElement::convert(const SlidePersistPtr & pSlide, sal_Int16 & nSubType) const
83 Any aTarget;
84 // see sd/source/files/ppt/pptinanimations.cxx:3191 (in importTargetElementContainer())
85 switch(mnType)
87 case XML_inkTgt:
88 // TODO
89 SAL_INFO("oox.ppt", "OOX: TODO inkTgt" );
90 break;
91 case XML_sldTgt:
92 // TODO
93 SAL_INFO("oox.ppt", "OOX: TODO sldTgt" );
94 break;
95 case XML_sndTgt:
96 aTarget = makeAny(msValue);
97 break;
98 case XML_spTgt:
100 OUString sShapeName = msValue;
102 // bnc#705982 - catch referenced diagram fallback shapes
103 if( maShapeTarget.mnType == XML_dgm )
104 sShapeName = maShapeTarget.msSubShapeId;
106 Any rTarget;
107 ::oox::drawingml::ShapePtr pShape = pSlide->getShape(sShapeName);
108 SAL_WARN_IF( !pShape, "oox.ppt", "failed to locate Shape");
109 if( pShape )
111 Reference< XShape > xShape( pShape->getXShape() );
112 SAL_WARN_IF( !xShape.is(), "oox.ppt", "fail to get XShape from shape" );
113 if( xShape.is() )
115 rTarget <<= xShape;
116 maShapeTarget.convert(rTarget, nSubType);
117 aTarget = rTarget;
120 break;
122 default:
123 break;
125 return aTarget;
129 // BEGIN CUT&PASTE from sd/source/filter/ppt/pptinanimations.cxx
130 /** this adds an any to another any.
131 if rNewValue is empty, rOldValue is returned.
132 if rOldValue is empty, rNewValue is returned.
133 if rOldValue contains a value, a sequence with rOldValue and rNewValue is returned.
134 if rOldValue contains a sequence, a new sequence with the old sequence and rNewValue is returned.
136 static Any addToSequence( const Any& rOldValue, const Any& rNewValue )
138 if( !rNewValue.hasValue() )
140 return rOldValue;
142 else if( !rOldValue.hasValue() )
144 return rNewValue;
146 else
148 Sequence< Any > aNewSeq;
149 if( rOldValue >>= aNewSeq )
151 sal_Int32 nSize = aNewSeq.getLength();
152 aNewSeq.realloc(nSize+1);
153 aNewSeq[nSize] = rNewValue;
155 else
157 aNewSeq.realloc(2);
158 aNewSeq[0] = rOldValue;
159 aNewSeq[1] = rNewValue;
161 return makeAny( aNewSeq );
164 // END
166 Any AnimationCondition::convert(const SlidePersistPtr & pSlide) const
168 Any aAny;
169 if( mpTarget )
171 sal_Int16 nSubType;
172 aAny = mpTarget->convert( pSlide, nSubType );
174 else
176 aAny = maValue;
178 return aAny;
182 Any AnimationCondition::convertList(const SlidePersistPtr & pSlide, const AnimationConditionList & l)
184 Any aAny;
185 for( AnimationConditionList::const_iterator iter = l.begin();
186 iter != l.end(); ++iter)
188 aAny = addToSequence( aAny, iter->convert(pSlide) );
190 return aAny;
196 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */