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