LCOV - code coverage report
Current view: top level - xmloff/source/draw - animimp.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 275 0.0 %
Date: 2014-04-14 Functions: 0 30 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 <xmloff/unointerfacetouniqueidentifiermapper.hxx>
      21             : #include <com/sun/star/lang/XServiceInfo.hpp>
      22             : #include <com/sun/star/presentation/AnimationEffect.hpp>
      23             : #include <com/sun/star/presentation/AnimationSpeed.hpp>
      24             : #include <com/sun/star/beans/XPropertySet.hpp>
      25             : #include <com/sun/star/xml/sax/XAttributeList.hpp>
      26             : 
      27             : #include <sax/tools/converter.hxx>
      28             : 
      29             : #include <list>
      30             : #include <xmloff/xmltoken.hxx>
      31             : #include <xmloff/xmlimp.hxx>
      32             : #include <xmloff/xmlnmspe.hxx>
      33             : #include <xmloff/xmluconv.hxx>
      34             : #include <xmloff/nmspmap.hxx>
      35             : #include "anim.hxx"
      36             : #include "animimp.hxx"
      37             : 
      38             : using namespace ::std;
      39             : using namespace ::cppu;
      40             : using namespace ::com::sun::star;
      41             : using namespace ::com::sun::star::xml;
      42             : using namespace ::com::sun::star::xml::sax;
      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             : SvXMLEnumMapEntry aXML_AnimationEffect_EnumMap[] =
      51             : {
      52             :     { XML_NONE,         EK_none },
      53             :     { XML_FADE,         EK_fade },
      54             :     { XML_MOVE,         EK_move },
      55             :     { XML_STRIPES,      EK_stripes },
      56             :     { XML_OPEN,         EK_open },
      57             :     { XML_CLOSE,        EK_close },
      58             :     { XML_DISSOLVE,     EK_dissolve },
      59             :     { XML_WAVYLINE,     EK_wavyline },
      60             :     { XML_RANDOM,       EK_random },
      61             :     { XML_LINES,        EK_lines },
      62             :     { XML_LASER,        EK_laser },
      63             :     { XML_APPEAR,       EK_appear },
      64             :     { XML_HIDE,         EK_hide },
      65             :     { XML_MOVE_SHORT,   EK_move_short },
      66             :     { XML_CHECKERBOARD, EK_checkerboard },
      67             :     { XML_ROTATE,       EK_rotate },
      68             :     { XML_STRETCH,      EK_stretch },
      69             :     { XML_TOKEN_INVALID, 0 }
      70             : };
      71             : 
      72             : SvXMLEnumMapEntry aXML_AnimationDirection_EnumMap[] =
      73             : {
      74             :     { XML_NONE,             ED_none },
      75             :     { XML_FROM_LEFT,        ED_from_left },
      76             :     { XML_FROM_TOP,         ED_from_top },
      77             :     { XML_FROM_RIGHT,       ED_from_right },
      78             :     { XML_FROM_BOTTOM,      ED_from_bottom },
      79             :     { XML_FROM_CENTER,      ED_from_center },
      80             :     { XML_FROM_UPPER_LEFT,  ED_from_upperleft },
      81             :     { XML_FROM_UPPER_RIGHT, ED_from_upperright },
      82             :     { XML_FROM_LOWER_LEFT,  ED_from_lowerleft },
      83             :     { XML_FROM_LOWER_RIGHT, ED_from_lowerright },
      84             :     { XML_TO_LEFT,          ED_to_left },
      85             :     { XML_TO_TOP,           ED_to_top },
      86             :     { XML_TO_RIGHT,         ED_to_right },
      87             :     { XML_TO_BOTTOM,        ED_to_bottom },
      88             :     { XML_TO_UPPER_LEFT,    ED_to_upperleft },
      89             :     { XML_TO_UPPER_RIGHT,   ED_to_upperright },
      90             :     { XML_TO_LOWER_RIGHT,   ED_to_lowerright },
      91             :     { XML_TO_LOWER_LEFT,    ED_to_lowerleft },
      92             :     { XML_PATH,             ED_path },
      93             :     { XML_SPIRAL_INWARD_LEFT, ED_spiral_inward_left },
      94             :     { XML_SPIRAL_INWARD_RIGHT,ED_spiral_inward_right },
      95             :     { XML_SPIRAL_OUTWARD_LEFT, ED_spiral_outward_left },
      96             :     { XML_SPIRAL_OUTWARD_RIGHT, ED_spiral_outward_right },
      97             :     { XML_VERTICAL,         ED_vertical },
      98             :     { XML_HORIZONTAL,       ED_horizontal },
      99             :     { XML_TO_CENTER,        ED_to_center },
     100             :     { XML_CLOCKWISE,        ED_clockwise },
     101             :     { XML_COUNTER_CLOCKWISE,ED_cclockwise },
     102             :     { XML_TOKEN_INVALID, 0 }
     103             : };
     104             : 
     105             : SvXMLEnumMapEntry aXML_AnimationSpeed_EnumMap[] =
     106             : {
     107             :     { XML_SLOW,     AnimationSpeed_SLOW },
     108             :     { XML_MEDIUM,   AnimationSpeed_MEDIUM },
     109             :     { XML_FAST,     AnimationSpeed_FAST },
     110             :     { XML_TOKEN_INVALID, 0 }
     111             : };
     112             : 
     113           0 : AnimationEffect ImplSdXMLgetEffect( XMLEffect eKind, XMLEffectDirection eDirection, sal_Int16 nStartScale, bool /*bIn*/ )
     114             : {
     115           0 :     switch( eKind )
     116             :     {
     117             :     case EK_fade:
     118           0 :         switch( eDirection )
     119             :         {
     120           0 :         case ED_from_left:          return AnimationEffect_FADE_FROM_LEFT;
     121           0 :         case ED_from_top:           return AnimationEffect_FADE_FROM_TOP;
     122           0 :         case ED_from_right:         return AnimationEffect_FADE_FROM_RIGHT;
     123           0 :         case ED_from_bottom:        return AnimationEffect_FADE_FROM_BOTTOM;
     124           0 :         case ED_from_center:        return AnimationEffect_FADE_FROM_CENTER;
     125           0 :         case ED_from_upperleft:     return AnimationEffect_FADE_FROM_UPPERLEFT;
     126           0 :         case ED_from_upperright:    return AnimationEffect_FADE_FROM_UPPERRIGHT;
     127           0 :         case ED_from_lowerleft:     return AnimationEffect_FADE_FROM_LOWERLEFT;
     128           0 :         case ED_from_lowerright:    return AnimationEffect_FADE_FROM_LOWERRIGHT;
     129           0 :         case ED_to_center:          return AnimationEffect_FADE_TO_CENTER;
     130           0 :         case ED_clockwise:          return AnimationEffect_CLOCKWISE;
     131           0 :         case ED_cclockwise:         return AnimationEffect_COUNTERCLOCKWISE;
     132           0 :         case ED_spiral_inward_left: return AnimationEffect_SPIRALIN_LEFT;
     133           0 :         case ED_spiral_inward_right:return AnimationEffect_SPIRALIN_RIGHT;
     134           0 :         case ED_spiral_outward_left:return AnimationEffect_SPIRALOUT_LEFT;
     135           0 :         case ED_spiral_outward_right:return AnimationEffect_SPIRALOUT_RIGHT;
     136           0 :         default:                    return AnimationEffect_FADE_FROM_LEFT;
     137             :         }
     138             :     case EK_move:
     139           0 :         if( nStartScale == 200 )
     140             :         {
     141           0 :             return AnimationEffect_ZOOM_OUT_SMALL;
     142             :         }
     143           0 :         else if( nStartScale == 50 )
     144             :         {
     145           0 :             return AnimationEffect_ZOOM_IN_SMALL;
     146             :         }
     147           0 :         else if( nStartScale < 100 )
     148             :         {
     149           0 :             switch( eDirection )
     150             :             {
     151           0 :             case ED_from_left:          return AnimationEffect_ZOOM_IN_FROM_LEFT;
     152           0 :             case ED_from_top:           return AnimationEffect_ZOOM_IN_FROM_TOP;
     153           0 :             case ED_from_right:         return AnimationEffect_ZOOM_IN_FROM_RIGHT;
     154           0 :             case ED_from_bottom:        return AnimationEffect_ZOOM_IN_FROM_BOTTOM;
     155           0 :             case ED_from_upperleft:     return AnimationEffect_ZOOM_IN_FROM_UPPERLEFT;
     156           0 :             case ED_from_upperright:    return AnimationEffect_ZOOM_IN_FROM_UPPERRIGHT;
     157           0 :             case ED_from_lowerleft:     return AnimationEffect_ZOOM_IN_FROM_LOWERLEFT;
     158           0 :             case ED_from_lowerright:    return AnimationEffect_ZOOM_IN_FROM_LOWERRIGHT;
     159           0 :             case ED_from_center:        return AnimationEffect_ZOOM_IN_FROM_CENTER;
     160           0 :             case ED_spiral_inward_left: return AnimationEffect_ZOOM_IN_SPIRAL;
     161           0 :             case ED_to_left:            return AnimationEffect_MOVE_TO_LEFT;
     162           0 :             case ED_to_top:             return AnimationEffect_MOVE_TO_TOP;
     163           0 :             case ED_to_right:           return AnimationEffect_MOVE_TO_RIGHT;
     164           0 :             case ED_to_bottom:          return AnimationEffect_MOVE_TO_BOTTOM;
     165           0 :             case ED_to_upperleft:       return AnimationEffect_MOVE_TO_UPPERLEFT;
     166           0 :             case ED_to_upperright:      return AnimationEffect_MOVE_TO_UPPERRIGHT;
     167           0 :             case ED_to_lowerright:      return AnimationEffect_MOVE_TO_LOWERRIGHT;
     168           0 :             case ED_to_lowerleft:       return AnimationEffect_MOVE_TO_LOWERLEFT;
     169           0 :             default:                    return AnimationEffect_ZOOM_IN;
     170             :             }
     171             :         }
     172           0 :         else if( nStartScale > 100 )
     173             :         {
     174           0 :             switch( eDirection )
     175             :             {
     176           0 :             case ED_from_left:          return AnimationEffect_ZOOM_OUT_FROM_LEFT;
     177           0 :             case ED_from_top:           return AnimationEffect_ZOOM_OUT_FROM_TOP;
     178           0 :             case ED_from_right:         return AnimationEffect_ZOOM_OUT_FROM_RIGHT;
     179           0 :             case ED_from_bottom:        return AnimationEffect_ZOOM_OUT_FROM_BOTTOM;
     180           0 :             case ED_from_upperleft:     return AnimationEffect_ZOOM_OUT_FROM_UPPERLEFT;
     181           0 :             case ED_from_upperright:    return AnimationEffect_ZOOM_OUT_FROM_UPPERRIGHT;
     182           0 :             case ED_from_lowerleft:     return AnimationEffect_ZOOM_OUT_FROM_LOWERLEFT;
     183           0 :             case ED_from_lowerright:    return AnimationEffect_ZOOM_OUT_FROM_LOWERRIGHT;
     184           0 :             case ED_from_center:        return AnimationEffect_ZOOM_OUT_FROM_CENTER;
     185           0 :             case ED_spiral_inward_left: return AnimationEffect_ZOOM_OUT_SPIRAL;
     186           0 :             default:                    return AnimationEffect_ZOOM_OUT;
     187             :             }
     188             :         }
     189             :         else
     190             :         {
     191           0 :             switch( eDirection )
     192             :             {
     193           0 :             case ED_from_left:          return AnimationEffect_MOVE_FROM_LEFT;
     194           0 :             case ED_from_top:           return AnimationEffect_MOVE_FROM_TOP;
     195           0 :             case ED_from_right:         return AnimationEffect_MOVE_FROM_RIGHT;
     196           0 :             case ED_from_bottom:        return AnimationEffect_MOVE_FROM_BOTTOM;
     197           0 :             case ED_from_upperleft:     return AnimationEffect_MOVE_FROM_UPPERLEFT;
     198           0 :             case ED_from_upperright:    return AnimationEffect_MOVE_FROM_UPPERRIGHT;
     199           0 :             case ED_from_lowerleft:     return AnimationEffect_MOVE_FROM_LOWERLEFT;
     200           0 :             case ED_from_lowerright:    return AnimationEffect_MOVE_FROM_LOWERRIGHT;
     201           0 :             case ED_path:               return AnimationEffect_PATH;
     202           0 :             case ED_to_top:             return AnimationEffect_MOVE_TO_TOP;
     203           0 :             case ED_to_right:           return AnimationEffect_MOVE_TO_RIGHT;
     204           0 :             case ED_to_bottom:          return AnimationEffect_MOVE_TO_BOTTOM;
     205           0 :             case ED_to_upperleft:       return AnimationEffect_MOVE_TO_UPPERLEFT;
     206           0 :             case ED_to_upperright:      return AnimationEffect_MOVE_TO_UPPERRIGHT;
     207           0 :             case ED_to_lowerright:      return AnimationEffect_MOVE_TO_LOWERRIGHT;
     208           0 :             case ED_to_lowerleft:       return AnimationEffect_MOVE_TO_LOWERLEFT;
     209             :             default:
     210           0 :                 break;
     211             :             }
     212             :         }
     213           0 :         return AnimationEffect_MOVE_FROM_LEFT;
     214             :     case EK_stripes:
     215           0 :         if( eDirection == ED_vertical )
     216           0 :             return AnimationEffect_VERTICAL_STRIPES;
     217             :         else
     218           0 :             return AnimationEffect_HORIZONTAL_STRIPES;
     219             :     case EK_open:
     220           0 :         if( eDirection == ED_vertical )
     221           0 :             return AnimationEffect_OPEN_VERTICAL;
     222             :         else
     223           0 :             return AnimationEffect_OPEN_HORIZONTAL;
     224             :     case EK_close:
     225           0 :         if( eDirection == ED_vertical )
     226           0 :             return AnimationEffect_CLOSE_VERTICAL;
     227             :         else
     228           0 :             return AnimationEffect_CLOSE_HORIZONTAL;
     229             :     case EK_dissolve:
     230           0 :         return AnimationEffect_DISSOLVE;
     231             :     case EK_wavyline:
     232           0 :         switch( eDirection )
     233             :         {
     234           0 :         case ED_from_left:          return AnimationEffect_WAVYLINE_FROM_LEFT;
     235           0 :         case ED_from_top:           return AnimationEffect_WAVYLINE_FROM_TOP;
     236           0 :         case ED_from_right:         return AnimationEffect_WAVYLINE_FROM_RIGHT;
     237           0 :         case ED_from_bottom:        return AnimationEffect_WAVYLINE_FROM_BOTTOM;
     238           0 :         default:                    return AnimationEffect_WAVYLINE_FROM_LEFT;
     239             :         }
     240             :     case EK_random:
     241           0 :         return AnimationEffect_RANDOM;
     242             :     case EK_lines:
     243           0 :         if( eDirection == ED_vertical )
     244           0 :             return AnimationEffect_VERTICAL_LINES;
     245             :         else
     246           0 :             return AnimationEffect_HORIZONTAL_LINES;
     247             :     case EK_laser:
     248           0 :         switch( eDirection )
     249             :         {
     250           0 :         case ED_from_left:          return AnimationEffect_LASER_FROM_LEFT;
     251           0 :         case ED_from_top:           return AnimationEffect_LASER_FROM_TOP;
     252           0 :         case ED_from_right:         return AnimationEffect_LASER_FROM_RIGHT;
     253           0 :         case ED_from_bottom:        return AnimationEffect_LASER_FROM_BOTTOM;
     254           0 :         case ED_from_upperleft:     return AnimationEffect_LASER_FROM_UPPERLEFT;
     255           0 :         case ED_from_upperright:    return AnimationEffect_LASER_FROM_UPPERRIGHT;
     256           0 :         case ED_from_lowerleft:     return AnimationEffect_LASER_FROM_LOWERLEFT;
     257           0 :         case ED_from_lowerright:    return AnimationEffect_LASER_FROM_LOWERRIGHT;
     258           0 :         default:                    return AnimationEffect_LASER_FROM_LEFT;
     259             :         }
     260             :     case EK_appear:
     261           0 :         return AnimationEffect_APPEAR;
     262             :     case EK_hide:
     263           0 :         return AnimationEffect_HIDE;
     264             :     case EK_move_short:
     265           0 :         switch( eDirection )
     266             :         {
     267           0 :         case ED_from_left:          return AnimationEffect_MOVE_SHORT_FROM_LEFT;
     268           0 :         case ED_from_top:           return AnimationEffect_MOVE_SHORT_FROM_TOP;
     269           0 :         case ED_from_right:         return AnimationEffect_MOVE_SHORT_FROM_RIGHT;
     270           0 :         case ED_from_bottom:        return AnimationEffect_MOVE_SHORT_FROM_BOTTOM;
     271           0 :         case ED_from_upperleft:     return AnimationEffect_MOVE_SHORT_FROM_UPPERLEFT;
     272           0 :         case ED_from_upperright:    return AnimationEffect_MOVE_SHORT_FROM_UPPERRIGHT;
     273           0 :         case ED_from_lowerleft:     return AnimationEffect_MOVE_SHORT_FROM_LOWERLEFT;
     274           0 :         case ED_from_lowerright:    return AnimationEffect_MOVE_SHORT_FROM_LOWERRIGHT;
     275           0 :         case ED_to_left:            return AnimationEffect_MOVE_SHORT_TO_LEFT;
     276           0 :         case ED_to_upperleft:       return AnimationEffect_MOVE_SHORT_TO_UPPERLEFT;
     277           0 :         case ED_to_top:             return AnimationEffect_MOVE_SHORT_TO_TOP;
     278           0 :         case ED_to_upperright:      return AnimationEffect_MOVE_SHORT_TO_UPPERRIGHT;
     279           0 :         case ED_to_right:           return AnimationEffect_MOVE_SHORT_TO_RIGHT;
     280           0 :         case ED_to_lowerright:      return AnimationEffect_MOVE_SHORT_TO_LOWERRIGHT;
     281           0 :         case ED_to_bottom:          return AnimationEffect_MOVE_SHORT_TO_BOTTOM;
     282           0 :         case ED_to_lowerleft:       return AnimationEffect_MOVE_SHORT_TO_LOWERLEFT;
     283           0 :         default:                    return AnimationEffect_MOVE_SHORT_FROM_LEFT;
     284             :         }
     285             :     case EK_checkerboard:
     286           0 :         if( eDirection == ED_vertical )
     287           0 :             return AnimationEffect_VERTICAL_CHECKERBOARD;
     288             :         else
     289           0 :             return AnimationEffect_HORIZONTAL_CHECKERBOARD;
     290             :     case EK_rotate:
     291           0 :         if( eDirection == ED_vertical )
     292           0 :             return AnimationEffect_VERTICAL_ROTATE;
     293             :         else
     294           0 :             return AnimationEffect_HORIZONTAL_ROTATE;
     295             :     case EK_stretch:
     296           0 :         switch( eDirection )
     297             :         {
     298           0 :         case ED_from_left:          return AnimationEffect_STRETCH_FROM_LEFT;
     299           0 :         case ED_from_top:           return AnimationEffect_STRETCH_FROM_TOP;
     300           0 :         case ED_from_right:         return AnimationEffect_STRETCH_FROM_RIGHT;
     301           0 :         case ED_from_bottom:        return AnimationEffect_STRETCH_FROM_BOTTOM;
     302           0 :         case ED_from_upperleft:     return AnimationEffect_STRETCH_FROM_UPPERLEFT;
     303           0 :         case ED_from_upperright:    return AnimationEffect_STRETCH_FROM_UPPERRIGHT;
     304           0 :         case ED_from_lowerleft:     return AnimationEffect_STRETCH_FROM_LOWERLEFT;
     305           0 :         case ED_from_lowerright:    return AnimationEffect_STRETCH_FROM_LOWERRIGHT;
     306           0 :         case ED_vertical:           return AnimationEffect_VERTICAL_STRETCH;
     307           0 :         case ED_horizontal:         return AnimationEffect_HORIZONTAL_STRETCH;
     308             :         default:
     309           0 :             break;
     310             :         }
     311           0 :         return AnimationEffect_STRETCH_FROM_LEFT;
     312             :     default:
     313           0 :         return AnimationEffect_NONE;
     314             :     }
     315             : }
     316             : 
     317           0 : class AnimImpImpl
     318             : {
     319             : public:
     320             :     Reference< XPropertySet > mxLastShape;
     321             :     OUString maLastShapeId;
     322             : 
     323             :     OUString msDimColor;
     324             :     OUString msDimHide;
     325             :     OUString msDimPrev;
     326             :     OUString msEffect;
     327             :     OUString msPlayFull;
     328             :     OUString msPresOrder;
     329             :     OUString msSound;
     330             :     OUString msSoundOn;
     331             :     OUString msSpeed;
     332             :     OUString msTextEffect;
     333             :     OUString msPresShapeService;
     334             :     OUString msAnimPath;
     335             :     OUString msIsAnimation;
     336             : 
     337           0 :     AnimImpImpl()
     338             :     :   msDimColor( "DimColor" ),
     339             :         msDimHide( "DimHide" ),
     340             :         msDimPrev( "DimPrevious" ),
     341             :         msEffect( "Effect" ),
     342             :         msPlayFull( "PlayFull" ),
     343             :         msPresOrder( "PresentationOrder" ),
     344             :         msSound( "Sound" ),
     345             :         msSoundOn( "SoundOn" ),
     346             :         msSpeed( "Speed" ),
     347             :         msTextEffect( "TextEffect" ),
     348             :         msPresShapeService( "com.sun.star.presentation.Shape" ),
     349             :         msAnimPath( "AnimationPath" ),
     350           0 :         msIsAnimation( "IsAnimation" )
     351           0 :     {}
     352             : };
     353             : 
     354             : enum XMLActionKind
     355             : {
     356             :     XMLE_SHOW,
     357             :     XMLE_HIDE,
     358             :     XMLE_DIM,
     359             :     XMLE_PLAY
     360             : };
     361             : 
     362             : class XMLAnimationsEffectContext : public SvXMLImportContext
     363             : {
     364             : public:
     365             :     AnimImpImpl*    mpImpl;
     366             : 
     367             :     XMLActionKind   meKind;
     368             :     sal_Bool        mbTextEffect;
     369             :     OUString        maShapeId;
     370             : 
     371             :     XMLEffect       meEffect;
     372             :     XMLEffectDirection  meDirection;
     373             :     sal_Int16       mnStartScale;
     374             : 
     375             :     AnimationSpeed  meSpeed;
     376             :     sal_Int32       maDimColor;
     377             :     OUString        maSoundURL;
     378             :     sal_Bool        mbPlayFull;
     379             :     OUString        maPathShapeId;
     380             : 
     381             : public:
     382             :     TYPEINFO_OVERRIDE();
     383             : 
     384             :     XMLAnimationsEffectContext( SvXMLImport& rImport,
     385             :         sal_uInt16 nPrfx,
     386             :         const OUString& rLocalName,
     387             :         const Reference< XAttributeList >& xAttrList,
     388             :         AnimImpImpl* pImpl);
     389             :     virtual ~XMLAnimationsEffectContext();
     390             : 
     391             :     virtual void EndElement() SAL_OVERRIDE;
     392             : 
     393             :     virtual SvXMLImportContext * CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName,
     394             :         const Reference< XAttributeList >& xAttrList ) SAL_OVERRIDE;
     395             : };
     396             : 
     397             : class XMLAnimationsSoundContext : public SvXMLImportContext
     398             : {
     399             :     XMLAnimationsEffectContext* mpParent;
     400             : 
     401             : public:
     402             :     TYPEINFO_OVERRIDE();
     403             : 
     404             :     XMLAnimationsSoundContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList, XMLAnimationsEffectContext* pParent );
     405             :     virtual ~XMLAnimationsSoundContext();
     406             : };
     407             : 
     408           0 : TYPEINIT1( XMLAnimationsSoundContext, SvXMLImportContext );
     409             : 
     410           0 : XMLAnimationsSoundContext::XMLAnimationsSoundContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList, XMLAnimationsEffectContext* pParent )
     411           0 : : SvXMLImportContext( rImport, nPrfx, rLocalName ), mpParent( pParent )
     412             : {
     413           0 :     if( mpParent && nPrfx == XML_NAMESPACE_PRESENTATION && IsXMLToken( rLocalName, XML_SOUND ) )
     414             :     {
     415           0 :         const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     416           0 :         for(sal_Int16 i=0; i < nAttrCount; i++)
     417             :         {
     418           0 :             OUString sAttrName = xAttrList->getNameByIndex( i );
     419           0 :             OUString aLocalName;
     420           0 :             sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
     421           0 :             OUString sValue = xAttrList->getValueByIndex( i );
     422             : 
     423           0 :             switch( nPrefix )
     424             :             {
     425             :             case XML_NAMESPACE_XLINK:
     426           0 :                 if( IsXMLToken( aLocalName, XML_HREF ) )
     427             :                 {
     428           0 :                     mpParent->maSoundURL = rImport.GetAbsoluteReference(sValue);
     429             :                 }
     430           0 :                 break;
     431             :             case XML_NAMESPACE_PRESENTATION:
     432           0 :                 if( IsXMLToken( aLocalName, XML_PLAY_FULL ) )
     433             :                 {
     434           0 :                     mpParent->mbPlayFull = IsXMLToken( sValue, XML_TRUE );
     435             :                 }
     436             :             }
     437           0 :         }
     438             :     }
     439           0 : }
     440             : 
     441           0 : XMLAnimationsSoundContext::~XMLAnimationsSoundContext()
     442             : {
     443           0 : }
     444             : 
     445           0 : TYPEINIT1( XMLAnimationsEffectContext, SvXMLImportContext );
     446             : 
     447           0 : XMLAnimationsEffectContext::XMLAnimationsEffectContext( SvXMLImport& rImport,  sal_uInt16 nPrfx, const OUString& rLocalName,  const Reference< XAttributeList >& xAttrList, AnimImpImpl* pImpl )
     448             : :   SvXMLImportContext(rImport, nPrfx, rLocalName),
     449             :     mpImpl( pImpl ),
     450             :     meKind( XMLE_SHOW ), mbTextEffect( sal_False ),
     451             :     meEffect( EK_none ), meDirection( ED_none ), mnStartScale( 100 ),
     452           0 :     meSpeed( AnimationSpeed_MEDIUM ), maDimColor(0), mbPlayFull( sal_False )
     453             : {
     454           0 :     if( IsXMLToken( rLocalName, XML_SHOW_SHAPE ) )
     455             :     {
     456           0 :         meKind = XMLE_SHOW;
     457             :     }
     458           0 :     else if( IsXMLToken( rLocalName, XML_SHOW_TEXT ) )
     459             :     {
     460           0 :         meKind = XMLE_SHOW;
     461           0 :         mbTextEffect = sal_True;
     462             :     }
     463           0 :     else if( IsXMLToken( rLocalName, XML_HIDE_SHAPE ) )
     464             :     {
     465           0 :         meKind = XMLE_HIDE;
     466             :     }
     467           0 :     else if( IsXMLToken( rLocalName, XML_HIDE_TEXT ) )
     468             :     {
     469           0 :         meKind = XMLE_HIDE;
     470           0 :         mbTextEffect = sal_True;
     471             :     }
     472           0 :     else if( IsXMLToken( rLocalName, XML_DIM ) )
     473             :     {
     474           0 :         meKind = XMLE_DIM;
     475             :     }
     476           0 :     else if( IsXMLToken( rLocalName, XML_PLAY ) )
     477             :     {
     478           0 :         meKind = XMLE_PLAY;
     479             :     }
     480             :     else
     481             :     {
     482             :         // unknown action, overread
     483           0 :         return;
     484             :     }
     485             : 
     486             :     // read attributes
     487           0 :     const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     488           0 :     for(sal_Int16 i=0; i < nAttrCount; i++)
     489             :     {
     490           0 :         OUString sAttrName = xAttrList->getNameByIndex( i );
     491           0 :         OUString aLocalName;
     492           0 :         sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
     493           0 :         OUString sValue = xAttrList->getValueByIndex( i );
     494             : 
     495           0 :         switch( nPrefix )
     496             :         {
     497             :         case XML_NAMESPACE_DRAW:
     498           0 :             if( IsXMLToken( aLocalName, XML_SHAPE_ID ) )
     499             :             {
     500           0 :                 maShapeId = sValue;
     501             :             }
     502           0 :             else if( IsXMLToken( aLocalName, XML_COLOR ) )
     503             :             {
     504           0 :                 ::sax::Converter::convertColor(maDimColor, sValue);
     505             :             }
     506           0 :             break;
     507             : 
     508             :         case XML_NAMESPACE_PRESENTATION:
     509           0 :             if( IsXMLToken( aLocalName, XML_EFFECT ) )
     510             :             {
     511             :                 sal_uInt16 eEnum;
     512           0 :                 if( SvXMLUnitConverter::convertEnum( eEnum, sValue, aXML_AnimationEffect_EnumMap ) )
     513           0 :                     meEffect = (XMLEffect)eEnum;
     514             :             }
     515           0 :             else if( IsXMLToken(aLocalName, XML_DIRECTION ) )
     516             :             {
     517             :                 sal_uInt16 eEnum;
     518           0 :                 if( SvXMLUnitConverter::convertEnum( eEnum, sValue, aXML_AnimationDirection_EnumMap ) )
     519           0 :                     meDirection = (XMLEffectDirection)eEnum;
     520             :             }
     521           0 :             else if( IsXMLToken( aLocalName, XML_START_SCALE ) )
     522             :             {
     523             :                 sal_Int32 nScale;
     524           0 :                 if (::sax::Converter::convertPercent( nScale, sValue ))
     525           0 :                     mnStartScale = (sal_Int16)nScale;
     526             :             }
     527           0 :             else if( IsXMLToken( aLocalName, XML_SPEED ) )
     528             :             {
     529             :                 sal_uInt16 eEnum;
     530           0 :                 if( SvXMLUnitConverter::convertEnum( eEnum, sValue, aXML_AnimationSpeed_EnumMap ) )
     531           0 :                     meSpeed = (AnimationSpeed)eEnum;
     532             :             }
     533           0 :             else if( IsXMLToken( aLocalName, XML_PATH_ID ) )
     534             :             {
     535           0 :                 maPathShapeId = sValue;
     536             :             }
     537           0 :             break;
     538             :         }
     539           0 :     }
     540             : }
     541             : 
     542           0 : XMLAnimationsEffectContext::~XMLAnimationsEffectContext()
     543             : {
     544           0 : }
     545             : 
     546           0 : SvXMLImportContext * XMLAnimationsEffectContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList>& xAttrList )
     547             : {
     548           0 :     return new XMLAnimationsSoundContext( GetImport(), nPrefix, rLocalName, xAttrList, this );
     549             : }
     550             : 
     551           0 : void XMLAnimationsEffectContext::EndElement()
     552             : {
     553             :     // set effect on shape
     554             : 
     555             :     try
     556             :     {
     557           0 :         UniReference< XMLShapeImportHelper > xShapeImport( GetImport().GetShapeImport() );
     558           0 :         Any aAny;
     559             : 
     560           0 :         if( !maShapeId.isEmpty() )
     561             :         {
     562           0 :             Reference< XPropertySet > xSet;
     563           0 :             if( mpImpl->maLastShapeId != maShapeId )
     564             :             {
     565           0 :                 xSet = Reference< XPropertySet >::query( GetImport().getInterfaceToIdentifierMapper().getReference( maShapeId ) );
     566           0 :                 if( xSet.is() )
     567             :                 {
     568             :                     // check for presentation shape service
     569             :                     {
     570           0 :                         Reference< XServiceInfo > xServiceInfo( xSet, UNO_QUERY );
     571           0 :                         if( !xServiceInfo.is() || !xServiceInfo->supportsService( mpImpl->msPresShapeService ) )
     572           0 :                             return;
     573             :                     }
     574             : 
     575           0 :                     mpImpl->maLastShapeId = maShapeId;
     576           0 :                     mpImpl->mxLastShape = xSet;
     577             :                 }
     578             :             }
     579             :             else
     580             :             {
     581           0 :                 xSet = mpImpl->mxLastShape;
     582             :             }
     583             : 
     584           0 :             if( xSet.is() )
     585             :             {
     586           0 :                 if( meKind == XMLE_DIM )
     587             :                 {
     588           0 :                     aAny <<= (sal_Bool)sal_True;
     589           0 :                     xSet->setPropertyValue( mpImpl->msDimPrev, aAny );
     590             : 
     591           0 :                     aAny <<= maDimColor;
     592           0 :                     xSet->setPropertyValue( mpImpl->msDimColor, aAny );
     593             :                 }
     594           0 :                 else if( meKind == XMLE_PLAY )
     595             :                 {
     596           0 :                     aAny <<= (sal_Bool)sal_True;
     597           0 :                     xSet->setPropertyValue( mpImpl->msIsAnimation, aAny );
     598             : 
     599             :                     // #i42894# speed is not supported for the old group animation fallback, so no need to set it
     600             :                     // aAny <<= meSpeed;
     601             :                     // xSet->setPropertyValue( mpImpl->msSpeed, aAny );
     602             :                 }
     603             :                 else
     604             :                 {
     605           0 :                     if( meKind == XMLE_HIDE && !mbTextEffect && meEffect == EK_none )
     606             :                     {
     607           0 :                         aAny <<= true;
     608           0 :                         xSet->setPropertyValue( mpImpl->msDimHide, aAny );
     609             :                     }
     610             :                     else
     611             :                     {
     612           0 :                         const AnimationEffect eEffect = ImplSdXMLgetEffect( meEffect, meDirection, mnStartScale, meKind == XMLE_SHOW );
     613             : 
     614           0 :                         xSet->setPropertyValue( mbTextEffect ? mpImpl->msTextEffect : mpImpl->msEffect, makeAny( eEffect ) );
     615           0 :                         xSet->setPropertyValue( mpImpl->msSpeed, makeAny( meSpeed ) );
     616             : 
     617           0 :                         if( eEffect == AnimationEffect_PATH && !maPathShapeId.isEmpty() )
     618             :                         {
     619           0 :                             Reference< XShape > xPath( GetImport().getInterfaceToIdentifierMapper().getReference( maPathShapeId ), UNO_QUERY );
     620           0 :                             if( xPath.is() )
     621           0 :                                 xSet->setPropertyValue( mpImpl->msAnimPath, makeAny( xPath ) );
     622             :                         }
     623             :                     }
     624             :                 }
     625             :             }
     626           0 :             if( !maSoundURL.isEmpty() )
     627             :             {
     628           0 :                 if( xSet.is() )
     629             :                 {
     630           0 :                     aAny <<= maSoundURL;
     631           0 :                     xSet->setPropertyValue( mpImpl->msSound, aAny );
     632             : 
     633           0 :                     aAny <<= mbPlayFull;
     634           0 :                     xSet->setPropertyValue( mpImpl->msPlayFull, aAny );
     635             : 
     636           0 :                     aAny <<= true;
     637           0 :                     xSet->setPropertyValue( mpImpl->msSoundOn, aAny );
     638             :                 }
     639             :                 else
     640             :                 {
     641             :                     OSL_FAIL("XMLAnimationsEffectContext::EndElement - Sound URL without a XPropertySet!");
     642             :                 }
     643           0 :             }
     644           0 :         }
     645             :     }
     646           0 :     catch (const Exception&)
     647             :     {
     648             :         OSL_FAIL( "exception caught while importing animation information!" );
     649             :     }
     650             : }
     651             : 
     652           0 : TYPEINIT1( XMLAnimationsContext, SvXMLImportContext );
     653             : 
     654           0 : XMLAnimationsContext::XMLAnimationsContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName,
     655             :         const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& )
     656           0 : : SvXMLImportContext(rImport, nPrfx, rLocalName)
     657             : {
     658           0 :     mpImpl = new AnimImpImpl();
     659           0 : }
     660             : 
     661           0 : XMLAnimationsContext::~XMLAnimationsContext()
     662             : {
     663           0 :     delete mpImpl;
     664           0 : }
     665             : 
     666           0 : SvXMLImportContext * XMLAnimationsContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName,
     667             :         const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList )
     668             : {
     669           0 :     return new XMLAnimationsEffectContext( GetImport(), nPrefix, rLocalName,  xAttrList, mpImpl );
     670             : }
     671             : 
     672             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10