LCOV - code coverage report
Current view: top level - oox/source/ppt - animationspersist.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 70 0.0 %
Date: 2014-04-14 Functions: 0 7 0.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           0 :     void ShapeTargetElement::convert( ::com::sun::star::uno::Any & rTarget, sal_Int16 & rSubType ) const
      39             :     {
      40           0 :         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           0 :             break;
      77             :         }
      78           0 :     }
      79             : 
      80             : 
      81           0 :     Any AnimTargetElement::convert(const SlidePersistPtr & pSlide, sal_Int16 & nSubType) const
      82             :     {
      83           0 :         Any aTarget;
      84             :         // see sd/source/files/ppt/pptinanimations.cxx:3191 (in importTargetElementContainer())
      85           0 :         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           0 :             OUString sShapeName = msValue;
     101             : 
     102             :             // bnc#705982 - catch referenced diagram fallback shapes
     103           0 :             if( maShapeTarget.mnType == XML_dgm )
     104           0 :                 sShapeName = maShapeTarget.msSubShapeId;
     105             : 
     106           0 :             Any rTarget;
     107           0 :             ::oox::drawingml::ShapePtr pShape = pSlide->getShape(sShapeName);
     108             :             SAL_WARN_IF( !pShape, "oox.ppt", "failed to locate Shape");
     109           0 :             if( pShape )
     110             :             {
     111           0 :                 Reference< XShape > xShape( pShape->getXShape() );
     112             :                 SAL_WARN_IF( !xShape.is(), "oox.ppt", "fail to get XShape from shape" );
     113           0 :                 if( xShape.is() )
     114             :                 {
     115           0 :                     rTarget <<= xShape;
     116           0 :                     maShapeTarget.convert(rTarget, nSubType);
     117           0 :                     aTarget = rTarget;
     118           0 :                 }
     119             :             }
     120           0 :             break;
     121             :         }
     122             :         default:
     123           0 :             break;
     124             :         }
     125           0 :         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           0 :     static Any addToSequence( const Any& rOldValue, const Any& rNewValue )
     137             :     {
     138           0 :         if( !rNewValue.hasValue() )
     139             :         {
     140           0 :             return rOldValue;
     141             :         }
     142           0 :         else if( !rOldValue.hasValue() )
     143             :         {
     144           0 :             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           0 :     Any AnimationCondition::convert(const SlidePersistPtr & pSlide) const
     167             :     {
     168           0 :         Any aAny;
     169           0 :         if( mpTarget )
     170             :         {
     171             :             sal_Int16 nSubType;
     172           0 :             aAny = mpTarget->convert( pSlide, nSubType );
     173             :         }
     174             :         else
     175             :         {
     176           0 :             aAny = maValue;
     177             :         }
     178           0 :         return aAny;
     179             :     }
     180             : 
     181             : 
     182           0 :     Any AnimationCondition::convertList(const SlidePersistPtr & pSlide, const AnimationConditionList & l)
     183             :     {
     184           0 :         Any aAny;
     185           0 :         for( AnimationConditionList::const_iterator iter = l.begin();
     186           0 :              iter != l.end(); ++iter)
     187             :         {
     188           0 :             aAny = addToSequence( aAny, iter->convert(pSlide) );
     189             :         }
     190           0 :         return aAny;
     191             :     }
     192             : 
     193           0 : } }
     194             : 
     195             : 
     196             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10