LCOV - code coverage report
Current view: top level - oox/source/ppt - animationspersist.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 43 70 61.4 %
Date: 2014-11-03 Functions: 7 7 100.0 %
Legend: Lines: hit not hit

          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          34 :     void ShapeTargetElement::convert( ::com::sun::star::uno::Any & rTarget, sal_Int16 & rSubType ) const
      39             :     {
      40          34 :         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          34 :             break;
      77             :         }
      78          34 :     }
      79             : 
      80          34 :     Any AnimTargetElement::convert(const SlidePersistPtr & pSlide, sal_Int16 & nSubType) const
      81             :     {
      82          34 :         Any aTarget;
      83             :         // see sd/source/files/ppt/pptinanimations.cxx:3191 (in importTargetElementContainer())
      84          34 :         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          34 :             OUString sShapeName = msValue;
     100             : 
     101             :             // bnc#705982 - catch referenced diagram fallback shapes
     102          34 :             if( maShapeTarget.mnType == XML_dgm )
     103           0 :                 sShapeName = maShapeTarget.msSubShapeId;
     104             : 
     105          68 :             Any rTarget;
     106          68 :             ::oox::drawingml::ShapePtr pShape = pSlide->getShape(sShapeName);
     107             :             SAL_WARN_IF( !pShape, "oox.ppt", "failed to locate Shape");
     108          34 :             if( pShape )
     109             :             {
     110          34 :                 Reference< XShape > xShape( pShape->getXShape() );
     111             :                 SAL_WARN_IF( !xShape.is(), "oox.ppt", "fail to get XShape from shape" );
     112          34 :                 if( xShape.is() )
     113             :                 {
     114          34 :                     rTarget <<= xShape;
     115          34 :                     maShapeTarget.convert(rTarget, nSubType);
     116          34 :                     aTarget = rTarget;
     117          34 :                 }
     118             :             }
     119          68 :             break;
     120             :         }
     121             :         default:
     122           0 :             break;
     123             :         }
     124          34 :         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          82 :     static Any addToSequence( const Any& rOldValue, const Any& rNewValue )
     135             :     {
     136          82 :         if( !rNewValue.hasValue() )
     137             :         {
     138           0 :             return rOldValue;
     139             :         }
     140          82 :         else if( !rOldValue.hasValue() )
     141             :         {
     142          76 :             return rNewValue;
     143             :         }
     144             :         else
     145             :         {
     146           6 :             Sequence< Any > aNewSeq;
     147           6 :             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           6 :                 aNewSeq.realloc(2);
     156           6 :                 aNewSeq[0] = rOldValue;
     157           6 :                 aNewSeq[1] = rNewValue;
     158             :             }
     159           6 :             return makeAny( aNewSeq );
     160             :         }
     161             :     }
     162             : // END
     163             : 
     164          84 :     Any AnimationCondition::convert(const SlidePersistPtr & pSlide) const
     165             :     {
     166          84 :         Any aAny;
     167          84 :         if( mpTarget )
     168             :         {
     169             :             sal_Int16 nSubType;
     170           2 :             aAny = mpTarget->convert( pSlide, nSubType );
     171             :         }
     172             :         else
     173             :         {
     174          82 :             aAny = maValue;
     175             :         }
     176          84 :         return aAny;
     177             :     }
     178             : 
     179          76 :     Any AnimationCondition::convertList(const SlidePersistPtr & pSlide, const AnimationConditionList & l)
     180             :     {
     181          76 :         Any aAny;
     182         474 :         for( AnimationConditionList::const_iterator iter = l.begin();
     183         316 :              iter != l.end(); ++iter)
     184             :         {
     185          82 :             aAny = addToSequence( aAny, iter->convert(pSlide) );
     186             :         }
     187          76 :         return aAny;
     188             :     }
     189             : 
     190         408 : } }
     191             : 
     192             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10