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