1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
43 rSubType
= ShapeAnimationSubType::AS_WHOLE
;
46 rSubType
= ShapeAnimationSubType::ONLY_BACKGROUND
;
50 ParagraphTarget aParaTarget
;
51 Reference
< XShape
> xShape
;
53 aParaTarget
.Shape
= xShape
;
54 rSubType
= ShapeAnimationSubType::ONLY_TEXT
;
56 Reference
< XText
> xText( xShape
, UNO_QUERY
);
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..." );
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" );
71 rTarget
= makeAny( aParaTarget
);
81 Any
AnimTargetElement::convert(const SlidePersistPtr
& pSlide
, sal_Int16
& nSubType
) const
84 // see sd/source/files/ppt/pptinanimations.cxx:3191 (in importTargetElementContainer())
89 SAL_INFO("oox.ppt", "OOX: TODO inkTgt" );
93 SAL_INFO("oox.ppt", "OOX: TODO sldTgt" );
96 aTarget
= makeAny(msValue
);
100 OUString sShapeName
= msValue
;
102 // bnc#705982 - catch referenced diagram fallback shapes
103 if( maShapeTarget
.mnType
== XML_dgm
)
104 sShapeName
= maShapeTarget
.msSubShapeId
;
107 ::oox::drawingml::ShapePtr pShape
= pSlide
->getShape(sShapeName
);
108 SAL_WARN_IF( !pShape
, "oox.ppt", "failed to locate Shape");
111 Reference
< XShape
> xShape( pShape
->getXShape() );
112 SAL_WARN_IF( !xShape
.is(), "oox.ppt", "fail to get XShape from shape" );
116 maShapeTarget
.convert(rTarget
, nSubType
);
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() )
142 else if( !rOldValue
.hasValue() )
148 Sequence
< Any
> aNewSeq
;
149 if( rOldValue
>>= aNewSeq
)
151 sal_Int32 nSize
= aNewSeq
.getLength();
152 aNewSeq
.realloc(nSize
+1);
153 aNewSeq
[nSize
] = rNewValue
;
158 aNewSeq
[0] = rOldValue
;
159 aNewSeq
[1] = rNewValue
;
161 return makeAny( aNewSeq
);
166 Any
AnimationCondition::convert(const SlidePersistPtr
& pSlide
) const
172 aAny
= mpTarget
->convert( pSlide
, nSubType
);
182 Any
AnimationCondition::convertList(const SlidePersistPtr
& pSlide
, const AnimationConditionList
& l
)
185 for( AnimationConditionList::const_iterator iter
= l
.begin();
186 iter
!= l
.end(); ++iter
)
188 aAny
= addToSequence( aAny
, iter
->convert(pSlide
) );
196 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */