LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/dlg - animobjs.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 634 0.2 %
Date: 2012-12-17 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/dispatch.hxx>
      28             : #include <sfx2/progress.hxx>
      29             : #include <vcl/msgbox.hxx>
      30             : #include "anminfo.hxx"
      31             : #include "animobjs.hxx"
      32             : #include "animobjs.hrc"
      33             : #include "app.hrc"
      34             : #include "strings.hrc"
      35             : #include "sdresid.hxx"
      36             : #include "View.hxx"
      37             : #include "drawdoc.hxx"
      38             : #include "sdpage.hxx"
      39             : #include "res_bmp.hrc"
      40             : #include "ViewShell.hxx"
      41             : 
      42             : #include <vcl/svapp.hxx>
      43             : 
      44             : #include <string>
      45             : #include <algorithm>
      46             : 
      47             : using namespace ::com::sun::star;
      48             : 
      49             : namespace sd {
      50             : 
      51             : /*************************************************************************
      52             : |*  SdDisplay - Control
      53             : \************************************************************************/
      54             : 
      55           0 : SdDisplay::SdDisplay( Window* pWin, SdResId Id ) :
      56             :         Control( pWin, Id ),
      57           0 :         aScale( 1, 1 )
      58             : {
      59           0 :     SetMapMode( MAP_PIXEL );
      60           0 :     const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
      61           0 :     SetBackground( Wallpaper( Color( rStyles.GetFieldColor() ) ) );
      62           0 : }
      63             : 
      64             : // -----------------------------------------------------------------------
      65             : 
      66           0 : SdDisplay::~SdDisplay()
      67             : {
      68           0 : }
      69             : 
      70             : // -----------------------------------------------------------------------
      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             : // -----------------------------------------------------------------------
      87             : 
      88           0 : void SdDisplay::Paint( const Rectangle& )
      89             : {
      90           0 :     Point aPt;
      91           0 :     Size aSize = GetOutputSize();
      92           0 :     Size aBmpSize = aBitmapEx.GetBitmap().GetSizePixel();
      93           0 :     aBmpSize.Width() = (long) ( (double) aBmpSize.Width() * (double) aScale );
      94           0 :     aBmpSize.Height() = (long) ( (double) aBmpSize.Height() * (double) aScale );
      95             : 
      96           0 :     if( aBmpSize.Width() < aSize.Width() )
      97           0 :         aPt.X() = ( aSize.Width() - aBmpSize.Width() ) / 2;
      98           0 :     if( aBmpSize.Height() < aSize.Height() )
      99           0 :         aPt.Y() = ( aSize.Height() - aBmpSize.Height() ) / 2;
     100             : 
     101           0 :     aBitmapEx.Draw( this, aPt, aBmpSize );
     102           0 : }
     103             : 
     104             : // -----------------------------------------------------------------------
     105             : 
     106           0 : void SdDisplay::SetScale( const Fraction& rFrac )
     107             : {
     108           0 :     aScale = rFrac;
     109           0 : }
     110             : 
     111           0 : void SdDisplay::DataChanged( const DataChangedEvent& rDCEvt )
     112             : {
     113           0 :     Control::DataChanged( rDCEvt );
     114             : 
     115           0 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     116             :     {
     117           0 :         const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
     118           0 :         SetBackground( Wallpaper( Color( rStyles.GetFieldColor() ) ) );
     119           0 :         SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode()
     120             :             ? ViewShell::OUTPUT_DRAWMODE_CONTRAST
     121           0 :             : ViewShell::OUTPUT_DRAWMODE_COLOR );
     122             :     }
     123           0 : }
     124             : 
     125             : /*************************************************************************
     126             : |*  AnimationWindow - FloatingWindow
     127             : \************************************************************************/
     128             : 
     129           0 : AnimationWindow::AnimationWindow( SfxBindings* pInBindings,
     130             :                 SfxChildWindow *pCW, Window* pParent, const SdResId& rSdResId ) :
     131             :         SfxDockingWindow    ( pInBindings, pCW, pParent, rSdResId ),
     132             :         aCtlDisplay         ( this, SdResId( CTL_DISPLAY ) ),
     133             :         aBtnFirst           ( this, SdResId( BTN_FIRST ) ),
     134             :         aBtnReverse         ( this, SdResId( BTN_REVERSE ) ),
     135             :         aBtnStop            ( this, SdResId( BTN_STOP ) ),
     136             :         aBtnPlay            ( this, SdResId( BTN_PLAY ) ),
     137             :         aBtnLast            ( this, SdResId( BTN_LAST ) ),
     138             :         aNumFldBitmap       ( this, SdResId( NUM_FLD_BITMAP ) ),
     139             :         aTimeField          ( this, SdResId( TIME_FIELD ) ),
     140             :         aLbLoopCount        ( this, SdResId( LB_LOOP_COUNT ) ),
     141             :         aGrpBitmap          ( this, SdResId( GRP_BITMAP ) ),
     142             :         aBtnGetOneObject    ( this, SdResId( BTN_GET_ONE_OBJECT ) ),
     143             :         aBtnGetAllObjects   ( this, SdResId( BTN_GET_ALL_OBJECTS ) ),
     144             :         aBtnRemoveBitmap    ( this, SdResId( BTN_REMOVE_BITMAP ) ),
     145             :         aBtnRemoveAll       ( this, SdResId( BTN_REMOVE_ALL ) ),
     146             :         aFtCount            ( this, SdResId( FT_COUNT ) ),
     147             :         aFiCount            ( this, SdResId( FI_COUNT ) ),
     148             :         aGrpAnimation       ( this, SdResId( GRP_ANIMATION_GROUP ) ),
     149             :         aRbtGroup           ( this, SdResId( RBT_GROUP ) ),
     150             :         aRbtBitmap          ( this, SdResId( RBT_BITMAP ) ),
     151             :         aFtAdjustment       ( this, SdResId( FT_ADJUSTMENT ) ),
     152             :         aLbAdjustment       ( this, SdResId( LB_ADJUSTMENT ) ),
     153             :         aBtnCreateGroup     ( this, SdResId( BTN_CREATE_GROUP ) ),
     154             : 
     155             :         pWin                ( pParent ),
     156             :         m_nCurrentFrame     ( EMPTY_FRAMELIST ),
     157             : 
     158             :         bMovie              ( sal_False ),
     159             :         bAllObjects         ( sal_False ),
     160             : 
     161           0 :         pBindings           ( pInBindings )
     162             : {
     163           0 :     aCtlDisplay.SetAccessibleName(String (SdResId(STR_DISPLAY)));
     164           0 :     FreeResource();
     165             : 
     166             :     // neues Dokument mit Seite erzeugen
     167           0 :     pMyDoc = new SdDrawDocument(DOCUMENT_TYPE_IMPRESS, NULL);
     168           0 :     SdPage* pPage = (SdPage*) pMyDoc->AllocPage(sal_False);
     169           0 :     pMyDoc->InsertPage(pPage);
     170             : 
     171           0 :     pControllerItem = new AnimationControllerItem( SID_ANIMATOR_STATE, this, pBindings );
     172             : 
     173             :     // Solange noch nicht in der Resource
     174           0 :     aTimeField.SetFormat( TIMEF_SEC_CS );
     175             : 
     176           0 :     aBtnFirst.SetClickHdl( LINK( this, AnimationWindow, ClickFirstHdl ) );
     177           0 :     aBtnReverse.SetClickHdl( LINK( this, AnimationWindow, ClickPlayHdl ) );
     178           0 :     aBtnStop.SetClickHdl( LINK( this, AnimationWindow, ClickStopHdl ) );
     179           0 :     aBtnPlay.SetClickHdl( LINK( this, AnimationWindow, ClickPlayHdl ) );
     180           0 :     aBtnLast.SetClickHdl( LINK( this, AnimationWindow, ClickLastHdl ) );
     181             : 
     182           0 :     aBtnGetOneObject.SetClickHdl( LINK( this, AnimationWindow, ClickGetObjectHdl ) );
     183           0 :     aBtnGetAllObjects.SetClickHdl( LINK( this, AnimationWindow, ClickGetObjectHdl ) );
     184           0 :     aBtnRemoveBitmap.SetClickHdl( LINK( this, AnimationWindow, ClickRemoveBitmapHdl ) );
     185           0 :     aBtnRemoveAll.SetClickHdl( LINK( this, AnimationWindow, ClickRemoveBitmapHdl ) );
     186             : 
     187           0 :     aRbtGroup.SetClickHdl( LINK( this, AnimationWindow, ClickRbtHdl ) );
     188           0 :     aRbtBitmap.SetClickHdl( LINK( this, AnimationWindow, ClickRbtHdl ) );
     189           0 :     aBtnCreateGroup.SetClickHdl( LINK( this, AnimationWindow, ClickCreateGroupHdl ) );
     190           0 :     aNumFldBitmap.SetModifyHdl( LINK( this, AnimationWindow, ModifyBitmapHdl ) );
     191           0 :     aTimeField.SetModifyHdl( LINK( this, AnimationWindow, ModifyTimeHdl ) );
     192             : 
     193             :     // disable 3D border
     194           0 :     aCtlDisplay.SetBorderStyle(WINDOW_BORDER_MONO);
     195           0 :     aDisplaySize = aCtlDisplay.GetOutputSize();
     196             : 
     197           0 :     aSize = GetOutputSizePixel();
     198           0 :     SetMinOutputSizePixel( aSize );
     199             : 
     200           0 :     ResetAttrs();
     201             : 
     202             :     // der Animator ist leer; es kann keine Animationsgruppe erstellt werden
     203           0 :     aBtnCreateGroup.Disable();
     204             : 
     205           0 :     aBtnGetOneObject.SetAccessibleRelationMemberOf( &aGrpBitmap );
     206           0 :     aBtnGetAllObjects.SetAccessibleRelationMemberOf( &aGrpBitmap );
     207           0 :     aBtnRemoveBitmap.SetAccessibleRelationMemberOf( &aGrpBitmap );
     208           0 :     aBtnRemoveAll.SetAccessibleRelationMemberOf( &aGrpBitmap );
     209           0 : }
     210             : 
     211             : // -----------------------------------------------------------------------
     212             : 
     213           0 : AnimationWindow::~AnimationWindow()
     214             : {
     215           0 :     delete pControllerItem;
     216             : 
     217           0 :     for (size_t i = 0; i < m_FrameList.size(); ++i)
     218             :     {
     219           0 :         delete m_FrameList[i].first;
     220           0 :         delete m_FrameList[i].second;
     221             :     }
     222           0 :     m_FrameList.clear();
     223           0 :     m_nCurrentFrame = EMPTY_FRAMELIST;
     224             : 
     225             :     // die Clones loeschen
     226           0 :     delete pMyDoc;
     227           0 : }
     228             : 
     229             : // -----------------------------------------------------------------------
     230             : 
     231           0 : IMPL_LINK_NOARG(AnimationWindow, ClickFirstHdl)
     232             : {
     233           0 :     m_nCurrentFrame = (m_FrameList.empty()) ? EMPTY_FRAMELIST : 0;
     234           0 :     UpdateControl();
     235             : 
     236           0 :     return( 0L );
     237             : }
     238             : 
     239             : // -----------------------------------------------------------------------
     240             : 
     241           0 : IMPL_LINK_NOARG(AnimationWindow, ClickStopHdl)
     242             : {
     243           0 :     bMovie = sal_False;
     244           0 :     return( 0L );
     245             : }
     246             : 
     247             : // -----------------------------------------------------------------------
     248             : 
     249           0 : IMPL_LINK( AnimationWindow, ClickPlayHdl, void *, p )
     250             : {
     251           0 :     ScopeLockGuard aGuard( maPlayLock );
     252             : 
     253           0 :     bMovie = sal_True;
     254           0 :     sal_Bool bDisableCtrls = sal_False;
     255           0 :     size_t const nCount = m_FrameList.size();
     256           0 :     sal_Bool bReverse = p == &aBtnReverse;
     257             : 
     258             :     // Kann spaeter schwer ermittelt werden
     259           0 :     sal_Bool bRbtGroupEnabled = aRbtGroup.IsEnabled();
     260           0 :     sal_Bool bBtnGetAllObjectsEnabled = aBtnGetAllObjects.IsEnabled();
     261           0 :     sal_Bool bBtnGetOneObjectEnabled = aBtnGetOneObject.IsEnabled();
     262             : 
     263             :     // Gesamtzeit ermitteln
     264           0 :     Time aTime( 0 );
     265             :     long nFullTime;
     266           0 :     if( aRbtBitmap.IsChecked() )
     267             :     {
     268           0 :         for (size_t i = 0; i < nCount; ++i)
     269             :         {
     270           0 :             aTime += *m_FrameList[i].second;
     271             :         }
     272           0 :         nFullTime  = aTime.GetMSFromTime();
     273             :     }
     274             :     else
     275             :     {
     276           0 :         nFullTime = nCount * 100;
     277           0 :         aTime.MakeTimeFromMS( nFullTime );
     278             :     }
     279             : 
     280             :     // StatusBarManager ab 1 Sekunde
     281           0 :     SfxProgress* pProgress = NULL;
     282           0 :     if( nFullTime >= 1000 )
     283             :     {
     284           0 :         bDisableCtrls = sal_True;
     285           0 :         aBtnStop.Enable();
     286           0 :         aBtnStop.Update();
     287           0 :         rtl::OUString aStr("Animator:"); // Hier sollte man sich noch etwas gescheites ausdenken!
     288           0 :         pProgress = new SfxProgress( NULL, aStr, nFullTime );
     289             :     }
     290             : 
     291           0 :     sal_uLong nTmpTime = 0;
     292           0 :     size_t i = 0;
     293           0 :     sal_Bool bCount = i < nCount;
     294           0 :     if( bReverse )
     295             :     {
     296           0 :         i = nCount - 1;
     297             :     }
     298           0 :     while( bCount && bMovie )
     299             :     {
     300             :         // make list and view consistent
     301             :         assert(0 < i && i < m_FrameList.size());
     302           0 :         m_nCurrentFrame = i;
     303             : 
     304           0 :         UpdateControl(bDisableCtrls);
     305             : 
     306           0 :         if( aRbtBitmap.IsChecked() )
     307             :         {
     308           0 :             Time *const pTime = m_FrameList[i].second;
     309             :             assert(pTime);
     310             : 
     311           0 :             aTimeField.SetTime( *pTime );
     312           0 :             sal_uLong nTime = pTime->GetMSFromTime();
     313             : 
     314           0 :             WaitInEffect( nTime, nTmpTime, pProgress );
     315           0 :             nTmpTime += nTime;
     316             :         }
     317             :         else
     318             :         {
     319           0 :             WaitInEffect( 100, nTmpTime, pProgress );
     320           0 :             nTmpTime += 100;
     321             :         }
     322           0 :         if( bReverse )
     323             :         {
     324           0 :             if (i == 0)
     325             :             {
     326             :                 // Terminate loop.
     327           0 :                 bCount = false;
     328             :             }
     329             :             else
     330             :             {
     331           0 :                 --i;
     332             :             }
     333             :         }
     334             :         else
     335             :         {
     336           0 :             i++;
     337           0 :             if (i >= nCount)
     338             :             {
     339             :                 // Terminate loop.
     340           0 :                 bCount = false;
     341             :                 // Move i back into valid range.
     342           0 :                 i = nCount - 1;
     343             :             }
     344             :         }
     345             :     }
     346             : 
     347             :     // Um die Controls wieder zu enablen
     348           0 :     bMovie = sal_False;
     349           0 :     if (nCount > 0)
     350             :     {
     351             :         assert(i == m_nCurrentFrame);
     352           0 :         UpdateControl();
     353             :     }
     354             : 
     355           0 :     if( pProgress )
     356             :     {
     357           0 :         delete pProgress;
     358           0 :         aBtnStop.Disable();
     359             :     }
     360             : 
     361           0 :     aRbtGroup.Enable( bRbtGroupEnabled );
     362           0 :     aBtnGetAllObjects.Enable( bBtnGetAllObjectsEnabled );
     363           0 :     aBtnGetOneObject.Enable( bBtnGetOneObjectEnabled );
     364             : 
     365           0 :     return( 0L );
     366             : }
     367             : 
     368             : // -----------------------------------------------------------------------
     369             : 
     370           0 : IMPL_LINK_NOARG(AnimationWindow, ClickLastHdl)
     371             : {
     372             :     m_nCurrentFrame =
     373           0 :         (m_FrameList.empty()) ? EMPTY_FRAMELIST : m_FrameList.size() - 1 ;
     374           0 :     UpdateControl();
     375             : 
     376           0 :     return( 0L );
     377             : }
     378             : 
     379             : // -----------------------------------------------------------------------
     380             : 
     381           0 : IMPL_LINK( AnimationWindow, ClickRbtHdl, void *, p )
     382             : {
     383           0 :     if (m_FrameList.empty() || p == &aRbtGroup || aRbtGroup.IsChecked())
     384             :     {
     385           0 :         aTimeField.SetText( String() );
     386           0 :         aTimeField.Enable( sal_False );
     387           0 :         aLbLoopCount.Enable( sal_False );
     388             :     }
     389           0 :     else if( p == &aRbtBitmap || aRbtBitmap.IsChecked() )
     390             :     {
     391           0 :         sal_uLong n = static_cast<sal_uLong>(aNumFldBitmap.GetValue());
     392           0 :         if( n > 0 )
     393             :         {
     394           0 :             Time *const pTime = m_FrameList[n - 1].second;
     395           0 :             if( pTime )
     396           0 :                 aTimeField.SetTime( *pTime );
     397             :         }
     398           0 :         aTimeField.Enable();
     399           0 :         aLbLoopCount.Enable();
     400             :     }
     401             : 
     402           0 :     return( 0L );
     403             : }
     404             : 
     405             : // -----------------------------------------------------------------------
     406             : 
     407           0 : IMPL_LINK( AnimationWindow, ClickGetObjectHdl, void *, pBtn )
     408             : {
     409           0 :     bAllObjects = pBtn == &aBtnGetAllObjects;
     410             : 
     411             :     // Code jetzt in AddObj()
     412           0 :     SfxBoolItem aItem( SID_ANIMATOR_ADD, sal_True );
     413             : 
     414           0 :     GetBindings().GetDispatcher()->Execute(
     415           0 :         SID_ANIMATOR_ADD, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, &aItem, 0L );
     416           0 :     return( 0L );
     417             : }
     418             : 
     419             : // -----------------------------------------------------------------------
     420             : 
     421           0 : IMPL_LINK( AnimationWindow, ClickRemoveBitmapHdl, void *, pBtn )
     422             : {
     423           0 :     SdPage*     pPage = pMyDoc->GetSdPage(0, PK_STANDARD);
     424             :     SdrObject*  pObject;
     425             : 
     426           0 :     if( pBtn == &aBtnRemoveBitmap )
     427             :     {
     428           0 :         delete m_FrameList[m_nCurrentFrame].first;
     429           0 :         delete m_FrameList[m_nCurrentFrame].second;
     430           0 :         m_FrameList.erase(m_FrameList.begin() + m_nCurrentFrame);
     431             : 
     432           0 :         pObject = pPage->GetObj(m_nCurrentFrame);
     433             :         // Durch Uebernahme der AnimatedGIFs muessen nicht unbedingt
     434             :         // Objekte vorhanden sein.
     435           0 :         if( pObject )
     436             :         {
     437           0 :             pObject = pPage->RemoveObject(m_nCurrentFrame);
     438             :             DBG_ASSERT(pObject, "Clone beim Loeschen nicht gefunden");
     439           0 :             SdrObject::Free( pObject );
     440           0 :             pPage->RecalcObjOrdNums();
     441             :         }
     442             : 
     443           0 :         if (m_nCurrentFrame >= m_FrameList.size())
     444             :         {
     445             :             assert(m_FrameList.empty());
     446           0 :             m_nCurrentFrame = EMPTY_FRAMELIST;
     447             :         }
     448             :     }
     449             :     else // Alles loeschen
     450             :     {
     451           0 :         WarningBox aWarnBox( this, WB_YES_NO, String( SdResId( STR_ASK_DELETE_ALL_PICTURES ) ) );
     452           0 :         short nReturn = aWarnBox.Execute();
     453             : 
     454           0 :         if( nReturn == RET_YES )
     455             :         {
     456             :             // clear frame list
     457           0 :             for (size_t i = m_FrameList.size(); i > 0; )
     458             :             {
     459           0 :                 --i;
     460           0 :                 delete m_FrameList[i].first;
     461             : 
     462           0 :                 pObject = pPage->GetObj( i );
     463           0 :                 if( pObject )
     464             :                 {
     465           0 :                     pObject = pPage->RemoveObject( i );
     466             :                     DBG_ASSERT(pObject, "Clone beim Loeschen nicht gefunden");
     467           0 :                     SdrObject::Free( pObject );
     468             :                     //pPage->RecalcObjOrdNums();
     469             :                 }
     470             : 
     471           0 :                 delete m_FrameList[i].second;
     472             :             }
     473           0 :             m_FrameList.clear();
     474           0 :             m_nCurrentFrame = EMPTY_FRAMELIST;
     475           0 :         }
     476             :     }
     477             : 
     478             :     // kann noch eine Animationsgruppe erstellt werden?
     479           0 :     if (m_FrameList.empty())
     480             :     {
     481           0 :         aBtnCreateGroup.Disable();
     482             :         // Falls vorher durch Uebernahme von AnimatedGIFs disabled:
     483             :         //aRbtBitmap.Enable();
     484           0 :         aRbtGroup.Enable();
     485             :     }
     486             : 
     487             :     // Zoom fuer DisplayWin berechnen und setzen
     488           0 :     Fraction aFrac( GetScale() );
     489           0 :     aCtlDisplay.SetScale( aFrac );
     490             : 
     491           0 :     UpdateControl();
     492             : 
     493           0 :     return( 0L );
     494             : }
     495             : 
     496             : // -----------------------------------------------------------------------
     497             : 
     498           0 : IMPL_LINK_NOARG(AnimationWindow, ClickCreateGroupHdl)
     499             : {
     500             :     // Code jetzt in CreatePresObj()
     501           0 :     SfxBoolItem aItem( SID_ANIMATOR_CREATE, sal_True );
     502             : 
     503           0 :     GetBindings().GetDispatcher()->Execute(
     504           0 :         SID_ANIMATOR_CREATE, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, &aItem, 0L );
     505           0 :     return( 0L );
     506             : }
     507             : 
     508             : // -----------------------------------------------------------------------
     509             : 
     510           0 : IMPL_LINK_NOARG(AnimationWindow, ModifyBitmapHdl)
     511             : {
     512           0 :     sal_uLong nBmp = static_cast<sal_uLong>(aNumFldBitmap.GetValue());
     513             : 
     514           0 :     if (nBmp > m_FrameList.size())
     515             :     {
     516           0 :         nBmp = m_FrameList.size();
     517             :     }
     518             : 
     519           0 :     m_nCurrentFrame = nBmp - 1;
     520             : 
     521           0 :     UpdateControl();
     522             : 
     523           0 :     return( 0L );
     524             : }
     525             : 
     526             : // -----------------------------------------------------------------------
     527             : 
     528           0 : IMPL_LINK_NOARG(AnimationWindow, ModifyTimeHdl)
     529             : {
     530           0 :     sal_uLong nPos = static_cast<sal_uLong>(aNumFldBitmap.GetValue() - 1);
     531             : 
     532           0 :     Time *const pTime = m_FrameList[nPos].second;
     533             : 
     534           0 :     *pTime = aTimeField.GetTime();
     535             : 
     536           0 :     return( 0L );
     537             : }
     538             : 
     539             : // -----------------------------------------------------------------------
     540             : 
     541           0 : void AnimationWindow::UpdateControl(bool const bDisableCtrls)
     542             : {
     543           0 :     String aString;
     544             : 
     545           0 :     if (!m_FrameList.empty())
     546             :     {
     547           0 :         BitmapEx aBmp(*m_FrameList[m_nCurrentFrame].first);
     548             : 
     549           0 :         SdPage* pPage = pMyDoc->GetSdPage(0, PK_STANDARD);
     550             :         SdrObject *const pObject =
     551           0 :             static_cast<SdrObject*>(pPage->GetObj(m_nCurrentFrame));
     552           0 :         if( pObject )
     553             :         {
     554           0 :             VirtualDevice   aVD;
     555           0 :             Rectangle       aObjRect( pObject->GetCurrentBoundRect() );
     556           0 :             Size            aObjSize( aObjRect.GetSize() );
     557           0 :             Point           aOrigin( Point( -aObjRect.Left(), -aObjRect.Top() ) );
     558           0 :             MapMode         aMap( aVD.GetMapMode() );
     559           0 :             aMap.SetMapUnit( MAP_100TH_MM );
     560           0 :             aMap.SetOrigin( aOrigin );
     561           0 :             aVD.SetMapMode( aMap );
     562           0 :             aVD.SetOutputSize( aObjSize );
     563           0 :             const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
     564           0 :             aVD.SetBackground( Wallpaper( rStyles.GetFieldColor() ) );
     565           0 :             aVD.SetDrawMode( rStyles.GetHighContrastMode()
     566             :                 ? ViewShell::OUTPUT_DRAWMODE_CONTRAST
     567           0 :                 : ViewShell::OUTPUT_DRAWMODE_COLOR );
     568           0 :             aVD.Erase();
     569           0 :             pObject->SingleObjectPainter( aVD );
     570           0 :             aBmp = BitmapEx( aVD.GetBitmap( aObjRect.TopLeft(), aObjSize ) );
     571             :         }
     572             : 
     573             : 
     574           0 :         aCtlDisplay.SetBitmapEx( &aBmp );
     575             :     }
     576             :     else
     577             :     {
     578           0 :         aCtlDisplay.SetBitmapEx(0);
     579             :     }
     580           0 :     aCtlDisplay.Invalidate();
     581           0 :     aCtlDisplay.Update();
     582             : 
     583             :     aFiCount.SetText(rtl::OUString::valueOf(
     584           0 :                 static_cast<sal_Int64>(m_FrameList.size())));
     585             : 
     586           0 :     if (!m_FrameList.empty() && !bMovie)
     587             :     {
     588           0 :         aNumFldBitmap.SetValue(m_nCurrentFrame + 1);
     589             : 
     590             :         // Wenn mind. 1 Objekt in der Liste ist
     591           0 :         aBtnFirst.Enable();
     592           0 :         aBtnReverse.Enable();
     593           0 :         aBtnPlay.Enable();
     594           0 :         aBtnLast.Enable();
     595           0 :         aNumFldBitmap.Enable();
     596           0 :         aTimeField.Enable();
     597           0 :         aLbLoopCount.Enable();
     598           0 :         aBtnRemoveBitmap.Enable();
     599           0 :         aBtnRemoveAll.Enable();
     600             :     }
     601             :     else
     602             :     {
     603             :         // Wenn kein Objekt in der Liste ist
     604           0 :         aBtnFirst.Enable( sal_False );
     605           0 :         aBtnReverse.Enable( sal_False );
     606           0 :         aBtnPlay.Enable( sal_False );
     607           0 :         aBtnLast.Enable( sal_False );
     608           0 :         aNumFldBitmap.Enable( sal_False );
     609           0 :         aTimeField.Enable( sal_False );
     610           0 :         aLbLoopCount.Enable( sal_False );
     611           0 :         aBtnRemoveBitmap.Enable( sal_False );
     612           0 :         aBtnRemoveAll.Enable( sal_False );
     613             : 
     614             :         //aFtAdjustment.Enable();
     615             :         //aLbAdjustment.Enable();
     616             :     }
     617             : 
     618           0 :     if( bMovie && bDisableCtrls )
     619             :     {
     620           0 :         aBtnGetOneObject.Enable( sal_False );
     621           0 :         aBtnGetAllObjects.Enable( sal_False );
     622           0 :         aRbtGroup.Enable( sal_False );
     623           0 :         aRbtBitmap.Enable( sal_False );
     624           0 :         aBtnCreateGroup.Enable( sal_False );
     625           0 :         aFtAdjustment.Enable( sal_False );
     626           0 :         aLbAdjustment.Enable( sal_False );
     627             :     }
     628             :     else
     629             :     {
     630             :         // 'Gruppenobjekt' nur dann enablen, wenn es kein Animated GIF ist
     631           0 :         if (m_FrameList.empty())
     632             :         {
     633           0 :             aRbtGroup.Enable();
     634             :         }
     635             : 
     636           0 :         aRbtBitmap.Enable();
     637           0 :         aBtnCreateGroup.Enable(!m_FrameList.empty());
     638           0 :         aFtAdjustment.Enable( sal_True );
     639           0 :         aLbAdjustment.Enable( sal_True );
     640             :     }
     641             : 
     642           0 :     ClickRbtHdl( NULL );
     643           0 : }
     644             : 
     645             : // -----------------------------------------------------------------------
     646             : 
     647           0 : void AnimationWindow::ResetAttrs()
     648             : {
     649           0 :     aRbtGroup.Check();
     650           0 :     aLbAdjustment.SelectEntryPos( BA_CENTER );
     651             :     // LoopCount
     652           0 :     aLbLoopCount.SelectEntryPos( aLbLoopCount.GetEntryCount() - 1);
     653             : 
     654           0 :     UpdateControl();
     655           0 : }
     656             : 
     657             : // -----------------------------------------------------------------------
     658             : 
     659           0 : void AnimationWindow::WaitInEffect( sal_uLong nMilliSeconds, sal_uLong nTime,
     660             :                                     SfxProgress* pProgress ) const
     661             : {
     662           0 :     clock_t aEnd = Time::GetSystemTicks() + nMilliSeconds;
     663           0 :     clock_t aCurrent = Time::GetSystemTicks();
     664           0 :     while (aCurrent < aEnd)
     665             :     {
     666           0 :         aCurrent = Time::GetSystemTicks();
     667             : 
     668           0 :         if( pProgress )
     669           0 :             pProgress->SetState( nTime + nMilliSeconds + aCurrent - aEnd );
     670             : 
     671           0 :         Application::Reschedule();
     672             : 
     673           0 :         if( !bMovie )
     674           0 :             return;
     675             :     }
     676             : }
     677             : 
     678             : // -----------------------------------------------------------------------
     679             : 
     680           0 : Fraction AnimationWindow::GetScale()
     681             : {
     682           0 :     Fraction aFrac;
     683           0 :     size_t const nCount = m_FrameList.size();
     684           0 :     if (nCount > 0)
     685             :     {
     686           0 :         aBmpSize.Width() = 0;
     687           0 :         aBmpSize.Height() = 0;
     688           0 :         for (size_t i = 0; i < nCount; i++)
     689             :         {
     690           0 :             BitmapEx *const pBitmap = m_FrameList[i].first;
     691           0 :             Size aTempSize( pBitmap->GetBitmap().GetSizePixel() );
     692           0 :             aBmpSize.Width() = Max( aBmpSize.Width(), aTempSize.Width() );
     693           0 :             aBmpSize.Height() = Max( aBmpSize.Height(), aTempSize.Height() );
     694             :         }
     695             : 
     696           0 :         aBmpSize.Width() += 10;
     697           0 :         aBmpSize.Height() += 10;
     698             : 
     699           0 :         aFrac = Fraction( std::min( (double)aDisplaySize.Width() / (double)aBmpSize.Width(),
     700           0 :                              (double)aDisplaySize.Height() / (double)aBmpSize.Height() ) );
     701             :     }
     702           0 :     return( aFrac );
     703             : }
     704             : 
     705             : // -----------------------------------------------------------------------
     706             : 
     707           0 : void AnimationWindow::Resize()
     708             : {
     709           0 :     if ( !IsFloatingMode() ||
     710           0 :          !GetFloatingWindow()->IsRollUp() )
     711             :     {
     712           0 :         Size aWinSize( GetOutputSizePixel() ); // vorher rSize im Resizing()
     713             : 
     714           0 :         Size aDiffSize;
     715           0 :         aDiffSize.Width() = aWinSize.Width() - aSize.Width();
     716           0 :         aDiffSize.Height() = aWinSize.Height() - aSize.Height();
     717             : 
     718             :         // Umgroessern des Display-Controls
     719           0 :         aDisplaySize.Width() += aDiffSize.Width();
     720           0 :         aDisplaySize.Height() += aDiffSize.Height();
     721           0 :         aCtlDisplay.SetOutputSizePixel( aDisplaySize );
     722             : 
     723           0 :         Point aPt;
     724           0 :         aPt.Y() = aDiffSize.Height();
     725             : 
     726             :         // Verschieben der anderen Controls
     727           0 :         aBtnFirst.Hide();
     728           0 :         aBtnReverse.Hide();
     729           0 :         aBtnStop.Hide();
     730           0 :         aBtnPlay.Hide();
     731           0 :         aBtnLast.Hide();
     732           0 :         aTimeField.Hide();
     733           0 :         aLbLoopCount.Hide();
     734           0 :         aNumFldBitmap.Hide();
     735           0 :         aFtCount.Hide();
     736           0 :         aFiCount.Hide();
     737           0 :         aBtnGetOneObject.Hide();
     738           0 :         aBtnGetAllObjects.Hide();
     739           0 :         aBtnRemoveBitmap.Hide();
     740           0 :         aBtnRemoveAll.Hide();
     741           0 :         aGrpBitmap.Hide();
     742           0 :         aRbtGroup.Hide();
     743           0 :         aRbtBitmap.Hide();
     744           0 :         aFtAdjustment.Hide();
     745           0 :         aLbAdjustment.Hide();
     746           0 :         aBtnCreateGroup.Hide();
     747           0 :         aGrpAnimation.Hide();
     748             : 
     749             : 
     750           0 :         aBtnFirst.SetPosPixel( aBtnFirst.GetPosPixel() + aPt );
     751           0 :         aBtnReverse.SetPosPixel( aBtnReverse.GetPosPixel() + aPt );
     752           0 :         aBtnStop.SetPosPixel( aBtnStop.GetPosPixel() + aPt );
     753           0 :         aBtnPlay.SetPosPixel( aBtnPlay.GetPosPixel() + aPt );
     754           0 :         aBtnLast.SetPosPixel( aBtnLast.GetPosPixel() + aPt );
     755           0 :         aNumFldBitmap.SetPosPixel( aNumFldBitmap.GetPosPixel() + aPt );
     756           0 :         aTimeField.SetPosPixel( aTimeField.GetPosPixel() + aPt );
     757           0 :         aLbLoopCount.SetPosPixel( aLbLoopCount.GetPosPixel() + aPt );
     758           0 :         aFtCount.SetPosPixel( aFtCount.GetPosPixel() + aPt );
     759           0 :         aFiCount.SetPosPixel( aFiCount.GetPosPixel() + aPt );
     760           0 :         aRbtGroup.SetPosPixel( aRbtGroup.GetPosPixel() + aPt );
     761           0 :         aRbtBitmap.SetPosPixel( aRbtBitmap.GetPosPixel() + aPt );
     762           0 :         aFtAdjustment.SetPosPixel( aFtAdjustment.GetPosPixel() + aPt );
     763           0 :         aLbAdjustment.SetPosPixel( aLbAdjustment.GetPosPixel() + aPt );
     764           0 :         aBtnGetOneObject.SetPosPixel( aBtnGetOneObject.GetPosPixel() + aPt );
     765           0 :         aBtnGetAllObjects.SetPosPixel( aBtnGetAllObjects.GetPosPixel() + aPt );
     766           0 :         aBtnRemoveBitmap.SetPosPixel( aBtnRemoveBitmap.GetPosPixel() + aPt );
     767           0 :         aBtnRemoveAll.SetPosPixel( aBtnRemoveAll.GetPosPixel() + aPt );
     768           0 :         aBtnCreateGroup.SetPosPixel( aBtnCreateGroup.GetPosPixel() + aPt );
     769           0 :         aGrpBitmap.SetPosPixel( aGrpBitmap.GetPosPixel() + aPt );
     770           0 :         aGrpAnimation.SetPosPixel( aGrpAnimation.GetPosPixel() + aPt );
     771             : 
     772             :         // Zoom fuer DisplayWin berechnen und setzen
     773           0 :         Fraction aFrac( GetScale() );
     774           0 :         aCtlDisplay.SetScale( aFrac );
     775             : 
     776           0 :         aBtnFirst.Show();
     777           0 :         aBtnReverse.Show();
     778           0 :         aBtnStop.Show();
     779           0 :         aBtnPlay.Show();
     780           0 :         aBtnLast.Show();
     781           0 :         aNumFldBitmap.Show();
     782           0 :         aTimeField.Show();
     783           0 :         aLbLoopCount.Show();
     784           0 :         aFtCount.Show();
     785           0 :         aFiCount.Show();
     786           0 :         aFtAdjustment.Show();
     787           0 :         aLbAdjustment.Show();
     788           0 :         aBtnGetOneObject.Show();
     789           0 :         aBtnGetAllObjects.Show();
     790           0 :         aBtnRemoveBitmap.Show();
     791           0 :         aBtnRemoveAll.Show();
     792           0 :         aGrpBitmap.Show();
     793           0 :         aRbtGroup.Show();
     794           0 :         aRbtBitmap.Show();
     795           0 :         aFtAdjustment.Show();
     796           0 :         aLbAdjustment.Show();
     797           0 :         aBtnCreateGroup.Show();
     798           0 :         aGrpAnimation.Show();
     799             : 
     800           0 :         aSize = aWinSize;
     801             :     }
     802           0 :     SfxDockingWindow::Resize();
     803           0 : }
     804             : 
     805             : // -----------------------------------------------------------------------
     806             : 
     807           0 : sal_Bool AnimationWindow::Close()
     808             : {
     809           0 :     if( maPlayLock.isLocked() )
     810             :     {
     811           0 :         return sal_False;
     812             :     }
     813             :     else
     814             :     {
     815           0 :         SfxBoolItem aItem( SID_ANIMATION_OBJECTS, sal_False );
     816             : 
     817           0 :         GetBindings().GetDispatcher()->Execute(
     818           0 :             SID_ANIMATION_OBJECTS, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
     819             : 
     820           0 :         SfxDockingWindow::Close();
     821             : 
     822           0 :         return sal_True;
     823             :     }
     824             : }
     825             : 
     826             : // -----------------------------------------------------------------------
     827             : 
     828           0 : void AnimationWindow::FillInfo( SfxChildWinInfo& rInfo ) const
     829             : {
     830           0 :     SfxDockingWindow::FillInfo( rInfo ) ;
     831           0 : }
     832             : 
     833             : // -----------------------------------------------------------------------
     834             : 
     835           0 : void AnimationWindow::AddObj (::sd::View& rView )
     836             : {
     837             :     // Texteingabemodus beenden, damit Bitmap mit
     838             :     // Objekt identisch ist.
     839           0 :     if( rView.IsTextEdit() )
     840           0 :         rView.SdrEndTextEdit();
     841             : 
     842             :     // Objekt(e) clonen und den/die Clone(s) in die Liste stellen
     843           0 :     const SdrMarkList& rMarkList   = rView.GetMarkedObjectList();
     844           0 :     sal_uLong              nMarkCount  = rMarkList.GetMarkCount();
     845           0 :     SdPage*            pPage       = pMyDoc->GetSdPage(0, PK_STANDARD);
     846           0 :     sal_uLong              nCloneCount = pPage->GetObjCount();
     847             : 
     848           0 :     if (nMarkCount > 0)
     849             :     {
     850             :         // Wenn es sich um EIN Animationsobjekt oder ein Gruppenobjekt
     851             :         // handelt, das 'einzeln uebernommen' wurde,
     852             :         // werden die einzelnen Objekte eingefuegt
     853           0 :         sal_Bool bAnimObj = sal_False;
     854           0 :         if( nMarkCount == 1 )
     855             :         {
     856           0 :             SdrMark*            pMark = rMarkList.GetMark(0);
     857           0 :             SdrObject*          pObject = pMark->GetMarkedSdrObj();
     858           0 :             SdAnimationInfo*    pAnimInfo = rView.GetDoc().GetAnimationInfo( pObject );
     859           0 :             sal_uInt32              nInv = pObject->GetObjInventor();
     860           0 :             sal_uInt16              nId = pObject->GetObjIdentifier();
     861             : 
     862             :             // Animated Bitmap (GIF)
     863           0 :             if( nInv == SdrInventor && nId == OBJ_GRAF && ( (SdrGrafObj*) pObject )->IsAnimated() )
     864             :             {
     865           0 :                 const SdrGrafObj*   pGrafObj = (SdrGrafObj*) pObject;
     866           0 :                 Graphic             aGraphic( pGrafObj->GetTransformedGraphic() );
     867           0 :                 sal_uInt16              nCount = 0;
     868             : 
     869           0 :                 if( aGraphic.IsAnimated() )
     870           0 :                     nCount = aGraphic.GetAnimation().Count();
     871             : 
     872           0 :                 if( nCount > 0 )
     873             :                 {
     874           0 :                     const Animation aAnimation( aGraphic.GetAnimation() );
     875             : 
     876           0 :                     for( sal_uInt16 i = 0; i < nCount; i++ )
     877             :                     {
     878           0 :                         const AnimationBitmap& rAnimBmp = aAnimation.Get( i );
     879             : 
     880             :                         BitmapEx *const pBitmapEx =
     881           0 :                             new BitmapEx(rAnimBmp.aBmpEx);
     882             : 
     883             :                         // LoopCount
     884           0 :                         if( i == 0 )
     885             :                         {
     886           0 :                             long nLoopCount = aAnimation.GetLoopCount();
     887             : 
     888           0 :                             if( !nLoopCount ) // unendlich
     889           0 :                                 aLbLoopCount.SelectEntryPos( aLbLoopCount.GetEntryCount() - 1);
     890             :                             else
     891           0 :                                 aLbLoopCount.SelectEntry(rtl::OUString::valueOf( nLoopCount ) );
     892             :                         }
     893             : 
     894           0 :                         long nTime = rAnimBmp.nWait;
     895           0 :                         Time* pTime = new Time( 0, 0, nTime / 100, nTime % 100 );
     896             :                         m_FrameList.insert(
     897           0 :                                 m_FrameList.begin() + m_nCurrentFrame + 1,
     898           0 :                                 ::std::make_pair(pBitmapEx, pTime));
     899             : 
     900             :                         // increment => next one inserted after this one
     901           0 :                         ++m_nCurrentFrame;
     902             :                     }
     903             :                     // Nachdem ein animated GIF uebernommen wurde, kann auch nur ein solches erstellt werden
     904           0 :                     aRbtBitmap.Check();
     905           0 :                     aRbtGroup.Enable( sal_False );
     906           0 :                     bAnimObj = sal_True;
     907           0 :                 }
     908             :             }
     909           0 :             else if( bAllObjects || ( pAnimInfo && pAnimInfo->mbIsMovie ) )
     910             :             {
     911             :                 // Mehrere Objekte
     912           0 :                 SdrObjList* pObjList = ((SdrObjGroup*)pObject)->GetSubList();
     913             : 
     914           0 :                 for( sal_uInt16 nObject = 0; nObject < pObjList->GetObjCount(); nObject++ )
     915             :                 {
     916           0 :                     SdrObject* pSnapShot = (SdrObject*) pObjList->GetObj( (sal_uLong) nObject );
     917             : 
     918             :                     BitmapEx *const pBitmapEx = new BitmapEx(
     919             :                         SdrExchangeView::GetObjGraphic(
     920           0 :                             pSnapShot->GetModel(), pSnapShot).GetBitmapEx() );
     921             : 
     922           0 :                     Time* pTime = new Time( aTimeField.GetTime() );
     923             : 
     924             :                     m_FrameList.insert(
     925           0 :                             m_FrameList.begin() + m_nCurrentFrame + 1,
     926           0 :                             ::std::make_pair(pBitmapEx, pTime));
     927             : 
     928             :                     // increment => next one inserted after this one
     929           0 :                     ++m_nCurrentFrame;
     930             : 
     931             :                     // Clone
     932           0 :                     pPage->InsertObject(pSnapShot->Clone(), m_nCurrentFrame);
     933             :                 }
     934           0 :                 bAnimObj = sal_True;
     935             :             }
     936             :         }
     937             :         // Auch ein einzelnes animiertes Objekt
     938           0 :         if( !bAnimObj && !( bAllObjects && nMarkCount > 1 ) )
     939             :         {
     940             :             BitmapEx *const pBitmapEx =
     941           0 :                 new BitmapEx(rView.GetAllMarkedGraphic().GetBitmapEx());
     942             : 
     943           0 :             Time* pTime = new Time( aTimeField.GetTime() );
     944             : 
     945             :             m_FrameList.insert(
     946           0 :                     m_FrameList.begin() + m_nCurrentFrame + 1,
     947           0 :                     ::std::make_pair(pBitmapEx, pTime));
     948             :         }
     949             : 
     950             :         // ein einzelnes Objekt
     951           0 :         if( nMarkCount == 1 && !bAnimObj )
     952             :         {
     953           0 :             SdrMark*    pMark   = rMarkList.GetMark(0);
     954           0 :             SdrObject*  pObject = pMark->GetMarkedSdrObj();
     955           0 :             SdrObject*  pClone  = pObject->Clone();
     956           0 :             pPage->InsertObject(pClone, m_nCurrentFrame + 1);
     957             :         }
     958             :         // mehrere Objekte: die Clones zu einer Gruppe zusammenfassen
     959           0 :         else if (nMarkCount > 1)
     960             :         {
     961             :             // Objekte einzeln uebernehmen
     962           0 :             if( bAllObjects )
     963             :             {
     964           0 :                 for( sal_uLong nObject= 0; nObject < nMarkCount; nObject++ )
     965             :                 {
     966             :                     // Clone
     967           0 :                     SdrObject* pObject = rMarkList.GetMark( nObject )->GetMarkedSdrObj();
     968             : 
     969             :                     BitmapEx *const pBitmapEx = new BitmapEx(
     970             :                         SdrExchangeView::GetObjGraphic(
     971           0 :                             pObject->GetModel(), pObject).GetBitmapEx() );
     972             : 
     973           0 :                     Time* pTime = new Time( aTimeField.GetTime() );
     974             : 
     975             :                     m_FrameList.insert(
     976           0 :                         m_FrameList.begin() + m_nCurrentFrame + 1,
     977           0 :                         ::std::make_pair(pBitmapEx, pTime));
     978             : 
     979             :                     // increment => next one inserted after this one
     980           0 :                     ++m_nCurrentFrame;
     981             : 
     982           0 :                     pPage->InsertObject(pObject->Clone(), m_nCurrentFrame);
     983             :                 }
     984           0 :                 bAnimObj = sal_True; // damit nicht nochmal weitergeschaltet wird
     985             :             }
     986             :             else
     987             :             {
     988           0 :                 SdrObjGroup* pCloneGroup = new SdrObjGroup;
     989           0 :                 SdrObjList*  pObjList    = pCloneGroup->GetSubList();
     990             : 
     991           0 :                 for (sal_uLong nObject= 0; nObject < nMarkCount; nObject++)
     992           0 :                     pObjList->InsertObject(rMarkList.GetMark(nObject)->GetMarkedSdrObj()->Clone(), LIST_APPEND);
     993             : 
     994           0 :                 pPage->InsertObject(pCloneGroup, m_nCurrentFrame + 1);
     995             :             }
     996             :         }
     997             : 
     998           0 :         if( !bAnimObj )
     999             :         {
    1000           0 :             ++m_nCurrentFrame;
    1001             :         }
    1002             : 
    1003             :         // wenn vorher nichts im Animator war und jetzt was da ist, kann eine
    1004             :         // Animationsgruppe erstellt werden
    1005           0 :         if (nCloneCount == 0 && !m_FrameList.empty())
    1006             :         {
    1007           0 :             aBtnCreateGroup.Enable();
    1008             :         }
    1009             : 
    1010             :         // Zoom fuer DisplayWin berechnen und setzen
    1011           0 :         Fraction aFrac( GetScale() );
    1012           0 :         aCtlDisplay.SetScale( aFrac );
    1013             : 
    1014           0 :         UpdateControl();
    1015             :     }
    1016           0 : }
    1017             : 
    1018             : // -----------------------------------------------------------------------
    1019             : 
    1020           0 : void AnimationWindow::CreateAnimObj (::sd::View& rView )
    1021             : {
    1022           0 :     ::Window* pOutWin = static_cast< ::Window*>(rView.GetFirstOutputDevice()); // GetWin( 0 );
    1023             :     DBG_ASSERT( pOutWin, "Window ist nicht vorhanden!" );
    1024             : 
    1025             :     // die Fentermitte ermitteln
    1026           0 :     const MapMode       aMap100( MAP_100TH_MM );
    1027           0 :     Size                aMaxSizeLog;
    1028           0 :     Size                aMaxSizePix;
    1029           0 :     Size                aTemp( pOutWin->GetOutputSizePixel() );
    1030           0 :     const Point         aWindowCenter( pOutWin->PixelToLogic( Point( aTemp.Width() >> 1, aTemp.Height() >> 1 ) ) );
    1031           0 :     const OutputDevice* pDefDev = Application::GetDefaultDevice();
    1032           0 :     const size_t nCount = m_FrameList.size();
    1033           0 :     BitmapAdjustment    eBA = (BitmapAdjustment) aLbAdjustment.GetSelectEntryPos();
    1034             : 
    1035             :     // Groesste Bitmap ermitteln
    1036           0 :     for (size_t i = 0; i < nCount; ++i)
    1037             :     {
    1038           0 :         const BitmapEx& rBmpEx = *m_FrameList[i].first;
    1039           0 :         const Graphic   aGraphic( rBmpEx );
    1040           0 :         Size            aTmpSizeLog;
    1041           0 :         const Size      aTmpSizePix( rBmpEx.GetSizePixel() );
    1042             : 
    1043           0 :         if ( aGraphic.GetPrefMapMode().GetMapUnit() == MAP_PIXEL )
    1044           0 :             aTmpSizeLog = pDefDev->PixelToLogic( aGraphic.GetPrefSize(), aMap100 );
    1045             :         else
    1046           0 :             aTmpSizeLog = pDefDev->LogicToLogic( aGraphic.GetPrefSize(), aGraphic.GetPrefMapMode(), aMap100 );
    1047             : 
    1048           0 :         aMaxSizeLog.Width() = Max( aMaxSizeLog.Width(), aTmpSizeLog.Width() );
    1049           0 :         aMaxSizeLog.Height() = Max( aMaxSizeLog.Height(), aTmpSizeLog.Height() );
    1050             : 
    1051           0 :         aMaxSizePix.Width() = Max( aMaxSizePix.Width(), aTmpSizePix.Width() );
    1052           0 :         aMaxSizePix.Height() = Max( aMaxSizePix.Height(), aTmpSizePix.Height() );
    1053           0 :     }
    1054             : 
    1055           0 :     SdrPageView* pPV = rView.GetSdrPageView();
    1056             : 
    1057           0 :     if( aRbtBitmap.IsChecked() )
    1058             :     {
    1059             :         // Bitmapgruppe erzeugen (Animated GIF)
    1060           0 :         Animation   aAnimation;
    1061           0 :         Point       aPt;
    1062             : 
    1063           0 :         for (size_t i = 0; i < nCount; ++i)
    1064             :         {
    1065           0 :             Time *const pTime = m_FrameList[i].second;
    1066           0 :             long  nTime = pTime->Get100Sec();
    1067           0 :             nTime += pTime->GetSec() * 100;
    1068             : 
    1069           0 :             BitmapEx const*const pBitmapEx = m_FrameList[i].first;
    1070             : 
    1071             :             // Offset fuer die gewuenschte Ausrichtung bestimmen
    1072           0 :             const Size aBitmapSize( pBitmapEx->GetSizePixel() );
    1073             : 
    1074           0 :             switch( eBA )
    1075             :             {
    1076             :                 case BA_LEFT_UP:
    1077           0 :                 break;
    1078             : 
    1079             :                 case BA_LEFT:
    1080           0 :                     aPt.Y() = (aMaxSizePix.Height() - aBitmapSize.Height()) >> 1;
    1081           0 :                 break;
    1082             : 
    1083             :                 case BA_LEFT_DOWN:
    1084           0 :                     aPt.Y() = aMaxSizePix.Height() - aBitmapSize.Height();
    1085           0 :                 break;
    1086             : 
    1087             :                 case BA_UP:
    1088           0 :                     aPt.X() = (aMaxSizePix.Width() - aBitmapSize.Width()) >> 1;
    1089           0 :                 break;
    1090             : 
    1091             :                 case BA_CENTER:
    1092           0 :                     aPt.X()  = (aMaxSizePix.Width() - aBitmapSize.Width()) >> 1;
    1093           0 :                     aPt.Y() = (aMaxSizePix.Height() - aBitmapSize.Height()) >> 1;
    1094           0 :                 break;
    1095             : 
    1096             :                 case BA_DOWN:
    1097           0 :                     aPt.X()  = (aMaxSizePix.Width() - aBitmapSize.Width()) >> 1;
    1098           0 :                     aPt.Y() = aMaxSizePix.Height() - aBitmapSize.Height();
    1099           0 :                 break;
    1100             : 
    1101             :                 case BA_RIGHT_UP:
    1102           0 :                     aPt.X() = aMaxSizePix.Width() - aBitmapSize.Width();
    1103           0 :                 break;
    1104             : 
    1105             :                 case BA_RIGHT:
    1106           0 :                     aPt.X()  = aMaxSizePix.Width() - aBitmapSize.Width();
    1107           0 :                     aPt.Y() = (aMaxSizePix.Height() - aBitmapSize.Height()) >> 1;
    1108           0 :                 break;
    1109             : 
    1110             :                 case BA_RIGHT_DOWN:
    1111           0 :                     aPt.X()  = aMaxSizePix.Width() - aBitmapSize.Width();
    1112           0 :                     aPt.Y() = aMaxSizePix.Height() - aBitmapSize.Height();
    1113           0 :                 break;
    1114             : 
    1115             :             }
    1116             : 
    1117             :             // LoopCount (Anzahl der Durchlaeufe) ermitteln
    1118           0 :             AnimationBitmap aAnimBmp;
    1119           0 :             long            nLoopCount = 0L;
    1120           0 :             sal_uInt16          nPos = aLbLoopCount.GetSelectEntryPos();
    1121             : 
    1122           0 :             if( nPos != LISTBOX_ENTRY_NOTFOUND && nPos != aLbLoopCount.GetEntryCount() - 1 ) // unendlich
    1123           0 :                 nLoopCount = (long) aLbLoopCount.GetSelectEntry().ToInt32();
    1124             : 
    1125           0 :             aAnimBmp.aBmpEx = *pBitmapEx;
    1126           0 :             aAnimBmp.aPosPix = aPt;
    1127           0 :             aAnimBmp.aSizePix = aBitmapSize;
    1128           0 :             aAnimBmp.nWait = nTime;
    1129           0 :             aAnimBmp.eDisposal = DISPOSE_BACK;
    1130           0 :             aAnimBmp.bUserInput = sal_False;
    1131             : 
    1132           0 :             aAnimation.Insert( aAnimBmp );
    1133           0 :             aAnimation.SetDisplaySizePixel( aMaxSizePix );
    1134           0 :             aAnimation.SetLoopCount( nLoopCount );
    1135           0 :         }
    1136             : 
    1137           0 :         SdrGrafObj* pGrafObj = new SdrGrafObj( Graphic( aAnimation ) );
    1138           0 :         const Point aOrg( aWindowCenter.X() - ( aMaxSizeLog.Width() >> 1 ), aWindowCenter.Y() - ( aMaxSizeLog.Height() >> 1 ) );
    1139             : 
    1140           0 :         pGrafObj->SetLogicRect( Rectangle( aOrg, aMaxSizeLog ) );
    1141           0 :         rView.InsertObjectAtView( pGrafObj, *pPV, SDRINSERT_SETDEFLAYER);
    1142             :     }
    1143             :     else
    1144             :     {
    1145             :         // Offset fuer die gewuenschte Ausrichtung bestimmen
    1146           0 :         Size aOffset;
    1147           0 :         SdrObject * pClone = NULL;
    1148           0 :         SdPage* pPage = pMyDoc->GetSdPage(0, PK_STANDARD);
    1149             : 
    1150           0 :         for (size_t i = 0; i < nCount; ++i)
    1151             :         {
    1152           0 :             pClone = pPage->GetObj(i);
    1153           0 :             Rectangle aRect( pClone->GetSnapRect() );
    1154             : 
    1155           0 :             switch( eBA )
    1156             :             {
    1157             :                 case BA_LEFT_UP:
    1158           0 :                 break;
    1159             : 
    1160             :                 case BA_LEFT:
    1161           0 :                     aOffset.Height() = (aMaxSizeLog.Height() - aRect.GetHeight()) / 2;
    1162           0 :                 break;
    1163             : 
    1164             :                 case BA_LEFT_DOWN:
    1165           0 :                     aOffset.Height() = aMaxSizeLog.Height() - aRect.GetHeight();
    1166           0 :                 break;
    1167             : 
    1168             :                 case BA_UP:
    1169           0 :                     aOffset.Width() = (aMaxSizeLog.Width() - aRect.GetWidth()) / 2;
    1170           0 :                 break;
    1171             : 
    1172             :                 case BA_CENTER:
    1173           0 :                     aOffset.Width()  = (aMaxSizeLog.Width() - aRect.GetWidth()) / 2;
    1174           0 :                     aOffset.Height() = (aMaxSizeLog.Height() - aRect.GetHeight()) / 2;
    1175           0 :                 break;
    1176             : 
    1177             :                 case BA_DOWN:
    1178           0 :                     aOffset.Width()  = (aMaxSizeLog.Width() - aRect.GetWidth()) / 2;
    1179           0 :                     aOffset.Height() = aMaxSizeLog.Height() - aRect.GetHeight();
    1180           0 :                 break;
    1181             : 
    1182             :                 case BA_RIGHT_UP:
    1183           0 :                     aOffset.Width() = aMaxSizeLog.Width() - aRect.GetWidth();
    1184           0 :                 break;
    1185             : 
    1186             :                 case BA_RIGHT:
    1187           0 :                     aOffset.Width()  = aMaxSizeLog.Width() - aRect.GetWidth();
    1188           0 :                     aOffset.Height() = (aMaxSizeLog.Height() - aRect.GetHeight()) / 2;
    1189           0 :                 break;
    1190             : 
    1191             :                 case BA_RIGHT_DOWN:
    1192           0 :                     aOffset.Width()  = aMaxSizeLog.Width() - aRect.GetWidth();
    1193           0 :                     aOffset.Height() = aMaxSizeLog.Height() - aRect.GetHeight();
    1194           0 :                 break;
    1195             : 
    1196             :             }
    1197             :             // SetSnapRect ist fuer Ellipsen leider nicht implementiert !!!
    1198           0 :             Point aMovePt( aWindowCenter + Point( aOffset.Width(), aOffset.Height() ) - aRect.TopLeft() );
    1199           0 :             Size aMoveSize( aMovePt.X(), aMovePt.Y() );
    1200           0 :             pClone->NbcMove( aMoveSize );
    1201             :         }
    1202             : 
    1203             :         // Animationsgruppe erzeugen
    1204           0 :         SdrObjGroup* pGroup   = new SdrObjGroup;
    1205           0 :         SdrObjList*  pObjList = pGroup->GetSubList();
    1206             : 
    1207           0 :         for (size_t i = 0; i < nCount; i++)
    1208             :         {
    1209             :             // der Clone verbleibt im Animator; in die Gruppe kommt ein Clone
    1210             :             // des Clones
    1211           0 :             pClone = pPage->GetObj(i);
    1212           0 :             SdrObject* pCloneOfClone = pClone->Clone();
    1213             :             //SdrObject* pCloneOfClone = pPage->GetObj(i)->Clone();
    1214           0 :             pObjList->InsertObject(pCloneOfClone, LIST_APPEND);
    1215             :         }
    1216             : 
    1217             :         // bis jetzt liegt die linke obere Ecke der Gruppe in der Fenstermitte;
    1218             :         // jetzt noch um die Haelfte der Groesse nach oben und links korrigieren
    1219           0 :         aTemp = aMaxSizeLog;
    1220           0 :         aTemp.Height() = - aTemp.Height() / 2;
    1221           0 :         aTemp.Width()  = - aTemp.Width() / 2;
    1222           0 :         pGroup->NbcMove(aTemp);
    1223             : 
    1224             :         // Animationsinformation erzeugen
    1225           0 :         SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pGroup,true);
    1226           0 :         pInfo->meEffect = presentation::AnimationEffect_NONE;
    1227           0 :         pInfo->meSpeed = presentation::AnimationSpeed_MEDIUM;
    1228           0 :         pInfo->mbActive = sal_True;
    1229           0 :         pInfo->mbIsMovie = sal_True;
    1230           0 :         pInfo->maBlueScreen = COL_WHITE;
    1231             : 
    1232           0 :         rView.InsertObjectAtView( pGroup, *pPV, SDRINSERT_SETDEFLAYER);
    1233             :     }
    1234             : 
    1235           0 :     ClickFirstHdl( this );
    1236           0 : }
    1237             : 
    1238           0 : void AnimationWindow::DataChanged( const DataChangedEvent& rDCEvt )
    1239             : {
    1240           0 :     SfxDockingWindow::DataChanged( rDCEvt );
    1241             : 
    1242           0 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
    1243             :     {
    1244           0 :         UpdateControl();
    1245             :     }
    1246           0 : }
    1247             : 
    1248             : /*************************************************************************
    1249             : |*
    1250             : |* ControllerItem fuer Animator
    1251             : |*
    1252             : \************************************************************************/
    1253             : 
    1254           0 : AnimationControllerItem::AnimationControllerItem(
    1255             :     sal_uInt16 _nId,
    1256             :     AnimationWindow* pAnimWin,
    1257             :     SfxBindings*    _pBindings)
    1258             :     : SfxControllerItem( _nId, *_pBindings ),
    1259           0 :       pAnimationWin( pAnimWin )
    1260             : {
    1261           0 : }
    1262             : 
    1263             : // -----------------------------------------------------------------------
    1264             : 
    1265           0 : void AnimationControllerItem::StateChanged( sal_uInt16 nSId,
    1266             :                         SfxItemState eState, const SfxPoolItem* pItem )
    1267             : {
    1268           0 :     if( eState >= SFX_ITEM_AVAILABLE && nSId == SID_ANIMATOR_STATE )
    1269             :     {
    1270           0 :         const SfxUInt16Item* pStateItem = PTR_CAST( SfxUInt16Item, pItem );
    1271             :         DBG_ASSERT( pStateItem, "SfxUInt16Item erwartet");
    1272           0 :         sal_uInt16 nState = pStateItem->GetValue();
    1273             : 
    1274           0 :         pAnimationWin->aBtnGetOneObject.Enable( nState & 1 );
    1275           0 :         pAnimationWin->aBtnGetAllObjects.Enable( nState & 2 );
    1276             :     }
    1277           0 : }
    1278             : 
    1279             : 
    1280          18 : } // end of namespace sd
    1281             : 
    1282             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10