LCOV - code coverage report
Current view: top level - sd/source/ui/animations - CustomAnimationCreateDialog.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 308 0.0 %
Date: 2012-08-25 Functions: 0 44 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 547 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                 :            : 
      30                 :            : #include <com/sun/star/i18n/XCollator.hpp>
      31                 :            : 
      32                 :            : #include <comphelper/processfactory.hxx>
      33                 :            : #include <vcl/svapp.hxx>
      34                 :            : #include <vcl/tabctrl.hxx>
      35                 :            : #include <vcl/tabpage.hxx>
      36                 :            : 
      37                 :            : #include <vcl/button.hxx>
      38                 :            : #include <vcl/fixed.hxx>
      39                 :            : #include <vcl/lstbox.hxx>
      40                 :            : #include <vcl/combobox.hxx>
      41                 :            : 
      42                 :            : #include <svx/svdetc.hxx>
      43                 :            : #include <svx/svdstr.hrc>
      44                 :            : #include "sdresid.hxx"
      45                 :            : #include <unotools/viewoptions.hxx>
      46                 :            : #include <com/sun/star/presentation/EffectNodeType.hpp>
      47                 :            : #include "CustomAnimationCreateDialog.hxx"
      48                 :            : #include "CustomAnimationCreateDialog.hrc"
      49                 :            : #include "CustomAnimation.hrc"
      50                 :            : #include "CustomAnimationPane.hxx"
      51                 :            : #include "optsitem.hxx"
      52                 :            : #include "sddll.hxx"
      53                 :            : #include "sdmod.hxx"
      54                 :            : 
      55                 :            : #include "helpids.h"
      56                 :            : 
      57                 :            : using namespace ::com::sun::star;
      58                 :            : 
      59                 :            : using ::rtl::OUString;
      60                 :            : using ::com::sun::star::uno::UNO_QUERY;
      61                 :            : using ::com::sun::star::uno::UNO_QUERY_THROW;
      62                 :            : using ::com::sun::star::uno::Any;
      63                 :            : using ::com::sun::star::uno::Reference;
      64                 :            : using ::com::sun::star::uno::Exception;
      65                 :            : 
      66                 :            : using namespace ::com::sun::star::presentation;
      67                 :            : 
      68                 :            : namespace sd {
      69                 :            : 
      70                 :            : 
      71                 :            : const int ENTRANCE = 0;
      72                 :            : const int EMPHASIS = 1;
      73                 :            : const int EXIT = 2;
      74                 :            : const int MOTIONPATH = 3;
      75                 :            : const int MISCEFFECTS = 4;
      76                 :            : 
      77                 :            : extern void fillDurationComboBox( ComboBox* pBox );
      78                 :            : 
      79                 :            : // --------------------------------------------------------------------
      80                 :            : 
      81                 :            : class CategoryListBox : public ListBox
      82                 :            : {
      83                 :            : public:
      84                 :            :     CategoryListBox( Window* pParent, const ResId& rResId );
      85                 :            :     ~CategoryListBox();
      86                 :            : 
      87                 :            :     virtual void        MouseButtonUp( const MouseEvent& rMEvt );
      88                 :            : 
      89                 :            :     sal_uInt16          InsertCategory( const XubString& rStr, sal_uInt16 nPos = LISTBOX_APPEND );
      90                 :            : 
      91                 :          0 :     void            SetDoubleClickLink( const Link& rDoubleClickHdl ) { maDoubleClickHdl = rDoubleClickHdl; }
      92                 :            : 
      93                 :            :     DECL_LINK(implDoubleClickHdl, void *);
      94                 :            : 
      95                 :            : private:
      96                 :            :     virtual void    UserDraw( const UserDrawEvent& rUDEvt );
      97                 :            : 
      98                 :            :     Link            maDoubleClickHdl;
      99                 :            : };
     100                 :            : 
     101                 :          0 : CategoryListBox::CategoryListBox( Window* pParent, const ResId& rResId )
     102         [ #  # ]:          0 : : ListBox( pParent, rResId )
     103                 :            : {
     104         [ #  # ]:          0 :     EnableUserDraw( sal_True );
     105         [ #  # ]:          0 :     SetDoubleClickHdl( LINK( this, CategoryListBox, implDoubleClickHdl ) );
     106                 :          0 : }
     107                 :            : 
     108                 :          0 : CategoryListBox::~CategoryListBox()
     109                 :            : {
     110         [ #  # ]:          0 : }
     111                 :            : 
     112                 :          0 : sal_uInt16 CategoryListBox::InsertCategory( const XubString& rStr, sal_uInt16 nPos /* = LISTBOX_APPEND */ )
     113                 :            : {
     114                 :          0 :     sal_uInt16 n = ListBox::InsertEntry( rStr, nPos );
     115         [ #  # ]:          0 :     if( n != LISTBOX_ENTRY_NOTFOUND )
     116                 :          0 :         ListBox::SetEntryFlags( n, ListBox::GetEntryFlags(n) | LISTBOX_ENTRY_FLAG_DISABLE_SELECTION );
     117                 :            : 
     118                 :          0 :     return n;
     119                 :            : }
     120                 :            : 
     121                 :          0 : void CategoryListBox::UserDraw( const UserDrawEvent& rUDEvt )
     122                 :            : {
     123                 :          0 :     const sal_uInt16 nItem = rUDEvt.GetItemId();
     124                 :            : 
     125         [ #  # ]:          0 :     if( ListBox::GetEntryFlags(nItem) & LISTBOX_ENTRY_FLAG_DISABLE_SELECTION )
     126                 :            :     {
     127                 :          0 :         Rectangle aOutRect( rUDEvt.GetRect() );
     128                 :          0 :         OutputDevice* pDev = rUDEvt.GetDevice();
     129                 :            : 
     130                 :            :         // fill the background
     131                 :          0 :         Color aColor (GetSettings().GetStyleSettings().GetDialogColor());
     132                 :            : 
     133         [ #  # ]:          0 :         pDev->SetFillColor (aColor);
     134         [ #  # ]:          0 :         pDev->SetLineColor ();
     135         [ #  # ]:          0 :         pDev->DrawRect(aOutRect);
     136                 :            : 
     137                 :            :         // Erase the four corner pixels to make the rectangle appear rounded.
     138         [ #  # ]:          0 :         pDev->SetLineColor( GetSettings().GetStyleSettings().GetWindowColor());
     139         [ #  # ]:          0 :         pDev->DrawPixel( aOutRect.TopLeft());
     140         [ #  # ]:          0 :         pDev->DrawPixel( Point(aOutRect.Right(), aOutRect.Top()));
     141         [ #  # ]:          0 :         pDev->DrawPixel( Point(aOutRect.Left(), aOutRect.Bottom()));
     142         [ #  # ]:          0 :         pDev->DrawPixel( Point(aOutRect.Right(), aOutRect.Bottom()));
     143                 :            : 
     144                 :            :         // draw the category title
     145 [ #  # ][ #  # ]:          0 :         pDev->DrawText (aOutRect, GetEntry(nItem), TEXT_DRAW_CENTER );
                 [ #  # ]
     146                 :            :     }
     147                 :            :     else
     148                 :            :     {
     149                 :          0 :         DrawEntry( rUDEvt, sal_True, sal_True );
     150                 :            :     }
     151                 :          0 : }
     152                 :            : 
     153                 :            : // --------------------------------------------------------------------
     154                 :            : 
     155                 :          0 : IMPL_LINK_NOARG(CategoryListBox, implDoubleClickHdl)
     156                 :            : {
     157                 :          0 :     CaptureMouse();
     158                 :          0 :     return 0;
     159                 :            : }
     160                 :            : 
     161                 :            : // --------------------------------------------------------------------
     162                 :            : 
     163                 :          0 : void CategoryListBox::MouseButtonUp( const MouseEvent& rMEvt )
     164                 :            : {
     165                 :          0 :     ReleaseMouse();
     166 [ #  # ][ #  # ]:          0 :     if( rMEvt.IsLeft() && (rMEvt.GetClicks() == 2) )
                 [ #  # ]
     167                 :            :     {
     168         [ #  # ]:          0 :         if( maDoubleClickHdl.IsSet() )
     169                 :          0 :             maDoubleClickHdl.Call( this );
     170                 :            :     }
     171                 :            :     else
     172                 :            :     {
     173                 :          0 :         ListBox::MouseButtonUp( rMEvt );
     174                 :            :     }
     175                 :          0 : }
     176                 :            : 
     177                 :            : // --------------------------------------------------------------------
     178                 :            : 
     179                 :            : class CustomAnimationCreateTabPage : public TabPage
     180                 :            : {
     181                 :            : public:
     182                 :            :     CustomAnimationCreateTabPage( Window* pParent, CustomAnimationCreateDialog* pDialogParent, int nTabId, const PresetCategoryList& rCategoryList, bool bHasText );
     183                 :            :     ~CustomAnimationCreateTabPage();
     184                 :            : 
     185                 :            :     PathKind getCreatePathKind() const;
     186                 :            :     CustomAnimationPresetPtr getSelectedPreset() const;
     187                 :            :     double getDuration() const;
     188                 :            :     void setDuration( double fDuration );
     189                 :            : 
     190                 :            :     bool getIsPreview() const;
     191                 :            :     void setIsPreview( bool bIsPreview );
     192                 :            : 
     193                 :            :     bool select( const OUString& rsPresetId );
     194                 :            : 
     195                 :            : private:
     196                 :            :     DECL_LINK( implSelectHdl, Control* );
     197                 :            :     DECL_LINK( implDoubleClickHdl, Control* );
     198                 :            : 
     199                 :            :     void onSelectEffect();
     200                 :            : 
     201                 :            :     void clearEffects();
     202                 :            : 
     203                 :            : private:
     204                 :            :     CategoryListBox*    mpLBEffects;
     205                 :            :     FixedText*  mpFTSpeed;
     206                 :            :     ComboBox*   mpCBSpeed;
     207                 :            :     CheckBox*   mpCBXPReview;
     208                 :            : 
     209                 :            :     CustomAnimationCreateDialog*        mpParent;
     210                 :            : 
     211                 :            :     sal_uInt16 mnCurvePathPos;
     212                 :            :     sal_uInt16 mnPolygonPathPos;
     213                 :            :     sal_uInt16 mnFreeformPathPos;
     214                 :            : 
     215                 :            : };
     216                 :            : 
     217                 :          0 : struct ImplStlEffectCategorySortHelper
     218                 :            : {
     219                 :            :     ImplStlEffectCategorySortHelper();
     220                 :            :     bool operator()( const CustomAnimationPresetPtr& p1, const CustomAnimationPresetPtr& p2 );
     221                 :            : 
     222                 :            : private:
     223                 :            :     uno::Reference< i18n::XCollator > mxCollator;
     224                 :            : };
     225                 :            : 
     226                 :          0 : ImplStlEffectCategorySortHelper::ImplStlEffectCategorySortHelper()
     227                 :            : {
     228         [ #  # ]:          0 :     uno::Reference<lang::XMultiServiceFactory> xFac( ::comphelper::getProcessServiceFactory() );
     229         [ #  # ]:          0 :     if( xFac.is() )
     230                 :            :     {
     231 [ #  # ][ #  # ]:          0 :         mxCollator.set( xFac->createInstance( "com.sun.star.i18n.Collator" ), uno::UNO_QUERY );
                 [ #  # ]
     232                 :            : 
     233         [ #  # ]:          0 :         if( mxCollator.is() )
     234                 :            :         {
     235 [ #  # ][ #  # ]:          0 :             const lang::Locale& rLocale = Application::GetSettings().GetLocale();
     236 [ #  # ][ #  # ]:          0 :             mxCollator->loadDefaultCollator(rLocale, 0);
     237                 :            :         }
     238                 :          0 :     }
     239                 :          0 : }
     240                 :            : 
     241                 :          0 : bool ImplStlEffectCategorySortHelper::operator()( const CustomAnimationPresetPtr& p1, const CustomAnimationPresetPtr& p2 )
     242                 :            : {
     243 [ #  # ][ #  # ]:          0 :     return mxCollator.is() ? mxCollator->compareString(p1->getLabel(), p2->getLabel()) == -1 : false;
     244                 :            : }
     245                 :            : 
     246                 :          0 : CustomAnimationCreateTabPage::CustomAnimationCreateTabPage( Window* pParent, CustomAnimationCreateDialog* pDialogParent, int nTabId, const PresetCategoryList& rCategoryList, bool bHasText )
     247                 :            : : TabPage( pParent, SdResId( RID_TP_CUSTOMANIMATION_ENTRANCE ) )
     248                 :            : , mpParent( pDialogParent )
     249                 :            : , mnCurvePathPos( LISTBOX_ENTRY_NOTFOUND )
     250                 :            : , mnPolygonPathPos( LISTBOX_ENTRY_NOTFOUND )
     251         [ #  # ]:          0 : , mnFreeformPathPos( LISTBOX_ENTRY_NOTFOUND )
     252                 :            : {
     253 [ #  # ][ #  # ]:          0 :     mpLBEffects = new CategoryListBox( this, SdResId( LB_EFFECTS ) );
                 [ #  # ]
     254 [ #  # ][ #  # ]:          0 :     mpFTSpeed = new FixedText( this, SdResId( FT_SPEED ) );
                 [ #  # ]
     255 [ #  # ][ #  # ]:          0 :     mpCBSpeed = new ComboBox( this, SdResId( CB_SPEED ) );
                 [ #  # ]
     256 [ #  # ][ #  # ]:          0 :     mpCBXPReview = new CheckBox( this, SdResId( CBX_PREVIEW ) );
                 [ #  # ]
     257                 :            : 
     258 [ #  # ][ #  # ]:          0 :     String sMotionPathLabel( SdResId( STR_USERPATH ) );
     259                 :            : 
     260         [ #  # ]:          0 :     FreeResource();
     261                 :            : 
     262                 :          0 :     sal_uInt16 nFirstEffect = LISTBOX_ENTRY_NOTFOUND;
     263                 :            : 
     264         [ #  # ]:          0 :     if( nTabId == MOTIONPATH )
     265                 :            :     {
     266         [ #  # ]:          0 :         mpLBEffects->InsertCategory( sMotionPathLabel );
     267                 :            : 
     268 [ #  # ][ #  # ]:          0 :         mnCurvePathPos = nFirstEffect = mpLBEffects->InsertEntry( sdr::GetResourceString(STR_ObjNameSingulCOMBLINE) );
                 [ #  # ]
     269 [ #  # ][ #  # ]:          0 :         mnPolygonPathPos = mpLBEffects->InsertEntry( sdr::GetResourceString(STR_ObjNameSingulPOLY) );
                 [ #  # ]
     270 [ #  # ][ #  # ]:          0 :         mnFreeformPathPos = mpLBEffects->InsertEntry( sdr::GetResourceString(STR_ObjNameSingulFREELINE) );
                 [ #  # ]
     271                 :            :     };
     272                 :            : 
     273                 :          0 :     PresetCategoryList::const_iterator aCategoryIter( rCategoryList.begin() );
     274                 :          0 :     const PresetCategoryList::const_iterator aCategoryEnd( rCategoryList.end() );
     275 [ #  # ][ #  # ]:          0 :     while( aCategoryIter != aCategoryEnd )
     276                 :            :     {
     277 [ #  # ][ #  # ]:          0 :         PresetCategoryPtr pCategory( *aCategoryIter++ );
     278         [ #  # ]:          0 :         if( pCategory.get() )
     279                 :            :         {
     280 [ #  # ][ #  # ]:          0 :             mpLBEffects->InsertCategory( pCategory->maLabel );
                 [ #  # ]
     281                 :            : 
     282         [ #  # ]:          0 :             std::vector< CustomAnimationPresetPtr > aSortedVector(pCategory->maEffects.size());
     283         [ #  # ]:          0 :             std::copy( pCategory->maEffects.begin(), pCategory->maEffects.end(), aSortedVector.begin() );
     284         [ #  # ]:          0 :             ImplStlEffectCategorySortHelper aSortHelper;
     285 [ #  # ][ #  # ]:          0 :             std::sort( aSortedVector.begin(), aSortedVector.end(), aSortHelper );
                 [ #  # ]
     286                 :            : 
     287         [ #  # ]:          0 :             std::vector< CustomAnimationPresetPtr >::const_iterator aIter( aSortedVector.begin() );
     288         [ #  # ]:          0 :             const std::vector< CustomAnimationPresetPtr >::const_iterator aEnd( aSortedVector.end() );
     289 [ #  # ][ #  # ]:          0 :             while( aIter != aEnd )
     290                 :            :             {
     291 [ #  # ][ #  # ]:          0 :                 CustomAnimationPresetPtr pDescriptor = (*aIter++);
     292 [ #  # ][ #  # ]:          0 :                 if( pDescriptor.get() && (bHasText || !pDescriptor->isTextOnly() ) )
         [ #  # ][ #  # ]
     293                 :            :                 {
     294 [ #  # ][ #  # ]:          0 :                     sal_uInt16 nPos = mpLBEffects->InsertEntry( pDescriptor->getLabel() );
                 [ #  # ]
     295 [ #  # ][ #  # ]:          0 :                     mpLBEffects->SetEntryData( nPos, static_cast<void*>( new CustomAnimationPresetPtr( pDescriptor ) ) );
                 [ #  # ]
     296                 :            : 
     297         [ #  # ]:          0 :                     if( nFirstEffect == LISTBOX_ENTRY_NOTFOUND )
     298                 :          0 :                         nFirstEffect = nPos;
     299                 :            :                 }
     300 [ #  # ][ #  # ]:          0 :             }
     301                 :            :         }
     302         [ #  # ]:          0 :     }
     303                 :            : 
     304         [ #  # ]:          0 :     mpLBEffects->SelectEntryPos( nFirstEffect );
     305                 :            : 
     306         [ #  # ]:          0 :     fillDurationComboBox( mpCBSpeed );
     307                 :            : 
     308         [ #  # ]:          0 :     if( nFirstEffect != LISTBOX_ENTRY_NOTFOUND )
     309         [ #  # ]:          0 :         onSelectEffect();
     310                 :            : 
     311         [ #  # ]:          0 :     mpLBEffects->SetSelectHdl( LINK( this, CustomAnimationCreateTabPage, implSelectHdl ) );
     312 [ #  # ][ #  # ]:          0 :     mpLBEffects->SetDoubleClickLink( LINK( this, CustomAnimationCreateTabPage, implDoubleClickHdl ) );
     313                 :          0 : }
     314                 :            : 
     315                 :          0 : CustomAnimationCreateTabPage::~CustomAnimationCreateTabPage()
     316                 :            : {
     317         [ #  # ]:          0 :     clearEffects();
     318                 :            : 
     319 [ #  # ][ #  # ]:          0 :     delete mpLBEffects;
     320 [ #  # ][ #  # ]:          0 :     delete mpFTSpeed;
     321 [ #  # ][ #  # ]:          0 :     delete mpCBSpeed;
     322 [ #  # ][ #  # ]:          0 :     delete mpCBXPReview;
     323         [ #  # ]:          0 : }
     324                 :            : 
     325                 :          0 : IMPL_LINK( CustomAnimationCreateTabPage, implSelectHdl, Control*, pControl )
     326                 :            : {
     327         [ #  # ]:          0 :     if( pControl == mpLBEffects )
     328                 :          0 :         onSelectEffect();
     329                 :          0 :     return 0;
     330                 :            : }
     331                 :            : 
     332                 :          0 : IMPL_LINK( CustomAnimationCreateTabPage, implDoubleClickHdl, Control*, pControl )
     333                 :            : {
     334         [ #  # ]:          0 :     if( pControl == mpLBEffects )
     335                 :            :     {
     336         [ #  # ]:          0 :         if( mpLBEffects->GetSelectEntryCount() )
     337                 :          0 :             mpParent->EndDialog( sal_True );
     338                 :            :     }
     339                 :          0 :     return 0;
     340                 :            : }
     341                 :            : 
     342                 :          0 : void CustomAnimationCreateTabPage::onSelectEffect()
     343                 :            : {
     344 [ #  # ][ #  # ]:          0 :     CustomAnimationPresetPtr*p = static_cast< CustomAnimationPresetPtr* >( mpLBEffects->GetEntryData( mpLBEffects->GetSelectEntryPos() ) );
     345                 :            : 
     346         [ #  # ]:          0 :     if( !p )
     347                 :          0 :         return;
     348                 :            : 
     349         [ #  # ]:          0 :     CustomAnimationPresetPtr pPreset( *p );
     350                 :            : 
     351                 :          0 :     const double fDuration = pPreset->getDuration();
     352                 :          0 :     sal_uInt16 nPos = 0xffff;
     353                 :            : 
     354         [ #  # ]:          0 :     if( fDuration == 5.0 )
     355                 :          0 :         nPos = 0;
     356         [ #  # ]:          0 :     else if( fDuration == 3.0 )
     357                 :          0 :         nPos = 1;
     358         [ #  # ]:          0 :     else if( fDuration == 2.0 )
     359                 :          0 :         nPos = 2;
     360         [ #  # ]:          0 :     else if( fDuration == 1.0 )
     361                 :          0 :         nPos = 3;
     362         [ #  # ]:          0 :     else if( fDuration == 0.5 )
     363                 :          0 :         nPos = 4;
     364                 :            : 
     365         [ #  # ]:          0 :     mpCBSpeed->SelectEntryPos( nPos );
     366                 :            : 
     367                 :          0 :     bool bHasSpeed = pPreset->getDuration() > 0.001;
     368         [ #  # ]:          0 :     mpCBSpeed->Enable( bHasSpeed );
     369         [ #  # ]:          0 :     mpFTSpeed->Enable( bHasSpeed );
     370                 :            : 
     371 [ #  # ][ #  # ]:          0 :     if( mpCBXPReview->IsChecked() )
     372                 :            :     {
     373         [ #  # ]:          0 :         mpParent->preview( pPreset );
     374         [ #  # ]:          0 :     }
     375                 :            : }
     376                 :            : 
     377                 :          0 : void CustomAnimationCreateTabPage::clearEffects()
     378                 :            : {
     379                 :          0 :     sal_uInt16 nPos = mpLBEffects->GetEntryCount();
     380         [ #  # ]:          0 :     while( nPos-- )
     381         [ #  # ]:          0 :         delete static_cast< CustomAnimationPresetPtr* >( mpLBEffects->GetEntryData( nPos ) );
     382                 :            : 
     383                 :          0 :     mpLBEffects->Clear();
     384                 :          0 : }
     385                 :            : 
     386                 :          0 : CustomAnimationPresetPtr CustomAnimationCreateTabPage::getSelectedPreset() const
     387                 :            : {
     388                 :          0 :     CustomAnimationPresetPtr pPreset;
     389                 :            : 
     390 [ #  # ][ #  # ]:          0 :     if( mpLBEffects->GetSelectEntryCount() == 1 )
     391                 :            :     {
     392 [ #  # ][ #  # ]:          0 :         void* pEntryData = mpLBEffects->GetEntryData( mpLBEffects->GetSelectEntryPos() );
     393         [ #  # ]:          0 :         if( pEntryData )
     394         [ #  # ]:          0 :             pPreset = *static_cast< CustomAnimationPresetPtr* >( pEntryData );
     395                 :            :     }
     396                 :            : 
     397                 :          0 :     return pPreset;
     398                 :            : }
     399                 :            : 
     400                 :          0 : PathKind CustomAnimationCreateTabPage::getCreatePathKind() const
     401                 :            : {
     402                 :          0 :     PathKind eKind = NONE;
     403                 :            : 
     404         [ #  # ]:          0 :     if( mpLBEffects->GetSelectEntryCount() == 1 )
     405                 :            :     {
     406                 :          0 :         const sal_uInt16 nPos = mpLBEffects->GetSelectEntryPos();
     407         [ #  # ]:          0 :         if( nPos == mnCurvePathPos )
     408                 :            :         {
     409                 :          0 :             eKind = CURVE;
     410                 :            :         }
     411         [ #  # ]:          0 :         else if( nPos == mnPolygonPathPos )
     412                 :            :         {
     413                 :          0 :             eKind = POLYGON;
     414                 :            :         }
     415         [ #  # ]:          0 :         else if( nPos == mnFreeformPathPos )
     416                 :            :         {
     417                 :          0 :             eKind = FREEFORM;
     418                 :            :         }
     419                 :            :     }
     420                 :            : 
     421                 :          0 :     return eKind;
     422                 :            : }
     423                 :            : 
     424                 :            : 
     425                 :            : 
     426                 :          0 : double CustomAnimationCreateTabPage::getDuration() const
     427                 :            : {
     428                 :          0 :     sal_uInt16 nPos = mpCBSpeed->GetSelectEntryPos();
     429 [ #  # ][ #  # ]:          0 :     if( (nPos == 0xffff) || !mpCBSpeed->IsEnabled() )
                 [ #  # ]
     430                 :            :     {
     431         [ #  # ]:          0 :         CustomAnimationPresetPtr pPreset = getSelectedPreset();
     432         [ #  # ]:          0 :         if( pPreset.get() )
     433 [ #  # ][ #  # ]:          0 :             return pPreset->getDuration();
     434                 :            :     }
     435                 :            : 
     436   [ #  #  #  #  :          0 :     switch( nPos )
                   #  # ]
     437                 :            :     {
     438                 :          0 :     case 0: return 5.0f;
     439                 :          0 :     case 1: return 3.0f;
     440                 :          0 :     case 2: return 2.0f;
     441                 :          0 :     case 3: return 1.0f;
     442                 :          0 :     case 4: return 0.5f;
     443                 :            :     }
     444                 :            : 
     445                 :          0 :     return 0.0f;
     446                 :            : }
     447                 :            : 
     448                 :          0 : void CustomAnimationCreateTabPage::setDuration( double fDuration )
     449                 :            : {
     450                 :          0 :     sal_uInt16 nPos = 0;
     451         [ #  # ]:          0 :     if( fDuration < 2.0f )
     452                 :            :     {
     453         [ #  # ]:          0 :         if( fDuration < 1.0f )
     454                 :            :         {
     455                 :          0 :             nPos = 4;
     456                 :            :         }
     457                 :            :         else
     458                 :            :         {
     459                 :          0 :             nPos = 3;
     460                 :            :         }
     461                 :            :     }
     462         [ #  # ]:          0 :     else if( fDuration < 5.0f )
     463                 :            :     {
     464         [ #  # ]:          0 :         if( fDuration < 3.0f )
     465                 :            :         {
     466                 :          0 :             nPos = 2;
     467                 :            :         }
     468                 :            :         else
     469                 :            :         {
     470                 :          0 :             nPos = 1;
     471                 :            :         }
     472                 :            :     }
     473                 :            : 
     474                 :          0 :     mpCBSpeed->SelectEntryPos( nPos );
     475                 :          0 : }
     476                 :            : 
     477                 :          0 : bool CustomAnimationCreateTabPage::getIsPreview() const
     478                 :            : {
     479                 :          0 :     return mpCBXPReview->IsChecked() ? true : false;
     480                 :            : }
     481                 :            : 
     482                 :          0 : void CustomAnimationCreateTabPage::setIsPreview( bool bIsPreview )
     483                 :            : {
     484         [ #  # ]:          0 :     mpCBXPReview->Check( bIsPreview ? sal_True : sal_False );
     485                 :          0 : }
     486                 :            : 
     487                 :          0 : bool CustomAnimationCreateTabPage::select( const OUString& rsPresetId )
     488                 :            : {
     489                 :          0 :     sal_uInt16 nPos = mpLBEffects->GetEntryCount();
     490         [ #  # ]:          0 :     while( nPos-- )
     491                 :            :     {
     492                 :          0 :         void* pEntryData = mpLBEffects->GetEntryData( nPos );
     493         [ #  # ]:          0 :         if( pEntryData )
     494                 :            :         {
     495                 :          0 :             CustomAnimationPresetPtr& pPtr = *static_cast< CustomAnimationPresetPtr* >(pEntryData);
     496 [ #  # ][ #  # ]:          0 :             if( pPtr.get() && pPtr->getPresetId() == rsPresetId )
                 [ #  # ]
     497                 :            :             {
     498                 :          0 :                 mpLBEffects->SelectEntryPos( nPos );
     499                 :          0 :                 return true;
     500                 :            :             }
     501                 :            :         }
     502                 :            :     }
     503                 :            : 
     504                 :          0 :     return false;
     505                 :            : }
     506                 :            : 
     507                 :            : // --------------------------------------------------------------------
     508                 :            : 
     509                 :          0 : CustomAnimationCreateDialog::CustomAnimationCreateDialog( Window* pParent, CustomAnimationPane* pPane, const std::vector< ::com::sun::star::uno::Any >& rTargets, bool bHasText, const ::rtl::OUString& rsPresetId, double fDuration  )
     510                 :            : :   TabDialog( pParent, SdResId( DLG_CUSTOMANIMATION_CREATE ) )
     511                 :            : ,   mpPane( pPane )
     512                 :            : ,   mrTargets( rTargets )
     513         [ #  # ]:          0 : ,   mfDuration( fDuration )
     514                 :            : {
     515 [ #  # ][ #  # ]:          0 :     mpTabControl = new TabControl( this, SdResId( 1 ) );
                 [ #  # ]
     516 [ #  # ][ #  # ]:          0 :     mpOKButton = new OKButton(this, SdResId( 1 ) ) ;
                 [ #  # ]
     517 [ #  # ][ #  # ]:          0 :     mpCancelButton = new CancelButton(this, SdResId( 1 ) );
                 [ #  # ]
     518 [ #  # ][ #  # ]:          0 :     mpHelpButton = new HelpButton(this, SdResId( 1 ) );
                 [ #  # ]
     519                 :            : 
     520         [ #  # ]:          0 :     FreeResource();
     521                 :            : 
     522 [ #  # ][ #  # ]:          0 :     SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
     523         [ #  # ]:          0 :     mbIsPreview = pOptions->IsPreviewNewEffects();
     524                 :            : 
     525         [ #  # ]:          0 :     const CustomAnimationPresets& rPresets = CustomAnimationPresets::getCustomAnimationPresets();
     526 [ #  # ][ #  # ]:          0 :     mpTabPages[ENTRANCE] = new CustomAnimationCreateTabPage( mpTabControl, this, ENTRANCE, rPresets.getEntrancePresets(), bHasText );
     527         [ #  # ]:          0 :     mpTabPages[ENTRANCE]->SetHelpId( HID_SD_CUSTOMANIMATIONDIALOG_ENTRANCE );
     528         [ #  # ]:          0 :     mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_ENTRANCE, mpTabPages[ENTRANCE] );
     529 [ #  # ][ #  # ]:          0 :     mpTabPages[EMPHASIS] = new CustomAnimationCreateTabPage( mpTabControl, this, EMPHASIS, rPresets.getEmphasisPresets(), bHasText );
     530         [ #  # ]:          0 :     mpTabPages[EMPHASIS]->SetHelpId( HID_SD_CUSTOMANIMATIONDIALOG_EMPHASIS );
     531         [ #  # ]:          0 :     mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_EMPHASIS, mpTabPages[EMPHASIS] );
     532 [ #  # ][ #  # ]:          0 :     mpTabPages[EXIT] = new CustomAnimationCreateTabPage( mpTabControl, this, EXIT, rPresets.getExitPresets(), bHasText );
     533         [ #  # ]:          0 :     mpTabPages[EXIT]->SetHelpId( HID_SD_CUSTOMANIMATIONDIALOG_EXIT );
     534         [ #  # ]:          0 :     mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_EXIT, mpTabPages[EXIT] );
     535 [ #  # ][ #  # ]:          0 :     mpTabPages[MOTIONPATH] = new CustomAnimationCreateTabPage( mpTabControl, this, MOTIONPATH, rPresets.getMotionPathsPresets(), bHasText );
     536         [ #  # ]:          0 :     mpTabPages[MOTIONPATH]->SetHelpId( HID_SD_CUSTOMANIMATIONDIALOG_MOTIONPATH );
     537         [ #  # ]:          0 :     mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_MOTIONPATH, mpTabPages[MOTIONPATH] );
     538 [ #  # ][ #  # ]:          0 :     mpTabPages[MISCEFFECTS] = new CustomAnimationCreateTabPage( mpTabControl, this, MISCEFFECTS, rPresets.getMiscPresets(), bHasText );
     539         [ #  # ]:          0 :     mpTabPages[MISCEFFECTS]->SetHelpId( HID_SD_CUSTOMANIMATIONDIALOG_MISCEFFECTS );
     540         [ #  # ]:          0 :     mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_MISCEFFECTS, mpTabPages[MISCEFFECTS] );
     541                 :            : 
     542 [ #  # ][ #  # ]:          0 :     getCurrentPage()->setDuration( mfDuration );
     543 [ #  # ][ #  # ]:          0 :     getCurrentPage()->setIsPreview( mbIsPreview );
     544                 :            : 
     545         [ #  # ]:          0 :     mpTabControl->SetActivatePageHdl( LINK( this, CustomAnimationCreateDialog, implActivatePagekHdl ) );
     546         [ #  # ]:          0 :     mpTabControl->SetDeactivatePageHdl( LINK( this, CustomAnimationCreateDialog, implDeactivatePagekHdl ) );
     547                 :            : 
     548         [ #  # ]:          0 :     setPosition();
     549                 :            : 
     550                 :            :     // select current preset if available
     551         [ #  # ]:          0 :     if( !rsPresetId.isEmpty() )
     552                 :            :     {
     553         [ #  # ]:          0 :         for( sal_uInt16 i = ENTRANCE; i <= MOTIONPATH; i++ )
     554                 :            :         {
     555 [ #  # ][ #  # ]:          0 :             if( mpTabPages[i]->select( rsPresetId ) )
     556                 :            :             {
     557         [ #  # ]:          0 :                 mpTabControl->SetCurPageId( RID_TP_CUSTOMANIMATION_ENTRANCE + i );
     558                 :          0 :                 break;
     559                 :            :             }
     560                 :            :         }
     561                 :            :     }
     562                 :          0 : }
     563                 :            : 
     564                 :          0 : CustomAnimationCreateDialog::~CustomAnimationCreateDialog()
     565                 :            : {
     566         [ #  # ]:          0 :     storePosition();
     567                 :            : 
     568 [ #  # ][ #  # ]:          0 :     SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
     569 [ #  # ][ #  # ]:          0 :     pOptions->SetPreviewNewEffects( getCurrentPage()->getIsPreview() );
                 [ #  # ]
     570                 :            : 
     571 [ #  # ][ #  # ]:          0 :     delete mpTabPages[ENTRANCE];
     572 [ #  # ][ #  # ]:          0 :     delete mpTabPages[EMPHASIS];
     573 [ #  # ][ #  # ]:          0 :     delete mpTabPages[EXIT];
     574 [ #  # ][ #  # ]:          0 :     delete mpTabPages[MOTIONPATH];
     575 [ #  # ][ #  # ]:          0 :     delete mpTabPages[MISCEFFECTS];
     576                 :            : 
     577 [ #  # ][ #  # ]:          0 :     delete mpTabControl;
     578 [ #  # ][ #  # ]:          0 :     delete mpOKButton;
     579 [ #  # ][ #  # ]:          0 :     delete mpCancelButton;
     580 [ #  # ][ #  # ]:          0 :     delete mpHelpButton;
     581         [ #  # ]:          0 : }
     582                 :            : 
     583                 :          0 : CustomAnimationCreateTabPage* CustomAnimationCreateDialog::getCurrentPage() const
     584                 :            : {
     585   [ #  #  #  #  :          0 :     switch( mpTabControl->GetCurPageId() )
                      # ]
     586                 :            :     {
     587                 :          0 :     case RID_TP_CUSTOMANIMATION_ENTRANCE:   return mpTabPages[ENTRANCE];
     588                 :          0 :     case RID_TP_CUSTOMANIMATION_EMPHASIS:   return mpTabPages[EMPHASIS];
     589                 :          0 :     case RID_TP_CUSTOMANIMATION_EXIT:       return mpTabPages[EXIT];
     590                 :          0 :     case RID_TP_CUSTOMANIMATION_MISCEFFECTS:return mpTabPages[MISCEFFECTS];
     591                 :            :     default:
     592                 :          0 :                                             return mpTabPages[MOTIONPATH];
     593                 :            :     }
     594                 :            : }
     595                 :            : 
     596                 :          0 : PathKind CustomAnimationCreateDialog::getCreatePathKind() const
     597                 :            : {
     598                 :          0 :     return getCurrentPage()->getCreatePathKind();
     599                 :            : }
     600                 :            : 
     601                 :          0 : CustomAnimationPresetPtr CustomAnimationCreateDialog::getSelectedPreset() const
     602                 :            : {
     603                 :          0 :     return getCurrentPage()->getSelectedPreset();
     604                 :            : }
     605                 :            : 
     606                 :          0 : double CustomAnimationCreateDialog::getSelectedDuration() const
     607                 :            : {
     608                 :          0 :     return getCurrentPage()->getDuration();
     609                 :            : }
     610                 :            : 
     611                 :          0 : IMPL_LINK_NOARG(CustomAnimationCreateDialog, implActivatePagekHdl)
     612                 :            : {
     613                 :          0 :     getCurrentPage()->setDuration( mfDuration );
     614                 :          0 :     getCurrentPage()->setIsPreview( mbIsPreview );
     615                 :          0 :     return 1;
     616                 :            : }
     617                 :            : 
     618                 :          0 : IMPL_LINK_NOARG(CustomAnimationCreateDialog, implDeactivatePagekHdl)
     619                 :            : {
     620                 :          0 :     mfDuration = getCurrentPage()->getDuration();
     621                 :          0 :     mbIsPreview = getCurrentPage()->getIsPreview();
     622                 :          0 :     return 1;
     623                 :            : }
     624                 :            : 
     625                 :          0 : void CustomAnimationCreateDialog::preview( const CustomAnimationPresetPtr& pPreset ) const
     626                 :            : {
     627 [ #  # ][ #  # ]:          0 :     MainSequencePtr pSequence( new MainSequence() );
                 [ #  # ]
     628                 :            : 
     629                 :          0 :     std::vector< Any >::const_iterator aIter( mrTargets.begin() );
     630                 :          0 :     const std::vector< Any >::const_iterator aEnd( mrTargets.end() );
     631                 :            : 
     632         [ #  # ]:          0 :     const double fDuration = getSelectedDuration();
     633                 :            : 
     634                 :          0 :     bool bFirst = true;
     635 [ #  # ][ #  # ]:          0 :     while( aIter != aEnd )
     636                 :            :     {
     637                 :            :         CustomAnimationEffectPtr pNew(
     638 [ #  # ][ #  # ]:          0 :             pSequence->append( pPreset, (*aIter++), fDuration ) );
     639                 :            : 
     640         [ #  # ]:          0 :         if( bFirst )
     641                 :          0 :             bFirst = false;
     642                 :            :         else
     643         [ #  # ]:          0 :             pNew->setNodeType( EffectNodeType::WITH_PREVIOUS );
     644         [ #  # ]:          0 :     }
     645                 :            : 
     646 [ #  # ][ #  # ]:          0 :     mpPane->preview( pSequence->getRootNode() );
                 [ #  # ]
     647                 :          0 : }
     648                 :            : 
     649                 :            : namespace
     650                 :            : {
     651                 :          0 : Window * lcl_GetTopmostParent( Window * pWindow )
     652                 :            : {
     653                 :          0 :     Window * pResult = 0;
     654         [ #  # ]:          0 :     Window * pCurrent = pWindow ? pWindow->GetParent() : 0;
     655         [ #  # ]:          0 :     while( pCurrent )
     656                 :            :     {
     657                 :          0 :         pResult = pCurrent;
     658                 :          0 :         pCurrent = pCurrent->GetParent();
     659                 :            :     }
     660                 :          0 :     return pResult;
     661                 :            : }
     662                 :            : }
     663                 :            : 
     664                 :          0 : void CustomAnimationCreateDialog::setPosition()
     665                 :            : {
     666                 :            :     SvtViewOptions aDlgOpt(
     667         [ #  # ]:          0 :         E_TABDIALOG, rtl::OUString::valueOf(static_cast<sal_Int32>(DLG_CUSTOMANIMATION_CREATE)));
     668 [ #  # ][ #  # ]:          0 :     if ( aDlgOpt.Exists() )
     669                 :            :     {
     670                 :            :         SetWindowState( rtl::OUStringToOString(aDlgOpt.GetWindowState(),
     671 [ #  # ][ #  # ]:          0 :             RTL_TEXTENCODING_ASCII_US) );
                 [ #  # ]
     672                 :            :     }
     673                 :            :     else
     674                 :            :     {
     675                 :            :         // default position: aligned with right edge of parent
     676         [ #  # ]:          0 :         Window * pParent = lcl_GetTopmostParent( this );
     677         [ #  # ]:          0 :         if( pParent )
     678                 :            :         {
     679         [ #  # ]:          0 :             Point aPos( GetPosPixel());
     680         [ #  # ]:          0 :             Size  aSize( GetSizePixel());
     681         [ #  # ]:          0 :             Size  aParentSize( pParent->GetSizePixel());
     682                 :            : 
     683                 :            :             // right center
     684                 :          0 :             aPos.setX( aParentSize.getWidth() - aSize.getWidth() );
     685                 :          0 :             aPos.setY( (aParentSize.getHeight() - aSize.getHeight()) / 2 );
     686         [ #  # ]:          0 :             SetPosPixel( aPos );
     687                 :            :         }
     688         [ #  # ]:          0 :     }
     689                 :          0 : }
     690                 :            : 
     691                 :          0 : void CustomAnimationCreateDialog::storePosition()
     692                 :            : {
     693                 :            :     // save settings (screen position and current page)
     694                 :            :     SvtViewOptions aDlgOpt(
     695         [ #  # ]:          0 :         E_TABDIALOG, rtl::OUString::valueOf(static_cast<sal_Int32>(DLG_CUSTOMANIMATION_CREATE)));
     696                 :            :     aDlgOpt.SetWindowState(OStringToOUString(
     697 [ #  # ][ #  # ]:          0 :         GetWindowState(WINDOWSTATE_MASK_POS), RTL_TEXTENCODING_ASCII_US));
         [ #  # ][ #  # ]
     698                 :          0 : }
     699                 :            : 
     700                 :            : }
     701                 :            : 
     702                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10