xref: /AOO41X/main/sd/source/ui/animations/CustomAnimationCreateDialog.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sd.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_XCOLLATOR_HPP_
32*cdf0e10cSrcweir #include <com/sun/star/i18n/XCollator.hpp>
33*cdf0e10cSrcweir #endif
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #ifndef _UNOTOOLS_PROCESSFACTORY_HXX
36*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
37*cdf0e10cSrcweir #endif
38*cdf0e10cSrcweir #include <vcl/svapp.hxx>
39*cdf0e10cSrcweir #include <vcl/tabctrl.hxx>
40*cdf0e10cSrcweir #include <vcl/tabpage.hxx>
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir #ifndef _SV_BUTTON_HXX
43*cdf0e10cSrcweir #include <vcl/button.hxx>
44*cdf0e10cSrcweir #endif
45*cdf0e10cSrcweir #include <vcl/fixed.hxx>
46*cdf0e10cSrcweir #include <vcl/lstbox.hxx>
47*cdf0e10cSrcweir #include <vcl/combobox.hxx>
48*cdf0e10cSrcweir #include <svtools/valueset.hxx>
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir #include <svx/svdetc.hxx>
51*cdf0e10cSrcweir #include <svx/svdstr.hrc>
52*cdf0e10cSrcweir #include "sdresid.hxx"
53*cdf0e10cSrcweir #include <unotools/viewoptions.hxx>
54*cdf0e10cSrcweir #include <com/sun/star/presentation/EffectNodeType.hpp>
55*cdf0e10cSrcweir #include "CustomAnimationCreateDialog.hxx"
56*cdf0e10cSrcweir #ifndef _SD_CUSTOMANIMATIONCREATEDIALOG_HRC
57*cdf0e10cSrcweir #include "CustomAnimationCreateDialog.hrc"
58*cdf0e10cSrcweir #endif
59*cdf0e10cSrcweir #ifndef _SD_CUSTOMANIMATION_HRC
60*cdf0e10cSrcweir #include "CustomAnimation.hrc"
61*cdf0e10cSrcweir #endif
62*cdf0e10cSrcweir #include "CustomAnimationPane.hxx"
63*cdf0e10cSrcweir #include "optsitem.hxx"
64*cdf0e10cSrcweir #include "sddll.hxx"
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir #include "helpids.h"
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir using namespace ::com::sun::star;
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir using ::rtl::OUString;
71*cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY;
72*cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY_THROW;
73*cdf0e10cSrcweir using ::com::sun::star::uno::Any;
74*cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
75*cdf0e10cSrcweir using ::com::sun::star::uno::Exception;
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir using namespace ::com::sun::star::presentation;
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir namespace sd {
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir const int ENTRANCE = 0;
83*cdf0e10cSrcweir const int EMPHASIS = 1;
84*cdf0e10cSrcweir const int EXIT = 2;
85*cdf0e10cSrcweir const int MOTIONPATH = 3;
86*cdf0e10cSrcweir const int MISCEFFECTS = 4;
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir extern void fillDurationComboBox( ComboBox* pBox );
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir // --------------------------------------------------------------------
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir class CategoryListBox : public ListBox
93*cdf0e10cSrcweir {
94*cdf0e10cSrcweir public:
95*cdf0e10cSrcweir 	CategoryListBox( Window* pParent, const ResId& rResId );
96*cdf0e10cSrcweir 	~CategoryListBox();
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir 	virtual void        MouseButtonUp( const MouseEvent& rMEvt );
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 	sal_uInt16			InsertCategory( const XubString& rStr, sal_uInt16 nPos = LISTBOX_APPEND );
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir 	void			SetDoubleClickLink( const Link& rDoubleClickHdl ) { maDoubleClickHdl = rDoubleClickHdl; }
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 	DECL_LINK( implDoubleClickHdl, Control* );
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir private:
107*cdf0e10cSrcweir 	virtual void	UserDraw( const UserDrawEvent& rUDEvt );
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 	Link			maDoubleClickHdl;
110*cdf0e10cSrcweir };
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir CategoryListBox::CategoryListBox( Window* pParent, const ResId& rResId )
113*cdf0e10cSrcweir : ListBox( pParent, rResId )
114*cdf0e10cSrcweir {
115*cdf0e10cSrcweir 	EnableUserDraw( sal_True );
116*cdf0e10cSrcweir 	SetDoubleClickHdl( LINK( this, CategoryListBox, implDoubleClickHdl ) );
117*cdf0e10cSrcweir }
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir CategoryListBox::~CategoryListBox()
120*cdf0e10cSrcweir {
121*cdf0e10cSrcweir }
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir sal_uInt16 CategoryListBox::InsertCategory( const XubString& rStr, sal_uInt16 nPos /* = LISTBOX_APPEND */ )
124*cdf0e10cSrcweir {
125*cdf0e10cSrcweir 	sal_uInt16 n = ListBox::InsertEntry( rStr, nPos );
126*cdf0e10cSrcweir 	if( n != LISTBOX_ENTRY_NOTFOUND )
127*cdf0e10cSrcweir 		ListBox::SetEntryFlags( n, ListBox::GetEntryFlags(n) | LISTBOX_ENTRY_FLAG_DISABLE_SELECTION );
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir 	return n;
130*cdf0e10cSrcweir }
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir void CategoryListBox::UserDraw( const UserDrawEvent& rUDEvt )
133*cdf0e10cSrcweir {
134*cdf0e10cSrcweir 	const sal_uInt16 nItem = rUDEvt.GetItemId();
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir 	if( ListBox::GetEntryFlags(nItem) & LISTBOX_ENTRY_FLAG_DISABLE_SELECTION )
137*cdf0e10cSrcweir 	{
138*cdf0e10cSrcweir 		Rectangle aOutRect( rUDEvt.GetRect() );
139*cdf0e10cSrcweir 		OutputDevice* pDev = rUDEvt.GetDevice();
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 		// fill the background
142*cdf0e10cSrcweir         Color aColor (GetSettings().GetStyleSettings().GetDialogColor());
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir         pDev->SetFillColor (aColor);
145*cdf0e10cSrcweir         pDev->SetLineColor ();
146*cdf0e10cSrcweir         pDev->DrawRect(aOutRect);
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir         // Erase the four corner pixels to make the rectangle appear rounded.
149*cdf0e10cSrcweir         pDev->SetLineColor( GetSettings().GetStyleSettings().GetWindowColor());
150*cdf0e10cSrcweir         pDev->DrawPixel( aOutRect.TopLeft());
151*cdf0e10cSrcweir         pDev->DrawPixel( Point(aOutRect.Right(), aOutRect.Top()));
152*cdf0e10cSrcweir         pDev->DrawPixel( Point(aOutRect.Left(), aOutRect.Bottom()));
153*cdf0e10cSrcweir         pDev->DrawPixel( Point(aOutRect.Right(), aOutRect.Bottom()));
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir 		// draw the category title
156*cdf0e10cSrcweir 		pDev->DrawText (aOutRect, GetEntry(nItem), TEXT_DRAW_CENTER );
157*cdf0e10cSrcweir 	}
158*cdf0e10cSrcweir 	else
159*cdf0e10cSrcweir 	{
160*cdf0e10cSrcweir 		DrawEntry( rUDEvt, sal_True, sal_True );
161*cdf0e10cSrcweir 	}
162*cdf0e10cSrcweir }
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir // --------------------------------------------------------------------
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir IMPL_LINK( CategoryListBox, implDoubleClickHdl, Control*, EMPTYARG )
167*cdf0e10cSrcweir {
168*cdf0e10cSrcweir 	CaptureMouse();
169*cdf0e10cSrcweir 	return 0;
170*cdf0e10cSrcweir }
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir // --------------------------------------------------------------------
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir void CategoryListBox::MouseButtonUp( const MouseEvent& rMEvt )
175*cdf0e10cSrcweir {
176*cdf0e10cSrcweir     ReleaseMouse();
177*cdf0e10cSrcweir 	if( rMEvt.IsLeft() && (rMEvt.GetClicks() == 2) )
178*cdf0e10cSrcweir 	{
179*cdf0e10cSrcweir 		if( maDoubleClickHdl.IsSet() )
180*cdf0e10cSrcweir 			maDoubleClickHdl.Call( this );
181*cdf0e10cSrcweir 	}
182*cdf0e10cSrcweir 	else
183*cdf0e10cSrcweir 	{
184*cdf0e10cSrcweir 		ListBox::MouseButtonUp( rMEvt );
185*cdf0e10cSrcweir 	}
186*cdf0e10cSrcweir }
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir // --------------------------------------------------------------------
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir class CustomAnimationCreateTabPage : public TabPage
191*cdf0e10cSrcweir {
192*cdf0e10cSrcweir public:
193*cdf0e10cSrcweir 	CustomAnimationCreateTabPage( Window* pParent, CustomAnimationCreateDialog* pDialogParent, int nTabId, const PresetCategoryList& rCategoryList, bool bHasText );
194*cdf0e10cSrcweir 	~CustomAnimationCreateTabPage();
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir 	PathKind getCreatePathKind() const;
197*cdf0e10cSrcweir 	CustomAnimationPresetPtr getSelectedPreset() const;
198*cdf0e10cSrcweir 	double getDuration() const;
199*cdf0e10cSrcweir 	void setDuration( double fDuration );
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir 	bool getIsPreview() const;
202*cdf0e10cSrcweir 	void setIsPreview( bool bIsPreview );
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir 	bool select( const OUString& rsPresetId );
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir private:
207*cdf0e10cSrcweir 	DECL_LINK( implSelectHdl, Control* );
208*cdf0e10cSrcweir 	DECL_LINK( implDoubleClickHdl, Control* );
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir 	void onSelectEffect();
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir 	void clearEffects();
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir private:
215*cdf0e10cSrcweir 	CategoryListBox*	mpLBEffects;
216*cdf0e10cSrcweir 	FixedText*	mpFTSpeed;
217*cdf0e10cSrcweir 	ComboBox*	mpCBSpeed;
218*cdf0e10cSrcweir 	CheckBox*	mpCBXPReview;
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir 	CustomAnimationCreateDialog*		mpParent;
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir 	sal_uInt16 mnCurvePathPos;
223*cdf0e10cSrcweir 	sal_uInt16 mnPolygonPathPos;
224*cdf0e10cSrcweir 	sal_uInt16 mnFreeformPathPos;
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir };
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir struct ImplStlEffectCategorySortHelper
229*cdf0e10cSrcweir {
230*cdf0e10cSrcweir 	ImplStlEffectCategorySortHelper();
231*cdf0e10cSrcweir 	bool operator()( const CustomAnimationPresetPtr& p1, const CustomAnimationPresetPtr& p2 );
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir private:
234*cdf0e10cSrcweir 	uno::Reference< i18n::XCollator > mxCollator;
235*cdf0e10cSrcweir };
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir ImplStlEffectCategorySortHelper::ImplStlEffectCategorySortHelper()
238*cdf0e10cSrcweir {
239*cdf0e10cSrcweir 	uno::Reference<lang::XMultiServiceFactory> xFac( ::comphelper::getProcessServiceFactory() );
240*cdf0e10cSrcweir 	if( xFac.is() )
241*cdf0e10cSrcweir 	{
242*cdf0e10cSrcweir 		mxCollator.set( xFac->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.i18n.Collator" ) ), uno::UNO_QUERY );
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir 		if( mxCollator.is() )
245*cdf0e10cSrcweir 		{
246*cdf0e10cSrcweir 			const lang::Locale& rLocale = Application::GetSettings().GetLocale();
247*cdf0e10cSrcweir 			mxCollator->loadDefaultCollator(rLocale, 0);
248*cdf0e10cSrcweir 		}
249*cdf0e10cSrcweir 	}
250*cdf0e10cSrcweir }
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir bool ImplStlEffectCategorySortHelper::operator()( const CustomAnimationPresetPtr& p1, const CustomAnimationPresetPtr& p2 )
253*cdf0e10cSrcweir {
254*cdf0e10cSrcweir 	return mxCollator.is() ? mxCollator->compareString(p1->getLabel(), p2->getLabel()) == -1 : false;
255*cdf0e10cSrcweir }
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir CustomAnimationCreateTabPage::CustomAnimationCreateTabPage( Window* pParent, CustomAnimationCreateDialog* pDialogParent, int nTabId, const PresetCategoryList& rCategoryList, bool bHasText )
258*cdf0e10cSrcweir : TabPage( pParent, SdResId( RID_TP_CUSTOMANIMATION_ENTRANCE ) )
259*cdf0e10cSrcweir , mpParent( pDialogParent )
260*cdf0e10cSrcweir , mnCurvePathPos( LISTBOX_ENTRY_NOTFOUND )
261*cdf0e10cSrcweir , mnPolygonPathPos( LISTBOX_ENTRY_NOTFOUND )
262*cdf0e10cSrcweir , mnFreeformPathPos( LISTBOX_ENTRY_NOTFOUND )
263*cdf0e10cSrcweir {
264*cdf0e10cSrcweir 	mpLBEffects = new CategoryListBox( this, SdResId( LB_EFFECTS ) );
265*cdf0e10cSrcweir 	mpFTSpeed = new FixedText( this, SdResId( FT_SPEED ) );
266*cdf0e10cSrcweir 	mpCBSpeed = new ComboBox( this, SdResId( CB_SPEED ) );
267*cdf0e10cSrcweir 	mpCBXPReview = new CheckBox( this, SdResId( CBX_PREVIEW ) );
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir 	String sMotionPathLabel( SdResId( STR_USERPATH ) );
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir 	FreeResource();
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir 	sal_uInt16 nFirstEffect = LISTBOX_ENTRY_NOTFOUND;
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir 	if( nTabId == MOTIONPATH )
276*cdf0e10cSrcweir 	{
277*cdf0e10cSrcweir 		mpLBEffects->InsertCategory( sMotionPathLabel );
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir 		mnCurvePathPos = nFirstEffect = mpLBEffects->InsertEntry( sdr::GetResourceString(STR_ObjNameSingulCOMBLINE) );
280*cdf0e10cSrcweir 		mnPolygonPathPos = mpLBEffects->InsertEntry( sdr::GetResourceString(STR_ObjNameSingulPOLY) );
281*cdf0e10cSrcweir 		mnFreeformPathPos = mpLBEffects->InsertEntry( sdr::GetResourceString(STR_ObjNameSingulFREELINE) );
282*cdf0e10cSrcweir 	};
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir 	PresetCategoryList::const_iterator aCategoryIter( rCategoryList.begin() );
285*cdf0e10cSrcweir 	const PresetCategoryList::const_iterator aCategoryEnd( rCategoryList.end() );
286*cdf0e10cSrcweir 	while( aCategoryIter != aCategoryEnd )
287*cdf0e10cSrcweir 	{
288*cdf0e10cSrcweir 		PresetCategoryPtr pCategory( *aCategoryIter++ );
289*cdf0e10cSrcweir 		if( pCategory.get() )
290*cdf0e10cSrcweir 		{
291*cdf0e10cSrcweir 			mpLBEffects->InsertCategory( pCategory->maLabel );
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir 			std::vector< CustomAnimationPresetPtr > aSortedVector(pCategory->maEffects.size());
294*cdf0e10cSrcweir 			std::copy( pCategory->maEffects.begin(), pCategory->maEffects.end(), aSortedVector.begin() );
295*cdf0e10cSrcweir 			ImplStlEffectCategorySortHelper aSortHelper;
296*cdf0e10cSrcweir 			std::sort( aSortedVector.begin(), aSortedVector.end(), aSortHelper );
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir 			std::vector< CustomAnimationPresetPtr >::const_iterator aIter( aSortedVector.begin() );
299*cdf0e10cSrcweir 			const std::vector< CustomAnimationPresetPtr >::const_iterator aEnd( aSortedVector.end() );
300*cdf0e10cSrcweir 			while( aIter != aEnd )
301*cdf0e10cSrcweir 			{
302*cdf0e10cSrcweir 				CustomAnimationPresetPtr pDescriptor = (*aIter++);
303*cdf0e10cSrcweir 				if( pDescriptor.get() && (bHasText || !pDescriptor->isTextOnly() ) )
304*cdf0e10cSrcweir 				{
305*cdf0e10cSrcweir 					sal_uInt16 nPos = mpLBEffects->InsertEntry( pDescriptor->getLabel() );
306*cdf0e10cSrcweir 					mpLBEffects->SetEntryData( nPos, static_cast<void*>( new CustomAnimationPresetPtr( pDescriptor ) ) );
307*cdf0e10cSrcweir 
308*cdf0e10cSrcweir 					if( nFirstEffect == LISTBOX_ENTRY_NOTFOUND )
309*cdf0e10cSrcweir 						nFirstEffect = nPos;
310*cdf0e10cSrcweir 				}
311*cdf0e10cSrcweir 			}
312*cdf0e10cSrcweir 		}
313*cdf0e10cSrcweir 	}
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir 	mpLBEffects->SelectEntryPos( nFirstEffect );
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir 	fillDurationComboBox( mpCBSpeed );
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir 	if( nFirstEffect != LISTBOX_ENTRY_NOTFOUND )
320*cdf0e10cSrcweir 		onSelectEffect();
321*cdf0e10cSrcweir 
322*cdf0e10cSrcweir 	mpLBEffects->SetSelectHdl( LINK( this, CustomAnimationCreateTabPage, implSelectHdl ) );
323*cdf0e10cSrcweir 	mpLBEffects->SetDoubleClickLink( LINK( this, CustomAnimationCreateTabPage, implDoubleClickHdl ) );
324*cdf0e10cSrcweir }
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir CustomAnimationCreateTabPage::~CustomAnimationCreateTabPage()
327*cdf0e10cSrcweir {
328*cdf0e10cSrcweir 	clearEffects();
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir 	delete mpLBEffects;
331*cdf0e10cSrcweir 	delete mpFTSpeed;
332*cdf0e10cSrcweir 	delete mpCBSpeed;
333*cdf0e10cSrcweir 	delete mpCBXPReview;
334*cdf0e10cSrcweir }
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir IMPL_LINK( CustomAnimationCreateTabPage, implSelectHdl, Control*, pControl )
337*cdf0e10cSrcweir {
338*cdf0e10cSrcweir 	if( pControl == mpLBEffects )
339*cdf0e10cSrcweir 		onSelectEffect();
340*cdf0e10cSrcweir 	return 0;
341*cdf0e10cSrcweir }
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir IMPL_LINK( CustomAnimationCreateTabPage, implDoubleClickHdl, Control*, pControl )
344*cdf0e10cSrcweir {
345*cdf0e10cSrcweir 	if( pControl == mpLBEffects )
346*cdf0e10cSrcweir 	{
347*cdf0e10cSrcweir 		if( mpLBEffects->GetSelectEntryCount() )
348*cdf0e10cSrcweir 			mpParent->EndDialog( sal_True );
349*cdf0e10cSrcweir 	}
350*cdf0e10cSrcweir 	return 0;
351*cdf0e10cSrcweir }
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir void CustomAnimationCreateTabPage::onSelectEffect()
354*cdf0e10cSrcweir {
355*cdf0e10cSrcweir 	CustomAnimationPresetPtr*p = static_cast< CustomAnimationPresetPtr* >( mpLBEffects->GetEntryData( mpLBEffects->GetSelectEntryPos() ) );
356*cdf0e10cSrcweir 
357*cdf0e10cSrcweir 	if( !p )
358*cdf0e10cSrcweir 		return;
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir 	CustomAnimationPresetPtr pPreset( *p );
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir 	const double fDuration = pPreset->getDuration();
363*cdf0e10cSrcweir 	sal_uInt16 nPos = 0xffff;
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir 	if( fDuration == 5.0 )
366*cdf0e10cSrcweir 		nPos = 0;
367*cdf0e10cSrcweir 	else if( fDuration == 3.0 )
368*cdf0e10cSrcweir 		nPos = 1;
369*cdf0e10cSrcweir 	else if( fDuration == 2.0 )
370*cdf0e10cSrcweir 		nPos = 2;
371*cdf0e10cSrcweir 	else if( fDuration == 1.0 )
372*cdf0e10cSrcweir 		nPos = 3;
373*cdf0e10cSrcweir 	else if( fDuration == 0.5 )
374*cdf0e10cSrcweir 		nPos = 4;
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir 	mpCBSpeed->SelectEntryPos( nPos );
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir     bool bHasSpeed = pPreset->getDuration() > 0.001;
379*cdf0e10cSrcweir     mpCBSpeed->Enable( bHasSpeed );
380*cdf0e10cSrcweir     mpFTSpeed->Enable( bHasSpeed );
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir 	if( mpCBXPReview->IsChecked() )
383*cdf0e10cSrcweir 	{
384*cdf0e10cSrcweir 		mpParent->preview( pPreset );
385*cdf0e10cSrcweir 	}
386*cdf0e10cSrcweir }
387*cdf0e10cSrcweir 
388*cdf0e10cSrcweir void CustomAnimationCreateTabPage::clearEffects()
389*cdf0e10cSrcweir {
390*cdf0e10cSrcweir 	sal_uInt16 nPos = mpLBEffects->GetEntryCount();
391*cdf0e10cSrcweir 	while( nPos-- )
392*cdf0e10cSrcweir 		delete static_cast< CustomAnimationPresetPtr* >( mpLBEffects->GetEntryData( nPos ) );
393*cdf0e10cSrcweir 
394*cdf0e10cSrcweir 	mpLBEffects->Clear();
395*cdf0e10cSrcweir }
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir CustomAnimationPresetPtr CustomAnimationCreateTabPage::getSelectedPreset() const
398*cdf0e10cSrcweir {
399*cdf0e10cSrcweir 	CustomAnimationPresetPtr pPreset;
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir 	if( mpLBEffects->GetSelectEntryCount() == 1 )
402*cdf0e10cSrcweir 	{
403*cdf0e10cSrcweir 		void* pEntryData = mpLBEffects->GetEntryData( mpLBEffects->GetSelectEntryPos() );
404*cdf0e10cSrcweir 		if( pEntryData )
405*cdf0e10cSrcweir 			pPreset = *static_cast< CustomAnimationPresetPtr* >( pEntryData );
406*cdf0e10cSrcweir 	}
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir 	return pPreset;
409*cdf0e10cSrcweir }
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir PathKind CustomAnimationCreateTabPage::getCreatePathKind() const
412*cdf0e10cSrcweir {
413*cdf0e10cSrcweir 	PathKind eKind = NONE;
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir 	if( mpLBEffects->GetSelectEntryCount() == 1 )
416*cdf0e10cSrcweir 	{
417*cdf0e10cSrcweir 		const sal_uInt16 nPos = mpLBEffects->GetSelectEntryPos();
418*cdf0e10cSrcweir 		if( nPos == mnCurvePathPos )
419*cdf0e10cSrcweir 		{
420*cdf0e10cSrcweir 			eKind = CURVE;
421*cdf0e10cSrcweir 		}
422*cdf0e10cSrcweir 		else if( nPos == mnPolygonPathPos )
423*cdf0e10cSrcweir 		{
424*cdf0e10cSrcweir 			eKind = POLYGON;
425*cdf0e10cSrcweir 		}
426*cdf0e10cSrcweir 		else if( nPos == mnFreeformPathPos )
427*cdf0e10cSrcweir 		{
428*cdf0e10cSrcweir 			eKind = FREEFORM;
429*cdf0e10cSrcweir 		}
430*cdf0e10cSrcweir 	}
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir 	return eKind;
433*cdf0e10cSrcweir }
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir 
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir double CustomAnimationCreateTabPage::getDuration() const
438*cdf0e10cSrcweir {
439*cdf0e10cSrcweir 	sal_uInt16 nPos = mpCBSpeed->GetSelectEntryPos();
440*cdf0e10cSrcweir 	if( (nPos == 0xffff) || !mpCBSpeed->IsEnabled() )
441*cdf0e10cSrcweir 	{
442*cdf0e10cSrcweir 		CustomAnimationPresetPtr pPreset = getSelectedPreset();
443*cdf0e10cSrcweir 		if( pPreset.get() )
444*cdf0e10cSrcweir 			return pPreset->getDuration();
445*cdf0e10cSrcweir 	}
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir 	switch( nPos )
448*cdf0e10cSrcweir 	{
449*cdf0e10cSrcweir 	case 0: return 5.0f;
450*cdf0e10cSrcweir 	case 1: return 3.0f;
451*cdf0e10cSrcweir 	case 2: return 2.0f;
452*cdf0e10cSrcweir 	case 3: return 1.0f;
453*cdf0e10cSrcweir 	case 4: return 0.5f;
454*cdf0e10cSrcweir 	}
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir 	return 0.0f;
457*cdf0e10cSrcweir }
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir void CustomAnimationCreateTabPage::setDuration( double fDuration )
460*cdf0e10cSrcweir {
461*cdf0e10cSrcweir 	sal_uInt16 nPos = 0;
462*cdf0e10cSrcweir 	if( fDuration < 2.0f )
463*cdf0e10cSrcweir 	{
464*cdf0e10cSrcweir 		if( fDuration < 1.0f )
465*cdf0e10cSrcweir 		{
466*cdf0e10cSrcweir 			nPos = 4;
467*cdf0e10cSrcweir 		}
468*cdf0e10cSrcweir 		else
469*cdf0e10cSrcweir 		{
470*cdf0e10cSrcweir 			nPos = 3;
471*cdf0e10cSrcweir 		}
472*cdf0e10cSrcweir 	}
473*cdf0e10cSrcweir 	else if( fDuration < 5.0f )
474*cdf0e10cSrcweir 	{
475*cdf0e10cSrcweir 		if( fDuration < 3.0f )
476*cdf0e10cSrcweir 		{
477*cdf0e10cSrcweir 			nPos = 2;
478*cdf0e10cSrcweir 		}
479*cdf0e10cSrcweir 		else
480*cdf0e10cSrcweir 		{
481*cdf0e10cSrcweir 			nPos = 1;
482*cdf0e10cSrcweir 		}
483*cdf0e10cSrcweir 	}
484*cdf0e10cSrcweir 
485*cdf0e10cSrcweir 	mpCBSpeed->SelectEntryPos( nPos );
486*cdf0e10cSrcweir }
487*cdf0e10cSrcweir 
488*cdf0e10cSrcweir bool CustomAnimationCreateTabPage::getIsPreview() const
489*cdf0e10cSrcweir {
490*cdf0e10cSrcweir 	return mpCBXPReview->IsChecked() ? true : false;
491*cdf0e10cSrcweir }
492*cdf0e10cSrcweir 
493*cdf0e10cSrcweir void CustomAnimationCreateTabPage::setIsPreview( bool bIsPreview )
494*cdf0e10cSrcweir {
495*cdf0e10cSrcweir 	mpCBXPReview->Check( bIsPreview ? sal_True : sal_False );
496*cdf0e10cSrcweir }
497*cdf0e10cSrcweir 
498*cdf0e10cSrcweir bool CustomAnimationCreateTabPage::select( const OUString& rsPresetId )
499*cdf0e10cSrcweir {
500*cdf0e10cSrcweir 	sal_uInt16 nPos = mpLBEffects->GetEntryCount();
501*cdf0e10cSrcweir 	while( nPos-- )
502*cdf0e10cSrcweir 	{
503*cdf0e10cSrcweir 		void* pEntryData = mpLBEffects->GetEntryData( nPos );
504*cdf0e10cSrcweir 		if( pEntryData )
505*cdf0e10cSrcweir 		{
506*cdf0e10cSrcweir 			CustomAnimationPresetPtr& pPtr = *static_cast< CustomAnimationPresetPtr* >(pEntryData);
507*cdf0e10cSrcweir 			if( pPtr.get() && pPtr->getPresetId() == rsPresetId )
508*cdf0e10cSrcweir 			{
509*cdf0e10cSrcweir 				mpLBEffects->SelectEntryPos( nPos );
510*cdf0e10cSrcweir 				return true;
511*cdf0e10cSrcweir 			}
512*cdf0e10cSrcweir 		}
513*cdf0e10cSrcweir 	}
514*cdf0e10cSrcweir 
515*cdf0e10cSrcweir 	return false;
516*cdf0e10cSrcweir }
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir // --------------------------------------------------------------------
519*cdf0e10cSrcweir 
520*cdf0e10cSrcweir CustomAnimationCreateDialog::CustomAnimationCreateDialog( Window* pParent, CustomAnimationPane* pPane, const std::vector< ::com::sun::star::uno::Any >& rTargets, bool bHasText, const ::rtl::OUString& rsPresetId, double fDuration  )
521*cdf0e10cSrcweir :	TabDialog( pParent, SdResId( DLG_CUSTOMANIMATION_CREATE ) )
522*cdf0e10cSrcweir ,	mpPane( pPane )
523*cdf0e10cSrcweir ,	mrTargets( rTargets )
524*cdf0e10cSrcweir ,	mfDuration( fDuration )
525*cdf0e10cSrcweir {
526*cdf0e10cSrcweir 	mpTabControl = new TabControl( this, SdResId( 1 ) );
527*cdf0e10cSrcweir 	mpOKButton = new OKButton(this, SdResId( 1 ) ) ;
528*cdf0e10cSrcweir 	mpCancelButton = new CancelButton(this, SdResId( 1 ) );
529*cdf0e10cSrcweir 	mpHelpButton = new HelpButton(this, SdResId( 1 ) );
530*cdf0e10cSrcweir 
531*cdf0e10cSrcweir 	FreeResource();
532*cdf0e10cSrcweir 
533*cdf0e10cSrcweir 	SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
534*cdf0e10cSrcweir 	mbIsPreview = pOptions->IsPreviewNewEffects();
535*cdf0e10cSrcweir 
536*cdf0e10cSrcweir 	const CustomAnimationPresets& rPresets = CustomAnimationPresets::getCustomAnimationPresets();
537*cdf0e10cSrcweir 	mpTabPages[ENTRANCE] = new CustomAnimationCreateTabPage( mpTabControl, this, ENTRANCE, rPresets.getEntrancePresets(), bHasText );
538*cdf0e10cSrcweir     mpTabPages[ENTRANCE]->SetHelpId( HID_SD_CUSTOMANIMATIONDIALOG_ENTRANCE );
539*cdf0e10cSrcweir 	mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_ENTRANCE, mpTabPages[ENTRANCE] );
540*cdf0e10cSrcweir 	mpTabPages[EMPHASIS] = new CustomAnimationCreateTabPage( mpTabControl, this, EMPHASIS, rPresets.getEmphasisPresets(), bHasText );
541*cdf0e10cSrcweir     mpTabPages[EMPHASIS]->SetHelpId( HID_SD_CUSTOMANIMATIONDIALOG_EMPHASIS );
542*cdf0e10cSrcweir 	mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_EMPHASIS, mpTabPages[EMPHASIS] );
543*cdf0e10cSrcweir 	mpTabPages[EXIT] = new CustomAnimationCreateTabPage( mpTabControl, this, EXIT, rPresets.getExitPresets(), bHasText );
544*cdf0e10cSrcweir     mpTabPages[EXIT]->SetHelpId( HID_SD_CUSTOMANIMATIONDIALOG_EXIT );
545*cdf0e10cSrcweir 	mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_EXIT, mpTabPages[EXIT] );
546*cdf0e10cSrcweir 	mpTabPages[MOTIONPATH] = new CustomAnimationCreateTabPage( mpTabControl, this, MOTIONPATH, rPresets.getMotionPathsPresets(), bHasText );
547*cdf0e10cSrcweir     mpTabPages[MOTIONPATH]->SetHelpId( HID_SD_CUSTOMANIMATIONDIALOG_MOTIONPATH );
548*cdf0e10cSrcweir 	mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_MOTIONPATH, mpTabPages[MOTIONPATH] );
549*cdf0e10cSrcweir 	mpTabPages[MISCEFFECTS] = new CustomAnimationCreateTabPage( mpTabControl, this, MISCEFFECTS, rPresets.getMiscPresets(), bHasText );
550*cdf0e10cSrcweir     mpTabPages[MISCEFFECTS]->SetHelpId( HID_SD_CUSTOMANIMATIONDIALOG_MISCEFFECTS );
551*cdf0e10cSrcweir 	mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_MISCEFFECTS, mpTabPages[MISCEFFECTS] );
552*cdf0e10cSrcweir 
553*cdf0e10cSrcweir 	getCurrentPage()->setDuration( mfDuration );
554*cdf0e10cSrcweir 	getCurrentPage()->setIsPreview( mbIsPreview );
555*cdf0e10cSrcweir 
556*cdf0e10cSrcweir     mpTabControl->SetActivatePageHdl( LINK( this, CustomAnimationCreateDialog, implActivatePagekHdl ) );
557*cdf0e10cSrcweir 	mpTabControl->SetDeactivatePageHdl( LINK( this, CustomAnimationCreateDialog, implDeactivatePagekHdl ) );
558*cdf0e10cSrcweir 
559*cdf0e10cSrcweir     setPosition();
560*cdf0e10cSrcweir 
561*cdf0e10cSrcweir 	// select current preset if available
562*cdf0e10cSrcweir 	if( rsPresetId.getLength() != 0 )
563*cdf0e10cSrcweir 	{
564*cdf0e10cSrcweir 		for( sal_uInt16 i = ENTRANCE; i <= MOTIONPATH; i++ )
565*cdf0e10cSrcweir 		{
566*cdf0e10cSrcweir 			if( mpTabPages[i]->select( rsPresetId ) )
567*cdf0e10cSrcweir 			{
568*cdf0e10cSrcweir 				mpTabControl->SetCurPageId( RID_TP_CUSTOMANIMATION_ENTRANCE + i );
569*cdf0e10cSrcweir 				break;
570*cdf0e10cSrcweir 			}
571*cdf0e10cSrcweir 		}
572*cdf0e10cSrcweir 	}
573*cdf0e10cSrcweir }
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir CustomAnimationCreateDialog::~CustomAnimationCreateDialog()
576*cdf0e10cSrcweir {
577*cdf0e10cSrcweir     storePosition();
578*cdf0e10cSrcweir 
579*cdf0e10cSrcweir 	SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
580*cdf0e10cSrcweir 	pOptions->SetPreviewNewEffects( getCurrentPage()->getIsPreview() );
581*cdf0e10cSrcweir 
582*cdf0e10cSrcweir 	delete mpTabPages[ENTRANCE];
583*cdf0e10cSrcweir 	delete mpTabPages[EMPHASIS];
584*cdf0e10cSrcweir 	delete mpTabPages[EXIT];
585*cdf0e10cSrcweir 	delete mpTabPages[MOTIONPATH];
586*cdf0e10cSrcweir 	delete mpTabPages[MISCEFFECTS];
587*cdf0e10cSrcweir 
588*cdf0e10cSrcweir 	delete mpTabControl;
589*cdf0e10cSrcweir 	delete mpOKButton;
590*cdf0e10cSrcweir 	delete mpCancelButton;
591*cdf0e10cSrcweir 	delete mpHelpButton;
592*cdf0e10cSrcweir }
593*cdf0e10cSrcweir 
594*cdf0e10cSrcweir CustomAnimationCreateTabPage* CustomAnimationCreateDialog::getCurrentPage() const
595*cdf0e10cSrcweir {
596*cdf0e10cSrcweir 	switch( mpTabControl->GetCurPageId() )
597*cdf0e10cSrcweir 	{
598*cdf0e10cSrcweir 	case RID_TP_CUSTOMANIMATION_ENTRANCE:	return mpTabPages[ENTRANCE];
599*cdf0e10cSrcweir 	case RID_TP_CUSTOMANIMATION_EMPHASIS:	return mpTabPages[EMPHASIS];
600*cdf0e10cSrcweir 	case RID_TP_CUSTOMANIMATION_EXIT:		return mpTabPages[EXIT];
601*cdf0e10cSrcweir 	case RID_TP_CUSTOMANIMATION_MISCEFFECTS:return mpTabPages[MISCEFFECTS];
602*cdf0e10cSrcweir 	//case RID_TP_CUSTOMANIMATION_MOTIONPATH:
603*cdf0e10cSrcweir 	default:
604*cdf0e10cSrcweir 											return mpTabPages[MOTIONPATH];
605*cdf0e10cSrcweir 	}
606*cdf0e10cSrcweir }
607*cdf0e10cSrcweir 
608*cdf0e10cSrcweir PathKind CustomAnimationCreateDialog::getCreatePathKind() const
609*cdf0e10cSrcweir {
610*cdf0e10cSrcweir 	return getCurrentPage()->getCreatePathKind();
611*cdf0e10cSrcweir }
612*cdf0e10cSrcweir 
613*cdf0e10cSrcweir CustomAnimationPresetPtr CustomAnimationCreateDialog::getSelectedPreset() const
614*cdf0e10cSrcweir {
615*cdf0e10cSrcweir 	return getCurrentPage()->getSelectedPreset();
616*cdf0e10cSrcweir }
617*cdf0e10cSrcweir 
618*cdf0e10cSrcweir double CustomAnimationCreateDialog::getSelectedDuration() const
619*cdf0e10cSrcweir {
620*cdf0e10cSrcweir 	return getCurrentPage()->getDuration();
621*cdf0e10cSrcweir }
622*cdf0e10cSrcweir 
623*cdf0e10cSrcweir IMPL_LINK( CustomAnimationCreateDialog, implActivatePagekHdl, Control*, EMPTYARG )
624*cdf0e10cSrcweir {
625*cdf0e10cSrcweir 	getCurrentPage()->setDuration( mfDuration );
626*cdf0e10cSrcweir 	getCurrentPage()->setIsPreview( mbIsPreview );
627*cdf0e10cSrcweir 	return 1;
628*cdf0e10cSrcweir }
629*cdf0e10cSrcweir 
630*cdf0e10cSrcweir IMPL_LINK( CustomAnimationCreateDialog, implDeactivatePagekHdl, Control*, EMPTYARG )
631*cdf0e10cSrcweir {
632*cdf0e10cSrcweir 	mfDuration = getCurrentPage()->getDuration();
633*cdf0e10cSrcweir 	mbIsPreview = getCurrentPage()->getIsPreview();
634*cdf0e10cSrcweir 	return 1;
635*cdf0e10cSrcweir }
636*cdf0e10cSrcweir 
637*cdf0e10cSrcweir void CustomAnimationCreateDialog::preview( const CustomAnimationPresetPtr& pPreset ) const
638*cdf0e10cSrcweir {
639*cdf0e10cSrcweir 	MainSequencePtr pSequence( new MainSequence() );
640*cdf0e10cSrcweir 
641*cdf0e10cSrcweir 	std::vector< Any >::const_iterator aIter( mrTargets.begin() );
642*cdf0e10cSrcweir 	const std::vector< Any >::const_iterator aEnd( mrTargets.end() );
643*cdf0e10cSrcweir 
644*cdf0e10cSrcweir 	const double fDuration = getSelectedDuration();
645*cdf0e10cSrcweir 
646*cdf0e10cSrcweir 	bool bFirst = true;
647*cdf0e10cSrcweir 	while( aIter != aEnd )
648*cdf0e10cSrcweir 	{
649*cdf0e10cSrcweir 		CustomAnimationEffectPtr pNew(
650*cdf0e10cSrcweir 			pSequence->append( pPreset, (*aIter++), fDuration ) );
651*cdf0e10cSrcweir 
652*cdf0e10cSrcweir 		if( bFirst )
653*cdf0e10cSrcweir 			bFirst = false;
654*cdf0e10cSrcweir 		else
655*cdf0e10cSrcweir 			pNew->setNodeType( EffectNodeType::WITH_PREVIOUS );
656*cdf0e10cSrcweir 	}
657*cdf0e10cSrcweir 
658*cdf0e10cSrcweir 	mpPane->preview( pSequence->getRootNode() );
659*cdf0e10cSrcweir }
660*cdf0e10cSrcweir 
661*cdf0e10cSrcweir namespace
662*cdf0e10cSrcweir {
663*cdf0e10cSrcweir Window * lcl_GetTopmostParent( Window * pWindow )
664*cdf0e10cSrcweir {
665*cdf0e10cSrcweir     Window * pResult = 0;
666*cdf0e10cSrcweir     Window * pCurrent = pWindow ? pWindow->GetParent() : 0;
667*cdf0e10cSrcweir     while( pCurrent )
668*cdf0e10cSrcweir     {
669*cdf0e10cSrcweir         pResult = pCurrent;
670*cdf0e10cSrcweir         pCurrent = pCurrent->GetParent();
671*cdf0e10cSrcweir     }
672*cdf0e10cSrcweir     return pResult;
673*cdf0e10cSrcweir }
674*cdf0e10cSrcweir }
675*cdf0e10cSrcweir 
676*cdf0e10cSrcweir void CustomAnimationCreateDialog::setPosition()
677*cdf0e10cSrcweir {
678*cdf0e10cSrcweir 	SvtViewOptions aDlgOpt(
679*cdf0e10cSrcweir         E_TABDIALOG, String::CreateFromInt32( DLG_CUSTOMANIMATION_CREATE ) );
680*cdf0e10cSrcweir 	if ( aDlgOpt.Exists() )
681*cdf0e10cSrcweir 	{
682*cdf0e10cSrcweir 		SetWindowState( ByteString( aDlgOpt.GetWindowState().getStr(),
683*cdf0e10cSrcweir                                     RTL_TEXTENCODING_ASCII_US ) );
684*cdf0e10cSrcweir     }
685*cdf0e10cSrcweir     else
686*cdf0e10cSrcweir     {
687*cdf0e10cSrcweir         // default position: aligned with right edge of parent
688*cdf0e10cSrcweir         Window * pParent = lcl_GetTopmostParent( this );
689*cdf0e10cSrcweir         if( pParent )
690*cdf0e10cSrcweir         {
691*cdf0e10cSrcweir             Point aPos( GetPosPixel());
692*cdf0e10cSrcweir             Size  aSize( GetSizePixel());
693*cdf0e10cSrcweir             Point aParentPos( pParent->GetPosPixel());
694*cdf0e10cSrcweir             Size  aParentSize( pParent->GetSizePixel());
695*cdf0e10cSrcweir 
696*cdf0e10cSrcweir             // right center
697*cdf0e10cSrcweir             aPos.setX( aParentSize.getWidth() - aSize.getWidth() );
698*cdf0e10cSrcweir             aPos.setY( (aParentSize.getHeight() - aSize.getHeight()) / 2 );
699*cdf0e10cSrcweir             SetPosPixel( aPos );
700*cdf0e10cSrcweir         }
701*cdf0e10cSrcweir     }
702*cdf0e10cSrcweir }
703*cdf0e10cSrcweir 
704*cdf0e10cSrcweir void CustomAnimationCreateDialog::storePosition()
705*cdf0e10cSrcweir {
706*cdf0e10cSrcweir     // save settings (screen position and current page)
707*cdf0e10cSrcweir 	SvtViewOptions aDlgOpt(
708*cdf0e10cSrcweir         E_TABDIALOG, String::CreateFromInt32( DLG_CUSTOMANIMATION_CREATE ) );
709*cdf0e10cSrcweir 	aDlgOpt.SetWindowState(
710*cdf0e10cSrcweir         OUString::createFromAscii( GetWindowState( WINDOWSTATE_MASK_POS ).GetBuffer() ) );
711*cdf0e10cSrcweir }
712*cdf0e10cSrcweir 
713*cdf0e10cSrcweir }
714