update emoji autocorrect entries from po-files
[LibreOffice.git] / oox / source / ppt / animationspersist.cxx
blob6b919851da1db21b9ba33e927c3a1c78f524e493
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;
80 Any AnimTargetElement::convert(const SlidePersistPtr & pSlide, sal_Int16 & nSubType) const
82 Any aTarget;
83 // see sd/source/files/ppt/pptinanimations.cxx:3191 (in importTargetElementContainer())
84 switch(mnType)
86 case XML_inkTgt:
87 // TODO
88 SAL_INFO("oox.ppt", "OOX: TODO inkTgt" );
89 break;
90 case XML_sldTgt:
91 // TODO
92 SAL_INFO("oox.ppt", "OOX: TODO sldTgt" );
93 break;
94 case XML_sndTgt:
95 aTarget = makeAny(msValue);
96 break;
97 case XML_spTgt:
99 OUString sShapeName = msValue;
101 // bnc#705982 - catch referenced diagram fallback shapes
102 if( maShapeTarget.mnType == XML_dgm )
103 sShapeName = maShapeTarget.msSubShapeId;
105 Any rTarget;
106 ::oox::drawingml::ShapePtr pShape = pSlide->getShape(sShapeName);
107 SAL_WARN_IF( !pShape, "oox.ppt", "failed to locate Shape");
108 if( pShape )
110 Reference< XShape > xShape( pShape->getXShape() );
111 SAL_WARN_IF( !xShape.is(), "oox.ppt", "fail to get XShape from shape" );
112 if( xShape.is() )
114 rTarget <<= xShape;
115 maShapeTarget.convert(rTarget, nSubType);
116 aTarget = rTarget;
119 break;
121 default:
122 break;
124 return aTarget;
127 // BEGIN CUT&PASTE from sd/source/filter/ppt/pptinanimations.cxx
128 /** this adds an any to another any.
129 if rNewValue is empty, rOldValue is returned.
130 if rOldValue is empty, rNewValue is returned.
131 if rOldValue contains a value, a sequence with rOldValue and rNewValue is returned.
132 if rOldValue contains a sequence, a new sequence with the old sequence and rNewValue is returned.
134 static Any addToSequence( const Any& rOldValue, const Any& rNewValue )
136 if( !rNewValue.hasValue() )
138 return rOldValue;
140 else if( !rOldValue.hasValue() )
142 return rNewValue;
144 else
146 Sequence< Any > aNewSeq;
147 if( rOldValue >>= aNewSeq )
149 sal_Int32 nSize = aNewSeq.getLength();
150 aNewSeq.realloc(nSize+1);
151 aNewSeq[nSize] = rNewValue;
153 else
155 aNewSeq.realloc(2);
156 aNewSeq[0] = rOldValue;
157 aNewSeq[1] = rNewValue;
159 return makeAny( aNewSeq );
162 // END
164 Any AnimationCondition::convert(const SlidePersistPtr & pSlide) const
166 Any aAny;
167 if( mpTarget )
169 sal_Int16 nSubType;
170 aAny = mpTarget->convert( pSlide, nSubType );
172 else
174 aAny = maValue;
176 return aAny;
179 Any AnimationCondition::convertList(const SlidePersistPtr & pSlide, const AnimationConditionList & l)
181 Any aAny;
182 for( AnimationConditionList::const_iterator iter = l.begin();
183 iter != l.end(); ++iter)
185 aAny = addToSequence( aAny, iter->convert(pSlide) );
187 return aAny;
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */