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

Generated by: LCOV version 1.10