1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 #include <com/sun/star/presentation/EffectNodeType.hpp>
27 #include <com/sun/star/animations/Timing.hpp>
28 #include <com/sun/star/animations/Event.hpp>
29 #include <com/sun/star/animations/EventTrigger.hpp>
30 #include <com/sun/star/animations/AnimationFill.hpp>
31 #include <com/sun/star/presentation/TextAnimationType.hpp>
32 #include <com/sun/star/animations/ValuePair.hpp>
33 #include <com/sun/star/awt/FontSlant.hpp>
34 #include <com/sun/star/awt/FontWeight.hpp>
35 #include <com/sun/star/awt/FontUnderline.hpp>
36 #include <com/sun/star/drawing/XDrawPage.hpp>
37 #include <com/sun/star/beans/XPropertySet.hpp>
38 #include <com/sun/star/media/XManager.hpp>
39 #include <com/sun/star/media/XPlayer.hpp>
40 
41 #ifndef BOOST_SHARED_PTR_HPP_INCLUDED
42 #include <boost/shared_ptr.hpp>
43 #endif
44 
45 #ifndef _UNOTOOLS_PROCESSFACTORY_HXX
46 #include <comphelper/processfactory.hxx>
47 #endif
48 #include <unotools/pathoptions.hxx>
49 #include <vcl/tabctrl.hxx>
50 #include <vcl/tabpage.hxx>
51 #include <vcl/menubtn.hxx>
52 #include <vcl/svapp.hxx>
53 #include <vcl/fixed.hxx>
54 #include <vcl/lstbox.hxx>
55 #include <vcl/field.hxx>
56 #include <vcl/msgbox.hxx>
57 #include <vcl/decoview.hxx>
58 #include <vcl/combobox.hxx>
59 #include <vcl/menu.hxx>
60 #include <svtools/ctrlbox.hxx>
61 #include <svtools/ctrltool.hxx>
62 #include <sfx2/objsh.hxx>
63 
64 #ifndef _SVX_SVXIDS_HRC
65 #include <svx/svxids.hrc>
66 #endif
67 #include <svx/dialmgr.hxx>
68 #include <editeng/flstitem.hxx>
69 #include <svx/drawitem.hxx>
70 
71 #include <svx/xtable.hxx>
72 #include <svx/gallery.hxx>
73 
74 #ifndef _SVX_DIALOGS_HRC
75 #include <svx/dialogs.hrc>
76 #endif
77 #include "sdresid.hxx"
78 
79 #include "glob.hrc"
80 #include "CustomAnimationDialog.hxx"
81 #ifndef _SD_CUSTOMANIMATIONDIALOG_HRC
82 #include "CustomAnimationDialog.hrc"
83 #endif
84 #ifndef _SD_CUSTOMANIMATION_HRC
85 #include "CustomAnimation.hrc"
86 #endif
87 #include "STLPropertySet.hxx"
88 
89 #include <avmedia/mediawindow.hxx>
90 
91 #include "filedlg.hxx"
92 #include "strings.hrc"
93 #include "helpids.h"
94 
95 using namespace ::com::sun::star;
96 using namespace ::com::sun::star::animations;
97 using namespace ::com::sun::star::presentation;
98 
99 using ::rtl::OUString;
100 using ::com::sun::star::uno::UNO_QUERY;
101 using ::com::sun::star::uno::UNO_QUERY_THROW;
102 using ::com::sun::star::uno::Any;
103 using ::com::sun::star::uno::makeAny;
104 using ::com::sun::star::uno::Sequence;
105 using ::com::sun::star::uno::Reference;
106 using ::com::sun::star::uno::Exception;
107 using ::com::sun::star::drawing::XShape;
108 using ::com::sun::star::drawing::XDrawPage;
109 using ::com::sun::star::beans::XPropertySet;
110 
111 namespace sd {
112 
113 extern void fillRepeatComboBox( ComboBox* pBox );
114 extern void fillDurationComboBox( ComboBox* pBox );
115 extern OUString getShapeDescription( const Reference< XShape >& xShape, bool bWithText = true );
116 extern OUString getPropertyName( sal_Int32 nPropertyType );
117 
118 // ====================================================================
119 
120 class PresetPropertyBox  : public PropertySubControl
121 {
122 public:
123 	PresetPropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const OUString& aPresetId, const Link& rModifyHdl );
124 	~PresetPropertyBox();
125 
126 	virtual Any getValue();
127 	virtual void setValue( const Any& rValue, const OUString& rPresetId );
128 	virtual Control* getControl();
129 
130 private:
131 	std::map< sal_uInt16, rtl::OUString > maPropertyValues;
132 	ListBox* mpControl;
133 };
134 
135 // --------------------------------------------------------------------
136 
137 PresetPropertyBox::PresetPropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const OUString& aPresetId, const Link& rModifyHdl )
138 : PropertySubControl( nControlType )
139 {
140 	mpControl = new ListBox( pParent, WB_BORDER|WB_TABSTOP|WB_DROPDOWN );
141 	mpControl->SetDropDownLineCount( 10 );
142 	mpControl->SetSelectHdl( rModifyHdl );
143 	mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_PRESETPROPERTYBOX );
144 
145 	setValue( rValue, aPresetId );
146 
147 }
148 
149 void PresetPropertyBox::setValue( const Any& rValue, const OUString& rPresetId )
150 {
151 	if( mpControl )
152 	{
153 		mpControl->Clear();
154 
155 		const CustomAnimationPresets& rPresets = CustomAnimationPresets::getCustomAnimationPresets();
156 		CustomAnimationPresetPtr pDescriptor = rPresets.getEffectDescriptor( rPresetId );
157 		if( pDescriptor.get() )
158 		{
159 
160 			OUString aPropertyValue;
161 			rValue >>= aPropertyValue;
162 
163 			UStringList aSubTypes( pDescriptor->getSubTypes() );
164 			UStringList::iterator aIter( aSubTypes.begin() );
165 			const UStringList::iterator aEnd( aSubTypes.end() );
166 
167 			mpControl->Enable( aIter != aEnd );
168 
169 			while( aIter != aEnd )
170 			{
171 				sal_uInt16 nPos = mpControl->InsertEntry( rPresets.getUINameForProperty( (*aIter) ) );
172 				if( (*aIter) == aPropertyValue )
173 					mpControl->SelectEntryPos( nPos );
174 				maPropertyValues[nPos] = (*aIter++);
175 			}
176 		}
177 		else
178 		{
179 			mpControl->Enable( sal_False );
180 		}
181 	}
182 }
183 
184 // --------------------------------------------------------------------
185 
186 PresetPropertyBox::~PresetPropertyBox()
187 {
188 	delete mpControl;
189 }
190 
191 // --------------------------------------------------------------------
192 
193 Any PresetPropertyBox::getValue()
194 {
195 	return makeAny( maPropertyValues[mpControl->GetSelectEntryPos()] );
196 }
197 
198 // --------------------------------------------------------------------
199 
200 Control* PresetPropertyBox::getControl()
201 {
202 	return mpControl;
203 }
204 
205 // ====================================================================
206 
207 class ColorPropertyBox  : public PropertySubControl
208 {
209 public:
210 	ColorPropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl );
211 	~ColorPropertyBox();
212 
213 	virtual Any getValue();
214 	virtual void setValue( const Any& rValue, const OUString& rPresetId  );
215 	virtual Control* getControl();
216 
217 private:
218 	ColorListBox* mpControl;
219 };
220 
221 // --------------------------------------------------------------------
222 
223 ColorPropertyBox::ColorPropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl )
224 : PropertySubControl( nControlType )
225 {
226 	mpControl = new ColorListBox( pParent, WB_BORDER|WB_TABSTOP|WB_DROPDOWN );
227 	mpControl->SetDropDownLineCount( 10 );
228 	mpControl->SetSelectHdl( rModifyHdl );
229 	mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_COLORPROPERTYBOX );
230 
231 	SfxObjectShell* pDocSh = SfxObjectShell::Current();
232 	DBG_ASSERT( pDocSh, "DocShell not found!" );
233 	XColorList* pColorTable = NULL;
234 	bool bKillTable = false;
235 	const SfxPoolItem* pItem = NULL;
236 
237 	if ( pDocSh && ( ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) != 0) )
238 		pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable();
239 
240 	if ( !pColorTable )
241 	{
242 		pColorTable = new XColorList( SvtPathOptions().GetPalettePath() );
243 		bKillTable = sal_True;
244 	}
245 
246 	sal_Int32 nColor = 0;
247 	rValue >>= nColor;
248 
249 	for ( long i = 0; i < pColorTable->Count(); i++ )
250 	{
251 		XColorEntry* pEntry = pColorTable->GetColor(i);
252 		sal_uInt16 nPos = mpControl->InsertEntry( pEntry->GetColor(), pEntry->GetName() );
253 		if( pEntry->GetColor().GetRGBColor() == (sal_uInt32)nColor )
254 			mpControl->SelectEntryPos( nPos );
255 	}
256 
257 	if ( bKillTable )
258 		delete pColorTable;
259 }
260 
261 // --------------------------------------------------------------------
262 
263 ColorPropertyBox::~ColorPropertyBox()
264 {
265 	delete mpControl;
266 }
267 
268 // --------------------------------------------------------------------
269 
270 void ColorPropertyBox::setValue( const Any& rValue, const OUString& )
271 {
272 	if( mpControl )
273 	{
274 		sal_Int32 nColor = 0;
275 		rValue >>= nColor;
276 
277 		mpControl->SetNoSelection();
278 		mpControl->SelectEntryPos( mpControl->GetEntryPos( (Color)nColor ) );
279 	}
280 }
281 
282 // --------------------------------------------------------------------
283 
284 Any ColorPropertyBox::getValue()
285 {
286 	return makeAny( (sal_Int32)mpControl->GetSelectEntryColor().GetRGBColor() );
287 }
288 
289 // --------------------------------------------------------------------
290 
291 Control* ColorPropertyBox::getControl()
292 {
293 	return mpControl;
294 }
295 
296 // ====================================================================
297 
298 class FontPropertyBox : public PropertySubControl
299 {
300 public:
301 	FontPropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl );
302 	virtual ~FontPropertyBox();
303 
304 	virtual Any getValue();
305 	virtual void setValue( const Any& rValue, const OUString& rPresetId  );
306 
307 	virtual Control* getControl();
308 
309 private:
310 	FontNameBox* mpControl;
311 };
312 
313 // --------------------------------------------------------------------
314 
315 FontPropertyBox::FontPropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl )
316 : PropertySubControl( nControlType )
317 {
318 	mpControl = new FontNameBox( pParent, WB_BORDER|WB_TABSTOP|WB_DROPDOWN );
319 	mpControl->SetDropDownLineCount( 10 );
320 	mpControl->SetSelectHdl( rModifyHdl );
321 	mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_FONTPROPERTYBOX );
322 
323 	SfxObjectShell* pDocSh = SfxObjectShell::Current();
324 	const SfxPoolItem* pItem;
325 
326 	const FontList* pFontList = 0;
327 	bool bMustDelete = false;
328 
329     if ( pDocSh && ( (pItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST ) ) != 0) )
330         pFontList = ( (SvxFontListItem*)pItem )->GetFontList();
331 
332 	if(!pFontList)
333 	{
334         pFontList = new FontList( Application::GetDefaultDevice(), NULL, sal_False );
335 		bMustDelete = true;
336 	}
337 
338 	mpControl->Fill( pFontList );
339 
340 	if( bMustDelete )
341 		delete pFontList;
342 
343 	OUString aPresetId;
344 	setValue( rValue, aPresetId );
345 }
346 
347 // --------------------------------------------------------------------
348 
349 void FontPropertyBox::setValue( const Any& rValue, const OUString& )
350 {
351 	if( mpControl )
352 	{
353 		OUString aFontName;
354 		rValue >>= aFontName;
355 		mpControl->SetText( aFontName );
356 	}
357 }
358 
359 // --------------------------------------------------------------------
360 
361 FontPropertyBox::~FontPropertyBox()
362 {
363 	delete mpControl;
364 }
365 
366 // --------------------------------------------------------------------
367 
368 Any FontPropertyBox::getValue()
369 {
370 	OUString aFontName( mpControl->GetText() );
371 	return makeAny( aFontName );
372 }
373 
374 // --------------------------------------------------------------------
375 
376 Control* FontPropertyBox::getControl()
377 {
378 	return mpControl;
379 }
380 
381 // ====================================================================
382 
383 class DropdownMenuBox : public Edit
384 {
385 public:
386 	DropdownMenuBox( Window* pParent, Edit* pSubControl, PopupMenu* pMenu );
387 	~DropdownMenuBox();
388 
389 	void Resize();
390 	long PreNotify( NotifyEvent& rNEvt );
391 
392 	void SetMenuSelectHdl( const Link& rLink ) { mpDropdownButton->SetSelectHdl( rLink ); }
393 
394 private:
395 	Edit* mpSubControl;
396 	MenuButton* mpDropdownButton;
397 	PopupMenu* mpMenu;
398 };
399 
400 // --------------------------------------------------------------------
401 
402 DropdownMenuBox::DropdownMenuBox( Window* pParent, Edit* pSubControl, PopupMenu* pMenu )
403 :	Edit( pParent, WB_BORDER|WB_TABSTOP| WB_DIALOGCONTROL ),
404 	mpSubControl(pSubControl),mpDropdownButton(0),mpMenu(pMenu)
405 {
406 	mpDropdownButton = new MenuButton( this, WB_NOLIGHTBORDER | WB_RECTSTYLE | WB_NOTABSTOP);
407 	mpDropdownButton->SetSymbol(SYMBOL_SPIN_DOWN);
408 	mpDropdownButton->Show();
409 	mpDropdownButton->SetPopupMenu( pMenu );
410 
411 	SetSubEdit( mpSubControl );
412 	mpSubControl->SetParent( this );
413 	mpSubControl->Show();
414 }
415 
416 // --------------------------------------------------------------------
417 
418 DropdownMenuBox::~DropdownMenuBox()
419 {
420 	SetSubEdit( 0 );
421 	delete mpSubControl;
422 	delete mpDropdownButton;
423 	delete mpMenu;
424 }
425 
426 // --------------------------------------------------------------------
427 
428 void DropdownMenuBox::Resize()
429 {
430 	Size aOutSz = GetOutputSizePixel();
431 
432 	long nSBWidth = GetSettings().GetStyleSettings().GetScrollBarSize();
433 	nSBWidth = CalcZoom( nSBWidth );
434 	mpSubControl->SetPosSizePixel( 0, 1, aOutSz.Width() - nSBWidth, aOutSz.Height()-2 );
435 	mpDropdownButton->SetPosSizePixel( aOutSz.Width() - nSBWidth, 0, nSBWidth, aOutSz.Height() );
436 }
437 
438 // --------------------------------------------------------------------
439 
440 long DropdownMenuBox::PreNotify( NotifyEvent& rNEvt )
441 {
442 	long nResult=sal_True;
443 
444 	sal_uInt16 nSwitch=rNEvt.GetType();
445 	if (nSwitch==EVENT_KEYINPUT)
446 	{
447 		const KeyCode& aKeyCode=rNEvt.GetKeyEvent()->GetKeyCode();
448 		sal_uInt16 nKey=aKeyCode.GetCode();
449 
450 		if (nKey==KEY_DOWN && aKeyCode.IsMod2())
451 		{
452 			mpDropdownButton->KeyInput( *rNEvt.GetKeyEvent() );
453 		}
454 		else
455 		{
456 			nResult=Edit::PreNotify(rNEvt);
457 		}
458 	}
459 	else
460 		nResult=Edit::PreNotify(rNEvt);
461 
462 	return nResult;
463 }
464 
465 // --------------------------------------------------------------------
466 
467 class CharHeightPropertyBox : public PropertySubControl
468 {
469 public:
470 	CharHeightPropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl );
471 	virtual ~CharHeightPropertyBox();
472 
473 	virtual Any getValue();
474 	virtual void setValue( const Any& rValue, const OUString& );
475 
476 	virtual Control* getControl();
477 
478 	DECL_LINK( implMenuSelectHdl, MenuButton* );
479 
480 private:
481 	DropdownMenuBox* mpControl;
482 	PopupMenu* mpMenu;
483 	MetricField* mpMetric;
484 };
485 
486 // --------------------------------------------------------------------
487 
488 CharHeightPropertyBox::CharHeightPropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl )
489 : PropertySubControl( nControlType )
490 {
491 	mpMetric = new MetricField( pParent, WB_TABSTOP|WB_IGNORETAB| WB_NOBORDER);
492 	mpMetric->SetUnit( FUNIT_PERCENT );
493 	mpMetric->SetMin( 0 );
494 	mpMetric->SetMax( 1000 );
495 
496 	mpMenu = new PopupMenu(SdResId( RID_CUSTOMANIMATION_FONTSIZE_POPUP ) );
497 	mpControl = new DropdownMenuBox( pParent, mpMetric, mpMenu );
498 	mpControl->SetMenuSelectHdl( LINK( this, CharHeightPropertyBox, implMenuSelectHdl ));
499 	mpControl->SetModifyHdl( rModifyHdl );
500 	mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_CHARHEIGHTPROPERTYBOX );
501 
502 	OUString aPresetId;
503 	setValue( rValue, aPresetId );
504 }
505 
506 // --------------------------------------------------------------------
507 
508 CharHeightPropertyBox::~CharHeightPropertyBox()
509 {
510 	delete mpControl;
511 }
512 
513 // --------------------------------------------------------------------
514 
515 IMPL_LINK( CharHeightPropertyBox, implMenuSelectHdl, MenuButton*, pPb )
516 {
517 	long nValue = 100;
518 	switch( pPb->GetCurItemId() )
519 	{
520 	case CM_SIZE_25: nValue = 25; break;
521 	case CM_SIZE_50: nValue = 50; break;
522 	case CM_SIZE_150: nValue = 150; break;
523 	case CM_SIZE_400: nValue = 400; break;
524 	}
525 	mpMetric->SetValue( nValue );
526 	mpMetric->Modify();
527 	return 0;
528 }
529 
530 // --------------------------------------------------------------------
531 
532 void CharHeightPropertyBox::setValue( const Any& rValue, const OUString& )
533 {
534 	if( mpMetric )
535 	{
536 		double fValue = 0.0;
537 		rValue >>= fValue;
538 		mpMetric->SetValue( (long)(fValue * 100.0) );
539 	}
540 }
541 
542 // --------------------------------------------------------------------
543 
544 Any CharHeightPropertyBox::getValue()
545 {
546 	return makeAny( (double)((double)mpMetric->GetValue() / 100.0) );
547 }
548 
549 // --------------------------------------------------------------------
550 
551 Control* CharHeightPropertyBox::getControl()
552 {
553 	return mpControl;
554 }
555 
556 // ====================================================================
557 
558 class TransparencyPropertyBox : public PropertySubControl
559 {
560 public:
561 	TransparencyPropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl );
562 	~TransparencyPropertyBox();
563 
564 	virtual Any getValue();
565 	virtual void setValue( const Any& rValue, const OUString& rPresetId  );
566 
567 	virtual Control* getControl();
568 
569 	DECL_LINK( implMenuSelectHdl, MenuButton* );
570 	DECL_LINK( implModifyHdl, Control* );
571 
572 	void updateMenu();
573 
574 private:
575 	DropdownMenuBox* mpControl;
576 	PopupMenu* mpMenu;
577 	MetricField* mpMetric;
578 	Link maModifyHdl;
579 };
580 
581 // --------------------------------------------------------------------
582 
583 TransparencyPropertyBox::TransparencyPropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl )
584 : PropertySubControl( nControlType )
585 , maModifyHdl( rModifyHdl )
586 {
587 	mpMetric = new MetricField( pParent ,WB_TABSTOP|WB_IGNORETAB| WB_NOBORDER);
588 	mpMetric->SetUnit( FUNIT_PERCENT );
589 	mpMetric->SetMin( 0 );
590 	mpMetric->SetMax( 100 );
591 
592 	mpMenu = new PopupMenu();
593 	for( sal_uInt16 i = 25; i < 101; i += 25 )
594 	{
595 		String aStr( String::CreateFromInt32( i ) );
596 		aStr += sal_Unicode('%');
597 		mpMenu->InsertItem( i, aStr );
598 	}
599 
600 	mpControl = new DropdownMenuBox( pParent, mpMetric, mpMenu );
601 	mpControl->SetMenuSelectHdl( LINK( this, TransparencyPropertyBox, implMenuSelectHdl ));
602 	mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_TRANSPARENCYPROPERTYBOX );
603 
604 	Link aLink( LINK( this, TransparencyPropertyBox, implModifyHdl ) );
605 	mpControl->SetModifyHdl( aLink );
606 
607 	OUString aPresetId;
608 	setValue( rValue, aPresetId  );
609 }
610 
611 // --------------------------------------------------------------------
612 
613 TransparencyPropertyBox::~TransparencyPropertyBox()
614 {
615 	delete mpControl;
616 }
617 
618 // --------------------------------------------------------------------
619 
620 void TransparencyPropertyBox::updateMenu()
621 {
622 	sal_Int64 nValue = mpMetric->GetValue();
623 	for( sal_uInt16 i = 25; i < 101; i += 25 )
624 		mpMenu->CheckItem( i, nValue == i );
625 }
626 
627 // --------------------------------------------------------------------
628 
629 IMPL_LINK( TransparencyPropertyBox, implModifyHdl, Control*, EMPTYARG )
630 {
631 	updateMenu();
632 	maModifyHdl.Call(mpMetric);
633 
634 	return 0;
635 }
636 
637 // --------------------------------------------------------------------
638 
639 IMPL_LINK( TransparencyPropertyBox, implMenuSelectHdl, MenuButton*, pPb )
640 {
641 	if( pPb->GetCurItemId() != mpMetric->GetValue() )
642 	{
643 		mpMetric->SetValue( pPb->GetCurItemId() );
644 		mpMetric->Modify();
645 	}
646 
647 	return 0;
648 }
649 
650 // --------------------------------------------------------------------
651 
652 void TransparencyPropertyBox::setValue( const Any& rValue, const OUString& )
653 {
654 	if( mpMetric )
655 	{
656 		double fValue = 0.0;
657 		rValue >>= fValue;
658 		long nValue = (long)(fValue * 100);
659 		mpMetric->SetValue( nValue );
660 		updateMenu();
661 	}
662 }
663 
664 // --------------------------------------------------------------------
665 
666 Any TransparencyPropertyBox::getValue()
667 {
668 	return makeAny( (double)((double)mpMetric->GetValue()) / 100.0 );
669 }
670 
671 // --------------------------------------------------------------------
672 
673 Control* TransparencyPropertyBox::getControl()
674 {
675 	return mpControl;
676 }
677 
678 // --------------------------------------------------------------------
679 
680 class RotationPropertyBox : public PropertySubControl
681 {
682 public:
683 	RotationPropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl );
684 	~RotationPropertyBox();
685 
686 	virtual Any getValue();
687 	virtual void setValue( const Any& rValue, const OUString& );
688 
689 	virtual Control* getControl();
690 
691 	DECL_LINK( implMenuSelectHdl, MenuButton* );
692 	DECL_LINK( implModifyHdl, Control* );
693 
694 	void updateMenu();
695 
696 private:
697 	DropdownMenuBox* mpControl;
698 	PopupMenu* mpMenu;
699 	MetricField* mpMetric;
700 	Link maModifyHdl;
701 };
702 
703 // --------------------------------------------------------------------
704 
705 RotationPropertyBox::RotationPropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl )
706 : PropertySubControl( nControlType )
707 , maModifyHdl( rModifyHdl )
708 {
709 	mpMetric = new MetricField( pParent ,WB_TABSTOP|WB_IGNORETAB| WB_NOBORDER);
710 	mpMetric->SetUnit( FUNIT_CUSTOM );
711 	mpMetric->SetCustomUnitText( OUString( sal_Unicode(0xb0)) ); // degree sign
712 	mpMetric->SetMin( -10000 );
713 	mpMetric->SetMax( 10000 );
714 
715 	mpMenu = new PopupMenu(SdResId( RID_CUSTOMANIMATION_ROTATION_POPUP ) );
716 	mpControl = new DropdownMenuBox( pParent, mpMetric, mpMenu );
717 	mpControl->SetMenuSelectHdl( LINK( this, RotationPropertyBox, implMenuSelectHdl ));
718 	mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_ROTATIONPROPERTYBOX );
719 
720 	Link aLink( LINK( this, RotationPropertyBox, implModifyHdl ) );
721 	mpControl->SetModifyHdl( aLink );
722 
723 	OUString aPresetId;
724 	setValue( rValue, aPresetId );
725 }
726 
727 // --------------------------------------------------------------------
728 
729 RotationPropertyBox::~RotationPropertyBox()
730 {
731 	delete mpControl;
732 }
733 
734 // --------------------------------------------------------------------
735 
736 void RotationPropertyBox::updateMenu()
737 {
738 	sal_Int64 nValue = mpMetric->GetValue();
739 	bool bDirection = nValue >= 0;
740 	nValue = (nValue < 0 ? -nValue : nValue);
741 
742 	mpMenu->CheckItem( CM_QUARTER_SPIN, nValue == 90 );
743 	mpMenu->CheckItem( CM_HALF_SPIN, nValue == 180 );
744 	mpMenu->CheckItem( CM_FULL_SPIN, nValue == 360 );
745 	mpMenu->CheckItem( CM_TWO_SPINS, nValue == 720 );
746 
747 	mpMenu->CheckItem( CM_CLOCKWISE, bDirection );
748 	mpMenu->CheckItem( CM_COUNTERCLOCKWISE, !bDirection );
749 }
750 
751 // --------------------------------------------------------------------
752 
753 IMPL_LINK( RotationPropertyBox, implModifyHdl, Control*, EMPTYARG )
754 {
755 	updateMenu();
756 	maModifyHdl.Call(mpMetric);
757 
758 	return 0;
759 }
760 
761 IMPL_LINK( RotationPropertyBox, implMenuSelectHdl, MenuButton*, pPb )
762 {
763 	sal_Int64 nValue = mpMetric->GetValue();
764 	bool bDirection = nValue >= 0;
765 	nValue = (nValue < 0 ? -nValue : nValue);
766 
767 	switch( pPb->GetCurItemId() )
768 	{
769 	case CM_QUARTER_SPIN: nValue = 90; break;
770 	case CM_HALF_SPIN: nValue = 180; break;
771 	case CM_FULL_SPIN: nValue = 360; break;
772 	case CM_TWO_SPINS: nValue = 720; break;
773 
774 	case CM_CLOCKWISE: bDirection = true; break;
775 	case CM_COUNTERCLOCKWISE: bDirection = false; break;
776 
777 	}
778 
779 	if( !bDirection )
780 		nValue = -nValue;
781 
782 	if( nValue != mpMetric->GetValue() )
783 	{
784 		mpMetric->SetValue( nValue );
785 		mpMetric->Modify();
786 	}
787 
788 	return 0;
789 }
790 
791 // --------------------------------------------------------------------
792 
793 void RotationPropertyBox::setValue( const Any& rValue, const OUString& )
794 {
795 	if( mpMetric )
796 	{
797 		double fValue = 0.0;
798 		rValue >>= fValue;
799 		long nValue = (long)(fValue);
800 		mpMetric->SetValue( nValue );
801 		updateMenu();
802 	}
803 }
804 
805 // --------------------------------------------------------------------
806 
807 Any RotationPropertyBox::getValue()
808 {
809 	return makeAny( (double)((double)mpMetric->GetValue()) );
810 }
811 
812 // --------------------------------------------------------------------
813 
814 Control* RotationPropertyBox::getControl()
815 {
816 	return mpControl;
817 }
818 
819 // --------------------------------------------------------------------
820 
821 class ScalePropertyBox : public PropertySubControl
822 {
823 public:
824 	ScalePropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl );
825 	~ScalePropertyBox();
826 
827 	virtual Any getValue();
828 	virtual void setValue( const Any& rValue, const OUString& );
829 
830 	virtual Control* getControl();
831 
832 	DECL_LINK( implMenuSelectHdl, MenuButton* );
833 	DECL_LINK( implModifyHdl, Control* );
834 
835 	void updateMenu();
836 
837 private:
838 	DropdownMenuBox* mpControl;
839 	PopupMenu* mpMenu;
840 	MetricField* mpMetric;
841 	Link maModifyHdl;
842 	int mnDirection;
843 };
844 
845 // --------------------------------------------------------------------
846 
847 ScalePropertyBox::ScalePropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl )
848 : PropertySubControl( nControlType )
849 , maModifyHdl( rModifyHdl )
850 {
851 	mpMetric = new MetricField( pParent ,WB_TABSTOP|WB_IGNORETAB| WB_NOBORDER);
852 	mpMetric->SetUnit( FUNIT_PERCENT );
853 	mpMetric->SetMin( 0 );
854 	mpMetric->SetMax( 10000 );
855 
856 	mpMenu = new PopupMenu(SdResId( RID_CUSTOMANIMATION_SCALE_POPUP ) );
857 	mpControl = new DropdownMenuBox( pParent, mpMetric, mpMenu );
858 	mpControl->SetMenuSelectHdl( LINK( this, ScalePropertyBox, implMenuSelectHdl ));
859 	mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_SCALEPROPERTYBOX );
860 
861 	Link aLink( LINK( this, ScalePropertyBox, implModifyHdl ) );
862 	mpControl->SetModifyHdl( aLink );
863 
864 	OUString aPresetId;
865 	setValue( rValue, aPresetId );
866 }
867 
868 // --------------------------------------------------------------------
869 
870 ScalePropertyBox::~ScalePropertyBox()
871 {
872 	delete mpControl;
873 }
874 
875 // --------------------------------------------------------------------
876 
877 void ScalePropertyBox::updateMenu()
878 {
879 	sal_Int64 nValue = mpMetric->GetValue();
880 
881 	mpMenu->CheckItem( 25, nValue == 25 );
882 	mpMenu->CheckItem( 50, nValue == 50 );
883 	mpMenu->CheckItem( 150, nValue == 150 );
884 	mpMenu->CheckItem( 400, nValue == 400 );
885 
886 	mpMenu->CheckItem( CM_HORIZONTAL, mnDirection == 1 );
887 	mpMenu->CheckItem( CM_VERTICAL, mnDirection == 2 );
888 	mpMenu->CheckItem( CM_BOTH, mnDirection == 3 );
889 }
890 
891 // --------------------------------------------------------------------
892 
893 IMPL_LINK( ScalePropertyBox, implModifyHdl, Control*, EMPTYARG )
894 {
895 	updateMenu();
896 	maModifyHdl.Call(mpMetric);
897 
898 	return 0;
899 }
900 
901 IMPL_LINK( ScalePropertyBox, implMenuSelectHdl, MenuButton*, pPb )
902 {
903 	sal_Int64 nValue = mpMetric->GetValue();
904 
905 	int nDirection = mnDirection;
906 
907 	switch( pPb->GetCurItemId() )
908 	{
909 	case CM_HORIZONTAL: nDirection = 1; break;
910 	case CM_VERTICAL: nDirection = 2; break;
911 	case CM_BOTH: nDirection = 3; break;
912 
913 	default:
914 		nValue = pPb->GetCurItemId();
915 	}
916 
917 	bool bModified = false;
918 
919 	if( nDirection != mnDirection )
920 	{
921 		mnDirection = nDirection;
922 		bModified = true;
923 	}
924 
925 	if( nValue != mpMetric->GetValue() )
926 	{
927 		mpMetric->SetValue( nValue );
928 		bModified = true;
929 	}
930 
931 	if( bModified )
932 	{
933 		mpMetric->Modify();
934 		updateMenu();
935 	}
936 
937 	return 0;
938 }
939 
940 // --------------------------------------------------------------------
941 
942 void ScalePropertyBox::setValue( const Any& rValue, const OUString& )
943 {
944 	if( mpMetric )
945 	{
946 		ValuePair aValues;
947 		rValue >>= aValues;
948 
949 		double fValue1 = 0.0;
950 		double fValue2 = 0.0;
951 
952 		aValues.First >>= fValue1;
953 		aValues.Second >>= fValue2;
954 
955 		if( fValue2 == 0.0 )
956 			mnDirection = 1;
957 		else if( fValue1 == 0.0 )
958 			mnDirection = 2;
959 		else
960 			mnDirection = 3;
961 
962 		long nValue;
963 		if( fValue1 )
964 			nValue = (long)(fValue1 * 100.0);
965 		else
966 			nValue = (long)(fValue2 * 100.0);
967 		mpMetric->SetValue( nValue );
968 		updateMenu();
969 	}
970 }
971 
972 // --------------------------------------------------------------------
973 
974 Any ScalePropertyBox::getValue()
975 {
976 	double fValue1 = (double)((double)mpMetric->GetValue() / 100.0);
977 	double fValue2 = fValue1;
978 
979 	if( mnDirection == 1 )
980 		fValue2 = 0.0;
981 	else if( mnDirection == 2 )
982 		fValue1 = 0.0;
983 
984 	ValuePair aValues;
985 	aValues.First <<= fValue1;
986 	aValues.Second <<= fValue2;
987 
988 	return makeAny( aValues );
989 }
990 
991 // --------------------------------------------------------------------
992 
993 Control* ScalePropertyBox::getControl()
994 {
995 	return mpControl;
996 }
997 
998 // ====================================================================
999 
1000 class FontStylePropertyBox : public PropertySubControl
1001 {
1002 public:
1003 	FontStylePropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl );
1004 	~FontStylePropertyBox();
1005 
1006 	virtual Any getValue();
1007 	virtual void setValue( const Any& rValue, const OUString& );
1008 
1009 	virtual Control* getControl();
1010 
1011 	DECL_LINK( implMenuSelectHdl, MenuButton* );
1012 
1013 	void update();
1014 
1015 private:
1016 	DropdownMenuBox* mpControl;
1017 	PopupMenu* mpMenu;
1018 	Edit* mpEdit;
1019 	Link maModifyHdl;
1020 
1021 	float mfFontWeight;
1022 	awt::FontSlant meFontSlant;
1023 	sal_Int16 mnFontUnderline;
1024 };
1025 
1026 // --------------------------------------------------------------------
1027 
1028 FontStylePropertyBox::FontStylePropertyBox( sal_Int32 nControlType, Window* pParent, const Any& rValue, const Link& rModifyHdl )
1029 : PropertySubControl( nControlType )
1030 , maModifyHdl( rModifyHdl )
1031 {
1032 	mpEdit = new Edit( pParent, WB_TABSTOP|WB_IGNORETAB|WB_NOBORDER|WB_READONLY);
1033 	mpEdit->SetText( String( SdResId( STR_CUSTOMANIMATION_SAMPLE ) ) );
1034 
1035 	mpMenu = new PopupMenu(SdResId( RID_CUSTOMANIMATION_FONTSTYLE_POPUP ) );
1036 	mpControl = new DropdownMenuBox( pParent, mpEdit, mpMenu );
1037 	mpControl->SetMenuSelectHdl( LINK( this, FontStylePropertyBox, implMenuSelectHdl ));
1038 	mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_FONTSTYLEPROPERTYBOX );
1039 
1040 	OUString aPresetId;
1041 	setValue( rValue, aPresetId );
1042 }
1043 
1044 // --------------------------------------------------------------------
1045 
1046 FontStylePropertyBox::~FontStylePropertyBox()
1047 {
1048 	delete mpControl;
1049 }
1050 
1051 // --------------------------------------------------------------------
1052 
1053 void FontStylePropertyBox::update()
1054 {
1055 	// update menu
1056 	mpMenu->CheckItem( CM_BOLD, mfFontWeight == awt::FontWeight::BOLD );
1057 	mpMenu->CheckItem( CM_ITALIC, meFontSlant == awt::FontSlant_ITALIC);
1058 	mpMenu->CheckItem( CM_UNDERLINED, mnFontUnderline != awt::FontUnderline::NONE );
1059 
1060 	// update sample edit
1061 	Font aFont( mpEdit->GetFont() );
1062 	aFont.SetWeight( mfFontWeight == awt::FontWeight::BOLD ? WEIGHT_BOLD : WEIGHT_NORMAL );
1063 	aFont.SetItalic( meFontSlant == awt::FontSlant_ITALIC ? ITALIC_NORMAL : ITALIC_NONE  );
1064 	aFont.SetUnderline( mnFontUnderline == awt::FontUnderline::NONE ? UNDERLINE_NONE : UNDERLINE_SINGLE );
1065 	mpEdit->SetFont( aFont );
1066 	mpEdit->Invalidate();
1067 }
1068 
1069 // --------------------------------------------------------------------
1070 
1071 IMPL_LINK( FontStylePropertyBox, implMenuSelectHdl, MenuButton*, pPb )
1072 {
1073 	switch( pPb->GetCurItemId() )
1074 	{
1075 	case CM_BOLD:
1076 		if( mfFontWeight == awt::FontWeight::BOLD )
1077 			mfFontWeight = awt::FontWeight::NORMAL;
1078 		else
1079 			mfFontWeight = awt::FontWeight::BOLD;
1080 		break;
1081 	case CM_ITALIC:
1082 		if( meFontSlant == awt::FontSlant_ITALIC )
1083 			meFontSlant = awt::FontSlant_NONE;
1084 		else
1085 			meFontSlant = awt::FontSlant_ITALIC;
1086 		break;
1087 	case CM_UNDERLINED:
1088 		if( mnFontUnderline == awt::FontUnderline::SINGLE )
1089 			mnFontUnderline = awt::FontUnderline::NONE;
1090 		else
1091 			mnFontUnderline = awt::FontUnderline::SINGLE;
1092 		break;
1093 	default:
1094 		return 0;
1095 	}
1096 
1097 	update();
1098 	maModifyHdl.Call(mpEdit);
1099 
1100 	return 0;
1101 }
1102 
1103 // --------------------------------------------------------------------
1104 
1105 void FontStylePropertyBox::setValue( const Any& rValue, const OUString& )
1106 {
1107 	Sequence<Any> aValues;
1108 	rValue >>= aValues;
1109 
1110 	aValues[0] >>= mfFontWeight;
1111 	aValues[1] >>= meFontSlant;
1112 	aValues[2] >>= mnFontUnderline;
1113 
1114 	update();
1115 }
1116 
1117 // --------------------------------------------------------------------
1118 
1119 Any FontStylePropertyBox::getValue()
1120 {
1121 	Sequence<Any> aValues(3);
1122 	aValues[0] <<= mfFontWeight;
1123 	aValues[1] <<= meFontSlant;
1124 	aValues[2] <<= mnFontUnderline;
1125 	return makeAny( aValues );
1126 }
1127 
1128 // --------------------------------------------------------------------
1129 
1130 Control* FontStylePropertyBox::getControl()
1131 {
1132 	return mpControl;
1133 }
1134 
1135 // ====================================================================
1136 
1137 class CustomAnimationEffectTabPage : public TabPage
1138 {
1139 public:
1140 	CustomAnimationEffectTabPage( Window* pParent, const ResId& rResId, const STLPropertySet* pSet );
1141 	~CustomAnimationEffectTabPage();
1142 
1143 	void update( STLPropertySet* pSet );
1144 	DECL_LINK( implSelectHdl, Control* );
1145 
1146 private:
1147 	void updateControlStates();
1148 	void fillSoundListBox();
1149 	void clearSoundListBox();
1150 	sal_Int32 getSoundObject( const String& rStr );
1151 	void openSoundFileDialog();
1152 	void onSoundPreview();
1153 
1154 private:
1155 	List maSoundList;
1156 	sal_Bool mbHasText;
1157 	const STLPropertySet* mpSet;
1158 
1159 	FixedLine*		mpFLSettings;
1160 	FixedText*		mpFTProperty1;
1161 	PropertyControl* mpLBProperty1;
1162 	FixedText*		mpFTProperty2;
1163 	PropertyControl* mpLBProperty2;
1164 	CheckBox*		mpCBSmoothStart;
1165 	CheckBox*		mpCBSmoothEnd;
1166 	CheckBox*		mpCBAutoRestart;
1167 
1168 	FixedLine*		mpFLPlay;
1169 	RadioButton*	mpRBFromStart;
1170 	RadioButton*	mpRBFromLast;
1171 	RadioButton*	mpRBFromTime;
1172 	MetricField*	mpMFStartTime;
1173 	FixedLine*		mpFLStop;
1174 	RadioButton*	mpRBStopOnClick;
1175 	RadioButton*	mpRBStopOnNextSlide;
1176 	RadioButton*	mpRBStopAfterSlides;
1177 	MetricField*	mpMFStopAfterSlides;
1178 
1179 	FixedLine*		mpFLEnhancements;
1180 	FixedText*		mpFTSound;
1181 	ListBox*		mpLBSound;
1182 	PushButton*		mpPBSoundPreview;
1183 	FixedText*		mpFTAfterEffect;
1184 	ListBox*		mpLBAfterEffect;
1185 	FixedText*		mpFTDimColor;
1186 	ColorListBox*	mpCLBDimColor;
1187 	FixedText*		mpFTTextAnim;
1188 	ListBox*		mpLBTextAnim;
1189 	MetricField*	mpMFTextDelay;
1190 	FixedText*		mpFTTextDelay;
1191 
1192 	::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > mxPlayer;
1193 };
1194 
1195 
1196 static void move_down( Control* pControl, int nOffsetX, int nOffsetY )
1197 {
1198 	Point aPos( pControl->GetPosPixel() );
1199 	aPos.X() += nOffsetX;
1200 	aPos.Y() += nOffsetY;
1201 	pControl->SetPosPixel( aPos );
1202 }
1203 
1204 CustomAnimationEffectTabPage::CustomAnimationEffectTabPage( Window* pParent, const ResId& rResId, const STLPropertySet* pSet )
1205 : TabPage( pParent, rResId ), mbHasText( sal_False ), mpSet(pSet )
1206 {
1207 	mpFLSettings = new FixedLine( this, SdResId( FL_SETTINGS ) );
1208 	mpFTProperty1 = new FixedText( this, SdResId( FT_PROPERTY_1 ) );
1209 	mpLBProperty1 = new PropertyControl( this, SdResId( LB_PROPERTY_1 ) );
1210 	mpFTProperty2 = new FixedText( this, SdResId( FT_PROPERTY_2 ) );
1211 	mpLBProperty2 = new PropertyControl( this, SdResId( LB_PROPERTY_2 ) );
1212 	mpCBSmoothStart = new CheckBox( this, SdResId( CB_SMOOTH_START ) );
1213 	mpCBSmoothEnd = new CheckBox( this, SdResId( CB_SMOOTH_END ) );
1214 	mpCBAutoRestart = new CheckBox( this, SdResId( CB_AUTORESTART ) );
1215 /*
1216 	mpFLPlay = new FixedLine( this, SdResId( FL_PLAY ) );
1217 	mpRBFromStart = new RadioButton( this, SdResId( RB_FROM_START ) );
1218 	mpRBFromLast = new RadioButton( this, SdResId( RB_FROM_LAST ) );
1219 	mpRBFromTime = new RadioButton( this, SdResId( RB_FROM_TIME ) );
1220 	mpMFStartTime = new MetricField( this, SdResId( MF_START_TIME ) );
1221 	mpFLStop = new FixedLine( this, SdResId( FL_STOP ) );
1222 	mpRBStopOnClick = new RadioButton( this, SdResId( RB_STOP_ON_CLICK ) );
1223 	mpRBStopOnNextSlide = new RadioButton( this, SdResId( RB_STOP_ON_NEXT_SLIDE ) );
1224 	mpRBStopAfterSlides = new RadioButton( this, SdResId( RB_STOP_AFTER_N_SLIDES ) );
1225 	mpMFStopAfterSlides = new MetricField( this, SdResId( MF_STOP_AFTER_SLIDES ) );
1226 */
1227 	mpFLEnhancements = new FixedLine( this, SdResId( FL_ENHANCEMENTS ) );
1228 	mpFTSound = new FixedText( this, SdResId( FT_SOUND ) );
1229 	mpLBSound = new ListBox( this, SdResId( LB_SOUND ) );
1230 	mpPBSoundPreview = new PushButton( this, SdResId( PB_SOUND_PREVIEW ) );
1231 	mpFTAfterEffect = new FixedText( this, SdResId( FT_AFTER_EFFECT ) );
1232 	mpLBAfterEffect = new ListBox( this, SdResId( LB_AFTER_EFFECT ) );
1233 	mpFTDimColor = new FixedText( this, SdResId( FT_DIMCOLOR ) );
1234 	mpCLBDimColor = new ColorListBox( this, SdResId( CLB_DIMCOLOR ) );
1235 	mpFTTextAnim = new FixedText( this, SdResId( FT_TEXT_ANIM ) );
1236 	mpLBTextAnim = new ListBox( this, SdResId( LB_TEXT_ANIM ) );
1237 	mpMFTextDelay = new MetricField( this, SdResId( MF_TEXT_DELAY ) );
1238 	mpFTTextDelay = new FixedText( this, SdResId( FT_TEXT_DELAY ) );
1239 
1240 	FreeResource();
1241 
1242 	// fill the soundbox
1243 	fillSoundListBox();
1244 
1245 	mpLBSound->SetSelectHdl( LINK( this, CustomAnimationEffectTabPage, implSelectHdl ) );
1246 
1247 	mpPBSoundPreview->SetClickHdl( LINK( this, CustomAnimationEffectTabPage, implSelectHdl ) );
1248 	mpPBSoundPreview->SetSymbol( SYMBOL_PLAY );
1249 
1250 	// fill the color box
1251 	SfxObjectShell* pDocSh = SfxObjectShell::Current();
1252 	DBG_ASSERT( pDocSh, "DocShell not found!" );
1253 	XColorList* pColorTable = NULL;
1254 	bool bKillTable = false;
1255 	const SfxPoolItem* pItem = NULL;
1256 
1257 	if ( pDocSh && ( (pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) != 0 ) )
1258 		pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable();
1259 
1260 	if ( !pColorTable )
1261 	{
1262 		pColorTable = new XColorList( SvtPathOptions().GetPalettePath() );
1263 		bKillTable = sal_True;
1264 	}
1265 
1266     mpCLBDimColor->SetUpdateMode( sal_False );
1267 
1268     for ( long i = 0; i < pColorTable->Count(); i++ )
1269 	{
1270 		XColorEntry* pEntry = pColorTable->GetColor(i);
1271         mpCLBDimColor->InsertEntry( pEntry->GetColor(), pEntry->GetName() );
1272 	}
1273 
1274     mpCLBDimColor->SetUpdateMode( sal_True );
1275 
1276 	if ( bKillTable )
1277 		delete pColorTable;
1278 
1279 	//
1280 	// init settings controls
1281 	//
1282 
1283 	int nOffsetY = 0;
1284 	int nOffsetX = 0;
1285 
1286 	Size aSpace( LogicToPixel( Size( 3, 3 ), MAP_APPFONT ) );
1287 
1288 	// only show settings if all selected effects have the same preset-id
1289 	if( pSet->getPropertyState( nHandlePresetId ) != STLPropertyState_AMBIGUOUS )
1290 	{
1291 		OUString aPresetId;
1292 		pSet->getPropertyValue( nHandlePresetId ) >>= aPresetId;
1293 
1294 		//
1295 		// property 1
1296 		//
1297 
1298 		if( pSet->getPropertyState( nHandleProperty1Type ) != STLPropertyState_AMBIGUOUS )
1299 		{
1300 			sal_Int32 nType = 0;
1301 			pSet->getPropertyValue( nHandleProperty1Type ) >>= nType;
1302 
1303 			if( nType != nPropertyTypeNone )
1304 			{
1305 				// set ui name for property at fixed text
1306 				OUString aPropertyName( getPropertyName( nType ) );
1307 
1308 				if( aPropertyName.getLength() )
1309 				{
1310 					mpFTProperty1->Show();
1311 					mpLBProperty1->Show();
1312 
1313 					nOffsetY += mpLBProperty1->GetSizePixel().Height() + aSpace.Height();
1314 
1315 					mpFTProperty1->SetText( aPropertyName );
1316 				}
1317 
1318 				// get property value
1319 				const Any aValue( pSet->getPropertyValue( nHandleProperty1Value ) );
1320 
1321 				Link aModifyLink;
1322 				// create property sub control
1323 				mpLBProperty1->setSubControl( PropertySubControl::create( nType, this, aValue, aPresetId, aModifyLink ));
1324 			}
1325 		}
1326 
1327 		mpFTProperty1->Enable( mpLBProperty1->IsEnabled() );
1328 
1329 		//
1330 		// accelerate & deccelerate
1331 		//
1332 
1333 		if( pSet->getPropertyState( nHandleAccelerate ) == STLPropertyState_DIRECT )
1334 		{
1335 			mpCBSmoothStart->Show();
1336 			mpCBSmoothEnd->Show();
1337 
1338 			move_down( mpCBSmoothStart, nOffsetX, nOffsetY );
1339 			move_down( mpCBSmoothEnd, nOffsetX, nOffsetY );
1340 
1341 			nOffsetY += mpCBSmoothStart->GetSizePixel().Height() + aSpace.Height();
1342 
1343 			double fTemp = 0.0;
1344 			pSet->getPropertyValue( nHandleAccelerate ) >>= fTemp;
1345 			mpCBSmoothStart->Check( fTemp > 0.0 );
1346 
1347 			pSet->getPropertyValue( nHandleDecelerate ) >>= fTemp;
1348 			mpCBSmoothEnd->Check( fTemp > 0.0 );
1349 		}
1350 
1351 		//
1352 		// auto reverse
1353 		//
1354 
1355 
1356 		if( nOffsetY )
1357 		{
1358 			nOffsetY += mpFLSettings->GetSizePixel().Height() + aSpace.Height();
1359 			mpFLSettings->Show();
1360 
1361 			mpFLEnhancements->Show();
1362 			move_down( mpFLEnhancements, nOffsetX, nOffsetY );
1363 
1364 			nOffsetY += mpFLEnhancements->GetSizePixel().Height() + aSpace.Height();
1365 
1366 			nOffsetX = 2* aSpace.Width();
1367 		}
1368 	}
1369 
1370 	if( (nOffsetY != 0) || (nOffsetX != 0) )
1371 	{
1372 		move_down( mpFTSound, nOffsetX, nOffsetY );
1373 		move_down( mpLBSound, nOffsetX, nOffsetY );
1374 		move_down( mpPBSoundPreview, nOffsetX, nOffsetY );
1375 		move_down( mpFTAfterEffect, nOffsetX, nOffsetY );
1376 		move_down( mpLBAfterEffect, nOffsetX, nOffsetY );
1377 		move_down( mpFTDimColor, nOffsetX, nOffsetY );
1378 		move_down( mpCLBDimColor, nOffsetX, nOffsetY );
1379 		move_down( mpFTTextAnim, nOffsetX, nOffsetY );
1380 		move_down( mpLBTextAnim, nOffsetX, nOffsetY );
1381 		move_down( mpMFTextDelay, nOffsetX, nOffsetY );
1382 		move_down( mpFTTextDelay, nOffsetX, nOffsetY );
1383 	}
1384 
1385 	//
1386 	// init after effect controls
1387 	//
1388 
1389     mpLBAfterEffect->SetSelectHdl( LINK( this, CustomAnimationEffectTabPage, implSelectHdl ) );
1390     mpLBTextAnim->SetSelectHdl( LINK( this, CustomAnimationEffectTabPage, implSelectHdl ) );
1391 
1392 	if( (pSet->getPropertyState( nHandleHasAfterEffect ) != STLPropertyState_AMBIGUOUS) &&
1393 		(pSet->getPropertyState( nHandleAfterEffectOnNextEffect ) != STLPropertyState_AMBIGUOUS) &&
1394 		(pSet->getPropertyState( nHandleDimColor ) != STLPropertyState_AMBIGUOUS))
1395 	{
1396 		sal_Bool bHasAfterEffect = sal_False;
1397 		pSet->getPropertyValue( nHandleHasAfterEffect ) >>= bHasAfterEffect;
1398 
1399 		sal_uInt16 nPos = 0;
1400 		if( bHasAfterEffect )
1401 		{
1402 			nPos++;
1403 
1404 			sal_Bool bAfterEffectOnNextClick = sal_False;
1405 			pSet->getPropertyValue( nHandleAfterEffectOnNextEffect ) >>= bAfterEffectOnNextClick;
1406 			Any aDimColor( pSet->getPropertyValue( nHandleDimColor ) );
1407 
1408 			if( aDimColor.hasValue() )
1409 			{
1410 				sal_Int32 nColor = 0;
1411 				aDimColor >>= nColor;
1412 				Color aColor( nColor );
1413 	            sal_uInt16 nColorPos = mpCLBDimColor->GetEntryPos( aColor );
1414 				if ( LISTBOX_ENTRY_NOTFOUND != nColorPos )
1415 					mpCLBDimColor->SelectEntryPos( nColorPos );
1416 				else
1417                     mpCLBDimColor->SelectEntryPos(
1418                         mpCLBDimColor->InsertEntry( aColor, String( SVX_RES( RID_SVXSTR_COLOR_USER ) ) ) );
1419 			}
1420 			else
1421 			{
1422 				nPos++;
1423 				if( bAfterEffectOnNextClick )
1424 					nPos++;
1425 			}
1426 		}
1427 
1428 		mpLBAfterEffect->SelectEntryPos( nPos );
1429 	}
1430 
1431 	if( pSet->getPropertyState( nHandleHasText ) != STLPropertyState_AMBIGUOUS )
1432 		pSet->getPropertyValue( nHandleHasText ) >>= mbHasText;
1433 
1434 	if( mbHasText )
1435 	{
1436 		if( pSet->getPropertyState( nHandleIterateType ) != STLPropertyState_AMBIGUOUS)
1437 		{
1438 			sal_uInt16 nPos = LISTBOX_ENTRY_NOTFOUND;
1439 
1440 			sal_Int32 nIterateType = 0;
1441 			pSet->getPropertyValue( nHandleIterateType ) >>= nIterateType;
1442 			switch( nIterateType )
1443 			{
1444 			case TextAnimationType::BY_PARAGRAPH:	nPos = 0; break;
1445 			case TextAnimationType::BY_WORD:		nPos = 1; break;
1446 			case TextAnimationType::BY_LETTER:		nPos = 2; break;
1447 			}
1448 
1449 			mpLBTextAnim->SelectEntryPos( nPos );
1450 		}
1451 
1452 		if( pSet->getPropertyState( nHandleIterateInterval ) )
1453 		{
1454 			double fIterateInterval = 0.0;
1455 			pSet->getPropertyValue( nHandleIterateInterval ) >>= fIterateInterval;
1456 			mpMFTextDelay->SetValue( (long)(fIterateInterval*10) );
1457 		}
1458 	}
1459 	else
1460 	{
1461 		mpFTTextAnim->Enable( sal_False );
1462 		mpLBTextAnim->Enable( sal_False );
1463 		mpMFTextDelay->Enable( sal_False );
1464 		mpFTTextDelay->Enable( sal_False );
1465 
1466 	}
1467 
1468 	if( pSet->getPropertyState( nHandleSoundURL ) != STLPropertyState_AMBIGUOUS )
1469 	{
1470 		sal_uInt16 nPos = 0;
1471 
1472 		const Any aValue( pSet->getPropertyValue( nHandleSoundURL ) );
1473 
1474 		if( aValue.getValueType() == ::getCppuType((const sal_Bool*)0) )
1475 		{
1476 			nPos = 1;
1477 		}
1478 		else
1479 		{
1480 			OUString aSoundURL;
1481 			aValue >>= aSoundURL;
1482 
1483 			if( aSoundURL.getLength() )
1484 			{
1485 				const String aTmp( aSoundURL );
1486 
1487 				sal_uLong i;
1488 				for( i = 0; i < maSoundList.Count(); i++ )
1489 				{
1490 					String* pString = (String*)maSoundList.GetObject( i );
1491 					if( *pString == aTmp )
1492 					{
1493 						nPos = (sal_uInt16)i+2;
1494 						break;
1495 					}
1496 				}
1497 
1498 				if( nPos == 0 )
1499 				{
1500 					nPos = (sal_uInt16)maSoundList.Count()+2;
1501 					maSoundList.Insert( new String( aTmp ), LIST_APPEND );
1502 					INetURLObject aURL( aTmp );
1503 					nPos = mpLBSound->InsertEntry( aURL.GetBase(), nPos );
1504 				}
1505 			}
1506 		}
1507 
1508 		if( nPos != LISTBOX_ENTRY_NOTFOUND )
1509 			mpLBSound->SelectEntryPos( nPos );
1510 	}
1511 
1512 	updateControlStates();
1513 
1514 	Size aSize( GetSizePixel() );
1515 	aSize.Height() += mpMFTextDelay->GetPosPixel().X() + GetSizePixel().Height() + aSpace.Height();
1516 	SetSizePixel( aSize );
1517 }
1518 
1519 CustomAnimationEffectTabPage::~CustomAnimationEffectTabPage()
1520 {
1521 	clearSoundListBox();
1522 
1523 	delete mpFLSettings;
1524 	delete mpFTProperty1;
1525 	delete mpLBProperty1;
1526 	delete mpFTProperty2;
1527 	delete mpLBProperty2;
1528 	delete mpCBSmoothStart;
1529 	delete mpCBSmoothEnd;
1530 	delete mpCBAutoRestart;
1531 
1532 	delete mpFLEnhancements;
1533 	delete mpFTSound;
1534 	delete mpLBSound;
1535 	delete mpPBSoundPreview;
1536 	delete mpFTAfterEffect;
1537 	delete mpLBAfterEffect;
1538 	delete mpFTDimColor;
1539 	delete mpCLBDimColor;
1540 	delete mpFTTextAnim;
1541 	delete mpLBTextAnim;
1542 	delete mpMFTextDelay;
1543 	delete mpFTTextDelay;
1544 }
1545 
1546 void CustomAnimationEffectTabPage::updateControlStates()
1547 {
1548 	sal_uInt16 nPos = mpLBAfterEffect->GetSelectEntryPos();
1549 	mpCLBDimColor->Enable( nPos == 1 );
1550 	mpFTDimColor->Enable( nPos == 1 );
1551 
1552 	if( mbHasText )
1553 	{
1554 		nPos = mpLBTextAnim->GetSelectEntryPos();
1555 		mpMFTextDelay->Enable( nPos != 0 );
1556 		mpFTTextDelay->Enable( nPos != 0 );
1557 	}
1558 
1559 	nPos = mpLBSound->GetSelectEntryPos();
1560 	mpPBSoundPreview->Enable( nPos >= 2 );
1561 }
1562 
1563 IMPL_LINK( CustomAnimationEffectTabPage, implSelectHdl, Control*, pControl )
1564 {
1565 	if( pControl == mpLBAfterEffect )
1566 	{
1567 		sal_uInt16 nPos = static_cast<ListBox*>( mpLBAfterEffect )->GetSelectEntryPos();
1568 		if( nPos == 1 )
1569 		{
1570 			if( mpCLBDimColor->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND )
1571 				mpCLBDimColor->SelectEntryPos(0);
1572 		}
1573 	}
1574 	else if( pControl == mpLBTextAnim )
1575 	{
1576 		if( mpMFTextDelay->GetValue() == 0 )
1577 			mpMFTextDelay->SetValue( 100 );
1578 	}
1579 	else if( pControl == mpLBSound )
1580 	{
1581 		sal_uInt16 nPos = mpLBSound->GetSelectEntryPos();
1582 		if( nPos == (mpLBSound->GetEntryCount() - 1) )
1583 		{
1584 			openSoundFileDialog();
1585 		}
1586 	}
1587 	else if( pControl == mpPBSoundPreview )
1588 	{
1589 		onSoundPreview();
1590 	}
1591 
1592 	updateControlStates();
1593 	return 0;
1594 }
1595 
1596 void CustomAnimationEffectTabPage::update( STLPropertySet* pSet )
1597 {
1598 	if( mpLBProperty1->getSubControl() )
1599 	{
1600 		Any aNewValue( mpLBProperty1->getSubControl()->getValue() );
1601 		Any aOldValue;
1602 		if( mpSet->getPropertyState( nHandleProperty1Value ) != STLPropertyState_AMBIGUOUS)
1603 			aOldValue = mpSet->getPropertyValue( nHandleProperty1Value );
1604 
1605 		if( aOldValue != aNewValue )
1606 			pSet->setPropertyValue( nHandleProperty1Value, aNewValue );
1607 	}
1608 
1609 	if( mpLBProperty2->getSubControl() )
1610 	{
1611 		Any aNewValue( mpLBProperty2->getSubControl()->getValue() );
1612 		Any aOldValue;
1613 		if( mpSet->getPropertyState( nHandleProperty2Value ) != STLPropertyState_AMBIGUOUS)
1614 			aOldValue = mpSet->getPropertyValue( nHandleProperty2Value );
1615 
1616 		if( aOldValue != aNewValue )
1617 			pSet->setPropertyValue( nHandleProperty2Value, aNewValue );
1618 	}
1619 
1620 	if( mpCBSmoothStart->IsVisible() )
1621 	{
1622 		// set selected value for accelerate if different then in original set
1623 
1624 		double fTemp = mpCBSmoothStart->IsChecked() ? 0.5 : 0.0;
1625 
1626 		double fOldTemp = 0.0;
1627 		if(mpSet->getPropertyState( nHandleAccelerate ) != STLPropertyState_AMBIGUOUS)
1628 			mpSet->getPropertyValue( nHandleAccelerate ) >>= fOldTemp;
1629 		else
1630 			fOldTemp = -2.0;
1631 
1632 		if( fOldTemp != fTemp )
1633 			pSet->setPropertyValue( nHandleAccelerate, makeAny( fTemp ) );
1634 
1635 		// set selected value for decelerate if different then in original set
1636 		fTemp = mpCBSmoothEnd->IsChecked() ? 0.5 : 0.0;
1637 
1638 		if(mpSet->getPropertyState( nHandleDecelerate ) != STLPropertyState_AMBIGUOUS)
1639 			mpSet->getPropertyValue( nHandleDecelerate ) >>= fOldTemp;
1640 		else
1641 			fOldTemp = -2.0;
1642 
1643 		if( fOldTemp != fTemp )
1644 			pSet->setPropertyValue( nHandleDecelerate, makeAny( fTemp ) );
1645 	}
1646 
1647 	sal_uInt16 nPos = mpLBAfterEffect->GetSelectEntryPos();
1648 	if( nPos != LISTBOX_ENTRY_NOTFOUND )
1649 	{
1650 		sal_Bool bAfterEffect = nPos != 0;
1651 
1652 		sal_Bool bOldAfterEffect = sal_False;
1653 
1654 		if(mpSet->getPropertyState( nHandleHasAfterEffect ) != STLPropertyState_AMBIGUOUS)
1655 			mpSet->getPropertyValue( nHandleHasAfterEffect ) >>= bOldAfterEffect;
1656 		else
1657 			bOldAfterEffect = !bAfterEffect;
1658 
1659 		if( bOldAfterEffect != bAfterEffect )
1660 			pSet->setPropertyValue( nHandleHasAfterEffect, makeAny( bAfterEffect ) );
1661 
1662 		Any aDimColor;
1663 		if( nPos == 1 )
1664 		{
1665 			Color aSelectedColor;
1666 			if ( mpCLBDimColor->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
1667 				aSelectedColor = mpCLBDimColor->GetSelectEntryColor();
1668 
1669 			aDimColor = makeAny( makeAny( (sal_Int32)aSelectedColor.GetRGBColor() ) );
1670 		}
1671 
1672 		if( (mpSet->getPropertyState( nHandleDimColor ) == STLPropertyState_AMBIGUOUS) ||
1673 			(mpSet->getPropertyValue( nHandleDimColor ) != aDimColor) )
1674 			pSet->setPropertyValue( nHandleDimColor, makeAny( aDimColor ) );
1675 
1676 		sal_Bool bAfterEffectOnNextEffect = nPos != 2 ? sal_True : sal_False;
1677 		sal_Bool bOldAfterEffectOnNextEffect = !bAfterEffectOnNextEffect;
1678 
1679 		if( mpSet->getPropertyState( nHandleAfterEffectOnNextEffect ) != STLPropertyState_AMBIGUOUS)
1680 			mpSet->getPropertyValue( nHandleAfterEffectOnNextEffect ) >>= bOldAfterEffectOnNextEffect;
1681 
1682 		if( bAfterEffectOnNextEffect != bOldAfterEffectOnNextEffect )
1683 			pSet->setPropertyValue( nHandleAfterEffectOnNextEffect, makeAny( bAfterEffectOnNextEffect ) );
1684 	}
1685 
1686 	// ---
1687 
1688 	nPos = mpLBTextAnim->GetSelectEntryPos();
1689 	if( nPos != LISTBOX_ENTRY_NOTFOUND )
1690 	{
1691 		sal_Int16 nIterateType;
1692 
1693 		switch( nPos )
1694 		{
1695 		case 1: nIterateType = TextAnimationType::BY_WORD; break;
1696 		case 2: nIterateType = TextAnimationType::BY_LETTER; break;
1697 		default:
1698 			nIterateType = TextAnimationType::BY_PARAGRAPH;
1699 		}
1700 
1701 		sal_Int16 nOldIterateType = nIterateType-1;
1702 
1703 		if(mpSet->getPropertyState( nHandleIterateType ) != STLPropertyState_AMBIGUOUS)
1704 			mpSet->getPropertyValue( nHandleIterateType ) >>= nOldIterateType;
1705 
1706 		if( nIterateType != nOldIterateType )
1707 			pSet->setPropertyValue( nHandleIterateType, makeAny( nIterateType ) );
1708 	}
1709 
1710 	// ---
1711 
1712 	{
1713 		double fIterateInterval = static_cast< double >( mpMFTextDelay->GetValue() ) / 10;
1714 		double fOldIterateInterval = -1.0;
1715 
1716 		if( mpSet->getPropertyState( nHandleIterateInterval ) != STLPropertyState_AMBIGUOUS )
1717 			mpSet->getPropertyValue( nHandleIterateInterval ) >>= fOldIterateInterval;
1718 
1719 		if( fIterateInterval != fOldIterateInterval )
1720 			pSet->setPropertyValue( nHandleIterateInterval, makeAny( fIterateInterval ) );
1721 	}
1722 
1723 	nPos = mpLBSound->GetSelectEntryPos();
1724 	if( nPos != LISTBOX_ENTRY_NOTFOUND )
1725 	{
1726 		Any aNewSoundURL, aOldSoundURL( makeAny( (sal_Int32) 0 ) );
1727 
1728 		if( nPos == 0 )
1729 		{
1730 			// 0 means no sound, so leave any empty
1731 		}
1732 		else if( nPos == 1 )
1733 		{
1734 			// this means stop sound
1735 			aNewSoundURL = makeAny( (sal_Bool)sal_True );
1736 		}
1737 		else
1738 		{
1739 			OUString aSoundURL( *(String*)maSoundList.GetObject( nPos-2 ) );
1740 			aNewSoundURL = makeAny( aSoundURL );
1741 		}
1742 
1743 		if( mpSet->getPropertyState( nHandleSoundURL ) != STLPropertyState_AMBIGUOUS )
1744 			mpSet->getPropertyValue( nHandleSoundURL  ) >>= aOldSoundURL;
1745 
1746 		if( aNewSoundURL != aOldSoundURL )
1747 			pSet->setPropertyValue( nHandleSoundURL, aNewSoundURL );
1748 	}
1749 }
1750 
1751 void CustomAnimationEffectTabPage::fillSoundListBox()
1752 {
1753 	GalleryExplorer::FillObjList( GALLERY_THEME_SOUNDS, maSoundList );
1754 	GalleryExplorer::FillObjList( GALLERY_THEME_USERSOUNDS, maSoundList );
1755 
1756 	mpLBSound->InsertEntry( String( SdResId( STR_CUSTOMANIMATION_NO_SOUND ) ) );
1757 	mpLBSound->InsertEntry( String( SdResId( STR_CUSTOMANIMATION_STOP_PREVIOUS_SOUND ) ) );
1758 	for( sal_uLong i = 0; i < maSoundList.Count(); i++ )
1759 	{
1760 		String* pString = (String*)maSoundList.GetObject( i );
1761 		INetURLObject aURL( *pString );
1762 		mpLBSound->InsertEntry( aURL.GetBase() );
1763 	}
1764 	mpLBSound->InsertEntry( String( SdResId( STR_CUSTOMANIMATION_BROWSE_SOUND ) ) );
1765 }
1766 
1767 void CustomAnimationEffectTabPage::clearSoundListBox()
1768 {
1769 	const sal_uInt32 nCount = maSoundList.Count();
1770 	sal_uInt32 i;
1771 	for( i = 0; i < nCount; i++ )
1772 		delete (String*)maSoundList.GetObject( i );
1773 	maSoundList.Clear();
1774 
1775 	mpLBSound->Clear();
1776 }
1777 
1778 sal_Int32 CustomAnimationEffectTabPage::getSoundObject( const String& rStr )
1779 {
1780 	String aStrIn( rStr );
1781 	aStrIn.ToLowerAscii();
1782 
1783 	sal_uInt32 i;
1784 	const sal_uInt32 nCount = maSoundList.Count();
1785 	for( i = 0; i < nCount; i++ )
1786 	{
1787 		String aTmpStr( *(String*)maSoundList.GetObject( i ) );
1788 		aTmpStr.ToLowerAscii();
1789 
1790 		if( aTmpStr == aStrIn )
1791 			return i+2;
1792 	}
1793 
1794 	return -1;
1795 }
1796 
1797 void CustomAnimationEffectTabPage::openSoundFileDialog()
1798 {
1799 	SdOpenSoundFileDialog	aFileDialog;
1800 
1801 	String aFile( SvtPathOptions().GetGraphicPath() );
1802 	aFileDialog.SetPath( aFile );
1803 
1804 	bool bValidSoundFile = false;
1805 	bool bQuitLoop = false;
1806 	long nPos = 0;
1807 
1808 	while( !bQuitLoop && (aFileDialog.Execute() == ERRCODE_NONE) )
1809 	{
1810 		aFile = aFileDialog.GetPath();
1811 		nPos = getSoundObject( aFile );
1812 
1813 		if( nPos < 0 ) // not in Soundliste
1814 		{
1815 			// try to insert in Gallery
1816 			if( GalleryExplorer::InsertURL( GALLERY_THEME_USERSOUNDS, aFile, SGA_FORMAT_SOUND ) )
1817 			{
1818 				clearSoundListBox();
1819 				fillSoundListBox();
1820 
1821 				nPos = getSoundObject( aFile );
1822 				DBG_ASSERT( nPos >= 0, "sd::CustomAnimationEffectTabPage::openSoundFileDialog(), Recently inserted sound not in list!" );
1823 
1824 				bValidSoundFile=true;
1825 				bQuitLoop=true;
1826 			}
1827 			else
1828 			{
1829 				String aStrWarning(SdResId(STR_WARNING_NOSOUNDFILE));
1830 				String aStr; aStr += sal_Unicode('%');
1831 				aStrWarning.SearchAndReplace( aStr , aFile );
1832 				WarningBox aWarningBox( NULL, WB_3DLOOK | WB_RETRY_CANCEL, aStrWarning );
1833 				aWarningBox.SetModalInputMode (sal_True);
1834 				bQuitLoop = aWarningBox.Execute()==RET_RETRY ? sal_False : sal_True;
1835 
1836 				bValidSoundFile=false;
1837 			}
1838 		}
1839 		else
1840 		{
1841 			bValidSoundFile=true;
1842 			bQuitLoop=true;
1843 		}
1844 	}
1845 
1846 	if( !bValidSoundFile )
1847 		nPos = 0;
1848 
1849 	mpLBSound->SelectEntryPos( (sal_uInt16) nPos );
1850 }
1851 
1852 void CustomAnimationEffectTabPage::onSoundPreview()
1853 {
1854 	const sal_uInt16 nPos = mpLBSound->GetSelectEntryPos();
1855 
1856 	if( nPos >= 2 ) try
1857     {
1858 		const OUString aSoundURL( *(String*)maSoundList.GetObject( nPos-2 ) );
1859                 mxPlayer.set( avmedia::MediaWindow::createPlayer( aSoundURL ), uno::UNO_QUERY_THROW );
1860 		mxPlayer->start();
1861 	}
1862     catch( uno::Exception& e )
1863     {
1864 		(void)e;
1865         DBG_ERROR("CustomAnimationEffectTabPage::onSoundPreview(), exception caught!" );
1866     }
1867 }
1868 
1869 class CustomAnimationDurationTabPage : public TabPage
1870 {
1871 public:
1872 	CustomAnimationDurationTabPage( Window* pParent, const ResId& rResId, const STLPropertySet* pSet );
1873 	~CustomAnimationDurationTabPage();
1874 
1875 	void update( STLPropertySet* pSet );
1876 
1877 	DECL_LINK( implControlHdl, Control* );
1878 
1879 private:
1880 	const STLPropertySet* mpSet;
1881 
1882 	boost::shared_ptr< FixedText > mpFTStart;
1883 	boost::shared_ptr< ListBox > mpLBStart;
1884 	boost::shared_ptr< FixedText > mpFTStartDelay;
1885 	boost::shared_ptr< MetricField > mpMFStartDelay;
1886 	boost::shared_ptr< FixedText > mpFTDuration;
1887 	boost::shared_ptr< ComboBox > mpCBDuration;
1888 	boost::shared_ptr< FixedText > mpFTRepeat;
1889 	boost::shared_ptr< ComboBox > mpCBRepeat;
1890 	boost::shared_ptr< CheckBox > mpCBXRewind;
1891 	boost::shared_ptr< FixedLine > mpFLTrigger;
1892 	boost::shared_ptr< RadioButton > mpRBClickSequence;
1893 	boost::shared_ptr< RadioButton > mpRBInteractive;
1894 	boost::shared_ptr< ListBox > mpLBTrigger;
1895 };
1896 
1897 CustomAnimationDurationTabPage::CustomAnimationDurationTabPage(Window* pParent, const ResId& rResId, const STLPropertySet* pSet)
1898 : TabPage( pParent, rResId ), mpSet( pSet )
1899 {
1900 	mpFTStart.reset( new FixedText( this, SdResId( FT_START ) ) );
1901 	mpLBStart.reset( new ListBox( this, SdResId( LB_START ) ) );
1902 	mpFTStartDelay.reset( new FixedText( this, SdResId( FT_START_DELAY ) ) );
1903 	mpMFStartDelay.reset( new MetricField( this, SdResId( MF_START_DELAY ) ) );
1904 	mpFTDuration.reset( new FixedText( this, SdResId( FT_DURATION ) ) );
1905 	mpCBDuration.reset( new ComboBox( this, SdResId( CB_DURATION ) ) );
1906 	mpFTRepeat.reset( new FixedText( this, SdResId( FT_REPEAT ) ) );
1907 	mpCBRepeat.reset( new ComboBox( this, SdResId( CB_REPEAT ) ) );
1908 	mpCBXRewind.reset( new CheckBox( this, SdResId( CBX_REWIND ) ) );
1909 	mpFLTrigger.reset( new FixedLine( this, SdResId( FL_TRIGGER ) ) );
1910 	mpRBClickSequence.reset( new RadioButton( this, SdResId( RB_CLICKSEQUENCE ) ) );
1911 	mpRBInteractive.reset( new RadioButton( this, SdResId( RB_INTERACTIVE ) ) );
1912 	mpLBTrigger.reset( new ListBox( this, SdResId( LB_TRIGGER ) ) );
1913 
1914 	fillRepeatComboBox( mpCBRepeat.get() );
1915 	fillDurationComboBox( mpCBDuration.get() );
1916 
1917 	FreeResource();
1918 
1919     mpRBClickSequence->SetClickHdl( LINK( this, CustomAnimationDurationTabPage, implControlHdl ) );
1920     mpRBClickSequence->SetClickHdl( LINK( this, CustomAnimationDurationTabPage, implControlHdl ) );
1921     mpLBTrigger->SetSelectHdl( LINK( this, CustomAnimationDurationTabPage, implControlHdl ) );
1922 
1923 	if( pSet->getPropertyState( nHandleStart ) != STLPropertyState_AMBIGUOUS )
1924 	{
1925 		sal_Int16 nStart = 0;
1926 		pSet->getPropertyValue( nHandleStart ) >>= nStart;
1927 		sal_uInt16 nPos = 0;
1928 		switch( nStart )
1929 		{
1930 			case EffectNodeType::WITH_PREVIOUS:		nPos = 1; break;
1931 			case EffectNodeType::AFTER_PREVIOUS:	nPos = 2; break;
1932 		}
1933 		mpLBStart->SelectEntryPos( nPos );
1934 	}
1935 
1936 	if( pSet->getPropertyState( nHandleBegin ) != STLPropertyState_AMBIGUOUS )
1937 	{
1938 		double fBegin = 0.0;
1939 		pSet->getPropertyValue( nHandleBegin ) >>= fBegin;
1940 		mpMFStartDelay->SetValue( (long)(fBegin*10) );
1941 	}
1942 
1943 	if( pSet->getPropertyState( nHandleDuration ) != STLPropertyState_AMBIGUOUS )
1944 	{
1945 		double fDuration = 0.0;
1946 		pSet->getPropertyValue( nHandleDuration ) >>= fDuration;
1947 
1948 		if( fDuration == 0.001 )
1949 		{
1950 			mpFTDuration->Disable();
1951 			mpCBDuration->Disable();
1952 			mpFTRepeat->Disable();
1953 			mpCBRepeat->Disable();
1954 			mpCBXRewind->Disable();
1955 		}
1956 		else
1957 		{
1958 			sal_uInt16 nPos = LISTBOX_ENTRY_NOTFOUND;
1959 
1960 			if( fDuration == 5.0 )
1961 				nPos = 0;
1962 			else if( fDuration == 3.0 )
1963 				nPos = 1;
1964 			else if( fDuration == 2.0 )
1965 				nPos = 2;
1966 			else if( fDuration == 1.0 )
1967 				nPos = 3;
1968 			else if( fDuration == 0.5 )
1969 				nPos = 4;
1970 
1971 			if( nPos != LISTBOX_ENTRY_NOTFOUND )
1972 				mpCBDuration->SelectEntryPos( nPos );
1973 			else
1974 				mpCBDuration->SetText( String::CreateFromDouble( fDuration ) );
1975 		}
1976 	}
1977 
1978 	if( pSet->getPropertyState( nHandleRepeat ) != STLPropertyState_AMBIGUOUS )
1979 	{
1980 		Any aRepeatCount( pSet->getPropertyValue( nHandleRepeat ) );
1981 		if( (aRepeatCount.getValueType() == ::getCppuType((const double*)0)) || !aRepeatCount.hasValue() )
1982 		{
1983 			double fRepeat = 0.0;
1984 			if( aRepeatCount.hasValue() )
1985 				aRepeatCount >>= fRepeat;
1986 
1987 			sal_uInt16 nPos = LISTBOX_ENTRY_NOTFOUND;
1988 
1989 			if( fRepeat == 0 )
1990 				nPos = 0;
1991 			else if( fRepeat == 2.0 )
1992 				nPos = 1;
1993 			else if( fRepeat == 3.0 )
1994 				nPos = 2;
1995 			else if( fRepeat == 4.0 )
1996 				nPos = 3;
1997 			else if( fRepeat == 5.0 )
1998 				nPos = 4;
1999 			else if( fRepeat == 10.0 )
2000 				nPos = 5;
2001 
2002 			if( nPos != LISTBOX_ENTRY_NOTFOUND )
2003 				mpCBRepeat->SelectEntryPos( nPos );
2004 			else
2005 				mpCBRepeat->SetText( String::CreateFromDouble( fRepeat ) );
2006 		}
2007 		else if( aRepeatCount.getValueType() == ::getCppuType((const Timing*)0) )
2008 		{
2009 			Any aEnd;
2010 			if( pSet->getPropertyState( nHandleEnd ) != STLPropertyState_AMBIGUOUS )
2011 				aEnd = pSet->getPropertyValue( nHandleEnd );
2012 
2013 			mpCBRepeat->SelectEntryPos( aEnd.hasValue() ? 6 : 7 );
2014 		}
2015 	}
2016 
2017 	if( pSet->getPropertyState( nHandleRewind ) != STLPropertyState_AMBIGUOUS )
2018 	{
2019 		sal_Int16 nFill = 0;
2020 		if( pSet->getPropertyValue( nHandleRewind ) >>= nFill )
2021 		{
2022 			mpCBXRewind->Check( (nFill == AnimationFill::REMOVE) ? sal_True : sal_False );
2023 		}
2024 		else
2025 		{
2026 			mpCBXRewind->SetState( STATE_DONTKNOW );
2027 		}
2028 	}
2029 
2030 	Reference< XShape > xTrigger;
2031 
2032 	if( pSet->getPropertyState( nHandleTrigger ) != STLPropertyState_AMBIGUOUS )
2033 	{
2034 		pSet->getPropertyValue( nHandleTrigger ) >>= xTrigger;
2035 
2036 		mpRBInteractive->Check( xTrigger.is() );
2037 		mpRBClickSequence->Check( !xTrigger.is() );
2038 	}
2039 
2040 	Reference< XDrawPage > xCurrentPage;
2041 	pSet->getPropertyValue( nHandleCurrentPage ) >>= xCurrentPage;
2042 	if( xCurrentPage.is() )
2043 	{
2044 		const OUString aStrIsEmptyPresObj( RTL_CONSTASCII_USTRINGPARAM( "IsEmptyPresentationObject" ) );
2045 
2046 		sal_Int32 nShape, nCount = xCurrentPage->getCount();
2047 		for( nShape = 0; nShape < nCount; nShape++ )
2048 		{
2049 			Reference< XShape > xShape( xCurrentPage->getByIndex( nShape ), UNO_QUERY );
2050 
2051 			if( !xShape.is() )
2052 				continue;
2053 
2054 			Reference< XPropertySet > xSet( xShape, UNO_QUERY );
2055 			if( xSet.is() && xSet->getPropertySetInfo()->hasPropertyByName( aStrIsEmptyPresObj ) )
2056 			{
2057 				sal_Bool bIsEmpty = sal_False;
2058 				xSet->getPropertyValue( aStrIsEmptyPresObj ) >>= bIsEmpty;
2059 				if( bIsEmpty )
2060 					continue;
2061 			}
2062 
2063 			String aDescription( getShapeDescription( xShape, true ) );
2064 			sal_uInt16 nPos = mpLBTrigger->InsertEntry( aDescription );
2065 
2066 			mpLBTrigger->SetEntryData( nPos, (void*)nShape );
2067 			if( xShape == xTrigger )
2068 				mpLBTrigger->SelectEntryPos( nPos );
2069 		}
2070 	}
2071 }
2072 
2073 CustomAnimationDurationTabPage::~CustomAnimationDurationTabPage()
2074 {
2075 }
2076 
2077 IMPL_LINK( CustomAnimationDurationTabPage, implControlHdl, Control*, pControl )
2078 {
2079 	if( pControl == mpLBTrigger.get() )
2080 	{
2081 		mpRBClickSequence->Check( sal_False );
2082 		mpRBInteractive->Check( sal_True );
2083 	}
2084 
2085 	return 0;
2086 }
2087 
2088 void CustomAnimationDurationTabPage::update( STLPropertySet* pSet )
2089 {
2090 	sal_uInt16 nPos = mpLBStart->GetSelectEntryPos();
2091 	if( nPos != LISTBOX_ENTRY_NOTFOUND )
2092 	{
2093 		sal_Int16 nStart;
2094 		sal_Int16 nOldStart = -1;
2095 
2096 		switch( nPos )
2097 		{
2098 		case 1: nStart = EffectNodeType::WITH_PREVIOUS; break;
2099 		case 2: nStart = EffectNodeType::AFTER_PREVIOUS; break;
2100 		default:
2101 			nStart = EffectNodeType::ON_CLICK; break;
2102 		}
2103 
2104 		if(mpSet->getPropertyState( nHandleStart ) != STLPropertyState_AMBIGUOUS)
2105 			mpSet->getPropertyValue( nHandleStart ) >>= nOldStart;
2106 
2107 		if( nStart != nOldStart )
2108 			pSet->setPropertyValue( nHandleStart, makeAny( nStart ) );
2109 	}
2110 
2111 	// ---
2112 
2113 	{
2114 		double fBegin = static_cast<double>( mpMFStartDelay->GetValue()) / 10.0;
2115 		double fOldBegin = -1.0;
2116 
2117 		if( mpSet->getPropertyState( nHandleBegin ) != STLPropertyState_AMBIGUOUS )
2118 			mpSet->getPropertyValue( nHandleBegin ) >>= fOldBegin;
2119 
2120 		if( fBegin != fOldBegin )
2121 			pSet->setPropertyValue( nHandleBegin, makeAny( fBegin ) );
2122 	}
2123 
2124 	// ---
2125 
2126 	nPos = mpCBRepeat->GetSelectEntryPos();
2127 	if( (nPos != LISTBOX_ENTRY_NOTFOUND) || (mpCBRepeat->GetText().Len() != 0) )
2128 	{
2129 		Any aRepeatCount;
2130 		Any aEnd;
2131 
2132 		switch( nPos )
2133 		{
2134 		case 0:
2135 			break;
2136 		case 6:
2137 			{
2138 				Event aEvent;
2139 				aEvent.Trigger = EventTrigger::ON_NEXT;
2140 				aEvent.Repeat = 0;
2141 				aEnd <<= aEvent;
2142 			}
2143 			// ATTENTION: FALL THROUGH INTENDED!
2144 		case 7:
2145 			aRepeatCount <<= Timing_INDEFINITE;
2146 			break;
2147 		default:
2148 			{
2149 				String aText( mpCBRepeat->GetText() );
2150 				if( aText.Len() )
2151 					aRepeatCount <<= aText.ToDouble();
2152 			}
2153 		}
2154 
2155 		Any aOldRepeatCount( aRepeatCount );
2156 		if( mpSet->getPropertyState( nHandleRepeat ) != STLPropertyState_AMBIGUOUS )
2157 			aOldRepeatCount = mpSet->getPropertyValue( nHandleRepeat );
2158 
2159 		if( aRepeatCount != aOldRepeatCount )
2160 			pSet->setPropertyValue( nHandleRepeat, aRepeatCount );
2161 
2162 		Any aOldEnd( aEnd );
2163 		if( mpSet->getPropertyState( nHandleEnd ) != STLPropertyState_AMBIGUOUS )
2164 			aOldEnd = mpSet->getPropertyValue( nHandleEnd );
2165 
2166 		if( aEnd != aOldEnd )
2167 			pSet->setPropertyValue( nHandleEnd, aEnd );
2168 	}
2169 
2170 	// ---
2171 
2172 	double fDuration = -1.0;
2173 	nPos = mpCBDuration->GetSelectEntryPos();
2174 	if( nPos != LISTBOX_ENTRY_NOTFOUND )
2175 	{
2176 		fDuration = *static_cast< const double * >( mpCBDuration->GetEntryData(nPos) );
2177 	}
2178 	else
2179 	{
2180 		String aText( mpCBDuration->GetText() );
2181 		if( aText.Len() )
2182 		{
2183 			fDuration = aText.ToDouble();
2184 		}
2185 	}
2186 
2187 	if( fDuration != -1.0 )
2188 	{
2189 		double fOldDuration = -1;
2190 
2191 		if( mpSet->getPropertyState( nHandleDuration ) != STLPropertyState_AMBIGUOUS )
2192 			mpSet->getPropertyValue( nHandleDuration ) >>= fOldDuration;
2193 
2194 		if( fDuration != fOldDuration )
2195 			pSet->setPropertyValue( nHandleDuration, makeAny( fDuration ) );
2196 	}
2197 
2198 	// ---
2199 
2200 	if( mpCBXRewind->GetState() != STATE_DONTKNOW )
2201 	{
2202 		sal_Int16 nFill = mpCBXRewind->IsChecked() ? AnimationFill::REMOVE : AnimationFill::HOLD;
2203 
2204 		bool bSet = true;
2205 
2206 		if( mpSet->getPropertyState( nHandleRewind ) != STLPropertyState_AMBIGUOUS )
2207 		{
2208 			sal_Int16 nOldFill = 0;
2209 			mpSet->getPropertyValue( nHandleRewind ) >>= nOldFill;
2210 			bSet = nFill != nOldFill;
2211 		}
2212 
2213 		if( bSet )
2214 			pSet->setPropertyValue( nHandleRewind, makeAny( nFill ) );
2215 	}
2216 
2217 	Reference< XShape > xTrigger;
2218 
2219 	if( mpRBInteractive->IsChecked() )
2220 	{
2221 		nPos = mpLBTrigger->GetSelectEntryPos();
2222 		if( nPos != LISTBOX_ENTRY_NOTFOUND )
2223 		{
2224 			sal_Int32 nShape = (sal_Int32)(sal_IntPtr)mpLBTrigger->GetEntryData( nPos );
2225 
2226 			Reference< XDrawPage > xCurrentPage;
2227 			mpSet->getPropertyValue( nHandleCurrentPage ) >>= xCurrentPage;
2228 
2229 			if( xCurrentPage.is() && (nShape >= 0) && (nShape < xCurrentPage->getCount()) )
2230 				xCurrentPage->getByIndex( nShape ) >>= xTrigger;
2231 		}
2232 	}
2233 
2234 
2235 	if( xTrigger.is() || mpRBClickSequence->IsChecked() )
2236 	{
2237 		Any aNewValue( makeAny( xTrigger ) );
2238 		Any aOldValue;
2239 
2240 		if( mpSet->getPropertyState( nHandleTrigger ) != STLPropertyState_AMBIGUOUS )
2241 			aOldValue = mpSet->getPropertyValue( nHandleTrigger );
2242 
2243 		if( aNewValue != aOldValue )
2244 			pSet->setPropertyValue( nHandleTrigger, aNewValue );
2245 	}
2246 }
2247 
2248 class CustomAnimationTextAnimTabPage : public TabPage
2249 {
2250 public:
2251 	CustomAnimationTextAnimTabPage( Window* pParent, const ResId& rResId, const STLPropertySet* pSet );
2252 
2253 	void update( STLPropertySet* pSet );
2254 
2255 	void updateControlStates();
2256 	DECL_LINK( implSelectHdl, Control* );
2257 
2258 private:
2259 	FixedText	maFTGroupText;
2260 	ListBox		maLBGroupText;
2261 	CheckBox	maCBXGroupAuto;
2262 	MetricField	maMFGroupAuto;
2263 	CheckBox	maCBXAnimateForm;
2264 	CheckBox	maCBXReverse;
2265 
2266 	const STLPropertySet* mpSet;
2267 
2268 	bool mbHasVisibleShapes;
2269 };
2270 
2271 CustomAnimationTextAnimTabPage::CustomAnimationTextAnimTabPage(Window* pParent, const ResId& rResId, const STLPropertySet* pSet)
2272 :	TabPage( pParent, rResId ),
2273 	maFTGroupText( this, SdResId( FT_GROUP_TEXT ) ),
2274 	maLBGroupText( this, SdResId( LB_GROUP_TEXT ) ),
2275 	maCBXGroupAuto( this, SdResId( CBX_GROUP_AUTO ) ),
2276 	maMFGroupAuto( this, SdResId( MF_GROUP_AUTO ) ),
2277 	maCBXAnimateForm( this, SdResId( CBX_ANIMATE_FORM ) ),
2278 	maCBXReverse( this, SdResId( CBX_REVERSE ) ),
2279 	mpSet( pSet ),
2280 	mbHasVisibleShapes(true)
2281 {
2282 	FreeResource();
2283 
2284 	maLBGroupText.SetSelectHdl( LINK( this, CustomAnimationTextAnimTabPage, implSelectHdl ) );
2285 
2286 	if( pSet->getPropertyState( nHandleTextGrouping ) != STLPropertyState_AMBIGUOUS )
2287 	{
2288 		sal_Int32 nTextGrouping = 0;
2289 		if( pSet->getPropertyValue( nHandleTextGrouping ) >>= nTextGrouping )
2290 			maLBGroupText.SelectEntryPos( (sal_uInt16)(nTextGrouping + 1) );
2291 	}
2292 
2293 	if( pSet->getPropertyState( nHandleHasVisibleShape ) != STLPropertyState_AMBIGUOUS )
2294 		pSet->getPropertyValue( nHandleHasVisibleShape ) >>= mbHasVisibleShapes;
2295 
2296 	if( pSet->getPropertyState( nHandleTextGroupingAuto ) != STLPropertyState_AMBIGUOUS )
2297 	{
2298 		double fTextGroupingAuto = 0.0;
2299 		if( pSet->getPropertyValue( nHandleTextGroupingAuto ) >>= fTextGroupingAuto )
2300 		{
2301 			maCBXGroupAuto.Check( fTextGroupingAuto >= 0.0 );
2302 			if( fTextGroupingAuto >= 0.0 )
2303 				maMFGroupAuto.SetValue( (long)(fTextGroupingAuto*10) );
2304 		}
2305 	}
2306 	else
2307 	{
2308 		maCBXGroupAuto.SetState( STATE_DONTKNOW );
2309 	}
2310 
2311 	maCBXAnimateForm.SetState( STATE_DONTKNOW );
2312 	if( pSet->getPropertyState( nHandleAnimateForm ) != STLPropertyState_AMBIGUOUS )
2313 	{
2314 		sal_Bool bAnimateForm = sal_False;
2315 		if( pSet->getPropertyValue( nHandleAnimateForm ) >>= bAnimateForm )
2316 		{
2317 			maCBXAnimateForm.Check( bAnimateForm );
2318 		}
2319 	}
2320 	else
2321 	{
2322 		maCBXAnimateForm.Enable( sal_False );
2323 	}
2324 
2325 	maCBXReverse.SetState( STATE_DONTKNOW );
2326 	if( pSet->getPropertyState( nHandleTextReverse ) != STLPropertyState_AMBIGUOUS )
2327 	{
2328 		sal_Bool bTextReverse = sal_False;
2329 		if( pSet->getPropertyValue( nHandleTextReverse ) >>= bTextReverse )
2330 		{
2331 			maCBXReverse.Check( bTextReverse );
2332 		}
2333 	}
2334 
2335 	if( pSet->getPropertyState( nHandleMaxParaDepth ) == STLPropertyState_DIRECT )
2336 	{
2337 		sal_Int32 nMaxParaDepth = 0;
2338 		pSet->getPropertyValue( nHandleMaxParaDepth ) >>= nMaxParaDepth;
2339 		nMaxParaDepth += 1;
2340 
2341 		sal_Int32 nPos = 6;
2342 		while( (nPos > 2) && (nPos > nMaxParaDepth) )
2343 		{
2344 			maLBGroupText.RemoveEntry( (sal_uInt16)nPos );
2345 			nPos--;
2346 		}
2347 	}
2348 
2349 	updateControlStates();
2350 }
2351 
2352 void CustomAnimationTextAnimTabPage::update( STLPropertySet* pSet )
2353 {
2354 	sal_uInt16 nPos = maLBGroupText.GetSelectEntryPos();
2355 	if( nPos != LISTBOX_ENTRY_NOTFOUND )
2356 	{
2357 		sal_Int32 nTextGrouping = nPos - 1;
2358 		sal_Int32 nOldGrouping = -2;
2359 
2360 		if(mpSet->getPropertyState( nHandleTextGrouping ) != STLPropertyState_AMBIGUOUS)
2361 			mpSet->getPropertyValue( nHandleTextGrouping ) >>= nOldGrouping;
2362 
2363 		if( nTextGrouping != nOldGrouping )
2364 			pSet->setPropertyValue( nHandleTextGrouping, makeAny( nTextGrouping ) );
2365 	}
2366 
2367 	if( nPos > 0 )
2368 	{
2369 		sal_Bool bTextReverse = maCBXReverse.IsChecked();
2370 		sal_Bool bOldTextReverse = !bTextReverse;
2371 
2372 		if(mpSet->getPropertyState( nHandleTextReverse ) != STLPropertyState_AMBIGUOUS)
2373 			mpSet->getPropertyValue( nHandleTextReverse ) >>= bOldTextReverse;
2374 
2375 		if( bTextReverse != bOldTextReverse )
2376 			pSet->setPropertyValue( nHandleTextReverse, makeAny( bTextReverse ) );
2377 
2378 		if( nPos > 1 )
2379 		{
2380 			double fTextGroupingAuto = maCBXGroupAuto.IsChecked() ? maMFGroupAuto.GetValue() / 10.0 : -1.0;
2381 			double fOldTextGroupingAuto = -2.0;
2382 
2383 			if(mpSet->getPropertyState( nHandleTextGroupingAuto ) != STLPropertyState_AMBIGUOUS)
2384 				mpSet->getPropertyValue( nHandleTextGroupingAuto ) >>= fOldTextGroupingAuto;
2385 
2386 			if( fTextGroupingAuto != fOldTextGroupingAuto )
2387 				pSet->setPropertyValue( nHandleTextGroupingAuto, makeAny( fTextGroupingAuto ) );
2388 		}
2389 	}
2390 	//bug 120049
2391 	//[crash] Aoo crash when modify the "Random effects" animation effect's trigger condition to "Start effect on click of" .
2392 	//If this control is disabled, we should ignore its value
2393 	if (maCBXAnimateForm.IsEnabled())
2394 	{
2395 		sal_Bool bAnimateForm = maCBXAnimateForm.IsChecked();
2396 		sal_Bool bOldAnimateForm = !bAnimateForm;
2397 
2398 		if(mpSet->getPropertyState( nHandleAnimateForm ) != STLPropertyState_AMBIGUOUS)
2399 			mpSet->getPropertyValue( nHandleAnimateForm ) >>= bOldAnimateForm;
2400 
2401 		if( bAnimateForm != bOldAnimateForm )
2402 			pSet->setPropertyValue( nHandleAnimateForm, makeAny( bAnimateForm ) );
2403 	}
2404 }
2405 
2406 void CustomAnimationTextAnimTabPage::updateControlStates()
2407 {
2408 	sal_uInt16 nPos = maLBGroupText.GetSelectEntryPos();
2409 
2410 	maCBXGroupAuto.Enable( nPos > 1 );
2411 	maMFGroupAuto.Enable( nPos > 1 );
2412 	maCBXReverse.Enable( nPos > 0 );
2413 
2414 	if( !mbHasVisibleShapes && nPos > 0 )
2415 	{
2416 		maCBXAnimateForm.Check(sal_False);
2417 		maCBXAnimateForm.Enable(sal_False);
2418 	}
2419 	else
2420 	{
2421 		maCBXAnimateForm.Enable(sal_True);
2422 	}
2423 }
2424 
2425 IMPL_LINK( CustomAnimationTextAnimTabPage, implSelectHdl, Control*, EMPTYARG )
2426 {
2427 	updateControlStates();
2428 	return 0;
2429 }
2430 
2431 // --------------------------------------------------------------------
2432 
2433 CustomAnimationDialog::CustomAnimationDialog( Window* pParent, STLPropertySet* pSet, sal_uInt16 nPage /* = 0 */  )
2434 : TabDialog( pParent, SdResId( DLG_CUSTOMANIMATION ) ), mpSet( pSet ), mpResultSet( 0 )
2435 {
2436 	mpTabControl = new TabControl( this, SdResId( 1 ) );
2437 	mpOKButton = new OKButton(this, SdResId( 1 ) ) ;
2438 	mpCancelButton = new CancelButton(this, SdResId( 1 ) );
2439 	mpHelpButton = new HelpButton(this, SdResId( 1 ) );
2440 
2441 	FreeResource();
2442 
2443 	mpEffectTabPage = new CustomAnimationEffectTabPage( mpTabControl, SdResId( RID_TP_CUSTOMANIMATION_EFFECT ), mpSet );
2444 	mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_EFFECT, mpEffectTabPage );
2445 	mpDurationTabPage = new CustomAnimationDurationTabPage( mpTabControl, SdResId( RID_TP_CUSTOMANIMATION_DURATION ), mpSet );
2446 	mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_DURATION, mpDurationTabPage );
2447 
2448 	sal_Bool bHasText = sal_False;
2449 	if( pSet->getPropertyState( nHandleHasText ) != STLPropertyState_AMBIGUOUS )
2450 		pSet->getPropertyValue( nHandleHasText ) >>= bHasText;
2451 
2452 	if( bHasText )
2453 	{
2454 		mpTextAnimTabPage = new CustomAnimationTextAnimTabPage( mpTabControl, SdResId( RID_TP_CUSTOMANIMATION_TEXT ), mpSet );
2455 		mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_TEXT, mpTextAnimTabPage );
2456 	}
2457 	else
2458 	{
2459 		mpTextAnimTabPage = 0;
2460 		mpTabControl->RemovePage( RID_TP_CUSTOMANIMATION_TEXT );
2461 	}
2462 
2463 	if( nPage )
2464 		mpTabControl->SelectTabPage( nPage );
2465 }
2466 
2467 CustomAnimationDialog::~CustomAnimationDialog()
2468 {
2469 	delete mpEffectTabPage;
2470 	delete mpDurationTabPage;
2471 	delete mpTextAnimTabPage;
2472 
2473 	delete mpTabControl;
2474 	delete mpOKButton;
2475 	delete mpCancelButton;
2476 	delete mpHelpButton;
2477 
2478 	delete mpSet;
2479 	delete mpResultSet;
2480 }
2481 
2482 STLPropertySet* CustomAnimationDialog::getResultSet()
2483 {
2484 	if( mpResultSet )
2485 		delete mpResultSet;
2486 
2487 	mpResultSet = createDefaultSet();
2488 
2489 	mpEffectTabPage->update( mpResultSet );
2490 	mpDurationTabPage->update( mpResultSet );
2491 	if( mpTextAnimTabPage )
2492 		mpTextAnimTabPage->update( mpResultSet );
2493 
2494 	return mpResultSet;
2495 }
2496 
2497 STLPropertySet* CustomAnimationDialog::createDefaultSet()
2498 {
2499 	Any aEmpty;
2500 
2501 	STLPropertySet* pSet = new STLPropertySet();
2502 	pSet->setPropertyDefaultValue( nHandleMaxParaDepth, makeAny( (sal_Int32)-1 ) );
2503 
2504 	pSet->setPropertyDefaultValue( nHandleHasAfterEffect, makeAny( (sal_Bool)sal_False ) );
2505 	pSet->setPropertyDefaultValue( nHandleAfterEffectOnNextEffect, makeAny( (sal_Bool)sal_False ) );
2506 	pSet->setPropertyDefaultValue( nHandleDimColor, aEmpty );
2507 	pSet->setPropertyDefaultValue( nHandleIterateType, makeAny( (sal_Int16)0 ) );
2508 	pSet->setPropertyDefaultValue( nHandleIterateInterval, makeAny( (double)0.0 ) );
2509 
2510 	pSet->setPropertyDefaultValue( nHandleStart, makeAny( (sal_Int16)EffectNodeType::ON_CLICK ) );
2511 	pSet->setPropertyDefaultValue( nHandleBegin, makeAny( (double)0.0 ) );
2512 	pSet->setPropertyDefaultValue( nHandleDuration, makeAny( (double)2.0 ) );
2513 	pSet->setPropertyDefaultValue( nHandleRepeat, aEmpty );
2514 	pSet->setPropertyDefaultValue( nHandleRewind, makeAny( AnimationFill::HOLD ) );
2515 
2516 	pSet->setPropertyDefaultValue( nHandleEnd, aEmpty );
2517 
2518 	pSet->setPropertyDefaultValue( nHandlePresetId, aEmpty );
2519 	pSet->setPropertyDefaultValue( nHandleProperty1Type, makeAny( nPropertyTypeNone ) );
2520 	pSet->setPropertyDefaultValue( nHandleProperty1Value, aEmpty );
2521 	pSet->setPropertyDefaultValue( nHandleProperty2Type, makeAny( nPropertyTypeNone ) );
2522 	pSet->setPropertyDefaultValue( nHandleProperty2Value, aEmpty );
2523 	pSet->setPropertyDefaultValue( nHandleAccelerate, aEmpty );
2524 	pSet->setPropertyDefaultValue( nHandleDecelerate, aEmpty );
2525 	pSet->setPropertyDefaultValue( nHandleAutoReverse, aEmpty );
2526 	pSet->setPropertyDefaultValue( nHandleTrigger, aEmpty );
2527 
2528 	pSet->setPropertyDefaultValue( nHandleHasText, makeAny( sal_False ) );
2529 	pSet->setPropertyDefaultValue( nHandleHasVisibleShape, makeAny( sal_False ) );
2530 	pSet->setPropertyDefaultValue( nHandleTextGrouping, makeAny( (sal_Int32)-1 ) );
2531 	pSet->setPropertyDefaultValue( nHandleAnimateForm, makeAny( sal_True ) );
2532 	pSet->setPropertyDefaultValue( nHandleTextGroupingAuto, makeAny( (double)-1.0 ) );
2533 	pSet->setPropertyDefaultValue( nHandleTextReverse, makeAny( sal_False ) );
2534 
2535 	pSet->setPropertyDefaultValue( nHandleCurrentPage, aEmpty );
2536 
2537 	pSet->setPropertyDefaultValue( nHandleSoundURL, aEmpty );
2538 	pSet->setPropertyDefaultValue( nHandleSoundVolumne, makeAny( (double)1.0) );
2539 	pSet->setPropertyDefaultValue( nHandleSoundEndAfterSlide, makeAny( (sal_Int32)0 ) );
2540 
2541 	pSet->setPropertyDefaultValue( nHandleCommand, makeAny( (sal_Int16)0 ) );
2542 	return pSet;
2543 }
2544 
2545 PropertyControl::PropertyControl( Window* pParent, const ResId& rResId )
2546 : ListBox( pParent, rResId ), mpSubControl(0)
2547 {
2548 }
2549 
2550 PropertyControl::~PropertyControl()
2551 {
2552 	if( mpSubControl )
2553 		delete mpSubControl;
2554 }
2555 
2556 void PropertyControl::setSubControl( PropertySubControl* pSubControl )
2557 {
2558 	if( mpSubControl && mpSubControl != pSubControl )
2559 		delete mpSubControl;
2560 
2561 	mpSubControl = pSubControl;
2562 
2563 	Control* pControl = pSubControl ? pSubControl->getControl() : 0;
2564 
2565 	if( pControl )
2566 	{
2567 		pControl->SetPosSizePixel( GetPosPixel(), GetSizePixel() );
2568 		pControl->SetZOrder( this, WINDOW_ZORDER_BEFOR );
2569 		pControl->Show();
2570 		Hide();
2571 	}
2572 	else
2573 	{
2574 		Show();
2575 	}
2576 }
2577 
2578 void PropertyControl::Resize()
2579 {
2580 	Control* pControl = mpSubControl ? mpSubControl->getControl() : 0;
2581 	if( pControl )
2582 		pControl->SetPosSizePixel( GetPosPixel(), GetSizePixel() );
2583 	ListBox::Resize();
2584 }
2585 
2586 // ====================================================================
2587 
2588 PropertySubControl::~PropertySubControl()
2589 {
2590 }
2591 
2592 PropertySubControl* PropertySubControl::create( sal_Int32 nType, Window* pParent, const Any& rValue, const OUString& rPresetId, const Link& rModifyHdl )
2593 {
2594 	PropertySubControl* pSubControl = NULL;
2595 	switch( nType )
2596 	{
2597 	case nPropertyTypeDirection:
2598 	case nPropertyTypeSpokes:
2599 	case nPropertyTypeZoom:
2600 		pSubControl = new PresetPropertyBox( nType, pParent, rValue, rPresetId, rModifyHdl );
2601 		break;
2602 
2603 	case nPropertyTypeColor:
2604 	case nPropertyTypeFillColor:
2605 	case nPropertyTypeFirstColor:
2606 	case nPropertyTypeCharColor:
2607 	case nPropertyTypeLineColor:
2608 		pSubControl = new ColorPropertyBox( nType, pParent, rValue, rModifyHdl );
2609 		break;
2610 
2611 	case nPropertyTypeFont:
2612 		pSubControl = new FontPropertyBox( nType, pParent, rValue, rModifyHdl );
2613 		break;
2614 
2615 	case nPropertyTypeCharHeight:
2616 		pSubControl = new CharHeightPropertyBox( nType, pParent, rValue, rModifyHdl );
2617 		break;
2618 
2619 	case nPropertyTypeRotate:
2620 		pSubControl = new RotationPropertyBox( nType, pParent, rValue, rModifyHdl );
2621 		break;
2622 
2623 	case nPropertyTypeTransparency:
2624 		pSubControl = new TransparencyPropertyBox( nType, pParent, rValue, rModifyHdl );
2625 		break;
2626 
2627 	case nPropertyTypeScale:
2628 		pSubControl = new ScalePropertyBox( nType, pParent, rValue, rModifyHdl );
2629 		break;
2630 
2631 	case nPropertyTypeCharDecoration:
2632 		pSubControl = new FontStylePropertyBox( nType, pParent, rValue, rModifyHdl );
2633 		break;
2634 	}
2635 
2636 	return pSubControl;
2637 }
2638 
2639 }
2640