1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: animationspersist.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 #include "oox/ppt/animationspersist.hxx"
35 #include <rtl/ustring.hxx>
36 #include <com/sun/star/uno/Any.hxx>
37 #include <com/sun/star/drawing/XShape.hpp>
38 #include <com/sun/star/text/XText.hpp>
39 #include <com/sun/star/presentation/ParagraphTarget.hpp>
40 #include <com/sun/star/presentation/ShapeAnimationSubType.hpp>
42 #include "oox/drawingml/shape.hxx"
47 using namespace ::com::sun::star::uno
;
48 using namespace ::com::sun::star::presentation
;
49 using namespace ::com::sun::star::drawing
;
50 using namespace ::com::sun::star::text
;
52 namespace oox
{ namespace ppt
{
54 void ShapeTargetElement::convert( ::com::sun::star::uno::Any
& rTarget
, sal_Int16
& rSubType
) const
59 rSubType
= ShapeAnimationSubType::AS_WHOLE
;
62 rSubType
= ShapeAnimationSubType::ONLY_BACKGROUND
;
66 ParagraphTarget aParaTarget
;
67 Reference
< XShape
> xShape
;
69 aParaTarget
.Shape
= xShape
;
70 rSubType
= ShapeAnimationSubType::ONLY_TEXT
;
72 Reference
< XText
> xText( xShape
, UNO_QUERY
);
78 // TODO calculate the corresponding paragraph for the text range....
79 OSL_TRACE( "OOX: TODO calculate the corresponding paragraph for the text range..." );
82 aParaTarget
.Paragraph
= static_cast< sal_Int16
>( maRange
.start
);
83 // TODO what to do with more than one.
84 OSL_TRACE( "OOX: TODO what to do with more than one" );
87 rTarget
= makeAny( aParaTarget
);
97 Any
AnimTargetElement::convert(const SlidePersistPtr
& pSlide
, sal_Int16
& nSubType
) const
100 // see sd/source/files/ppt/pptinanimations.cxx:3191 (in importTargetElementContainer())
105 OSL_TRACE( "OOX: TODO inkTgt" );
109 OSL_TRACE( "OOX: TODO sldTgt" );
112 aTarget
= makeAny(msValue
);
117 ::oox::drawingml::ShapePtr pShape
= pSlide
->getShape(msValue
);
118 OSL_ENSURE( pShape
, "failed to locate Shape");
121 Reference
< XShape
> xShape( pShape
->getXShape() );
122 OSL_ENSURE( xShape
.is(), "fail to get XShape from shape" );
126 maShapeTarget
.convert(rTarget
, nSubType
);
139 // BEGIN CUT&PASTE from sd/source/filter/ppt/pptinanimations.cxx
140 /** this adds an any to another any.
141 if rNewValue is empty, rOldValue is returned.
142 if rOldValue is empty, rNewValue is returned.
143 if rOldValue contains a value, a sequence with rOldValue and rNewValue is returned.
144 if rOldValue contains a sequence, a new sequence with the old sequence and rNewValue is returned.
146 static Any
addToSequence( const Any
& rOldValue
, const Any
& rNewValue
)
148 if( !rNewValue
.hasValue() )
152 else if( !rOldValue
.hasValue() )
158 Sequence
< Any
> aNewSeq
;
159 if( rOldValue
>>= aNewSeq
)
161 sal_Int32 nSize
= aNewSeq
.getLength();
162 aNewSeq
.realloc(nSize
+1);
163 aNewSeq
[nSize
] = rNewValue
;
168 aNewSeq
[0] = rOldValue
;
169 aNewSeq
[1] = rNewValue
;
171 return makeAny( aNewSeq
);
176 Any
AnimationCondition::convert(const SlidePersistPtr
& pSlide
) const
182 aAny
= mpTarget
->convert( pSlide
, nSubType
);
192 Any
AnimationCondition::convertList(const SlidePersistPtr
& pSlide
, const AnimationConditionList
& l
)
195 for( AnimationConditionList::const_iterator iter
= l
.begin();
196 iter
!= l
.end(); iter
++)
198 aAny
= addToSequence( aAny
, iter
->convert(pSlide
) );