LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/oox/source/ppt - animationspersist.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 36 70 51.4 %
Date: 2013-07-09 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           8 :     void ShapeTargetElement::convert( ::com::sun::star::uno::Any & rTarget, sal_Int16 & rSubType ) const
      39             :     {
      40           8 :         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           8 :             break;
      77             :         }
      78           8 :     }
      79             : 
      80             : 
      81           8 :     Any AnimTargetElement::convert(const SlidePersistPtr & pSlide, sal_Int16 & nSubType) const
      82             :     {
      83           8 :         Any aTarget;
      84             :         // see sd/source/files/ppt/pptinanimations.cxx:3191 (in importTargetElementContainer())
      85           8 :         switch(mnType)
      86             :         {
      87             :         case XML_inkTgt:
      88             :             // TODO
      89             :             SAL_INFO("oox.ppt", "OOX: TODO inkTgt" );
      90           0 :             break;
      91             :         case XML_sldTgt:
      92             :             // TODO
      93             :             SAL_INFO("oox.ppt", "OOX: TODO sldTgt" );
      94           0 :             break;
      95             :         case XML_sndTgt:
      96           0 :             aTarget = makeAny(msValue);
      97           0 :             break;
      98             :         case XML_spTgt:
      99             :         {
     100           8 :             OUString sShapeName = msValue;
     101             : 
     102             :             // bnc#705982 - catch referenced diagram fallback shapes
     103           8 :             if( maShapeTarget.mnType == XML_dgm )
     104           0 :                 sShapeName = maShapeTarget.msSubShapeId;
     105             : 
     106          16 :             Any rTarget;
     107          16 :             ::oox::drawingml::ShapePtr pShape = pSlide->getShape(sShapeName);
     108             :             SAL_WARN_IF( !pShape, "oox.ppt", "failed to locate Shape");
     109           8 :             if( pShape )
     110             :             {
     111           8 :                 Reference< XShape > xShape( pShape->getXShape() );
     112             :                 SAL_WARN_IF( !xShape.is(), "oox.ppt", "fail to get XShape from shape" );
     113           8 :                 if( xShape.is() )
     114             :                 {
     115           8 :                     rTarget <<= xShape;
     116           8 :                     maShapeTarget.convert(rTarget, nSubType);
     117           8 :                     aTarget = rTarget;
     118           8 :                 }
     119             :             }
     120          16 :             break;
     121             :         }
     122             :         default:
     123           0 :             break;
     124             :         }
     125           8 :         return aTarget;
     126             :     }
     127             : 
     128             : 
     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.
     135             : */
     136          16 :     static Any addToSequence( const Any& rOldValue, const Any& rNewValue )
     137             :     {
     138          16 :         if( !rNewValue.hasValue() )
     139             :         {
     140           0 :             return rOldValue;
     141             :         }
     142          16 :         else if( !rOldValue.hasValue() )
     143             :         {
     144          16 :             return rNewValue;
     145             :         }
     146             :         else
     147             :         {
     148           0 :             Sequence< Any > aNewSeq;
     149           0 :             if( rOldValue >>= aNewSeq )
     150             :             {
     151           0 :                 sal_Int32 nSize = aNewSeq.getLength();
     152           0 :                 aNewSeq.realloc(nSize+1);
     153           0 :                 aNewSeq[nSize] = rNewValue;
     154             :             }
     155             :             else
     156             :             {
     157           0 :                 aNewSeq.realloc(2);
     158           0 :                 aNewSeq[0] = rOldValue;
     159           0 :                 aNewSeq[1] = rNewValue;
     160             :             }
     161           0 :             return makeAny( aNewSeq );
     162             :         }
     163             :     }
     164             : // END
     165             : 
     166          16 :     Any AnimationCondition::convert(const SlidePersistPtr & pSlide) const
     167             :     {
     168          16 :         Any aAny;
     169          16 :         if( mpTarget )
     170             :         {
     171             :             sal_Int16 nSubType;
     172           0 :             aAny = mpTarget->convert( pSlide, nSubType );
     173             :         }
     174             :         else
     175             :         {
     176          16 :             aAny = maValue;
     177             :         }
     178          16 :         return aAny;
     179             :     }
     180             : 
     181             : 
     182          16 :     Any AnimationCondition::convertList(const SlidePersistPtr & pSlide, const AnimationConditionList & l)
     183             :     {
     184          16 :         Any aAny;
     185          96 :         for( AnimationConditionList::const_iterator iter = l.begin();
     186          64 :              iter != l.end(); ++iter)
     187             :         {
     188          16 :             aAny = addToSequence( aAny, iter->convert(pSlide) );
     189             :         }
     190          16 :         return aAny;
     191             :     }
     192             : 
     193         141 : } }
     194             : 
     195             : 
     196             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10