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

Generated by: LCOV version 1.11