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