LCOV - code coverage report
Current view: top level - sd/source/ui/animations - CustomAnimationList.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 458 0.0 %
Date: 2012-08-25 Functions: 0 47 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 794 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <com/sun/star/drawing/XShapes.hpp>
      30                 :            : #include <com/sun/star/presentation/ShapeAnimationSubType.hpp>
      31                 :            : #include <com/sun/star/presentation/EffectNodeType.hpp>
      32                 :            : #include <com/sun/star/presentation/ParagraphTarget.hpp>
      33                 :            : #include <com/sun/star/container/XEnumerationAccess.hpp>
      34                 :            : #include <com/sun/star/animations/XIterateContainer.hpp>
      35                 :            : #include <com/sun/star/presentation/EffectPresetClass.hpp>
      36                 :            : #include <com/sun/star/presentation/EffectCommands.hpp>
      37                 :            : #include <com/sun/star/text/XTextRange.hpp>
      38                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      39                 :            : #include <com/sun/star/drawing/XDrawPage.hpp>
      40                 :            : #include <svx/ShapeTypeHandler.hxx>
      41                 :            : #include "CustomAnimationList.hxx"
      42                 :            : #include "CustomAnimationPane.hrc"
      43                 :            : #include "CustomAnimation.hrc"
      44                 :            : #include "CustomAnimationPreset.hxx"
      45                 :            : #include <vcl/svapp.hxx>
      46                 :            : #include "sdresid.hxx"
      47                 :            : 
      48                 :            : #include "res_bmp.hrc"
      49                 :            : #include "glob.hrc"
      50                 :            : 
      51                 :            : #include <algorithm>
      52                 :            : 
      53                 :            : using namespace ::com::sun::star;
      54                 :            : using namespace ::com::sun::star::animations;
      55                 :            : using namespace ::com::sun::star::presentation;
      56                 :            : 
      57                 :            : using ::rtl::OUString;
      58                 :            : using ::com::sun::star::uno::UNO_QUERY;
      59                 :            : using ::com::sun::star::uno::UNO_QUERY_THROW;
      60                 :            : using ::com::sun::star::uno::Any;
      61                 :            : using ::com::sun::star::uno::Sequence;
      62                 :            : using ::com::sun::star::uno::Reference;
      63                 :            : using ::com::sun::star::uno::Exception;
      64                 :            : using ::com::sun::star::uno::XInterface;
      65                 :            : using ::com::sun::star::text::XTextRange;
      66                 :            : using ::com::sun::star::drawing::XShape;
      67                 :            : using ::com::sun::star::drawing::XShapes;
      68                 :            : using ::com::sun::star::drawing::XDrawPage;
      69                 :            : using ::com::sun::star::container::XChild;
      70                 :            : using ::com::sun::star::container::XIndexAccess;
      71                 :            : using ::com::sun::star::container::XEnumerationAccess;
      72                 :            : using ::com::sun::star::container::XEnumeration;
      73                 :            : using ::com::sun::star::beans::XPropertySet;
      74                 :            : using ::com::sun::star::beans::XPropertySetInfo;
      75                 :            : using ::accessibility::ShapeTypeHandler;
      76                 :            : 
      77                 :            : namespace sd {
      78                 :            : 
      79                 :            : // go recursivly through all shapes in the given XShapes collection and return true as soon as the
      80                 :            : // given shape is found. nIndex is incremented for each shape with the same shape type as the given
      81                 :            : // shape is found until the given shape is found.
      82                 :          0 : static bool getShapeIndex(  const Reference< XShapes >& xShapes, const Reference< XShape >& xShape, sal_Int32& nIndex )
      83                 :            : {
      84                 :          0 :     const sal_Int32 nCount = xShapes->getCount();
      85                 :            :     sal_Int32 n;
      86         [ #  # ]:          0 :     for( n = 0; n < nCount; n++ )
      87                 :            :     {
      88                 :          0 :         Reference< XShape > xChild;
      89 [ #  # ][ #  # ]:          0 :         xShapes->getByIndex( n ) >>= xChild;
                 [ #  # ]
      90 [ #  # ][ #  # ]:          0 :         if( xChild == xShape )
      91                 :          0 :             return true;
      92                 :            : 
      93 [ #  # ][ #  # ]:          0 :         if( xChild->getShapeType() == xShape->getShapeType() )
         [ #  # ][ #  # ]
                 [ #  # ]
      94                 :          0 :             nIndex++;
      95                 :            : 
      96         [ #  # ]:          0 :         Reference< XShapes > xChildContainer( xChild, UNO_QUERY );
      97         [ #  # ]:          0 :         if( xChildContainer.is() )
      98                 :            :         {
      99 [ #  # ][ #  # ]:          0 :             if( getShapeIndex( xChildContainer, xShape, nIndex ) )
     100                 :          0 :                 return true;
     101                 :            :         }
     102 [ #  # ][ #  # ]:          0 :     }
     103                 :            : 
     104                 :          0 :     return false;
     105                 :            : }
     106                 :            : 
     107                 :            : // returns the index of the shape type from the given shape
     108                 :          0 : static sal_Int32 getShapeIndex( const Reference< XShape >& xShape )
     109                 :            : {
     110         [ #  # ]:          0 :     Reference< XChild > xChild( xShape, UNO_QUERY );
     111                 :          0 :     Reference< XShapes > xPage;
     112                 :            : 
     113 [ #  # ][ #  # ]:          0 :     while( xChild.is() && !xPage.is() )
                 [ #  # ]
     114                 :            :     {
     115 [ #  # ][ #  # ]:          0 :         Reference< XInterface > x( xChild->getParent() );
     116 [ #  # ][ #  # ]:          0 :         xChild = Reference< XChild >::query( x );
     117         [ #  # ]:          0 :         Reference< XDrawPage > xTestPage( x, UNO_QUERY );
     118         [ #  # ]:          0 :         if( xTestPage.is() )
     119 [ #  # ][ #  # ]:          0 :             xPage = Reference< XShapes >::query( x );
     120                 :          0 :     }
     121                 :            : 
     122                 :          0 :     sal_Int32 nIndex = 1;
     123                 :            : 
     124 [ #  # ][ #  # ]:          0 :     if( xPage.is() && getShapeIndex( xPage, xShape, nIndex ) )
         [ #  # ][ #  # ]
     125                 :          0 :         return nIndex;
     126                 :            :     else
     127                 :          0 :         return -1;
     128                 :            : }
     129                 :            : 
     130                 :          0 : OUString getShapeDescription( const Reference< XShape >& xShape, bool bWithText = true )
     131                 :            : {
     132                 :          0 :     OUString aDescription;
     133         [ #  # ]:          0 :     Reference< XPropertySet > xSet( xShape, UNO_QUERY );
     134         [ #  # ]:          0 :     if( xSet.is() )
     135                 :            :     {
     136 [ #  # ][ #  # ]:          0 :         Reference< XPropertySetInfo > xInfo( xSet->getPropertySetInfo() );
     137                 :          0 :         const OUString aPropName( "UINameSingular");
     138 [ #  # ][ #  # ]:          0 :         if( xInfo->hasPropertyByName( aPropName ) )
                 [ #  # ]
     139 [ #  # ][ #  # ]:          0 :             xSet->getPropertyValue( aPropName ) >>= aDescription;
     140                 :            :     }
     141                 :            : 
     142                 :          0 :     aDescription += " ";
     143         [ #  # ]:          0 :     aDescription += OUString::valueOf( getShapeIndex( xShape ) );
     144                 :            : 
     145         [ #  # ]:          0 :     if( bWithText )
     146                 :            :     {
     147         [ #  # ]:          0 :         Reference< XTextRange > xText( xShape, UNO_QUERY );
     148         [ #  # ]:          0 :         if( xText.is() )
     149                 :            :         {
     150 [ #  # ][ #  # ]:          0 :             OUString aText( xText->getString() );
     151         [ #  # ]:          0 :             if( !aText.isEmpty() )
     152                 :            :             {
     153                 :          0 :                 aDescription += ": ";
     154                 :            : 
     155                 :          0 :                 aText = aText.replace( (sal_Unicode)'\n', (sal_Unicode)' ' );
     156                 :          0 :                 aText = aText.replace( (sal_Unicode)'\r', (sal_Unicode)' ' );
     157                 :            : 
     158                 :          0 :                 aDescription += aText;
     159                 :          0 :             }
     160                 :          0 :         }
     161                 :            :     }
     162                 :          0 :     return aDescription;
     163                 :            : }
     164                 :            : 
     165                 :          0 : static OUString getDescription( const Any& rTarget, bool bWithText = true )
     166                 :            : {
     167                 :          0 :     OUString aDescription;
     168                 :            : 
     169 [ #  # ][ #  # ]:          0 :     if( rTarget.getValueType() == ::getCppuType((const ParagraphTarget*)0) )
     170                 :            :     {
     171         [ #  # ]:          0 :         ParagraphTarget aParaTarget;
     172         [ #  # ]:          0 :         rTarget >>= aParaTarget;
     173                 :            : 
     174         [ #  # ]:          0 :         Reference< XEnumerationAccess > xText( aParaTarget.Shape, UNO_QUERY_THROW );
     175 [ #  # ][ #  # ]:          0 :         Reference< XEnumeration > xEnumeration( xText->createEnumeration(), UNO_QUERY_THROW );
                 [ #  # ]
     176                 :          0 :         sal_Int32 nPara = aParaTarget.Paragraph;
     177                 :            : 
     178 [ #  # ][ #  # ]:          0 :         while( xEnumeration->hasMoreElements() && nPara )
         [ #  # ][ #  # ]
                 [ #  # ]
     179                 :            :         {
     180 [ #  # ][ #  # ]:          0 :             xEnumeration->nextElement();
     181                 :          0 :             nPara--;
     182                 :            :         }
     183                 :            : 
     184                 :            :         DBG_ASSERT( xEnumeration->hasMoreElements(), "sd::CustomAnimationEffect::prepareText(), paragraph out of range!" );
     185                 :            : 
     186 [ #  # ][ #  # ]:          0 :         if( xEnumeration->hasMoreElements() )
                 [ #  # ]
     187                 :            :         {
     188                 :          0 :             Reference< XTextRange > xParagraph;
     189 [ #  # ][ #  # ]:          0 :             xEnumeration->nextElement() >>= xParagraph;
                 [ #  # ]
     190                 :            : 
     191         [ #  # ]:          0 :             if( xParagraph.is() )
     192 [ #  # ][ #  # ]:          0 :                 aDescription = xParagraph->getString();
     193         [ #  # ]:          0 :         }
     194                 :            :     }
     195                 :            :     else
     196                 :            :     {
     197                 :          0 :         Reference< XShape > xShape;
     198         [ #  # ]:          0 :         rTarget >>= xShape;
     199         [ #  # ]:          0 :         if( xShape.is() )
     200         [ #  # ]:          0 :             aDescription = getShapeDescription( xShape, bWithText );
     201                 :            :     }
     202                 :            : 
     203                 :          0 :     return aDescription;
     204                 :            : }
     205                 :            : 
     206                 :            : // ====================================================================
     207                 :            : 
     208                 :            : class CustomAnimationListEntryItem : public SvLBoxString
     209                 :            : {
     210                 :            : public:
     211                 :            :                     CustomAnimationListEntryItem( SvLBoxEntry*,sal_uInt16 nFlags, OUString aDescription, CustomAnimationEffectPtr pEffect, CustomAnimationList* pParent  );
     212                 :            :     virtual         ~CustomAnimationListEntryItem();
     213                 :            :     void            InitViewData( SvLBox*,SvLBoxEntry*,SvViewDataItem* );
     214                 :            :     void            Paint( const Point&, SvLBox& rDev, sal_uInt16 nFlags,SvLBoxEntry* );
     215                 :            :     SvLBoxItem*     Create() const;
     216                 :            :     void            Clone( SvLBoxItem* pSource );
     217                 :            : 
     218                 :            : private:
     219                 :            :     CustomAnimationList* mpParent;
     220                 :            :     OUString        maDescription;
     221                 :            :     CustomAnimationEffectPtr mpEffect;
     222                 :            : };
     223                 :            : 
     224                 :            : // --------------------------------------------------------------------
     225                 :            : 
     226                 :          0 : CustomAnimationListEntryItem::CustomAnimationListEntryItem( SvLBoxEntry* pEntry, sal_uInt16 nFlags, OUString aDescription, CustomAnimationEffectPtr pEffect, CustomAnimationList* pParent  )
     227                 :            : : SvLBoxString( pEntry, nFlags, aDescription )
     228                 :            : , mpParent( pParent )
     229                 :            : , maDescription( aDescription )
     230         [ #  # ]:          0 : , mpEffect(pEffect)
     231                 :            : {
     232                 :          0 : }
     233                 :            : 
     234                 :            : // --------------------------------------------------------------------
     235                 :            : 
     236         [ #  # ]:          0 : CustomAnimationListEntryItem::~CustomAnimationListEntryItem()
     237                 :            : {
     238         [ #  # ]:          0 : }
     239                 :            : 
     240                 :            : // --------------------------------------------------------------------
     241                 :            : 
     242                 :          0 : void CustomAnimationListEntryItem::InitViewData( SvLBox* pView, SvLBoxEntry* pEntry, SvViewDataItem* pViewData )
     243                 :            : {
     244         [ #  # ]:          0 :     if( !pViewData )
     245         [ #  # ]:          0 :         pViewData = pView->GetViewDataItem( pEntry, this );
     246                 :            : 
     247 [ #  # ][ #  # ]:          0 :     Size aSize(pView->GetTextWidth( maDescription ) + 2 * 19, pView->GetTextHeight() );
         [ #  # ][ #  # ]
     248         [ #  # ]:          0 :     if( aSize.Height() < 19 )
     249                 :          0 :         aSize.Height() = 19;
     250                 :          0 :     pViewData->aSize = aSize;
     251                 :          0 : }
     252                 :            : 
     253                 :            : // --------------------------------------------------------------------
     254                 :            : 
     255                 :          0 : void CustomAnimationListEntryItem::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16, SvLBoxEntry* pEntry )
     256                 :            : {
     257                 :            : 
     258         [ #  # ]:          0 :     SvViewDataItem* pViewData = mpParent->GetViewDataItem( pEntry, this );
     259                 :            : 
     260                 :          0 :     Point aPos( rPos );
     261                 :          0 :     Size aSize( pViewData->aSize );
     262                 :            : 
     263                 :          0 :     sal_Int16 nNodeType = mpEffect->getNodeType();
     264         [ #  # ]:          0 :     if( nNodeType == EffectNodeType::ON_CLICK )
     265                 :            :     {
     266 [ #  # ][ #  # ]:          0 :         rDev.DrawImage( aPos, mpParent->getImage( IMG_CUSTOMANIMATION_ON_CLICK ) );
     267                 :            :     }
     268         [ #  # ]:          0 :     else if( nNodeType == EffectNodeType::AFTER_PREVIOUS )
     269                 :            :     {
     270 [ #  # ][ #  # ]:          0 :         rDev.DrawImage( aPos, mpParent->getImage( IMG_CUSTOMANIMATION_AFTER_PREVIOUS ) );
     271                 :            :     }
     272                 :            : 
     273                 :          0 :     aPos.X() += 19;
     274                 :            : 
     275                 :            :     sal_uInt16 nImage;
     276   [ #  #  #  #  :          0 :     switch( mpEffect->getPresetClass() )
                #  #  # ]
     277                 :            :     {
     278                 :          0 :     case EffectPresetClass::ENTRANCE:   nImage = IMG_CUSTOMANIMATION_ENTRANCE_EFFECT; break;
     279                 :          0 :     case EffectPresetClass::EXIT:       nImage =  IMG_CUSTOMANIMATION_EXIT_EFFECT; break;
     280                 :          0 :     case EffectPresetClass::EMPHASIS:   nImage =  IMG_CUSTOMANIMATION_EMPHASIS_EFFECT; break;
     281                 :          0 :     case EffectPresetClass::MOTIONPATH: nImage = IMG_CUSTOMANIMATION_MOTION_PATH; break;
     282                 :          0 :     case EffectPresetClass::OLEACTION:  nImage = IMG_CUSTOMANIMATION_OLE; break;
     283                 :            :     case EffectPresetClass::MEDIACALL:
     284      [ #  #  # ]:          0 :         switch( mpEffect->getCommand() )
     285                 :            :         {
     286                 :          0 :         case EffectCommands::TOGGLEPAUSE:   nImage = IMG_CUSTOMANIMATION_MEDIA_PAUSE; break;
     287                 :          0 :         case EffectCommands::STOP:          nImage = IMG_CUSTOMANIMATION_MEDIA_STOP; break;
     288                 :            :         case EffectCommands::PLAY:
     289                 :          0 :         default:                            nImage = IMG_CUSTOMANIMATION_MEDIA_PLAY; break;
     290                 :            :         }
     291                 :          0 :         break;
     292                 :          0 :     default:                            nImage = 0xffff;
     293                 :            :     }
     294                 :            : 
     295         [ #  # ]:          0 :     if( nImage != 0xffff )
     296                 :            :     {
     297         [ #  # ]:          0 :         const Image& rImage = mpParent->getImage( nImage );
     298                 :          0 :         Point aImagePos( aPos );
     299         [ #  # ]:          0 :         aImagePos.Y() += ( aSize.Height() - rImage.GetSizePixel().Height() ) >> 1;
     300         [ #  # ]:          0 :         rDev.DrawImage( aImagePos, rImage );
     301                 :            :     }
     302                 :            : 
     303                 :          0 :     aPos.X() += 19;
     304         [ #  # ]:          0 :     aPos.Y() += ( aSize.Height() - rDev.GetTextHeight()) >> 1;
     305                 :            : 
     306 [ #  # ][ #  # ]:          0 :     rDev.DrawText( aPos, rDev.GetEllipsisString( maDescription, rDev.GetOutputSizePixel().Width() - aPos.X() ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     307                 :          0 : }
     308                 :            : 
     309                 :            : // --------------------------------------------------------------------
     310                 :            : 
     311                 :          0 : SvLBoxItem* CustomAnimationListEntryItem::Create() const
     312                 :            : {
     313                 :          0 :     return NULL;
     314                 :            : }
     315                 :            : 
     316                 :            : // --------------------------------------------------------------------
     317                 :            : 
     318                 :          0 : void CustomAnimationListEntryItem::Clone( SvLBoxItem* )
     319                 :            : {
     320                 :          0 : }
     321                 :            : 
     322                 :            : // ====================================================================
     323                 :            : 
     324                 :            : class CustomAnimationListEntry : public SvLBoxEntry
     325                 :            : {
     326                 :            : public:
     327                 :            :     CustomAnimationListEntry();
     328                 :            :     CustomAnimationListEntry( CustomAnimationEffectPtr pEffect );
     329                 :            :     virtual ~CustomAnimationListEntry();
     330                 :            : 
     331                 :          0 :     CustomAnimationEffectPtr getEffect() const { return mpEffect; }
     332                 :            : 
     333                 :            : private:
     334                 :            :     CustomAnimationEffectPtr mpEffect;
     335                 :            : };
     336                 :            : 
     337                 :            : // --------------------------------------------------------------------
     338                 :            : 
     339         [ #  # ]:          0 : CustomAnimationListEntry::CustomAnimationListEntry()
     340                 :            : {
     341                 :          0 : }
     342                 :            : 
     343                 :            : // --------------------------------------------------------------------
     344                 :            : 
     345                 :          0 : CustomAnimationListEntry::CustomAnimationListEntry( CustomAnimationEffectPtr pEffect )
     346         [ #  # ]:          0 : : mpEffect( pEffect )
     347                 :            : {
     348                 :          0 : }
     349                 :            : 
     350                 :            : // --------------------------------------------------------------------
     351                 :            : 
     352         [ #  # ]:          0 : CustomAnimationListEntry::~CustomAnimationListEntry()
     353                 :            : {
     354         [ #  # ]:          0 : }
     355                 :            : 
     356                 :            : // ====================================================================
     357                 :            : 
     358                 :            : class CustomAnimationTriggerEntryItem : public SvLBoxString
     359                 :            : {
     360                 :            : public:
     361                 :            :                     CustomAnimationTriggerEntryItem( SvLBoxEntry*,sal_uInt16 nFlags, OUString aDescription, CustomAnimationList* pParent  );
     362                 :            :     virtual         ~CustomAnimationTriggerEntryItem();
     363                 :            :     virtual sal_uInt16  IsA();
     364                 :            :     void            InitViewData( SvLBox*,SvLBoxEntry*,SvViewDataItem* );
     365                 :            :     void            Paint( const Point&, SvLBox& rDev, sal_uInt16 nFlags,SvLBoxEntry* );
     366                 :            :     SvLBoxItem*     Create() const;
     367                 :            :     void            Clone( SvLBoxItem* pSource );
     368                 :            : 
     369                 :            : private:
     370                 :            :     CustomAnimationList* mpParent;
     371                 :            :     OUString        maDescription;
     372                 :            : };
     373                 :            : 
     374                 :            : // --------------------------------------------------------------------
     375                 :            : 
     376                 :          0 : CustomAnimationTriggerEntryItem::CustomAnimationTriggerEntryItem( SvLBoxEntry* pEntry, sal_uInt16 nFlags, OUString aDescription, CustomAnimationList* pParent  )
     377                 :          0 : : SvLBoxString( pEntry, nFlags, aDescription ), mpParent( pParent ), maDescription( aDescription )
     378                 :            : {
     379                 :          0 : }
     380                 :            : 
     381                 :            : // --------------------------------------------------------------------
     382                 :            : 
     383                 :          0 : CustomAnimationTriggerEntryItem::~CustomAnimationTriggerEntryItem()
     384                 :            : {
     385         [ #  # ]:          0 : }
     386                 :            : 
     387                 :            : // --------------------------------------------------------------------
     388                 :            : 
     389                 :          0 : sal_uInt16 CustomAnimationTriggerEntryItem::IsA()
     390                 :            : {
     391                 :          0 :     return (sal_uInt16)-1;
     392                 :            : }
     393                 :            : 
     394                 :            : // --------------------------------------------------------------------
     395                 :            : 
     396                 :          0 : void CustomAnimationTriggerEntryItem::InitViewData( SvLBox* pView, SvLBoxEntry* pEntry, SvViewDataItem* pViewData )
     397                 :            : {
     398         [ #  # ]:          0 :     if( !pViewData )
     399         [ #  # ]:          0 :         pViewData = pView->GetViewDataItem( pEntry, this );
     400                 :            : 
     401 [ #  # ][ #  # ]:          0 :     Size aSize(pView->GetTextWidth( maDescription ) + 2 * 19, pView->GetTextHeight() );
         [ #  # ][ #  # ]
     402         [ #  # ]:          0 :     if( aSize.Height() < 19 )
     403                 :          0 :         aSize.Height() = 19;
     404                 :          0 :     pViewData->aSize = aSize;
     405                 :          0 : }
     406                 :            : 
     407                 :            : // --------------------------------------------------------------------
     408                 :            : 
     409                 :          0 : void CustomAnimationTriggerEntryItem::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16, SvLBoxEntry* )
     410                 :            : {
     411                 :          0 :     Size aSize( rDev.GetOutputSizePixel().Width(), static_cast< SvTreeListBox* >(&rDev)->GetEntryHeight() );
     412                 :            : 
     413                 :          0 :     Point aPos( 0, rPos.Y() );
     414                 :            : 
     415         [ #  # ]:          0 :     Rectangle aOutRect( aPos, aSize );
     416                 :            : 
     417                 :            :     // fill the background
     418                 :          0 :     Color aColor (rDev.GetSettings().GetStyleSettings().GetDialogColor());
     419                 :            : 
     420         [ #  # ]:          0 :     rDev.Push();
     421         [ #  # ]:          0 :     rDev.SetFillColor (aColor);
     422         [ #  # ]:          0 :     rDev.SetLineColor ();
     423         [ #  # ]:          0 :     rDev.DrawRect(aOutRect);
     424                 :            : 
     425                 :            :     // Erase the four corner pixels to make the rectangle appear rounded.
     426         [ #  # ]:          0 :     rDev.SetLineColor( rDev.GetSettings().GetStyleSettings().GetWindowColor());
     427         [ #  # ]:          0 :     rDev.DrawPixel( aOutRect.TopLeft());
     428         [ #  # ]:          0 :     rDev.DrawPixel( Point(aOutRect.Right(), aOutRect.Top()));
     429         [ #  # ]:          0 :     rDev.DrawPixel( Point(aOutRect.Left(), aOutRect.Bottom()));
     430         [ #  # ]:          0 :     rDev.DrawPixel( Point(aOutRect.Right(), aOutRect.Bottom()));
     431                 :            : 
     432                 :            :     // draw the category title
     433                 :            : 
     434         [ #  # ]:          0 :     int nVertBorder = (( aSize.Height() - rDev.GetTextHeight()) >> 1);
     435 [ #  # ][ #  # ]:          0 :     int nHorzBorder = rDev.LogicToPixel( Size( 3, 3 ), MAP_APPFONT ).Width();
                 [ #  # ]
     436                 :            : 
     437                 :          0 :     aOutRect.nLeft += nHorzBorder;
     438                 :          0 :     aOutRect.nRight -= nHorzBorder;
     439                 :          0 :     aOutRect.nTop += nVertBorder;
     440                 :          0 :     aOutRect.nBottom -= nVertBorder;
     441                 :            : 
     442 [ #  # ][ #  # ]:          0 :     rDev.DrawText (aOutRect, rDev.GetEllipsisString( maDescription, aOutRect.GetWidth() ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     443         [ #  # ]:          0 :     rDev.Pop();
     444                 :          0 : }
     445                 :            : 
     446                 :            : // --------------------------------------------------------------------
     447                 :            : 
     448                 :          0 : SvLBoxItem* CustomAnimationTriggerEntryItem::Create() const
     449                 :            : {
     450                 :          0 :     return NULL;
     451                 :            : }
     452                 :            : 
     453                 :            : // --------------------------------------------------------------------
     454                 :            : 
     455                 :          0 : void CustomAnimationTriggerEntryItem::Clone( SvLBoxItem* )
     456                 :            : {
     457                 :          0 : }
     458                 :            : 
     459                 :            : // ====================================================================
     460                 :            : 
     461                 :          0 : CustomAnimationList::CustomAnimationList( ::Window* pParent, const ResId& rResId, ICustomAnimationListController* pController )
     462                 :            : :   SvTreeListBox( pParent, rResId )
     463                 :            : ,   mbIgnorePaint( false )
     464                 :            : ,   mpController( pController )
     465 [ #  # ][ #  # ]:          0 : ,   mpLastParentEntry(0)
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     466                 :            : {
     467 [ #  # ][ #  # ]:          0 :     SetStyle( GetStyle() | WB_TABSTOP | WB_BORDER | WB_HASLINES | WB_HASBUTTONS | WB_HASBUTTONSATROOT );
     468                 :            : 
     469         [ #  # ]:          0 :     EnableContextMenuHandling();
     470         [ #  # ]:          0 :     SetSelectionMode( MULTIPLE_SELECTION );
     471         [ #  # ]:          0 :     SetIndent(16);
     472         [ #  # ]:          0 :     SetNodeDefaultImages();
     473   [ #  #  #  # ]:          0 : }
     474                 :            : 
     475                 :            : // --------------------------------------------------------------------
     476                 :            : 
     477                 :          0 : const Image&  CustomAnimationList::getImage( sal_uInt16 nId )
     478                 :            : {
     479                 :            :     DBG_ASSERT( (nId >= IMG_CUSTOMANIMATION_ON_CLICK) && (nId <= IMG_CUSTOMANIMATION_MEDIA_STOP), "sd::CustomAnimationList::getImage(), illegal index!" );
     480                 :            : 
     481                 :          0 :     Image& rImage = maImages[nId - IMG_CUSTOMANIMATION_ON_CLICK];
     482                 :            : 
     483                 :            :     // load on demand
     484         [ #  # ]:          0 :     if( rImage.GetSizePixel().Width() == 0 )
     485 [ #  # ][ #  # ]:          0 :         rImage = Image(SdResId( nId ) );
                 [ #  # ]
     486                 :            : 
     487                 :          0 :     return rImage;
     488                 :            : }
     489                 :            : 
     490                 :            : // --------------------------------------------------------------------
     491                 :            : 
     492 [ #  # ][ #  # ]:          0 : CustomAnimationList::~CustomAnimationList()
                 [ #  # ]
     493                 :            : {
     494         [ #  # ]:          0 :     if( mpMainSequence.get() )
     495         [ #  # ]:          0 :         mpMainSequence->removeListener( this );
     496                 :            : 
     497         [ #  # ]:          0 :     clear();
     498 [ #  # ][ #  # ]:          0 : }
                 [ #  # ]
           [ #  #  #  # ]
     499                 :            : 
     500                 :            : // --------------------------------------------------------------------
     501                 :            : 
     502                 :          0 : void CustomAnimationList::KeyInput( const KeyEvent& rKEvt )
     503                 :            : {
     504                 :          0 :     const int nKeyCode = rKEvt.GetKeyCode().GetCode();
     505   [ #  #  #  # ]:          0 :     switch( nKeyCode )
     506                 :            :     {
     507                 :          0 :         case KEY_DELETE:    mpController->onContextMenu( CM_REMOVE ); return;
     508                 :          0 :         case KEY_INSERT:    mpController->onContextMenu( CM_CREATE ); return;
     509                 :            :         case KEY_SPACE:
     510                 :            :             {
     511                 :          0 :                 const Point aPos;
     512         [ #  # ]:          0 :                 const CommandEvent aCEvt( aPos, COMMAND_CONTEXTMENU );
     513         [ #  # ]:          0 :                 Command( aCEvt );
     514                 :            :                 return;
     515                 :            :             }
     516                 :            : 
     517                 :            :     }
     518                 :            : 
     519                 :          0 :     ::SvTreeListBox::KeyInput( rKEvt );
     520                 :            : }
     521                 :            : 
     522                 :            : // --------------------------------------------------------------------
     523                 :            : 
     524                 :            : /** selects or deselects the given effect.
     525                 :            :     Selections of other effects are not changed */
     526                 :          0 : void CustomAnimationList::select( CustomAnimationEffectPtr pEffect, bool bSelect /* = true */ )
     527                 :            : {
     528                 :          0 :     CustomAnimationListEntry* pEntry = static_cast< CustomAnimationListEntry* >(First());
     529         [ #  # ]:          0 :     while( pEntry )
     530                 :            :     {
     531 [ #  # ][ #  # ]:          0 :         if( pEntry->getEffect() == pEffect )
     532                 :            :         {
     533                 :          0 :             Select( pEntry, bSelect );
     534                 :          0 :             MakeVisible( pEntry );
     535                 :          0 :             break;
     536                 :            :         }
     537                 :          0 :         pEntry = static_cast< CustomAnimationListEntry* >(Next( pEntry ));
     538                 :            :     }
     539                 :            : 
     540 [ #  # ][ #  # ]:          0 :     if( !pEntry && bSelect )
     541                 :            :     {
     542         [ #  # ]:          0 :         append( pEffect );
     543         [ #  # ]:          0 :         select( pEffect );
     544                 :            :     }
     545                 :          0 : }
     546                 :            : 
     547                 :            : // --------------------------------------------------------------------
     548                 :            : 
     549                 :          0 : void CustomAnimationList::clear()
     550                 :            : {
     551                 :          0 :     Clear();
     552                 :            : 
     553                 :          0 :     mpLastParentEntry = 0;
     554                 :          0 :     mxLastTargetShape = 0;
     555                 :          0 : }
     556                 :            : 
     557                 :            : // --------------------------------------------------------------------
     558                 :            : 
     559                 :          0 : void CustomAnimationList::update( MainSequencePtr pMainSequence )
     560                 :            : {
     561         [ #  # ]:          0 :     if( mpMainSequence.get() )
     562                 :          0 :         mpMainSequence->removeListener( this );
     563                 :            : 
     564                 :          0 :     mpMainSequence = pMainSequence;
     565                 :          0 :     update();
     566                 :            : 
     567         [ #  # ]:          0 :     if( mpMainSequence.get() )
     568                 :          0 :         mpMainSequence->addListener( this );
     569                 :          0 : }
     570                 :            : 
     571                 :            : // --------------------------------------------------------------------
     572                 :            : 
     573                 :            : struct stl_append_effect_func : public std::unary_function<CustomAnimationEffectPtr, void>
     574                 :            : {
     575                 :          0 :     stl_append_effect_func( CustomAnimationList& rList ) : mrList( rList ) {}
     576                 :            :     void operator()(CustomAnimationEffectPtr pEffect);
     577                 :            :     CustomAnimationList& mrList;
     578                 :            : };
     579                 :            : 
     580                 :          0 : void stl_append_effect_func::operator()(CustomAnimationEffectPtr pEffect)
     581                 :            : {
     582         [ #  # ]:          0 :     mrList.append( pEffect );
     583                 :          0 : }
     584                 :            : // --------------------------------------------------------------------
     585                 :            : 
     586                 :          0 : void CustomAnimationList::update()
     587                 :            : {
     588                 :          0 :     mbIgnorePaint = true;
     589         [ #  # ]:          0 :     SetUpdateMode( sal_False );
     590                 :            : 
     591                 :          0 :     CustomAnimationListEntry* pEntry = 0;
     592                 :            : 
     593         [ #  # ]:          0 :     std::list< CustomAnimationEffectPtr > aExpanded;
     594         [ #  # ]:          0 :     std::list< CustomAnimationEffectPtr > aSelected;
     595                 :            : 
     596         [ #  # ]:          0 :     CustomAnimationEffectPtr pFirstSelEffect;
     597         [ #  # ]:          0 :     CustomAnimationEffectPtr pLastSelEffect;
     598                 :          0 :     long nFirstVis = -1;
     599                 :          0 :     long nLastVis = -1;
     600                 :          0 :     long nFirstSelOld = -1;
     601                 :          0 :     long nLastSelOld = -1;
     602                 :          0 :     bool bMoved = false;
     603                 :          0 :     bool bMovedUp = false;
     604                 :          0 :     bool bMovedDown = false;
     605                 :            : 
     606         [ #  # ]:          0 :     if( mpMainSequence.get() )
     607                 :            :     {
     608                 :            :         // save scroll position
     609         [ #  # ]:          0 :         pEntry = static_cast<CustomAnimationListEntry*>(GetFirstEntryInView());
     610         [ #  # ]:          0 :         if( pEntry )
     611         [ #  # ]:          0 :             nFirstVis = GetAbsPos( pEntry );
     612                 :            : 
     613         [ #  # ]:          0 :         pEntry = static_cast<CustomAnimationListEntry*>(GetLastEntryInView());
     614         [ #  # ]:          0 :         if( pEntry )
     615         [ #  # ]:          0 :             nLastVis = GetAbsPos( pEntry );
     616                 :            : 
     617         [ #  # ]:          0 :         pEntry = static_cast<CustomAnimationListEntry*>(FirstSelected());
     618         [ #  # ]:          0 :         if( pEntry )
     619                 :            :         {
     620 [ #  # ][ #  # ]:          0 :             pFirstSelEffect = pEntry->getEffect();
                 [ #  # ]
     621         [ #  # ]:          0 :             nFirstSelOld = GetAbsPos( pEntry );
     622                 :            :         }
     623                 :            : 
     624         [ #  # ]:          0 :         pEntry = static_cast<CustomAnimationListEntry*>(LastSelected());
     625         [ #  # ]:          0 :         if( pEntry )
     626                 :            :         {
     627 [ #  # ][ #  # ]:          0 :             pLastSelEffect = pEntry->getEffect();
                 [ #  # ]
     628         [ #  # ]:          0 :             nLastSelOld = GetAbsPos( pEntry );
     629                 :            :         }
     630                 :            : 
     631                 :            :         // save selection and expand states
     632         [ #  # ]:          0 :         pEntry = static_cast<CustomAnimationListEntry*>(First());
     633                 :            : 
     634         [ #  # ]:          0 :         while( pEntry )
     635                 :            :         {
     636         [ #  # ]:          0 :             CustomAnimationEffectPtr pEffect( pEntry->getEffect() );
     637         [ #  # ]:          0 :             if( pEffect.get() )
     638                 :            :             {
     639 [ #  # ][ #  # ]:          0 :                 if( IsExpanded( pEntry ) )
     640         [ #  # ]:          0 :                     aExpanded.push_back( pEffect );
     641                 :            : 
     642 [ #  # ][ #  # ]:          0 :                 if( IsSelected( pEntry ) )
     643         [ #  # ]:          0 :                     aSelected.push_back( pEffect );
     644                 :            :             }
     645                 :            : 
     646         [ #  # ]:          0 :             pEntry = static_cast<CustomAnimationListEntry*>(Next( pEntry ));
     647         [ #  # ]:          0 :         }
     648                 :            :     }
     649                 :            : 
     650                 :            :     // rebuild list
     651         [ #  # ]:          0 :     clear();
     652         [ #  # ]:          0 :     if( mpMainSequence.get() )
     653                 :            :     {
     654                 :          0 :         long nFirstSelNew = -1;
     655                 :          0 :         long nLastSelNew = -1;
     656         [ #  # ]:          0 :         std::for_each( mpMainSequence->getBegin(), mpMainSequence->getEnd(), stl_append_effect_func( *this ) );
     657                 :          0 :         mpLastParentEntry = 0;
     658                 :            : 
     659                 :          0 :         const InteractiveSequenceList& rISL = mpMainSequence->getInteractiveSequenceList();
     660                 :            : 
     661                 :          0 :         InteractiveSequenceList::const_iterator aIter( rISL.begin() );
     662                 :          0 :         const InteractiveSequenceList::const_iterator aEnd( rISL.end() );
     663         [ #  # ]:          0 :         while( aIter != aEnd )
     664                 :            :         {
     665         [ #  # ]:          0 :             InteractiveSequencePtr pIS( (*aIter++) );
     666                 :            : 
     667         [ #  # ]:          0 :             Reference< XShape > xShape( pIS->getTriggerShape() );
     668         [ #  # ]:          0 :             if( xShape.is() )
     669                 :            :             {
     670 [ #  # ][ #  # ]:          0 :                 SvLBoxEntry* pLBoxEntry = new CustomAnimationListEntry;
     671 [ #  # ][ #  # ]:          0 :                 pLBoxEntry->AddItem( new SvLBoxContextBmp( pLBoxEntry, 0, Image(), Image(), 0));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     672 [ #  # ][ #  # ]:          0 :                 OUString aDescription = String( SdResId( STR_CUSTOMANIMATION_TRIGGER ) );
         [ #  # ][ #  # ]
     673                 :          0 :                 aDescription += ": ";
     674         [ #  # ]:          0 :                 aDescription += getShapeDescription( xShape, false );
     675 [ #  # ][ #  # ]:          0 :                 pLBoxEntry->AddItem( new CustomAnimationTriggerEntryItem( pLBoxEntry, 0, aDescription, this ) );
                 [ #  # ]
     676         [ #  # ]:          0 :                 Insert( pLBoxEntry );
     677         [ #  # ]:          0 :                 SvViewData* pViewData = GetViewData( pLBoxEntry );
     678         [ #  # ]:          0 :                 if( pViewData )
     679                 :          0 :                     pViewData->SetSelectable(false);
     680                 :            : 
     681         [ #  # ]:          0 :                 std::for_each( pIS->getBegin(), pIS->getEnd(), stl_append_effect_func( *this ) );
     682                 :          0 :                 mpLastParentEntry = 0;
     683                 :            :             }
     684         [ #  # ]:          0 :         }
     685                 :            : 
     686                 :            :         // restore selection and expand states
     687         [ #  # ]:          0 :         pEntry = static_cast<CustomAnimationListEntry*>(First());
     688                 :            : 
     689         [ #  # ]:          0 :         while( pEntry )
     690                 :            :         {
     691         [ #  # ]:          0 :             CustomAnimationEffectPtr pEffect( pEntry->getEffect() );
     692         [ #  # ]:          0 :             if( pEffect.get() )
     693                 :            :             {
     694 [ #  # ][ #  # ]:          0 :                 if( std::find( aExpanded.begin(), aExpanded.end(), pEffect ) != aExpanded.end() )
     695         [ #  # ]:          0 :                     Expand( pEntry );
     696                 :            : 
     697 [ #  # ][ #  # ]:          0 :                 if( std::find( aSelected.begin(), aSelected.end(), pEffect ) != aSelected.end() )
     698         [ #  # ]:          0 :                     Select( pEntry );
     699                 :            : 
     700 [ #  # ][ #  # ]:          0 :                 if( pEffect == pFirstSelEffect )
     701         [ #  # ]:          0 :                     nFirstSelNew = GetAbsPos( pEntry );
     702                 :            : 
     703 [ #  # ][ #  # ]:          0 :                 if( pEffect == pLastSelEffect )
     704         [ #  # ]:          0 :                     nLastSelNew = GetAbsPos( pEntry );
     705                 :            :             }
     706                 :            : 
     707         [ #  # ]:          0 :             pEntry = static_cast<CustomAnimationListEntry*>(Next( pEntry ));
     708         [ #  # ]:          0 :         }
     709                 :            : 
     710                 :            :         // Scroll to a selected entry, depending on where the selection moved.
     711                 :          0 :         bMoved = nFirstSelNew != nFirstSelOld;
     712                 :          0 :         bMovedUp = nFirstSelNew < nFirstSelOld;
     713                 :          0 :         bMovedDown = nFirstSelNew > nFirstSelOld;
     714                 :            : 
     715 [ #  # ][ #  # ]:          0 :         if( bMoved && nLastSelOld < nFirstVis && nLastSelNew < nFirstVis )
                 [ #  # ]
     716                 :            :         {
     717                 :            :             // The selection is above the visible area.
     718                 :            :             // Scroll up to show the last few selected entries.
     719         [ #  # ]:          0 :             if( nLastSelNew - (nLastVis - nFirstVis) > nFirstSelNew)
     720                 :            :             {
     721                 :            :                 // The entries in the selection range can't fit in view.
     722                 :            :                 // Scroll so the last selected entry is last in view.
     723         [ #  # ]:          0 :                 ScrollToAbsPos( nLastSelNew - (nLastVis - nFirstVis) );
     724                 :            :             }
     725                 :            :             else
     726         [ #  # ]:          0 :                 ScrollToAbsPos( nFirstSelNew );
     727                 :            :         }
     728 [ #  # ][ #  # ]:          0 :         else if( bMoved && nFirstSelOld > nLastVis && nFirstSelNew > nLastVis )
                 [ #  # ]
     729                 :            :         {
     730                 :            :             // The selection is below the visible area.
     731                 :            :             // Scroll down to the first few selected entries.
     732         [ #  # ]:          0 :             ScrollToAbsPos( nFirstSelNew );
     733                 :            :         }
     734 [ #  # ][ #  # ]:          0 :         else if( bMovedUp && nFirstSelOld <= nFirstVis )
     735                 :            :         {
     736                 :            :             // A visible entry has moved up out of view; scroll up one.
     737         [ #  # ]:          0 :             ScrollToAbsPos( nFirstVis - 1 );
     738                 :            :         }
     739 [ #  # ][ #  # ]:          0 :         else if( bMovedDown && nLastSelOld >= nLastVis )
     740                 :            :         {
     741                 :            :             // An entry has moved down out of view; scroll down one.
     742         [ #  # ]:          0 :             ScrollToAbsPos( nFirstVis + 1 );
     743                 :            :         }
     744         [ #  # ]:          0 :         else if ( nFirstVis != -1 )
     745                 :            :         {
     746                 :            :             // The selection is still in view, or it hasn't moved.
     747         [ #  # ]:          0 :             ScrollToAbsPos( nFirstVis );
     748                 :            :         }
     749                 :            :     }
     750                 :            : 
     751                 :          0 :     mbIgnorePaint = false;
     752         [ #  # ]:          0 :     SetUpdateMode( sal_True );
     753 [ #  # ][ #  # ]:          0 :     Invalidate();
                 [ #  # ]
     754                 :          0 : }
     755                 :            : 
     756                 :            : // --------------------------------------------------------------------
     757                 :            : 
     758                 :          0 : void CustomAnimationList::append( CustomAnimationEffectPtr pEffect )
     759                 :            : {
     760                 :            :     // create a ui description
     761                 :          0 :     OUString aDescription;
     762                 :            : 
     763                 :          0 :     Any aTarget( pEffect->getTarget() );
     764         [ #  # ]:          0 :     if( aTarget.hasValue() ) try
     765                 :            :     {
     766         [ #  # ]:          0 :         aDescription = getDescription( aTarget, pEffect->getTargetSubItem() != ShapeAnimationSubType::ONLY_BACKGROUND );
     767                 :            : 
     768                 :          0 :         SvLBoxEntry* pParentEntry = 0;
     769                 :            : 
     770         [ #  # ]:          0 :         Reference< XShape > xTargetShape( pEffect->getTargetShape() );
     771                 :          0 :         sal_Int32 nGroupId = pEffect->getGroupId();
     772                 :            : 
     773                 :            :         // if this effect has the same target and group-id as the last root effect,
     774                 :            :         // the last root effect is also this effects parent
     775 [ #  # ][ #  # ]:          0 :         if( mpLastParentEntry && (nGroupId != -1) && (mxLastTargetShape == xTargetShape) && (mnLastGroupId == nGroupId) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     776                 :          0 :             pParentEntry = mpLastParentEntry;
     777                 :            : 
     778                 :            :         // create an entry for the effect
     779 [ #  # ][ #  # ]:          0 :         SvLBoxEntry* pEntry = new CustomAnimationListEntry( pEffect );
         [ #  # ][ #  # ]
     780                 :            : 
     781 [ #  # ][ #  # ]:          0 :         pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), 0));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     782 [ #  # ][ #  # ]:          0 :         pEntry->AddItem( new CustomAnimationListEntryItem( pEntry, 0, aDescription, pEffect, this ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     783                 :            : 
     784         [ #  # ]:          0 :         if( pParentEntry )
     785                 :            :         {
     786                 :            :             // add a subentry
     787         [ #  # ]:          0 :             Insert( pEntry, pParentEntry );
     788                 :            :         }
     789                 :            :         else
     790                 :            :         {
     791                 :            :             // add a root entry
     792         [ #  # ]:          0 :             Insert( pEntry );
     793                 :            : 
     794                 :            :             // and the new root entry becomes the possible next group header
     795         [ #  # ]:          0 :             mxLastTargetShape = xTargetShape;
     796                 :          0 :             mnLastGroupId = nGroupId;
     797                 :          0 :             mpLastParentEntry = pEntry;
     798         [ #  # ]:          0 :         }
     799                 :            :     }
     800         [ #  # ]:          0 :     catch( Exception& )
     801                 :            :     {
     802                 :            :         OSL_FAIL("sd::CustomAnimationList::append(), exception caught!" );
     803                 :          0 :     }
     804                 :          0 : }
     805                 :            : 
     806                 :            : // --------------------------------------------------------------------
     807                 :            : 
     808                 :          0 : void selectShape( SvTreeListBox* pTreeList, Reference< XShape > xShape )
     809                 :            : {
     810                 :          0 :     CustomAnimationListEntry* pEntry = static_cast< CustomAnimationListEntry* >(pTreeList->First());
     811         [ #  # ]:          0 :     while( pEntry )
     812                 :            :     {
     813         [ #  # ]:          0 :         CustomAnimationEffectPtr pEffect( pEntry->getEffect() );
     814         [ #  # ]:          0 :         if( pEffect.get() )
     815                 :            :         {
     816 [ #  # ][ #  # ]:          0 :             if( pEffect->getTarget() == xShape )
     817         [ #  # ]:          0 :                 pTreeList->Select( pEntry );
     818                 :            :         }
     819                 :            : 
     820         [ #  # ]:          0 :         pEntry = static_cast< CustomAnimationListEntry* >(pTreeList->Next( pEntry ));
     821         [ #  # ]:          0 :     }
     822                 :          0 : }
     823                 :            : 
     824                 :            : // --------------------------------------------------------------------
     825                 :            : 
     826                 :          0 : void CustomAnimationList::onSelectionChanged( Any aSelection )
     827                 :            : {
     828                 :            :     try
     829                 :            :     {
     830         [ #  # ]:          0 :         SelectAll(sal_False);
     831                 :            : 
     832         [ #  # ]:          0 :         if( aSelection.hasValue() )
     833                 :            :         {
     834         [ #  # ]:          0 :             Reference< XIndexAccess > xShapes( aSelection, UNO_QUERY );
     835         [ #  # ]:          0 :             if( xShapes.is() )
     836                 :            :             {
     837 [ #  # ][ #  # ]:          0 :                 sal_Int32 nCount = xShapes->getCount();
     838                 :            :                 sal_Int32 nIndex;
     839         [ #  # ]:          0 :                 for( nIndex = 0; nIndex < nCount; nIndex++ )
     840                 :            :                 {
     841 [ #  # ][ #  # ]:          0 :                     Reference< XShape > xShape( xShapes->getByIndex( nIndex ), UNO_QUERY );
                 [ #  # ]
     842         [ #  # ]:          0 :                     if( xShape.is() )
     843         [ #  # ]:          0 :                         selectShape( this, xShape );
     844                 :          0 :                 }
     845                 :            :             }
     846                 :            :             else
     847                 :            :             {
     848         [ #  # ]:          0 :                 Reference< XShape > xShape( aSelection, UNO_QUERY );
     849         [ #  # ]:          0 :                 if( xShape.is() )
     850         [ #  # ]:          0 :                     selectShape( this, xShape );
     851         [ #  # ]:          0 :             }
     852                 :            :         }
     853                 :            : 
     854         [ #  # ]:          0 :         SelectHdl();
     855                 :            :     }
     856                 :          0 :     catch( Exception& )
     857                 :            :     {
     858                 :            :         OSL_FAIL( "sd::CustomAnimationList::onSelectionChanged(), Exception caught!" );
     859                 :            :     }
     860                 :          0 : }
     861                 :            : 
     862                 :            : // --------------------------------------------------------------------
     863                 :            : 
     864                 :          0 : void CustomAnimationList::SelectHdl()
     865                 :            : {
     866         [ #  # ]:          0 :     if( mbIgnorePaint )
     867                 :          0 :         return;
     868                 :          0 :     SvTreeListBox::SelectHdl();
     869                 :          0 :     mpController->onSelect();
     870                 :            : }
     871                 :            : 
     872                 :            : // --------------------------------------------------------------------
     873                 :            : 
     874                 :          0 : bool CustomAnimationList::isExpanded( const CustomAnimationEffectPtr& pEffect ) const
     875                 :            : {
     876                 :          0 :     CustomAnimationListEntry* pEntry = static_cast<CustomAnimationListEntry*>(First());
     877                 :            : 
     878         [ #  # ]:          0 :     while( pEntry )
     879                 :            :     {
     880 [ #  # ][ #  # ]:          0 :         if( pEntry->getEffect() == pEffect )
     881                 :          0 :             break;
     882                 :            : 
     883                 :          0 :         pEntry = static_cast<CustomAnimationListEntry*>(Next( pEntry ));
     884                 :            :     }
     885                 :            : 
     886         [ #  # ]:          0 :     if( pEntry )
     887                 :          0 :         pEntry = static_cast<CustomAnimationListEntry*>(GetParent( pEntry ));
     888                 :            : 
     889 [ #  # ][ #  # ]:          0 :     return (pEntry == 0) || IsExpanded( pEntry );
     890                 :            : }
     891                 :            : 
     892                 :            : // --------------------------------------------------------------------
     893                 :          0 : EffectSequence CustomAnimationList::getSelection() const
     894                 :            : {
     895                 :          0 :     EffectSequence aSelection;
     896                 :            : 
     897 [ #  # ][ #  # ]:          0 :     CustomAnimationListEntry* pEntry = dynamic_cast< CustomAnimationListEntry* >(FirstSelected());
     898         [ #  # ]:          0 :     while( pEntry )
     899                 :            :     {
     900         [ #  # ]:          0 :         CustomAnimationEffectPtr pEffect( pEntry->getEffect() );
     901         [ #  # ]:          0 :         if( pEffect.get() )
     902         [ #  # ]:          0 :             aSelection.push_back( pEffect );
     903                 :            : 
     904                 :            :         // if the selected effect is not expanded and has children
     905                 :            :         // we say that the children are automaticly selected
     906 [ #  # ][ #  # ]:          0 :         if( !IsExpanded( pEntry ) )
     907                 :            :         {
     908 [ #  # ][ #  # ]:          0 :             CustomAnimationListEntry* pChild = dynamic_cast< CustomAnimationListEntry* >( FirstChild( pEntry ) );
     909         [ #  # ]:          0 :             while( pChild )
     910                 :            :             {
     911 [ #  # ][ #  # ]:          0 :                 if( !IsSelected( pChild ) )
     912                 :            :                 {
     913         [ #  # ]:          0 :                     CustomAnimationEffectPtr pChildEffect( pChild->getEffect() );
     914         [ #  # ]:          0 :                     if( pChildEffect.get() )
     915 [ #  # ][ #  # ]:          0 :                         aSelection.push_back( pChildEffect );
     916                 :            :                 }
     917                 :            : 
     918 [ #  # ][ #  # ]:          0 :                 pChild = dynamic_cast< CustomAnimationListEntry* >(  NextSibling( pChild ) );
     919                 :            :             }
     920                 :            :         }
     921                 :            : 
     922         [ #  # ]:          0 :         pEntry = static_cast< CustomAnimationListEntry* >(NextSelected( pEntry ));
     923         [ #  # ]:          0 :     }
     924                 :            : 
     925                 :          0 :     return aSelection;
     926                 :            : }
     927                 :            : 
     928                 :            : // --------------------------------------------------------------------
     929                 :            : 
     930                 :          0 : sal_Bool CustomAnimationList::DoubleClickHdl()
     931                 :            : {
     932                 :          0 :     mpController->onDoubleClick();
     933                 :          0 :     return false;
     934                 :            : }
     935                 :            : 
     936                 :            : // --------------------------------------------------------------------
     937                 :            : 
     938                 :          0 : PopupMenu* CustomAnimationList::CreateContextMenu()
     939                 :            : {
     940 [ #  # ][ #  # ]:          0 :     PopupMenu* pMenu = new PopupMenu(SdResId( RID_EFFECT_CONTEXTMENU ));
     941                 :            : 
     942                 :          0 :     sal_Int16 nNodeType = -1;
     943                 :          0 :     sal_Int16 nEntries = 0;
     944                 :            : 
     945                 :          0 :     CustomAnimationListEntry* pEntry = static_cast< CustomAnimationListEntry* >(FirstSelected());
     946         [ #  # ]:          0 :     while( pEntry )
     947                 :            :     {
     948                 :          0 :         nEntries++;
     949         [ #  # ]:          0 :         CustomAnimationEffectPtr pEffect( pEntry->getEffect() );
     950         [ #  # ]:          0 :         if( pEffect.get() )
     951                 :            :         {
     952         [ #  # ]:          0 :             if( nNodeType == -1 )
     953                 :            :             {
     954                 :          0 :                 nNodeType = pEffect->getNodeType();
     955                 :            :             }
     956                 :            :             else
     957                 :            :             {
     958         [ #  # ]:          0 :                 if( nNodeType != pEffect->getNodeType() )
     959                 :            :                 {
     960                 :          0 :                     nNodeType = -1;
     961                 :            :                     break;
     962                 :            :                 }
     963                 :            :             }
     964                 :            :         }
     965                 :            : 
     966 [ #  # ][ #  # ]:          0 :         pEntry = static_cast< CustomAnimationListEntry* >(NextSelected( pEntry ));
     967         [ #  # ]:          0 :     }
     968                 :            : 
     969                 :          0 :     pMenu->CheckItem( CM_WITH_CLICK, nNodeType == EffectNodeType::ON_CLICK );
     970                 :          0 :     pMenu->CheckItem( CM_WITH_PREVIOUS, nNodeType == EffectNodeType::WITH_PREVIOUS );
     971                 :          0 :     pMenu->CheckItem( CM_AFTER_PREVIOUS, nNodeType == EffectNodeType::AFTER_PREVIOUS );
     972                 :          0 :     pMenu->EnableItem( CM_OPTIONS, nEntries == 1 );
     973                 :          0 :     pMenu->EnableItem( CM_DURATION, nEntries == 1 );
     974                 :            : 
     975                 :          0 :     return pMenu;
     976                 :            : }
     977                 :            : 
     978                 :            : // --------------------------------------------------------------------
     979                 :            : 
     980                 :          0 : void CustomAnimationList::ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry )
     981                 :            : {
     982                 :          0 :     mpController->onContextMenu( nSelectedPopupEntry );
     983                 :          0 : }
     984                 :            : 
     985                 :            : // --------------------------------------------------------------------
     986                 :            : 
     987                 :          0 : void CustomAnimationList::SetTabs()
     988                 :            : {
     989                 :          0 :     SvTreeListBox::SetTabs();
     990                 :          0 : }
     991                 :            : 
     992                 :            : // --------------------------------------------------------------------
     993                 :            : 
     994                 :          0 : void CustomAnimationList::notify_change()
     995                 :            : {
     996                 :          0 :     update();
     997                 :          0 :     mpController->onSelect();
     998                 :          0 : }
     999                 :            : 
    1000                 :          0 : void CustomAnimationList::Paint( const Rectangle& rRect )
    1001                 :            : {
    1002         [ #  # ]:          0 :     if( mbIgnorePaint )
    1003                 :          0 :         return;
    1004                 :            : 
    1005                 :          0 :     SvTreeListBox::Paint( rRect );
    1006                 :            : 
    1007                 :            :     // draw help text if list box is still empty
    1008         [ #  # ]:          0 :     if( First() == 0 )
    1009                 :            :     {
    1010                 :          0 :         Color aOldColor( GetTextColor() );
    1011         [ #  # ]:          0 :         SetTextColor( GetSettings().GetStyleSettings().GetDisableColor() );
    1012 [ #  # ][ #  # ]:          0 :         ::Point aOffset( LogicToPixel( Point( 6, 6 ), MAP_APPFONT ) );
                 [ #  # ]
    1013                 :            : 
    1014 [ #  # ][ #  # ]:          0 :         Rectangle aRect( Point( 0,0 ), GetOutputSizePixel() );
    1015                 :            : 
    1016                 :          0 :         aRect.Left() += aOffset.X();
    1017                 :          0 :         aRect.Top() += aOffset.Y();
    1018                 :          0 :         aRect.Right() -= aOffset.X();
    1019                 :          0 :         aRect.Bottom() -= aOffset.Y();
    1020                 :            : 
    1021                 :            :         DrawText( aRect, String( SdResId( STR_CUSTOMANIMATION_LIST_HELPTEXT ) ),
    1022 [ #  # ][ #  # ]:          0 :             TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK | TEXT_DRAW_CENTER | TEXT_DRAW_VCENTER );
         [ #  # ][ #  # ]
    1023                 :            : 
    1024         [ #  # ]:          0 :         SetTextColor( aOldColor );
    1025                 :            :     }
    1026                 :            : }
    1027                 :            : 
    1028                 :            : }
    1029                 :            : 
    1030                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10