Update ooo320-m1
[ooovba.git] / sd / source / ui / animations / CustomAnimationDialog.cxx
blob2f4ba4f6fba4f69736089c8d55a394d049a814d1
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: CustomAnimationDialog.cxx,v $
10 * $Revision: 1.22 $
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/EffectNodeType.hpp>
34 #include <com/sun/star/animations/Timing.hpp>
35 #include <com/sun/star/animations/Event.hpp>
36 #include <com/sun/star/animations/EventTrigger.hpp>
37 #include <com/sun/star/animations/AnimationFill.hpp>
38 #include <com/sun/star/presentation/TextAnimationType.hpp>
39 #include <com/sun/star/animations/ValuePair.hpp>
40 #include <com/sun/star/awt/FontSlant.hpp>
41 #include <com/sun/star/awt/FontWeight.hpp>
42 #include <com/sun/star/awt/FontUnderline.hpp>
43 #include <com/sun/star/drawing/XDrawPage.hpp>
44 #include <com/sun/star/beans/XPropertySet.hpp>
45 #include <com/sun/star/media/XManager.hpp>
46 #include <com/sun/star/media/XPlayer.hpp>
48 #ifndef BOOST_SHARED_PTR_HPP_INCLUDED
49 #include <boost/shared_ptr.hpp>
50 #endif
52 #ifndef _UNOTOOLS_PROCESSFACTORY_HXX
53 #include <comphelper/processfactory.hxx>
54 #endif
55 #include <svtools/pathoptions.hxx>
56 #include <vcl/tabctrl.hxx>
57 #include <vcl/tabpage.hxx>
58 #include <vcl/menubtn.hxx>
59 #include <vcl/svapp.hxx>
60 #include <vcl/fixed.hxx>
61 #include <vcl/lstbox.hxx>
62 #include <vcl/field.hxx>
63 #include <vcl/msgbox.hxx>
64 #include <vcl/decoview.hxx>
65 #include <vcl/combobox.hxx>
66 #include <vcl/menu.hxx>
67 #include <svtools/ctrlbox.hxx>
68 #include <svtools/ctrltool.hxx>
69 #include <sfx2/objsh.hxx>
71 #ifndef _SVX_SVXIDS_HRC
72 #include <svx/svxids.hrc>
73 #endif
74 #include <svx/dialmgr.hxx>
75 #include <svx/flstitem.hxx>
76 #include <svx/drawitem.hxx>
78 #include <svx/xtable.hxx>
79 #include <svx/gallery.hxx>
81 #ifndef _SVX_DIALOGS_HRC
82 #include <svx/dialogs.hrc>
83 #endif
84 #include "sdresid.hxx"
86 #include "glob.hrc"
87 #include "CustomAnimationDialog.hxx"
88 #ifndef _SD_CUSTOMANIMATIONDIALOG_HRC
89 #include "CustomAnimationDialog.hrc"
90 #endif
91 #ifndef _SD_CUSTOMANIMATION_HRC
92 #include "CustomAnimation.hrc"
93 #endif
94 #include "STLPropertySet.hxx"
96 #include <avmedia/mediawindow.hxx>
98 #include "filedlg.hxx"
99 #include "strings.hrc"
100 #include "helpids.h"
102 using namespace ::com::sun::star;
103 using namespace ::com::sun::star::animations;
104 using namespace ::com::sun::star::presentation;
106 using ::rtl::OUString;
107 using ::com::sun::star::uno::UNO_QUERY;
108 using ::com::sun::star::uno::UNO_QUERY_THROW;
109 using ::com::sun::star::uno::Any;
110 using ::com::sun::star::uno::makeAny;
111 using ::com::sun::star::uno::Sequence;
112 using ::com::sun::star::uno::Reference;
113 using ::com::sun::star::uno::Exception;
114 using ::com::sun::star::drawing::XShape;
115 using ::com::sun::star::drawing::XDrawPage;
116 using ::com::sun::star::beans::XPropertySet;
118 namespace sd {
120 extern void fillRepeatComboBox( ComboBox* pBox );
121 extern void fillDurationComboBox( ComboBox* pBox );
122 extern OUString getShapeDescription( const Reference< XShape >& xShape, bool bWithText = true );
123 extern OUString getPropertyName( sal_Int32 nPropertyType );
125 // ====================================================================
127 class PresetPropertyBox : public PropertySubControl
129 public:
130 PresetPropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const OUString& aPresetId, const Link& rModifyHdl );
131 ~PresetPropertyBox();
133 virtual Any getValue();
134 virtual void setValue( const Any& rValue, const OUString& rPresetId );
135 virtual Control* getControl();
137 private:
138 std::map< USHORT, rtl::OUString > maPropertyValues;
139 ListBox* mpControl;
142 // --------------------------------------------------------------------
144 PresetPropertyBox::PresetPropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const OUString& aPresetId, const Link& rModifyHdl )
145 : PropertySubControl( nControlType )
147 mpControl = new ListBox( pParent, WB_BORDER|WB_TABSTOP|WB_DROPDOWN );
148 mpControl->SetDropDownLineCount( 10 );
149 mpControl->SetSelectHdl( rModifyHdl );
150 mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_PRESETPROPERTYBOX );
152 setValue( rValue, aPresetId );
156 void PresetPropertyBox::setValue( const Any& rValue, const OUString& rPresetId )
158 if( mpControl )
160 mpControl->Clear();
162 const CustomAnimationPresets& rPresets = CustomAnimationPresets::getCustomAnimationPresets();
163 CustomAnimationPresetPtr pDescriptor = rPresets.getEffectDescriptor( rPresetId );
164 if( pDescriptor.get() )
167 OUString aPropertyValue;
168 rValue >>= aPropertyValue;
170 UStringList aSubTypes( pDescriptor->getSubTypes() );
171 UStringList::iterator aIter( aSubTypes.begin() );
172 const UStringList::iterator aEnd( aSubTypes.end() );
174 mpControl->Enable( aIter != aEnd );
176 while( aIter != aEnd )
178 USHORT nPos = mpControl->InsertEntry( rPresets.getUINameForProperty( (*aIter) ) );
179 if( (*aIter) == aPropertyValue )
180 mpControl->SelectEntryPos( nPos );
181 maPropertyValues[nPos] = (*aIter++);
184 else
186 mpControl->Enable( FALSE );
191 // --------------------------------------------------------------------
193 PresetPropertyBox::~PresetPropertyBox()
195 delete mpControl;
198 // --------------------------------------------------------------------
200 Any PresetPropertyBox::getValue()
202 return makeAny( maPropertyValues[mpControl->GetSelectEntryPos()] );
205 // --------------------------------------------------------------------
207 Control* PresetPropertyBox::getControl()
209 return mpControl;
212 // ====================================================================
214 class ColorPropertyBox : public PropertySubControl
216 public:
217 ColorPropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl );
218 ~ColorPropertyBox();
220 virtual Any getValue();
221 virtual void setValue( const Any& rValue, const OUString& rPresetId );
222 virtual Control* getControl();
224 private:
225 ColorListBox* mpControl;
228 // --------------------------------------------------------------------
230 ColorPropertyBox::ColorPropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl )
231 : PropertySubControl( nControlType )
233 mpControl = new ColorListBox( pParent, WB_BORDER|WB_TABSTOP|WB_DROPDOWN );
234 mpControl->SetDropDownLineCount( 10 );
235 mpControl->SetSelectHdl( rModifyHdl );
236 mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_COLORPROPERTYBOX );
238 SfxObjectShell* pDocSh = SfxObjectShell::Current();
239 DBG_ASSERT( pDocSh, "DocShell not found!" );
240 XColorTable* pColorTable = NULL;
241 bool bKillTable = false;
242 const SfxPoolItem* pItem = NULL;
244 if ( pDocSh && ( ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) != 0) )
245 pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable();
247 if ( !pColorTable )
249 pColorTable = new XColorTable( SvtPathOptions().GetPalettePath() );
250 bKillTable = TRUE;
253 sal_Int32 nColor = 0;
254 rValue >>= nColor;
256 for ( long i = 0; i < pColorTable->Count(); i++ )
258 XColorEntry* pEntry = pColorTable->GetColor(i);
259 USHORT nPos = mpControl->InsertEntry( pEntry->GetColor(), pEntry->GetName() );
260 if( pEntry->GetColor().GetRGBColor() == (sal_uInt32)nColor )
261 mpControl->SelectEntryPos( nPos );
264 if ( bKillTable )
265 delete pColorTable;
268 // --------------------------------------------------------------------
270 ColorPropertyBox::~ColorPropertyBox()
272 delete mpControl;
275 // --------------------------------------------------------------------
277 void ColorPropertyBox::setValue( const Any& rValue, const OUString& )
279 if( mpControl )
281 sal_Int32 nColor = 0;
282 rValue >>= nColor;
284 mpControl->SetNoSelection();
285 mpControl->SelectEntryPos( mpControl->GetEntryPos( (Color)nColor ) );
289 // --------------------------------------------------------------------
291 Any ColorPropertyBox::getValue()
293 return makeAny( (sal_Int32)mpControl->GetSelectEntryColor().GetRGBColor() );
296 // --------------------------------------------------------------------
298 Control* ColorPropertyBox::getControl()
300 return mpControl;
303 // ====================================================================
305 class FontPropertyBox : public PropertySubControl
307 public:
308 FontPropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl );
309 virtual ~FontPropertyBox();
311 virtual Any getValue();
312 virtual void setValue( const Any& rValue, const OUString& rPresetId );
314 virtual Control* getControl();
316 private:
317 FontNameBox* mpControl;
320 // --------------------------------------------------------------------
322 FontPropertyBox::FontPropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl )
323 : PropertySubControl( nControlType )
325 mpControl = new FontNameBox( pParent, WB_BORDER|WB_TABSTOP|WB_DROPDOWN );
326 mpControl->SetDropDownLineCount( 10 );
327 mpControl->SetSelectHdl( rModifyHdl );
328 mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_FONTPROPERTYBOX );
330 SfxObjectShell* pDocSh = SfxObjectShell::Current();
331 const SfxPoolItem* pItem;
333 const FontList* pFontList = 0;
334 bool bMustDelete = false;
336 if ( pDocSh && ( (pItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST ) ) != 0) )
337 pFontList = ( (SvxFontListItem*)pItem )->GetFontList();
339 if(!pFontList)
341 pFontList = new FontList( Application::GetDefaultDevice(), NULL, FALSE );
342 bMustDelete = true;
345 mpControl->Fill( pFontList );
347 if( bMustDelete )
348 delete pFontList;
350 OUString aPresetId;
351 setValue( rValue, aPresetId );
354 // --------------------------------------------------------------------
356 void FontPropertyBox::setValue( const Any& rValue, const OUString& )
358 if( mpControl )
360 OUString aFontName;
361 rValue >>= aFontName;
362 mpControl->SetText( aFontName );
366 // --------------------------------------------------------------------
368 FontPropertyBox::~FontPropertyBox()
370 delete mpControl;
373 // --------------------------------------------------------------------
375 Any FontPropertyBox::getValue()
377 OUString aFontName( mpControl->GetText() );
378 return makeAny( aFontName );
381 // --------------------------------------------------------------------
383 Control* FontPropertyBox::getControl()
385 return mpControl;
388 // ====================================================================
390 class DropdownMenuBox : public Edit
392 public:
393 DropdownMenuBox( Window* pParent, Edit* pSubControl, PopupMenu* pMenu );
394 ~DropdownMenuBox();
396 void Resize();
397 long PreNotify( NotifyEvent& rNEvt );
399 void SetMenuSelectHdl( const Link& rLink ) { mpDropdownButton->SetSelectHdl( rLink ); }
401 private:
402 Edit* mpSubControl;
403 MenuButton* mpDropdownButton;
404 PopupMenu* mpMenu;
407 // --------------------------------------------------------------------
409 DropdownMenuBox::DropdownMenuBox( Window* pParent, Edit* pSubControl, PopupMenu* pMenu )
410 : Edit( pParent, WB_BORDER|WB_TABSTOP| WB_DIALOGCONTROL ),
411 mpSubControl(pSubControl),mpDropdownButton(0),mpMenu(pMenu)
413 mpDropdownButton = new MenuButton( this, WB_NOLIGHTBORDER | WB_RECTSTYLE | WB_NOTABSTOP);
414 mpDropdownButton->SetSymbol(SYMBOL_SPIN_DOWN);
415 mpDropdownButton->Show();
416 mpDropdownButton->SetPopupMenu( pMenu );
418 SetSubEdit( mpSubControl );
419 mpSubControl->SetParent( this );
420 mpSubControl->Show();
423 // --------------------------------------------------------------------
425 DropdownMenuBox::~DropdownMenuBox()
427 SetSubEdit( 0 );
428 delete mpSubControl;
429 delete mpDropdownButton;
430 delete mpMenu;
433 // --------------------------------------------------------------------
435 void DropdownMenuBox::Resize()
437 Size aOutSz = GetOutputSizePixel();
439 long nSBWidth = GetSettings().GetStyleSettings().GetScrollBarSize();
440 nSBWidth = CalcZoom( nSBWidth );
441 mpSubControl->SetPosSizePixel( 0, 1, aOutSz.Width() - nSBWidth, aOutSz.Height()-2 );
442 mpDropdownButton->SetPosSizePixel( aOutSz.Width() - nSBWidth, 0, nSBWidth, aOutSz.Height() );
445 // --------------------------------------------------------------------
447 long DropdownMenuBox::PreNotify( NotifyEvent& rNEvt )
449 long nResult=sal_True;
451 sal_uInt16 nSwitch=rNEvt.GetType();
452 if (nSwitch==EVENT_KEYINPUT)
454 const KeyCode& aKeyCode=rNEvt.GetKeyEvent()->GetKeyCode();
455 sal_uInt16 nKey=aKeyCode.GetCode();
457 if (nKey==KEY_DOWN && aKeyCode.IsMod2())
459 mpDropdownButton->KeyInput( *rNEvt.GetKeyEvent() );
461 else
463 nResult=Edit::PreNotify(rNEvt);
466 else
467 nResult=Edit::PreNotify(rNEvt);
469 return nResult;
472 // --------------------------------------------------------------------
474 class CharHeightPropertyBox : public PropertySubControl
476 public:
477 CharHeightPropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl );
478 virtual ~CharHeightPropertyBox();
480 virtual Any getValue();
481 virtual void setValue( const Any& rValue, const OUString& );
483 virtual Control* getControl();
485 DECL_LINK( implMenuSelectHdl, MenuButton* );
487 private:
488 DropdownMenuBox* mpControl;
489 PopupMenu* mpMenu;
490 MetricField* mpMetric;
493 // --------------------------------------------------------------------
495 CharHeightPropertyBox::CharHeightPropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl )
496 : PropertySubControl( nControlType )
498 mpMetric = new MetricField( pParent, WB_TABSTOP|WB_IGNORETAB| WB_NOBORDER);
499 mpMetric->SetUnit( FUNIT_PERCENT );
500 mpMetric->SetMin( 0 );
501 mpMetric->SetMax( 1000 );
503 mpMenu = new PopupMenu(SdResId( RID_CUSTOMANIMATION_FONTSIZE_POPUP ) );
504 mpControl = new DropdownMenuBox( pParent, mpMetric, mpMenu );
505 mpControl->SetMenuSelectHdl( LINK( this, CharHeightPropertyBox, implMenuSelectHdl ));
506 mpControl->SetModifyHdl( rModifyHdl );
507 mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_CHARHEIGHTPROPERTYBOX );
509 OUString aPresetId;
510 setValue( rValue, aPresetId );
513 // --------------------------------------------------------------------
515 CharHeightPropertyBox::~CharHeightPropertyBox()
517 delete mpControl;
520 // --------------------------------------------------------------------
522 IMPL_LINK( CharHeightPropertyBox, implMenuSelectHdl, MenuButton*, pPb )
524 long nValue = 100;
525 switch( pPb->GetCurItemId() )
527 case CM_SIZE_25: nValue = 25; break;
528 case CM_SIZE_50: nValue = 50; break;
529 case CM_SIZE_150: nValue = 150; break;
530 case CM_SIZE_400: nValue = 400; break;
532 mpMetric->SetValue( nValue );
533 mpMetric->Modify();
534 return 0;
537 // --------------------------------------------------------------------
539 void CharHeightPropertyBox::setValue( const Any& rValue, const OUString& )
541 if( mpMetric )
543 double fValue = 0.0;
544 rValue >>= fValue;
545 mpMetric->SetValue( (long)(fValue * 100.0) );
549 // --------------------------------------------------------------------
551 Any CharHeightPropertyBox::getValue()
553 return makeAny( (double)((double)mpMetric->GetValue() / 100.0) );
556 // --------------------------------------------------------------------
558 Control* CharHeightPropertyBox::getControl()
560 return mpControl;
563 // ====================================================================
565 class TransparencyPropertyBox : public PropertySubControl
567 public:
568 TransparencyPropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl );
569 ~TransparencyPropertyBox();
571 virtual Any getValue();
572 virtual void setValue( const Any& rValue, const OUString& rPresetId );
574 virtual Control* getControl();
576 DECL_LINK( implMenuSelectHdl, MenuButton* );
577 DECL_LINK( implModifyHdl, Control* );
579 void updateMenu();
581 private:
582 DropdownMenuBox* mpControl;
583 PopupMenu* mpMenu;
584 MetricField* mpMetric;
585 Link maModifyHdl;
588 // --------------------------------------------------------------------
590 TransparencyPropertyBox::TransparencyPropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl )
591 : PropertySubControl( nControlType )
592 , maModifyHdl( rModifyHdl )
594 mpMetric = new MetricField( pParent ,WB_TABSTOP|WB_IGNORETAB| WB_NOBORDER);
595 mpMetric->SetUnit( FUNIT_PERCENT );
596 mpMetric->SetMin( 0 );
597 mpMetric->SetMax( 100 );
599 mpMenu = new PopupMenu();
600 for( USHORT i = 25; i < 101; i += 25 )
602 String aStr( String::CreateFromInt32( i ) );
603 aStr += sal_Unicode('%');
604 mpMenu->InsertItem( i, aStr );
607 mpControl = new DropdownMenuBox( pParent, mpMetric, mpMenu );
608 mpControl->SetMenuSelectHdl( LINK( this, TransparencyPropertyBox, implMenuSelectHdl ));
609 mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_TRANSPARENCYPROPERTYBOX );
611 Link aLink( LINK( this, TransparencyPropertyBox, implModifyHdl ) );
612 mpControl->SetModifyHdl( aLink );
614 OUString aPresetId;
615 setValue( rValue, aPresetId );
618 // --------------------------------------------------------------------
620 TransparencyPropertyBox::~TransparencyPropertyBox()
622 delete mpControl;
625 // --------------------------------------------------------------------
627 void TransparencyPropertyBox::updateMenu()
629 sal_Int64 nValue = mpMetric->GetValue();
630 for( USHORT i = 25; i < 101; i += 25 )
631 mpMenu->CheckItem( i, nValue == i );
634 // --------------------------------------------------------------------
636 IMPL_LINK( TransparencyPropertyBox, implModifyHdl, Control*, EMPTYARG )
638 updateMenu();
639 maModifyHdl.Call(mpMetric);
641 return 0;
644 // --------------------------------------------------------------------
646 IMPL_LINK( TransparencyPropertyBox, implMenuSelectHdl, MenuButton*, pPb )
648 if( pPb->GetCurItemId() != mpMetric->GetValue() )
650 mpMetric->SetValue( pPb->GetCurItemId() );
651 mpMetric->Modify();
654 return 0;
657 // --------------------------------------------------------------------
659 void TransparencyPropertyBox::setValue( const Any& rValue, const OUString& )
661 if( mpMetric )
663 double fValue = 0.0;
664 rValue >>= fValue;
665 long nValue = (long)(fValue * 100);
666 mpMetric->SetValue( nValue );
667 updateMenu();
671 // --------------------------------------------------------------------
673 Any TransparencyPropertyBox::getValue()
675 return makeAny( (double)((double)mpMetric->GetValue()) / 100.0 );
678 // --------------------------------------------------------------------
680 Control* TransparencyPropertyBox::getControl()
682 return mpControl;
685 // --------------------------------------------------------------------
687 class RotationPropertyBox : public PropertySubControl
689 public:
690 RotationPropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl );
691 ~RotationPropertyBox();
693 virtual Any getValue();
694 virtual void setValue( const Any& rValue, const OUString& );
696 virtual Control* getControl();
698 DECL_LINK( implMenuSelectHdl, MenuButton* );
699 DECL_LINK( implModifyHdl, Control* );
701 void updateMenu();
703 private:
704 DropdownMenuBox* mpControl;
705 PopupMenu* mpMenu;
706 MetricField* mpMetric;
707 Link maModifyHdl;
710 // --------------------------------------------------------------------
712 RotationPropertyBox::RotationPropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl )
713 : PropertySubControl( nControlType )
714 , maModifyHdl( rModifyHdl )
716 mpMetric = new MetricField( pParent ,WB_TABSTOP|WB_IGNORETAB| WB_NOBORDER);
717 mpMetric->SetUnit( FUNIT_CUSTOM );
718 mpMetric->SetCustomUnitText( OUString( sal_Unicode(0xb0)) ); // degree sign
719 mpMetric->SetMin( -10000 );
720 mpMetric->SetMax( 10000 );
722 mpMenu = new PopupMenu(SdResId( RID_CUSTOMANIMATION_ROTATION_POPUP ) );
723 mpControl = new DropdownMenuBox( pParent, mpMetric, mpMenu );
724 mpControl->SetMenuSelectHdl( LINK( this, RotationPropertyBox, implMenuSelectHdl ));
725 mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_ROTATIONPROPERTYBOX );
727 Link aLink( LINK( this, RotationPropertyBox, implModifyHdl ) );
728 mpControl->SetModifyHdl( aLink );
730 OUString aPresetId;
731 setValue( rValue, aPresetId );
734 // --------------------------------------------------------------------
736 RotationPropertyBox::~RotationPropertyBox()
738 delete mpControl;
741 // --------------------------------------------------------------------
743 void RotationPropertyBox::updateMenu()
745 sal_Int64 nValue = mpMetric->GetValue();
746 bool bDirection = nValue >= 0;
747 nValue = (nValue < 0 ? -nValue : nValue);
749 mpMenu->CheckItem( CM_QUARTER_SPIN, nValue == 90 );
750 mpMenu->CheckItem( CM_HALF_SPIN, nValue == 180 );
751 mpMenu->CheckItem( CM_FULL_SPIN, nValue == 360 );
752 mpMenu->CheckItem( CM_TWO_SPINS, nValue == 720 );
754 mpMenu->CheckItem( CM_CLOCKWISE, bDirection );
755 mpMenu->CheckItem( CM_COUNTERCLOCKWISE, !bDirection );
758 // --------------------------------------------------------------------
760 IMPL_LINK( RotationPropertyBox, implModifyHdl, Control*, EMPTYARG )
762 updateMenu();
763 maModifyHdl.Call(mpMetric);
765 return 0;
768 IMPL_LINK( RotationPropertyBox, implMenuSelectHdl, MenuButton*, pPb )
770 sal_Int64 nValue = mpMetric->GetValue();
771 bool bDirection = nValue >= 0;
772 nValue = (nValue < 0 ? -nValue : nValue);
774 switch( pPb->GetCurItemId() )
776 case CM_QUARTER_SPIN: nValue = 90; break;
777 case CM_HALF_SPIN: nValue = 180; break;
778 case CM_FULL_SPIN: nValue = 360; break;
779 case CM_TWO_SPINS: nValue = 720; break;
781 case CM_CLOCKWISE: bDirection = true; break;
782 case CM_COUNTERCLOCKWISE: bDirection = false; break;
786 if( !bDirection )
787 nValue = -nValue;
789 if( nValue != mpMetric->GetValue() )
791 mpMetric->SetValue( nValue );
792 mpMetric->Modify();
795 return 0;
798 // --------------------------------------------------------------------
800 void RotationPropertyBox::setValue( const Any& rValue, const OUString& )
802 if( mpMetric )
804 double fValue = 0.0;
805 rValue >>= fValue;
806 long nValue = (long)(fValue);
807 mpMetric->SetValue( nValue );
808 updateMenu();
812 // --------------------------------------------------------------------
814 Any RotationPropertyBox::getValue()
816 return makeAny( (double)((double)mpMetric->GetValue()) );
819 // --------------------------------------------------------------------
821 Control* RotationPropertyBox::getControl()
823 return mpControl;
826 // --------------------------------------------------------------------
828 class ScalePropertyBox : public PropertySubControl
830 public:
831 ScalePropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl );
832 ~ScalePropertyBox();
834 virtual Any getValue();
835 virtual void setValue( const Any& rValue, const OUString& );
837 virtual Control* getControl();
839 DECL_LINK( implMenuSelectHdl, MenuButton* );
840 DECL_LINK( implModifyHdl, Control* );
842 void updateMenu();
844 private:
845 DropdownMenuBox* mpControl;
846 PopupMenu* mpMenu;
847 MetricField* mpMetric;
848 Link maModifyHdl;
849 int mnDirection;
852 // --------------------------------------------------------------------
854 ScalePropertyBox::ScalePropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl )
855 : PropertySubControl( nControlType )
856 , maModifyHdl( rModifyHdl )
858 mpMetric = new MetricField( pParent ,WB_TABSTOP|WB_IGNORETAB| WB_NOBORDER);
859 mpMetric->SetUnit( FUNIT_PERCENT );
860 mpMetric->SetMin( 0 );
861 mpMetric->SetMax( 10000 );
863 mpMenu = new PopupMenu(SdResId( RID_CUSTOMANIMATION_SCALE_POPUP ) );
864 mpControl = new DropdownMenuBox( pParent, mpMetric, mpMenu );
865 mpControl->SetMenuSelectHdl( LINK( this, ScalePropertyBox, implMenuSelectHdl ));
866 mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_SCALEPROPERTYBOX );
868 Link aLink( LINK( this, ScalePropertyBox, implModifyHdl ) );
869 mpControl->SetModifyHdl( aLink );
871 OUString aPresetId;
872 setValue( rValue, aPresetId );
875 // --------------------------------------------------------------------
877 ScalePropertyBox::~ScalePropertyBox()
879 delete mpControl;
882 // --------------------------------------------------------------------
884 void ScalePropertyBox::updateMenu()
886 sal_Int64 nValue = mpMetric->GetValue();
888 mpMenu->CheckItem( 25, nValue == 25 );
889 mpMenu->CheckItem( 50, nValue == 50 );
890 mpMenu->CheckItem( 150, nValue == 150 );
891 mpMenu->CheckItem( 400, nValue == 400 );
893 mpMenu->CheckItem( CM_HORIZONTAL, mnDirection == 1 );
894 mpMenu->CheckItem( CM_VERTICAL, mnDirection == 2 );
895 mpMenu->CheckItem( CM_BOTH, mnDirection == 3 );
898 // --------------------------------------------------------------------
900 IMPL_LINK( ScalePropertyBox, implModifyHdl, Control*, EMPTYARG )
902 updateMenu();
903 maModifyHdl.Call(mpMetric);
905 return 0;
908 IMPL_LINK( ScalePropertyBox, implMenuSelectHdl, MenuButton*, pPb )
910 sal_Int64 nValue = mpMetric->GetValue();
912 int nDirection = mnDirection;
914 switch( pPb->GetCurItemId() )
916 case CM_HORIZONTAL: nDirection = 1; break;
917 case CM_VERTICAL: nDirection = 2; break;
918 case CM_BOTH: nDirection = 3; break;
920 default:
921 nValue = pPb->GetCurItemId();
924 bool bModified = false;
926 if( nDirection != mnDirection )
928 mnDirection = nDirection;
929 bModified = true;
932 if( nValue != mpMetric->GetValue() )
934 mpMetric->SetValue( nValue );
935 bModified = true;
938 if( bModified )
940 mpMetric->Modify();
941 updateMenu();
944 return 0;
947 // --------------------------------------------------------------------
949 void ScalePropertyBox::setValue( const Any& rValue, const OUString& )
951 if( mpMetric )
953 ValuePair aValues;
954 rValue >>= aValues;
956 double fValue1 = 0.0;
957 double fValue2 = 0.0;
959 aValues.First >>= fValue1;
960 aValues.Second >>= fValue2;
962 if( fValue2 == 0.0 )
963 mnDirection = 1;
964 else if( fValue1 == 0.0 )
965 mnDirection = 2;
966 else
967 mnDirection = 3;
969 long nValue;
970 if( fValue1 )
971 nValue = (long)(fValue1 * 100.0);
972 else
973 nValue = (long)(fValue2 * 100.0);
974 mpMetric->SetValue( nValue );
975 updateMenu();
979 // --------------------------------------------------------------------
981 Any ScalePropertyBox::getValue()
983 double fValue1 = (double)((double)mpMetric->GetValue() / 100.0);
984 double fValue2 = fValue1;
986 if( mnDirection == 1 )
987 fValue2 = 0.0;
988 else if( mnDirection == 2 )
989 fValue1 = 0.0;
991 ValuePair aValues;
992 aValues.First <<= fValue1;
993 aValues.Second <<= fValue2;
995 return makeAny( aValues );
998 // --------------------------------------------------------------------
1000 Control* ScalePropertyBox::getControl()
1002 return mpControl;
1005 // ====================================================================
1007 class FontStylePropertyBox : public PropertySubControl
1009 public:
1010 FontStylePropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl );
1011 ~FontStylePropertyBox();
1013 virtual Any getValue();
1014 virtual void setValue( const Any& rValue, const OUString& );
1016 virtual Control* getControl();
1018 DECL_LINK( implMenuSelectHdl, MenuButton* );
1020 void update();
1022 private:
1023 DropdownMenuBox* mpControl;
1024 PopupMenu* mpMenu;
1025 Edit* mpEdit;
1026 Link maModifyHdl;
1028 float mfFontWeight;
1029 awt::FontSlant meFontSlant;
1030 sal_Int16 mnFontUnderline;
1033 // --------------------------------------------------------------------
1035 FontStylePropertyBox::FontStylePropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl )
1036 : PropertySubControl( nControlType )
1037 , maModifyHdl( rModifyHdl )
1039 mpEdit = new Edit( pParent, WB_TABSTOP|WB_IGNORETAB|WB_NOBORDER|WB_READONLY);
1040 mpEdit->SetText( String( SdResId( STR_CUSTOMANIMATION_SAMPLE ) ) );
1042 mpMenu = new PopupMenu(SdResId( RID_CUSTOMANIMATION_FONTSTYLE_POPUP ) );
1043 mpControl = new DropdownMenuBox( pParent, mpEdit, mpMenu );
1044 mpControl->SetMenuSelectHdl( LINK( this, FontStylePropertyBox, implMenuSelectHdl ));
1045 mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_FONTSTYLEPROPERTYBOX );
1047 OUString aPresetId;
1048 setValue( rValue, aPresetId );
1051 // --------------------------------------------------------------------
1053 FontStylePropertyBox::~FontStylePropertyBox()
1055 delete mpControl;
1058 // --------------------------------------------------------------------
1060 void FontStylePropertyBox::update()
1062 // update menu
1063 mpMenu->CheckItem( CM_BOLD, mfFontWeight == awt::FontWeight::BOLD );
1064 mpMenu->CheckItem( CM_ITALIC, meFontSlant == awt::FontSlant_ITALIC);
1065 mpMenu->CheckItem( CM_UNDERLINED, mnFontUnderline != awt::FontUnderline::NONE );
1067 // update sample edit
1068 Font aFont( mpEdit->GetFont() );
1069 aFont.SetWeight( mfFontWeight == awt::FontWeight::BOLD ? WEIGHT_BOLD : WEIGHT_NORMAL );
1070 aFont.SetItalic( meFontSlant == awt::FontSlant_ITALIC ? ITALIC_NORMAL : ITALIC_NONE );
1071 aFont.SetUnderline( mnFontUnderline == awt::FontUnderline::NONE ? UNDERLINE_NONE : UNDERLINE_SINGLE );
1072 mpEdit->SetFont( aFont );
1073 mpEdit->Invalidate();
1076 // --------------------------------------------------------------------
1078 IMPL_LINK( FontStylePropertyBox, implMenuSelectHdl, MenuButton*, pPb )
1080 switch( pPb->GetCurItemId() )
1082 case CM_BOLD:
1083 if( mfFontWeight == awt::FontWeight::BOLD )
1084 mfFontWeight = awt::FontWeight::NORMAL;
1085 else
1086 mfFontWeight = awt::FontWeight::BOLD;
1087 break;
1088 case CM_ITALIC:
1089 if( meFontSlant == awt::FontSlant_ITALIC )
1090 meFontSlant = awt::FontSlant_NONE;
1091 else
1092 meFontSlant = awt::FontSlant_ITALIC;
1093 break;
1094 case CM_UNDERLINED:
1095 if( mnFontUnderline == awt::FontUnderline::SINGLE )
1096 mnFontUnderline = awt::FontUnderline::NONE;
1097 else
1098 mnFontUnderline = awt::FontUnderline::SINGLE;
1099 break;
1100 default:
1101 return 0;
1104 update();
1105 maModifyHdl.Call(mpEdit);
1107 return 0;
1110 // --------------------------------------------------------------------
1112 void FontStylePropertyBox::setValue( const Any& rValue, const OUString& )
1114 Sequence<Any> aValues;
1115 rValue >>= aValues;
1117 aValues[0] >>= mfFontWeight;
1118 aValues[1] >>= meFontSlant;
1119 aValues[2] >>= mnFontUnderline;
1121 update();
1124 // --------------------------------------------------------------------
1126 Any FontStylePropertyBox::getValue()
1128 Sequence<Any> aValues(3);
1129 aValues[0] <<= mfFontWeight;
1130 aValues[1] <<= meFontSlant;
1131 aValues[2] <<= mnFontUnderline;
1132 return makeAny( aValues );
1135 // --------------------------------------------------------------------
1137 Control* FontStylePropertyBox::getControl()
1139 return mpControl;
1142 // ====================================================================
1144 class CustomAnimationEffectTabPage : public TabPage
1146 public:
1147 CustomAnimationEffectTabPage( Window* pParent, const ResId& rResId, const STLPropertySet* pSet );
1148 ~CustomAnimationEffectTabPage();
1150 void update( STLPropertySet* pSet );
1151 DECL_LINK( implSelectHdl, Control* );
1153 private:
1154 void updateControlStates();
1155 void fillSoundListBox();
1156 void clearSoundListBox();
1157 sal_Int32 getSoundObject( const String& rStr );
1158 void openSoundFileDialog();
1159 void onSoundPreview();
1161 private:
1162 List maSoundList;
1163 sal_Bool mbHasText;
1164 const STLPropertySet* mpSet;
1166 FixedLine* mpFLSettings;
1167 FixedText* mpFTProperty1;
1168 PropertyControl* mpLBProperty1;
1169 FixedText* mpFTProperty2;
1170 PropertyControl* mpLBProperty2;
1171 CheckBox* mpCBSmoothStart;
1172 CheckBox* mpCBSmoothEnd;
1173 CheckBox* mpCBAutoRestart;
1175 FixedLine* mpFLPlay;
1176 RadioButton* mpRBFromStart;
1177 RadioButton* mpRBFromLast;
1178 RadioButton* mpRBFromTime;
1179 MetricField* mpMFStartTime;
1180 FixedLine* mpFLStop;
1181 RadioButton* mpRBStopOnClick;
1182 RadioButton* mpRBStopOnNextSlide;
1183 RadioButton* mpRBStopAfterSlides;
1184 MetricField* mpMFStopAfterSlides;
1186 FixedLine* mpFLEnhancements;
1187 FixedText* mpFTSound;
1188 ListBox* mpLBSound;
1189 PushButton* mpPBSoundPreview;
1190 FixedText* mpFTAfterEffect;
1191 ListBox* mpLBAfterEffect;
1192 FixedText* mpFTDimColor;
1193 ColorListBox* mpCLBDimColor;
1194 FixedText* mpFTTextAnim;
1195 ListBox* mpLBTextAnim;
1196 MetricField* mpMFTextDelay;
1197 FixedText* mpFTTextDelay;
1199 ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > mxPlayer;
1203 static void move_down( Control* pControl, int nOffsetX, int nOffsetY )
1205 Point aPos( pControl->GetPosPixel() );
1206 aPos.X() += nOffsetX;
1207 aPos.Y() += nOffsetY;
1208 pControl->SetPosPixel( aPos );
1211 CustomAnimationEffectTabPage::CustomAnimationEffectTabPage( Window* pParent, const ResId& rResId, const STLPropertySet* pSet )
1212 : TabPage( pParent, rResId ), mbHasText( sal_False ), mpSet(pSet )
1214 mpFLSettings = new FixedLine( this, SdResId( FL_SETTINGS ) );
1215 mpFTProperty1 = new FixedText( this, SdResId( FT_PROPERTY_1 ) );
1216 mpLBProperty1 = new PropertyControl( this, SdResId( LB_PROPERTY_1 ) );
1217 mpFTProperty2 = new FixedText( this, SdResId( FT_PROPERTY_2 ) );
1218 mpLBProperty2 = new PropertyControl( this, SdResId( LB_PROPERTY_2 ) );
1219 mpCBSmoothStart = new CheckBox( this, SdResId( CB_SMOOTH_START ) );
1220 mpCBSmoothEnd = new CheckBox( this, SdResId( CB_SMOOTH_END ) );
1221 mpCBAutoRestart = new CheckBox( this, SdResId( CB_AUTORESTART ) );
1223 mpFLPlay = new FixedLine( this, SdResId( FL_PLAY ) );
1224 mpRBFromStart = new RadioButton( this, SdResId( RB_FROM_START ) );
1225 mpRBFromLast = new RadioButton( this, SdResId( RB_FROM_LAST ) );
1226 mpRBFromTime = new RadioButton( this, SdResId( RB_FROM_TIME ) );
1227 mpMFStartTime = new MetricField( this, SdResId( MF_START_TIME ) );
1228 mpFLStop = new FixedLine( this, SdResId( FL_STOP ) );
1229 mpRBStopOnClick = new RadioButton( this, SdResId( RB_STOP_ON_CLICK ) );
1230 mpRBStopOnNextSlide = new RadioButton( this, SdResId( RB_STOP_ON_NEXT_SLIDE ) );
1231 mpRBStopAfterSlides = new RadioButton( this, SdResId( RB_STOP_AFTER_N_SLIDES ) );
1232 mpMFStopAfterSlides = new MetricField( this, SdResId( MF_STOP_AFTER_SLIDES ) );
1234 mpFLEnhancements = new FixedLine( this, SdResId( FL_ENHANCEMENTS ) );
1235 mpFTSound = new FixedText( this, SdResId( FT_SOUND ) );
1236 mpLBSound = new ListBox( this, SdResId( LB_SOUND ) );
1237 mpPBSoundPreview = new PushButton( this, SdResId( PB_SOUND_PREVIEW ) );
1238 mpFTAfterEffect = new FixedText( this, SdResId( FT_AFTER_EFFECT ) );
1239 mpLBAfterEffect = new ListBox( this, SdResId( LB_AFTER_EFFECT ) );
1240 mpFTDimColor = new FixedText( this, SdResId( FT_DIMCOLOR ) );
1241 mpCLBDimColor = new ColorListBox( this, SdResId( CLB_DIMCOLOR ) );
1242 mpFTTextAnim = new FixedText( this, SdResId( FT_TEXT_ANIM ) );
1243 mpLBTextAnim = new ListBox( this, SdResId( LB_TEXT_ANIM ) );
1244 mpMFTextDelay = new MetricField( this, SdResId( MF_TEXT_DELAY ) );
1245 mpFTTextDelay = new FixedText( this, SdResId( FT_TEXT_DELAY ) );
1247 FreeResource();
1249 // fill the soundbox
1250 fillSoundListBox();
1252 mpLBSound->SetSelectHdl( LINK( this, CustomAnimationEffectTabPage, implSelectHdl ) );
1254 mpPBSoundPreview->SetClickHdl( LINK( this, CustomAnimationEffectTabPage, implSelectHdl ) );
1255 mpPBSoundPreview->SetSymbol( SYMBOL_PLAY );
1257 // fill the color box
1258 SfxObjectShell* pDocSh = SfxObjectShell::Current();
1259 DBG_ASSERT( pDocSh, "DocShell not found!" );
1260 XColorTable* pColorTable = NULL;
1261 bool bKillTable = false;
1262 const SfxPoolItem* pItem = NULL;
1264 if ( pDocSh && ( (pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) != 0 ) )
1265 pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable();
1267 if ( !pColorTable )
1269 pColorTable = new XColorTable( SvtPathOptions().GetPalettePath() );
1270 bKillTable = TRUE;
1273 mpCLBDimColor->SetUpdateMode( FALSE );
1275 for ( long i = 0; i < pColorTable->Count(); i++ )
1277 XColorEntry* pEntry = pColorTable->GetColor(i);
1278 mpCLBDimColor->InsertEntry( pEntry->GetColor(), pEntry->GetName() );
1281 mpCLBDimColor->SetUpdateMode( TRUE );
1283 if ( bKillTable )
1284 delete pColorTable;
1287 // init settings controls
1290 int nOffsetY = 0;
1291 int nOffsetX = 0;
1293 Size aSpace( LogicToPixel( Size( 3, 3 ), MAP_APPFONT ) );
1295 // only show settings if all selected effects have the same preset-id
1296 if( pSet->getPropertyState( nHandlePresetId ) != STLPropertyState_AMBIGUOUS )
1298 OUString aPresetId;
1299 pSet->getPropertyValue( nHandlePresetId ) >>= aPresetId;
1302 // property 1
1305 if( pSet->getPropertyState( nHandleProperty1Type ) != STLPropertyState_AMBIGUOUS )
1307 sal_Int32 nType = 0;
1308 pSet->getPropertyValue( nHandleProperty1Type ) >>= nType;
1310 if( nType != nPropertyTypeNone )
1312 // set ui name for property at fixed text
1313 OUString aPropertyName( getPropertyName( nType ) );
1315 if( aPropertyName.getLength() )
1317 mpFTProperty1->Show();
1318 mpLBProperty1->Show();
1320 nOffsetY += mpLBProperty1->GetSizePixel().Height() + aSpace.Height();
1322 mpFTProperty1->SetText( aPropertyName );
1325 // get property value
1326 const Any aValue( pSet->getPropertyValue( nHandleProperty1Value ) );
1328 Link aModifyLink;
1329 // create property sub control
1330 mpLBProperty1->setSubControl( PropertySubControl::create( nType, this, aValue, aPresetId, aModifyLink ));
1334 mpFTProperty1->Enable( mpLBProperty1->IsEnabled() );
1337 // accelerate & deccelerate
1340 if( pSet->getPropertyState( nHandleAccelerate ) == STLPropertyState_DIRECT )
1342 mpCBSmoothStart->Show();
1343 mpCBSmoothEnd->Show();
1345 move_down( mpCBSmoothStart, nOffsetX, nOffsetY );
1346 move_down( mpCBSmoothEnd, nOffsetX, nOffsetY );
1348 nOffsetY += mpCBSmoothStart->GetSizePixel().Height() + aSpace.Height();
1350 double fTemp = 0.0;
1351 pSet->getPropertyValue( nHandleAccelerate ) >>= fTemp;
1352 mpCBSmoothStart->Check( fTemp > 0.0 );
1354 pSet->getPropertyValue( nHandleDecelerate ) >>= fTemp;
1355 mpCBSmoothEnd->Check( fTemp > 0.0 );
1359 // auto reverse
1363 if( nOffsetY )
1365 nOffsetY += mpFLSettings->GetSizePixel().Height() + aSpace.Height();
1366 mpFLSettings->Show();
1368 mpFLEnhancements->Show();
1369 move_down( mpFLEnhancements, nOffsetX, nOffsetY );
1371 nOffsetY += mpFLEnhancements->GetSizePixel().Height() + aSpace.Height();
1373 nOffsetX = 2* aSpace.Width();
1377 if( (nOffsetY != 0) || (nOffsetX != 0) )
1379 move_down( mpFTSound, nOffsetX, nOffsetY );
1380 move_down( mpLBSound, nOffsetX, nOffsetY );
1381 move_down( mpPBSoundPreview, nOffsetX, nOffsetY );
1382 move_down( mpFTAfterEffect, nOffsetX, nOffsetY );
1383 move_down( mpLBAfterEffect, nOffsetX, nOffsetY );
1384 move_down( mpFTDimColor, nOffsetX, nOffsetY );
1385 move_down( mpCLBDimColor, nOffsetX, nOffsetY );
1386 move_down( mpFTTextAnim, nOffsetX, nOffsetY );
1387 move_down( mpLBTextAnim, nOffsetX, nOffsetY );
1388 move_down( mpMFTextDelay, nOffsetX, nOffsetY );
1389 move_down( mpFTTextDelay, nOffsetX, nOffsetY );
1393 // init after effect controls
1396 mpLBAfterEffect->SetSelectHdl( LINK( this, CustomAnimationEffectTabPage, implSelectHdl ) );
1397 mpLBTextAnim->SetSelectHdl( LINK( this, CustomAnimationEffectTabPage, implSelectHdl ) );
1399 if( (pSet->getPropertyState( nHandleHasAfterEffect ) != STLPropertyState_AMBIGUOUS) &&
1400 (pSet->getPropertyState( nHandleAfterEffectOnNextEffect ) != STLPropertyState_AMBIGUOUS) &&
1401 (pSet->getPropertyState( nHandleDimColor ) != STLPropertyState_AMBIGUOUS))
1403 sal_Bool bHasAfterEffect = sal_False;
1404 pSet->getPropertyValue( nHandleHasAfterEffect ) >>= bHasAfterEffect;
1406 USHORT nPos = 0;
1407 if( bHasAfterEffect )
1409 nPos++;
1411 sal_Bool bAfterEffectOnNextClick = sal_False;
1412 pSet->getPropertyValue( nHandleAfterEffectOnNextEffect ) >>= bAfterEffectOnNextClick;
1413 Any aDimColor( pSet->getPropertyValue( nHandleDimColor ) );
1415 if( aDimColor.hasValue() )
1417 sal_Int32 nColor = 0;
1418 aDimColor >>= nColor;
1419 Color aColor( nColor );
1420 USHORT nColorPos = mpCLBDimColor->GetEntryPos( aColor );
1421 if ( LISTBOX_ENTRY_NOTFOUND != nColorPos )
1422 mpCLBDimColor->SelectEntryPos( nColorPos );
1423 else
1424 mpCLBDimColor->SelectEntryPos(
1425 mpCLBDimColor->InsertEntry( aColor, String( SVX_RES( RID_SVXSTR_COLOR_USER ) ) ) );
1427 else
1429 nPos++;
1430 if( bAfterEffectOnNextClick )
1431 nPos++;
1435 mpLBAfterEffect->SelectEntryPos( nPos );
1438 if( pSet->getPropertyState( nHandleHasText ) != STLPropertyState_AMBIGUOUS )
1439 pSet->getPropertyValue( nHandleHasText ) >>= mbHasText;
1441 if( mbHasText )
1443 if( pSet->getPropertyState( nHandleIterateType ) != STLPropertyState_AMBIGUOUS)
1445 USHORT nPos = LISTBOX_ENTRY_NOTFOUND;
1447 sal_Int32 nIterateType = 0;
1448 pSet->getPropertyValue( nHandleIterateType ) >>= nIterateType;
1449 switch( nIterateType )
1451 case TextAnimationType::BY_PARAGRAPH: nPos = 0; break;
1452 case TextAnimationType::BY_WORD: nPos = 1; break;
1453 case TextAnimationType::BY_LETTER: nPos = 2; break;
1456 mpLBTextAnim->SelectEntryPos( nPos );
1459 if( pSet->getPropertyState( nHandleIterateInterval ) )
1461 double fIterateInterval = 0.0;
1462 pSet->getPropertyValue( nHandleIterateInterval ) >>= fIterateInterval;
1463 mpMFTextDelay->SetValue( (long)(fIterateInterval*10) );
1466 else
1468 mpFTTextAnim->Enable( FALSE );
1469 mpLBTextAnim->Enable( FALSE );
1470 mpMFTextDelay->Enable( FALSE );
1471 mpFTTextDelay->Enable( FALSE );
1475 if( pSet->getPropertyState( nHandleSoundURL ) != STLPropertyState_AMBIGUOUS )
1477 USHORT nPos = 0;
1479 const Any aValue( pSet->getPropertyValue( nHandleSoundURL ) );
1481 if( aValue.getValueType() == ::getCppuType((const sal_Bool*)0) )
1483 nPos = 1;
1485 else
1487 OUString aSoundURL;
1488 aValue >>= aSoundURL;
1490 if( aSoundURL.getLength() )
1492 const String aTmp( aSoundURL );
1494 ULONG i;
1495 for( i = 0; i < maSoundList.Count(); i++ )
1497 String* pString = (String*)maSoundList.GetObject( i );
1498 if( *pString == aTmp )
1500 nPos = (USHORT)i+2;
1501 break;
1505 if( nPos == 0 )
1507 nPos = (USHORT)maSoundList.Count()+2;
1508 maSoundList.Insert( new String( aTmp ), LIST_APPEND );
1509 INetURLObject aURL( aTmp );
1510 nPos = mpLBSound->InsertEntry( aURL.GetBase(), nPos );
1515 if( nPos != LISTBOX_ENTRY_NOTFOUND )
1516 mpLBSound->SelectEntryPos( nPos );
1519 updateControlStates();
1521 Size aSize( GetSizePixel() );
1522 aSize.Height() += mpMFTextDelay->GetPosPixel().X() + GetSizePixel().Height() + aSpace.Height();
1523 SetSizePixel( aSize );
1526 CustomAnimationEffectTabPage::~CustomAnimationEffectTabPage()
1528 clearSoundListBox();
1530 delete mpFLSettings;
1531 delete mpFTProperty1;
1532 delete mpLBProperty1;
1533 delete mpFTProperty2;
1534 delete mpLBProperty2;
1535 delete mpCBSmoothStart;
1536 delete mpCBSmoothEnd;
1537 delete mpCBAutoRestart;
1539 delete mpFLEnhancements;
1540 delete mpFTSound;
1541 delete mpLBSound;
1542 delete mpPBSoundPreview;
1543 delete mpFTAfterEffect;
1544 delete mpLBAfterEffect;
1545 delete mpFTDimColor;
1546 delete mpCLBDimColor;
1547 delete mpFTTextAnim;
1548 delete mpLBTextAnim;
1549 delete mpMFTextDelay;
1550 delete mpFTTextDelay;
1553 void CustomAnimationEffectTabPage::updateControlStates()
1555 USHORT nPos = mpLBAfterEffect->GetSelectEntryPos();
1556 mpCLBDimColor->Enable( nPos == 1 );
1557 mpFTDimColor->Enable( nPos == 1 );
1559 if( mbHasText )
1561 nPos = mpLBTextAnim->GetSelectEntryPos();
1562 mpMFTextDelay->Enable( nPos != 0 );
1563 mpFTTextDelay->Enable( nPos != 0 );
1566 nPos = mpLBSound->GetSelectEntryPos();
1567 mpPBSoundPreview->Enable( nPos >= 2 );
1570 IMPL_LINK( CustomAnimationEffectTabPage, implSelectHdl, Control*, pControl )
1572 if( pControl == mpLBAfterEffect )
1574 USHORT nPos = static_cast<ListBox*>( mpLBAfterEffect )->GetSelectEntryPos();
1575 if( nPos == 1 )
1577 if( mpCLBDimColor->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND )
1578 mpCLBDimColor->SelectEntryPos(0);
1581 else if( pControl == mpLBTextAnim )
1583 if( mpMFTextDelay->GetValue() == 0 )
1584 mpMFTextDelay->SetValue( 100 );
1586 else if( pControl == mpLBSound )
1588 USHORT nPos = mpLBSound->GetSelectEntryPos();
1589 if( nPos == (mpLBSound->GetEntryCount() - 1) )
1591 openSoundFileDialog();
1594 else if( pControl == mpPBSoundPreview )
1596 onSoundPreview();
1599 updateControlStates();
1600 return 0;
1603 void CustomAnimationEffectTabPage::update( STLPropertySet* pSet )
1605 if( mpLBProperty1->getSubControl() )
1607 Any aNewValue( mpLBProperty1->getSubControl()->getValue() );
1608 Any aOldValue;
1609 if( mpSet->getPropertyState( nHandleProperty1Value ) != STLPropertyState_AMBIGUOUS)
1610 aOldValue = mpSet->getPropertyValue( nHandleProperty1Value );
1612 if( aOldValue != aNewValue )
1613 pSet->setPropertyValue( nHandleProperty1Value, aNewValue );
1616 if( mpLBProperty2->getSubControl() )
1618 Any aNewValue( mpLBProperty2->getSubControl()->getValue() );
1619 Any aOldValue;
1620 if( mpSet->getPropertyState( nHandleProperty2Value ) != STLPropertyState_AMBIGUOUS)
1621 aOldValue = mpSet->getPropertyValue( nHandleProperty2Value );
1623 if( aOldValue != aNewValue )
1624 pSet->setPropertyValue( nHandleProperty2Value, aNewValue );
1627 if( mpCBSmoothStart->IsVisible() )
1629 // set selected value for accelerate if different then in original set
1631 double fTemp = mpCBSmoothStart->IsChecked() ? 0.5 : 0.0;
1633 double fOldTemp = 0.0;
1634 if(mpSet->getPropertyState( nHandleAccelerate ) != STLPropertyState_AMBIGUOUS)
1635 mpSet->getPropertyValue( nHandleAccelerate ) >>= fOldTemp;
1636 else
1637 fOldTemp = -2.0;
1639 if( fOldTemp != fTemp )
1640 pSet->setPropertyValue( nHandleAccelerate, makeAny( fTemp ) );
1642 // set selected value for decelerate if different then in original set
1643 fTemp = mpCBSmoothEnd->IsChecked() ? 0.5 : 0.0;
1645 if(mpSet->getPropertyState( nHandleDecelerate ) != STLPropertyState_AMBIGUOUS)
1646 mpSet->getPropertyValue( nHandleDecelerate ) >>= fOldTemp;
1647 else
1648 fOldTemp = -2.0;
1650 if( fOldTemp != fTemp )
1651 pSet->setPropertyValue( nHandleDecelerate, makeAny( fTemp ) );
1654 USHORT nPos = mpLBAfterEffect->GetSelectEntryPos();
1655 if( nPos != LISTBOX_ENTRY_NOTFOUND )
1657 sal_Bool bAfterEffect = nPos != 0;
1659 sal_Bool bOldAfterEffect = sal_False;
1661 if(mpSet->getPropertyState( nHandleHasAfterEffect ) != STLPropertyState_AMBIGUOUS)
1662 mpSet->getPropertyValue( nHandleHasAfterEffect ) >>= bOldAfterEffect;
1663 else
1664 bOldAfterEffect = !bAfterEffect;
1666 if( bOldAfterEffect != bAfterEffect )
1667 pSet->setPropertyValue( nHandleHasAfterEffect, makeAny( bAfterEffect ) );
1669 Any aDimColor;
1670 if( nPos == 1 )
1672 Color aSelectedColor;
1673 if ( mpCLBDimColor->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
1674 aSelectedColor = mpCLBDimColor->GetSelectEntryColor();
1676 aDimColor = makeAny( makeAny( (sal_Int32)aSelectedColor.GetRGBColor() ) );
1679 if( (mpSet->getPropertyState( nHandleDimColor ) == STLPropertyState_AMBIGUOUS) ||
1680 (mpSet->getPropertyValue( nHandleDimColor ) != aDimColor) )
1681 pSet->setPropertyValue( nHandleDimColor, makeAny( aDimColor ) );
1683 sal_Bool bAfterEffectOnNextEffect = nPos != 2 ? sal_True : sal_False;
1684 sal_Bool bOldAfterEffectOnNextEffect = !bAfterEffectOnNextEffect;
1686 if( mpSet->getPropertyState( nHandleAfterEffectOnNextEffect ) != STLPropertyState_AMBIGUOUS)
1687 mpSet->getPropertyValue( nHandleAfterEffectOnNextEffect ) >>= bOldAfterEffectOnNextEffect;
1689 if( bAfterEffectOnNextEffect != bOldAfterEffectOnNextEffect )
1690 pSet->setPropertyValue( nHandleAfterEffectOnNextEffect, makeAny( bAfterEffectOnNextEffect ) );
1693 // ---
1695 nPos = mpLBTextAnim->GetSelectEntryPos();
1696 if( nPos != LISTBOX_ENTRY_NOTFOUND )
1698 sal_Int16 nIterateType;
1700 switch( nPos )
1702 case 1: nIterateType = TextAnimationType::BY_WORD; break;
1703 case 2: nIterateType = TextAnimationType::BY_LETTER; break;
1704 default:
1705 nIterateType = TextAnimationType::BY_PARAGRAPH;
1708 sal_Int16 nOldIterateType = nIterateType-1;
1710 if(mpSet->getPropertyState( nHandleIterateType ) != STLPropertyState_AMBIGUOUS)
1711 mpSet->getPropertyValue( nHandleIterateType ) >>= nOldIterateType;
1713 if( nIterateType != nOldIterateType )
1714 pSet->setPropertyValue( nHandleIterateType, makeAny( nIterateType ) );
1717 // ---
1720 double fIterateInterval = static_cast< double >( mpMFTextDelay->GetValue() ) / 10;
1721 double fOldIterateInterval = -1.0;
1723 if( mpSet->getPropertyState( nHandleIterateInterval ) != STLPropertyState_AMBIGUOUS )
1724 mpSet->getPropertyValue( nHandleIterateInterval ) >>= fOldIterateInterval;
1726 if( fIterateInterval != fOldIterateInterval )
1727 pSet->setPropertyValue( nHandleIterateInterval, makeAny( fIterateInterval ) );
1730 nPos = mpLBSound->GetSelectEntryPos();
1731 if( nPos != LISTBOX_ENTRY_NOTFOUND )
1733 Any aNewSoundURL, aOldSoundURL( makeAny( (sal_Int32) 0 ) );
1735 if( nPos == 0 )
1737 // 0 means no sound, so leave any empty
1739 else if( nPos == 1 )
1741 // this means stop sound
1742 aNewSoundURL = makeAny( (sal_Bool)sal_True );
1744 else
1746 OUString aSoundURL( *(String*)maSoundList.GetObject( nPos-2 ) );
1747 aNewSoundURL = makeAny( aSoundURL );
1750 if( mpSet->getPropertyState( nHandleSoundURL ) != STLPropertyState_AMBIGUOUS )
1751 mpSet->getPropertyValue( nHandleSoundURL ) >>= aOldSoundURL;
1753 if( aNewSoundURL != aOldSoundURL )
1754 pSet->setPropertyValue( nHandleSoundURL, aNewSoundURL );
1758 void CustomAnimationEffectTabPage::fillSoundListBox()
1760 GalleryExplorer::FillObjList( GALLERY_THEME_SOUNDS, maSoundList );
1761 GalleryExplorer::FillObjList( GALLERY_THEME_USERSOUNDS, maSoundList );
1763 mpLBSound->InsertEntry( String( SdResId( STR_CUSTOMANIMATION_NO_SOUND ) ) );
1764 mpLBSound->InsertEntry( String( SdResId( STR_CUSTOMANIMATION_STOP_PREVIOUS_SOUND ) ) );
1765 for( ULONG i = 0; i < maSoundList.Count(); i++ )
1767 String* pString = (String*)maSoundList.GetObject( i );
1768 INetURLObject aURL( *pString );
1769 mpLBSound->InsertEntry( aURL.GetBase() );
1771 mpLBSound->InsertEntry( String( SdResId( STR_CUSTOMANIMATION_BROWSE_SOUND ) ) );
1774 void CustomAnimationEffectTabPage::clearSoundListBox()
1776 const sal_uInt32 nCount = maSoundList.Count();
1777 sal_uInt32 i;
1778 for( i = 0; i < nCount; i++ )
1779 delete (String*)maSoundList.GetObject( i );
1780 maSoundList.Clear();
1782 mpLBSound->Clear();
1785 sal_Int32 CustomAnimationEffectTabPage::getSoundObject( const String& rStr )
1787 String aStrIn( rStr );
1788 aStrIn.ToLowerAscii();
1790 sal_uInt32 i;
1791 const sal_uInt32 nCount = maSoundList.Count();
1792 for( i = 0; i < nCount; i++ )
1794 String aTmpStr( *(String*)maSoundList.GetObject( i ) );
1795 aTmpStr.ToLowerAscii();
1797 if( aTmpStr == aStrIn )
1798 return i+2;
1801 return -1;
1804 void CustomAnimationEffectTabPage::openSoundFileDialog()
1806 SdOpenSoundFileDialog aFileDialog;
1808 String aFile( SvtPathOptions().GetGraphicPath() );
1809 aFileDialog.SetPath( aFile );
1811 bool bValidSoundFile = false;
1812 bool bQuitLoop = false;
1813 long nPos = 0;
1815 while( !bQuitLoop && (aFileDialog.Execute() == ERRCODE_NONE) )
1817 aFile = aFileDialog.GetPath();
1818 nPos = getSoundObject( aFile );
1820 if( nPos < 0 ) // not in Soundliste
1822 // try to insert in Gallery
1823 if( GalleryExplorer::InsertURL( GALLERY_THEME_USERSOUNDS, aFile, SGA_FORMAT_SOUND ) )
1825 clearSoundListBox();
1826 fillSoundListBox();
1828 nPos = getSoundObject( aFile );
1829 DBG_ASSERT( nPos >= 0, "sd::CustomAnimationEffectTabPage::openSoundFileDialog(), Recently inserted sound not in list!" );
1831 bValidSoundFile=true;
1832 bQuitLoop=true;
1834 else
1836 String aStrWarning(SdResId(STR_WARNING_NOSOUNDFILE));
1837 String aStr; aStr += sal_Unicode('%');
1838 aStrWarning.SearchAndReplace( aStr , aFile );
1839 WarningBox aWarningBox( NULL, WB_3DLOOK | WB_RETRY_CANCEL, aStrWarning );
1840 aWarningBox.SetModalInputMode (TRUE);
1841 bQuitLoop = aWarningBox.Execute()==RET_RETRY ? FALSE : TRUE;
1843 bValidSoundFile=false;
1846 else
1848 bValidSoundFile=true;
1849 bQuitLoop=true;
1853 if( !bValidSoundFile )
1854 nPos = 0;
1856 mpLBSound->SelectEntryPos( (USHORT) nPos );
1859 void CustomAnimationEffectTabPage::onSoundPreview()
1861 const USHORT nPos = mpLBSound->GetSelectEntryPos();
1863 if( nPos >= 2 ) try
1865 const OUString aSoundURL( *(String*)maSoundList.GetObject( nPos-2 ) );
1866 mxPlayer.set( avmedia::MediaWindow::createPlayer( aSoundURL ), uno::UNO_QUERY_THROW );
1867 mxPlayer->start();
1869 catch( uno::Exception& e )
1871 (void)e;
1872 DBG_ERROR("CustomAnimationEffectTabPage::onSoundPreview(), exception caught!" );
1876 class CustomAnimationDurationTabPage : public TabPage
1878 public:
1879 CustomAnimationDurationTabPage( Window* pParent, const ResId& rResId, const STLPropertySet* pSet );
1880 ~CustomAnimationDurationTabPage();
1882 void update( STLPropertySet* pSet );
1884 DECL_LINK( implControlHdl, Control* );
1886 private:
1887 const STLPropertySet* mpSet;
1889 boost::shared_ptr< FixedText > mpFTStart;
1890 boost::shared_ptr< ListBox > mpLBStart;
1891 boost::shared_ptr< FixedText > mpFTStartDelay;
1892 boost::shared_ptr< MetricField > mpMFStartDelay;
1893 boost::shared_ptr< FixedText > mpFTDuration;
1894 boost::shared_ptr< ComboBox > mpCBDuration;
1895 boost::shared_ptr< FixedText > mpFTRepeat;
1896 boost::shared_ptr< ComboBox > mpCBRepeat;
1897 boost::shared_ptr< CheckBox > mpCBXRewind;
1898 boost::shared_ptr< FixedLine > mpFLTrigger;
1899 boost::shared_ptr< RadioButton > mpRBClickSequence;
1900 boost::shared_ptr< RadioButton > mpRBInteractive;
1901 boost::shared_ptr< ListBox > mpLBTrigger;
1904 CustomAnimationDurationTabPage::CustomAnimationDurationTabPage(Window* pParent, const ResId& rResId, const STLPropertySet* pSet)
1905 : TabPage( pParent, rResId ), mpSet( pSet )
1907 mpFTStart.reset( new FixedText( this, SdResId( FT_START ) ) );
1908 mpLBStart.reset( new ListBox( this, SdResId( LB_START ) ) );
1909 mpFTStartDelay.reset( new FixedText( this, SdResId( FT_START_DELAY ) ) );
1910 mpMFStartDelay.reset( new MetricField( this, SdResId( MF_START_DELAY ) ) );
1911 mpFTDuration.reset( new FixedText( this, SdResId( FT_DURATION ) ) );
1912 mpCBDuration.reset( new ComboBox( this, SdResId( CB_DURATION ) ) );
1913 mpFTRepeat.reset( new FixedText( this, SdResId( FT_REPEAT ) ) );
1914 mpCBRepeat.reset( new ComboBox( this, SdResId( CB_REPEAT ) ) );
1915 mpCBXRewind.reset( new CheckBox( this, SdResId( CBX_REWIND ) ) );
1916 mpFLTrigger.reset( new FixedLine( this, SdResId( FL_TRIGGER ) ) );
1917 mpRBClickSequence.reset( new RadioButton( this, SdResId( RB_CLICKSEQUENCE ) ) );
1918 mpRBInteractive.reset( new RadioButton( this, SdResId( RB_INTERACTIVE ) ) );
1919 mpLBTrigger.reset( new ListBox( this, SdResId( LB_TRIGGER ) ) );
1921 fillRepeatComboBox( mpCBRepeat.get() );
1922 fillDurationComboBox( mpCBDuration.get() );
1924 FreeResource();
1926 mpRBClickSequence->SetClickHdl( LINK( this, CustomAnimationDurationTabPage, implControlHdl ) );
1927 mpRBClickSequence->SetClickHdl( LINK( this, CustomAnimationDurationTabPage, implControlHdl ) );
1928 mpLBTrigger->SetSelectHdl( LINK( this, CustomAnimationDurationTabPage, implControlHdl ) );
1930 if( pSet->getPropertyState( nHandleStart ) != STLPropertyState_AMBIGUOUS )
1932 sal_Int16 nStart = 0;
1933 pSet->getPropertyValue( nHandleStart ) >>= nStart;
1934 USHORT nPos = 0;
1935 switch( nStart )
1937 case EffectNodeType::WITH_PREVIOUS: nPos = 1; break;
1938 case EffectNodeType::AFTER_PREVIOUS: nPos = 2; break;
1940 mpLBStart->SelectEntryPos( nPos );
1943 if( pSet->getPropertyState( nHandleBegin ) != STLPropertyState_AMBIGUOUS )
1945 double fBegin = 0.0;
1946 pSet->getPropertyValue( nHandleBegin ) >>= fBegin;
1947 mpMFStartDelay->SetValue( (long)(fBegin*10) );
1950 if( pSet->getPropertyState( nHandleDuration ) != STLPropertyState_AMBIGUOUS )
1952 double fDuration = 0.0;
1953 pSet->getPropertyValue( nHandleDuration ) >>= fDuration;
1955 if( fDuration == 0.001 )
1957 mpFTDuration->Disable();
1958 mpCBDuration->Disable();
1959 mpFTRepeat->Disable();
1960 mpCBRepeat->Disable();
1961 mpCBXRewind->Disable();
1963 else
1965 USHORT nPos = LISTBOX_ENTRY_NOTFOUND;
1967 if( fDuration == 5.0 )
1968 nPos = 0;
1969 else if( fDuration == 3.0 )
1970 nPos = 1;
1971 else if( fDuration == 2.0 )
1972 nPos = 2;
1973 else if( fDuration == 1.0 )
1974 nPos = 3;
1975 else if( fDuration == 0.5 )
1976 nPos = 4;
1978 if( nPos != LISTBOX_ENTRY_NOTFOUND )
1979 mpCBDuration->SelectEntryPos( nPos );
1980 else
1981 mpCBDuration->SetText( String::CreateFromDouble( fDuration ) );
1985 if( pSet->getPropertyState( nHandleRepeat ) != STLPropertyState_AMBIGUOUS )
1987 Any aRepeatCount( pSet->getPropertyValue( nHandleRepeat ) );
1988 if( (aRepeatCount.getValueType() == ::getCppuType((const double*)0)) || !aRepeatCount.hasValue() )
1990 double fRepeat = 0.0;
1991 if( aRepeatCount.hasValue() )
1992 aRepeatCount >>= fRepeat;
1994 USHORT nPos = LISTBOX_ENTRY_NOTFOUND;
1996 if( fRepeat == 0 )
1997 nPos = 0;
1998 else if( fRepeat == 2.0 )
1999 nPos = 1;
2000 else if( fRepeat == 3.0 )
2001 nPos = 2;
2002 else if( fRepeat == 4.0 )
2003 nPos = 3;
2004 else if( fRepeat == 5.0 )
2005 nPos = 4;
2006 else if( fRepeat == 10.0 )
2007 nPos = 5;
2009 if( nPos != LISTBOX_ENTRY_NOTFOUND )
2010 mpCBRepeat->SelectEntryPos( nPos );
2011 else
2012 mpCBRepeat->SetText( String::CreateFromDouble( fRepeat ) );
2014 else if( aRepeatCount.getValueType() == ::getCppuType((const Timing*)0) )
2016 Any aEnd;
2017 if( pSet->getPropertyState( nHandleEnd ) != STLPropertyState_AMBIGUOUS )
2018 aEnd = pSet->getPropertyValue( nHandleEnd );
2020 mpCBRepeat->SelectEntryPos( aEnd.hasValue() ? 6 : 7 );
2024 if( pSet->getPropertyState( nHandleRewind ) != STLPropertyState_AMBIGUOUS )
2026 sal_Int16 nFill = 0;
2027 if( pSet->getPropertyValue( nHandleRewind ) >>= nFill )
2029 mpCBXRewind->Check( (nFill == AnimationFill::REMOVE) ? TRUE : FALSE );
2031 else
2033 mpCBXRewind->SetState( STATE_DONTKNOW );
2037 Reference< XShape > xTrigger;
2039 if( pSet->getPropertyState( nHandleTrigger ) != STLPropertyState_AMBIGUOUS )
2041 pSet->getPropertyValue( nHandleTrigger ) >>= xTrigger;
2043 mpRBInteractive->Check( xTrigger.is() );
2044 mpRBClickSequence->Check( !xTrigger.is() );
2047 Reference< XDrawPage > xCurrentPage;
2048 pSet->getPropertyValue( nHandleCurrentPage ) >>= xCurrentPage;
2049 if( xCurrentPage.is() )
2051 const OUString aStrIsEmptyPresObj( RTL_CONSTASCII_USTRINGPARAM( "IsEmptyPresentationObject" ) );
2053 sal_Int32 nShape, nCount = xCurrentPage->getCount();
2054 for( nShape = 0; nShape < nCount; nShape++ )
2056 Reference< XShape > xShape( xCurrentPage->getByIndex( nShape ), UNO_QUERY );
2058 if( !xShape.is() )
2059 continue;
2061 Reference< XPropertySet > xSet( xShape, UNO_QUERY );
2062 if( xSet.is() && xSet->getPropertySetInfo()->hasPropertyByName( aStrIsEmptyPresObj ) )
2064 sal_Bool bIsEmpty = sal_False;
2065 xSet->getPropertyValue( aStrIsEmptyPresObj ) >>= bIsEmpty;
2066 if( bIsEmpty )
2067 continue;
2070 String aDescription( getShapeDescription( xShape, true ) );
2071 USHORT nPos = mpLBTrigger->InsertEntry( aDescription );
2073 mpLBTrigger->SetEntryData( nPos, (void*)nShape );
2074 if( xShape == xTrigger )
2075 mpLBTrigger->SelectEntryPos( nPos );
2080 CustomAnimationDurationTabPage::~CustomAnimationDurationTabPage()
2084 IMPL_LINK( CustomAnimationDurationTabPage, implControlHdl, Control*, pControl )
2086 if( pControl == mpLBTrigger.get() )
2088 mpRBClickSequence->Check( FALSE );
2089 mpRBInteractive->Check( TRUE );
2092 return 0;
2095 void CustomAnimationDurationTabPage::update( STLPropertySet* pSet )
2097 USHORT nPos = mpLBStart->GetSelectEntryPos();
2098 if( nPos != LISTBOX_ENTRY_NOTFOUND )
2100 sal_Int16 nStart;
2101 sal_Int16 nOldStart = -1;
2103 switch( nPos )
2105 case 1: nStart = EffectNodeType::WITH_PREVIOUS; break;
2106 case 2: nStart = EffectNodeType::AFTER_PREVIOUS; break;
2107 default:
2108 nStart = EffectNodeType::ON_CLICK; break;
2111 if(mpSet->getPropertyState( nHandleStart ) != STLPropertyState_AMBIGUOUS)
2112 mpSet->getPropertyValue( nHandleStart ) >>= nOldStart;
2114 if( nStart != nOldStart )
2115 pSet->setPropertyValue( nHandleStart, makeAny( nStart ) );
2118 // ---
2121 double fBegin = static_cast<double>( mpMFStartDelay->GetValue()) / 10.0;
2122 double fOldBegin = -1.0;
2124 if( mpSet->getPropertyState( nHandleBegin ) != STLPropertyState_AMBIGUOUS )
2125 mpSet->getPropertyValue( nHandleBegin ) >>= fOldBegin;
2127 if( fBegin != fOldBegin )
2128 pSet->setPropertyValue( nHandleBegin, makeAny( fBegin ) );
2131 // ---
2133 nPos = mpCBRepeat->GetSelectEntryPos();
2134 if( (nPos != LISTBOX_ENTRY_NOTFOUND) || (mpCBRepeat->GetText().Len() != 0) )
2136 Any aRepeatCount;
2137 Any aEnd;
2139 switch( nPos )
2141 case 0:
2142 break;
2143 case 6:
2145 Event aEvent;
2146 aEvent.Trigger = EventTrigger::ON_NEXT;
2147 aEvent.Repeat = 0;
2148 aEnd <<= aEvent;
2150 // ATTENTION: FALL THROUGH INTENDED!
2151 case 7:
2152 aRepeatCount <<= Timing_INDEFINITE;
2153 break;
2154 default:
2156 String aText( mpCBRepeat->GetText() );
2157 if( aText.Len() )
2158 aRepeatCount <<= aText.ToDouble();
2162 Any aOldRepeatCount( aRepeatCount );
2163 if( mpSet->getPropertyState( nHandleRepeat ) != STLPropertyState_AMBIGUOUS )
2164 aOldRepeatCount = mpSet->getPropertyValue( nHandleRepeat );
2166 if( aRepeatCount != aOldRepeatCount )
2167 pSet->setPropertyValue( nHandleRepeat, aRepeatCount );
2169 Any aOldEnd( aEnd );
2170 if( mpSet->getPropertyState( nHandleEnd ) != STLPropertyState_AMBIGUOUS )
2171 aOldEnd = mpSet->getPropertyValue( nHandleEnd );
2173 if( aEnd != aOldEnd )
2174 pSet->setPropertyValue( nHandleEnd, aEnd );
2177 // ---
2179 double fDuration = -1.0;
2180 nPos = mpCBDuration->GetSelectEntryPos();
2181 if( nPos != LISTBOX_ENTRY_NOTFOUND )
2183 fDuration = *static_cast< const double * >( mpCBDuration->GetEntryData(nPos) );
2185 else
2187 String aText( mpCBDuration->GetText() );
2188 if( aText.Len() )
2190 fDuration = aText.ToDouble();
2194 if( fDuration != -1.0 )
2196 double fOldDuration = -1;
2198 if( mpSet->getPropertyState( nHandleDuration ) != STLPropertyState_AMBIGUOUS )
2199 mpSet->getPropertyValue( nHandleDuration ) >>= fOldDuration;
2201 if( fDuration != fOldDuration )
2202 pSet->setPropertyValue( nHandleDuration, makeAny( fDuration ) );
2205 // ---
2207 if( mpCBXRewind->GetState() != STATE_DONTKNOW )
2209 sal_Int16 nFill = mpCBXRewind->IsChecked() ? AnimationFill::REMOVE : AnimationFill::HOLD;
2211 bool bSet = true;
2213 if( mpSet->getPropertyState( nHandleRewind ) != STLPropertyState_AMBIGUOUS )
2215 sal_Int16 nOldFill = 0;
2216 mpSet->getPropertyValue( nHandleRewind ) >>= nOldFill;
2217 bSet = nFill != nOldFill;
2220 if( bSet )
2221 pSet->setPropertyValue( nHandleRewind, makeAny( nFill ) );
2224 Reference< XShape > xTrigger;
2226 if( mpRBInteractive->IsChecked() )
2228 nPos = mpLBTrigger->GetSelectEntryPos();
2229 if( nPos != LISTBOX_ENTRY_NOTFOUND )
2231 sal_Int32 nShape = (sal_Int32)(sal_IntPtr)mpLBTrigger->GetEntryData( nPos );
2233 Reference< XDrawPage > xCurrentPage;
2234 mpSet->getPropertyValue( nHandleCurrentPage ) >>= xCurrentPage;
2236 if( xCurrentPage.is() && (nShape >= 0) && (nShape < xCurrentPage->getCount()) )
2237 xCurrentPage->getByIndex( nShape ) >>= xTrigger;
2242 if( xTrigger.is() || mpRBClickSequence->IsChecked() )
2244 Any aNewValue( makeAny( xTrigger ) );
2245 Any aOldValue;
2247 if( mpSet->getPropertyState( nHandleTrigger ) != STLPropertyState_AMBIGUOUS )
2248 aOldValue = mpSet->getPropertyValue( nHandleTrigger );
2250 if( aNewValue != aOldValue )
2251 pSet->setPropertyValue( nHandleTrigger, aNewValue );
2255 class CustomAnimationTextAnimTabPage : public TabPage
2257 public:
2258 CustomAnimationTextAnimTabPage( Window* pParent, const ResId& rResId, const STLPropertySet* pSet );
2260 void update( STLPropertySet* pSet );
2262 void updateControlStates();
2263 DECL_LINK( implSelectHdl, Control* );
2265 private:
2266 FixedText maFTGroupText;
2267 ListBox maLBGroupText;
2268 CheckBox maCBXGroupAuto;
2269 MetricField maMFGroupAuto;
2270 CheckBox maCBXAnimateForm;
2271 CheckBox maCBXReverse;
2273 const STLPropertySet* mpSet;
2275 bool mbHasVisibleShapes;
2278 CustomAnimationTextAnimTabPage::CustomAnimationTextAnimTabPage(Window* pParent, const ResId& rResId, const STLPropertySet* pSet)
2279 : TabPage( pParent, rResId ),
2280 maFTGroupText( this, SdResId( FT_GROUP_TEXT ) ),
2281 maLBGroupText( this, SdResId( LB_GROUP_TEXT ) ),
2282 maCBXGroupAuto( this, SdResId( CBX_GROUP_AUTO ) ),
2283 maMFGroupAuto( this, SdResId( MF_GROUP_AUTO ) ),
2284 maCBXAnimateForm( this, SdResId( CBX_ANIMATE_FORM ) ),
2285 maCBXReverse( this, SdResId( CBX_REVERSE ) ),
2286 mpSet( pSet ),
2287 mbHasVisibleShapes(true)
2289 FreeResource();
2291 maLBGroupText.SetSelectHdl( LINK( this, CustomAnimationTextAnimTabPage, implSelectHdl ) );
2293 if( pSet->getPropertyState( nHandleTextGrouping ) != STLPropertyState_AMBIGUOUS )
2295 sal_Int32 nTextGrouping = 0;
2296 if( pSet->getPropertyValue( nHandleTextGrouping ) >>= nTextGrouping )
2297 maLBGroupText.SelectEntryPos( (USHORT)(nTextGrouping + 1) );
2300 if( pSet->getPropertyState( nHandleHasVisibleShape ) != STLPropertyState_AMBIGUOUS )
2301 pSet->getPropertyValue( nHandleHasVisibleShape ) >>= mbHasVisibleShapes;
2303 if( pSet->getPropertyState( nHandleTextGroupingAuto ) != STLPropertyState_AMBIGUOUS )
2305 double fTextGroupingAuto = 0.0;
2306 if( pSet->getPropertyValue( nHandleTextGroupingAuto ) >>= fTextGroupingAuto )
2308 maCBXGroupAuto.Check( fTextGroupingAuto >= 0.0 );
2309 if( fTextGroupingAuto >= 0.0 )
2310 maMFGroupAuto.SetValue( (long)(fTextGroupingAuto*10) );
2313 else
2315 maCBXGroupAuto.SetState( STATE_DONTKNOW );
2318 maCBXAnimateForm.SetState( STATE_DONTKNOW );
2319 if( pSet->getPropertyState( nHandleAnimateForm ) != STLPropertyState_AMBIGUOUS )
2321 sal_Bool bAnimateForm = sal_False;
2322 if( pSet->getPropertyValue( nHandleAnimateForm ) >>= bAnimateForm )
2324 maCBXAnimateForm.Check( bAnimateForm );
2327 else
2329 maCBXAnimateForm.Enable( FALSE );
2332 maCBXReverse.SetState( STATE_DONTKNOW );
2333 if( pSet->getPropertyState( nHandleTextReverse ) != STLPropertyState_AMBIGUOUS )
2335 sal_Bool bTextReverse = sal_False;
2336 if( pSet->getPropertyValue( nHandleTextReverse ) >>= bTextReverse )
2338 maCBXReverse.Check( bTextReverse );
2342 if( pSet->getPropertyState( nHandleMaxParaDepth ) == STLPropertyState_DIRECT )
2344 sal_Int32 nMaxParaDepth = 0;
2345 pSet->getPropertyValue( nHandleMaxParaDepth ) >>= nMaxParaDepth;
2346 nMaxParaDepth += 1;
2348 sal_Int32 nPos = 6;
2349 while( (nPos > 2) && (nPos > nMaxParaDepth) )
2351 maLBGroupText.RemoveEntry( (USHORT)nPos );
2352 nPos--;
2356 updateControlStates();
2359 void CustomAnimationTextAnimTabPage::update( STLPropertySet* pSet )
2361 USHORT nPos = maLBGroupText.GetSelectEntryPos();
2362 if( nPos != LISTBOX_ENTRY_NOTFOUND )
2364 sal_Int32 nTextGrouping = nPos - 1;
2365 sal_Int32 nOldGrouping = -2;
2367 if(mpSet->getPropertyState( nHandleTextGrouping ) != STLPropertyState_AMBIGUOUS)
2368 mpSet->getPropertyValue( nHandleTextGrouping ) >>= nOldGrouping;
2370 if( nTextGrouping != nOldGrouping )
2371 pSet->setPropertyValue( nHandleTextGrouping, makeAny( nTextGrouping ) );
2374 if( nPos > 0 )
2376 sal_Bool bTextReverse = maCBXReverse.IsChecked();
2377 sal_Bool bOldTextReverse = !bTextReverse;
2379 if(mpSet->getPropertyState( nHandleTextReverse ) != STLPropertyState_AMBIGUOUS)
2380 mpSet->getPropertyValue( nHandleTextReverse ) >>= bOldTextReverse;
2382 if( bTextReverse != bOldTextReverse )
2383 pSet->setPropertyValue( nHandleTextReverse, makeAny( bTextReverse ) );
2385 if( nPos > 1 )
2387 double fTextGroupingAuto = maCBXGroupAuto.IsChecked() ? maMFGroupAuto.GetValue() / 10.0 : -1.0;
2388 double fOldTextGroupingAuto = -2.0;
2390 if(mpSet->getPropertyState( nHandleTextGroupingAuto ) != STLPropertyState_AMBIGUOUS)
2391 mpSet->getPropertyValue( nHandleTextGroupingAuto ) >>= fOldTextGroupingAuto;
2393 if( fTextGroupingAuto != fOldTextGroupingAuto )
2394 pSet->setPropertyValue( nHandleTextGroupingAuto, makeAny( fTextGroupingAuto ) );
2398 sal_Bool bAnimateForm = maCBXAnimateForm.IsChecked();
2399 sal_Bool bOldAnimateForm = !bAnimateForm;
2401 if(mpSet->getPropertyState( nHandleAnimateForm ) != STLPropertyState_AMBIGUOUS)
2402 mpSet->getPropertyValue( nHandleAnimateForm ) >>= bOldAnimateForm;
2404 if( bAnimateForm != bOldAnimateForm )
2405 pSet->setPropertyValue( nHandleAnimateForm, makeAny( bAnimateForm ) );
2408 void CustomAnimationTextAnimTabPage::updateControlStates()
2410 USHORT nPos = maLBGroupText.GetSelectEntryPos();
2412 maCBXGroupAuto.Enable( nPos > 1 );
2413 maMFGroupAuto.Enable( nPos > 1 );
2414 maCBXReverse.Enable( nPos > 0 );
2416 if( !mbHasVisibleShapes && nPos > 0 )
2418 maCBXAnimateForm.Check(FALSE);
2419 maCBXAnimateForm.Enable(FALSE);
2421 else
2423 maCBXAnimateForm.Enable(TRUE);
2427 IMPL_LINK( CustomAnimationTextAnimTabPage, implSelectHdl, Control*, EMPTYARG )
2429 updateControlStates();
2430 return 0;
2433 // --------------------------------------------------------------------
2435 CustomAnimationDialog::CustomAnimationDialog( Window* pParent, STLPropertySet* pSet, USHORT nPage /* = 0 */ )
2436 : TabDialog( pParent, SdResId( DLG_CUSTOMANIMATION ) ), mpSet( pSet ), mpResultSet( 0 )
2438 mpTabControl = new TabControl( this, SdResId( 1 ) );
2439 mpOKButton = new OKButton(this, SdResId( 1 ) ) ;
2440 mpCancelButton = new CancelButton(this, SdResId( 1 ) );
2441 mpHelpButton = new HelpButton(this, SdResId( 1 ) );
2443 FreeResource();
2445 mpEffectTabPage = new CustomAnimationEffectTabPage( mpTabControl, SdResId( RID_TP_CUSTOMANIMATION_EFFECT ), mpSet );
2446 mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_EFFECT, mpEffectTabPage );
2447 mpDurationTabPage = new CustomAnimationDurationTabPage( mpTabControl, SdResId( RID_TP_CUSTOMANIMATION_DURATION ), mpSet );
2448 mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_DURATION, mpDurationTabPage );
2450 sal_Bool bHasText = sal_False;
2451 if( pSet->getPropertyState( nHandleHasText ) != STLPropertyState_AMBIGUOUS )
2452 pSet->getPropertyValue( nHandleHasText ) >>= bHasText;
2454 if( bHasText )
2456 mpTextAnimTabPage = new CustomAnimationTextAnimTabPage( mpTabControl, SdResId( RID_TP_CUSTOMANIMATION_TEXT ), mpSet );
2457 mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_TEXT, mpTextAnimTabPage );
2459 else
2461 mpTextAnimTabPage = 0;
2462 mpTabControl->RemovePage( RID_TP_CUSTOMANIMATION_TEXT );
2465 if( nPage )
2466 mpTabControl->SelectTabPage( nPage );
2469 CustomAnimationDialog::~CustomAnimationDialog()
2471 delete mpEffectTabPage;
2472 delete mpDurationTabPage;
2473 delete mpTextAnimTabPage;
2475 delete mpTabControl;
2476 delete mpOKButton;
2477 delete mpCancelButton;
2478 delete mpHelpButton;
2480 delete mpSet;
2481 delete mpResultSet;
2484 STLPropertySet* CustomAnimationDialog::getResultSet()
2486 if( mpResultSet )
2487 delete mpResultSet;
2489 mpResultSet = createDefaultSet();
2491 mpEffectTabPage->update( mpResultSet );
2492 mpDurationTabPage->update( mpResultSet );
2493 if( mpTextAnimTabPage )
2494 mpTextAnimTabPage->update( mpResultSet );
2496 return mpResultSet;
2499 STLPropertySet* CustomAnimationDialog::createDefaultSet()
2501 Any aEmpty;
2503 STLPropertySet* pSet = new STLPropertySet();
2504 pSet->setPropertyDefaultValue( nHandleMaxParaDepth, makeAny( (sal_Int32)-1 ) );
2506 pSet->setPropertyDefaultValue( nHandleHasAfterEffect, makeAny( (sal_Bool)sal_False ) );
2507 pSet->setPropertyDefaultValue( nHandleAfterEffectOnNextEffect, makeAny( (sal_Bool)sal_False ) );
2508 pSet->setPropertyDefaultValue( nHandleDimColor, aEmpty );
2509 pSet->setPropertyDefaultValue( nHandleIterateType, makeAny( (sal_Int16)0 ) );
2510 pSet->setPropertyDefaultValue( nHandleIterateInterval, makeAny( (double)0.0 ) );
2512 pSet->setPropertyDefaultValue( nHandleStart, makeAny( (sal_Int16)EffectNodeType::ON_CLICK ) );
2513 pSet->setPropertyDefaultValue( nHandleBegin, makeAny( (double)0.0 ) );
2514 pSet->setPropertyDefaultValue( nHandleDuration, makeAny( (double)2.0 ) );
2515 pSet->setPropertyDefaultValue( nHandleRepeat, aEmpty );
2516 pSet->setPropertyDefaultValue( nHandleRewind, makeAny( AnimationFill::HOLD ) );
2518 pSet->setPropertyDefaultValue( nHandleEnd, aEmpty );
2520 pSet->setPropertyDefaultValue( nHandlePresetId, aEmpty );
2521 pSet->setPropertyDefaultValue( nHandleProperty1Type, makeAny( nPropertyTypeNone ) );
2522 pSet->setPropertyDefaultValue( nHandleProperty1Value, aEmpty );
2523 pSet->setPropertyDefaultValue( nHandleProperty2Type, makeAny( nPropertyTypeNone ) );
2524 pSet->setPropertyDefaultValue( nHandleProperty2Value, aEmpty );
2525 pSet->setPropertyDefaultValue( nHandleAccelerate, aEmpty );
2526 pSet->setPropertyDefaultValue( nHandleDecelerate, aEmpty );
2527 pSet->setPropertyDefaultValue( nHandleAutoReverse, aEmpty );
2528 pSet->setPropertyDefaultValue( nHandleTrigger, aEmpty );
2530 pSet->setPropertyDefaultValue( nHandleHasText, makeAny( sal_False ) );
2531 pSet->setPropertyDefaultValue( nHandleHasVisibleShape, makeAny( sal_False ) );
2532 pSet->setPropertyDefaultValue( nHandleTextGrouping, makeAny( (sal_Int32)-1 ) );
2533 pSet->setPropertyDefaultValue( nHandleAnimateForm, makeAny( sal_True ) );
2534 pSet->setPropertyDefaultValue( nHandleTextGroupingAuto, makeAny( (double)-1.0 ) );
2535 pSet->setPropertyDefaultValue( nHandleTextReverse, makeAny( sal_False ) );
2537 pSet->setPropertyDefaultValue( nHandleCurrentPage, aEmpty );
2539 pSet->setPropertyDefaultValue( nHandleSoundURL, aEmpty );
2540 pSet->setPropertyDefaultValue( nHandleSoundVolumne, makeAny( (double)1.0) );
2541 pSet->setPropertyDefaultValue( nHandleSoundEndAfterSlide, makeAny( (sal_Int32)0 ) );
2543 pSet->setPropertyDefaultValue( nHandleCommand, makeAny( (sal_Int16)0 ) );
2544 return pSet;
2547 PropertyControl::PropertyControl( Window* pParent, const ResId& rResId )
2548 : ListBox( pParent, rResId ), mpSubControl(0)
2552 PropertyControl::~PropertyControl()
2554 if( mpSubControl )
2555 delete mpSubControl;
2558 void PropertyControl::setSubControl( PropertySubControl* pSubControl )
2560 if( mpSubControl && mpSubControl != pSubControl )
2561 delete mpSubControl;
2563 mpSubControl = pSubControl;
2565 Control* pControl = pSubControl ? pSubControl->getControl() : 0;
2567 if( pControl )
2569 pControl->SetPosSizePixel( GetPosPixel(), GetSizePixel() );
2570 pControl->SetZOrder( this, WINDOW_ZORDER_BEFOR );
2571 pControl->Show();
2572 Hide();
2574 else
2576 Show();
2580 void PropertyControl::Resize()
2582 Control* pControl = mpSubControl ? mpSubControl->getControl() : 0;
2583 if( pControl )
2584 pControl->SetPosSizePixel( GetPosPixel(), GetSizePixel() );
2585 ListBox::Resize();
2588 // ====================================================================
2590 PropertySubControl::~PropertySubControl()
2594 PropertySubControl* PropertySubControl::create( sal_Int32 nType, Window* pParent, const Any& rValue, const OUString& rPresetId, const Link& rModifyHdl )
2596 PropertySubControl* pSubControl = NULL;
2597 switch( nType )
2599 case nPropertyTypeDirection:
2600 case nPropertyTypeSpokes:
2601 case nPropertyTypeZoom:
2602 pSubControl = new PresetPropertyBox( nType, pParent, rValue, rPresetId, rModifyHdl );
2603 break;
2605 case nPropertyTypeColor:
2606 case nPropertyTypeFillColor:
2607 case nPropertyTypeFirstColor:
2608 case nPropertyTypeCharColor:
2609 case nPropertyTypeLineColor:
2610 pSubControl = new ColorPropertyBox( nType, pParent, rValue, rModifyHdl );
2611 break;
2613 case nPropertyTypeFont:
2614 pSubControl = new FontPropertyBox( nType, pParent, rValue, rModifyHdl );
2615 break;
2617 case nPropertyTypeCharHeight:
2618 pSubControl = new CharHeightPropertyBox( nType, pParent, rValue, rModifyHdl );
2619 break;
2621 case nPropertyTypeRotate:
2622 pSubControl = new RotationPropertyBox( nType, pParent, rValue, rModifyHdl );
2623 break;
2625 case nPropertyTypeTransparency:
2626 pSubControl = new TransparencyPropertyBox( nType, pParent, rValue, rModifyHdl );
2627 break;
2629 case nPropertyTypeScale:
2630 pSubControl = new ScalePropertyBox( nType, pParent, rValue, rModifyHdl );
2631 break;
2633 case nPropertyTypeCharDecoration:
2634 pSubControl = new FontStylePropertyBox( nType, pParent, rValue, rModifyHdl );
2635 break;
2638 return pSubControl;