Line data Source code
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 "oox/ppt/animationspersist.hxx"
21 :
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>
28 :
29 : #include "oox/drawingml/shape.hxx"
30 :
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;
35 :
36 : namespace oox { namespace ppt {
37 :
38 17 : void ShapeTargetElement::convert( ::com::sun::star::uno::Any & rTarget, sal_Int16 & rSubType ) const
39 : {
40 17 : switch(mnType)
41 : {
42 : case XML_subSp:
43 0 : rSubType = ShapeAnimationSubType::AS_WHOLE;
44 0 : break;
45 : case XML_bg:
46 0 : rSubType = ShapeAnimationSubType::ONLY_BACKGROUND;
47 0 : break;
48 : case XML_txEl:
49 : {
50 0 : ParagraphTarget aParaTarget;
51 0 : Reference< XShape > xShape;
52 0 : rTarget >>= xShape;
53 0 : aParaTarget.Shape = xShape;
54 0 : rSubType = ShapeAnimationSubType::ONLY_TEXT;
55 :
56 0 : Reference< XText > xText( xShape, UNO_QUERY );
57 0 : if( xText.is() )
58 : {
59 0 : switch(mnRangeType)
60 : {
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 0 : break;
65 : case XML_pRg:
66 0 : 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 0 : break;
70 : }
71 0 : rTarget = makeAny( aParaTarget );
72 : }
73 0 : break;
74 : }
75 : default:
76 17 : break;
77 : }
78 17 : }
79 :
80 17 : Any AnimTargetElement::convert(const SlidePersistPtr & pSlide, sal_Int16 & nSubType) const
81 : {
82 17 : Any aTarget;
83 : // see sd/source/files/ppt/pptinanimations.cxx:3191 (in importTargetElementContainer())
84 17 : switch(mnType)
85 : {
86 : case XML_inkTgt:
87 : // TODO
88 : SAL_INFO("oox.ppt", "OOX: TODO inkTgt" );
89 0 : break;
90 : case XML_sldTgt:
91 : // TODO
92 : SAL_INFO("oox.ppt", "OOX: TODO sldTgt" );
93 0 : break;
94 : case XML_sndTgt:
95 0 : aTarget = makeAny(msValue);
96 0 : break;
97 : case XML_spTgt:
98 : {
99 17 : OUString sShapeName = msValue;
100 :
101 : // bnc#705982 - catch referenced diagram fallback shapes
102 17 : if( maShapeTarget.mnType == XML_dgm )
103 0 : sShapeName = maShapeTarget.msSubShapeId;
104 :
105 34 : Any rTarget;
106 34 : ::oox::drawingml::ShapePtr pShape = pSlide->getShape(sShapeName);
107 : SAL_WARN_IF( !pShape, "oox.ppt", "failed to locate Shape");
108 17 : if( pShape )
109 : {
110 17 : Reference< XShape > xShape( pShape->getXShape() );
111 : SAL_WARN_IF( !xShape.is(), "oox.ppt", "fail to get XShape from shape" );
112 17 : if( xShape.is() )
113 : {
114 17 : rTarget <<= xShape;
115 17 : maShapeTarget.convert(rTarget, nSubType);
116 17 : aTarget = rTarget;
117 17 : }
118 : }
119 34 : break;
120 : }
121 : default:
122 0 : break;
123 : }
124 17 : return aTarget;
125 : }
126 :
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.
133 : */
134 41 : static Any addToSequence( const Any& rOldValue, const Any& rNewValue )
135 : {
136 41 : if( !rNewValue.hasValue() )
137 : {
138 0 : return rOldValue;
139 : }
140 41 : else if( !rOldValue.hasValue() )
141 : {
142 38 : return rNewValue;
143 : }
144 : else
145 : {
146 3 : Sequence< Any > aNewSeq;
147 3 : if( rOldValue >>= aNewSeq )
148 : {
149 0 : sal_Int32 nSize = aNewSeq.getLength();
150 0 : aNewSeq.realloc(nSize+1);
151 0 : aNewSeq[nSize] = rNewValue;
152 : }
153 : else
154 : {
155 3 : aNewSeq.realloc(2);
156 3 : aNewSeq[0] = rOldValue;
157 3 : aNewSeq[1] = rNewValue;
158 : }
159 3 : return makeAny( aNewSeq );
160 : }
161 : }
162 : // END
163 :
164 42 : Any AnimationCondition::convert(const SlidePersistPtr & pSlide) const
165 : {
166 42 : Any aAny;
167 42 : if( mpTarget )
168 : {
169 : sal_Int16 nSubType;
170 1 : aAny = mpTarget->convert( pSlide, nSubType );
171 : }
172 : else
173 : {
174 41 : aAny = maValue;
175 : }
176 42 : return aAny;
177 : }
178 :
179 38 : Any AnimationCondition::convertList(const SlidePersistPtr & pSlide, const AnimationConditionList & l)
180 : {
181 38 : Any aAny;
182 237 : for( AnimationConditionList::const_iterator iter = l.begin();
183 158 : iter != l.end(); ++iter)
184 : {
185 41 : aAny = addToSequence( aAny, iter->convert(pSlide) );
186 : }
187 38 : return aAny;
188 : }
189 :
190 246 : } }
191 :
192 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|