merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / animations / CustomAnimationCreateDialog.cxx
blobae53aa8f763cb62c309f5dff98b8817dfb8399d1
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: CustomAnimationCreateDialog.cxx,v $
10 * $Revision: 1.14.74.1 $
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"
34 #ifndef _COM_SUN_STAR_UTIL_XCOLLATOR_HPP_
35 #include <com/sun/star/i18n/XCollator.hpp>
36 #endif
38 #ifndef _UNOTOOLS_PROCESSFACTORY_HXX
39 #include <comphelper/processfactory.hxx>
40 #endif
41 #include <vcl/svapp.hxx>
42 #include <vcl/tabctrl.hxx>
43 #include <vcl/tabpage.hxx>
45 #ifndef _SV_BUTTON_HXX
46 #include <vcl/button.hxx>
47 #endif
48 #include <vcl/fixed.hxx>
49 #include <vcl/lstbox.hxx>
50 #include <vcl/combobox.hxx>
51 #include <svtools/valueset.hxx>
53 #include <svx/svdetc.hxx>
54 #include <svx/svdstr.hrc>
55 #include "sdresid.hxx"
56 #include <svtools/viewoptions.hxx>
57 #include <com/sun/star/presentation/EffectNodeType.hpp>
58 #include "CustomAnimationCreateDialog.hxx"
59 #ifndef _SD_CUSTOMANIMATIONCREATEDIALOG_HRC
60 #include "CustomAnimationCreateDialog.hrc"
61 #endif
62 #ifndef _SD_CUSTOMANIMATION_HRC
63 #include "CustomAnimation.hrc"
64 #endif
65 #include "CustomAnimationPane.hxx"
66 #include "optsitem.hxx"
67 #include "sddll.hxx"
69 #include "helpids.h"
71 using namespace ::com::sun::star;
73 using ::rtl::OUString;
74 using ::com::sun::star::uno::UNO_QUERY;
75 using ::com::sun::star::uno::UNO_QUERY_THROW;
76 using ::com::sun::star::uno::Any;
77 using ::com::sun::star::uno::Reference;
78 using ::com::sun::star::uno::Exception;
80 using namespace ::com::sun::star::presentation;
82 namespace sd {
85 const int ENTRANCE = 0;
86 const int EMPHASIS = 1;
87 const int EXIT = 2;
88 const int MOTIONPATH = 3;
89 const int MISCEFFECTS = 4;
91 extern void fillDurationComboBox( ComboBox* pBox );
93 // --------------------------------------------------------------------
95 class CategoryListBox : public ListBox
97 public:
98 CategoryListBox( Window* pParent, WinBits nStyle = WB_BORDER );
99 CategoryListBox( Window* pParent, const ResId& rResId );
100 ~CategoryListBox();
102 virtual void MouseButtonUp( const MouseEvent& rMEvt );
104 USHORT InsertCategory( const XubString& rStr, USHORT nPos = LISTBOX_APPEND );
106 void SetDoubleClickLink( const Link& rDoubleClickHdl ) { maDoubleClickHdl = rDoubleClickHdl; }
108 DECL_LINK( implDoubleClickHdl, Control* );
110 private:
111 virtual void UserDraw( const UserDrawEvent& rUDEvt );
113 Link maDoubleClickHdl;
116 CategoryListBox::CategoryListBox( Window* pParent, WinBits nStyle /* = WB_BORDER */ )
117 : ListBox( pParent, nStyle )
119 EnableUserDraw( TRUE );
122 CategoryListBox::CategoryListBox( Window* pParent, const ResId& rResId )
123 : ListBox( pParent, rResId )
125 EnableUserDraw( TRUE );
126 SetDoubleClickHdl( LINK( this, CategoryListBox, implDoubleClickHdl ) );
129 CategoryListBox::~CategoryListBox()
133 USHORT CategoryListBox::InsertCategory( const XubString& rStr, USHORT nPos /* = LISTBOX_APPEND */ )
135 USHORT n = ListBox::InsertEntry( rStr, nPos );
136 if( n != LISTBOX_ENTRY_NOTFOUND )
137 ListBox::SetEntryFlags( n, ListBox::GetEntryFlags(n) | LISTBOX_ENTRY_FLAG_DISABLE_SELECTION );
139 return n;
142 void CategoryListBox::UserDraw( const UserDrawEvent& rUDEvt )
144 const USHORT nItem = rUDEvt.GetItemId();
146 if( ListBox::GetEntryFlags(nItem) & LISTBOX_ENTRY_FLAG_DISABLE_SELECTION )
148 Rectangle aOutRect( rUDEvt.GetRect() );
149 OutputDevice* pDev = rUDEvt.GetDevice();
151 // fill the background
152 Color aColor (GetSettings().GetStyleSettings().GetDialogColor());
154 pDev->SetFillColor (aColor);
155 pDev->SetLineColor ();
156 pDev->DrawRect(aOutRect);
158 // Erase the four corner pixels to make the rectangle appear rounded.
159 pDev->SetLineColor( GetSettings().GetStyleSettings().GetWindowColor());
160 pDev->DrawPixel( aOutRect.TopLeft());
161 pDev->DrawPixel( Point(aOutRect.Right(), aOutRect.Top()));
162 pDev->DrawPixel( Point(aOutRect.Left(), aOutRect.Bottom()));
163 pDev->DrawPixel( Point(aOutRect.Right(), aOutRect.Bottom()));
165 // draw the category title
166 pDev->DrawText (aOutRect, GetEntry(nItem), TEXT_DRAW_CENTER );
168 else
170 DrawEntry( rUDEvt, TRUE, TRUE );
174 // --------------------------------------------------------------------
176 IMPL_LINK( CategoryListBox, implDoubleClickHdl, Control*, EMPTYARG )
178 CaptureMouse();
179 return 0;
182 // --------------------------------------------------------------------
184 void CategoryListBox::MouseButtonUp( const MouseEvent& rMEvt )
186 ReleaseMouse();
187 if( rMEvt.IsLeft() && (rMEvt.GetClicks() == 2) )
189 if( maDoubleClickHdl.IsSet() )
190 maDoubleClickHdl.Call( this );
192 else
194 ListBox::MouseButtonUp( rMEvt );
198 // --------------------------------------------------------------------
200 class CustomAnimationCreateTabPage : public TabPage
202 public:
203 CustomAnimationCreateTabPage( Window* pParent, CustomAnimationCreateDialog* pDialogParent, int nTabId, const PresetCategoryList& rCategoryList, bool bHasText );
204 ~CustomAnimationCreateTabPage();
206 PathKind getCreatePathKind() const;
207 CustomAnimationPresetPtr getSelectedPreset() const;
208 double getDuration() const;
209 void setDuration( double fDuration );
211 bool getIsPreview() const;
212 void setIsPreview( bool bIsPreview );
214 bool select( const OUString& rsPresetId );
216 private:
217 DECL_LINK( implSelectHdl, Control* );
218 DECL_LINK( implDoubleClickHdl, Control* );
220 void onSelectEffect();
222 void clearEffects();
224 private:
225 CategoryListBox* mpLBEffects;
226 FixedText* mpFTSpeed;
227 ComboBox* mpCBSpeed;
228 CheckBox* mpCBXPReview;
230 CustomAnimationCreateDialog* mpParent;
232 USHORT mnCurvePathPos;
233 USHORT mnPolygonPathPos;
234 USHORT mnFreeformPathPos;
238 struct ImplStlEffectCategorySortHelper
240 ImplStlEffectCategorySortHelper();
241 bool operator()( const CustomAnimationPresetPtr& p1, const CustomAnimationPresetPtr& p2 );
243 private:
244 uno::Reference< i18n::XCollator > mxCollator;
247 ImplStlEffectCategorySortHelper::ImplStlEffectCategorySortHelper()
249 uno::Reference<lang::XMultiServiceFactory> xFac( ::comphelper::getProcessServiceFactory() );
250 if( xFac.is() )
252 mxCollator.set( xFac->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.i18n.Collator" ) ), uno::UNO_QUERY );
254 if( mxCollator.is() )
256 const lang::Locale& rLocale = Application::GetSettings().GetLocale();
257 mxCollator->loadDefaultCollator(rLocale, 0);
262 bool ImplStlEffectCategorySortHelper::operator()( const CustomAnimationPresetPtr& p1, const CustomAnimationPresetPtr& p2 )
264 return mxCollator.is() ? mxCollator->compareString(p1->getLabel(), p2->getLabel()) == -1 : false;
267 CustomAnimationCreateTabPage::CustomAnimationCreateTabPage( Window* pParent, CustomAnimationCreateDialog* pDialogParent, int nTabId, const PresetCategoryList& rCategoryList, bool bHasText )
268 : TabPage( pParent, SdResId( RID_TP_CUSTOMANIMATION_ENTRANCE ) )
269 , mpParent( pDialogParent )
270 , mnCurvePathPos( LISTBOX_ENTRY_NOTFOUND )
271 , mnPolygonPathPos( LISTBOX_ENTRY_NOTFOUND )
272 , mnFreeformPathPos( LISTBOX_ENTRY_NOTFOUND )
274 mpLBEffects = new CategoryListBox( this, SdResId( LB_EFFECTS ) );
275 mpFTSpeed = new FixedText( this, SdResId( FT_SPEED ) );
276 mpCBSpeed = new ComboBox( this, SdResId( CB_SPEED ) );
277 mpCBXPReview = new CheckBox( this, SdResId( CBX_PREVIEW ) );
279 String sMotionPathLabel( SdResId( STR_USERPATH ) );
281 FreeResource();
283 USHORT nFirstEffect = LISTBOX_ENTRY_NOTFOUND;
285 if( nTabId == MOTIONPATH )
287 mpLBEffects->InsertCategory( sMotionPathLabel );
289 mnCurvePathPos = nFirstEffect = mpLBEffects->InsertEntry( sdr::GetResourceString(STR_ObjNameSingulCOMBLINE) );
290 mnPolygonPathPos = mpLBEffects->InsertEntry( sdr::GetResourceString(STR_ObjNameSingulPOLY) );
291 mnFreeformPathPos = mpLBEffects->InsertEntry( sdr::GetResourceString(STR_ObjNameSingulFREELINE) );
294 PresetCategoryList::const_iterator aCategoryIter( rCategoryList.begin() );
295 const PresetCategoryList::const_iterator aCategoryEnd( rCategoryList.end() );
296 while( aCategoryIter != aCategoryEnd )
298 PresetCategoryPtr pCategory( *aCategoryIter++ );
299 if( pCategory.get() )
301 mpLBEffects->InsertCategory( pCategory->maLabel );
303 std::vector< CustomAnimationPresetPtr > aSortedVector(pCategory->maEffects.size());
304 std::copy( pCategory->maEffects.begin(), pCategory->maEffects.end(), aSortedVector.begin() );
305 ImplStlEffectCategorySortHelper aSortHelper;
306 std::sort( aSortedVector.begin(), aSortedVector.end(), aSortHelper );
308 std::vector< CustomAnimationPresetPtr >::const_iterator aIter( aSortedVector.begin() );
309 const std::vector< CustomAnimationPresetPtr >::const_iterator aEnd( aSortedVector.end() );
310 while( aIter != aEnd )
312 CustomAnimationPresetPtr pDescriptor = (*aIter++);
313 if( pDescriptor.get() && (bHasText || !pDescriptor->isTextOnly() ) )
315 USHORT nPos = mpLBEffects->InsertEntry( pDescriptor->getLabel() );
316 mpLBEffects->SetEntryData( nPos, static_cast<void*>( new CustomAnimationPresetPtr( pDescriptor ) ) );
318 if( nFirstEffect == LISTBOX_ENTRY_NOTFOUND )
319 nFirstEffect = nPos;
325 mpLBEffects->SelectEntryPos( nFirstEffect );
327 fillDurationComboBox( mpCBSpeed );
329 if( nFirstEffect != LISTBOX_ENTRY_NOTFOUND )
330 onSelectEffect();
332 mpLBEffects->SetSelectHdl( LINK( this, CustomAnimationCreateTabPage, implSelectHdl ) );
333 mpLBEffects->SetDoubleClickLink( LINK( this, CustomAnimationCreateTabPage, implDoubleClickHdl ) );
336 CustomAnimationCreateTabPage::~CustomAnimationCreateTabPage()
338 clearEffects();
340 delete mpLBEffects;
341 delete mpFTSpeed;
342 delete mpCBSpeed;
343 delete mpCBXPReview;
346 IMPL_LINK( CustomAnimationCreateTabPage, implSelectHdl, Control*, pControl )
348 if( pControl == mpLBEffects )
349 onSelectEffect();
350 return 0;
353 IMPL_LINK( CustomAnimationCreateTabPage, implDoubleClickHdl, Control*, pControl )
355 if( pControl == mpLBEffects )
357 if( mpLBEffects->GetSelectEntryCount() )
358 mpParent->EndDialog( TRUE );
360 return 0;
363 void CustomAnimationCreateTabPage::onSelectEffect()
365 CustomAnimationPresetPtr*p = static_cast< CustomAnimationPresetPtr* >( mpLBEffects->GetEntryData( mpLBEffects->GetSelectEntryPos() ) );
367 if( !p )
368 return;
370 CustomAnimationPresetPtr pPreset( *p );
372 const double fDuration = pPreset->getDuration();
373 USHORT nPos = 0xffff;
375 if( fDuration == 5.0 )
376 nPos = 0;
377 else if( fDuration == 3.0 )
378 nPos = 1;
379 else if( fDuration == 2.0 )
380 nPos = 2;
381 else if( fDuration == 1.0 )
382 nPos = 3;
383 else if( fDuration == 0.5 )
384 nPos = 4;
386 mpCBSpeed->SelectEntryPos( nPos );
388 bool bHasSpeed = pPreset->getDuration() > 0.001;
389 mpCBSpeed->Enable( bHasSpeed );
390 mpFTSpeed->Enable( bHasSpeed );
392 if( mpCBXPReview->IsChecked() )
394 mpParent->preview( pPreset );
398 void CustomAnimationCreateTabPage::clearEffects()
400 USHORT nPos = mpLBEffects->GetEntryCount();
401 while( nPos-- )
402 delete static_cast< CustomAnimationPresetPtr* >( mpLBEffects->GetEntryData( nPos ) );
404 mpLBEffects->Clear();
407 CustomAnimationPresetPtr CustomAnimationCreateTabPage::getSelectedPreset() const
409 CustomAnimationPresetPtr pPreset;
411 if( mpLBEffects->GetSelectEntryCount() == 1 )
413 void* pEntryData = mpLBEffects->GetEntryData( mpLBEffects->GetSelectEntryPos() );
414 if( pEntryData )
415 pPreset = *static_cast< CustomAnimationPresetPtr* >( pEntryData );
418 return pPreset;
421 PathKind CustomAnimationCreateTabPage::getCreatePathKind() const
423 PathKind eKind = NONE;
425 if( mpLBEffects->GetSelectEntryCount() == 1 )
427 const USHORT nPos = mpLBEffects->GetSelectEntryPos();
428 if( nPos == mnCurvePathPos )
430 eKind = CURVE;
432 else if( nPos == mnPolygonPathPos )
434 eKind = POLYGON;
436 else if( nPos == mnFreeformPathPos )
438 eKind = FREEFORM;
442 return eKind;
447 double CustomAnimationCreateTabPage::getDuration() const
449 USHORT nPos = mpCBSpeed->GetSelectEntryPos();
450 if( (nPos == 0xffff) || !mpCBSpeed->IsEnabled() )
452 CustomAnimationPresetPtr pPreset = getSelectedPreset();
453 if( pPreset.get() )
454 return pPreset->getDuration();
457 switch( nPos )
459 case 0: return 5.0f;
460 case 1: return 3.0f;
461 case 2: return 2.0f;
462 case 3: return 1.0f;
463 case 4: return 0.5f;
466 return 0.0f;
469 void CustomAnimationCreateTabPage::setDuration( double fDuration )
471 USHORT nPos = 0;
472 if( fDuration < 2.0f )
474 if( fDuration < 1.0f )
476 nPos = 4;
478 else
480 nPos = 3;
483 else if( fDuration < 5.0f )
485 if( fDuration < 3.0f )
487 nPos = 2;
489 else
491 nPos = 1;
495 mpCBSpeed->SelectEntryPos( nPos );
498 bool CustomAnimationCreateTabPage::getIsPreview() const
500 return mpCBXPReview->IsChecked() ? true : false;
503 void CustomAnimationCreateTabPage::setIsPreview( bool bIsPreview )
505 mpCBXPReview->Check( bIsPreview ? TRUE : FALSE );
508 bool CustomAnimationCreateTabPage::select( const OUString& rsPresetId )
510 USHORT nPos = mpLBEffects->GetEntryCount();
511 while( nPos-- )
513 void* pEntryData = mpLBEffects->GetEntryData( nPos );
514 if( pEntryData )
516 CustomAnimationPresetPtr& pPtr = *static_cast< CustomAnimationPresetPtr* >(pEntryData);
517 if( pPtr.get() && pPtr->getPresetId() == rsPresetId )
519 mpLBEffects->SelectEntryPos( nPos );
520 return true;
525 return false;
528 // --------------------------------------------------------------------
530 CustomAnimationCreateDialog::CustomAnimationCreateDialog( Window* pParent, CustomAnimationPane* pPane, const std::vector< ::com::sun::star::uno::Any >& rTargets, bool bHasText, const ::rtl::OUString& rsPresetId, double fDuration )
531 : TabDialog( pParent, SdResId( DLG_CUSTOMANIMATION_CREATE ) )
532 , mpPane( pPane )
533 , mrTargets( rTargets )
534 , mfDuration( fDuration )
536 mpTabControl = new TabControl( this, SdResId( 1 ) );
537 mpOKButton = new OKButton(this, SdResId( 1 ) ) ;
538 mpOKButton->SetStyle(WB_DEFBUTTON);
539 mpCancelButton = new CancelButton(this, SdResId( 1 ) );
540 mpCancelButton->SetStyle(WB_DEFBUTTON);
541 mpHelpButton = new HelpButton(this, SdResId( 1 ) );
543 FreeResource();
545 SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
546 mbIsPreview = pOptions->IsPreviewNewEffects();
548 const CustomAnimationPresets& rPresets = CustomAnimationPresets::getCustomAnimationPresets();
549 mpTabPages[ENTRANCE] = new CustomAnimationCreateTabPage( mpTabControl, this, ENTRANCE, rPresets.getEntrancePresets(), bHasText );
550 mpTabPages[ENTRANCE]->SetHelpId( HID_SD_CUSTOMANIMATIONDIALOG_ENTRANCE );
551 mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_ENTRANCE, mpTabPages[ENTRANCE] );
552 mpTabPages[EMPHASIS] = new CustomAnimationCreateTabPage( mpTabControl, this, EMPHASIS, rPresets.getEmphasisPresets(), bHasText );
553 mpTabPages[EMPHASIS]->SetHelpId( HID_SD_CUSTOMANIMATIONDIALOG_EMPHASIS );
554 mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_EMPHASIS, mpTabPages[EMPHASIS] );
555 mpTabPages[EXIT] = new CustomAnimationCreateTabPage( mpTabControl, this, EXIT, rPresets.getExitPresets(), bHasText );
556 mpTabPages[EXIT]->SetHelpId( HID_SD_CUSTOMANIMATIONDIALOG_EXIT );
557 mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_EXIT, mpTabPages[EXIT] );
558 mpTabPages[MOTIONPATH] = new CustomAnimationCreateTabPage( mpTabControl, this, MOTIONPATH, rPresets.getMotionPathsPresets(), bHasText );
559 mpTabPages[MOTIONPATH]->SetHelpId( HID_SD_CUSTOMANIMATIONDIALOG_MOTIONPATH );
560 mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_MOTIONPATH, mpTabPages[MOTIONPATH] );
561 mpTabPages[MISCEFFECTS] = new CustomAnimationCreateTabPage( mpTabControl, this, MISCEFFECTS, rPresets.getMiscPresets(), bHasText );
562 mpTabPages[MISCEFFECTS]->SetHelpId( HID_SD_CUSTOMANIMATIONDIALOG_MISCEFFECTS );
563 mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_MISCEFFECTS, mpTabPages[MISCEFFECTS] );
565 getCurrentPage()->setDuration( mfDuration );
566 getCurrentPage()->setIsPreview( mbIsPreview );
568 mpTabControl->SetActivatePageHdl( LINK( this, CustomAnimationCreateDialog, implActivatePagekHdl ) );
569 mpTabControl->SetDeactivatePageHdl( LINK( this, CustomAnimationCreateDialog, implDeactivatePagekHdl ) );
571 setPosition();
573 // select current preset if available
574 if( rsPresetId.getLength() != 0 )
576 for( sal_uInt16 i = ENTRANCE; i <= MOTIONPATH; i++ )
578 if( mpTabPages[i]->select( rsPresetId ) )
580 mpTabControl->SetCurPageId( RID_TP_CUSTOMANIMATION_ENTRANCE + i );
581 break;
587 CustomAnimationCreateDialog::~CustomAnimationCreateDialog()
589 storePosition();
591 SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
592 pOptions->SetPreviewNewEffects( getCurrentPage()->getIsPreview() );
594 delete mpTabPages[ENTRANCE];
595 delete mpTabPages[EMPHASIS];
596 delete mpTabPages[EXIT];
597 delete mpTabPages[MOTIONPATH];
598 delete mpTabPages[MISCEFFECTS];
600 delete mpTabControl;
601 delete mpOKButton;
602 delete mpCancelButton;
603 delete mpHelpButton;
606 CustomAnimationCreateTabPage* CustomAnimationCreateDialog::getCurrentPage() const
608 switch( mpTabControl->GetCurPageId() )
610 case RID_TP_CUSTOMANIMATION_ENTRANCE: return mpTabPages[ENTRANCE];
611 case RID_TP_CUSTOMANIMATION_EMPHASIS: return mpTabPages[EMPHASIS];
612 case RID_TP_CUSTOMANIMATION_EXIT: return mpTabPages[EXIT];
613 case RID_TP_CUSTOMANIMATION_MISCEFFECTS:return mpTabPages[MISCEFFECTS];
614 //case RID_TP_CUSTOMANIMATION_MOTIONPATH:
615 default:
616 return mpTabPages[MOTIONPATH];
620 PathKind CustomAnimationCreateDialog::getCreatePathKind() const
622 return getCurrentPage()->getCreatePathKind();
625 CustomAnimationPresetPtr CustomAnimationCreateDialog::getSelectedPreset() const
627 return getCurrentPage()->getSelectedPreset();
630 double CustomAnimationCreateDialog::getSelectedDuration() const
632 return getCurrentPage()->getDuration();
635 IMPL_LINK( CustomAnimationCreateDialog, implActivatePagekHdl, Control*, EMPTYARG )
637 getCurrentPage()->setDuration( mfDuration );
638 getCurrentPage()->setIsPreview( mbIsPreview );
639 return 1;
642 IMPL_LINK( CustomAnimationCreateDialog, implDeactivatePagekHdl, Control*, EMPTYARG )
644 mfDuration = getCurrentPage()->getDuration();
645 mbIsPreview = getCurrentPage()->getIsPreview();
646 return 1;
649 void CustomAnimationCreateDialog::preview( const CustomAnimationPresetPtr& pPreset ) const
651 MainSequencePtr pSequence( new MainSequence() );
653 std::vector< Any >::const_iterator aIter( mrTargets.begin() );
654 const std::vector< Any >::const_iterator aEnd( mrTargets.end() );
656 const double fDuration = getSelectedDuration();
658 bool bFirst = true;
659 while( aIter != aEnd )
661 CustomAnimationEffectPtr pNew(
662 pSequence->append( pPreset, (*aIter++), fDuration ) );
664 if( bFirst )
665 bFirst = false;
666 else
667 pNew->setNodeType( EffectNodeType::WITH_PREVIOUS );
670 mpPane->preview( pSequence->getRootNode() );
673 namespace
675 Window * lcl_GetTopmostParent( Window * pWindow )
677 Window * pResult = 0;
678 Window * pCurrent = pWindow ? pWindow->GetParent() : 0;
679 while( pCurrent )
681 pResult = pCurrent;
682 pCurrent = pCurrent->GetParent();
684 return pResult;
688 void CustomAnimationCreateDialog::setPosition()
690 SvtViewOptions aDlgOpt(
691 E_TABDIALOG, String::CreateFromInt32( DLG_CUSTOMANIMATION_CREATE ) );
692 if ( aDlgOpt.Exists() )
694 SetWindowState( ByteString( aDlgOpt.GetWindowState().getStr(),
695 RTL_TEXTENCODING_ASCII_US ) );
697 else
699 // default position: aligned with right edge of parent
700 Window * pParent = lcl_GetTopmostParent( this );
701 if( pParent )
703 Point aPos( GetPosPixel());
704 Size aSize( GetSizePixel());
705 Point aParentPos( pParent->GetPosPixel());
706 Size aParentSize( pParent->GetSizePixel());
708 // right center
709 aPos.setX( aParentSize.getWidth() - aSize.getWidth() );
710 aPos.setY( (aParentSize.getHeight() - aSize.getHeight()) / 2 );
711 SetPosPixel( aPos );
716 void CustomAnimationCreateDialog::storePosition()
718 // save settings (screen position and current page)
719 SvtViewOptions aDlgOpt(
720 E_TABDIALOG, String::CreateFromInt32( DLG_CUSTOMANIMATION_CREATE ) );
721 aDlgOpt.SetWindowState(
722 OUString::createFromAscii( GetWindowState( WINDOWSTATE_MASK_POS ).GetBuffer() ) );