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