LCOV - code coverage report
Current view: top level - sd/source/ui/dlg - animobjs.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 633 0.2 %
Date: 2014-11-03 Functions: 2 44 4.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <com/sun/star/presentation/AnimationEffect.hpp>
      21             : #include <com/sun/star/presentation/AnimationSpeed.hpp>
      22             : #include <svx/xoutbmp.hxx>
      23             : #include <time.h>
      24             : #include <svl/eitem.hxx>
      25             : #include <svx/svdograf.hxx>
      26             : #include <svx/svdogrp.hxx>
      27             : #include <sfx2/basedlgs.hxx>
      28             : #include <sfx2/dispatch.hxx>
      29             : #include <sfx2/progress.hxx>
      30             : #include <vcl/msgbox.hxx>
      31             : 
      32             : #include "anminfo.hxx"
      33             : #include "animobjs.hxx"
      34             : #include "animobjs.hrc"
      35             : #include "app.hrc"
      36             : #include "strings.hrc"
      37             : #include "sdresid.hxx"
      38             : #include "View.hxx"
      39             : #include "drawdoc.hxx"
      40             : #include "sdpage.hxx"
      41             : #include "res_bmp.hrc"
      42             : #include "ViewShell.hxx"
      43             : 
      44             : #include <vcl/svapp.hxx>
      45             : #include <vcl/settings.hxx>
      46             : 
      47             : #include <EffectMigration.hxx>
      48             : 
      49             : #include <string>
      50             : #include <algorithm>
      51             : 
      52             : using namespace ::com::sun::star;
      53             : 
      54             : namespace sd {
      55             : 
      56             : /**
      57             :  *  SdDisplay - Control
      58             :  */
      59           0 : SdDisplay::SdDisplay( vcl::Window* pWin, SdResId Id ) :
      60             :         Control( pWin, Id ),
      61           0 :         aScale( 1, 1 )
      62             : {
      63           0 :     SetMapMode( MAP_PIXEL );
      64           0 :     const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
      65           0 :     SetBackground( Wallpaper( Color( rStyles.GetFieldColor() ) ) );
      66           0 : }
      67             : 
      68           0 : SdDisplay::~SdDisplay()
      69             : {
      70           0 : }
      71             : 
      72           0 : void SdDisplay::SetBitmapEx( BitmapEx* pBmpEx )
      73             : {
      74           0 :     if( pBmpEx )
      75             :     {
      76           0 :         aBitmapEx = *pBmpEx;
      77             :     }
      78             :     else
      79             :     {
      80           0 :         const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
      81           0 :         const Color aFillColor = rStyles.GetFieldColor();
      82           0 :         aBitmapEx.Erase(aFillColor);
      83             :     }
      84           0 : }
      85             : 
      86           0 : void SdDisplay::Paint( const Rectangle& )
      87             : {
      88           0 :     Point aPt;
      89           0 :     Size aSize = GetOutputSize();
      90           0 :     Size aBmpSize = aBitmapEx.GetBitmap().GetSizePixel();
      91           0 :     aBmpSize.Width() = (long) ( (double) aBmpSize.Width() * (double) aScale );
      92           0 :     aBmpSize.Height() = (long) ( (double) aBmpSize.Height() * (double) aScale );
      93             : 
      94           0 :     if( aBmpSize.Width() < aSize.Width() )
      95           0 :         aPt.X() = ( aSize.Width() - aBmpSize.Width() ) / 2;
      96           0 :     if( aBmpSize.Height() < aSize.Height() )
      97           0 :         aPt.Y() = ( aSize.Height() - aBmpSize.Height() ) / 2;
      98             : 
      99           0 :     aBitmapEx.Draw( this, aPt, aBmpSize );
     100           0 : }
     101             : 
     102           0 : void SdDisplay::SetScale( const Fraction& rFrac )
     103             : {
     104           0 :     aScale = rFrac;
     105           0 : }
     106             : 
     107           0 : void SdDisplay::DataChanged( const DataChangedEvent& rDCEvt )
     108             : {
     109           0 :     Control::DataChanged( rDCEvt );
     110             : 
     111           0 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     112             :     {
     113           0 :         const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
     114           0 :         SetBackground( Wallpaper( Color( rStyles.GetFieldColor() ) ) );
     115           0 :         SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode()
     116             :             ? ViewShell::OUTPUT_DRAWMODE_CONTRAST
     117           0 :             : ViewShell::OUTPUT_DRAWMODE_COLOR );
     118             :     }
     119           0 : }
     120             : 
     121             : /**
     122             :  *  AnimationWindow - FloatingWindow
     123             :  */
     124           0 : AnimationWindow::AnimationWindow( SfxBindings* pInBindings,
     125             :                 SfxChildWindow *pCW, vcl::Window* pParent, const SdResId& rSdResId ) :
     126             :         SfxDockingWindow    ( pInBindings, pCW, pParent, rSdResId ),
     127             :         aCtlDisplay         ( this, SdResId( CTL_DISPLAY ) ),
     128             :         aBtnFirst           ( this, SdResId( BTN_FIRST ) ),
     129             :         aBtnReverse         ( this, SdResId( BTN_REVERSE ) ),
     130             :         aBtnStop            ( this, SdResId( BTN_STOP ) ),
     131             :         aBtnPlay            ( this, SdResId( BTN_PLAY ) ),
     132             :         aBtnLast            ( this, SdResId( BTN_LAST ) ),
     133             :         aNumFldBitmap       ( this, SdResId( NUM_FLD_BITMAP ) ),
     134             :         aTimeField          ( this, SdResId( TIME_FIELD ) ),
     135             :         aLbLoopCount        ( this, SdResId( LB_LOOP_COUNT ) ),
     136             :         aGrpBitmap          ( this, SdResId( GRP_BITMAP ) ),
     137             :         aBtnGetOneObject    ( this, SdResId( BTN_GET_ONE_OBJECT ) ),
     138             :         aBtnGetAllObjects   ( this, SdResId( BTN_GET_ALL_OBJECTS ) ),
     139             :         aBtnRemoveBitmap    ( this, SdResId( BTN_REMOVE_BITMAP ) ),
     140             :         aBtnRemoveAll       ( this, SdResId( BTN_REMOVE_ALL ) ),
     141             :         aFtCount            ( this, SdResId( FT_COUNT ) ),
     142             :         aFiCount            ( this, SdResId( FI_COUNT ) ),
     143             :         aGrpAnimation       ( this, SdResId( GRP_ANIMATION_GROUP ) ),
     144             :         aRbtGroup           ( this, SdResId( RBT_GROUP ) ),
     145             :         aRbtBitmap          ( this, SdResId( RBT_BITMAP ) ),
     146             :         aFtAdjustment       ( this, SdResId( FT_ADJUSTMENT ) ),
     147             :         aLbAdjustment       ( this, SdResId( LB_ADJUSTMENT ) ),
     148             :         aBtnCreateGroup     ( this, SdResId( BTN_CREATE_GROUP ) ),
     149             :         aBtnHelp            ( this, SdResId( BTN_HELP ) ),
     150             : 
     151             :         pWin                ( pParent ),
     152             :         m_nCurrentFrame     ( EMPTY_FRAMELIST ),
     153             : 
     154             :         bMovie              ( false ),
     155             :         bAllObjects         ( false ),
     156             : 
     157           0 :         pBindings           ( pInBindings )
     158             : {
     159           0 :     aCtlDisplay.SetAccessibleName(SD_RESSTR(STR_DISPLAY));
     160           0 :     FreeResource();
     161             :     //undo SfxDockingWindow HelpId clear hack
     162           0 :     reverseUniqueHelpIdHack(*this);
     163             : 
     164             :     // create new document with page
     165           0 :     pMyDoc = new SdDrawDocument(DOCUMENT_TYPE_IMPRESS, NULL);
     166           0 :     SdPage* pPage = pMyDoc->AllocSdPage(false);
     167           0 :     pMyDoc->InsertPage(pPage);
     168             : 
     169           0 :     pControllerItem = new AnimationControllerItem( SID_ANIMATOR_STATE, this, pBindings );
     170             : 
     171             :     // as long as not in the resource
     172           0 :     aTimeField.SetFormat( TimeFieldFormat::F_SEC_CS );
     173             : 
     174           0 :     aBtnFirst.SetClickHdl( LINK( this, AnimationWindow, ClickFirstHdl ) );
     175           0 :     aBtnReverse.SetClickHdl( LINK( this, AnimationWindow, ClickPlayHdl ) );
     176           0 :     aBtnStop.SetClickHdl( LINK( this, AnimationWindow, ClickStopHdl ) );
     177           0 :     aBtnPlay.SetClickHdl( LINK( this, AnimationWindow, ClickPlayHdl ) );
     178           0 :     aBtnLast.SetClickHdl( LINK( this, AnimationWindow, ClickLastHdl ) );
     179             : 
     180           0 :     aBtnGetOneObject.SetClickHdl( LINK( this, AnimationWindow, ClickGetObjectHdl ) );
     181           0 :     aBtnGetAllObjects.SetClickHdl( LINK( this, AnimationWindow, ClickGetObjectHdl ) );
     182           0 :     aBtnRemoveBitmap.SetClickHdl( LINK( this, AnimationWindow, ClickRemoveBitmapHdl ) );
     183           0 :     aBtnRemoveAll.SetClickHdl( LINK( this, AnimationWindow, ClickRemoveBitmapHdl ) );
     184             : 
     185           0 :     aRbtGroup.SetClickHdl( LINK( this, AnimationWindow, ClickRbtHdl ) );
     186           0 :     aRbtBitmap.SetClickHdl( LINK( this, AnimationWindow, ClickRbtHdl ) );
     187           0 :     aBtnCreateGroup.SetClickHdl( LINK( this, AnimationWindow, ClickCreateGroupHdl ) );
     188           0 :     aNumFldBitmap.SetModifyHdl( LINK( this, AnimationWindow, ModifyBitmapHdl ) );
     189           0 :     aTimeField.SetModifyHdl( LINK( this, AnimationWindow, ModifyTimeHdl ) );
     190             : 
     191             :     // disable 3D border
     192           0 :     aCtlDisplay.SetBorderStyle(WindowBorderStyle::MONO);
     193           0 :     aDisplaySize = aCtlDisplay.GetOutputSize();
     194             : 
     195           0 :     aSize = GetOutputSizePixel();
     196           0 :     SetMinOutputSizePixel( aSize );
     197             : 
     198           0 :     ResetAttrs();
     199             : 
     200             :     // the animator is empty; no animation group can be created
     201           0 :     aBtnCreateGroup.Disable();
     202             : 
     203           0 :     aBtnGetOneObject.SetAccessibleRelationMemberOf( &aGrpBitmap );
     204           0 :     aBtnGetAllObjects.SetAccessibleRelationMemberOf( &aGrpBitmap );
     205           0 :     aBtnRemoveBitmap.SetAccessibleRelationMemberOf( &aGrpBitmap );
     206           0 :     aBtnRemoveAll.SetAccessibleRelationMemberOf( &aGrpBitmap );
     207           0 : }
     208             : 
     209           0 : AnimationWindow::~AnimationWindow()
     210             : {
     211           0 :     delete pControllerItem;
     212             : 
     213           0 :     for (size_t i = 0; i < m_FrameList.size(); ++i)
     214             :     {
     215           0 :         delete m_FrameList[i].first;
     216           0 :         delete m_FrameList[i].second;
     217             :     }
     218           0 :     m_FrameList.clear();
     219           0 :     m_nCurrentFrame = EMPTY_FRAMELIST;
     220             : 
     221             :     // delete the clones
     222           0 :     delete pMyDoc;
     223           0 : }
     224             : 
     225           0 : IMPL_LINK_NOARG(AnimationWindow, ClickFirstHdl)
     226             : {
     227           0 :     m_nCurrentFrame = (m_FrameList.empty()) ? EMPTY_FRAMELIST : 0;
     228           0 :     UpdateControl();
     229             : 
     230           0 :     return( 0L );
     231             : }
     232             : 
     233           0 : IMPL_LINK_NOARG(AnimationWindow, ClickStopHdl)
     234             : {
     235           0 :     bMovie = false;
     236           0 :     return( 0L );
     237             : }
     238             : 
     239           0 : IMPL_LINK( AnimationWindow, ClickPlayHdl, void *, p )
     240             : {
     241           0 :     ScopeLockGuard aGuard( maPlayLock );
     242             : 
     243           0 :     bMovie = true;
     244           0 :     bool bDisableCtrls = false;
     245           0 :     size_t const nCount = m_FrameList.size();
     246           0 :     bool bReverse = p == &aBtnReverse;
     247             : 
     248             :     // it is difficult to find it later on
     249           0 :     bool bRbtGroupEnabled = aRbtGroup.IsEnabled();
     250           0 :     bool bBtnGetAllObjectsEnabled = aBtnGetAllObjects.IsEnabled();
     251           0 :     bool bBtnGetOneObjectEnabled = aBtnGetOneObject.IsEnabled();
     252             : 
     253             :     // calculate overall time
     254           0 :     tools::Time aTime( 0 );
     255             :     long nFullTime;
     256           0 :     if( aRbtBitmap.IsChecked() )
     257             :     {
     258           0 :         for (size_t i = 0; i < nCount; ++i)
     259             :         {
     260           0 :             aTime += *m_FrameList[i].second;
     261             :         }
     262           0 :         nFullTime  = aTime.GetMSFromTime();
     263             :     }
     264             :     else
     265             :     {
     266           0 :         nFullTime = nCount * 100;
     267           0 :         aTime.MakeTimeFromMS( nFullTime );
     268             :     }
     269             : 
     270             :     // StatusBarManager from 1 second
     271           0 :     SfxProgress* pProgress = NULL;
     272           0 :     if( nFullTime >= 1000 )
     273             :     {
     274           0 :         bDisableCtrls = true;
     275           0 :         aBtnStop.Enable();
     276           0 :         aBtnStop.Update();
     277           0 :         OUString aStr("Animator:"); // here we should think about something smart
     278           0 :         pProgress = new SfxProgress( NULL, aStr, nFullTime );
     279             :     }
     280             : 
     281           0 :     sal_uLong nTmpTime = 0;
     282           0 :     size_t i = 0;
     283           0 :     bool bCount = i < nCount;
     284           0 :     if( bReverse )
     285             :     {
     286           0 :         i = nCount - 1;
     287             :     }
     288           0 :     while( bCount && bMovie )
     289             :     {
     290             :         // make list and view consistent
     291             :         assert(0 < i && i < m_FrameList.size());
     292           0 :         m_nCurrentFrame = i;
     293             : 
     294           0 :         UpdateControl(bDisableCtrls);
     295             : 
     296           0 :         if( aRbtBitmap.IsChecked() )
     297             :         {
     298           0 :             tools::Time *const pTime = m_FrameList[i].second;
     299             :             assert(pTime);
     300             : 
     301           0 :             aTimeField.SetTime( *pTime );
     302           0 :             sal_uLong nTime = pTime->GetMSFromTime();
     303             : 
     304           0 :             WaitInEffect( nTime, nTmpTime, pProgress );
     305           0 :             nTmpTime += nTime;
     306             :         }
     307             :         else
     308             :         {
     309           0 :             WaitInEffect( 100, nTmpTime, pProgress );
     310           0 :             nTmpTime += 100;
     311             :         }
     312           0 :         if( bReverse )
     313             :         {
     314           0 :             if (i == 0)
     315             :             {
     316             :                 // Terminate loop.
     317           0 :                 bCount = false;
     318             :             }
     319             :             else
     320             :             {
     321           0 :                 --i;
     322             :             }
     323             :         }
     324             :         else
     325             :         {
     326           0 :             i++;
     327           0 :             if (i >= nCount)
     328             :             {
     329             :                 // Terminate loop.
     330           0 :                 bCount = false;
     331             :                 // Move i back into valid range.
     332           0 :                 i = nCount - 1;
     333             :             }
     334             :         }
     335             :     }
     336             : 
     337             :     // to re-enable the controls
     338           0 :     bMovie = false;
     339           0 :     if (nCount > 0)
     340             :     {
     341             :         assert(i == m_nCurrentFrame);
     342           0 :         UpdateControl();
     343             :     }
     344             : 
     345           0 :     if( pProgress )
     346             :     {
     347           0 :         delete pProgress;
     348           0 :         aBtnStop.Disable();
     349             :     }
     350             : 
     351           0 :     aRbtGroup.Enable( bRbtGroupEnabled );
     352           0 :     aBtnGetAllObjects.Enable( bBtnGetAllObjectsEnabled );
     353           0 :     aBtnGetOneObject.Enable( bBtnGetOneObjectEnabled );
     354             : 
     355           0 :     return( 0L );
     356             : }
     357             : 
     358           0 : IMPL_LINK_NOARG(AnimationWindow, ClickLastHdl)
     359             : {
     360             :     m_nCurrentFrame =
     361           0 :         (m_FrameList.empty()) ? EMPTY_FRAMELIST : m_FrameList.size() - 1 ;
     362           0 :     UpdateControl();
     363             : 
     364           0 :     return( 0L );
     365             : }
     366             : 
     367           0 : IMPL_LINK( AnimationWindow, ClickRbtHdl, void *, p )
     368             : {
     369           0 :     if (m_FrameList.empty() || p == &aRbtGroup || aRbtGroup.IsChecked())
     370             :     {
     371           0 :         aTimeField.SetText( OUString() );
     372           0 :         aTimeField.Enable( false );
     373           0 :         aLbLoopCount.Enable( false );
     374             :     }
     375           0 :     else if( p == &aRbtBitmap || aRbtBitmap.IsChecked() )
     376             :     {
     377           0 :         sal_uLong n = static_cast<sal_uLong>(aNumFldBitmap.GetValue());
     378           0 :         if( n > 0 )
     379             :         {
     380           0 :             tools::Time *const pTime = m_FrameList[n - 1].second;
     381           0 :             if( pTime )
     382           0 :                 aTimeField.SetTime( *pTime );
     383             :         }
     384           0 :         aTimeField.Enable();
     385           0 :         aLbLoopCount.Enable();
     386             :     }
     387             : 
     388           0 :     return( 0L );
     389             : }
     390             : 
     391           0 : IMPL_LINK( AnimationWindow, ClickGetObjectHdl, void *, pBtn )
     392             : {
     393           0 :     bAllObjects = pBtn == &aBtnGetAllObjects;
     394             : 
     395             :     // Code now in AddObj()
     396           0 :     SfxBoolItem aItem( SID_ANIMATOR_ADD, true );
     397             : 
     398           0 :     GetBindings().GetDispatcher()->Execute(
     399           0 :         SID_ANIMATOR_ADD, SfxCallMode::SLOT | SfxCallMode::RECORD, &aItem, 0L );
     400           0 :     return( 0L );
     401             : }
     402             : 
     403           0 : IMPL_LINK( AnimationWindow, ClickRemoveBitmapHdl, void *, pBtn )
     404             : {
     405           0 :     SdPage*     pPage = pMyDoc->GetSdPage(0, PK_STANDARD);
     406             :     SdrObject*  pObject;
     407             : 
     408           0 :     if( pBtn == &aBtnRemoveBitmap )
     409             :     {
     410           0 :         delete m_FrameList[m_nCurrentFrame].first;
     411           0 :         delete m_FrameList[m_nCurrentFrame].second;
     412           0 :         m_FrameList.erase(m_FrameList.begin() + m_nCurrentFrame);
     413             : 
     414           0 :         pObject = pPage->GetObj(m_nCurrentFrame);
     415             :         // Through acquisition of the AnimatedGIFs, objects does not need to
     416             :         // exist.
     417           0 :         if( pObject )
     418             :         {
     419           0 :             pObject = pPage->RemoveObject(m_nCurrentFrame);
     420             :             DBG_ASSERT(pObject, "Clone not found during deletion");
     421           0 :             SdrObject::Free( pObject );
     422           0 :             pPage->RecalcObjOrdNums();
     423             :         }
     424             : 
     425           0 :         if (m_nCurrentFrame >= m_FrameList.size())
     426             :         {
     427             :             assert(m_FrameList.empty());
     428           0 :             m_nCurrentFrame = EMPTY_FRAMELIST;
     429             :         }
     430             :     }
     431             :     else // delete everything
     432             :     {
     433           0 :         WarningBox aWarnBox( this, WB_YES_NO, SD_RESSTR( STR_ASK_DELETE_ALL_PICTURES ) );
     434           0 :         short nReturn = aWarnBox.Execute();
     435             : 
     436           0 :         if( nReturn == RET_YES )
     437             :         {
     438             :             // clear frame list
     439           0 :             for (size_t i = m_FrameList.size(); i > 0; )
     440             :             {
     441           0 :                 --i;
     442           0 :                 delete m_FrameList[i].first;
     443             : 
     444           0 :                 pObject = pPage->GetObj( i );
     445           0 :                 if( pObject )
     446             :                 {
     447           0 :                     pObject = pPage->RemoveObject( i );
     448             :                     DBG_ASSERT(pObject, "Clone not found during deletion");
     449           0 :                     SdrObject::Free( pObject );
     450             :                     //pPage->RecalcObjOrdNums();
     451             :                 }
     452             : 
     453           0 :                 delete m_FrameList[i].second;
     454             :             }
     455           0 :             m_FrameList.clear();
     456           0 :             m_nCurrentFrame = EMPTY_FRAMELIST;
     457           0 :         }
     458             :     }
     459             : 
     460             :     // can we create a animation group
     461           0 :     if (m_FrameList.empty())
     462             :     {
     463           0 :         aBtnCreateGroup.Disable();
     464             :         // if previous disabled by acquisition of AnimatedGIFs:
     465             :         //aRbtBitmap.Enable();
     466           0 :         aRbtGroup.Enable();
     467             :     }
     468             : 
     469             :     // calculate and set zoom for DisplayWin
     470           0 :     Fraction aFrac( GetScale() );
     471           0 :     aCtlDisplay.SetScale( aFrac );
     472             : 
     473           0 :     UpdateControl();
     474             : 
     475           0 :     return( 0L );
     476             : }
     477             : 
     478           0 : IMPL_LINK_NOARG(AnimationWindow, ClickCreateGroupHdl)
     479             : {
     480             :     // Code now in CreatePresObj()
     481           0 :     SfxBoolItem aItem( SID_ANIMATOR_CREATE, true );
     482             : 
     483           0 :     GetBindings().GetDispatcher()->Execute(
     484           0 :         SID_ANIMATOR_CREATE, SfxCallMode::SLOT | SfxCallMode::RECORD, &aItem, 0L );
     485           0 :     return( 0L );
     486             : }
     487             : 
     488           0 : IMPL_LINK_NOARG(AnimationWindow, ModifyBitmapHdl)
     489             : {
     490           0 :     sal_uLong nBmp = static_cast<sal_uLong>(aNumFldBitmap.GetValue());
     491             : 
     492           0 :     if (nBmp > m_FrameList.size())
     493             :     {
     494           0 :         nBmp = m_FrameList.size();
     495             :     }
     496             : 
     497           0 :     m_nCurrentFrame = nBmp - 1;
     498             : 
     499           0 :     UpdateControl();
     500             : 
     501           0 :     return( 0L );
     502             : }
     503             : 
     504           0 : IMPL_LINK_NOARG(AnimationWindow, ModifyTimeHdl)
     505             : {
     506           0 :     sal_uLong nPos = static_cast<sal_uLong>(aNumFldBitmap.GetValue() - 1);
     507             : 
     508           0 :     tools::Time *const pTime = m_FrameList[nPos].second;
     509             : 
     510           0 :     *pTime = aTimeField.GetTime();
     511             : 
     512           0 :     return( 0L );
     513             : }
     514             : 
     515           0 : void AnimationWindow::UpdateControl(bool const bDisableCtrls)
     516             : {
     517           0 :     if (!m_FrameList.empty())
     518             :     {
     519           0 :         BitmapEx aBmp(*m_FrameList[m_nCurrentFrame].first);
     520             : 
     521           0 :         SdPage* pPage = pMyDoc->GetSdPage(0, PK_STANDARD);
     522             :         SdrObject *const pObject =
     523           0 :             static_cast<SdrObject*>(pPage->GetObj(m_nCurrentFrame));
     524           0 :         if( pObject )
     525             :         {
     526           0 :             VirtualDevice   aVD;
     527           0 :             Rectangle       aObjRect( pObject->GetCurrentBoundRect() );
     528           0 :             Size            aObjSize( aObjRect.GetSize() );
     529           0 :             Point           aOrigin( Point( -aObjRect.Left(), -aObjRect.Top() ) );
     530           0 :             MapMode         aMap( aVD.GetMapMode() );
     531           0 :             aMap.SetMapUnit( MAP_100TH_MM );
     532           0 :             aMap.SetOrigin( aOrigin );
     533           0 :             aVD.SetMapMode( aMap );
     534           0 :             aVD.SetOutputSize( aObjSize );
     535           0 :             const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
     536           0 :             aVD.SetBackground( Wallpaper( rStyles.GetFieldColor() ) );
     537           0 :             aVD.SetDrawMode( rStyles.GetHighContrastMode()
     538             :                 ? ViewShell::OUTPUT_DRAWMODE_CONTRAST
     539           0 :                 : ViewShell::OUTPUT_DRAWMODE_COLOR );
     540           0 :             aVD.Erase();
     541           0 :             pObject->SingleObjectPainter( aVD );
     542           0 :             aBmp = BitmapEx( aVD.GetBitmap( aObjRect.TopLeft(), aObjSize ) );
     543             :         }
     544             : 
     545           0 :         aCtlDisplay.SetBitmapEx( &aBmp );
     546             :     }
     547             :     else
     548             :     {
     549           0 :         aCtlDisplay.SetBitmapEx(0);
     550             :     }
     551           0 :     aCtlDisplay.Invalidate();
     552           0 :     aCtlDisplay.Update();
     553             : 
     554             :     aFiCount.SetText(OUString::number(
     555           0 :                 m_FrameList.size()));
     556             : 
     557           0 :     if (!m_FrameList.empty() && !bMovie)
     558             :     {
     559           0 :         aNumFldBitmap.SetValue(m_nCurrentFrame + 1);
     560             : 
     561             :         // if there is at least 1 object in the list
     562           0 :         aBtnFirst.Enable();
     563           0 :         aBtnReverse.Enable();
     564           0 :         aBtnPlay.Enable();
     565           0 :         aBtnLast.Enable();
     566           0 :         aNumFldBitmap.Enable();
     567           0 :         aTimeField.Enable();
     568           0 :         aLbLoopCount.Enable();
     569           0 :         aBtnRemoveBitmap.Enable();
     570           0 :         aBtnRemoveAll.Enable();
     571             :     }
     572             :     else
     573             :     {
     574             :         // if no object is in the list
     575           0 :         aBtnFirst.Enable( false );
     576           0 :         aBtnReverse.Enable( false );
     577           0 :         aBtnPlay.Enable( false );
     578           0 :         aBtnLast.Enable( false );
     579           0 :         aNumFldBitmap.Enable( false );
     580           0 :         aTimeField.Enable( false );
     581           0 :         aLbLoopCount.Enable( false );
     582           0 :         aBtnRemoveBitmap.Enable( false );
     583           0 :         aBtnRemoveAll.Enable( false );
     584             : 
     585             :         //aFtAdjustment.Enable();
     586             :         //aLbAdjustment.Enable();
     587             :     }
     588             : 
     589           0 :     if( bMovie && bDisableCtrls )
     590             :     {
     591           0 :         aBtnGetOneObject.Enable( false );
     592           0 :         aBtnGetAllObjects.Enable( false );
     593           0 :         aRbtGroup.Enable( false );
     594           0 :         aRbtBitmap.Enable( false );
     595           0 :         aBtnCreateGroup.Enable( false );
     596           0 :         aFtAdjustment.Enable( false );
     597           0 :         aLbAdjustment.Enable( false );
     598             :     }
     599             :     else
     600             :     {
     601             :         // enable 'group object' only if it is not a Animated GIF
     602           0 :         if (m_FrameList.empty())
     603             :         {
     604           0 :             aRbtGroup.Enable();
     605             :         }
     606             : 
     607           0 :         aRbtBitmap.Enable();
     608           0 :         aBtnCreateGroup.Enable(!m_FrameList.empty());
     609           0 :         aFtAdjustment.Enable( true );
     610           0 :         aLbAdjustment.Enable( true );
     611             :     }
     612             : 
     613           0 :     ClickRbtHdl( NULL );
     614           0 : }
     615             : 
     616           0 : void AnimationWindow::ResetAttrs()
     617             : {
     618           0 :     aRbtGroup.Check();
     619           0 :     aLbAdjustment.SelectEntryPos( BA_CENTER );
     620             :     // LoopCount
     621           0 :     aLbLoopCount.SelectEntryPos( aLbLoopCount.GetEntryCount() - 1);
     622             : 
     623           0 :     UpdateControl();
     624           0 : }
     625             : 
     626           0 : void AnimationWindow::WaitInEffect( sal_uLong nMilliSeconds, sal_uLong nTime,
     627             :                                     SfxProgress* pProgress ) const
     628             : {
     629           0 :     clock_t aEnd = tools::Time::GetSystemTicks() + nMilliSeconds;
     630           0 :     clock_t aCurrent = tools::Time::GetSystemTicks();
     631           0 :     while (aCurrent < aEnd)
     632             :     {
     633           0 :         aCurrent = tools::Time::GetSystemTicks();
     634             : 
     635           0 :         if( pProgress )
     636           0 :             pProgress->SetState( nTime + nMilliSeconds + aCurrent - aEnd );
     637             : 
     638           0 :         Application::Reschedule();
     639             : 
     640           0 :         if( !bMovie )
     641           0 :             return;
     642             :     }
     643             : }
     644             : 
     645           0 : Fraction AnimationWindow::GetScale()
     646             : {
     647           0 :     Fraction aFrac;
     648           0 :     size_t const nCount = m_FrameList.size();
     649           0 :     if (nCount > 0)
     650             :     {
     651           0 :         aBmpSize.Width() = 0;
     652           0 :         aBmpSize.Height() = 0;
     653           0 :         for (size_t i = 0; i < nCount; i++)
     654             :         {
     655           0 :             BitmapEx *const pBitmap = m_FrameList[i].first;
     656           0 :             Size aTempSize( pBitmap->GetBitmap().GetSizePixel() );
     657           0 :             aBmpSize.Width() = std::max( aBmpSize.Width(), aTempSize.Width() );
     658           0 :             aBmpSize.Height() = std::max( aBmpSize.Height(), aTempSize.Height() );
     659             :         }
     660             : 
     661           0 :         aBmpSize.Width() += 10;
     662           0 :         aBmpSize.Height() += 10;
     663             : 
     664           0 :         aFrac = Fraction( std::min( (double)aDisplaySize.Width() / (double)aBmpSize.Width(),
     665           0 :                              (double)aDisplaySize.Height() / (double)aBmpSize.Height() ) );
     666             :     }
     667           0 :     return( aFrac );
     668             : }
     669             : 
     670           0 : void AnimationWindow::Resize()
     671             : {
     672           0 :     if ( !IsFloatingMode() ||
     673           0 :          !GetFloatingWindow()->IsRollUp() )
     674             :     {
     675           0 :         Size aWinSize( GetOutputSizePixel() ); // former rSize in Resizing()
     676             : 
     677           0 :         Size aDiffSize;
     678           0 :         aDiffSize.Width() = aWinSize.Width() - aSize.Width();
     679           0 :         aDiffSize.Height() = aWinSize.Height() - aSize.Height();
     680             : 
     681             :         // resize display controls
     682           0 :         aDisplaySize.Width() += aDiffSize.Width();
     683           0 :         aDisplaySize.Height() += aDiffSize.Height();
     684           0 :         aCtlDisplay.SetOutputSizePixel( aDisplaySize );
     685             : 
     686           0 :         Point aPt;
     687           0 :         aPt.Y() = aDiffSize.Height();
     688             : 
     689             :         // move other controls
     690           0 :         aBtnFirst.Hide();
     691           0 :         aBtnReverse.Hide();
     692           0 :         aBtnStop.Hide();
     693           0 :         aBtnPlay.Hide();
     694           0 :         aBtnLast.Hide();
     695           0 :         aTimeField.Hide();
     696           0 :         aLbLoopCount.Hide();
     697           0 :         aNumFldBitmap.Hide();
     698           0 :         aFtCount.Hide();
     699           0 :         aFiCount.Hide();
     700           0 :         aBtnGetOneObject.Hide();
     701           0 :         aBtnGetAllObjects.Hide();
     702           0 :         aBtnRemoveBitmap.Hide();
     703           0 :         aBtnRemoveAll.Hide();
     704           0 :         aGrpBitmap.Hide();
     705           0 :         aRbtGroup.Hide();
     706           0 :         aRbtBitmap.Hide();
     707           0 :         aFtAdjustment.Hide();
     708           0 :         aLbAdjustment.Hide();
     709           0 :         aBtnCreateGroup.Hide();
     710           0 :         aGrpAnimation.Hide();
     711             : 
     712           0 :         aBtnFirst.SetPosPixel( aBtnFirst.GetPosPixel() + aPt );
     713           0 :         aBtnReverse.SetPosPixel( aBtnReverse.GetPosPixel() + aPt );
     714           0 :         aBtnStop.SetPosPixel( aBtnStop.GetPosPixel() + aPt );
     715           0 :         aBtnPlay.SetPosPixel( aBtnPlay.GetPosPixel() + aPt );
     716           0 :         aBtnLast.SetPosPixel( aBtnLast.GetPosPixel() + aPt );
     717           0 :         aNumFldBitmap.SetPosPixel( aNumFldBitmap.GetPosPixel() + aPt );
     718           0 :         aTimeField.SetPosPixel( aTimeField.GetPosPixel() + aPt );
     719           0 :         aLbLoopCount.SetPosPixel( aLbLoopCount.GetPosPixel() + aPt );
     720           0 :         aFtCount.SetPosPixel( aFtCount.GetPosPixel() + aPt );
     721           0 :         aFiCount.SetPosPixel( aFiCount.GetPosPixel() + aPt );
     722           0 :         aRbtGroup.SetPosPixel( aRbtGroup.GetPosPixel() + aPt );
     723           0 :         aRbtBitmap.SetPosPixel( aRbtBitmap.GetPosPixel() + aPt );
     724           0 :         aFtAdjustment.SetPosPixel( aFtAdjustment.GetPosPixel() + aPt );
     725           0 :         aLbAdjustment.SetPosPixel( aLbAdjustment.GetPosPixel() + aPt );
     726           0 :         aBtnGetOneObject.SetPosPixel( aBtnGetOneObject.GetPosPixel() + aPt );
     727           0 :         aBtnGetAllObjects.SetPosPixel( aBtnGetAllObjects.GetPosPixel() + aPt );
     728           0 :         aBtnRemoveBitmap.SetPosPixel( aBtnRemoveBitmap.GetPosPixel() + aPt );
     729           0 :         aBtnRemoveAll.SetPosPixel( aBtnRemoveAll.GetPosPixel() + aPt );
     730           0 :         aBtnCreateGroup.SetPosPixel( aBtnCreateGroup.GetPosPixel() + aPt );
     731           0 :         aGrpBitmap.SetPosPixel( aGrpBitmap.GetPosPixel() + aPt );
     732           0 :         aGrpAnimation.SetPosPixel( aGrpAnimation.GetPosPixel() + aPt );
     733             : 
     734             :         // calculate and set zoom for DisplayWin
     735           0 :         Fraction aFrac( GetScale() );
     736           0 :         aCtlDisplay.SetScale( aFrac );
     737             : 
     738           0 :         aBtnFirst.Show();
     739           0 :         aBtnReverse.Show();
     740           0 :         aBtnStop.Show();
     741           0 :         aBtnPlay.Show();
     742           0 :         aBtnLast.Show();
     743           0 :         aNumFldBitmap.Show();
     744           0 :         aTimeField.Show();
     745           0 :         aLbLoopCount.Show();
     746           0 :         aFtCount.Show();
     747           0 :         aFiCount.Show();
     748           0 :         aFtAdjustment.Show();
     749           0 :         aLbAdjustment.Show();
     750           0 :         aBtnGetOneObject.Show();
     751           0 :         aBtnGetAllObjects.Show();
     752           0 :         aBtnRemoveBitmap.Show();
     753           0 :         aBtnRemoveAll.Show();
     754           0 :         aGrpBitmap.Show();
     755           0 :         aRbtGroup.Show();
     756           0 :         aRbtBitmap.Show();
     757           0 :         aFtAdjustment.Show();
     758           0 :         aLbAdjustment.Show();
     759           0 :         aBtnCreateGroup.Show();
     760           0 :         aGrpAnimation.Show();
     761             : 
     762           0 :         aSize = aWinSize;
     763             :     }
     764           0 :     SfxDockingWindow::Resize();
     765           0 : }
     766             : 
     767           0 : bool AnimationWindow::Close()
     768             : {
     769           0 :     if( maPlayLock.isLocked() )
     770             :     {
     771           0 :         return false;
     772             :     }
     773             :     else
     774             :     {
     775           0 :         SfxBoolItem aItem( SID_ANIMATION_OBJECTS, false );
     776             : 
     777           0 :         GetBindings().GetDispatcher()->Execute(
     778           0 :             SID_ANIMATION_OBJECTS, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, &aItem, 0L );
     779             : 
     780           0 :         SfxDockingWindow::Close();
     781             : 
     782           0 :         return true;
     783             :     }
     784             : }
     785             : 
     786           0 : void AnimationWindow::FillInfo( SfxChildWinInfo& rInfo ) const
     787             : {
     788           0 :     SfxDockingWindow::FillInfo( rInfo ) ;
     789           0 : }
     790             : 
     791           0 : void AnimationWindow::AddObj (::sd::View& rView )
     792             : {
     793             :     // finish text entry mode to ensure that bitmap is identical with object
     794           0 :     if( rView.IsTextEdit() )
     795           0 :         rView.SdrEndTextEdit();
     796             : 
     797             :     // clone object(s) and insert the clone(s) into the list
     798           0 :     const SdrMarkList& rMarkList   = rView.GetMarkedObjectList();
     799           0 :     const size_t nMarkCount = rMarkList.GetMarkCount();
     800           0 :     SdPage*            pPage       = pMyDoc->GetSdPage(0, PK_STANDARD);
     801           0 :     const size_t nCloneCount = pPage->GetObjCount();
     802             : 
     803           0 :     if (nMarkCount > 0)
     804             :     {
     805             :         // If it is ONE animation object or one group object, which was
     806             :         // 'individually taken', we insert the objects separately
     807           0 :         bool bAnimObj = false;
     808           0 :         if( nMarkCount == 1 )
     809             :         {
     810           0 :             SdrMark*            pMark = rMarkList.GetMark(0);
     811           0 :             SdrObject*          pObject = pMark->GetMarkedSdrObj();
     812           0 :             SdAnimationInfo*    pAnimInfo = rView.GetDoc().GetAnimationInfo( pObject );
     813           0 :             sal_uInt32              nInv = pObject->GetObjInventor();
     814           0 :             sal_uInt16              nId = pObject->GetObjIdentifier();
     815             : 
     816             :             // Animated Bitmap (GIF)
     817           0 :             if( nInv == SdrInventor && nId == OBJ_GRAF && ( (SdrGrafObj*) pObject )->IsAnimated() )
     818             :             {
     819           0 :                 const SdrGrafObj*   pGrafObj = (SdrGrafObj*) pObject;
     820           0 :                 Graphic             aGraphic( pGrafObj->GetTransformedGraphic() );
     821           0 :                 sal_uInt16              nCount = 0;
     822             : 
     823           0 :                 if( aGraphic.IsAnimated() )
     824           0 :                     nCount = aGraphic.GetAnimation().Count();
     825             : 
     826           0 :                 if( nCount > 0 )
     827             :                 {
     828           0 :                     const Animation aAnimation( aGraphic.GetAnimation() );
     829             : 
     830           0 :                     for( sal_uInt16 i = 0; i < nCount; i++ )
     831             :                     {
     832           0 :                         const AnimationBitmap& rAnimBmp = aAnimation.Get( i );
     833             : 
     834             :                         BitmapEx *const pBitmapEx =
     835           0 :                             new BitmapEx(rAnimBmp.aBmpEx);
     836             : 
     837             :                         // LoopCount
     838           0 :                         if( i == 0 )
     839             :                         {
     840           0 :                             long nLoopCount = aAnimation.GetLoopCount();
     841             : 
     842           0 :                             if( !nLoopCount ) // endless
     843           0 :                                 aLbLoopCount.SelectEntryPos( aLbLoopCount.GetEntryCount() - 1);
     844             :                             else
     845           0 :                                 aLbLoopCount.SelectEntry(OUString::number( nLoopCount ) );
     846             :                         }
     847             : 
     848           0 :                         long nTime = rAnimBmp.nWait;
     849           0 :                         ::tools::Time* pTime = new ::tools::Time( 0, 0, nTime / 100, nTime % 100 );
     850             :                         m_FrameList.insert(
     851           0 :                                 m_FrameList.begin() + m_nCurrentFrame + 1,
     852           0 :                                 ::std::make_pair(pBitmapEx, pTime));
     853             : 
     854             :                         // increment => next one inserted after this one
     855           0 :                         ++m_nCurrentFrame;
     856             :                     }
     857             :                     // if a animated GIF is taken, only such one can be created
     858           0 :                     aRbtBitmap.Check();
     859           0 :                     aRbtGroup.Enable( false );
     860           0 :                     bAnimObj = true;
     861           0 :                 }
     862             :             }
     863           0 :             else if( bAllObjects || ( pAnimInfo && pAnimInfo->mbIsMovie ) )
     864             :             {
     865             :                 // several objects
     866           0 :                 SdrObjList* pObjList = ((SdrObjGroup*)pObject)->GetSubList();
     867             : 
     868           0 :                 for( size_t nObject = 0; nObject < pObjList->GetObjCount(); ++nObject )
     869             :                 {
     870           0 :                     SdrObject* pSnapShot = (SdrObject*) pObjList->GetObj( nObject );
     871             : 
     872             :                     BitmapEx *const pBitmapEx = new BitmapEx(
     873             :                         SdrExchangeView::GetObjGraphic(
     874           0 :                             pSnapShot->GetModel(), pSnapShot).GetBitmapEx() );
     875             : 
     876           0 :                     ::tools::Time* pTime = new ::tools::Time( aTimeField.GetTime() );
     877             : 
     878             :                     m_FrameList.insert(
     879           0 :                             m_FrameList.begin() + m_nCurrentFrame + 1,
     880           0 :                             ::std::make_pair(pBitmapEx, pTime));
     881             : 
     882             :                     // increment => next one inserted after this one
     883           0 :                     ++m_nCurrentFrame;
     884             : 
     885             :                     // Clone
     886           0 :                     pPage->InsertObject(pSnapShot->Clone(), m_nCurrentFrame);
     887             :                 }
     888           0 :                 bAnimObj = true;
     889             :             }
     890             :         }
     891             :         // also one single animated object
     892           0 :         if( !bAnimObj && !( bAllObjects && nMarkCount > 1 ) )
     893             :         {
     894             :             BitmapEx *const pBitmapEx =
     895           0 :                 new BitmapEx(rView.GetAllMarkedGraphic().GetBitmapEx());
     896             : 
     897           0 :             ::tools::Time* pTime = new ::tools::Time( aTimeField.GetTime() );
     898             : 
     899             :             m_FrameList.insert(
     900           0 :                     m_FrameList.begin() + m_nCurrentFrame + 1,
     901           0 :                     ::std::make_pair(pBitmapEx, pTime));
     902             :         }
     903             : 
     904             :         // one single object
     905           0 :         if( nMarkCount == 1 && !bAnimObj )
     906             :         {
     907           0 :             SdrMark*    pMark   = rMarkList.GetMark(0);
     908           0 :             SdrObject*  pObject = pMark->GetMarkedSdrObj();
     909           0 :             SdrObject*  pClone  = pObject->Clone();
     910           0 :             pPage->InsertObject(pClone, m_nCurrentFrame + 1);
     911             :         }
     912             :         // several objects: group the clones
     913           0 :         else if (nMarkCount > 1)
     914             :         {
     915             :             // take objects separately
     916           0 :             if( bAllObjects )
     917             :             {
     918           0 :                 for( size_t nObject= 0; nObject < nMarkCount; ++nObject )
     919             :                 {
     920             :                     // Clone
     921           0 :                     SdrObject* pObject = rMarkList.GetMark( nObject )->GetMarkedSdrObj();
     922             : 
     923             :                     BitmapEx *const pBitmapEx = new BitmapEx(
     924             :                         SdrExchangeView::GetObjGraphic(
     925           0 :                             pObject->GetModel(), pObject).GetBitmapEx() );
     926             : 
     927           0 :                     ::tools::Time* pTime = new ::tools::Time( aTimeField.GetTime() );
     928             : 
     929             :                     m_FrameList.insert(
     930           0 :                         m_FrameList.begin() + m_nCurrentFrame + 1,
     931           0 :                         ::std::make_pair(pBitmapEx, pTime));
     932             : 
     933             :                     // increment => next one inserted after this one
     934           0 :                     ++m_nCurrentFrame;
     935             : 
     936           0 :                     pPage->InsertObject(pObject->Clone(), m_nCurrentFrame);
     937             :                 }
     938           0 :                 bAnimObj = true; // that we don't change again
     939             :             }
     940             :             else
     941             :             {
     942           0 :                 SdrObjGroup* pCloneGroup = new SdrObjGroup;
     943           0 :                 SdrObjList*  pObjList    = pCloneGroup->GetSubList();
     944             : 
     945           0 :                 for (size_t nObject= 0; nObject < nMarkCount; ++nObject)
     946           0 :                     pObjList->InsertObject(rMarkList.GetMark(nObject)->GetMarkedSdrObj()->Clone());
     947             : 
     948           0 :                 pPage->InsertObject(pCloneGroup, m_nCurrentFrame + 1);
     949             :             }
     950             :         }
     951             : 
     952           0 :         if( !bAnimObj )
     953             :         {
     954           0 :             ++m_nCurrentFrame;
     955             :         }
     956             : 
     957             :         // if there was nothing in the animator before but now is something
     958             :         // there, we can create a animation group
     959           0 :         if (nCloneCount == 0 && !m_FrameList.empty())
     960             :         {
     961           0 :             aBtnCreateGroup.Enable();
     962             :         }
     963             : 
     964             :         // calculate and set zoom for DisplayWin
     965           0 :         Fraction aFrac( GetScale() );
     966           0 :         aCtlDisplay.SetScale( aFrac );
     967             : 
     968           0 :         UpdateControl();
     969             :     }
     970           0 : }
     971             : 
     972           0 : void AnimationWindow::CreateAnimObj (::sd::View& rView )
     973             : {
     974           0 :     vcl::Window* pOutWin = static_cast< vcl::Window*>(rView.GetFirstOutputDevice()); // GetWin( 0 );
     975             :     DBG_ASSERT( pOutWin, "Window does not exist!" );
     976             : 
     977             :     // find window center
     978           0 :     const MapMode       aMap100( MAP_100TH_MM );
     979           0 :     Size                aMaxSizeLog;
     980           0 :     Size                aMaxSizePix;
     981           0 :     Size                aTemp( pOutWin->GetOutputSizePixel() );
     982           0 :     const Point         aWindowCenter( pOutWin->PixelToLogic( Point( aTemp.Width() >> 1, aTemp.Height() >> 1 ) ) );
     983           0 :     const OutputDevice* pDefDev = Application::GetDefaultDevice();
     984           0 :     const size_t nCount = m_FrameList.size();
     985           0 :     BitmapAdjustment    eBA = (BitmapAdjustment) aLbAdjustment.GetSelectEntryPos();
     986             : 
     987             :     // find biggest bitmap
     988           0 :     for (size_t i = 0; i < nCount; ++i)
     989             :     {
     990           0 :         const BitmapEx& rBmpEx = *m_FrameList[i].first;
     991           0 :         const Graphic   aGraphic( rBmpEx );
     992           0 :         Size            aTmpSizeLog;
     993           0 :         const Size      aTmpSizePix( rBmpEx.GetSizePixel() );
     994             : 
     995           0 :         if ( aGraphic.GetPrefMapMode().GetMapUnit() == MAP_PIXEL )
     996           0 :             aTmpSizeLog = pDefDev->PixelToLogic( aGraphic.GetPrefSize(), aMap100 );
     997             :         else
     998           0 :             aTmpSizeLog = OutputDevice::LogicToLogic( aGraphic.GetPrefSize(), aGraphic.GetPrefMapMode(), aMap100 );
     999             : 
    1000           0 :         aMaxSizeLog.Width() = std::max( aMaxSizeLog.Width(), aTmpSizeLog.Width() );
    1001           0 :         aMaxSizeLog.Height() = std::max( aMaxSizeLog.Height(), aTmpSizeLog.Height() );
    1002             : 
    1003           0 :         aMaxSizePix.Width() = std::max( aMaxSizePix.Width(), aTmpSizePix.Width() );
    1004           0 :         aMaxSizePix.Height() = std::max( aMaxSizePix.Height(), aTmpSizePix.Height() );
    1005           0 :     }
    1006             : 
    1007           0 :     SdrPageView* pPV = rView.GetSdrPageView();
    1008             : 
    1009           0 :     if( aRbtBitmap.IsChecked() )
    1010             :     {
    1011             :         // create bitmap group (Animated GIF)
    1012           0 :         Animation   aAnimation;
    1013           0 :         Point       aPt;
    1014             : 
    1015           0 :         for (size_t i = 0; i < nCount; ++i)
    1016             :         {
    1017           0 :             tools::Time *const pTime = m_FrameList[i].second;
    1018           0 :             long  nTime = pTime->GetNanoSec();
    1019           0 :             nTime += pTime->GetSec() * 100;
    1020             : 
    1021           0 :             BitmapEx const*const pBitmapEx = m_FrameList[i].first;
    1022             : 
    1023             :             // calculate offset for the specified direction
    1024           0 :             const Size aBitmapSize( pBitmapEx->GetSizePixel() );
    1025             : 
    1026           0 :             switch( eBA )
    1027             :             {
    1028             :                 case BA_LEFT_UP:
    1029           0 :                 break;
    1030             : 
    1031             :                 case BA_LEFT:
    1032           0 :                     aPt.Y() = (aMaxSizePix.Height() - aBitmapSize.Height()) >> 1;
    1033           0 :                 break;
    1034             : 
    1035             :                 case BA_LEFT_DOWN:
    1036           0 :                     aPt.Y() = aMaxSizePix.Height() - aBitmapSize.Height();
    1037           0 :                 break;
    1038             : 
    1039             :                 case BA_UP:
    1040           0 :                     aPt.X() = (aMaxSizePix.Width() - aBitmapSize.Width()) >> 1;
    1041           0 :                 break;
    1042             : 
    1043             :                 case BA_CENTER:
    1044           0 :                     aPt.X()  = (aMaxSizePix.Width() - aBitmapSize.Width()) >> 1;
    1045           0 :                     aPt.Y() = (aMaxSizePix.Height() - aBitmapSize.Height()) >> 1;
    1046           0 :                 break;
    1047             : 
    1048             :                 case BA_DOWN:
    1049           0 :                     aPt.X()  = (aMaxSizePix.Width() - aBitmapSize.Width()) >> 1;
    1050           0 :                     aPt.Y() = aMaxSizePix.Height() - aBitmapSize.Height();
    1051           0 :                 break;
    1052             : 
    1053             :                 case BA_RIGHT_UP:
    1054           0 :                     aPt.X() = aMaxSizePix.Width() - aBitmapSize.Width();
    1055           0 :                 break;
    1056             : 
    1057             :                 case BA_RIGHT:
    1058           0 :                     aPt.X()  = aMaxSizePix.Width() - aBitmapSize.Width();
    1059           0 :                     aPt.Y() = (aMaxSizePix.Height() - aBitmapSize.Height()) >> 1;
    1060           0 :                 break;
    1061             : 
    1062             :                 case BA_RIGHT_DOWN:
    1063           0 :                     aPt.X()  = aMaxSizePix.Width() - aBitmapSize.Width();
    1064           0 :                     aPt.Y() = aMaxSizePix.Height() - aBitmapSize.Height();
    1065           0 :                 break;
    1066             : 
    1067             :             }
    1068             : 
    1069             :             // find LoopCount (number of passes)
    1070           0 :             AnimationBitmap aAnimBmp;
    1071           0 :             long            nLoopCount = 0L;
    1072           0 :             sal_Int32          nPos = aLbLoopCount.GetSelectEntryPos();
    1073             : 
    1074           0 :             if( nPos != LISTBOX_ENTRY_NOTFOUND && nPos != aLbLoopCount.GetEntryCount() - 1 ) // endless
    1075           0 :                 nLoopCount = (long) aLbLoopCount.GetSelectEntry().toInt32();
    1076             : 
    1077           0 :             aAnimBmp.aBmpEx = *pBitmapEx;
    1078           0 :             aAnimBmp.aPosPix = aPt;
    1079           0 :             aAnimBmp.aSizePix = aBitmapSize;
    1080           0 :             aAnimBmp.nWait = nTime;
    1081           0 :             aAnimBmp.eDisposal = DISPOSE_BACK;
    1082           0 :             aAnimBmp.bUserInput = false;
    1083             : 
    1084           0 :             aAnimation.Insert( aAnimBmp );
    1085           0 :             aAnimation.SetDisplaySizePixel( aMaxSizePix );
    1086           0 :             aAnimation.SetLoopCount( nLoopCount );
    1087           0 :         }
    1088             : 
    1089           0 :         SdrGrafObj* pGrafObj = new SdrGrafObj( Graphic( aAnimation ) );
    1090           0 :         const Point aOrg( aWindowCenter.X() - ( aMaxSizeLog.Width() >> 1 ), aWindowCenter.Y() - ( aMaxSizeLog.Height() >> 1 ) );
    1091             : 
    1092           0 :         pGrafObj->SetLogicRect( Rectangle( aOrg, aMaxSizeLog ) );
    1093           0 :         rView.InsertObjectAtView( pGrafObj, *pPV, SDRINSERT_SETDEFLAYER);
    1094             :     }
    1095             :     else
    1096             :     {
    1097             :         // calculate offset for the specified direction
    1098           0 :         Size aOffset;
    1099           0 :         SdrObject * pClone = NULL;
    1100           0 :         SdPage* pPage = pMyDoc->GetSdPage(0, PK_STANDARD);
    1101             : 
    1102           0 :         for (size_t i = 0; i < nCount; ++i)
    1103             :         {
    1104           0 :             pClone = pPage->GetObj(i);
    1105           0 :             Rectangle aRect( pClone->GetSnapRect() );
    1106             : 
    1107           0 :             switch( eBA )
    1108             :             {
    1109             :                 case BA_LEFT_UP:
    1110           0 :                 break;
    1111             : 
    1112             :                 case BA_LEFT:
    1113           0 :                     aOffset.Height() = (aMaxSizeLog.Height() - aRect.GetHeight()) / 2;
    1114           0 :                 break;
    1115             : 
    1116             :                 case BA_LEFT_DOWN:
    1117           0 :                     aOffset.Height() = aMaxSizeLog.Height() - aRect.GetHeight();
    1118           0 :                 break;
    1119             : 
    1120             :                 case BA_UP:
    1121           0 :                     aOffset.Width() = (aMaxSizeLog.Width() - aRect.GetWidth()) / 2;
    1122           0 :                 break;
    1123             : 
    1124             :                 case BA_CENTER:
    1125           0 :                     aOffset.Width()  = (aMaxSizeLog.Width() - aRect.GetWidth()) / 2;
    1126           0 :                     aOffset.Height() = (aMaxSizeLog.Height() - aRect.GetHeight()) / 2;
    1127           0 :                 break;
    1128             : 
    1129             :                 case BA_DOWN:
    1130           0 :                     aOffset.Width()  = (aMaxSizeLog.Width() - aRect.GetWidth()) / 2;
    1131           0 :                     aOffset.Height() = aMaxSizeLog.Height() - aRect.GetHeight();
    1132           0 :                 break;
    1133             : 
    1134             :                 case BA_RIGHT_UP:
    1135           0 :                     aOffset.Width() = aMaxSizeLog.Width() - aRect.GetWidth();
    1136           0 :                 break;
    1137             : 
    1138             :                 case BA_RIGHT:
    1139           0 :                     aOffset.Width()  = aMaxSizeLog.Width() - aRect.GetWidth();
    1140           0 :                     aOffset.Height() = (aMaxSizeLog.Height() - aRect.GetHeight()) / 2;
    1141           0 :                 break;
    1142             : 
    1143             :                 case BA_RIGHT_DOWN:
    1144           0 :                     aOffset.Width()  = aMaxSizeLog.Width() - aRect.GetWidth();
    1145           0 :                     aOffset.Height() = aMaxSizeLog.Height() - aRect.GetHeight();
    1146           0 :                 break;
    1147             : 
    1148             :             }
    1149             :             // Unfortunately, SetSnapRect is not implemented for ellipses !!!
    1150           0 :             Point aMovePt( aWindowCenter + Point( aOffset.Width(), aOffset.Height() ) - aRect.TopLeft() );
    1151           0 :             Size aMoveSize( aMovePt.X(), aMovePt.Y() );
    1152           0 :             pClone->NbcMove( aMoveSize );
    1153             :         }
    1154             : 
    1155             :         // #i42894# Caution(!) variable pPage looks right, but it is a page from the local
    1156             :         // document the dialog is using (!), so get the target page from the target view
    1157           0 :         SdPage* pTargetSdPage = dynamic_cast< SdPage* >(rView.GetSdrPageView() ? rView.GetSdrPageView()->GetPage() : 0);
    1158             : 
    1159           0 :         if(pTargetSdPage)
    1160             :         {
    1161             :             // create animation group
    1162           0 :             SdrObjGroup* pGroup   = new SdrObjGroup;
    1163           0 :             SdrObjList*  pObjList = pGroup->GetSubList();
    1164             : 
    1165           0 :             for (size_t i = 0; i < nCount; ++i)
    1166             :             {
    1167             :                 // the clone remains in the animatior; we insert a clone of the
    1168             :                 // clone into the group
    1169           0 :                 pClone = pPage->GetObj(i);
    1170           0 :                 SdrObject* pCloneOfClone = pClone->Clone();
    1171             :                 //SdrObject* pCloneOfClone = pPage->GetObj(i)->Clone();
    1172           0 :                 pObjList->InsertObject(pCloneOfClone);
    1173             :             }
    1174             : 
    1175             :             // until now the top left corner of the group is in the window center;
    1176             :             // correct the position by half of the size of the group
    1177           0 :             aTemp = aMaxSizeLog;
    1178           0 :             aTemp.Height() = - aTemp.Height() / 2;
    1179           0 :             aTemp.Width()  = - aTemp.Width() / 2;
    1180           0 :             pGroup->NbcMove(aTemp);
    1181             : 
    1182             :             // #i42894# create needed SMIL stuff and move child objects to page directly (see
    1183             :             // comments at EffectMigration::CreateAnimatedGroup why this has to be done).
    1184           0 :             EffectMigration::CreateAnimatedGroup(*pGroup, *pTargetSdPage);
    1185             : 
    1186             :             // #i42894# if that worked, delete the group again
    1187           0 :             if(!pGroup->GetSubList()->GetObjCount())
    1188             :             {
    1189           0 :                 delete pGroup;
    1190             :             }
    1191             :         }
    1192             :     }
    1193             : 
    1194           0 :     ClickFirstHdl( this );
    1195           0 : }
    1196             : 
    1197           0 : void AnimationWindow::DataChanged( const DataChangedEvent& rDCEvt )
    1198             : {
    1199           0 :     SfxDockingWindow::DataChanged( rDCEvt );
    1200             : 
    1201           0 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
    1202             :     {
    1203           0 :         UpdateControl();
    1204             :     }
    1205           0 : }
    1206             : 
    1207             : /**
    1208             :  * ControllerItem for Animator
    1209             :  */
    1210           0 : AnimationControllerItem::AnimationControllerItem(
    1211             :     sal_uInt16 _nId,
    1212             :     AnimationWindow* pAnimWin,
    1213             :     SfxBindings*    _pBindings)
    1214             :     : SfxControllerItem( _nId, *_pBindings ),
    1215           0 :       pAnimationWin( pAnimWin )
    1216             : {
    1217           0 : }
    1218             : 
    1219           0 : void AnimationControllerItem::StateChanged( sal_uInt16 nSId,
    1220             :                         SfxItemState eState, const SfxPoolItem* pItem )
    1221             : {
    1222           0 :     if( eState >= SfxItemState::DEFAULT && nSId == SID_ANIMATOR_STATE )
    1223             :     {
    1224           0 :         const SfxUInt16Item* pStateItem = PTR_CAST( SfxUInt16Item, pItem );
    1225             :         assert(pStateItem); //SfxUInt16Item expected
    1226           0 :         if (pStateItem)
    1227             :         {
    1228           0 :             sal_uInt16 nState = pStateItem->GetValue();
    1229           0 :             pAnimationWin->aBtnGetOneObject.Enable( nState & 1 );
    1230           0 :             pAnimationWin->aBtnGetAllObjects.Enable( nState & 2 );
    1231             :         }
    1232             :     }
    1233           0 : }
    1234             : 
    1235         114 : } // end of namespace sd
    1236             : 
    1237             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10