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