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

Generated by: LCOV version 1.10