merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / dlg / animobjs.cxx
blob8a51c44e10b4a5a4b17321e6c013e125bf275dc0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: animobjs.cxx,v $
10 * $Revision: 1.30 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
33 #include <com/sun/star/presentation/AnimationEffect.hpp>
34 #include <com/sun/star/presentation/AnimationSpeed.hpp>
36 #define _ANIMATION //animation freischalten
38 #define _SV_BITMAPEX
39 #include <svx/xoutbmp.hxx>
41 #include <time.h>
42 #include <svtools/eitem.hxx>
43 #include <svx/svdograf.hxx>
44 #include <svx/svdogrp.hxx>
45 #include <sfx2/dispatch.hxx>
46 #include <sfx2/progress.hxx>
47 #include <vcl/msgbox.hxx>
48 #include "anminfo.hxx"
49 #include "animobjs.hxx"
50 #include "animobjs.hrc"
51 #include "anmdef.hxx"
52 #include "app.hrc"
53 #include "strings.hrc"
54 #include "sdresid.hxx"
55 #include "View.hxx"
56 #include "drawdoc.hxx"
57 #include "sdpage.hxx"
58 #include "res_bmp.hrc"
59 #include "ViewShell.hxx"
61 #ifndef _SV_SVAPP_HXX_
62 #include <vcl/svapp.hxx>
63 #endif
65 #include <string>
66 #include <algorithm>
68 using namespace ::com::sun::star;
70 namespace sd {
72 /*************************************************************************
73 |* SdDisplay - Control
74 \************************************************************************/
76 SdDisplay::SdDisplay( Window* pWin, SdResId Id ) :
77 Control( pWin, Id ),
78 aScale( 1, 1 )
80 SetMapMode( MAP_PIXEL );
81 const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
82 SetBackground( Wallpaper( Color( rStyles.GetFieldColor() ) ) );
85 // -----------------------------------------------------------------------
87 SdDisplay::~SdDisplay()
91 // -----------------------------------------------------------------------
93 void SdDisplay::SetBitmapEx( BitmapEx* pBmpEx )
95 if( pBmpEx )
97 aBitmapEx = *pBmpEx;
99 else
101 const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
102 const Color aFillColor = rStyles.GetFieldColor();
103 aBitmapEx.Erase(aFillColor);
107 // -----------------------------------------------------------------------
109 void SdDisplay::Paint( const Rectangle& )
111 Point aPt;
112 Size aSize = GetOutputSize();
113 Size aBmpSize = aBitmapEx.GetBitmap().GetSizePixel();
114 aBmpSize.Width() = (long) ( (double) aBmpSize.Width() * (double) aScale );
115 aBmpSize.Height() = (long) ( (double) aBmpSize.Height() * (double) aScale );
117 if( aBmpSize.Width() < aSize.Width() )
118 aPt.X() = ( aSize.Width() - aBmpSize.Width() ) / 2;
119 if( aBmpSize.Height() < aSize.Height() )
120 aPt.Y() = ( aSize.Height() - aBmpSize.Height() ) / 2;
122 aBitmapEx.Draw( this, aPt, aBmpSize );
123 //DrawBitmap( aPt, aBmpSize, *pBitmap );
126 // -----------------------------------------------------------------------
128 void SdDisplay::SetScale( const Fraction& rFrac )
130 aScale = rFrac;
133 void SdDisplay::DataChanged( const DataChangedEvent& rDCEvt )
135 Control::DataChanged( rDCEvt );
137 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
139 const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
140 SetBackground( Wallpaper( Color( rStyles.GetFieldColor() ) ) );
141 SetDrawMode( GetDisplayBackground().GetColor().IsDark()
142 ? ViewShell::OUTPUT_DRAWMODE_CONTRAST
143 : ViewShell::OUTPUT_DRAWMODE_COLOR );
147 /*************************************************************************
148 |* AnimationWindow - FloatingWindow
149 \************************************************************************/
151 AnimationWindow::AnimationWindow( SfxBindings* pInBindings,
152 SfxChildWindow *pCW, Window* pParent, const SdResId& rSdResId ) :
153 SfxDockingWindow ( pInBindings, pCW, pParent, rSdResId ),
154 aCtlDisplay ( this, SdResId( CTL_DISPLAY ) ),
155 aBtnFirst ( this, SdResId( BTN_FIRST ) ),
156 aBtnReverse ( this, SdResId( BTN_REVERSE ) ),
157 aBtnStop ( this, SdResId( BTN_STOP ) ),
158 aBtnPlay ( this, SdResId( BTN_PLAY ) ),
159 aBtnLast ( this, SdResId( BTN_LAST ) ),
160 aNumFldBitmap ( this, SdResId( NUM_FLD_BITMAP ) ),
161 aTimeField ( this, SdResId( TIME_FIELD ) ),
162 aLbLoopCount ( this, SdResId( LB_LOOP_COUNT ) ),
164 aBtnGetOneObject ( this, SdResId( BTN_GET_ONE_OBJECT ) ),
165 aBtnGetAllObjects ( this, SdResId( BTN_GET_ALL_OBJECTS ) ),
166 aBtnRemoveBitmap ( this, SdResId( BTN_REMOVE_BITMAP ) ),
167 aBtnRemoveAll ( this, SdResId( BTN_REMOVE_ALL ) ),
168 aFtCount ( this, SdResId( FT_COUNT ) ),
169 aFiCount ( this, SdResId( FI_COUNT ) ),
170 aGrpBitmap ( this, SdResId( GRP_BITMAP ) ),
172 aRbtGroup ( this, SdResId( RBT_GROUP ) ),
173 aRbtBitmap ( this, SdResId( RBT_BITMAP ) ),
174 aFtAdjustment ( this, SdResId( FT_ADJUSTMENT ) ),
175 aLbAdjustment ( this, SdResId( LB_ADJUSTMENT ) ),
176 aBtnCreateGroup ( this, SdResId( BTN_CREATE_GROUP ) ),
177 aGrpAnimation ( this, SdResId( GRP_ANIMATION_GROUP ) ),
179 pWin ( pParent ),
180 pBitmapEx ( NULL ),
182 bMovie ( FALSE ),
183 bAllObjects ( FALSE ),
185 pBindings ( pInBindings )
187 FreeResource();
189 aBtnGetOneObject.SetModeImage( Image( SdResId( IMG_GET1OBJECT_H ) ), BMP_COLOR_HIGHCONTRAST );
190 aBtnGetAllObjects.SetModeImage( Image( SdResId( IMG_GETALLOBJECT_H ) ), BMP_COLOR_HIGHCONTRAST );
191 aBtnRemoveBitmap.SetModeImage( Image( SdResId( IMG_REMOVEBMP_H ) ), BMP_COLOR_HIGHCONTRAST );
192 aBtnRemoveAll.SetModeImage( Image( SdResId( IMG_REMOVEALLBMP_H ) ), BMP_COLOR_HIGHCONTRAST );
194 // neues Dokument mit Seite erzeugen
195 pMyDoc = new SdDrawDocument(DOCUMENT_TYPE_IMPRESS, NULL);
196 SdPage* pPage = (SdPage*) pMyDoc->AllocPage(FALSE);
197 pMyDoc->InsertPage(pPage);
199 pControllerItem = new AnimationControllerItem( SID_ANIMATOR_STATE, this, pBindings );
201 // Solange noch nicht in der Resource
202 aTimeField.SetFormat( TIMEF_SEC_CS );
204 aBtnFirst.SetClickHdl( LINK( this, AnimationWindow, ClickFirstHdl ) );
205 aBtnReverse.SetClickHdl( LINK( this, AnimationWindow, ClickPlayHdl ) );
206 aBtnStop.SetClickHdl( LINK( this, AnimationWindow, ClickStopHdl ) );
207 aBtnPlay.SetClickHdl( LINK( this, AnimationWindow, ClickPlayHdl ) );
208 aBtnLast.SetClickHdl( LINK( this, AnimationWindow, ClickLastHdl ) );
210 aBtnGetOneObject.SetClickHdl( LINK( this, AnimationWindow, ClickGetObjectHdl ) );
211 aBtnGetAllObjects.SetClickHdl( LINK( this, AnimationWindow, ClickGetObjectHdl ) );
212 aBtnRemoveBitmap.SetClickHdl( LINK( this, AnimationWindow, ClickRemoveBitmapHdl ) );
213 aBtnRemoveAll.SetClickHdl( LINK( this, AnimationWindow, ClickRemoveBitmapHdl ) );
215 aRbtGroup.SetClickHdl( LINK( this, AnimationWindow, ClickRbtHdl ) );
216 aRbtBitmap.SetClickHdl( LINK( this, AnimationWindow, ClickRbtHdl ) );
217 aBtnCreateGroup.SetClickHdl( LINK( this, AnimationWindow, ClickCreateGroupHdl ) );
218 aNumFldBitmap.SetModifyHdl( LINK( this, AnimationWindow, ModifyBitmapHdl ) );
219 aTimeField.SetModifyHdl( LINK( this, AnimationWindow, ModifyTimeHdl ) );
221 // disable 3D border
222 aCtlDisplay.SetBorderStyle(WINDOW_BORDER_MONO);
223 aDisplaySize = aCtlDisplay.GetOutputSize();
225 aSize = GetOutputSizePixel();
226 SetMinOutputSizePixel( aSize );
228 ResetAttrs();
230 // der Animator ist leer; es kann keine Animationsgruppe erstellt werden
231 aBtnCreateGroup.Disable();
234 // -----------------------------------------------------------------------
236 AnimationWindow::~AnimationWindow()
238 ULONG i, nCount;
240 delete pControllerItem;
242 // Bitmapliste bereinigen
243 for( i = 0, nCount = aBmpExList.Count(); i < nCount; i++ )
244 delete static_cast< BitmapEx* >( aBmpExList.GetObject( i ) );
245 aBmpExList.Clear();
247 // Timeliste bereinigen
248 for( i = 0, nCount = aTimeList.Count(); i < nCount; i++ )
249 delete static_cast< Time* >( aTimeList.GetObject( i ) );
250 aTimeList.Clear();
252 // die Clones loeschen
253 delete pMyDoc;
256 // -----------------------------------------------------------------------
258 IMPL_LINK( AnimationWindow, ClickFirstHdl, void *, EMPTYARG )
260 aBmpExList.First();
261 pBitmapEx = static_cast< BitmapEx* >( aBmpExList.GetCurObject() );
262 UpdateControl( aBmpExList.GetCurPos() );
264 return( 0L );
267 // -----------------------------------------------------------------------
269 IMPL_LINK( AnimationWindow, ClickStopHdl, void *, EMPTYARG )
271 bMovie = FALSE;
272 return( 0L );
275 // -----------------------------------------------------------------------
277 IMPL_LINK( AnimationWindow, ClickPlayHdl, void *, p )
279 ScopeLockGuard aGuard( maPlayLock );
281 bMovie = TRUE;
282 BOOL bDisableCtrls = FALSE;
283 ULONG nCount = aBmpExList.Count();
284 BOOL bReverse = p == &aBtnReverse;
286 // Kann spaeter schwer ermittelt werden
287 BOOL bRbtGroupEnabled = aRbtGroup.IsEnabled();
288 BOOL bBtnGetAllObjectsEnabled = aBtnGetAllObjects.IsEnabled();
289 BOOL bBtnGetOneObjectEnabled = aBtnGetOneObject.IsEnabled();
291 // Gesamtzeit ermitteln
292 Time aTime( 0 );
293 long nFullTime;
294 if( aRbtBitmap.IsChecked() )
296 for( ULONG i = 0; i < nCount; i++ )
297 aTime += *static_cast< Time* >( aTimeList.GetObject( i ) );
298 nFullTime = aTime.GetMSFromTime();
300 else
302 nFullTime = nCount * 100;
303 aTime.MakeTimeFromMS( nFullTime );
306 // StatusBarManager ab 1 Sekunde
307 SfxProgress* pProgress = NULL;
308 if( nFullTime >= 1000 )
310 bDisableCtrls = 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 );
317 ULONG nTmpTime = 0;
318 long i = 0;
319 BOOL bCount = i < (long) nCount;
320 if( bReverse )
322 i = nCount - 1;
323 bCount = i >= 0;
325 while( bCount && bMovie )
327 // Um Konsistenz zwischen Liste und Anzeige zu erwirken
328 aBmpExList.Seek( i );
329 pBitmapEx = static_cast< BitmapEx* >( aBmpExList.GetCurObject() );
331 UpdateControl( i, bDisableCtrls );
333 if( aRbtBitmap.IsChecked() )
335 Time* pTime = static_cast< Time* >( aTimeList.GetObject( i ) );
336 DBG_ASSERT( pTime, "Keine Zeit gefunden!" );
338 aTimeField.SetTime( *pTime );
339 ULONG nTime = pTime->GetMSFromTime();
341 WaitInEffect( nTime, nTmpTime, pProgress );
342 nTmpTime += nTime;
344 else
346 WaitInEffect( 100, nTmpTime, pProgress );
347 nTmpTime += 100;
349 if( bReverse )
351 i--;
352 if (i < 0)
354 // Terminate loop.
355 bCount = false;
356 // Move i back into valid range.
357 i = 0;
360 else
362 i++;
363 if (i >= (long) nCount)
365 // Terminate loop.
366 bCount = false;
367 // Move i back into valid range.
368 i = nCount - 1;
373 // Um die Controls wieder zu enablen
374 bMovie = FALSE;
375 if (nCount > 0)
376 UpdateControl(i);
378 if( pProgress )
380 delete pProgress;
381 aBtnStop.Disable();
384 aRbtGroup.Enable( bRbtGroupEnabled );
385 aBtnGetAllObjects.Enable( bBtnGetAllObjectsEnabled );
386 aBtnGetOneObject.Enable( bBtnGetOneObjectEnabled );
388 return( 0L );
391 // -----------------------------------------------------------------------
393 IMPL_LINK( AnimationWindow, ClickLastHdl, void *, EMPTYARG )
395 aBmpExList.Last();
396 pBitmapEx = static_cast< BitmapEx* >( aBmpExList.GetCurObject() );
397 UpdateControl( aBmpExList.GetCurPos() );
399 return( 0L );
402 // -----------------------------------------------------------------------
404 IMPL_LINK( AnimationWindow, ClickRbtHdl, void *, p )
406 if( !pBitmapEx || p == &aRbtGroup || aRbtGroup.IsChecked() )
408 aTimeField.SetText( String() );
409 aTimeField.Enable( FALSE );
410 aLbLoopCount.Enable( FALSE );
412 else if( p == &aRbtBitmap || aRbtBitmap.IsChecked() )
414 ULONG n = static_cast<ULONG>(aNumFldBitmap.GetValue());
415 if( n > 0 )
417 Time* pTime = static_cast< Time* >( aTimeList.GetObject( n - 1 ) );
418 if( pTime )
419 aTimeField.SetTime( *pTime );
421 aTimeField.Enable();
422 aLbLoopCount.Enable();
425 return( 0L );
428 // -----------------------------------------------------------------------
430 IMPL_LINK( AnimationWindow, ClickGetObjectHdl, void *, pBtn )
432 bAllObjects = pBtn == &aBtnGetAllObjects;
434 // Code jetzt in AddObj()
435 SfxBoolItem aItem( SID_ANIMATOR_ADD, TRUE );
437 GetBindings().GetDispatcher()->Execute(
438 SID_ANIMATOR_ADD, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, &aItem, 0L );
439 return( 0L );
442 // -----------------------------------------------------------------------
444 IMPL_LINK( AnimationWindow, ClickRemoveBitmapHdl, void *, pBtn )
446 SdPage* pPage = pMyDoc->GetSdPage(0, PK_STANDARD);
447 SdrObject* pObject;
449 if( pBtn == &aBtnRemoveBitmap )
451 ULONG nPos = aBmpExList.GetCurPos();
452 pBitmapEx = static_cast< BitmapEx* >( aBmpExList.GetCurObject() );
453 if( pBitmapEx )
455 delete pBitmapEx;
456 aBmpExList.Remove();
457 pBitmapEx = static_cast< BitmapEx* >( aBmpExList.GetCurObject() );
459 Time* pTime = static_cast< Time* >( aTimeList.GetObject( nPos ) );
460 if( pTime )
462 delete pTime;
463 aTimeList.Remove( nPos );
466 pObject = pPage->GetObj( nPos );
467 // Durch Uebernahme der AnimatedGIFs muessen nicht unbedingt
468 // Objekte vorhanden sein.
469 if( pObject )
471 pObject = pPage->RemoveObject(nPos);
472 DBG_ASSERT(pObject, "Clone beim Loeschen nicht gefunden");
473 SdrObject::Free( pObject );
474 pPage->RecalcObjOrdNums();
478 else // Alles loeschen
480 WarningBox aWarnBox( this, WB_YES_NO, String( SdResId( STR_ASK_DELETE_ALL_PICTURES ) ) );
481 short nReturn = aWarnBox.Execute();
483 if( nReturn == RET_YES )
485 // Bitmapliste bereinigen
486 long nCount = aBmpExList.Count();
487 long i;
489 for( i = nCount - 1; i >= 0; i-- )
491 pBitmapEx = static_cast< BitmapEx* >( aBmpExList.GetObject( i ) );
492 delete pBitmapEx;
494 pObject = pPage->GetObj( i );
495 if( pObject )
497 pObject = pPage->RemoveObject( i );
498 DBG_ASSERT(pObject, "Clone beim Loeschen nicht gefunden");
499 SdrObject::Free( pObject );
500 //pPage->RecalcObjOrdNums();
504 aBmpExList.Clear();
506 // Timeliste bereinigen
507 nCount = aTimeList.Count();
508 for( i = 0; i < nCount; i++ )
510 delete static_cast< Time* >( aTimeList.GetObject( i ) );
512 aTimeList.Clear();
516 // kann noch eine Animationsgruppe erstellt werden?
517 if (aBmpExList.Count() == 0)
519 aBtnCreateGroup.Disable();
520 // Falls vorher durch Uebernahme von AnimatedGIFs disabled:
521 //aRbtBitmap.Enable();
522 aRbtGroup.Enable();
525 // Zoom fuer DisplayWin berechnen und setzen
526 Fraction aFrac( GetScale() );
527 aCtlDisplay.SetScale( aFrac );
529 UpdateControl( aBmpExList.GetCurPos() );
531 return( 0L );
534 // -----------------------------------------------------------------------
536 IMPL_LINK( AnimationWindow, ClickCreateGroupHdl, void *, EMPTYARG )
538 // Code jetzt in CreatePresObj()
539 SfxBoolItem aItem( SID_ANIMATOR_CREATE, TRUE );
541 GetBindings().GetDispatcher()->Execute(
542 SID_ANIMATOR_CREATE, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, &aItem, 0L );
543 return( 0L );
546 // -----------------------------------------------------------------------
548 IMPL_LINK( AnimationWindow, ModifyBitmapHdl, void *, EMPTYARG )
550 ULONG nBmp = static_cast<ULONG>(aNumFldBitmap.GetValue());
552 if( nBmp > aBmpExList.Count() )
553 nBmp = aBmpExList.Count();
555 pBitmapEx = static_cast< BitmapEx* >( aBmpExList.GetObject( nBmp - 1 ) );
557 // Positionieren in der Liste
558 aBmpExList.Seek( nBmp - 1 );
560 UpdateControl( nBmp - 1 );
562 return( 0L );
565 // -----------------------------------------------------------------------
567 IMPL_LINK( AnimationWindow, ModifyTimeHdl, void *, EMPTYARG )
569 ULONG nPos = static_cast<ULONG>(aNumFldBitmap.GetValue() - 1);
571 Time* pTime = static_cast< Time* >( aTimeList.GetObject( nPos ) );
572 DBG_ASSERT( pTime, "Zeit nicht gefunden!" );
574 *pTime = aTimeField.GetTime();
576 return( 0L );
579 // -----------------------------------------------------------------------
581 void AnimationWindow::UpdateControl( ULONG nListPos, BOOL bDisableCtrls )
583 String aString;
585 if( pBitmapEx )
587 BitmapEx aBmp( *pBitmapEx );
589 SdPage* pPage = pMyDoc->GetSdPage(0, PK_STANDARD);
590 SdrObject* pObject = (SdrObject*) pPage->GetObj( (ULONG) nListPos );
591 if( pObject )
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( GetDisplayBackground().GetColor().IsDark()
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 ) );
613 aCtlDisplay.SetBitmapEx( &aBmp );
615 else
617 aCtlDisplay.SetBitmapEx( pBitmapEx );
619 aCtlDisplay.Invalidate();
620 aCtlDisplay.Update();
622 aFiCount.SetText( UniString::CreateFromInt32( aBmpExList.Count() ) );
624 if( pBitmapEx && !bMovie )
626 aNumFldBitmap.SetValue( nListPos + 1 );
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();
639 else
641 //aFiCount.SetText( String( SdResId( STR_NULL ) ) );
643 // Wenn kein Objekt in der Liste ist
644 aBtnFirst.Enable( FALSE );
645 aBtnReverse.Enable( FALSE );
646 aBtnPlay.Enable( FALSE );
647 aBtnLast.Enable( FALSE );
648 aNumFldBitmap.Enable( FALSE );
649 aTimeField.Enable( FALSE );
650 aLbLoopCount.Enable( FALSE );
651 aBtnRemoveBitmap.Enable( FALSE );
652 aBtnRemoveAll.Enable( FALSE );
654 //aFtAdjustment.Enable();
655 //aLbAdjustment.Enable();
658 if( bMovie && bDisableCtrls )
660 aBtnGetOneObject.Enable( FALSE );
661 aBtnGetAllObjects.Enable( FALSE );
662 aRbtGroup.Enable( FALSE );
663 aRbtBitmap.Enable( FALSE );
664 aBtnCreateGroup.Enable( FALSE );
665 aFtAdjustment.Enable( FALSE );
666 aLbAdjustment.Enable( FALSE );
668 else
670 // 'Gruppenobjekt' nur dann enablen, wenn es kein Animated GIF ist
671 if (aBmpExList.Count() == 0)
672 aRbtGroup.Enable();
674 aRbtBitmap.Enable();
675 aBtnCreateGroup.Enable(aBmpExList.Count() != 0);
676 aFtAdjustment.Enable( TRUE );
677 aLbAdjustment.Enable( TRUE );
680 ClickRbtHdl( NULL );
683 // -----------------------------------------------------------------------
685 void AnimationWindow::ResetAttrs()
687 aRbtGroup.Check();
688 aLbAdjustment.SelectEntryPos( BA_CENTER );
689 // LoopCount
690 aLbLoopCount.SelectEntryPos( aLbLoopCount.GetEntryCount() - 1);
692 UpdateControl( 0 );
695 // -----------------------------------------------------------------------
697 void AnimationWindow::WaitInEffect( ULONG nMilliSeconds ) const
699 ULONG nEnd = Time::GetSystemTicks() + nMilliSeconds;
700 ULONG nCurrent = Time::GetSystemTicks();
701 while (nCurrent < nEnd)
703 nCurrent = Time::GetSystemTicks();
704 Application::Reschedule();
708 // -----------------------------------------------------------------------
710 void AnimationWindow::WaitInEffect( ULONG nMilliSeconds, ULONG nTime,
711 SfxProgress* pProgress ) const
713 clock_t aEnd = Time::GetSystemTicks() + nMilliSeconds;
714 clock_t aCurrent = Time::GetSystemTicks();
715 while (aCurrent < aEnd)
717 aCurrent = Time::GetSystemTicks();
719 if( pProgress )
720 pProgress->SetState( nTime + nMilliSeconds + aCurrent - aEnd );
722 Application::Reschedule();
724 if( !bMovie )
725 return;
729 // -----------------------------------------------------------------------
731 Fraction AnimationWindow::GetScale()
733 Fraction aFrac;
734 ULONG nPos = aBmpExList.GetCurPos();
735 ULONG nCount = aBmpExList.Count();
736 if( nCount > 0 )
738 aBmpSize.Width() = 0;
739 aBmpSize.Height() = 0;
740 for( ULONG i = 0; i < nCount; i++ )
742 pBitmapEx = static_cast< BitmapEx* >( aBmpExList.GetObject( i ) );
743 Size aTempSize( pBitmapEx->GetBitmap().GetSizePixel() );
744 aBmpSize.Width() = Max( aBmpSize.Width(), aTempSize.Width() );
745 aBmpSize.Height() = Max( aBmpSize.Height(), aTempSize.Height() );
748 aBmpSize.Width() += 10;
749 aBmpSize.Height() += 10;
751 aFrac = Fraction( std::min( (double)aDisplaySize.Width() / (double)aBmpSize.Width(),
752 (double)aDisplaySize.Height() / (double)aBmpSize.Height() ) );
754 // Liste wieder auf alten Stand bringen
755 pBitmapEx = static_cast< BitmapEx* >( aBmpExList.GetObject( nPos ) );
756 return( aFrac );
759 // -----------------------------------------------------------------------
761 void AnimationWindow::Resize()
763 //if( !IsZoomedIn() )
764 if ( !IsFloatingMode() ||
765 !GetFloatingWindow()->IsRollUp() )
767 Size aWinSize( GetOutputSizePixel() ); // vorher rSize im Resizing()
769 Size aDiffSize;
770 aDiffSize.Width() = aWinSize.Width() - aSize.Width();
771 aDiffSize.Height() = aWinSize.Height() - aSize.Height();
773 // Umgroessern des Display-Controls
774 aDisplaySize.Width() += aDiffSize.Width();
775 aDisplaySize.Height() += aDiffSize.Height();
776 aCtlDisplay.SetOutputSizePixel( aDisplaySize );
778 Point aPt;
779 // aPt.X() = aDiffSize.Width() / 2;
780 aPt.Y() = aDiffSize.Height();
782 // Verschieben der anderen Controls
783 aBtnFirst.Hide();
784 aBtnReverse.Hide();
785 aBtnStop.Hide();
786 aBtnPlay.Hide();
787 aBtnLast.Hide();
788 aTimeField.Hide();
789 aLbLoopCount.Hide();
790 aNumFldBitmap.Hide();
791 aFtCount.Hide();
792 aFiCount.Hide();
793 aBtnGetOneObject.Hide();
794 aBtnGetAllObjects.Hide();
795 aBtnRemoveBitmap.Hide();
796 aBtnRemoveAll.Hide();
797 aGrpBitmap.Hide();
798 aRbtGroup.Hide();
799 aRbtBitmap.Hide();
800 aFtAdjustment.Hide();
801 aLbAdjustment.Hide();
802 aBtnCreateGroup.Hide();
803 aGrpAnimation.Hide();
806 aBtnFirst.SetPosPixel( aBtnFirst.GetPosPixel() + aPt );
807 aBtnReverse.SetPosPixel( aBtnReverse.GetPosPixel() + aPt );
808 aBtnStop.SetPosPixel( aBtnStop.GetPosPixel() + aPt );
809 aBtnPlay.SetPosPixel( aBtnPlay.GetPosPixel() + aPt );
810 aBtnLast.SetPosPixel( aBtnLast.GetPosPixel() + aPt );
811 aNumFldBitmap.SetPosPixel( aNumFldBitmap.GetPosPixel() + aPt );
812 aTimeField.SetPosPixel( aTimeField.GetPosPixel() + aPt );
813 aLbLoopCount.SetPosPixel( aLbLoopCount.GetPosPixel() + aPt );
814 aFtCount.SetPosPixel( aFtCount.GetPosPixel() + aPt );
815 aFiCount.SetPosPixel( aFiCount.GetPosPixel() + aPt );
816 aRbtGroup.SetPosPixel( aRbtGroup.GetPosPixel() + aPt );
817 aRbtBitmap.SetPosPixel( aRbtBitmap.GetPosPixel() + aPt );
818 aFtAdjustment.SetPosPixel( aFtAdjustment.GetPosPixel() + aPt );
819 aLbAdjustment.SetPosPixel( aLbAdjustment.GetPosPixel() + aPt );
820 aBtnGetOneObject.SetPosPixel( aBtnGetOneObject.GetPosPixel() + aPt );
821 aBtnGetAllObjects.SetPosPixel( aBtnGetAllObjects.GetPosPixel() + aPt );
822 aBtnRemoveBitmap.SetPosPixel( aBtnRemoveBitmap.GetPosPixel() + aPt );
823 aBtnRemoveAll.SetPosPixel( aBtnRemoveAll.GetPosPixel() + aPt );
824 aBtnCreateGroup.SetPosPixel( aBtnCreateGroup.GetPosPixel() + aPt );
825 aGrpBitmap.SetPosPixel( aGrpBitmap.GetPosPixel() + aPt );
826 aGrpAnimation.SetPosPixel( aGrpAnimation.GetPosPixel() + aPt );
828 // Zoom fuer DisplayWin berechnen und setzen
829 Fraction aFrac( GetScale() );
830 aCtlDisplay.SetScale( aFrac );
832 aBtnFirst.Show();
833 aBtnReverse.Show();
834 aBtnStop.Show();
835 aBtnPlay.Show();
836 aBtnLast.Show();
837 aNumFldBitmap.Show();
838 aTimeField.Show();
839 aLbLoopCount.Show();
840 aFtCount.Show();
841 aFiCount.Show();
842 aFtAdjustment.Show();
843 aLbAdjustment.Show();
844 aBtnGetOneObject.Show();
845 aBtnGetAllObjects.Show();
846 aBtnRemoveBitmap.Show();
847 aBtnRemoveAll.Show();
848 aGrpBitmap.Show();
849 aRbtGroup.Show();
850 aRbtBitmap.Show();
851 aFtAdjustment.Show();
852 aLbAdjustment.Show();
853 aBtnCreateGroup.Show();
854 aGrpAnimation.Show();
856 aSize = aWinSize;
858 //aFltWinSize = GetSizePixel();
860 SfxDockingWindow::Resize();
863 // -----------------------------------------------------------------------
865 BOOL AnimationWindow::Close()
867 if( maPlayLock.isLocked() )
869 return FALSE;
871 else
873 SfxBoolItem aItem( SID_ANIMATION_OBJECTS, FALSE );
875 GetBindings().GetDispatcher()->Execute(
876 SID_ANIMATION_OBJECTS, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
878 SfxDockingWindow::Close();
880 return TRUE;
884 // -----------------------------------------------------------------------
886 void AnimationWindow::FillInfo( SfxChildWinInfo& rInfo ) const
888 SfxDockingWindow::FillInfo( rInfo ) ;
891 // -----------------------------------------------------------------------
893 void AnimationWindow::AddObj (::sd::View& rView )
895 // Texteingabemodus beenden, damit Bitmap mit
896 // Objekt identisch ist.
897 if( rView.IsTextEdit() )
898 rView.SdrEndTextEdit();
900 // Objekt(e) clonen und den/die Clone(s) in die Liste stellen
901 const SdrMarkList& rMarkList = rView.GetMarkedObjectList();
902 ULONG nMarkCount = rMarkList.GetMarkCount();
903 SdPage* pPage = pMyDoc->GetSdPage(0, PK_STANDARD);
904 ULONG nCloneCount = pPage->GetObjCount();
906 if (nMarkCount > 0)
908 // Wenn es sich um EIN Animationsobjekt oder ein Gruppenobjekt
909 // handelt, das 'einzeln uebernommen' wurde,
910 // werden die einzelnen Objekte eingefuegt
911 BOOL bAnimObj = FALSE;
912 if( nMarkCount == 1 )
914 SdrMark* pMark = rMarkList.GetMark(0);
915 SdrObject* pObject = pMark->GetMarkedSdrObj();
916 SdAnimationInfo* pAnimInfo = rView.GetDoc()->GetAnimationInfo( pObject );
917 UINT32 nInv = pObject->GetObjInventor();
918 UINT16 nId = pObject->GetObjIdentifier();
920 // Animated Bitmap (GIF)
921 if( nInv == SdrInventor && nId == OBJ_GRAF && ( (SdrGrafObj*) pObject )->IsAnimated() )
923 const SdrGrafObj* pGrafObj = (SdrGrafObj*) pObject;
924 Graphic aGraphic( pGrafObj->GetTransformedGraphic() );
925 USHORT nCount = 0;
927 if( aGraphic.IsAnimated() )
928 nCount = aGraphic.GetAnimation().Count();
930 if( nCount > 0 )
932 const Animation aAnimation( aGraphic.GetAnimation() );
934 for( USHORT i = 0; i < nCount; i++ )
936 const AnimationBitmap& rAnimBmp = aAnimation.Get( i );
938 pBitmapEx = new BitmapEx( rAnimBmp.aBmpEx );
939 aBmpExList.Insert( pBitmapEx, aBmpExList.GetCurPos() + 1 );
941 // LoopCount
942 if( i == 0 )
944 long nLoopCount = aAnimation.GetLoopCount();
946 if( !nLoopCount ) // unendlich
947 aLbLoopCount.SelectEntryPos( aLbLoopCount.GetEntryCount() - 1);
948 else
949 aLbLoopCount.SelectEntry( UniString::CreateFromInt32( nLoopCount ) );
952 // Time
953 long nTime = rAnimBmp.nWait;
954 Time* pTime = new Time( 0, 0, nTime / 100, nTime % 100 );
955 aTimeList.Insert( pTime, aBmpExList.GetCurPos() + 1 );
957 // Weiterschalten der BitmapListe
958 aBmpExList.Next();
960 // Nachdem ein animated GIF uebernommen wurde, kann auch nur ein solches erstellt werden
961 aRbtBitmap.Check();
962 aRbtGroup.Enable( FALSE );
963 bAnimObj = TRUE;
966 else if( bAllObjects || ( pAnimInfo && pAnimInfo->mbIsMovie ) )
968 // Mehrere Objekte
969 SdrObjList* pObjList = ((SdrObjGroup*)pObject)->GetSubList();
971 for( USHORT nObject = 0; nObject < pObjList->GetObjCount(); nObject++ )
973 SdrObject* pSnapShot = (SdrObject*) pObjList->GetObj( (ULONG) nObject );
975 pBitmapEx = new BitmapEx( SdrExchangeView::GetObjGraphic( pSnapShot->GetModel(), pSnapShot ).GetBitmapEx() );
976 aBmpExList.Insert( pBitmapEx, aBmpExList.GetCurPos() + 1 );
978 // Time
979 Time* pTime = new Time( aTimeField.GetTime() );
980 aTimeList.Insert( pTime, aBmpExList.GetCurPos() + 1 );
982 // Clone
983 pPage->InsertObject( pSnapShot->Clone(), aBmpExList.GetCurPos() + 1 );
985 // Weiterschalten der BitmapListe
986 aBmpExList.Next();
988 bAnimObj = TRUE;
991 // Auch ein einzelnes animiertes Objekt
992 if( !bAnimObj && !( bAllObjects && nMarkCount > 1 ) )
994 pBitmapEx = new BitmapEx( rView.GetAllMarkedGraphic().GetBitmapEx() );
995 aBmpExList.Insert( pBitmapEx, aBmpExList.GetCurPos() + 1 );
997 // Time
998 Time* pTime = new Time( aTimeField.GetTime() );
999 aTimeList.Insert( pTime, aBmpExList.GetCurPos() + 1 );
1003 // ein einzelnes Objekt
1004 if( nMarkCount == 1 && !bAnimObj )
1006 SdrMark* pMark = rMarkList.GetMark(0);
1007 SdrObject* pObject = pMark->GetMarkedSdrObj();
1008 SdrObject* pClone = pObject->Clone();
1009 pPage->InsertObject(pClone, aBmpExList.GetCurPos() + 1);
1011 // mehrere Objekte: die Clones zu einer Gruppe zusammenfassen
1012 else if (nMarkCount > 1)
1014 // Objekte einzeln uebernehmen
1015 if( bAllObjects )
1017 for( ULONG nObject= 0; nObject < nMarkCount; nObject++ )
1019 // Clone
1020 SdrObject* pObject = rMarkList.GetMark( nObject )->GetMarkedSdrObj();
1022 pBitmapEx = new BitmapEx( SdrExchangeView::GetObjGraphic( pObject->GetModel(), pObject ).GetBitmapEx() );
1023 aBmpExList.Insert( pBitmapEx, aBmpExList.GetCurPos() + 1 );
1025 // Time
1026 Time* pTime = new Time( aTimeField.GetTime() );
1027 aTimeList.Insert( pTime, aBmpExList.GetCurPos() + 1 );
1029 pPage->InsertObject( pObject->Clone(), aBmpExList.GetCurPos() + 1 );
1031 aBmpExList.Next();
1033 bAnimObj = TRUE; // damit nicht nochmal weitergeschaltet wird
1035 else
1037 SdrObjGroup* pCloneGroup = new SdrObjGroup;
1038 SdrObjList* pObjList = pCloneGroup->GetSubList();
1040 for (ULONG nObject= 0; nObject < nMarkCount; nObject++)
1041 pObjList->InsertObject(rMarkList.GetMark(nObject)->GetMarkedSdrObj()->Clone(), LIST_APPEND);
1043 pPage->InsertObject(pCloneGroup, aBmpExList.GetCurPos() + 1);
1047 if( !bAnimObj )
1048 aBmpExList.Next();
1050 // wenn vorher nichts im Animator war und jetzt was da ist, kann eine
1051 // Animationsgruppe erstellt werden
1052 if (nCloneCount == 0 && aBmpExList.Count() > 0)
1053 aBtnCreateGroup.Enable();
1055 // Zoom fuer DisplayWin berechnen und setzen
1056 Fraction aFrac( GetScale() );
1057 aCtlDisplay.SetScale( aFrac );
1059 UpdateControl( aBmpExList.GetCurPos() );
1063 // -----------------------------------------------------------------------
1065 void AnimationWindow::CreateAnimObj (::sd::View& rView )
1067 ::Window* pOutWin = static_cast< ::Window*>(rView.GetFirstOutputDevice()); // GetWin( 0 );
1068 DBG_ASSERT( pOutWin, "Window ist nicht vorhanden!" );
1070 // die Fentermitte ermitteln
1071 const MapMode aMap100( MAP_100TH_MM );
1072 Size aMaxSizeLog;
1073 Size aMaxSizePix;
1074 Size aTemp( pOutWin->GetOutputSizePixel() );
1075 const Point aWindowCenter( pOutWin->PixelToLogic( Point( aTemp.Width() >> 1, aTemp.Height() >> 1 ) ) );
1076 const OutputDevice* pDefDev = Application::GetDefaultDevice();
1077 const ULONG nCount = aBmpExList.Count();
1078 BitmapAdjustment eBA = (BitmapAdjustment) aLbAdjustment.GetSelectEntryPos();
1079 ULONG i;
1081 // Groesste Bitmap ermitteln
1082 for( i = 0; i < nCount; i++ )
1084 const BitmapEx& rBmpEx = *static_cast< BitmapEx* >( aBmpExList.GetObject( i ) );
1085 const Graphic aGraphic( rBmpEx );
1086 Size aTmpSizeLog;
1087 const Size aTmpSizePix( rBmpEx.GetSizePixel() );
1089 if ( aGraphic.GetPrefMapMode().GetMapUnit() == MAP_PIXEL )
1090 aTmpSizeLog = pDefDev->PixelToLogic( aGraphic.GetPrefSize(), aMap100 );
1091 else
1092 aTmpSizeLog = pDefDev->LogicToLogic( aGraphic.GetPrefSize(), aGraphic.GetPrefMapMode(), aMap100 );
1094 aMaxSizeLog.Width() = Max( aMaxSizeLog.Width(), aTmpSizeLog.Width() );
1095 aMaxSizeLog.Height() = Max( aMaxSizeLog.Height(), aTmpSizeLog.Height() );
1097 aMaxSizePix.Width() = Max( aMaxSizePix.Width(), aTmpSizePix.Width() );
1098 aMaxSizePix.Height() = Max( aMaxSizePix.Height(), aTmpSizePix.Height() );
1101 SdrPageView* pPV = rView.GetSdrPageView();
1103 if( aRbtBitmap.IsChecked() )
1105 // Bitmapgruppe erzeugen (Animated GIF)
1106 Animation aAnimation;
1107 Point aPt;
1109 for( i = 0; i < nCount; i++ )
1111 Time* pTime = static_cast< Time* >( aTimeList.GetObject( i ) );
1112 long nTime = pTime->Get100Sec();
1113 nTime += pTime->GetSec() * 100;
1115 pBitmapEx = static_cast< BitmapEx* >( aBmpExList.GetObject( i ) );
1117 // Offset fuer die gewuenschte Ausrichtung bestimmen
1118 const Size aBitmapSize( pBitmapEx->GetSizePixel() );
1120 switch( eBA )
1122 case BA_LEFT_UP:
1123 break;
1125 case BA_LEFT:
1126 aPt.Y() = (aMaxSizePix.Height() - aBitmapSize.Height()) >> 1;
1127 break;
1129 case BA_LEFT_DOWN:
1130 aPt.Y() = aMaxSizePix.Height() - aBitmapSize.Height();
1131 break;
1133 case BA_UP:
1134 aPt.X() = (aMaxSizePix.Width() - aBitmapSize.Width()) >> 1;
1135 break;
1137 case BA_CENTER:
1138 aPt.X() = (aMaxSizePix.Width() - aBitmapSize.Width()) >> 1;
1139 aPt.Y() = (aMaxSizePix.Height() - aBitmapSize.Height()) >> 1;
1140 break;
1142 case BA_DOWN:
1143 aPt.X() = (aMaxSizePix.Width() - aBitmapSize.Width()) >> 1;
1144 aPt.Y() = aMaxSizePix.Height() - aBitmapSize.Height();
1145 break;
1147 case BA_RIGHT_UP:
1148 aPt.X() = aMaxSizePix.Width() - aBitmapSize.Width();
1149 break;
1151 case BA_RIGHT:
1152 aPt.X() = aMaxSizePix.Width() - aBitmapSize.Width();
1153 aPt.Y() = (aMaxSizePix.Height() - aBitmapSize.Height()) >> 1;
1154 break;
1156 case BA_RIGHT_DOWN:
1157 aPt.X() = aMaxSizePix.Width() - aBitmapSize.Width();
1158 aPt.Y() = aMaxSizePix.Height() - aBitmapSize.Height();
1159 break;
1163 // LoopCount (Anzahl der Durchlaeufe) ermitteln
1164 AnimationBitmap aAnimBmp;
1165 long nLoopCount = 0L;
1166 USHORT nPos = aLbLoopCount.GetSelectEntryPos();
1168 if( nPos != LISTBOX_ENTRY_NOTFOUND && nPos != aLbLoopCount.GetEntryCount() - 1 ) // unendlich
1169 nLoopCount = (long) aLbLoopCount.GetSelectEntry().ToInt32();
1171 aAnimBmp.aBmpEx = *pBitmapEx;
1172 aAnimBmp.aPosPix = aPt;
1173 aAnimBmp.aSizePix = aBitmapSize;
1174 aAnimBmp.nWait = nTime;
1175 aAnimBmp.eDisposal = DISPOSE_BACK;
1176 aAnimBmp.bUserInput = FALSE;
1178 aAnimation.Insert( aAnimBmp );
1179 aAnimation.SetDisplaySizePixel( aMaxSizePix );
1180 aAnimation.SetLoopCount( nLoopCount );
1183 SdrGrafObj* pGrafObj = new SdrGrafObj( Graphic( aAnimation ) );
1184 const Point aOrg( aWindowCenter.X() - ( aMaxSizeLog.Width() >> 1 ), aWindowCenter.Y() - ( aMaxSizeLog.Height() >> 1 ) );
1186 pGrafObj->SetLogicRect( Rectangle( aOrg, aMaxSizeLog ) );
1187 rView.InsertObjectAtView( pGrafObj, *pPV, SDRINSERT_SETDEFLAYER);
1189 else
1191 // Offset fuer die gewuenschte Ausrichtung bestimmen
1192 Size aOffset;
1193 SdrObject * pClone = NULL;
1194 SdPage* pPage = pMyDoc->GetSdPage(0, PK_STANDARD);
1196 for(i = 0; i < nCount; i++)
1198 pClone = pPage->GetObj(i);
1199 Rectangle aRect( pClone->GetSnapRect() );
1201 switch( eBA )
1203 case BA_LEFT_UP:
1204 break;
1206 case BA_LEFT:
1207 aOffset.Height() = (aMaxSizeLog.Height() - aRect.GetHeight()) / 2;
1208 break;
1210 case BA_LEFT_DOWN:
1211 aOffset.Height() = aMaxSizeLog.Height() - aRect.GetHeight();
1212 break;
1214 case BA_UP:
1215 aOffset.Width() = (aMaxSizeLog.Width() - aRect.GetWidth()) / 2;
1216 break;
1218 case BA_CENTER:
1219 aOffset.Width() = (aMaxSizeLog.Width() - aRect.GetWidth()) / 2;
1220 aOffset.Height() = (aMaxSizeLog.Height() - aRect.GetHeight()) / 2;
1221 break;
1223 case BA_DOWN:
1224 aOffset.Width() = (aMaxSizeLog.Width() - aRect.GetWidth()) / 2;
1225 aOffset.Height() = aMaxSizeLog.Height() - aRect.GetHeight();
1226 break;
1228 case BA_RIGHT_UP:
1229 aOffset.Width() = aMaxSizeLog.Width() - aRect.GetWidth();
1230 break;
1232 case BA_RIGHT:
1233 aOffset.Width() = aMaxSizeLog.Width() - aRect.GetWidth();
1234 aOffset.Height() = (aMaxSizeLog.Height() - aRect.GetHeight()) / 2;
1235 break;
1237 case BA_RIGHT_DOWN:
1238 aOffset.Width() = aMaxSizeLog.Width() - aRect.GetWidth();
1239 aOffset.Height() = aMaxSizeLog.Height() - aRect.GetHeight();
1240 break;
1243 //aRect.SetPos(aWindowCenter + Point(aOffset.Width(), aOffset.Height()));
1244 //pClone->SetSnapRect( aRect );
1245 // SetSnapRect ist fuer Ellipsen leider nicht implementiert !!!
1246 Point aMovePt( aWindowCenter + Point( aOffset.Width(), aOffset.Height() ) - aRect.TopLeft() );
1247 Size aMoveSize( aMovePt.X(), aMovePt.Y() );
1248 pClone->NbcMove( aMoveSize );
1251 // Animationsgruppe erzeugen
1252 SdrObjGroup* pGroup = new SdrObjGroup;
1253 SdrObjList* pObjList = pGroup->GetSubList();
1255 for (i = 0; i < nCount; i++)
1257 // der Clone verbleibt im Animator; in die Gruppe kommt ein Clone
1258 // des Clones
1259 pClone = pPage->GetObj(i);
1260 SdrObject* pCloneOfClone = pClone->Clone();
1261 //SdrObject* pCloneOfClone = pPage->GetObj(i)->Clone();
1262 pObjList->InsertObject(pCloneOfClone, LIST_APPEND);
1265 // bis jetzt liegt die linke obere Ecke der Gruppe in der Fenstermitte;
1266 // jetzt noch um die Haelfte der Groesse nach oben und links korrigieren
1267 aTemp = aMaxSizeLog;
1268 aTemp.Height() = - aTemp.Height() / 2;
1269 aTemp.Width() = - aTemp.Width() / 2;
1270 pGroup->NbcMove(aTemp);
1272 // Animationsinformation erzeugen
1273 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pGroup,true);
1274 pInfo->meEffect = presentation::AnimationEffect_NONE;
1275 pInfo->meSpeed = presentation::AnimationSpeed_MEDIUM;
1276 pInfo->mbActive = TRUE;
1277 pInfo->mbIsMovie = TRUE;
1278 pInfo->maBlueScreen = COL_WHITE;
1280 rView.InsertObjectAtView( pGroup, *pPV, SDRINSERT_SETDEFLAYER);
1283 ClickFirstHdl( this );
1286 void AnimationWindow::DataChanged( const DataChangedEvent& rDCEvt )
1288 SfxDockingWindow::DataChanged( rDCEvt );
1290 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
1292 UpdateControl( aBmpExList.GetCurPos() );
1296 /*************************************************************************
1298 |* ControllerItem fuer Animator
1300 \************************************************************************/
1302 AnimationControllerItem::AnimationControllerItem(
1303 USHORT _nId,
1304 AnimationWindow* pAnimWin,
1305 SfxBindings* _pBindings)
1306 : SfxControllerItem( _nId, *_pBindings ),
1307 pAnimationWin( pAnimWin )
1311 // -----------------------------------------------------------------------
1313 void AnimationControllerItem::StateChanged( USHORT nSId,
1314 SfxItemState eState, const SfxPoolItem* pItem )
1316 if( eState >= SFX_ITEM_AVAILABLE && nSId == SID_ANIMATOR_STATE )
1318 const SfxUInt16Item* pStateItem = PTR_CAST( SfxUInt16Item, pItem );
1319 DBG_ASSERT( pStateItem, "SfxUInt16Item erwartet");
1320 UINT16 nState = pStateItem->GetValue();
1322 pAnimationWin->aBtnGetOneObject.Enable( nState & 1 );
1323 pAnimationWin->aBtnGetAllObjects.Enable( nState & 2 );
1328 } // end of namespace sd