bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / animations / CustomAnimationDialog.cxx
blob461272eb42a0aaa722ea5ff8723e0c1d34a25935
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/presentation/EffectNodeType.hpp>
21 #include <com/sun/star/animations/Timing.hpp>
22 #include <com/sun/star/animations/Event.hpp>
23 #include <com/sun/star/animations/EventTrigger.hpp>
24 #include <com/sun/star/animations/AnimationFill.hpp>
25 #include <com/sun/star/presentation/TextAnimationType.hpp>
26 #include <com/sun/star/animations/ValuePair.hpp>
27 #include <com/sun/star/awt/FontSlant.hpp>
28 #include <com/sun/star/awt/FontWeight.hpp>
29 #include <com/sun/star/awt/FontUnderline.hpp>
30 #include <com/sun/star/drawing/XDrawPage.hpp>
31 #include <com/sun/star/beans/XPropertySet.hpp>
32 #include <com/sun/star/media/XManager.hpp>
33 #include <com/sun/star/media/XPlayer.hpp>
35 #include <boost/shared_ptr.hpp>
37 #include <comphelper/processfactory.hxx>
38 #include <i18nutil/unicode.hxx>
39 #include <unotools/pathoptions.hxx>
40 #include <vcl/tabctrl.hxx>
41 #include <vcl/tabpage.hxx>
42 #include <vcl/menubtn.hxx>
43 #include <vcl/svapp.hxx>
44 #include <vcl/fixed.hxx>
45 #include <vcl/lstbox.hxx>
46 #include <vcl/layout.hxx>
47 #include <vcl/field.hxx>
48 #include <vcl/msgbox.hxx>
49 #include <vcl/decoview.hxx>
50 #include <vcl/combobox.hxx>
51 #include <vcl/menu.hxx>
52 #include <vcl/settings.hxx>
53 #include <vcl/builderfactory.hxx>
55 #include <svtools/ctrlbox.hxx>
56 #include <svtools/ctrltool.hxx>
57 #include <sfx2/objsh.hxx>
59 #include <svx/svxids.hrc>
60 #include <svx/dialmgr.hxx>
61 #include <editeng/flstitem.hxx>
62 #include <svx/drawitem.hxx>
64 #include <svx/xtable.hxx>
65 #include <svx/gallery.hxx>
67 #include <svx/dialogs.hrc>
68 #include "sdresid.hxx"
70 #include "glob.hrc"
71 #include "CustomAnimationDialog.hxx"
72 #include "CustomAnimationPane.hxx"
73 #include "CustomAnimation.hrc"
74 #include "STLPropertySet.hxx"
76 #include <avmedia/mediawindow.hxx>
78 #include "filedlg.hxx"
79 #include "strings.hrc"
80 #include "helpids.h"
82 using namespace ::com::sun::star;
83 using namespace ::com::sun::star::animations;
84 using namespace ::com::sun::star::presentation;
86 using ::com::sun::star::uno::UNO_QUERY;
87 using ::com::sun::star::uno::UNO_QUERY_THROW;
88 using ::com::sun::star::uno::Any;
89 using ::com::sun::star::uno::makeAny;
90 using ::com::sun::star::uno::Sequence;
91 using ::com::sun::star::uno::Reference;
92 using ::com::sun::star::uno::Exception;
93 using ::com::sun::star::drawing::XShape;
94 using ::com::sun::star::drawing::XDrawPage;
95 using ::com::sun::star::beans::XPropertySet;
97 namespace sd {
99 class PresetPropertyBox : public PropertySubControl
101 public:
102 PresetPropertyBox( sal_Int32 nControlType, vcl::Window* pParent, const Any& rValue, const OUString& aPresetId, const Link<>& rModifyHdl );
103 virtual ~PresetPropertyBox();
105 virtual Any getValue() SAL_OVERRIDE;
106 virtual void setValue( const Any& rValue, const OUString& rPresetId ) SAL_OVERRIDE;
107 virtual Control* getControl() SAL_OVERRIDE;
109 private:
110 std::map< sal_uInt16, OUString > maPropertyValues;
111 VclPtr<ListBox> mpControl;
114 PresetPropertyBox::PresetPropertyBox( sal_Int32 nControlType, vcl::Window* pParent, const Any& rValue, const OUString& aPresetId, const Link<>& rModifyHdl )
115 : PropertySubControl( nControlType )
117 mpControl = VclPtr<ListBox>::Create( pParent, WB_BORDER|WB_TABSTOP|WB_DROPDOWN );
118 mpControl->SetDropDownLineCount( 10 );
119 mpControl->SetSelectHdl( rModifyHdl );
120 mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_PRESETPROPERTYBOX );
122 setValue( rValue, aPresetId );
126 void PresetPropertyBox::setValue( const Any& rValue, const OUString& rPresetId )
128 if( mpControl )
130 mpControl->Clear();
132 const CustomAnimationPresets& rPresets = CustomAnimationPresets::getCustomAnimationPresets();
133 CustomAnimationPresetPtr pDescriptor = rPresets.getEffectDescriptor( rPresetId );
134 if( pDescriptor.get() )
137 OUString aPropertyValue;
138 rValue >>= aPropertyValue;
140 UStringList aSubTypes( pDescriptor->getSubTypes() );
141 UStringList::iterator aIter( aSubTypes.begin() );
142 const UStringList::iterator aEnd( aSubTypes.end() );
144 mpControl->Enable( aIter != aEnd );
146 while( aIter != aEnd )
148 sal_Int32 nPos = mpControl->InsertEntry( rPresets.getUINameForProperty( (*aIter) ) );
149 if( (*aIter) == aPropertyValue )
150 mpControl->SelectEntryPos( nPos );
151 maPropertyValues[nPos] = (*aIter++);
154 else
156 mpControl->Enable( false );
161 PresetPropertyBox::~PresetPropertyBox()
163 mpControl.disposeAndClear();
166 Any PresetPropertyBox::getValue()
168 return makeAny( maPropertyValues[mpControl->GetSelectEntryPos()] );
171 Control* PresetPropertyBox::getControl()
173 return mpControl;
176 class ColorPropertyBox : public PropertySubControl
178 public:
179 ColorPropertyBox( sal_Int32 nControlType, vcl::Window* pParent, const Any& rValue, const Link<>& rModifyHdl );
180 virtual ~ColorPropertyBox();
182 virtual Any getValue() SAL_OVERRIDE;
183 virtual void setValue( const Any& rValue, const OUString& rPresetId ) SAL_OVERRIDE;
184 virtual Control* getControl() SAL_OVERRIDE;
186 private:
187 VclPtr<ColorListBox> mpControl;
190 ColorPropertyBox::ColorPropertyBox( sal_Int32 nControlType, vcl::Window* pParent, const Any& rValue, const Link<>& rModifyHdl )
191 : PropertySubControl( nControlType )
193 mpControl = VclPtr<ColorListBox>::Create( pParent, WB_BORDER|WB_TABSTOP|WB_DROPDOWN );
194 mpControl->SetDropDownLineCount( 10 );
195 mpControl->SetSelectHdl( rModifyHdl );
196 mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_COLORPROPERTYBOX );
198 SfxObjectShell* pDocSh = SfxObjectShell::Current();
199 DBG_ASSERT( pDocSh, "DocShell not found!" );
200 XColorListRef pColorList;
201 const SfxPoolItem* pItem = NULL;
203 if ( pDocSh && ( ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) != 0) )
204 pColorList = static_cast<const SvxColorListItem*>(pItem)->GetColorList();
206 if ( !pColorList.is() )
207 pColorList = XColorList::CreateStdColorList();
209 sal_Int32 nColor = 0;
210 rValue >>= nColor;
212 for ( long i = 0; i < pColorList->Count(); i++ )
214 XColorEntry* pEntry = pColorList->GetColor(i);
215 sal_Int32 nPos = mpControl->InsertEntry( pEntry->GetColor(), pEntry->GetName() );
216 if( pEntry->GetColor().GetRGBColor() == (sal_uInt32)nColor )
217 mpControl->SelectEntryPos( nPos );
221 ColorPropertyBox::~ColorPropertyBox()
223 mpControl.disposeAndClear();
226 void ColorPropertyBox::setValue( const Any& rValue, const OUString& )
228 if( mpControl )
230 sal_Int32 nColor = 0;
231 rValue >>= nColor;
233 mpControl->SetNoSelection();
234 mpControl->SelectEntryPos( mpControl->GetEntryPos( static_cast<Color>(nColor) ) );
238 Any ColorPropertyBox::getValue()
240 return makeAny( (sal_Int32)mpControl->GetSelectEntryColor().GetRGBColor() );
243 Control* ColorPropertyBox::getControl()
245 return mpControl;
248 class FontPropertyBox : public PropertySubControl
250 public:
251 FontPropertyBox( sal_Int32 nControlType, vcl::Window* pParent, const Any& rValue, const Link<>& rModifyHdl );
252 virtual ~FontPropertyBox();
254 virtual Any getValue() SAL_OVERRIDE;
255 virtual void setValue( const Any& rValue, const OUString& rPresetId ) SAL_OVERRIDE;
257 virtual Control* getControl() SAL_OVERRIDE;
259 private:
260 VclPtr<FontNameBox> mpControl;
263 FontPropertyBox::FontPropertyBox( sal_Int32 nControlType, vcl::Window* pParent, const Any& rValue, const Link<>& rModifyHdl )
264 : PropertySubControl( nControlType )
266 mpControl = VclPtr<FontNameBox>::Create( pParent, WB_BORDER|WB_TABSTOP|WB_DROPDOWN );
267 mpControl->SetDropDownLineCount( 10 );
268 mpControl->SetSelectHdl( rModifyHdl );
269 mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_FONTPROPERTYBOX );
271 SfxObjectShell* pDocSh = SfxObjectShell::Current();
272 const SfxPoolItem* pItem;
274 const FontList* pFontList = 0;
275 bool bMustDelete = false;
277 if ( pDocSh && ( (pItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST ) ) != 0) )
278 pFontList = static_cast<const SvxFontListItem*>(pItem)->GetFontList();
280 if(!pFontList)
282 pFontList = new FontList( Application::GetDefaultDevice(), NULL, false );
283 bMustDelete = true;
286 mpControl->Fill( pFontList );
288 if( bMustDelete )
289 delete pFontList;
291 OUString aPresetId;
292 setValue( rValue, aPresetId );
295 void FontPropertyBox::setValue( const Any& rValue, const OUString& )
297 if( mpControl )
299 OUString aFontName;
300 rValue >>= aFontName;
301 mpControl->SetText( aFontName );
305 FontPropertyBox::~FontPropertyBox()
307 mpControl.disposeAndClear();
310 Any FontPropertyBox::getValue()
312 OUString aFontName( mpControl->GetText() );
313 return makeAny( aFontName );
316 Control* FontPropertyBox::getControl()
318 return mpControl;
321 class DropdownMenuBox : public Edit
323 public:
324 DropdownMenuBox( vcl::Window* pParent, Edit* pSubControl, PopupMenu* pMenu );
325 virtual ~DropdownMenuBox();
326 virtual void dispose() SAL_OVERRIDE;
328 void Resize() SAL_OVERRIDE;
329 bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
331 void SetMenuSelectHdl( const Link<MenuButton *, void>& rLink ) { mpDropdownButton->SetSelectHdl( rLink ); }
333 private:
334 VclPtr<Edit> mpSubControl;
335 VclPtr<MenuButton> mpDropdownButton;
336 PopupMenu* mpMenu;
339 DropdownMenuBox::DropdownMenuBox( vcl::Window* pParent, Edit* pSubControl, PopupMenu* pMenu )
340 : Edit( pParent, WB_BORDER|WB_TABSTOP| WB_DIALOGCONTROL ),
341 mpSubControl(pSubControl),mpDropdownButton(0),mpMenu(pMenu)
343 mpDropdownButton = VclPtr<MenuButton>::Create( this, WB_NOLIGHTBORDER | WB_RECTSTYLE | WB_NOTABSTOP);
344 mpDropdownButton->SetSymbol(SymbolType::SPIN_DOWN);
345 mpDropdownButton->Show();
346 mpDropdownButton->SetPopupMenu( pMenu );
348 SetSubEdit( mpSubControl );
349 mpSubControl->SetParent( this );
350 mpSubControl->Show();
353 DropdownMenuBox::~DropdownMenuBox()
355 disposeOnce();
358 void DropdownMenuBox::dispose()
360 SetSubEdit(nullptr);
361 mpDropdownButton.disposeAndClear();
362 delete mpMenu;
363 mpSubControl.disposeAndClear();
364 Edit::dispose();
367 void DropdownMenuBox::Resize()
369 Size aOutSz = GetOutputSizePixel();
371 long nSBWidth = GetSettings().GetStyleSettings().GetScrollBarSize();
372 nSBWidth = CalcZoom( nSBWidth );
373 mpSubControl->setPosSizePixel( 0, 1, aOutSz.Width() - nSBWidth, aOutSz.Height()-2 );
374 mpDropdownButton->setPosSizePixel( aOutSz.Width() - nSBWidth, 0, nSBWidth, aOutSz.Height() );
377 bool DropdownMenuBox::PreNotify( NotifyEvent& rNEvt )
379 bool nResult = true;
381 MouseNotifyEvent nSwitch=rNEvt.GetType();
382 if (nSwitch==MouseNotifyEvent::KEYINPUT)
384 const vcl::KeyCode& aKeyCode=rNEvt.GetKeyEvent()->GetKeyCode();
385 sal_uInt16 nKey=aKeyCode.GetCode();
387 if (nKey==KEY_DOWN && aKeyCode.IsMod2())
389 mpDropdownButton->KeyInput( *rNEvt.GetKeyEvent() );
391 else
393 nResult=Edit::PreNotify(rNEvt);
396 else
397 nResult=Edit::PreNotify(rNEvt);
399 return nResult;
402 class CharHeightPropertyBox : public PropertySubControl
404 public:
405 CharHeightPropertyBox( sal_Int32 nControlType, vcl::Window* pParent, const Any& rValue, const Link<>& rModifyHdl );
406 virtual ~CharHeightPropertyBox();
408 virtual Any getValue() SAL_OVERRIDE;
409 virtual void setValue( const Any& rValue, const OUString& ) SAL_OVERRIDE;
411 virtual Control* getControl() SAL_OVERRIDE;
413 DECL_LINK_TYPED( implMenuSelectHdl, MenuButton*, void );
415 private:
416 VclPtr<DropdownMenuBox> mpControl;
417 PopupMenu* mpMenu;
418 VclPtr<MetricField> mpMetric;
421 CharHeightPropertyBox::CharHeightPropertyBox( sal_Int32 nControlType, vcl::Window* pParent, const Any& rValue, const Link<>& rModifyHdl )
422 : PropertySubControl( nControlType )
424 mpMetric.set( VclPtr<MetricField>::Create( pParent, WB_TABSTOP|WB_IGNORETAB| WB_NOBORDER) );
425 mpMetric->SetUnit( FUNIT_PERCENT );
426 mpMetric->SetMin( 0 );
427 mpMetric->SetMax( 1000 );
429 mpMenu = new PopupMenu(SdResId( RID_CUSTOMANIMATION_FONTSIZE_POPUP ) );
430 mpControl = VclPtr<DropdownMenuBox>::Create( pParent, mpMetric, mpMenu );
431 mpControl->SetMenuSelectHdl( LINK( this, CharHeightPropertyBox, implMenuSelectHdl ));
432 mpControl->SetModifyHdl( rModifyHdl );
433 mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_CHARHEIGHTPROPERTYBOX );
435 OUString aPresetId;
436 setValue( rValue, aPresetId );
439 CharHeightPropertyBox::~CharHeightPropertyBox()
441 mpControl.disposeAndClear();
444 IMPL_LINK_TYPED( CharHeightPropertyBox, implMenuSelectHdl, MenuButton*, pPb, void )
446 long nValue = 100;
447 switch( pPb->GetCurItemId() )
449 case CM_SIZE_25: nValue = 25; break;
450 case CM_SIZE_50: nValue = 50; break;
451 case CM_SIZE_150: nValue = 150; break;
452 case CM_SIZE_400: nValue = 400; break;
454 mpMetric->SetValue( nValue );
455 mpMetric->Modify();
458 void CharHeightPropertyBox::setValue( const Any& rValue, const OUString& )
460 if( mpMetric.get() )
462 double fValue = 0.0;
463 rValue >>= fValue;
464 mpMetric->SetValue( (long)(fValue * 100.0) );
468 Any CharHeightPropertyBox::getValue()
470 return makeAny( (double)((double)mpMetric->GetValue() / 100.0) );
473 Control* CharHeightPropertyBox::getControl()
475 return mpControl;
478 class TransparencyPropertyBox : public PropertySubControl
480 public:
481 TransparencyPropertyBox( sal_Int32 nControlType, vcl::Window* pParent, const Any& rValue, const Link<>& rModifyHdl );
482 virtual ~TransparencyPropertyBox();
484 virtual Any getValue() SAL_OVERRIDE;
485 virtual void setValue( const Any& rValue, const OUString& rPresetId ) SAL_OVERRIDE;
487 virtual Control* getControl() SAL_OVERRIDE;
489 DECL_LINK_TYPED( implMenuSelectHdl, MenuButton*, void );
490 DECL_LINK(implModifyHdl, void *);
492 void updateMenu();
494 private:
495 VclPtr<DropdownMenuBox> mpControl;
496 PopupMenu* mpMenu;
497 VclPtr<MetricField> mpMetric;
498 Link<> maModifyHdl;
501 TransparencyPropertyBox::TransparencyPropertyBox( sal_Int32 nControlType, vcl::Window* pParent, const Any& rValue, const Link<>& rModifyHdl )
502 : PropertySubControl( nControlType )
503 , maModifyHdl( rModifyHdl )
505 mpMetric.set( VclPtr<MetricField>::Create( pParent ,WB_TABSTOP|WB_IGNORETAB| WB_NOBORDER) );
506 mpMetric->SetUnit( FUNIT_PERCENT );
507 mpMetric->SetMin( 0 );
508 mpMetric->SetMax( 100 );
510 mpMenu = new PopupMenu();
511 for( sal_Int32 i = 25; i < 101; i += 25 )
513 OUString aStr(unicode::formatPercent(i,
514 Application::GetSettings().GetUILanguageTag()));
515 mpMenu->InsertItem( i, aStr );
518 mpControl = VclPtr<DropdownMenuBox>::Create( pParent, mpMetric, mpMenu );
519 mpControl->SetMenuSelectHdl( LINK( this, TransparencyPropertyBox, implMenuSelectHdl ));
520 mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_TRANSPARENCYPROPERTYBOX );
522 Link<> aLink( LINK( this, TransparencyPropertyBox, implModifyHdl ) );
523 mpControl->SetModifyHdl( aLink );
525 OUString aPresetId;
526 setValue( rValue, aPresetId );
529 TransparencyPropertyBox::~TransparencyPropertyBox()
531 mpControl.disposeAndClear();
534 void TransparencyPropertyBox::updateMenu()
536 sal_Int64 nValue = mpMetric->GetValue();
537 for( sal_uInt16 i = 25; i < 101; i += 25 )
538 mpMenu->CheckItem( i, nValue == i );
541 IMPL_LINK_NOARG(TransparencyPropertyBox, implModifyHdl)
543 updateMenu();
544 maModifyHdl.Call(mpMetric.get());
546 return 0;
549 IMPL_LINK_TYPED( TransparencyPropertyBox, implMenuSelectHdl, MenuButton*, pPb, void )
551 if( pPb->GetCurItemId() != mpMetric->GetValue() )
553 mpMetric->SetValue( pPb->GetCurItemId() );
554 mpMetric->Modify();
558 void TransparencyPropertyBox::setValue( const Any& rValue, const OUString& )
560 if( mpMetric.get() )
562 double fValue = 0.0;
563 rValue >>= fValue;
564 long nValue = (long)(fValue * 100);
565 mpMetric->SetValue( nValue );
566 updateMenu();
570 Any TransparencyPropertyBox::getValue()
572 return makeAny( (double)((double)mpMetric->GetValue()) / 100.0 );
575 Control* TransparencyPropertyBox::getControl()
577 return mpControl;
580 class RotationPropertyBox : public PropertySubControl
582 public:
583 RotationPropertyBox( sal_Int32 nControlType, vcl::Window* pParent, const Any& rValue, const Link<>& rModifyHdl );
584 virtual ~RotationPropertyBox();
586 virtual Any getValue() SAL_OVERRIDE;
587 virtual void setValue( const Any& rValue, const OUString& ) SAL_OVERRIDE;
589 virtual Control* getControl() SAL_OVERRIDE;
591 DECL_LINK_TYPED( implMenuSelectHdl, MenuButton*, void );
592 DECL_LINK(implModifyHdl, void *);
594 void updateMenu();
596 private:
597 VclPtr<DropdownMenuBox> mpControl;
598 PopupMenu* mpMenu;
599 VclPtr<MetricField> mpMetric;
600 Link<> maModifyHdl;
603 RotationPropertyBox::RotationPropertyBox( sal_Int32 nControlType, vcl::Window* pParent, const Any& rValue, const Link<>& rModifyHdl )
604 : PropertySubControl( nControlType )
605 , maModifyHdl( rModifyHdl )
607 mpMetric.set( VclPtr<MetricField>::Create( pParent ,WB_TABSTOP|WB_IGNORETAB| WB_NOBORDER) );
608 mpMetric->SetUnit( FUNIT_CUSTOM );
609 mpMetric->SetCustomUnitText( OUString( sal_Unicode(0xb0)) ); // degree sign
610 mpMetric->SetMin( -10000 );
611 mpMetric->SetMax( 10000 );
613 mpMenu = new PopupMenu(SdResId( RID_CUSTOMANIMATION_ROTATION_POPUP ) );
614 mpControl = VclPtr<DropdownMenuBox>::Create( pParent, mpMetric, mpMenu );
615 mpControl->SetMenuSelectHdl( LINK( this, RotationPropertyBox, implMenuSelectHdl ));
616 mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_ROTATIONPROPERTYBOX );
618 Link<> aLink( LINK( this, RotationPropertyBox, implModifyHdl ) );
619 mpControl->SetModifyHdl( aLink );
621 OUString aPresetId;
622 setValue( rValue, aPresetId );
625 RotationPropertyBox::~RotationPropertyBox()
627 mpControl.disposeAndClear();
630 void RotationPropertyBox::updateMenu()
632 sal_Int64 nValue = mpMetric->GetValue();
633 bool bDirection = nValue >= 0;
634 nValue = (nValue < 0 ? -nValue : nValue);
636 mpMenu->CheckItem( CM_QUARTER_SPIN, nValue == 90 );
637 mpMenu->CheckItem( CM_HALF_SPIN, nValue == 180 );
638 mpMenu->CheckItem( CM_FULL_SPIN, nValue == 360 );
639 mpMenu->CheckItem( CM_TWO_SPINS, nValue == 720 );
641 mpMenu->CheckItem( CM_CLOCKWISE, bDirection );
642 mpMenu->CheckItem( CM_COUNTERCLOCKWISE, !bDirection );
645 IMPL_LINK_NOARG(RotationPropertyBox, implModifyHdl)
647 updateMenu();
648 maModifyHdl.Call(mpMetric.get());
650 return 0;
653 IMPL_LINK_TYPED( RotationPropertyBox, implMenuSelectHdl, MenuButton*, pPb, void )
655 sal_Int64 nValue = mpMetric->GetValue();
656 bool bDirection = nValue >= 0;
657 nValue = (nValue < 0 ? -nValue : nValue);
659 switch( pPb->GetCurItemId() )
661 case CM_QUARTER_SPIN: nValue = 90; break;
662 case CM_HALF_SPIN: nValue = 180; break;
663 case CM_FULL_SPIN: nValue = 360; break;
664 case CM_TWO_SPINS: nValue = 720; break;
666 case CM_CLOCKWISE: bDirection = true; break;
667 case CM_COUNTERCLOCKWISE: bDirection = false; break;
671 if( !bDirection )
672 nValue = -nValue;
674 if( nValue != mpMetric->GetValue() )
676 mpMetric->SetValue( nValue );
677 mpMetric->Modify();
681 void RotationPropertyBox::setValue( const Any& rValue, const OUString& )
683 if( mpMetric.get() )
685 double fValue = 0.0;
686 rValue >>= fValue;
687 long nValue = (long)(fValue);
688 mpMetric->SetValue( nValue );
689 updateMenu();
693 Any RotationPropertyBox::getValue()
695 return makeAny( (double)((double)mpMetric->GetValue()) );
698 Control* RotationPropertyBox::getControl()
700 return mpControl;
703 class ScalePropertyBox : public PropertySubControl
705 public:
706 ScalePropertyBox( sal_Int32 nControlType, vcl::Window* pParent, const Any& rValue, const Link<>& rModifyHdl );
707 virtual ~ScalePropertyBox();
709 virtual Any getValue() SAL_OVERRIDE;
710 virtual void setValue( const Any& rValue, const OUString& ) SAL_OVERRIDE;
712 virtual Control* getControl() SAL_OVERRIDE;
714 DECL_LINK_TYPED( implMenuSelectHdl, MenuButton*, void );
715 DECL_LINK(implModifyHdl, void *);
717 void updateMenu();
719 private:
720 VclPtr<DropdownMenuBox> mpControl;
721 PopupMenu* mpMenu;
722 VclPtr<MetricField> mpMetric;
723 Link<> maModifyHdl;
724 int mnDirection;
727 ScalePropertyBox::ScalePropertyBox( sal_Int32 nControlType, vcl::Window* pParent, const Any& rValue, const Link<>& rModifyHdl )
728 : PropertySubControl( nControlType )
729 , maModifyHdl( rModifyHdl )
731 mpMetric.set( VclPtr<MetricField>::Create( pParent ,WB_TABSTOP|WB_IGNORETAB| WB_NOBORDER) );
732 mpMetric->SetUnit( FUNIT_PERCENT );
733 mpMetric->SetMin( 0 );
734 mpMetric->SetMax( 10000 );
736 mpMenu = new PopupMenu(SdResId( RID_CUSTOMANIMATION_SCALE_POPUP ) );
737 mpControl = VclPtr<DropdownMenuBox>::Create( pParent, mpMetric, mpMenu );
738 mpControl->SetMenuSelectHdl( LINK( this, ScalePropertyBox, implMenuSelectHdl ));
739 mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_SCALEPROPERTYBOX );
741 Link<> aLink( LINK( this, ScalePropertyBox, implModifyHdl ) );
742 mpControl->SetModifyHdl( aLink );
744 OUString aPresetId;
745 setValue( rValue, aPresetId );
748 ScalePropertyBox::~ScalePropertyBox()
750 mpControl.disposeAndClear();
753 void ScalePropertyBox::updateMenu()
755 sal_Int64 nValue = mpMetric->GetValue();
757 mpMenu->CheckItem( 25, nValue == 25 );
758 mpMenu->CheckItem( 50, nValue == 50 );
759 mpMenu->CheckItem( 150, nValue == 150 );
760 mpMenu->CheckItem( 400, nValue == 400 );
762 mpMenu->CheckItem( CM_HORIZONTAL, mnDirection == 1 );
763 mpMenu->CheckItem( CM_VERTICAL, mnDirection == 2 );
764 mpMenu->CheckItem( CM_BOTH, mnDirection == 3 );
767 IMPL_LINK_NOARG(ScalePropertyBox, implModifyHdl)
769 updateMenu();
770 maModifyHdl.Call(mpMetric.get());
772 return 0;
775 IMPL_LINK_TYPED( ScalePropertyBox, implMenuSelectHdl, MenuButton*, pPb, void )
777 sal_Int64 nValue = mpMetric->GetValue();
779 int nDirection = mnDirection;
781 switch( pPb->GetCurItemId() )
783 case CM_HORIZONTAL: nDirection = 1; break;
784 case CM_VERTICAL: nDirection = 2; break;
785 case CM_BOTH: nDirection = 3; break;
787 default:
788 nValue = pPb->GetCurItemId();
791 bool bModified = false;
793 if( nDirection != mnDirection )
795 mnDirection = nDirection;
796 bModified = true;
799 if( nValue != mpMetric->GetValue() )
801 mpMetric->SetValue( nValue );
802 bModified = true;
805 if( bModified )
807 mpMetric->Modify();
808 updateMenu();
812 void ScalePropertyBox::setValue( const Any& rValue, const OUString& )
814 if( mpMetric.get() )
816 ValuePair aValues;
817 rValue >>= aValues;
819 double fValue1 = 0.0;
820 double fValue2 = 0.0;
822 aValues.First >>= fValue1;
823 aValues.Second >>= fValue2;
825 if( fValue2 == 0.0 )
826 mnDirection = 1;
827 else if( fValue1 == 0.0 )
828 mnDirection = 2;
829 else
830 mnDirection = 3;
832 long nValue;
833 if( fValue1 )
834 nValue = (long)(fValue1 * 100.0);
835 else
836 nValue = (long)(fValue2 * 100.0);
837 mpMetric->SetValue( nValue );
838 updateMenu();
842 Any ScalePropertyBox::getValue()
844 double fValue1 = (double)((double)mpMetric->GetValue() / 100.0);
845 double fValue2 = fValue1;
847 if( mnDirection == 1 )
848 fValue2 = 0.0;
849 else if( mnDirection == 2 )
850 fValue1 = 0.0;
852 ValuePair aValues;
853 aValues.First <<= fValue1;
854 aValues.Second <<= fValue2;
856 return makeAny( aValues );
859 Control* ScalePropertyBox::getControl()
861 return mpControl;
864 class FontStylePropertyBox : public PropertySubControl
866 public:
867 FontStylePropertyBox( sal_Int32 nControlType, vcl::Window* pParent, const Any& rValue, const Link<>& rModifyHdl );
868 virtual ~FontStylePropertyBox();
870 virtual Any getValue() SAL_OVERRIDE;
871 virtual void setValue( const Any& rValue, const OUString& ) SAL_OVERRIDE;
873 virtual Control* getControl() SAL_OVERRIDE;
875 DECL_LINK_TYPED( implMenuSelectHdl, MenuButton*, void );
877 void update();
879 private:
880 VclPtr<DropdownMenuBox> mpControl;
881 PopupMenu* mpMenu;
882 VclPtr<Edit> mpEdit;
883 Link<> maModifyHdl;
885 float mfFontWeight;
886 awt::FontSlant meFontSlant;
887 sal_Int16 mnFontUnderline;
890 FontStylePropertyBox::FontStylePropertyBox( sal_Int32 nControlType, vcl::Window* pParent, const Any& rValue, const Link<>& rModifyHdl )
891 : PropertySubControl( nControlType )
892 , maModifyHdl( rModifyHdl )
894 mpEdit.set( VclPtr<Edit>::Create( pParent, WB_TABSTOP|WB_IGNORETAB|WB_NOBORDER|WB_READONLY) );
895 mpEdit->SetText( SD_RESSTR(STR_CUSTOMANIMATION_SAMPLE) );
897 mpMenu = new PopupMenu(SdResId( RID_CUSTOMANIMATION_FONTSTYLE_POPUP ) );
898 mpControl = VclPtr<DropdownMenuBox>::Create( pParent, mpEdit, mpMenu );
899 mpControl->SetMenuSelectHdl( LINK( this, FontStylePropertyBox, implMenuSelectHdl ));
900 mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_FONTSTYLEPROPERTYBOX );
902 OUString aPresetId;
903 setValue( rValue, aPresetId );
906 FontStylePropertyBox::~FontStylePropertyBox()
908 mpControl.disposeAndClear();
911 void FontStylePropertyBox::update()
913 // update menu
914 mpMenu->CheckItem( CM_BOLD, mfFontWeight == awt::FontWeight::BOLD );
915 mpMenu->CheckItem( CM_ITALIC, meFontSlant == awt::FontSlant_ITALIC);
916 mpMenu->CheckItem( CM_UNDERLINED, mnFontUnderline != awt::FontUnderline::NONE );
918 // update sample edit
919 vcl::Font aFont( mpEdit->GetFont() );
920 aFont.SetWeight( mfFontWeight == awt::FontWeight::BOLD ? WEIGHT_BOLD : WEIGHT_NORMAL );
921 aFont.SetItalic( meFontSlant == awt::FontSlant_ITALIC ? ITALIC_NORMAL : ITALIC_NONE );
922 aFont.SetUnderline( mnFontUnderline == awt::FontUnderline::NONE ? UNDERLINE_NONE : UNDERLINE_SINGLE );
923 mpEdit->SetFont( aFont );
924 mpEdit->Invalidate();
927 IMPL_LINK_TYPED( FontStylePropertyBox, implMenuSelectHdl, MenuButton*, pPb, void )
929 switch( pPb->GetCurItemId() )
931 case CM_BOLD:
932 if( mfFontWeight == awt::FontWeight::BOLD )
933 mfFontWeight = awt::FontWeight::NORMAL;
934 else
935 mfFontWeight = awt::FontWeight::BOLD;
936 break;
937 case CM_ITALIC:
938 if( meFontSlant == awt::FontSlant_ITALIC )
939 meFontSlant = awt::FontSlant_NONE;
940 else
941 meFontSlant = awt::FontSlant_ITALIC;
942 break;
943 case CM_UNDERLINED:
944 if( mnFontUnderline == awt::FontUnderline::SINGLE )
945 mnFontUnderline = awt::FontUnderline::NONE;
946 else
947 mnFontUnderline = awt::FontUnderline::SINGLE;
948 break;
949 default:
950 return;
953 update();
954 maModifyHdl.Call(mpEdit.get());
957 void FontStylePropertyBox::setValue( const Any& rValue, const OUString& )
959 Sequence<Any> aValues;
960 rValue >>= aValues;
962 aValues[0] >>= mfFontWeight;
963 aValues[1] >>= meFontSlant;
964 aValues[2] >>= mnFontUnderline;
966 update();
969 Any FontStylePropertyBox::getValue()
971 Sequence<Any> aValues(3);
972 aValues[0] <<= mfFontWeight;
973 aValues[1] <<= meFontSlant;
974 aValues[2] <<= mnFontUnderline;
975 return makeAny( aValues );
978 Control* FontStylePropertyBox::getControl()
980 return mpControl;
983 class CustomAnimationEffectTabPage : public TabPage
985 public:
986 CustomAnimationEffectTabPage( vcl::Window* pParent, const STLPropertySet* pSet );
987 virtual ~CustomAnimationEffectTabPage();
988 virtual void dispose() SAL_OVERRIDE;
990 void update( STLPropertySet* pSet );
991 DECL_LINK( implSelectHdl, Control* );
993 private:
994 void updateControlStates();
995 void fillSoundListBox();
996 void clearSoundListBox();
997 sal_Int32 getSoundObject( const OUString& rStr );
998 void openSoundFileDialog();
999 void onSoundPreview();
1001 private:
1002 ::std::vector< OUString > maSoundList;
1003 bool mbHasText;
1004 const STLPropertySet* mpSet;
1006 VclPtr<VclFrame> mpSettings;
1007 VclPtr<FixedText> mpFTProperty1;
1008 VclPtr<PropertyControl> mpLBProperty1;
1009 VclPtr<VclHBox> mpPlaceholderBox;
1010 VclPtr<CheckBox> mpCBSmoothStart;
1011 VclPtr<CheckBox> mpCBSmoothEnd;
1013 VclPtr<FixedText> mpFTSound;
1014 VclPtr<ListBox> mpLBSound;
1015 VclPtr<PushButton> mpPBSoundPreview;
1016 VclPtr<FixedText> mpFTAfterEffect;
1017 VclPtr<ListBox> mpLBAfterEffect;
1018 VclPtr<FixedText> mpFTDimColor;
1019 VclPtr<ColorListBox> mpCLBDimColor;
1020 VclPtr<FixedText> mpFTTextAnim;
1021 VclPtr<ListBox> mpLBTextAnim;
1022 VclPtr<MetricField> mpMFTextDelay;
1023 VclPtr<FixedText> mpFTTextDelay;
1025 ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > mxPlayer;
1028 CustomAnimationEffectTabPage::CustomAnimationEffectTabPage( vcl::Window* pParent, const STLPropertySet* pSet )
1029 : TabPage( pParent, "EffectTab", "modules/simpress/ui/customanimationeffecttab.ui" ), mbHasText( false ), mpSet(pSet )
1031 get(mpSettings, "settings" );
1032 get(mpFTProperty1, "prop_label1" );
1033 get(mpLBProperty1, "prop_list1" );
1034 get(mpPlaceholderBox, "placeholder" );
1035 get(mpCBSmoothStart, "smooth_start" );
1036 get(mpCBSmoothEnd, "smooth_end" );
1037 get(mpFTSound, "sound_label");
1038 get(mpLBSound, "sound_list" );
1039 get(mpPBSoundPreview, "sound_preview" );
1040 get(mpFTAfterEffect, "aeffect_label" );
1041 get(mpLBAfterEffect, "aeffect_list" );
1042 get(mpFTDimColor, "dim_color_label" );
1043 get(mpCLBDimColor, "dim_color_list" );
1044 get(mpFTTextAnim, "text_animation_label" );
1045 get(mpLBTextAnim, "text_animation_list" );
1046 get(mpMFTextDelay,"text_delay" );
1047 get(mpFTTextDelay,"text_delay_label" );
1049 // fill the soundbox
1050 fillSoundListBox();
1052 mpLBSound->SetSelectHdl( LINK( this, CustomAnimationEffectTabPage, implSelectHdl ) );
1054 mpPBSoundPreview->SetClickHdl( LINK( this, CustomAnimationEffectTabPage, implSelectHdl ) );
1056 // fill the color box
1057 SfxObjectShell* pDocSh = SfxObjectShell::Current();
1058 DBG_ASSERT( pDocSh, "DocShell not found!" );
1059 XColorListRef pColorList;
1060 const SfxPoolItem* pItem = NULL;
1062 if ( pDocSh && ( (pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) != 0 ) )
1063 pColorList = static_cast<const SvxColorListItem*>(pItem)->GetColorList();
1065 if ( !pColorList.is() )
1066 pColorList = XColorList::CreateStdColorList();
1068 mpCLBDimColor->SetUpdateMode( false );
1070 for ( long i = 0; i < pColorList->Count(); i++ )
1072 XColorEntry* pEntry = pColorList->GetColor(i);
1073 mpCLBDimColor->InsertEntry( pEntry->GetColor(), pEntry->GetName() );
1076 mpCLBDimColor->SetUpdateMode( true );
1078 // only show settings if all selected effects have the same preset-id
1079 if( pSet->getPropertyState( nHandlePresetId ) != STLPropertyState_AMBIGUOUS )
1081 OUString aPresetId;
1082 pSet->getPropertyValue( nHandlePresetId ) >>= aPresetId;
1084 // property 1
1086 if( pSet->getPropertyState( nHandleProperty1Type ) != STLPropertyState_AMBIGUOUS )
1088 sal_Int32 nType = 0;
1089 pSet->getPropertyValue( nHandleProperty1Type ) >>= nType;
1091 if( nType != nPropertyTypeNone )
1093 // set ui name for property at fixed text
1094 OUString aPropertyName( getPropertyName( nType ) );
1096 if( !aPropertyName.isEmpty() )
1098 mpSettings->Show();
1099 mpFTProperty1->SetText( aPropertyName );
1102 // get property value
1103 const Any aValue( pSet->getPropertyValue( nHandleProperty1Value ) );
1105 Link<> aModifyLink;
1106 // create property sub control
1107 mpLBProperty1->setSubControl( PropertySubControl::create( nType, mpPlaceholderBox, aValue, aPresetId, aModifyLink ));
1111 mpFTProperty1->Enable( mpLBProperty1->IsEnabled() );
1113 // accelerate & deccelerate
1115 if( pSet->getPropertyState( nHandleAccelerate ) == STLPropertyState_DIRECT )
1117 mpCBSmoothStart->Show();
1118 mpCBSmoothEnd->Show();
1120 double fTemp = 0.0;
1121 pSet->getPropertyValue( nHandleAccelerate ) >>= fTemp;
1122 mpCBSmoothStart->Check( fTemp > 0.0 );
1124 pSet->getPropertyValue( nHandleDecelerate ) >>= fTemp;
1125 mpCBSmoothEnd->Check( fTemp > 0.0 );
1129 // init after effect controls
1131 mpLBAfterEffect->SetSelectHdl( LINK( this, CustomAnimationEffectTabPage, implSelectHdl ) );
1132 mpLBTextAnim->SetSelectHdl( LINK( this, CustomAnimationEffectTabPage, implSelectHdl ) );
1134 if( (pSet->getPropertyState( nHandleHasAfterEffect ) != STLPropertyState_AMBIGUOUS) &&
1135 (pSet->getPropertyState( nHandleAfterEffectOnNextEffect ) != STLPropertyState_AMBIGUOUS) &&
1136 (pSet->getPropertyState( nHandleDimColor ) != STLPropertyState_AMBIGUOUS))
1138 bool bHasAfterEffect = false;
1139 pSet->getPropertyValue( nHandleHasAfterEffect ) >>= bHasAfterEffect;
1141 sal_Int32 nPos = 0;
1142 if( bHasAfterEffect )
1144 nPos++;
1146 bool bAfterEffectOnNextClick = false;
1147 pSet->getPropertyValue( nHandleAfterEffectOnNextEffect ) >>= bAfterEffectOnNextClick;
1148 Any aDimColor( pSet->getPropertyValue( nHandleDimColor ) );
1150 if( aDimColor.hasValue() )
1152 sal_Int32 nColor = 0;
1153 aDimColor >>= nColor;
1154 Color aColor( nColor );
1155 sal_Int32 nColorPos = mpCLBDimColor->GetEntryPos( aColor );
1156 if ( LISTBOX_ENTRY_NOTFOUND != nColorPos )
1157 mpCLBDimColor->SelectEntryPos( nColorPos );
1158 else
1159 mpCLBDimColor->SelectEntryPos(
1160 mpCLBDimColor->InsertEntry( aColor, SVX_RESSTR(RID_SVXSTR_COLOR_USER) ) );
1162 else
1164 nPos++;
1165 if( bAfterEffectOnNextClick )
1166 nPos++;
1170 mpLBAfterEffect->SelectEntryPos( nPos );
1173 if( pSet->getPropertyState( nHandleHasText ) != STLPropertyState_AMBIGUOUS )
1174 pSet->getPropertyValue( nHandleHasText ) >>= mbHasText;
1176 if( mbHasText )
1178 if( pSet->getPropertyState( nHandleIterateType ) != STLPropertyState_AMBIGUOUS)
1180 sal_Int32 nPos = LISTBOX_ENTRY_NOTFOUND;
1182 sal_Int32 nIterateType = 0;
1183 pSet->getPropertyValue( nHandleIterateType ) >>= nIterateType;
1184 switch( nIterateType )
1186 case TextAnimationType::BY_PARAGRAPH: nPos = 0; break;
1187 case TextAnimationType::BY_WORD: nPos = 1; break;
1188 case TextAnimationType::BY_LETTER: nPos = 2; break;
1191 mpLBTextAnim->SelectEntryPos( nPos );
1194 if( pSet->getPropertyState( nHandleIterateInterval ) )
1196 double fIterateInterval = 0.0;
1197 pSet->getPropertyValue( nHandleIterateInterval ) >>= fIterateInterval;
1198 mpMFTextDelay->SetValue( (long)(fIterateInterval*10) );
1201 else
1203 mpFTTextAnim->Enable( false );
1204 mpLBTextAnim->Enable( false );
1205 mpMFTextDelay->Enable( false );
1206 mpFTTextDelay->Enable( false );
1210 if( pSet->getPropertyState( nHandleSoundURL ) != STLPropertyState_AMBIGUOUS )
1212 sal_Int32 nPos = 0;
1214 const Any aValue( pSet->getPropertyValue( nHandleSoundURL ) );
1216 if( aValue.getValueType() == ::cppu::UnoType<sal_Bool>::get() )
1218 nPos = 1;
1220 else
1222 OUString aSoundURL;
1223 aValue >>= aSoundURL;
1225 if( !aSoundURL.isEmpty() )
1227 sal_uLong i;
1228 for( i = 0; i < maSoundList.size(); i++ )
1230 OUString aString = maSoundList[ i ];
1231 if( aString == aSoundURL )
1233 nPos = (sal_Int32)i+2;
1234 break;
1238 if( nPos == 0 )
1240 nPos = (sal_Int32)maSoundList.size()+2;
1241 maSoundList.push_back( aSoundURL );
1242 INetURLObject aURL( aSoundURL );
1243 nPos = mpLBSound->InsertEntry( aURL.GetBase(), nPos );
1248 if( nPos != LISTBOX_ENTRY_NOTFOUND )
1249 mpLBSound->SelectEntryPos( nPos );
1252 updateControlStates();
1256 CustomAnimationEffectTabPage::~CustomAnimationEffectTabPage()
1258 disposeOnce();
1261 void CustomAnimationEffectTabPage::dispose()
1263 clearSoundListBox();
1264 mpSettings.clear();
1265 mpFTProperty1.clear();
1266 mpLBProperty1.clear();
1267 mpPlaceholderBox.clear();
1268 mpCBSmoothStart.clear();
1269 mpCBSmoothEnd.clear();
1270 mpFTSound.clear();
1271 mpLBSound.clear();
1272 mpPBSoundPreview.clear();
1273 mpFTAfterEffect.clear();
1274 mpLBAfterEffect.clear();
1275 mpFTDimColor.clear();
1276 mpCLBDimColor.clear();
1277 mpFTTextAnim.clear();
1278 mpLBTextAnim.clear();
1279 mpMFTextDelay.clear();
1280 mpFTTextDelay.clear();
1281 TabPage::dispose();
1284 void CustomAnimationEffectTabPage::updateControlStates()
1286 sal_Int32 nPos = mpLBAfterEffect->GetSelectEntryPos();
1287 mpCLBDimColor->Enable( nPos == 1 );
1288 mpFTDimColor->Enable( nPos == 1 );
1290 if( mbHasText )
1292 nPos = mpLBTextAnim->GetSelectEntryPos();
1293 mpMFTextDelay->Enable( nPos != 0 );
1294 mpFTTextDelay->Enable( nPos != 0 );
1297 nPos = mpLBSound->GetSelectEntryPos();
1298 mpPBSoundPreview->Enable( nPos >= 2 );
1301 IMPL_LINK( CustomAnimationEffectTabPage, implSelectHdl, Control*, pControl )
1303 if( pControl == mpLBAfterEffect )
1305 sal_Int32 nPos = static_cast<ListBox*>( mpLBAfterEffect )->GetSelectEntryPos();
1306 if( nPos == 1 )
1308 if( mpCLBDimColor->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND )
1309 mpCLBDimColor->SelectEntryPos(0);
1312 else if( pControl == mpLBTextAnim )
1314 if( mpMFTextDelay->GetValue() == 0 )
1315 mpMFTextDelay->SetValue( 100 );
1317 else if( pControl == mpLBSound )
1319 sal_Int32 nPos = mpLBSound->GetSelectEntryPos();
1320 if( nPos == (mpLBSound->GetEntryCount() - 1) )
1322 openSoundFileDialog();
1325 else if( pControl == mpPBSoundPreview )
1327 onSoundPreview();
1330 updateControlStates();
1331 return 0;
1334 void CustomAnimationEffectTabPage::update( STLPropertySet* pSet )
1336 if( mpLBProperty1->getSubControl() )
1338 Any aNewValue( mpLBProperty1->getSubControl()->getValue() );
1339 Any aOldValue;
1340 if( mpSet->getPropertyState( nHandleProperty1Value ) != STLPropertyState_AMBIGUOUS)
1341 aOldValue = mpSet->getPropertyValue( nHandleProperty1Value );
1343 if( aOldValue != aNewValue )
1344 pSet->setPropertyValue( nHandleProperty1Value, aNewValue );
1347 if( mpCBSmoothStart->IsVisible() )
1349 // set selected value for accelerate if different then in original set
1351 double fTemp = mpCBSmoothStart->IsChecked() ? 0.5 : 0.0;
1353 double fOldTemp = 0.0;
1354 if(mpSet->getPropertyState( nHandleAccelerate ) != STLPropertyState_AMBIGUOUS)
1355 mpSet->getPropertyValue( nHandleAccelerate ) >>= fOldTemp;
1356 else
1357 fOldTemp = -2.0;
1359 if( fOldTemp != fTemp )
1360 pSet->setPropertyValue( nHandleAccelerate, makeAny( fTemp ) );
1362 // set selected value for decelerate if different then in original set
1363 fTemp = mpCBSmoothEnd->IsChecked() ? 0.5 : 0.0;
1365 if(mpSet->getPropertyState( nHandleDecelerate ) != STLPropertyState_AMBIGUOUS)
1366 mpSet->getPropertyValue( nHandleDecelerate ) >>= fOldTemp;
1367 else
1368 fOldTemp = -2.0;
1370 if( fOldTemp != fTemp )
1371 pSet->setPropertyValue( nHandleDecelerate, makeAny( fTemp ) );
1374 sal_Int32 nPos = mpLBAfterEffect->GetSelectEntryPos();
1375 if( nPos != LISTBOX_ENTRY_NOTFOUND )
1377 bool bAfterEffect = nPos != 0;
1379 bool bOldAfterEffect = false;
1381 if(mpSet->getPropertyState( nHandleHasAfterEffect ) != STLPropertyState_AMBIGUOUS)
1382 mpSet->getPropertyValue( nHandleHasAfterEffect ) >>= bOldAfterEffect;
1383 else
1384 bOldAfterEffect = !bAfterEffect;
1386 if( bOldAfterEffect != bAfterEffect )
1387 pSet->setPropertyValue( nHandleHasAfterEffect, makeAny( bAfterEffect ) );
1389 Any aDimColor;
1390 if( nPos == 1 )
1392 Color aSelectedColor;
1393 if ( mpCLBDimColor->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
1394 aSelectedColor = mpCLBDimColor->GetSelectEntryColor();
1396 aDimColor = makeAny( (sal_Int32)aSelectedColor.GetRGBColor() );
1399 if( (mpSet->getPropertyState( nHandleDimColor ) == STLPropertyState_AMBIGUOUS) ||
1400 (mpSet->getPropertyValue( nHandleDimColor ) != aDimColor) )
1401 pSet->setPropertyValue( nHandleDimColor, aDimColor );
1403 bool bAfterEffectOnNextEffect = nPos != 2;
1404 bool bOldAfterEffectOnNextEffect = !bAfterEffectOnNextEffect;
1406 if( mpSet->getPropertyState( nHandleAfterEffectOnNextEffect ) != STLPropertyState_AMBIGUOUS)
1407 mpSet->getPropertyValue( nHandleAfterEffectOnNextEffect ) >>= bOldAfterEffectOnNextEffect;
1409 if( bAfterEffectOnNextEffect != bOldAfterEffectOnNextEffect )
1410 pSet->setPropertyValue( nHandleAfterEffectOnNextEffect, makeAny( bAfterEffectOnNextEffect ) );
1413 nPos = mpLBTextAnim->GetSelectEntryPos();
1414 if( nPos != LISTBOX_ENTRY_NOTFOUND )
1416 sal_Int16 nIterateType;
1418 switch( nPos )
1420 case 1: nIterateType = TextAnimationType::BY_WORD; break;
1421 case 2: nIterateType = TextAnimationType::BY_LETTER; break;
1422 default:
1423 nIterateType = TextAnimationType::BY_PARAGRAPH;
1426 sal_Int16 nOldIterateType = nIterateType-1;
1428 if(mpSet->getPropertyState( nHandleIterateType ) != STLPropertyState_AMBIGUOUS)
1429 mpSet->getPropertyValue( nHandleIterateType ) >>= nOldIterateType;
1431 if( nIterateType != nOldIterateType )
1432 pSet->setPropertyValue( nHandleIterateType, makeAny( nIterateType ) );
1436 double fIterateInterval = static_cast< double >( mpMFTextDelay->GetValue() ) / 10;
1437 double fOldIterateInterval = -1.0;
1439 if( mpSet->getPropertyState( nHandleIterateInterval ) != STLPropertyState_AMBIGUOUS )
1440 mpSet->getPropertyValue( nHandleIterateInterval ) >>= fOldIterateInterval;
1442 if( fIterateInterval != fOldIterateInterval )
1443 pSet->setPropertyValue( nHandleIterateInterval, makeAny( fIterateInterval ) );
1446 nPos = mpLBSound->GetSelectEntryPos();
1447 if( nPos != LISTBOX_ENTRY_NOTFOUND )
1449 Any aNewSoundURL, aOldSoundURL( makeAny( (sal_Int32) 0 ) );
1451 if( nPos == 0 )
1453 // 0 means no sound, so leave any empty
1455 else if( nPos == 1 )
1457 // this means stop sound
1458 aNewSoundURL = makeAny( true );
1460 else
1462 OUString aSoundURL( maSoundList[ nPos-2 ] );
1463 aNewSoundURL = makeAny( aSoundURL );
1466 if( mpSet->getPropertyState( nHandleSoundURL ) != STLPropertyState_AMBIGUOUS )
1467 mpSet->getPropertyValue( nHandleSoundURL ) >>= aOldSoundURL;
1469 if( aNewSoundURL != aOldSoundURL )
1470 pSet->setPropertyValue( nHandleSoundURL, aNewSoundURL );
1474 void CustomAnimationEffectTabPage::fillSoundListBox()
1476 GalleryExplorer::FillObjList( GALLERY_THEME_SOUNDS, maSoundList );
1477 GalleryExplorer::FillObjList( GALLERY_THEME_USERSOUNDS, maSoundList );
1479 mpLBSound->InsertEntry( SD_RESSTR(STR_CUSTOMANIMATION_NO_SOUND) );
1480 mpLBSound->InsertEntry( SD_RESSTR(STR_CUSTOMANIMATION_STOP_PREVIOUS_SOUND) );
1481 for( size_t i = 0; i < maSoundList.size(); i++ )
1483 OUString aString = maSoundList[ i ];
1484 INetURLObject aURL( aString );
1485 mpLBSound->InsertEntry( aURL.GetBase() );
1487 mpLBSound->InsertEntry( SD_RESSTR(STR_CUSTOMANIMATION_BROWSE_SOUND) );
1490 void CustomAnimationEffectTabPage::clearSoundListBox()
1492 maSoundList.clear();
1493 mpLBSound->Clear();
1496 sal_Int32 CustomAnimationEffectTabPage::getSoundObject( const OUString& rStr )
1498 size_t i;
1499 const size_t nCount = maSoundList.size();
1500 for( i = 0; i < nCount; i++ )
1502 if( maSoundList[ i ].equalsIgnoreAsciiCase(rStr) )
1503 return i+2;
1506 return -1;
1509 void CustomAnimationEffectTabPage::openSoundFileDialog()
1511 SdOpenSoundFileDialog aFileDialog;
1513 OUString aFile( SvtPathOptions().GetGraphicPath() );
1514 aFileDialog.SetPath( aFile );
1516 bool bValidSoundFile = false;
1517 bool bQuitLoop = false;
1518 long nPos = 0;
1520 while( !bQuitLoop && (aFileDialog.Execute() == ERRCODE_NONE) )
1522 aFile = aFileDialog.GetPath();
1523 nPos = getSoundObject( aFile );
1525 if( nPos < 0 ) // not in Soundliste
1527 // try to insert in Gallery
1528 if( GalleryExplorer::InsertURL( GALLERY_THEME_USERSOUNDS, aFile ) )
1530 clearSoundListBox();
1531 fillSoundListBox();
1533 nPos = getSoundObject( aFile );
1534 DBG_ASSERT( nPos >= 0, "sd::CustomAnimationEffectTabPage::openSoundFileDialog(), Recently inserted sound not in list!" );
1536 bValidSoundFile=true;
1537 bQuitLoop=true;
1539 else
1541 OUString aStrWarning(SD_RESSTR(STR_WARNING_NOSOUNDFILE));
1542 aStrWarning = aStrWarning.replaceFirst("%", aFile);
1543 ScopedVclPtrInstance< WarningBox > aWarningBox( nullptr, WB_3DLOOK | WB_RETRY_CANCEL, aStrWarning );
1544 aWarningBox->SetModalInputMode (true);
1545 bQuitLoop = aWarningBox->Execute() != RET_RETRY;
1547 bValidSoundFile=false;
1550 else
1552 bValidSoundFile=true;
1553 bQuitLoop=true;
1557 if( !bValidSoundFile )
1558 nPos = 0;
1560 mpLBSound->SelectEntryPos( nPos );
1563 void CustomAnimationEffectTabPage::onSoundPreview()
1565 const sal_Int32 nPos = mpLBSound->GetSelectEntryPos();
1567 if( nPos >= 2 ) try
1569 const OUString aSoundURL( maSoundList[ nPos-2 ] );
1570 mxPlayer.set( avmedia::MediaWindow::createPlayer( aSoundURL, "" ), uno::UNO_QUERY_THROW );
1571 mxPlayer->start();
1573 catch( uno::Exception& )
1575 OSL_FAIL("CustomAnimationEffectTabPage::onSoundPreview(), exception caught!" );
1579 class CustomAnimationDurationTabPage : public TabPage
1581 public:
1582 CustomAnimationDurationTabPage( vcl::Window* pParent, const STLPropertySet* pSet );
1583 virtual ~CustomAnimationDurationTabPage();
1584 virtual void dispose() SAL_OVERRIDE;
1586 void update( STLPropertySet* pSet );
1588 DECL_LINK( implControlHdl, Control* );
1590 private:
1591 const STLPropertySet* mpSet;
1593 VclPtr<FixedText> mpFTStart;
1594 VclPtr<ListBox> mpLBStart;
1595 VclPtr<FixedText> mpFTStartDelay;
1596 VclPtr<MetricField> mpMFStartDelay;
1597 VclPtr<FixedText> mpFTDuration;
1598 VclPtr<ListBox> mpCBDuration;
1599 VclPtr<FixedText> mpFTRepeat;
1600 VclPtr<ListBox> mpCBRepeat;
1601 VclPtr<CheckBox> mpCBXRewind;
1602 VclPtr<RadioButton> mpRBClickSequence;
1603 VclPtr<RadioButton> mpRBInteractive;
1604 VclPtr<ListBox> mpLBTrigger;
1607 CustomAnimationDurationTabPage::CustomAnimationDurationTabPage(vcl::Window* pParent, const STLPropertySet* pSet)
1608 : TabPage( pParent, "TimingTab", "modules/simpress/ui/customanimationtimingtab.ui" ), mpSet( pSet )
1610 get(mpFTStart,"start_label" );
1611 get(mpLBStart, "start_list" );
1612 get(mpFTStartDelay, "delay_label" );
1613 get(mpMFStartDelay, "delay_value" );
1614 get(mpFTDuration, "duration_label" );
1615 get(mpCBDuration, "duration_list" );
1616 get(mpFTRepeat, "repeat_label" );
1617 get(mpCBRepeat, "repeat_list" );
1618 get(mpCBXRewind, "rewind" );
1619 get(mpRBClickSequence, "rb_click_sequence" );
1620 get(mpRBInteractive, "rb_interactive" );
1621 get(mpLBTrigger, "trigger_list");
1622 mpLBTrigger->set_width_request(approximate_char_width() * 40);
1624 fillRepeatComboBox( mpCBRepeat );
1625 fillDurationComboBox( mpCBDuration );
1627 mpRBClickSequence->SetClickHdl( LINK( this, CustomAnimationDurationTabPage, implControlHdl ) );
1628 mpLBTrigger->SetSelectHdl( LINK( this, CustomAnimationDurationTabPage, implControlHdl ) );
1630 if( pSet->getPropertyState( nHandleStart ) != STLPropertyState_AMBIGUOUS )
1632 sal_Int16 nStart = 0;
1633 pSet->getPropertyValue( nHandleStart ) >>= nStart;
1634 sal_Int32 nPos = 0;
1635 switch( nStart )
1637 case EffectNodeType::WITH_PREVIOUS: nPos = 1; break;
1638 case EffectNodeType::AFTER_PREVIOUS: nPos = 2; break;
1640 mpLBStart->SelectEntryPos( nPos );
1643 if( pSet->getPropertyState( nHandleBegin ) != STLPropertyState_AMBIGUOUS )
1645 double fBegin = 0.0;
1646 pSet->getPropertyValue( nHandleBegin ) >>= fBegin;
1647 mpMFStartDelay->SetValue( (long)(fBegin*10) );
1650 if( pSet->getPropertyState( nHandleDuration ) != STLPropertyState_AMBIGUOUS )
1652 double fDuration = 0.0;
1653 pSet->getPropertyValue( nHandleDuration ) >>= fDuration;
1655 if( fDuration == 0.001 )
1657 mpFTDuration->Disable();
1658 mpCBDuration->Disable();
1659 mpFTRepeat->Disable();
1660 mpCBRepeat->Disable();
1661 mpCBXRewind->Disable();
1663 else
1665 sal_Int32 nPos = LISTBOX_ENTRY_NOTFOUND;
1667 if( fDuration == 5.0 )
1668 nPos = 0;
1669 else if( fDuration == 3.0 )
1670 nPos = 1;
1671 else if( fDuration == 2.0 )
1672 nPos = 2;
1673 else if( fDuration == 1.0 )
1674 nPos = 3;
1675 else if( fDuration == 0.5 )
1676 nPos = 4;
1678 if( nPos != LISTBOX_ENTRY_NOTFOUND )
1679 mpCBDuration->SelectEntryPos( nPos );
1680 else
1681 mpCBDuration->SetText(OUString::number(fDuration));
1685 if( pSet->getPropertyState( nHandleRepeat ) != STLPropertyState_AMBIGUOUS )
1687 Any aRepeatCount( pSet->getPropertyValue( nHandleRepeat ) );
1688 if( (aRepeatCount.getValueType() == ::cppu::UnoType<double>::get()) || !aRepeatCount.hasValue() )
1690 double fRepeat = 0.0;
1691 if( aRepeatCount.hasValue() )
1692 aRepeatCount >>= fRepeat;
1694 sal_Int32 nPos = LISTBOX_ENTRY_NOTFOUND;
1696 if( fRepeat == 0 )
1697 nPos = 0;
1698 else if( fRepeat == 2.0 )
1699 nPos = 1;
1700 else if( fRepeat == 3.0 )
1701 nPos = 2;
1702 else if( fRepeat == 4.0 )
1703 nPos = 3;
1704 else if( fRepeat == 5.0 )
1705 nPos = 4;
1706 else if( fRepeat == 10.0 )
1707 nPos = 5;
1709 if( nPos != LISTBOX_ENTRY_NOTFOUND )
1710 mpCBRepeat->SelectEntryPos( nPos );
1711 else
1712 mpCBRepeat->SetText(OUString::number(fRepeat));
1714 else if( aRepeatCount.getValueType() == ::cppu::UnoType<Timing>::get() )
1716 Any aEnd;
1717 if( pSet->getPropertyState( nHandleEnd ) != STLPropertyState_AMBIGUOUS )
1718 aEnd = pSet->getPropertyValue( nHandleEnd );
1720 mpCBRepeat->SelectEntryPos( aEnd.hasValue() ? 6 : 7 );
1724 if( pSet->getPropertyState( nHandleRewind ) != STLPropertyState_AMBIGUOUS )
1726 sal_Int16 nFill = 0;
1727 if( pSet->getPropertyValue( nHandleRewind ) >>= nFill )
1729 mpCBXRewind->Check( nFill == AnimationFill::REMOVE );
1731 else
1733 mpCBXRewind->SetState( TRISTATE_INDET );
1737 Reference< XShape > xTrigger;
1739 if( pSet->getPropertyState( nHandleTrigger ) != STLPropertyState_AMBIGUOUS )
1741 pSet->getPropertyValue( nHandleTrigger ) >>= xTrigger;
1743 mpRBInteractive->Check( xTrigger.is() );
1744 mpRBClickSequence->Check( !xTrigger.is() );
1747 Reference< XDrawPage > xCurrentPage;
1748 pSet->getPropertyValue( nHandleCurrentPage ) >>= xCurrentPage;
1749 if( xCurrentPage.is() )
1751 const OUString aStrIsEmptyPresObj( "IsEmptyPresentationObject" );
1753 sal_Int32 nShape, nCount = xCurrentPage->getCount();
1754 for( nShape = 0; nShape < nCount; nShape++ )
1756 Reference< XShape > xShape( xCurrentPage->getByIndex( nShape ), UNO_QUERY );
1758 if( !xShape.is() )
1759 continue;
1761 Reference< XPropertySet > xSet( xShape, UNO_QUERY );
1762 if( xSet.is() && xSet->getPropertySetInfo()->hasPropertyByName( aStrIsEmptyPresObj ) )
1764 bool bIsEmpty = false;
1765 xSet->getPropertyValue( aStrIsEmptyPresObj ) >>= bIsEmpty;
1766 if( bIsEmpty )
1767 continue;
1770 OUString aDescription( getShapeDescription( xShape, true ) );
1771 sal_Int32 nPos = mpLBTrigger->InsertEntry( aDescription );
1773 mpLBTrigger->SetEntryData( nPos, reinterpret_cast<void*>((sal_IntPtr)nShape) );
1774 if( xShape == xTrigger )
1775 mpLBTrigger->SelectEntryPos( nPos );
1780 CustomAnimationDurationTabPage::~CustomAnimationDurationTabPage()
1782 disposeOnce();
1785 void CustomAnimationDurationTabPage::dispose()
1787 mpFTStart.clear();
1788 mpLBStart.clear();
1789 mpFTStartDelay.clear();
1790 mpMFStartDelay.clear();
1791 mpFTDuration.clear();
1792 mpCBDuration.clear();
1793 mpFTRepeat.clear();
1794 mpCBRepeat.clear();
1795 mpCBXRewind.clear();
1796 mpRBClickSequence.clear();
1797 mpRBInteractive.clear();
1798 mpLBTrigger.clear();
1799 TabPage::dispose();
1802 IMPL_LINK( CustomAnimationDurationTabPage, implControlHdl, Control*, pControl )
1804 if( pControl == mpLBTrigger )
1806 mpRBClickSequence->Check( false );
1807 mpRBInteractive->Check( true );
1810 return 0;
1813 void CustomAnimationDurationTabPage::update( STLPropertySet* pSet )
1815 sal_Int32 nPos = mpLBStart->GetSelectEntryPos();
1816 if( nPos != LISTBOX_ENTRY_NOTFOUND )
1818 sal_Int16 nStart;
1819 sal_Int16 nOldStart = -1;
1821 switch( nPos )
1823 case 1: nStart = EffectNodeType::WITH_PREVIOUS; break;
1824 case 2: nStart = EffectNodeType::AFTER_PREVIOUS; break;
1825 default:
1826 nStart = EffectNodeType::ON_CLICK; break;
1829 if(mpSet->getPropertyState( nHandleStart ) != STLPropertyState_AMBIGUOUS)
1830 mpSet->getPropertyValue( nHandleStart ) >>= nOldStart;
1832 if( nStart != nOldStart )
1833 pSet->setPropertyValue( nHandleStart, makeAny( nStart ) );
1837 double fBegin = static_cast<double>( mpMFStartDelay->GetValue()) / 10.0;
1838 double fOldBegin = -1.0;
1840 if( mpSet->getPropertyState( nHandleBegin ) != STLPropertyState_AMBIGUOUS )
1841 mpSet->getPropertyValue( nHandleBegin ) >>= fOldBegin;
1843 if( fBegin != fOldBegin )
1844 pSet->setPropertyValue( nHandleBegin, makeAny( fBegin ) );
1847 nPos = mpCBRepeat->GetSelectEntryPos();
1848 if( (nPos != LISTBOX_ENTRY_NOTFOUND) || (!mpCBRepeat->GetText().isEmpty()) )
1850 Any aRepeatCount;
1851 Any aEnd;
1853 switch( nPos )
1855 case 0:
1856 break;
1858 case 6:
1860 Event aEvent;
1861 aEvent.Trigger = EventTrigger::ON_NEXT;
1862 aEvent.Repeat = 0;
1863 aEnd <<= aEvent;
1865 // ATTENTION: FALL THROUGH INTENDED!
1866 case 7:
1867 aRepeatCount <<= Timing_INDEFINITE;
1868 break;
1869 default:
1871 OUString aText(mpCBRepeat->GetEntry(nPos));
1872 if( !aText.isEmpty() )
1873 aRepeatCount <<= aText.toDouble();
1877 Any aOldRepeatCount( aRepeatCount );
1878 if( mpSet->getPropertyState( nHandleRepeat ) != STLPropertyState_AMBIGUOUS )
1879 aOldRepeatCount = mpSet->getPropertyValue( nHandleRepeat );
1881 if( aRepeatCount != aOldRepeatCount )
1882 pSet->setPropertyValue( nHandleRepeat, aRepeatCount );
1884 Any aOldEnd( aEnd );
1885 if( mpSet->getPropertyState( nHandleEnd ) != STLPropertyState_AMBIGUOUS )
1886 aOldEnd = mpSet->getPropertyValue( nHandleEnd );
1888 if( aEnd != aOldEnd )
1889 pSet->setPropertyValue( nHandleEnd, aEnd );
1892 double fDuration = -1.0;
1893 nPos = mpCBDuration->GetSelectEntryPos();
1894 if( nPos != LISTBOX_ENTRY_NOTFOUND )
1896 fDuration = *static_cast< const double * >( mpCBDuration->GetEntryData(nPos) );
1898 else
1900 OUString aText( mpCBDuration->GetText() );
1901 if( !aText.isEmpty() )
1903 fDuration = aText.toDouble();
1907 if( fDuration != -1.0 )
1909 double fOldDuration = -1;
1911 if( mpSet->getPropertyState( nHandleDuration ) != STLPropertyState_AMBIGUOUS )
1912 mpSet->getPropertyValue( nHandleDuration ) >>= fOldDuration;
1914 if( fDuration != fOldDuration )
1915 pSet->setPropertyValue( nHandleDuration, makeAny( fDuration ) );
1918 if( mpCBXRewind->GetState() != TRISTATE_INDET )
1920 sal_Int16 nFill = mpCBXRewind->IsChecked() ? AnimationFill::REMOVE : AnimationFill::HOLD;
1922 bool bSet = true;
1924 if( mpSet->getPropertyState( nHandleRewind ) != STLPropertyState_AMBIGUOUS )
1926 sal_Int16 nOldFill = 0;
1927 mpSet->getPropertyValue( nHandleRewind ) >>= nOldFill;
1928 bSet = nFill != nOldFill;
1931 if( bSet )
1932 pSet->setPropertyValue( nHandleRewind, makeAny( nFill ) );
1935 Reference< XShape > xTrigger;
1937 if( mpRBInteractive->IsChecked() )
1939 nPos = mpLBTrigger->GetSelectEntryPos();
1940 if( nPos != LISTBOX_ENTRY_NOTFOUND )
1942 sal_Int32 nShape = (sal_Int32)reinterpret_cast<sal_IntPtr>(mpLBTrigger->GetEntryData( nPos ));
1944 Reference< XDrawPage > xCurrentPage;
1945 mpSet->getPropertyValue( nHandleCurrentPage ) >>= xCurrentPage;
1947 if( xCurrentPage.is() && (nShape >= 0) && (nShape < xCurrentPage->getCount()) )
1948 xCurrentPage->getByIndex( nShape ) >>= xTrigger;
1952 if( xTrigger.is() || mpRBClickSequence->IsChecked() )
1954 Any aNewValue( makeAny( xTrigger ) );
1955 Any aOldValue;
1957 if( mpSet->getPropertyState( nHandleTrigger ) != STLPropertyState_AMBIGUOUS )
1958 aOldValue = mpSet->getPropertyValue( nHandleTrigger );
1960 if( aNewValue != aOldValue )
1961 pSet->setPropertyValue( nHandleTrigger, aNewValue );
1965 class CustomAnimationTextAnimTabPage : public TabPage
1967 public:
1968 CustomAnimationTextAnimTabPage( vcl::Window* pParent, const STLPropertySet* pSet );
1969 virtual ~CustomAnimationTextAnimTabPage();
1970 virtual void dispose() SAL_OVERRIDE;
1972 void update( STLPropertySet* pSet );
1974 void updateControlStates();
1975 DECL_LINK(implSelectHdl, void *);
1977 private:
1978 VclPtr<FixedText> maFTGroupText;
1979 VclPtr<ListBox> maLBGroupText;
1980 VclPtr<CheckBox> maCBXGroupAuto;
1981 VclPtr<MetricField> maMFGroupAuto;
1982 VclPtr<CheckBox> maCBXAnimateForm;
1983 VclPtr<CheckBox> maCBXReverse;
1985 const STLPropertySet* mpSet;
1987 bool mbHasVisibleShapes;
1990 CustomAnimationTextAnimTabPage::CustomAnimationTextAnimTabPage(vcl::Window* pParent, const STLPropertySet* pSet)
1991 : TabPage( pParent, "TextAnimationTab", "modules/simpress/ui/customanimationtexttab.ui" ),
1992 mpSet( pSet ),
1993 mbHasVisibleShapes(true)
1995 get( maFTGroupText, "group_text_label" );
1996 get( maLBGroupText, "group_text_list" );
1997 get( maCBXGroupAuto, "auto_after" );
1998 get( maMFGroupAuto, "auto_after_value" );
1999 get( maCBXAnimateForm, "animate_shape" );
2000 get( maCBXReverse, "reverse_order" );
2002 maLBGroupText->SetSelectHdl( LINK( this, CustomAnimationTextAnimTabPage, implSelectHdl ) );
2004 if( pSet->getPropertyState( nHandleTextGrouping ) != STLPropertyState_AMBIGUOUS )
2006 sal_Int32 nTextGrouping = 0;
2007 if( pSet->getPropertyValue( nHandleTextGrouping ) >>= nTextGrouping )
2008 maLBGroupText->SelectEntryPos( nTextGrouping + 1 );
2011 if( pSet->getPropertyState( nHandleHasVisibleShape ) != STLPropertyState_AMBIGUOUS )
2012 pSet->getPropertyValue( nHandleHasVisibleShape ) >>= mbHasVisibleShapes;
2014 if( pSet->getPropertyState( nHandleTextGroupingAuto ) != STLPropertyState_AMBIGUOUS )
2016 double fTextGroupingAuto = 0.0;
2017 if( pSet->getPropertyValue( nHandleTextGroupingAuto ) >>= fTextGroupingAuto )
2019 maCBXGroupAuto->Check( fTextGroupingAuto >= 0.0 );
2020 if( fTextGroupingAuto >= 0.0 )
2021 maMFGroupAuto->SetValue( (long)(fTextGroupingAuto*10) );
2024 else
2026 maCBXGroupAuto->SetState( TRISTATE_INDET );
2029 maCBXAnimateForm->SetState( TRISTATE_INDET );
2030 if( pSet->getPropertyState( nHandleAnimateForm ) != STLPropertyState_AMBIGUOUS )
2032 bool bAnimateForm = false;
2033 if( pSet->getPropertyValue( nHandleAnimateForm ) >>= bAnimateForm )
2035 maCBXAnimateForm->Check( bAnimateForm );
2038 else
2040 maCBXAnimateForm->Enable( false );
2043 maCBXReverse->SetState( TRISTATE_INDET );
2044 if( pSet->getPropertyState( nHandleTextReverse ) != STLPropertyState_AMBIGUOUS )
2046 bool bTextReverse = false;
2047 if( pSet->getPropertyValue( nHandleTextReverse ) >>= bTextReverse )
2049 maCBXReverse->Check( bTextReverse );
2053 if( pSet->getPropertyState( nHandleMaxParaDepth ) == STLPropertyState_DIRECT )
2055 sal_Int32 nMaxParaDepth = 0;
2056 pSet->getPropertyValue( nHandleMaxParaDepth ) >>= nMaxParaDepth;
2057 nMaxParaDepth += 1;
2059 sal_Int32 nPos = 6;
2060 while( (nPos > 2) && (nPos > nMaxParaDepth) )
2062 maLBGroupText->RemoveEntry( nPos );
2063 nPos--;
2067 updateControlStates();
2070 CustomAnimationTextAnimTabPage::~CustomAnimationTextAnimTabPage()
2072 disposeOnce();
2075 void CustomAnimationTextAnimTabPage::dispose()
2077 maFTGroupText.clear();
2078 maLBGroupText.clear();
2079 maCBXGroupAuto.clear();
2080 maMFGroupAuto.clear();
2081 maCBXAnimateForm.clear();
2082 maCBXReverse.clear();
2083 TabPage::dispose();
2086 void CustomAnimationTextAnimTabPage::update( STLPropertySet* pSet )
2088 sal_Int32 nPos = maLBGroupText->GetSelectEntryPos();
2089 if( nPos != LISTBOX_ENTRY_NOTFOUND )
2091 sal_Int32 nTextGrouping = nPos - 1;
2092 sal_Int32 nOldGrouping = -2;
2094 if(mpSet->getPropertyState( nHandleTextGrouping ) != STLPropertyState_AMBIGUOUS)
2095 mpSet->getPropertyValue( nHandleTextGrouping ) >>= nOldGrouping;
2097 if( nTextGrouping != nOldGrouping )
2098 pSet->setPropertyValue( nHandleTextGrouping, makeAny( nTextGrouping ) );
2101 if( nPos > 0 )
2103 bool bTextReverse = maCBXReverse->IsChecked();
2104 bool bOldTextReverse = !bTextReverse;
2106 if(mpSet->getPropertyState( nHandleTextReverse ) != STLPropertyState_AMBIGUOUS)
2107 mpSet->getPropertyValue( nHandleTextReverse ) >>= bOldTextReverse;
2109 if( bTextReverse != bOldTextReverse )
2110 pSet->setPropertyValue( nHandleTextReverse, makeAny( bTextReverse ) );
2112 if( nPos > 1 )
2114 double fTextGroupingAuto = maCBXGroupAuto->IsChecked() ? maMFGroupAuto->GetValue() / 10.0 : -1.0;
2115 double fOldTextGroupingAuto = -2.0;
2117 if(mpSet->getPropertyState( nHandleTextGroupingAuto ) != STLPropertyState_AMBIGUOUS)
2118 mpSet->getPropertyValue( nHandleTextGroupingAuto ) >>= fOldTextGroupingAuto;
2120 if( fTextGroupingAuto != fOldTextGroupingAuto )
2121 pSet->setPropertyValue( nHandleTextGroupingAuto, makeAny( fTextGroupingAuto ) );
2124 //#i120049# impress crashes when modifying the "Random effects" animation
2125 //effect's trigger condition to "Start effect on click of".
2126 //If this control is disabled, we should ignore its value
2127 if (maCBXAnimateForm->IsEnabled())
2129 bool bAnimateForm = maCBXAnimateForm->IsChecked();
2130 bool bOldAnimateForm = !bAnimateForm;
2132 if(mpSet->getPropertyState( nHandleAnimateForm ) != STLPropertyState_AMBIGUOUS)
2133 mpSet->getPropertyValue( nHandleAnimateForm ) >>= bOldAnimateForm;
2135 if( bAnimateForm != bOldAnimateForm )
2136 pSet->setPropertyValue( nHandleAnimateForm, makeAny( bAnimateForm ) );
2140 void CustomAnimationTextAnimTabPage::updateControlStates()
2142 sal_Int32 nPos = maLBGroupText->GetSelectEntryPos();
2144 maCBXGroupAuto->Enable( nPos > 1 );
2145 maMFGroupAuto->Enable( nPos > 1 );
2146 maCBXReverse->Enable( nPos > 0 );
2148 if( !mbHasVisibleShapes && nPos > 0 )
2150 maCBXAnimateForm->Check(false);
2151 maCBXAnimateForm->Enable(false);
2153 else
2155 maCBXAnimateForm->Enable(true);
2159 IMPL_LINK_NOARG(CustomAnimationTextAnimTabPage, implSelectHdl)
2161 updateControlStates();
2162 return 0;
2165 CustomAnimationDialog::CustomAnimationDialog(vcl::Window* pParent, STLPropertySet* pSet, const OString& sPage)
2166 : TabDialog( pParent, "CustomAnimationProperties", "modules/simpress/ui/customanimationproperties.ui")
2167 , mpSet( pSet )
2168 , mpResultSet( 0 )
2170 get(mpTabControl, "tabs");
2172 sal_uInt16 mnEffectId = mpTabControl->GetPageId("effect");
2173 sal_uInt16 mnTimingId = mpTabControl->GetPageId("timing");
2174 sal_uInt16 mnTextAnimId = mpTabControl->GetPageId("textanim");
2176 mpEffectTabPage = VclPtr<CustomAnimationEffectTabPage>::Create( mpTabControl, mpSet );
2177 mpTabControl->SetTabPage( mnEffectId, mpEffectTabPage );
2178 mpDurationTabPage = VclPtr<CustomAnimationDurationTabPage>::Create( mpTabControl, mpSet );
2179 mpTabControl->SetTabPage( mnTimingId, mpDurationTabPage );
2181 bool bHasText = false;
2182 if( pSet->getPropertyState( nHandleHasText ) != STLPropertyState_AMBIGUOUS )
2183 pSet->getPropertyValue( nHandleHasText ) >>= bHasText;
2185 if( bHasText )
2187 mpTextAnimTabPage = VclPtr<CustomAnimationTextAnimTabPage>::Create( mpTabControl, mpSet );
2188 mpTabControl->SetTabPage( mnTextAnimId, mpTextAnimTabPage );
2190 else
2192 mpTextAnimTabPage = 0;
2193 mpTabControl->RemovePage( mnTextAnimId );
2196 if (!sPage.isEmpty())
2197 mpTabControl->SelectTabPage(mpTabControl->GetPageId(sPage));
2200 CustomAnimationDialog::~CustomAnimationDialog()
2202 disposeOnce();
2205 void CustomAnimationDialog::dispose()
2207 mpEffectTabPage.disposeAndClear();
2208 mpDurationTabPage.disposeAndClear();
2209 mpTextAnimTabPage.disposeAndClear();
2211 delete mpSet;
2212 delete mpResultSet;
2214 mpTabControl.clear();
2215 TabDialog::dispose();
2218 STLPropertySet* CustomAnimationDialog::getResultSet()
2220 if( mpResultSet )
2221 delete mpResultSet;
2223 mpResultSet = createDefaultSet();
2225 mpEffectTabPage->update( mpResultSet );
2226 mpDurationTabPage->update( mpResultSet );
2227 if( mpTextAnimTabPage )
2228 mpTextAnimTabPage->update( mpResultSet );
2230 return mpResultSet;
2233 STLPropertySet* CustomAnimationDialog::createDefaultSet()
2235 Any aEmpty;
2237 STLPropertySet* pSet = new STLPropertySet();
2238 pSet->setPropertyDefaultValue( nHandleMaxParaDepth, makeAny( (sal_Int32)-1 ) );
2240 pSet->setPropertyDefaultValue( nHandleHasAfterEffect, makeAny( false ) );
2241 pSet->setPropertyDefaultValue( nHandleAfterEffectOnNextEffect, makeAny( false ) );
2242 pSet->setPropertyDefaultValue( nHandleDimColor, aEmpty );
2243 pSet->setPropertyDefaultValue( nHandleIterateType, makeAny( (sal_Int16)0 ) );
2244 pSet->setPropertyDefaultValue( nHandleIterateInterval, makeAny( (double)0.0 ) );
2246 pSet->setPropertyDefaultValue( nHandleStart, makeAny( (sal_Int16)EffectNodeType::ON_CLICK ) );
2247 pSet->setPropertyDefaultValue( nHandleBegin, makeAny( (double)0.0 ) );
2248 pSet->setPropertyDefaultValue( nHandleDuration, makeAny( (double)2.0 ) );
2249 pSet->setPropertyDefaultValue( nHandleRepeat, aEmpty );
2250 pSet->setPropertyDefaultValue( nHandleRewind, makeAny( AnimationFill::HOLD ) );
2252 pSet->setPropertyDefaultValue( nHandleEnd, aEmpty );
2254 pSet->setPropertyDefaultValue( nHandlePresetId, aEmpty );
2255 pSet->setPropertyDefaultValue( nHandleProperty1Type, makeAny( nPropertyTypeNone ) );
2256 pSet->setPropertyDefaultValue( nHandleProperty1Value, aEmpty );
2257 pSet->setPropertyDefaultValue( nHandleProperty2Type, makeAny( nPropertyTypeNone ) );
2258 pSet->setPropertyDefaultValue( nHandleProperty2Value, aEmpty );
2259 pSet->setPropertyDefaultValue( nHandleAccelerate, aEmpty );
2260 pSet->setPropertyDefaultValue( nHandleDecelerate, aEmpty );
2261 pSet->setPropertyDefaultValue( nHandleAutoReverse, aEmpty );
2262 pSet->setPropertyDefaultValue( nHandleTrigger, aEmpty );
2264 pSet->setPropertyDefaultValue( nHandleHasText, makeAny( sal_False ) );
2265 pSet->setPropertyDefaultValue( nHandleHasVisibleShape, makeAny( sal_False ) );
2266 pSet->setPropertyDefaultValue( nHandleTextGrouping, makeAny( (sal_Int32)-1 ) );
2267 pSet->setPropertyDefaultValue( nHandleAnimateForm, makeAny( sal_True ) );
2268 pSet->setPropertyDefaultValue( nHandleTextGroupingAuto, makeAny( (double)-1.0 ) );
2269 pSet->setPropertyDefaultValue( nHandleTextReverse, makeAny( sal_False ) );
2271 pSet->setPropertyDefaultValue( nHandleCurrentPage, aEmpty );
2273 pSet->setPropertyDefaultValue( nHandleSoundURL, aEmpty );
2274 pSet->setPropertyDefaultValue( nHandleSoundVolumne, makeAny( (double)1.0) );
2275 pSet->setPropertyDefaultValue( nHandleSoundEndAfterSlide, makeAny( (sal_Int32)0 ) );
2277 pSet->setPropertyDefaultValue( nHandleCommand, makeAny( (sal_Int16)0 ) );
2278 return pSet;
2281 PropertyControl::PropertyControl( vcl::Window* pParent )
2282 : ListBox( pParent, WB_TABSTOP | WB_BORDER | WB_DROPDOWN ), mpSubControl(0)
2286 VCL_BUILDER_FACTORY(PropertyControl)
2288 PropertyControl::~PropertyControl()
2290 disposeOnce();
2293 void PropertyControl::dispose()
2295 if( mpSubControl )
2296 delete mpSubControl;
2297 ListBox::dispose();
2300 void PropertyControl::setSubControl( PropertySubControl* pSubControl )
2302 if( mpSubControl && mpSubControl != pSubControl )
2303 delete mpSubControl;
2305 mpSubControl = pSubControl;
2307 Control* pControl = pSubControl ? pSubControl->getControl() : 0;
2309 if( pControl )
2311 pControl->SetPosSizePixel( GetPosPixel(), GetSizePixel() );
2312 pControl->SetZOrder( this, WINDOW_ZORDER_BEFOR );
2313 pControl->Show();
2314 Hide();
2316 else
2318 Show();
2322 void PropertyControl::Resize()
2324 Control* pControl = mpSubControl ? mpSubControl->getControl() : 0;
2325 if( pControl )
2326 pControl->SetPosSizePixel( GetPosPixel(), GetSizePixel() );
2327 ListBox::Resize();
2330 PropertySubControl::~PropertySubControl()
2334 PropertySubControl* PropertySubControl::create( sal_Int32 nType, vcl::Window* pParent, const Any& rValue, const OUString& rPresetId, const Link<>& rModifyHdl )
2336 PropertySubControl* pSubControl = NULL;
2337 switch( nType )
2339 case nPropertyTypeDirection:
2340 case nPropertyTypeSpokes:
2341 case nPropertyTypeZoom:
2342 pSubControl = new PresetPropertyBox( nType, pParent, rValue, rPresetId, rModifyHdl );
2343 break;
2345 case nPropertyTypeColor:
2346 case nPropertyTypeFillColor:
2347 case nPropertyTypeFirstColor:
2348 case nPropertyTypeCharColor:
2349 case nPropertyTypeLineColor:
2350 pSubControl = new ColorPropertyBox( nType, pParent, rValue, rModifyHdl );
2351 break;
2353 case nPropertyTypeFont:
2354 pSubControl = new FontPropertyBox( nType, pParent, rValue, rModifyHdl );
2355 break;
2357 case nPropertyTypeCharHeight:
2358 pSubControl = new CharHeightPropertyBox( nType, pParent, rValue, rModifyHdl );
2359 break;
2361 case nPropertyTypeRotate:
2362 pSubControl = new RotationPropertyBox( nType, pParent, rValue, rModifyHdl );
2363 break;
2365 case nPropertyTypeTransparency:
2366 pSubControl = new TransparencyPropertyBox( nType, pParent, rValue, rModifyHdl );
2367 break;
2369 case nPropertyTypeScale:
2370 pSubControl = new ScalePropertyBox( nType, pParent, rValue, rModifyHdl );
2371 break;
2373 case nPropertyTypeCharDecoration:
2374 pSubControl = new FontStylePropertyBox( nType, pParent, rValue, rModifyHdl );
2375 break;
2378 return pSubControl;
2383 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */