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