LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/xmloff/source/draw - animexp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 59 162 36.4 %
Date: 2013-07-09 Functions: 10 13 76.9 %
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             : 
      21             : #include <tools/debug.hxx>
      22             : #include <com/sun/star/lang/XServiceInfo.hpp>
      23             : #include <com/sun/star/presentation/AnimationSpeed.hpp>
      24             : #include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
      25             : 
      26             : #include <sax/tools/converter.hxx>
      27             : 
      28             : #include <list>
      29             : #include <comphelper/extract.hxx>
      30             : #include <xmloff/xmltoken.hxx>
      31             : #include "xmloff/xmlnmspe.hxx"
      32             : #include <xmloff/xmluconv.hxx>
      33             : #include <xmloff/xmlexp.hxx>
      34             : #include <xmloff/xmlement.hxx>
      35             : #include <xmloff/nmspmap.hxx>
      36             : #include <xmloff/shapeexport.hxx>
      37             : #include "anim.hxx"
      38             : 
      39             : 
      40             : using namespace ::std;
      41             : using namespace ::cppu;
      42             : using namespace ::com::sun::star;
      43             : using namespace ::com::sun::star::uno;
      44             : using namespace ::com::sun::star::drawing;
      45             : using namespace ::com::sun::star::beans;
      46             : using namespace ::com::sun::star::lang;
      47             : using namespace ::com::sun::star::presentation;
      48             : using namespace ::xmloff::token;
      49             : 
      50             : 
      51             : const struct Effect
      52             : {
      53             :     XMLEffect meKind;
      54             :     XMLEffectDirection meDirection;
      55             :     sal_Int16 mnStartScale;
      56             :     sal_Bool mbIn;
      57             : }
      58             :     AnimationEffectMap[] =
      59             : {
      60             :     { EK_none, ED_none,             -1, sal_True }, // AnimationEffect_NONE
      61             :     { EK_fade, ED_from_left,        -1, sal_True }, // AnimationEffect_FADE_FROM_LEFT
      62             :     { EK_fade, ED_from_top,         -1, sal_True }, // AnimationEffect_FADE_FROM_TOP
      63             :     { EK_fade, ED_from_right,       -1, sal_True }, // AnimationEffect_FADE_FROM_RIGHT
      64             :     { EK_fade, ED_from_bottom,      -1, sal_True }, // AnimationEffect_FADE_FROM_BOTTOM
      65             :     { EK_fade, ED_to_center,        -1, sal_True }, // AnimationEffect_FADE_TO_CENTER
      66             :     { EK_fade, ED_from_center,      -1, sal_True }, // AnimationEffect_FADE_FROM_CENTER
      67             :     { EK_move, ED_from_left,        -1, sal_True }, // AnimationEffect_MOVE_FROM_LEFT
      68             :     { EK_move, ED_from_top,         -1, sal_True }, // AnimationEffect_MOVE_FROM_TOP
      69             :     { EK_move, ED_from_right,       -1, sal_True }, // AnimationEffect_MOVE_FROM_RIGHT
      70             :     { EK_move, ED_from_bottom,      -1, sal_True }, // AnimationEffect_MOVE_FROM_BOTTOM
      71             :     { EK_stripes, ED_vertical,      -1, sal_True }, // AnimationEffect_VERTICAL_STRIPES
      72             :     { EK_stripes, ED_horizontal,    -1, sal_True }, // AnimationEffect_HORIZONTAL_STRIPES
      73             :     { EK_fade, ED_clockwise,        -1, sal_True }, // AnimationEffect_CLOCKWISE
      74             :     { EK_fade, ED_cclockwise,       -1, sal_True }, // AnimationEffect_COUNTERCLOCKWISE
      75             :     { EK_fade, ED_from_upperleft,   -1, sal_True }, // AnimationEffect_FADE_FROM_UPPERLEFT
      76             :     { EK_fade, ED_from_upperright,  -1, sal_True }, // AnimationEffect_FADE_FROM_UPPERRIGHT
      77             :     { EK_fade, ED_from_lowerleft,   -1, sal_True }, // AnimationEffect_FADE_FROM_LOWERLEFT
      78             :     { EK_fade, ED_from_lowerright,  -1, sal_True }, // AnimationEffect_FADE_FROM_LOWERRIGHT
      79             :     { EK_close,ED_vertical,         -1, sal_True }, // AnimationEffect_CLOSE_VERTICAL
      80             :     { EK_close,ED_horizontal,       -1, sal_True }, // AnimationEffect_CLOSE_HORIZONTAL
      81             :     { EK_open, ED_vertical,         -1, sal_True }, // AnimationEffect_OPEN_VERTICAL
      82             :     { EK_open, ED_horizontal,       -1, sal_True }, // AnimationEffect_OPEN_HORIZONTAL
      83             :     { EK_move, ED_path,             -1, sal_True }, // AnimationEffect_PATH
      84             :     { EK_move, ED_to_left,          -1, sal_False },// AnimationEffect_MOVE_TO_LEFT
      85             :     { EK_move, ED_to_top,           -1, sal_False },// AnimationEffect_MOVE_TO_TOP
      86             :     { EK_move, ED_to_right,         -1, sal_False },// AnimationEffect_MOVE_TO_RIGHT
      87             :     { EK_move, ED_to_bottom,        -1, sal_False },// AnimationEffect_MOVE_TO_BOTTOM
      88             :     { EK_fade, ED_spiral_inward_left,   -1, sal_True }, // AnimationEffect_SPIRALIN_LEFT
      89             :     { EK_fade, ED_spiral_inward_right,  -1, sal_True }, // AnimationEffect_SPIRALIN_RIGHT
      90             :     { EK_fade, ED_spiral_outward_left,  -1, sal_True }, // AnimationEffect_SPIRALOUT_LEFT
      91             :     { EK_fade, ED_spiral_outward_right, -1, sal_True }, // AnimationEffect_SPIRALOUT_RIGHT
      92             :     { EK_dissolve, ED_none,         -1, sal_True }, // AnimationEffect_DISSOLVE
      93             :     { EK_wavyline, ED_from_left,    -1, sal_True }, // AnimationEffect_WAVYLINE_FROM_LEFT
      94             :     { EK_wavyline, ED_from_top,     -1, sal_True }, // AnimationEffect_WAVYLINE_FROM_TOP
      95             :     { EK_wavyline, ED_from_right,   -1, sal_True }, // AnimationEffect_WAVYLINE_FROM_RIGHT
      96             :     { EK_wavyline, ED_from_bottom,  -1, sal_True }, // AnimationEffect_WAVYLINE_FROM_BOTTOM
      97             :     { EK_random, ED_none,           -1, sal_True }, // AnimationEffect_RANDOM
      98             :     { EK_lines, ED_vertical,        -1, sal_True }, // AnimationEffect_VERTICAL_LINES
      99             :     { EK_lines, ED_horizontal,      -1, sal_True }, // AnimationEffect_HORIZONTAL_LINES
     100             :     { EK_laser, ED_from_left,       -1, sal_True }, // AnimationEffect_LASER_FROM_LEFT
     101             :     { EK_laser, ED_from_top,        -1, sal_True }, // AnimationEffect_LASER_FROM_TOP
     102             :     { EK_laser, ED_from_right,      -1, sal_True }, // AnimationEffect_LASER_FROM_RIGHT
     103             :     { EK_laser, ED_from_bottom,     -1, sal_True }, // AnimationEffect_LASER_FROM_BOTTOM
     104             :     { EK_laser, ED_from_upperleft,  -1, sal_True }, // AnimationEffect_LASER_FROM_UPPERLEFT
     105             :     { EK_laser, ED_from_upperright, -1, sal_True }, // AnimationEffect_LASER_FROM_UPPERRIGHT
     106             :     { EK_laser, ED_from_lowerleft,  -1, sal_True }, // AnimationEffect_LASER_FROM_LOWERLEFT
     107             :     { EK_laser, ED_from_lowerright, -1, sal_True }, // AnimationEffect_LASER_FROM_LOWERRIGHT
     108             :     { EK_appear,ED_none,            -1, sal_True }, // AnimationEffect_APPEAR
     109             :     { EK_hide,  ED_none,            -1, sal_False },// AnimationEffect_HIDE
     110             :     { EK_move,  ED_from_upperleft,  -1, sal_True }, // AnimationEffect_MOVE_FROM_UPPERLEFT
     111             :     { EK_move,  ED_from_upperright, -1, sal_True }, // AnimationEffect_MOVE_FROM_UPPERRIGHT
     112             :     { EK_move,  ED_from_lowerright, -1, sal_True }, // AnimationEffect_MOVE_FROM_LOWERRIGHT
     113             :     { EK_move,  ED_from_lowerleft,  -1, sal_True }, // AnimationEffect_MOVE_FROM_LOWERLEFT
     114             :     { EK_move,  ED_to_upperleft,    -1, sal_False },// AnimationEffect_MOVE_TO_UPPERLEFT
     115             :     { EK_move,  ED_to_upperright,   -1, sal_False },// AnimationEffect_MOVE_TO_UPPERRIGHT
     116             :     { EK_move,  ED_to_lowerright,   -1, sal_False },// AnimationEffect_MOVE_TO_LOWERRIGHT
     117             :     { EK_move,  ED_to_lowerleft,    -1, sal_False },// AnimationEffect_MOVE_TO_LOWERLEFT
     118             :     { EK_move_short, ED_from_left,  -1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_LEFT
     119             :     { EK_move_short, ED_from_upperleft, -1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_UPPERLEFT
     120             :     { EK_move_short, ED_from_top,       -1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_TOP
     121             :     { EK_move_short, ED_from_upperright,-1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_UPPERRIGHT
     122             :     { EK_move_short, ED_from_right,     -1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_RIGHT
     123             :     { EK_move_short, ED_from_lowerright,-1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_LOWERRIGHT
     124             :     { EK_move_short, ED_from_bottom,    -1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_BOTTOM
     125             :     { EK_move_short, ED_from_lowerleft, -1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_LOWERLEFT
     126             :     { EK_move_short, ED_to_left,        -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_LEFT
     127             :     { EK_move_short, ED_to_upperleft,   -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_UPPERLEFT
     128             :     { EK_move_short, ED_to_top,         -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_TOP
     129             :     { EK_move_short, ED_to_upperright,  -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_UPPERRIGHT
     130             :     { EK_move_short, ED_to_right,       -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_RIGHT
     131             :     { EK_move_short, ED_to_lowerright,  -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_LOWERRIGHT
     132             :     { EK_move_short, ED_to_bottom,      -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_BOTTOM
     133             :     { EK_move_short, ED_to_lowerleft,   -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_LOWERLEFT
     134             :     { EK_checkerboard, ED_vertical,     -1, sal_True }, // AnimationEffect_VERTICAL_CHECKERBOARD
     135             :     { EK_checkerboard, ED_horizontal,   -1, sal_True }, // AnimationEffect_HORIZONTAL_CHECKERBOARD
     136             :     { EK_rotate, ED_horizontal,     -1, sal_True }, // AnimationEffect_HORIZONTAL_ROTATE
     137             :     { EK_rotate, ED_vertical,       -1, sal_True }, // AnimationEffect_VERTICAL_ROTATE
     138             :     { EK_stretch,ED_horizontal,     -1, sal_True }, // AnimationEffect_HORIZONTAL_STRETCH
     139             :     { EK_stretch,ED_vertical,       -1, sal_True }, // AnimationEffect_VERTICAL_STRETCH
     140             :     { EK_stretch,ED_from_left,      -1, sal_True }, // AnimationEffect_STRETCH_FROM_LEFT
     141             :     { EK_stretch,ED_from_upperleft, -1, sal_True }, // AnimationEffect_STRETCH_FROM_UPPERLEFT
     142             :     { EK_stretch,ED_from_top,       -1, sal_True }, // AnimationEffect_STRETCH_FROM_TOP
     143             :     { EK_stretch,ED_from_upperright,-1, sal_True }, // AnimationEffect_STRETCH_FROM_UPPERRIGHT
     144             :     { EK_stretch,ED_from_right,     -1, sal_True }, // AnimationEffect_STRETCH_FROM_RIGHT
     145             :     { EK_stretch,ED_from_lowerright,-1, sal_True }, // AnimationEffect_STRETCH_FROM_LOWERRIGHT
     146             :     { EK_stretch,ED_from_bottom,    -1, sal_True }, // AnimationEffect_STRETCH_FROM_BOTTOM
     147             :     { EK_stretch,ED_from_lowerleft, -1, sal_True }, // AnimationEffect_STRETCH_FROM_LOWERLEFT
     148             :     { EK_move,  ED_none,             0, sal_True }, // AnimationEffect_ZOOM_IN
     149             :     { EK_move,  ED_none,            50, sal_True }, // AnimationEffect_ZOOM_IN_SMALL
     150             :     { EK_move,  ED_spiral_inward_left,   0, sal_True }, // AnimationEffect_ZOOM_IN_SPIRAL
     151             :     { EK_move,  ED_none,           400, sal_True }, // AnimationEffect_ZOOM_OUT
     152             :     { EK_move,  ED_none,           200, sal_True }, // AnimationEffect_ZOOM_OUT_SMALL
     153             :     { EK_move,  ED_spiral_inward_left, 400, sal_True }, // AnimationEffect_ZOOM_OUT_SPIRAL
     154             :     { EK_move,  ED_from_left,        0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_LEFT
     155             :     { EK_move,  ED_from_upperleft,   0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_UPPERLEFT
     156             :     { EK_move,  ED_from_top,         0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_TOP
     157             :     { EK_move,  ED_from_upperright,  0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_UPPERRIGHT
     158             :     { EK_move,  ED_from_right,       0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_RIGHT
     159             :     { EK_move,  ED_from_lowerright,  0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_LOWERRIGHT
     160             :     { EK_move,  ED_from_bottom,      0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_BOTTOM
     161             :     { EK_move,  ED_from_lowerleft,   0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_LOWERLEFT
     162             :     { EK_move,  ED_from_center,      0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_CENTER
     163             :     { EK_move,  ED_from_left,      400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_LEFT
     164             :     { EK_move,  ED_from_upperleft, 400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_UPPERLEFT
     165             :     { EK_move,  ED_from_top,       400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_TOP
     166             :     { EK_move,  ED_from_upperright,400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_UPPERRIGHT
     167             :     { EK_move,  ED_from_right,     400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_RIGHT
     168             :     { EK_move,  ED_from_lowerright,400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_LOWERRIGHT
     169             :     { EK_move,  ED_from_bottom,    400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_BOTTOM
     170             :     { EK_move,  ED_from_lowerleft, 400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_LOWERLEFT
     171             :     { EK_move,  ED_from_center,    400, sal_True }  // AnimationEffect_ZOOM_OUT_FROM_CENTER
     172             : };
     173             : 
     174           0 : void SdXMLImplSetEffect( AnimationEffect eEffect, XMLEffect& eKind, XMLEffectDirection& eDirection, sal_Int16& nStartScale, sal_Bool& bIn )
     175             : {
     176           0 :     if( eEffect < AnimationEffect_NONE || eEffect > AnimationEffect_ZOOM_OUT_FROM_CENTER )
     177             :     {
     178             :         OSL_FAIL( "unknown animation effect!" );
     179           0 :         eEffect = AnimationEffect_NONE;
     180             :     }
     181             : 
     182           0 :     const Effect& rEffect = AnimationEffectMap[eEffect];
     183           0 :     eKind = rEffect.meKind;
     184           0 :     eDirection = rEffect.meDirection;
     185           0 :     nStartScale = rEffect.mnStartScale;
     186           0 :     bIn = rEffect.mbIn;
     187           0 : }
     188             : 
     189             : enum XMLActionKind
     190             : {
     191             :     XMLE_SHOW,
     192             :     XMLE_HIDE,
     193             :     XMLE_DIM,
     194             :     XMLE_PLAY
     195             : };
     196             : 
     197           2 : struct XMLEffectHint
     198             : {
     199             :     XMLActionKind   meKind;
     200             :     sal_Bool        mbTextEffect;
     201             :     Reference<XShape> mxShape;
     202             : 
     203             :     XMLEffect       meEffect;
     204             :     XMLEffectDirection  meDirection;
     205             :     sal_Int16       mnStartScale;
     206             : 
     207             :     AnimationSpeed  meSpeed;
     208             :         sal_Int32               maDimColor;
     209             :     OUString        maSoundURL;
     210             :     sal_Bool        mbPlayFull;
     211             :     sal_Int32       mnPresId;
     212             :     sal_Int32       mnPathShapeId;
     213             : 
     214           0 :     int operator<(const XMLEffectHint& rComp) const { return mnPresId < rComp.mnPresId; }
     215             : 
     216           2 :     XMLEffectHint()
     217             :     :   meKind( XMLE_SHOW ), mbTextEffect( sal_False ),
     218             :         meEffect( EK_none ), meDirection( ED_none ), mnStartScale( -1 ),
     219             :         meSpeed( AnimationSpeed_SLOW ), maDimColor(0), mbPlayFull( sal_False ),
     220           2 :         mnPresId( 0 ), mnPathShapeId( -1 )
     221           2 :         {}
     222             : };
     223             : 
     224           2 : class AnimExpImpl
     225             : {
     226             : public:
     227             :     list<XMLEffectHint> maEffects;
     228             :     UniReference< XMLShapeExport > mxShapeExp;
     229             : 
     230             :     OUString msDimColor;
     231             :     OUString msDimHide;
     232             :     OUString msDimPrev;
     233             :     OUString msEffect;
     234             :     OUString msPlayFull;
     235             :     OUString msPresOrder;
     236             :     OUString msSound;
     237             :     OUString msSoundOn;
     238             :     OUString msSpeed;
     239             :     OUString msTextEffect;
     240             :     OUString msIsAnimation;
     241             :     OUString msAnimPath;
     242             : 
     243           2 :     AnimExpImpl()
     244             :     :   msDimColor( "DimColor" ),
     245             :         msDimHide( "DimHide" ),
     246             :         msDimPrev( "DimPrevious" ),
     247             :         msEffect( "Effect" ),
     248             :         msPlayFull( "PlayFull" ),
     249             :         msPresOrder( "PresentationOrder" ),
     250             :         msSound( "Sound" ),
     251             :         msSoundOn( "SoundOn" ),
     252             :         msSpeed( "Speed" ),
     253             :         msTextEffect( "TextEffect" ),
     254             :         msIsAnimation( "IsAnimation" ),
     255           2 :         msAnimPath( "AnimationPath" )
     256           2 :     {}
     257             : };
     258             : 
     259           2 : XMLAnimationsExporter::XMLAnimationsExporter( XMLShapeExport* pShapeExp )
     260             : {
     261           2 :     mpImpl = new AnimExpImpl;
     262           2 :     mpImpl->mxShapeExp = pShapeExp;
     263           2 : }
     264             : 
     265           6 : XMLAnimationsExporter::~XMLAnimationsExporter()
     266             : {
     267           2 :     delete mpImpl;
     268           2 :     mpImpl = NULL;
     269           4 : }
     270             : 
     271           4 : void XMLAnimationsExporter::prepare( Reference< XShape > xShape, SvXMLExport& )
     272             : {
     273             :     try
     274             :     {
     275             :         // check for presentation shape service
     276             :         {
     277           4 :             Reference< XServiceInfo > xServiceInfo( xShape, UNO_QUERY );
     278           4 :             if( !xServiceInfo.is() || !xServiceInfo->supportsService("com.sun.star.presentation.Shape") )
     279           4 :                 return;
     280             :         }
     281             : 
     282           4 :         Reference< XPropertySet > xProps( xShape, UNO_QUERY );
     283           4 :         if( xProps.is() )
     284             :         {
     285             :             AnimationEffect eEffect;
     286           4 :             xProps->getPropertyValue( mpImpl->msEffect ) >>= eEffect;
     287           4 :             if( eEffect == AnimationEffect_PATH )
     288             :             {
     289           0 :                 Reference< XShape > xPath;
     290           0 :                 xProps->getPropertyValue( mpImpl->msAnimPath ) >>= xPath;
     291             :             }
     292           4 :         }
     293             :     }
     294           0 :     catch (const Exception&)
     295             :     {
     296             :         OSL_FAIL("exception caught while collection animation information!");
     297             :     }
     298             : }
     299             : 
     300           2 : void XMLAnimationsExporter::collect( Reference< XShape > xShape, SvXMLExport& rExport )
     301             : {
     302             :     try
     303             :     {
     304             :         // check for presentation shape service
     305             :         {
     306           2 :             Reference< XServiceInfo > xServiceInfo( xShape, UNO_QUERY );
     307           2 :             if( !xServiceInfo.is() || !xServiceInfo->supportsService("com.sun.star.presentation.Shape") )
     308           2 :                 return;
     309             :         }
     310             : 
     311           2 :         Reference< XPropertySet > xProps( xShape, UNO_QUERY );
     312           2 :         if( xProps.is() )
     313             :         {
     314           2 :             const OUString aEmptyStr;
     315             : 
     316           4 :             Reference< XPropertySetInfo > xInfo( xProps->getPropertySetInfo() );
     317             :             AnimationEffect eEffect;
     318           4 :             XMLEffectHint aEffect;
     319             : 
     320           2 :             if( any2bool( xProps->getPropertyValue( mpImpl->msSoundOn ) ) )
     321             :             {
     322           0 :                 xProps->getPropertyValue( mpImpl->msSound ) >>= aEffect.maSoundURL;
     323           0 :                 xProps->getPropertyValue( mpImpl->msPlayFull ) >>= aEffect.mbPlayFull;
     324             :             }
     325             : 
     326           2 :             xProps->getPropertyValue( mpImpl->msPresOrder ) >>= aEffect.mnPresId;
     327           2 :             xProps->getPropertyValue( mpImpl->msSpeed ) >>= aEffect.meSpeed;
     328             : 
     329             : 
     330           2 :             sal_Bool bIsAnimation = false;
     331           2 :             xProps->getPropertyValue( mpImpl->msIsAnimation ) >>= bIsAnimation;
     332           2 :             if( bIsAnimation )
     333             :             {
     334           0 :                 aEffect.meKind = XMLE_PLAY;
     335             : 
     336           0 :                 if( !aEffect.mxShape.is() )
     337             :                 {
     338           0 :                     rExport.getInterfaceToIdentifierMapper().registerReference( xShape );
     339           0 :                     aEffect.mxShape = xShape;
     340             :                 }
     341             : 
     342           0 :                 mpImpl->maEffects.push_back( aEffect );
     343             :             }
     344             : 
     345             :             {
     346             : 
     347           2 :                 xProps->getPropertyValue( mpImpl->msEffect ) >>= eEffect;
     348           2 :                 if( eEffect != AnimationEffect_NONE )
     349             :                 {
     350           0 :                     sal_Bool bIn = sal_True;
     351           0 :                     SdXMLImplSetEffect( eEffect, aEffect.meEffect, aEffect.meDirection, aEffect.mnStartScale, bIn );
     352             : 
     353           0 :                     aEffect.meKind = bIn ? XMLE_SHOW : XMLE_HIDE;
     354             : 
     355           0 :                     if( !aEffect.mxShape.is() )
     356             :                     {
     357           0 :                         rExport.getInterfaceToIdentifierMapper().registerReference( xShape );
     358           0 :                         aEffect.mxShape = xShape;
     359             :                     }
     360             : 
     361           0 :                     if( eEffect == AnimationEffect_PATH )
     362             :                     {
     363           0 :                         Reference< XShape > xPath;
     364           0 :                         xProps->getPropertyValue( mpImpl->msAnimPath ) >>= xPath;
     365           0 :                         if( xPath.is() )
     366             :                         {
     367             : // strip                    mpImpl->mxShapeExp->createShapeId( xPath );
     368             : // strip                    aEffect.mnPathShapeId = mpImpl->mxShapeExp->getShapeId( xPath );
     369           0 :                         }
     370             :                     }
     371           0 :                     mpImpl->maEffects.push_back( aEffect );
     372             : 
     373           0 :                     aEffect.mnPathShapeId = -1;
     374           0 :                     aEffect.maSoundURL = aEmptyStr;
     375             :                 }
     376             : 
     377           2 :                 xProps->getPropertyValue( mpImpl->msTextEffect ) >>= eEffect;
     378           2 :                 if( eEffect != AnimationEffect_NONE )
     379             :                 {
     380           0 :                     sal_Bool bIn = sal_True;
     381           0 :                     SdXMLImplSetEffect( eEffect, aEffect.meEffect, aEffect.meDirection, aEffect.mnStartScale, bIn );
     382           0 :                     aEffect.meKind = bIn ? XMLE_SHOW : XMLE_HIDE;
     383           0 :                     aEffect.mbTextEffect = sal_True;
     384             : 
     385           0 :                     if( !aEffect.mxShape.is() )
     386             :                     {
     387           0 :                         rExport.getInterfaceToIdentifierMapper().registerReference( xShape );
     388           0 :                         aEffect.mxShape = xShape;
     389             :                     }
     390             : 
     391           0 :                     mpImpl->maEffects.push_back( aEffect );
     392           0 :                     aEffect.mbTextEffect = sal_False;
     393           0 :                     aEffect.maSoundURL = aEmptyStr;
     394             :                 }
     395             : 
     396           2 :                 sal_Bool bDimPrev = false;
     397           2 :                 sal_Bool bDimHide = false;
     398           2 :                 xProps->getPropertyValue( mpImpl->msDimPrev ) >>= bDimPrev;
     399           2 :                 xProps->getPropertyValue( mpImpl->msDimHide ) >>= bDimHide;
     400           2 :                 if( bDimPrev || bDimHide )
     401             :                 {
     402           0 :                     aEffect.meKind = bDimPrev ? XMLE_DIM : XMLE_HIDE;
     403           0 :                     aEffect.meEffect = EK_none;
     404           0 :                     aEffect.meDirection = ED_none;
     405           0 :                     aEffect.meSpeed = AnimationSpeed_MEDIUM;
     406           0 :                     if( bDimPrev )
     407             :                     {
     408           0 :                         xProps->getPropertyValue( mpImpl->msDimColor )
     409           0 :                             >>= aEffect.maDimColor;
     410             :                     }
     411             : 
     412           0 :                     if( !aEffect.mxShape.is() )
     413             :                     {
     414           0 :                         rExport.getInterfaceToIdentifierMapper().registerReference( xShape );
     415           0 :                         aEffect.mxShape = xShape;
     416             :                     }
     417             : 
     418           0 :                     mpImpl->maEffects.push_back( aEffect );
     419           0 :                     aEffect.maSoundURL = aEmptyStr;
     420             :                 }
     421           2 :             }
     422           2 :         }
     423             :     }
     424           0 :     catch (const Exception&)
     425             :     {
     426             :         OSL_FAIL("exception caught while collection animation information!");
     427             :     }
     428             : }
     429             : 
     430           1 : void XMLAnimationsExporter::exportAnimations( SvXMLExport& rExport )
     431             : {
     432           1 :     mpImpl->maEffects.sort();
     433             : 
     434           1 :     list<XMLEffectHint>::iterator aIter = mpImpl->maEffects.begin();
     435           1 :     const list<XMLEffectHint>::iterator aEnd = mpImpl->maEffects.end();
     436             : 
     437           1 :     OUStringBuffer sTmp;
     438             : 
     439           1 :     if( aIter != aEnd )
     440             :     {
     441           0 :         SvXMLElementExport aElement( rExport, XML_NAMESPACE_PRESENTATION, XML_ANIMATIONS, sal_True, sal_True );
     442             : 
     443           0 :         do
     444             :         {
     445           0 :             XMLEffectHint& rEffect = *aIter;
     446             : 
     447             :             DBG_ASSERT( rEffect.mxShape.is(), "shape id creation failed for animation effect?" );
     448             : 
     449           0 :             rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_SHAPE_ID, rExport.getInterfaceToIdentifierMapper().getIdentifier( rEffect.mxShape ) );
     450             : 
     451           0 :             if( rEffect.meKind == XMLE_DIM )
     452             :             {
     453             :                 // export a dim action;
     454             : 
     455           0 :                 ::sax::Converter::convertColor( sTmp, rEffect.maDimColor );
     456           0 :                 rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_COLOR, sTmp.makeStringAndClear() );
     457             : 
     458           0 :                 SvXMLElementExport aElem( rExport, XML_NAMESPACE_PRESENTATION, XML_DIM, sal_True, sal_True );
     459             :             }
     460           0 :             else if( rEffect.meKind == XMLE_PLAY )
     461             :             {
     462           0 :                 if( rEffect.meSpeed != AnimationSpeed_MEDIUM )
     463             :                 {
     464           0 :                     SvXMLUnitConverter::convertEnum( sTmp, rEffect.meSpeed, aXML_AnimationSpeed_EnumMap );
     465           0 :                     rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_SPEED, sTmp.makeStringAndClear() );
     466             :                 }
     467             : 
     468           0 :                 SvXMLElementExport aElem( rExport, XML_NAMESPACE_PRESENTATION, XML_PLAY, sal_True, sal_True );
     469             :             }
     470             :             else
     471             :             {
     472             : 
     473           0 :                 if( rEffect.meEffect != EK_none )
     474             :                 {
     475           0 :                     SvXMLUnitConverter::convertEnum( sTmp, rEffect.meEffect, aXML_AnimationEffect_EnumMap );
     476           0 :                     rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_EFFECT, sTmp.makeStringAndClear() );
     477             :                 }
     478             : 
     479           0 :                 if( rEffect.meDirection != ED_none )
     480             :                 {
     481           0 :                     SvXMLUnitConverter::convertEnum( sTmp, rEffect.meDirection, aXML_AnimationDirection_EnumMap );
     482           0 :                     rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_DIRECTION, sTmp.makeStringAndClear() );
     483             :                 }
     484             : 
     485           0 :                 if( rEffect.mnStartScale != -1 )
     486             :                 {
     487           0 :                     ::sax::Converter::convertPercent(sTmp, rEffect.mnStartScale);
     488           0 :                     rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_START_SCALE, sTmp.makeStringAndClear() );
     489             :                 }
     490             : 
     491           0 :                 if( rEffect.meSpeed != AnimationSpeed_MEDIUM )
     492             :                 {
     493           0 :                     SvXMLUnitConverter::convertEnum( sTmp, rEffect.meSpeed, aXML_AnimationSpeed_EnumMap );
     494           0 :                     rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_SPEED, sTmp.makeStringAndClear() );
     495             :                 }
     496             : 
     497           0 :                 if( rEffect.mnPathShapeId != -1 )
     498             :                 {
     499           0 :                     rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PATH_ID, OUString::valueOf( rEffect.mnPathShapeId ) );
     500             :                 }
     501             : 
     502             :                 enum XMLTokenEnum eLocalName;
     503           0 :                 if( rEffect.meKind == XMLE_SHOW )
     504             :                 {
     505           0 :                     if( rEffect.mbTextEffect )
     506           0 :                         eLocalName = XML_SHOW_TEXT;
     507             :                     else
     508           0 :                         eLocalName = XML_SHOW_SHAPE;
     509             :                 }
     510             :                 else
     511             :                 {
     512           0 :                     if( rEffect.mbTextEffect )
     513           0 :                         eLocalName = XML_HIDE_TEXT;
     514             :                     else
     515           0 :                         eLocalName = XML_HIDE_SHAPE;
     516             :                 }
     517             : 
     518           0 :                 SvXMLElementExport aEle( rExport, XML_NAMESPACE_PRESENTATION, eLocalName, sal_True, sal_True );
     519           0 :                 if( !rEffect.maSoundURL.isEmpty() )
     520             :                 {
     521           0 :                     rExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, rExport.GetRelativeReference(rEffect.maSoundURL) );
     522           0 :                     rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
     523           0 :                     rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_NEW );
     524           0 :                     rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONREQUEST );
     525           0 :                     if( rEffect.mbPlayFull )
     526           0 :                         rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PLAY_FULL, XML_TRUE );
     527             : 
     528           0 :                     SvXMLElementExport aElem( rExport, XML_NAMESPACE_PRESENTATION, XML_SOUND, sal_True, sal_True );
     529           0 :                 }
     530             :             }
     531             : 
     532           0 :             ++aIter;
     533             :         }
     534           0 :         while( aIter != aEnd );
     535             :     }
     536             : 
     537           1 :     mpImpl->maEffects.clear();
     538           1 : }
     539             : 
     540             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10