LCOV - code coverage report
Current view: top level - sd/source/core - sdpage_animations.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 23 57 40.4 %
Date: 2012-08-25 Functions: 6 11 54.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 21 120 17.5 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <com/sun/star/presentation/ParagraphTarget.hpp>
      30                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      31                 :            : #include <com/sun/star/presentation/EffectNodeType.hpp>
      32                 :            : #include <comphelper/processfactory.hxx>
      33                 :            : #include <osl/mutex.hxx>
      34                 :            : #include <editeng/outliner.hxx>
      35                 :            : #include "CustomAnimationCloner.hxx"
      36                 :            : #include "drawdoc.hxx"
      37                 :            : #include "sdpage.hxx"
      38                 :            : #include <CustomAnimationPreset.hxx>
      39                 :            : #include <TransitionPreset.hxx>
      40                 :            : #include "undoanim.hxx"
      41                 :            : #include "EffectMigration.hxx"
      42                 :            : 
      43                 :            : using ::rtl::OUString;
      44                 :            : using namespace ::sd;
      45                 :            : using namespace ::com::sun::star::uno;
      46                 :            : using namespace ::com::sun::star::animations;
      47                 :            : using namespace ::com::sun::star::presentation;
      48                 :            : 
      49                 :            : using ::com::sun::star::drawing::XShape;
      50                 :            : 
      51                 :            : /** returns a helper class to manipulate effects inside the main sequence */
      52                 :         36 : sd::MainSequencePtr SdPage::getMainSequence()
      53                 :            : {
      54         [ +  + ]:         36 :     if( 0 == mpMainSequence.get() )
      55 [ +  - ][ +  - ]:          4 :         mpMainSequence.reset( new sd::MainSequence( getAnimationNode() ) );
                 [ +  - ]
      56                 :            : 
      57                 :         36 :     return mpMainSequence;
      58                 :            : }
      59                 :            : 
      60                 :            : /** returns the main animation node */
      61                 :         38 : Reference< XAnimationNode > SdPage::getAnimationNode() throw (RuntimeException)
      62                 :            : {
      63         [ +  + ]:         38 :     if( !mxAnimationNode.is() )
      64                 :            :     {
      65 [ +  - ][ +  - ]:         34 :         mxAnimationNode = Reference< XAnimationNode >::query(::comphelper::getProcessServiceFactory()->createInstance("com.sun.star.animations.ParallelTimeContainer"));
         [ +  - ][ +  - ]
      66         [ +  + ]:         34 :         if( mxAnimationNode.is() )
      67                 :            :         {
      68         [ +  - ]:          4 :             Sequence< ::com::sun::star::beans::NamedValue > aUserData( 1 );
      69         [ +  - ]:          4 :             aUserData[0].Name = "node-type";
      70 [ +  - ][ +  - ]:          4 :             aUserData[0].Value <<= ::com::sun::star::presentation::EffectNodeType::TIMING_ROOT;
      71 [ +  - ][ +  - ]:          4 :             mxAnimationNode->setUserData( aUserData );
                 [ +  - ]
      72                 :            :         }
      73                 :            :     }
      74                 :            : 
      75                 :         38 :     return mxAnimationNode;
      76                 :            : }
      77                 :            : 
      78                 :          0 : void SdPage::setAnimationNode( Reference< XAnimationNode >& xNode ) throw (RuntimeException)
      79                 :            : {
      80                 :          0 :     mxAnimationNode = xNode;
      81         [ #  # ]:          0 :     if( mpMainSequence.get() )
      82                 :          0 :         mpMainSequence->reset( xNode );
      83                 :          0 : }
      84                 :            : 
      85                 :            : /** removes all custom animations for the given shape */
      86                 :        548 : void SdPage::removeAnimations( const SdrObject* pObj )
      87                 :            : {
      88         [ -  + ]:        548 :     if( mxAnimationNode.is() )
      89                 :            :     {
      90 [ #  # ][ #  # ]:          0 :         getMainSequence();
      91                 :            : 
      92 [ #  # ][ #  # ]:          0 :         Reference< XShape > xShape( const_cast<SdrObject*>(pObj)->getUnoShape(), UNO_QUERY );
      93                 :            : 
      94 [ #  # ][ #  # ]:          0 :         if( mpMainSequence->hasEffect( xShape ) )
      95         [ #  # ]:          0 :             mpMainSequence->disposeShape( xShape );
      96                 :            :     }
      97                 :        548 : }
      98                 :            : 
      99                 :        140 : bool SdPage::hasAnimationNode() const
     100                 :            : {
     101                 :        140 :     return mxAnimationNode.is();
     102                 :            : }
     103                 :            : 
     104                 :          2 : void SdPage::SetFadeEffect(::com::sun::star::presentation::FadeEffect eNewEffect)
     105                 :            : {
     106                 :          2 :     EffectMigration::SetFadeEffect( this, eNewEffect );
     107                 :          2 : }
     108                 :            : 
     109                 :          4 : FadeEffect SdPage::GetFadeEffect() const
     110                 :            : {
     111                 :          4 :     return EffectMigration::GetFadeEffect( this );
     112                 :            : }
     113                 :            : 
     114                 :            : /** callback from the sd::View when a new paragraph for one object on this page is created */
     115                 :          0 : void SdPage::onParagraphInserted( ::Outliner* pOutliner, Paragraph* pPara, SdrObject* pObj )
     116                 :            : {
     117         [ #  # ]:          0 :     if( mxAnimationNode.is() )
     118                 :            :     {
     119         [ #  # ]:          0 :         ParagraphTarget aTarget;
     120 [ #  # ][ #  # ]:          0 :         aTarget.Shape = Reference< XShape >( pObj->getUnoShape(), UNO_QUERY );
                 [ #  # ]
     121         [ #  # ]:          0 :         aTarget.Paragraph = (sal_Int16)pOutliner->GetAbsPos( pPara );
     122                 :            : 
     123 [ #  # ][ #  # ]:          0 :         getMainSequence()->insertTextRange( makeAny( aTarget ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     124                 :            :     }
     125                 :          0 : }
     126                 :            : 
     127                 :            : /** callback from the sd::View when a paragraph from one object on this page is removed */
     128                 :          0 : void SdPage::onParagraphRemoving( ::Outliner* pOutliner, Paragraph* pPara, SdrObject* pObj )
     129                 :            : {
     130         [ #  # ]:          0 :     if( mxAnimationNode.is() )
     131                 :            :     {
     132         [ #  # ]:          0 :         ParagraphTarget aTarget;
     133 [ #  # ][ #  # ]:          0 :         aTarget.Shape = Reference< XShape >( pObj->getUnoShape(), UNO_QUERY );
                 [ #  # ]
     134         [ #  # ]:          0 :         aTarget.Paragraph = (sal_Int16)pOutliner->GetAbsPos( pPara );
     135                 :            : 
     136 [ #  # ][ #  # ]:          0 :         getMainSequence()->disposeTextRange( makeAny( aTarget ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     137                 :            :     }
     138                 :          0 : }
     139                 :            : 
     140                 :            : /** callback from the sd::View when an object just left text edit mode */
     141                 :          0 : void SdPage::onEndTextEdit( SdrObject* pObj )
     142                 :            : {
     143 [ #  # ][ #  # ]:          0 :     if( pObj && mxAnimationNode.is() )
                 [ #  # ]
     144                 :            :     {
     145 [ #  # ][ #  # ]:          0 :         Reference< XShape > xObj( pObj->getUnoShape(), UNO_QUERY );
     146 [ #  # ][ #  # ]:          0 :         getMainSequence()->onTextChanged( xObj );
                 [ #  # ]
     147                 :            :     }
     148                 :          0 : }
     149                 :            : 
     150                 :          0 : void SdPage::cloneAnimations( SdPage& rTargetPage ) const
     151                 :            : {
     152         [ #  # ]:          0 :     if( mxAnimationNode.is() )
     153                 :            :     {
     154                 :            :         Reference< XAnimationNode > xClonedNode(
     155         [ #  # ]:          0 :             ::sd::Clone( mxAnimationNode, this, &rTargetPage ) );
     156                 :            : 
     157         [ #  # ]:          0 :         if( xClonedNode.is() )
     158         [ #  # ]:          0 :             rTargetPage.setAnimationNode( xClonedNode );
     159                 :            :     }
     160                 :          0 : }
     161                 :            : 
     162                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10