Branch data 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 rtl::OUString;
32 : : using namespace ::com::sun::star::uno;
33 : : using namespace ::com::sun::star::presentation;
34 : : using namespace ::com::sun::star::drawing;
35 : : using namespace ::com::sun::star::text;
36 : :
37 : : namespace oox { namespace ppt {
38 : :
39 : 0 : void ShapeTargetElement::convert( ::com::sun::star::uno::Any & rTarget, sal_Int16 & rSubType ) const
40 : : {
41 [ # # # # ]: 0 : switch(mnType)
42 : : {
43 : : case XML_subSp:
44 : 0 : rSubType = ShapeAnimationSubType::AS_WHOLE;
45 : 0 : break;
46 : : case XML_bg:
47 : 0 : rSubType = ShapeAnimationSubType::ONLY_BACKGROUND;
48 : 0 : break;
49 : : case XML_txEl:
50 : : {
51 [ # # ]: 0 : ParagraphTarget aParaTarget;
52 : 0 : Reference< XShape > xShape;
53 [ # # ]: 0 : rTarget >>= xShape;
54 [ # # ]: 0 : aParaTarget.Shape = xShape;
55 : 0 : rSubType = ShapeAnimationSubType::ONLY_TEXT;
56 : :
57 [ # # ]: 0 : Reference< XText > xText( xShape, UNO_QUERY );
58 [ # # ]: 0 : if( xText.is() )
59 : : {
60 [ # # # ]: 0 : switch(mnRangeType)
61 : : {
62 : : case XML_charRg:
63 : : // TODO calculate the corresponding paragraph for the text range....
64 : : OSL_TRACE( "OOX: TODO calculate the corresponding paragraph for the text range..." );
65 : 0 : break;
66 : : case XML_pRg:
67 : 0 : aParaTarget.Paragraph = static_cast< sal_Int16 >( maRange.start );
68 : : // TODO what to do with more than one.
69 : : OSL_TRACE( "OOX: TODO what to do with more than one" );
70 : 0 : break;
71 : : }
72 [ # # ]: 0 : rTarget = makeAny( aParaTarget );
73 : : }
74 [ # # ]: 0 : break;
75 : : }
76 : : default:
77 : 0 : break;
78 : : }
79 : 0 : }
80 : :
81 : :
82 : 0 : Any AnimTargetElement::convert(const SlidePersistPtr & pSlide, sal_Int16 & nSubType) const
83 : : {
84 : 0 : Any aTarget;
85 : : // see sd/source/files/ppt/pptinanimations.cxx:3191 (in importTargetElementContainer())
86 [ # # # # : 0 : switch(mnType)
# ]
87 : : {
88 : : case XML_inkTgt:
89 : : // TODO
90 : : OSL_TRACE( "OOX: TODO inkTgt" );
91 : 0 : break;
92 : : case XML_sldTgt:
93 : : // TODO
94 : : OSL_TRACE( "OOX: TODO sldTgt" );
95 : 0 : break;
96 : : case XML_sndTgt:
97 [ # # ]: 0 : aTarget = makeAny(msValue);
98 : 0 : break;
99 : : case XML_spTgt:
100 : : {
101 : 0 : Any rTarget;
102 [ # # ]: 0 : ::oox::drawingml::ShapePtr pShape = pSlide->getShape(msValue);
103 : : OSL_ENSURE( pShape, "failed to locate Shape");
104 [ # # ]: 0 : if( pShape )
105 : : {
106 : 0 : Reference< XShape > xShape( pShape->getXShape() );
107 : : OSL_ENSURE( xShape.is(), "fail to get XShape from shape" );
108 [ # # ]: 0 : if( xShape.is() )
109 : : {
110 [ # # ]: 0 : rTarget <<= xShape;
111 [ # # ]: 0 : maShapeTarget.convert(rTarget, nSubType);
112 : 0 : aTarget = rTarget;
113 : 0 : }
114 : : }
115 [ # # ]: 0 : break;
116 : : }
117 : : default:
118 : 0 : break;
119 : : }
120 : 0 : return aTarget;
121 : : }
122 : :
123 : :
124 : : // BEGIN CUT&PASTE from sd/source/filter/ppt/pptinanimations.cxx
125 : : /** this adds an any to another any.
126 : : if rNewValue is empty, rOldValue is returned.
127 : : if rOldValue is empty, rNewValue is returned.
128 : : if rOldValue contains a value, a sequence with rOldValue and rNewValue is returned.
129 : : if rOldValue contains a sequence, a new sequence with the old sequence and rNewValue is returned.
130 : : */
131 : 0 : static Any addToSequence( const Any& rOldValue, const Any& rNewValue )
132 : : {
133 [ # # ]: 0 : if( !rNewValue.hasValue() )
134 : : {
135 : 0 : return rOldValue;
136 : : }
137 [ # # ]: 0 : else if( !rOldValue.hasValue() )
138 : : {
139 : 0 : return rNewValue;
140 : : }
141 : : else
142 : : {
143 [ # # ]: 0 : Sequence< Any > aNewSeq;
144 [ # # ][ # # ]: 0 : if( rOldValue >>= aNewSeq )
145 : : {
146 : 0 : sal_Int32 nSize = aNewSeq.getLength();
147 [ # # ]: 0 : aNewSeq.realloc(nSize+1);
148 [ # # ]: 0 : aNewSeq[nSize] = rNewValue;
149 : : }
150 : : else
151 : : {
152 [ # # ]: 0 : aNewSeq.realloc(2);
153 [ # # ]: 0 : aNewSeq[0] = rOldValue;
154 [ # # ]: 0 : aNewSeq[1] = rNewValue;
155 : : }
156 [ # # ][ # # ]: 0 : return makeAny( aNewSeq );
157 : : }
158 : : }
159 : : // END
160 : :
161 : 0 : Any AnimationCondition::convert(const SlidePersistPtr & pSlide) const
162 : : {
163 : 0 : Any aAny;
164 [ # # ]: 0 : if( mpTarget )
165 : : {
166 : : sal_Int16 nSubType;
167 [ # # ]: 0 : aAny = mpTarget->convert( pSlide, nSubType );
168 : : }
169 : : else
170 : : {
171 : 0 : aAny = maValue;
172 : : }
173 : 0 : return aAny;
174 : : }
175 : :
176 : :
177 : 0 : Any AnimationCondition::convertList(const SlidePersistPtr & pSlide, const AnimationConditionList & l)
178 : : {
179 : 0 : Any aAny;
180 [ # # ]: 0 : for( AnimationConditionList::const_iterator iter = l.begin();
181 : 0 : iter != l.end(); ++iter)
182 : : {
183 [ # # ][ # # ]: 0 : aAny = addToSequence( aAny, iter->convert(pSlide) );
184 : : }
185 : 0 : return aAny;
186 : : }
187 : :
188 [ + - ][ + - ]: 285 : } }
189 : :
190 : :
191 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|