xref: /aoo42x/main/sd/source/ui/dlg/dlgass.cxx (revision 87131587)
15b190011SAndrew Rist /**************************************************************
2*87131587Smseidel  *
35b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
45b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
55b190011SAndrew Rist  * distributed with this work for additional information
65b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
75b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
85b190011SAndrew Rist  * "License"); you may not use this file except in compliance
95b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*87131587Smseidel  *
115b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*87131587Smseidel  *
135b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
145b190011SAndrew Rist  * software distributed under the License is distributed on an
155b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
175b190011SAndrew Rist  * specific language governing permissions and limitations
185b190011SAndrew Rist  * under the License.
19*87131587Smseidel  *
205b190011SAndrew Rist  *************************************************************/
215b190011SAndrew Rist 
225b190011SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifdef SD_DLLIMPLEMENTATION
28cdf0e10cSrcweir #undef SD_DLLIMPLEMENTATION
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #include <com/sun/star/presentation/ClickAction.hpp>
31cdf0e10cSrcweir #include <vcl/svapp.hxx>
32cdf0e10cSrcweir #include <vos/mutex.hxx>
33cdf0e10cSrcweir #include <vcl/msgbox.hxx>
34cdf0e10cSrcweir #include <vcl/lstbox.hxx>
35cdf0e10cSrcweir #include <vcl/combobox.hxx>
36cdf0e10cSrcweir #include <sfx2/doctempl.hxx>
37cdf0e10cSrcweir #include <svl/lstner.hxx>
38cdf0e10cSrcweir #include <sfx2/objsh.hxx>
39cdf0e10cSrcweir #include <svtools/ehdl.hxx>
40cdf0e10cSrcweir #include <svtools/sfxecode.hxx>
41cdf0e10cSrcweir #include <tools/urlobj.hxx>
42cdf0e10cSrcweir #include <com/sun/star/presentation/FadeEffect.hpp>
43cdf0e10cSrcweir #include <fadedef.h>
44cdf0e10cSrcweir #include <sfx2/sfxsids.hrc>
45cdf0e10cSrcweir #include <svl/undo.hxx>
46cdf0e10cSrcweir #include "DrawDocShell.hxx"
47cdf0e10cSrcweir #include <vcl/gdimtf.hxx>
48cdf0e10cSrcweir #include <tools/wintypes.hxx>
49cdf0e10cSrcweir #include "docprev.hxx"
50cdf0e10cSrcweir #include <sfx2/app.hxx>
51cdf0e10cSrcweir #include <sfx2/docfile.hxx>
52cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
53cdf0e10cSrcweir #include <sfx2/request.hxx>
54cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSet.hpp>
55cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
56cdf0e10cSrcweir #include <com/sun/star/util/XCloseable.hpp>
57cdf0e10cSrcweir #include <com/sun/star/uno/RuntimeException.hpp>
58cdf0e10cSrcweir #include <com/sun/star/frame/XModuleManager.hpp>
59cdf0e10cSrcweir #include <com/sun/star/ucb/XSimpleFileAccess.hpp>
60cdf0e10cSrcweir #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
61cdf0e10cSrcweir #include <com/sun/star/ui/XImageManager.hpp>
62cdf0e10cSrcweir #include <unotools/historyoptions.hxx>
63cdf0e10cSrcweir #include <tools/urlobj.hxx>
64cdf0e10cSrcweir #include <osl/file.hxx>
65cdf0e10cSrcweir #include <sfx2/filedlghelper.hxx>
66cdf0e10cSrcweir 
67cdf0e10cSrcweir #include "sdpage.hxx"
68cdf0e10cSrcweir #include "helpids.h"
69cdf0e10cSrcweir #include "assclass.hxx"
70cdf0e10cSrcweir #include "dlgass.hrc"
71cdf0e10cSrcweir #include "dlgass.hxx"
72cdf0e10cSrcweir #include "dlgctrls.hxx"
73cdf0e10cSrcweir #ifndef _SD_CFGID_HXX
74cdf0e10cSrcweir #include "strings.hrc"
75cdf0e10cSrcweir #endif
76cdf0e10cSrcweir #ifndef _DATETIMEITEM_HXX
77cdf0e10cSrcweir #include "dlgassim.hxx"
78cdf0e10cSrcweir #endif
79cdf0e10cSrcweir #include "TemplateScanner.hxx"
80cdf0e10cSrcweir #include "WindowUpdater.hxx"
81cdf0e10cSrcweir 
82cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
83cdf0e10cSrcweir 
84cdf0e10cSrcweir using namespace ::com::sun::star;
85cdf0e10cSrcweir using namespace ::com::sun::star::uno;
86cdf0e10cSrcweir using namespace ::sd;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 
InterpolateFixedBitmap(FixedBitmap * pBitmap)89cdf0e10cSrcweir void InterpolateFixedBitmap( FixedBitmap * pBitmap )
90cdf0e10cSrcweir {
91cdf0e10cSrcweir 	Bitmap aBmp( pBitmap->GetBitmap() );
92cdf0e10cSrcweir 	Size aSize = pBitmap->GetSizePixel();
93cdf0e10cSrcweir 	aBmp.Scale( aSize, BMP_SCALE_INTERPOLATE );
94cdf0e10cSrcweir 	pBitmap->SetBitmap( aBmp );
95cdf0e10cSrcweir }
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 
98cdf0e10cSrcweir // ====================================================================
99cdf0e10cSrcweir // ====================================================================
100cdf0e10cSrcweir 
101cdf0e10cSrcweir const char* PageHelpIds[] =
102cdf0e10cSrcweir {
103cdf0e10cSrcweir 	HID_SD_AUTOPILOT_PAGE1,
104cdf0e10cSrcweir 	HID_SD_AUTOPILOT_PAGE2,
105cdf0e10cSrcweir 	HID_SD_AUTOPILOT_PAGE3,
106cdf0e10cSrcweir 	HID_SD_AUTOPILOT_PAGE4,
107cdf0e10cSrcweir 	HID_SD_AUTOPILOT_PAGE5
108cdf0e10cSrcweir };
109cdf0e10cSrcweir 
110cdf0e10cSrcweir // ====================================================================
111cdf0e10cSrcweir 
112cdf0e10cSrcweir class PasswordEntry
113cdf0e10cSrcweir {
114cdf0e10cSrcweir public:
115cdf0e10cSrcweir 	String maPassword;
116cdf0e10cSrcweir 	String maPath;
117cdf0e10cSrcweir };
118cdf0e10cSrcweir 
119cdf0e10cSrcweir DECLARE_LIST( PasswordEntryList, PasswordEntry * )
120cdf0e10cSrcweir 
121cdf0e10cSrcweir // ====================================================================
122cdf0e10cSrcweir 
123cdf0e10cSrcweir /** A simple wrapper that looks like a PushButton and is used to force the
124*87131587Smseidel 	broadcasting of focus events primarily for accessibility tools.
125*87131587Smseidel 	Forcing focus events is achieved by using two identical PushButtons
126*87131587Smseidel 	which, when the focus event is requested, are exchanged and play focus
127*87131587Smseidel 	ping-pong by moving the focus from one to the other.
128cdf0e10cSrcweir */
129cdf0e10cSrcweir class NextButton
130cdf0e10cSrcweir {
131cdf0e10cSrcweir public:
132*87131587Smseidel 	NextButton (::Window* pParent, const ResId& rResId);
133cdf0e10cSrcweir 
134*87131587Smseidel 	void ForceFocusEventBroadcast (void);
135cdf0e10cSrcweir 	void SetClickHdl (const Link& rLink);
136*87131587Smseidel 	bool IsEnabled (void);
137cdf0e10cSrcweir 	void Enable (bool bEnable);
138cdf0e10cSrcweir 
139cdf0e10cSrcweir private:
140*87131587Smseidel 	PushButton maNextButton1;
141*87131587Smseidel 	PushButton maNextButton2;
142*87131587Smseidel 	bool mbIsFirstButtonActive;
143cdf0e10cSrcweir };
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 
147cdf0e10cSrcweir // ====================================================================
148cdf0e10cSrcweir 
149cdf0e10cSrcweir class AssistentDlgImpl : public SfxListener
150cdf0e10cSrcweir {
151cdf0e10cSrcweir public:
152*87131587Smseidel 	AssistentDlgImpl( ::Window* pWindow, const Link& rFinishLink, sal_Bool bAutoPilot );
153cdf0e10cSrcweir 	~AssistentDlgImpl();
154cdf0e10cSrcweir 
155*87131587Smseidel 	// Local mutex used to serialize concurrent method calls.
156*87131587Smseidel 	::osl::Mutex maMutex;
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 	SfxObjectShellLock GetDocument();
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 	/** closes the current preview docshell */
161cdf0e10cSrcweir 	void CloseDocShell();
162cdf0e10cSrcweir 
163*87131587Smseidel 	/** Extract form the history list of recently used files the Impress
164cdf0e10cSrcweir 		files and insert them into a listbox.
165cdf0e10cSrcweir 	*/
166cdf0e10cSrcweir 	void	ScanDocmenu			(void);
167*87131587Smseidel 	/** Flag that is set to sal_True after the recently used files have been
168*87131587Smseidel 		scanned.
169cdf0e10cSrcweir 	*/
170cdf0e10cSrcweir 	sal_Bool mbRecentDocumentsReady;
171cdf0e10cSrcweir 
172*87131587Smseidel 	/** When the list of templates has not been scanned already this is done
173*87131587Smseidel 		when this method is called. That includes requesting the whole list
174*87131587Smseidel 		of templates from UCB and extracting from that list the Impress
175*87131587Smseidel 		templates and layouts and storing them for later use in
176*87131587Smseidel 		<member>maPresentList</member>. Note that the first call to this
177*87131587Smseidel 		method after installing a new Office may take some time.
178cdf0e10cSrcweir 	*/
179cdf0e10cSrcweir 	void ProvideTemplates (void);
180cdf0e10cSrcweir 
181*87131587Smseidel 	/** This method transfers the template folders from the template scanner
182*87131587Smseidel 		to the internal structures of this class. On termination it sets
183cdf0e10cSrcweir 		the flag <member>mbTemplatesReady</member> to <TRUE/> to indicate
184cdf0e10cSrcweir 		that the templates are available.
185*87131587Smseidel 		@param rTemplateFolders
186*87131587Smseidel 			This is a list of template folders. This method takes ownership
187*87131587Smseidel 			of the supplied entries by removing them from the list and
188*87131587Smseidel 			transferring them to an internal structure.
189cdf0e10cSrcweir 	*/
190cdf0e10cSrcweir 	void TemplateScanDone (std::vector<TemplateDir*>& rTemplateFolders);
191cdf0e10cSrcweir 
192*87131587Smseidel 	/** Flag that is set to sal_True after the Impress templates have been
193*87131587Smseidel 		scanned.
194cdf0e10cSrcweir 	*/
195cdf0e10cSrcweir 	sal_Bool mbTemplatesReady;
196cdf0e10cSrcweir 
197*87131587Smseidel 	/** Flag used to prevent nested or concurrent calls to the
198*87131587Smseidel 		<member>UpdatePreview</member> method. A <TRUE/> value indicates
199*87131587Smseidel 		that a preview update is currently active.
200*87131587Smseidel 	*/
201*87131587Smseidel 	sal_Bool mbPreviewUpdating;
202cdf0e10cSrcweir 
203cdf0e10cSrcweir 	::Window* mpWindow;
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 	void SavePassword( SfxObjectShellLock xDoc, const String& rPath );
206cdf0e10cSrcweir 	void RestorePassword( SfxItemSet* pSet, const String& rPath );
207cdf0e10cSrcweir 	String GetPassword( const String rPath );
208cdf0e10cSrcweir 	void DeletePassords();
209cdf0e10cSrcweir 
210cdf0e10cSrcweir 	PasswordEntryList maPasswordList;
211cdf0e10cSrcweir 
212cdf0e10cSrcweir 	String maDocFile;
213cdf0e10cSrcweir 	String maLayoutFile;
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 	String GetDocFileName();
216cdf0e10cSrcweir 	String GetLayoutFileName();
217cdf0e10cSrcweir 
218*87131587Smseidel 	// List of URLs of recently used Impress files.
219cdf0e10cSrcweir 	std::vector<String*> maOpenFilesList;
220cdf0e10cSrcweir 
221*87131587Smseidel 	// List of folders containing data about Impress templates.
222cdf0e10cSrcweir 	std::vector<TemplateDir*> maPresentList;
223cdf0e10cSrcweir 
224*87131587Smseidel 	// Currently selected template folder.
225cdf0e10cSrcweir 	TemplateDir* mpTemplateRegion;
226cdf0e10cSrcweir 
227*87131587Smseidel 	// Currently selected layout folder.
228cdf0e10cSrcweir 	TemplateDir* mpLayoutRegion;
229cdf0e10cSrcweir 
230cdf0e10cSrcweir 	// preview
231cdf0e10cSrcweir 	sal_Bool mbUserDataDirty;
232cdf0e10cSrcweir 	Timer maPrevTimer;
233cdf0e10cSrcweir 	Timer maEffectPrevTimer;
234cdf0e10cSrcweir 	Timer maUpdatePageListTimer;
235cdf0e10cSrcweir 	Timer maStartScanTimer;
236cdf0e10cSrcweir 
237cdf0e10cSrcweir 	SfxObjectShellLock xDocShell;
238cdf0e10cSrcweir 
239*87131587Smseidel 	::std::auto_ptr<WindowUpdater> mpWindowUpdater;
240cdf0e10cSrcweir 
241cdf0e10cSrcweir 	sal_Bool mbPreview;
242cdf0e10cSrcweir 	sal_uInt16 mnShowPage;
243cdf0e10cSrcweir 	sal_Bool mbDocPreview;
244cdf0e10cSrcweir 
245cdf0e10cSrcweir 	sal_uLong mnTemplate;
246cdf0e10cSrcweir 
247cdf0e10cSrcweir 	String maPageListFile;
248cdf0e10cSrcweir 
249cdf0e10cSrcweir 	void UpdatePreview( sal_Bool bDocPreview );
250cdf0e10cSrcweir 	void UpdatePageList();
251cdf0e10cSrcweir 	void UpdateUserData();
252cdf0e10cSrcweir 
253cdf0e10cSrcweir 	sal_Bool IsOwnFormat( const String& rPath );
254cdf0e10cSrcweir 
255cdf0e10cSrcweir 	// dlg status
256cdf0e10cSrcweir 	void EndDialog( long nResult = 0 );
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 	void SetStartType( StartType eType );
259cdf0e10cSrcweir 	StartType GetStartType();
260cdf0e10cSrcweir 
261cdf0e10cSrcweir 	void SelectTemplateRegion( const String& rRegion );
262cdf0e10cSrcweir 	void SelectLayoutRegion( const String& rRegion );
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 	void UpdatePage();
265cdf0e10cSrcweir 	void ChangePage();
266cdf0e10cSrcweir 	void LeavePage();
267cdf0e10cSrcweir 
268*87131587Smseidel 	String GetUiTextForCommand (const ::rtl::OUString& aCommandURL);
269*87131587Smseidel 	Image GetUiIconForCommand (const ::rtl::OUString& aCommandURL);
270cdf0e10cSrcweir 
271cdf0e10cSrcweir 	DECL_LINK( StartScanHdl, void * );
272cdf0e10cSrcweir 	DECL_LINK( SelectFileHdl, ListBox * );
273cdf0e10cSrcweir 	DECL_LINK( SelectRegionHdl, ListBox * );
274cdf0e10cSrcweir 	DECL_LINK( UpdatePreviewHdl, void * );
275cdf0e10cSrcweir 	DECL_LINK( UpdatePageListHdl, void * );
276cdf0e10cSrcweir 	DECL_LINK( StartTypeHdl, RadioButton * );
277cdf0e10cSrcweir 	DECL_LINK( SelectTemplateHdl, ListBox * );
278cdf0e10cSrcweir 	DECL_LINK( NextPageHdl, PushButton * );
279cdf0e10cSrcweir 	DECL_LINK( LastPageHdl, PushButton * );
280cdf0e10cSrcweir 	DECL_LINK( PreviewFlagHdl, CheckBox * );
281cdf0e10cSrcweir 	DECL_LINK( EffectPreviewHdl, Button * );
282cdf0e10cSrcweir 	DECL_LINK( SelectLayoutHdl, ListBox * );
283cdf0e10cSrcweir 	DECL_LINK( PageSelectHdl, Control * );
284cdf0e10cSrcweir 	DECL_LINK( PresTypeHdl, RadioButton * );
285cdf0e10cSrcweir 	DECL_LINK( UpdateUserDataHdl, Edit* );
286cdf0e10cSrcweir 	DECL_LINK( SelectEffectHdl, void* );
287*87131587Smseidel 	DECL_LINK( OpenButtonHdl, Button * );
288cdf0e10cSrcweir 
289cdf0e10cSrcweir 	// Common
290cdf0e10cSrcweir 	Assistent			maAssistentFunc;
291cdf0e10cSrcweir 	CheckBox			maPreviewFlag;
292cdf0e10cSrcweir 	CheckBox			maStartWithFlag;
293cdf0e10cSrcweir 	HelpButton			maHelpButton;
294cdf0e10cSrcweir 	CancelButton		maCancelButton;
295cdf0e10cSrcweir 	PushButton			maLastPageButton;
296*87131587Smseidel 	NextButton			maNextPageButton;
297cdf0e10cSrcweir 	OKButton			maFinishButton;
298cdf0e10cSrcweir 	SdDocPreviewWin		maPreview;
299cdf0e10cSrcweir 
300*87131587Smseidel 	String				maCreateStr;
301*87131587Smseidel 	String				maOpenStr;
302cdf0e10cSrcweir 
303*87131587Smseidel 	// Page 1
304cdf0e10cSrcweir 	FixedBitmap*		mpPage1FB;
305cdf0e10cSrcweir 	FixedLine*			mpPage1ArtFL;
306cdf0e10cSrcweir 	RadioButton*		mpPage1EmptyRB;
307cdf0e10cSrcweir 	RadioButton*		mpPage1TemplateRB;
308cdf0e10cSrcweir 	ListBox*			mpPage1RegionLB;
309cdf0e10cSrcweir 	ListBox*			mpPage1TemplateLB;
310cdf0e10cSrcweir 	RadioButton*		mpPage1OpenRB;
311cdf0e10cSrcweir 	ListBox*			mpPage1OpenLB;
312*87131587Smseidel 	PushButton*			mpPage1OpenPB;
313cdf0e10cSrcweir 
314*87131587Smseidel 	// Page 2
315cdf0e10cSrcweir 	FixedBitmap*		mpPage2FB;
316cdf0e10cSrcweir 	FixedLine*			mpPage2LayoutFL;
317cdf0e10cSrcweir 	ListBox*			mpPage2RegionLB;
318cdf0e10cSrcweir 	ListBox*			mpPage2LayoutLB;
319cdf0e10cSrcweir 	FixedLine*			mpPage2OutTypesFL;
320cdf0e10cSrcweir 	RadioButton*		mpPage2Medium1RB;
321cdf0e10cSrcweir 	RadioButton*		mpPage2Medium2RB;
322cdf0e10cSrcweir 	RadioButton*		mpPage2Medium3RB;
323cdf0e10cSrcweir 	RadioButton*		mpPage2Medium4RB;
324cdf0e10cSrcweir 	RadioButton*		mpPage2Medium5RB;
325cdf0e10cSrcweir 
326*87131587Smseidel 	// Page 3
327cdf0e10cSrcweir 	FixedBitmap*		mpPage3FB;
328cdf0e10cSrcweir 	FixedLine*			mpPage3EffectFL;
329cdf0e10cSrcweir 	FixedText*			mpPage3EffectFT;
330cdf0e10cSrcweir 	FadeEffectLB*		mpPage3EffectLB;
331cdf0e10cSrcweir 	FixedText*			mpPage3SpeedFT;
332cdf0e10cSrcweir 	ListBox*			mpPage3SpeedLB;
333cdf0e10cSrcweir 	FixedLine*			mpPage3PresTypeFL;
334cdf0e10cSrcweir 	RadioButton*		mpPage3PresTypeLiveRB;
335cdf0e10cSrcweir 	RadioButton*		mpPage3PresTypeKioskRB;
336cdf0e10cSrcweir 	FixedText*			mpPage3PresTimeFT;
337cdf0e10cSrcweir 	TimeField*			mpPage3PresTimeTMF;
338cdf0e10cSrcweir 	FixedText*			mpPage3BreakFT;
339cdf0e10cSrcweir 	TimeField*			mpPage3BreakTMF;
340cdf0e10cSrcweir 	CheckBox*			mpPage3LogoCB;
341cdf0e10cSrcweir 
342*87131587Smseidel 	// Page 4
343cdf0e10cSrcweir 	FixedBitmap*		mpPage4FB;
344cdf0e10cSrcweir 	FixedLine*			mpPage4PersonalFL;
345cdf0e10cSrcweir 	FixedText*			mpPage4AskNameFT;
346cdf0e10cSrcweir 	Edit*				mpPage4AskNameEDT;
347cdf0e10cSrcweir 	FixedText*			mpPage4AskTopicFT;
348cdf0e10cSrcweir 	Edit*				mpPage4AskTopicEDT;
349cdf0e10cSrcweir 	FixedText*			mpPage4AskInfoFT;
350cdf0e10cSrcweir 	MultiLineEdit*		mpPage4AskInfoEDT;
351cdf0e10cSrcweir 
352*87131587Smseidel 	// Page 5
353cdf0e10cSrcweir 	FixedBitmap*		mpPage5FB;
354cdf0e10cSrcweir 	FixedText*			mpPage5PageListFT;
355cdf0e10cSrcweir 	SdPageListControl*	mpPage5PageListCT;
356cdf0e10cSrcweir 	CheckBox*			mpPage5SummaryCB;
357cdf0e10cSrcweir 
358cdf0e10cSrcweir };
359cdf0e10cSrcweir 
360cdf0e10cSrcweir 
361cdf0e10cSrcweir 
362cdf0e10cSrcweir // ====================================================================
363cdf0e10cSrcweir 
AssistentDlgImpl(::Window * pWindow,const Link & rFinishLink,sal_Bool bAutoPilot)364cdf0e10cSrcweir AssistentDlgImpl::AssistentDlgImpl( ::Window* pWindow, const Link& rFinishLink, sal_Bool bAutoPilot ) :
365cdf0e10cSrcweir 	mpTemplateRegion(NULL),
366cdf0e10cSrcweir 	mpLayoutRegion(NULL),
367cdf0e10cSrcweir 	mbUserDataDirty(sal_False),
368cdf0e10cSrcweir 	xDocShell (NULL),
369*87131587Smseidel 	mpWindowUpdater (new WindowUpdater()),
370cdf0e10cSrcweir 	mbPreview(sal_True),
371cdf0e10cSrcweir 	mnShowPage(0),
372cdf0e10cSrcweir 	mbDocPreview(sal_False),
373cdf0e10cSrcweir 	maAssistentFunc(5),
374cdf0e10cSrcweir 	maPreviewFlag(pWindow,SdResId(CB_PREVIEW)),
375cdf0e10cSrcweir 	maStartWithFlag(pWindow,SdResId(CB_STARTWITH)),
376cdf0e10cSrcweir 	maHelpButton(pWindow,SdResId(BUT_HELP)),
377cdf0e10cSrcweir 	maCancelButton(pWindow,SdResId(BUT_CANCEL)),
378cdf0e10cSrcweir 	maLastPageButton(pWindow,SdResId(BUT_LAST)),
379cdf0e10cSrcweir 	maNextPageButton(pWindow,SdResId(BUT_NEXT)),
380cdf0e10cSrcweir 	maFinishButton(pWindow,SdResId(BUT_FINISH)),
381cdf0e10cSrcweir 	maPreview(pWindow,SdResId(CT_PREVIEW)),
382*87131587Smseidel 	maCreateStr(SdResId(STR_CREATE)),
383*87131587Smseidel 	maOpenStr(SdResId(STR_OPEN))
384cdf0e10cSrcweir {
385cdf0e10cSrcweir 	maPageListFile += sal_Unicode('?'),
386*87131587Smseidel 	mbRecentDocumentsReady = sal_False;
387cdf0e10cSrcweir 	mbTemplatesReady = sal_False;
388*87131587Smseidel 	mbPreviewUpdating = sal_False;
389cdf0e10cSrcweir 
390cdf0e10cSrcweir 	mpWindow = pWindow;
391cdf0e10cSrcweir 
392cdf0e10cSrcweir 	if(bAutoPilot)
393cdf0e10cSrcweir 		maStartWithFlag.Hide();
394cdf0e10cSrcweir 	else
395cdf0e10cSrcweir 		maAssistentFunc.InsertControl(1, &maStartWithFlag );
396cdf0e10cSrcweir 
397*87131587Smseidel 	// Page1 wird initialisiert und an die Assistentenfunktionalitaet
398*87131587Smseidel 	// uebergeben
399cdf0e10cSrcweir 	maAssistentFunc.InsertControl(1, &maPreview );
400cdf0e10cSrcweir 	maAssistentFunc.InsertControl(1, &maPreviewFlag );
401cdf0e10cSrcweir 	maAssistentFunc.InsertControl(1,
402cdf0e10cSrcweir 		mpPage1FB = new FixedBitmap(pWindow,SdResId(FB_PAGE1)));
403cdf0e10cSrcweir 	maAssistentFunc.InsertControl(1,
404cdf0e10cSrcweir 		mpPage1ArtFL = new FixedLine(pWindow,SdResId(FL_PAGE1_ARTGROUP)));
405cdf0e10cSrcweir 	maAssistentFunc.InsertControl(1,
406cdf0e10cSrcweir 		mpPage1EmptyRB=new RadioButton(pWindow,SdResId(RB_PAGE1_EMPTY)));
407cdf0e10cSrcweir 	maAssistentFunc.InsertControl(1,
408cdf0e10cSrcweir 		mpPage1TemplateRB=new RadioButton(pWindow,SdResId(RB_PAGE1_TEMPLATE)));
409cdf0e10cSrcweir 	maAssistentFunc.InsertControl(1,
410cdf0e10cSrcweir 		mpPage1OpenRB=new RadioButton(pWindow,SdResId(RB_PAGE1_OPEN)));
411cdf0e10cSrcweir 	maAssistentFunc.InsertControl(1,
412cdf0e10cSrcweir 		mpPage1RegionLB = new ListBox(pWindow,SdResId(LB_PAGE1_REGION)));
413cdf0e10cSrcweir 	maAssistentFunc.InsertControl(1,
414cdf0e10cSrcweir 		mpPage1TemplateLB=new ListBox(pWindow,SdResId(LB_PAGE1_TEMPLATES)));
415cdf0e10cSrcweir 	maAssistentFunc.InsertControl(1,
416cdf0e10cSrcweir 		mpPage1OpenPB=new PushButton(pWindow,SdResId(PB_PAGE1_OPEN)));
417cdf0e10cSrcweir 	maAssistentFunc.InsertControl(1,
418cdf0e10cSrcweir 		mpPage1OpenLB=new ListBox(pWindow,SdResId(LB_PAGE1_OPEN)));
419cdf0e10cSrcweir 
420*87131587Smseidel 	// Align the button and list box displayed for the "open existing file"
421*87131587Smseidel 	// radio button with the text of that radio button.
422*87131587Smseidel 	{
423*87131587Smseidel 		RadioButton aEmptyRB (mpWindow);
424*87131587Smseidel 		sal_Int32 nIndent (aEmptyRB.CalcMinimumSize(0).Width());
425*87131587Smseidel 		sal_Int32 nLeft (mpPage1OpenRB->GetPosPixel().X() + nIndent);
426*87131587Smseidel 		sal_Int32 nWidth (mpPage1OpenRB->GetSizePixel().Width() - nIndent);
427*87131587Smseidel 		mpPage1OpenPB->SetPosSizePixel(
428*87131587Smseidel 			Point(nLeft, mpPage1OpenPB->GetPosPixel().Y()),
429*87131587Smseidel 			Size(mpPage1OpenPB->GetSizePixel()));
430*87131587Smseidel 		mpPage1OpenLB->SetPosSizePixel(
431*87131587Smseidel 			Point(nLeft, mpPage1OpenLB->GetPosPixel().Y()),
432*87131587Smseidel 			Size(nWidth, mpPage1OpenLB->GetSizePixel().Height()));
433*87131587Smseidel 	}
434*87131587Smseidel 
435*87131587Smseidel 	// Set text and icon of the 'Open...' button.
436*87131587Smseidel 	{
437*87131587Smseidel 		String sText (GetUiTextForCommand(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:Open"))));
438*87131587Smseidel 		// Remove the mnemonic and add a leading space so that icon and text
439*87131587Smseidel 		// are not too close together.
440*87131587Smseidel 		sText.SearchAndReplaceAll(String(RTL_CONSTASCII_STRINGPARAM("~")),String());
441*87131587Smseidel 		sText.Insert(String(RTL_CONSTASCII_STRINGPARAM(" ")),0);
442*87131587Smseidel 		mpPage1OpenPB->SetText(sText);
443*87131587Smseidel 		// Place icon left of text and both centered in the button.
444*87131587Smseidel 		mpPage1OpenPB->SetModeImage(
445*87131587Smseidel 			GetUiIconForCommand(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:Open"))),
446*87131587Smseidel 			BMP_COLOR_NORMAL);
447*87131587Smseidel 		mpPage1OpenPB->EnableImageDisplay(sal_True);
448*87131587Smseidel 		mpPage1OpenPB->EnableTextDisplay(sal_True);
449*87131587Smseidel 		mpPage1OpenPB->SetImageAlign(IMAGEALIGN_LEFT);
450*87131587Smseidel 		mpPage1OpenPB->SetStyle(mpPage1OpenPB->GetStyle() | WB_CENTER);
451*87131587Smseidel 	}
452cdf0e10cSrcweir 
453cdf0e10cSrcweir 	// links&handler
454cdf0e10cSrcweir 	mpPage1RegionLB->SetSelectHdl(LINK(this,AssistentDlgImpl,SelectRegionHdl));
455cdf0e10cSrcweir 	mpPage1RegionLB->SetDropDownLineCount( 6 );
456cdf0e10cSrcweir 	mpPage1TemplateLB->SetSelectHdl(LINK(this,AssistentDlgImpl,SelectTemplateHdl));
457cdf0e10cSrcweir 	mpPage1TemplateLB->InsertEntry(String(SdResId(STR_ISLOADING)));
458cdf0e10cSrcweir 
459cdf0e10cSrcweir 	mpPage1EmptyRB->SetClickHdl(LINK(this,AssistentDlgImpl,StartTypeHdl));
460cdf0e10cSrcweir 	mpPage1TemplateRB->SetClickHdl(LINK(this,AssistentDlgImpl,StartTypeHdl));
461cdf0e10cSrcweir 	mpPage1OpenRB->SetClickHdl(LINK(this,AssistentDlgImpl,StartTypeHdl));
462cdf0e10cSrcweir 	mpPage1OpenLB->SetSelectHdl(LINK(this,AssistentDlgImpl,SelectFileHdl));
463cdf0e10cSrcweir 	mpPage1OpenLB->SetDoubleClickHdl(rFinishLink);
464*87131587Smseidel 	mpPage1OpenPB->SetClickHdl(LINK(this,AssistentDlgImpl,OpenButtonHdl));
465*87131587Smseidel //	mpPage1OpenLB->InsertEntry(String(SdResId(STR_WIZARD_POSITION)));
466cdf0e10cSrcweir 
467*87131587Smseidel 	// Page 2
468cdf0e10cSrcweir 	maAssistentFunc.InsertControl(2, &maPreview );
469cdf0e10cSrcweir 	maAssistentFunc.InsertControl(2, &maPreviewFlag );
470cdf0e10cSrcweir 	maAssistentFunc.InsertControl(2,
471cdf0e10cSrcweir 		mpPage2FB = new FixedBitmap(pWindow,SdResId(FB_PAGE2)));
472cdf0e10cSrcweir 	maAssistentFunc.InsertControl(2,
473cdf0e10cSrcweir 		mpPage2LayoutFL = new FixedLine( pWindow, SdResId(FL_PAGE2_LAYOUT) ));
474cdf0e10cSrcweir 	maAssistentFunc.InsertControl(2,
475cdf0e10cSrcweir 		mpPage2RegionLB = new ListBox(pWindow,SdResId(LB_PAGE2_REGION) ));
476cdf0e10cSrcweir 	maAssistentFunc.InsertControl(2,
477cdf0e10cSrcweir 		mpPage2LayoutLB = new ListBox(pWindow,SdResId(LB_PAGE2_LAYOUT) ));
478cdf0e10cSrcweir 
479cdf0e10cSrcweir 	maAssistentFunc.InsertControl(2,
480cdf0e10cSrcweir 		mpPage2OutTypesFL = new FixedLine( pWindow, SdResId(FL_PAGE2_OUTPUTTYPES) ));
481cdf0e10cSrcweir 	maAssistentFunc.InsertControl(2,
482cdf0e10cSrcweir 		mpPage2Medium5RB = new RadioButton( pWindow, SdResId(RB_PAGE2_MEDIUM5) ));
483cdf0e10cSrcweir 	maAssistentFunc.InsertControl(2,
484cdf0e10cSrcweir 		mpPage2Medium3RB = new RadioButton( pWindow, SdResId(RB_PAGE2_MEDIUM3) ));
485cdf0e10cSrcweir 	maAssistentFunc.InsertControl(2,
486cdf0e10cSrcweir 		mpPage2Medium4RB = new RadioButton( pWindow, SdResId(RB_PAGE2_MEDIUM4) ));
487cdf0e10cSrcweir 	maAssistentFunc.InsertControl(2,
488cdf0e10cSrcweir 		mpPage2Medium1RB = new RadioButton( pWindow, SdResId(RB_PAGE2_MEDIUM1) ));
489cdf0e10cSrcweir 	maAssistentFunc.InsertControl(2,
490cdf0e10cSrcweir 		mpPage2Medium2RB = new RadioButton( pWindow, SdResId(RB_PAGE2_MEDIUM2) ));
491cdf0e10cSrcweir 	mpPage2Medium5RB->Check();
492cdf0e10cSrcweir 
493cdf0e10cSrcweir 	mpPage2RegionLB->SetSelectHdl(LINK(this,AssistentDlgImpl,SelectRegionHdl));
494cdf0e10cSrcweir 	mpPage2RegionLB->SetDropDownLineCount( 6 );
495cdf0e10cSrcweir 	mpPage2LayoutLB->SetSelectHdl(LINK(this,AssistentDlgImpl,SelectLayoutHdl));
496cdf0e10cSrcweir 	mpPage2LayoutLB->InsertEntry(String(SdResId(STR_ISLOADING)));
497cdf0e10cSrcweir 
498*87131587Smseidel 	// Page 3
499cdf0e10cSrcweir 	maAssistentFunc.InsertControl(3, &maPreview );
500cdf0e10cSrcweir 	maAssistentFunc.InsertControl(3, &maPreviewFlag );
501cdf0e10cSrcweir 	maAssistentFunc.InsertControl(3,
502cdf0e10cSrcweir 		mpPage3FB = new FixedBitmap(pWindow,SdResId(FB_PAGE3)));
503cdf0e10cSrcweir 	maAssistentFunc.InsertControl(3,
504cdf0e10cSrcweir 		mpPage3EffectFL = new FixedLine( pWindow, SdResId(FL_PAGE3_EFFECT) ));
505cdf0e10cSrcweir 	maAssistentFunc.InsertControl(3,
506cdf0e10cSrcweir 		mpPage3EffectFT = new FixedText( pWindow, SdResId(FT_PAGE3_EFFECT) ));
507cdf0e10cSrcweir 	maAssistentFunc.InsertControl(3,
508cdf0e10cSrcweir 		mpPage3EffectLB = new FadeEffectLB( pWindow, SdResId(LB_PAGE3_EFFECT) ));
509cdf0e10cSrcweir 	maAssistentFunc.InsertControl(3,
510cdf0e10cSrcweir 		mpPage3SpeedFT = new FixedText( pWindow, SdResId(FT_PAGE3_SPEED) ));
511cdf0e10cSrcweir 	maAssistentFunc.InsertControl(3,
512cdf0e10cSrcweir 		mpPage3SpeedLB = new FadeEffectLB( pWindow, SdResId(LB_PAGE3_SPEED) ));
513cdf0e10cSrcweir 	maAssistentFunc.InsertControl(3,
514cdf0e10cSrcweir 		mpPage3PresTypeFL = new FixedLine( pWindow, SdResId(FL_PAGE3_PRESTYPE) ));
515cdf0e10cSrcweir 	maAssistentFunc.InsertControl(3,
516cdf0e10cSrcweir 		mpPage3PresTypeLiveRB = new RadioButton( pWindow, SdResId(RB_PAGE3_LIVE) ));
517cdf0e10cSrcweir 	maAssistentFunc.InsertControl(3,
518cdf0e10cSrcweir 		mpPage3PresTypeKioskRB = new RadioButton( pWindow, SdResId(RB_PAGE3_KIOSK) ));
519cdf0e10cSrcweir 	maAssistentFunc.InsertControl(3,
520cdf0e10cSrcweir 		mpPage3PresTimeFT = new FixedText( pWindow, SdResId( FT_PAGE3_TIME) ));
521cdf0e10cSrcweir 	maAssistentFunc.InsertControl(3,
522cdf0e10cSrcweir 		mpPage3PresTimeTMF = new TimeField( pWindow, SdResId( TMF_PAGE3_TIME) ));
523cdf0e10cSrcweir 	maAssistentFunc.InsertControl(3,
524cdf0e10cSrcweir 		mpPage3BreakFT = new FixedText( pWindow, SdResId( FT_PAGE3_BREAK) ));
525cdf0e10cSrcweir 	maAssistentFunc.InsertControl(3,
526cdf0e10cSrcweir 		mpPage3BreakTMF = new TimeField( pWindow, SdResId( TMF_PAGE3_BREAK) ));
527cdf0e10cSrcweir 	maAssistentFunc.InsertControl(3,
528cdf0e10cSrcweir 		mpPage3LogoCB = new CheckBox( pWindow, SdResId( CB_PAGE3_LOGO) ));
529cdf0e10cSrcweir 
530cdf0e10cSrcweir 	mpPage3EffectLB->Fill();
531cdf0e10cSrcweir //	mpPage3EffectLB->SelectEffect( presentation::FadeEffect_NONE );
532cdf0e10cSrcweir 	mpPage3EffectLB->SetSelectHdl( LINK(this,AssistentDlgImpl,SelectEffectHdl ));
533cdf0e10cSrcweir 	mpPage3EffectLB->SetDropDownLineCount( 12 );
534cdf0e10cSrcweir 
535cdf0e10cSrcweir 	mpPage3SpeedLB->InsertEntry( String( SdResId(STR_SLOW) ));
536cdf0e10cSrcweir 	mpPage3SpeedLB->InsertEntry( String( SdResId(STR_MEDIUM) ));
537cdf0e10cSrcweir 	mpPage3SpeedLB->InsertEntry( String( SdResId(STR_FAST) ));
538cdf0e10cSrcweir 	mpPage3SpeedLB->SetDropDownLineCount( 3 );
539cdf0e10cSrcweir 	mpPage3SpeedLB->SetSelectHdl( LINK(this,AssistentDlgImpl,SelectEffectHdl ));
540cdf0e10cSrcweir 	mpPage3SpeedLB->SelectEntryPos( 1 );
541cdf0e10cSrcweir 
542cdf0e10cSrcweir 	mpPage3PresTypeLiveRB->Check();
543cdf0e10cSrcweir 	mpPage3PresTypeLiveRB->SetClickHdl( LINK(this,AssistentDlgImpl, PresTypeHdl ));
544cdf0e10cSrcweir 	mpPage3PresTypeKioskRB->SetClickHdl( LINK(this,AssistentDlgImpl, PresTypeHdl ));
545cdf0e10cSrcweir 	mpPage3PresTimeTMF->SetFormat( TIMEF_SEC );
546cdf0e10cSrcweir 	mpPage3PresTimeTMF->SetTime( Time( 0, 0, 10 ) );
547cdf0e10cSrcweir 	mpPage3BreakTMF->SetFormat( TIMEF_SEC );
548cdf0e10cSrcweir 	mpPage3BreakTMF->SetTime( Time( 0, 0, 10 ) );
549cdf0e10cSrcweir 	mpPage3LogoCB->Check();
550cdf0e10cSrcweir 
551cdf0e10cSrcweir 	// set cursor in timefield
552cdf0e10cSrcweir 	Edit *pEditPage3PresTimeTMF = mpPage3PresTimeTMF->GetField();
553cdf0e10cSrcweir 	Edit *pEditPage3BreakTMF = mpPage3BreakTMF->GetField();
554cdf0e10cSrcweir 	Selection aSel1( pEditPage3PresTimeTMF->GetMaxTextLen(), pEditPage3PresTimeTMF->GetMaxTextLen() );
555cdf0e10cSrcweir 	Selection aSel2( pEditPage3BreakTMF->GetMaxTextLen(), pEditPage3BreakTMF->GetMaxTextLen() );
556cdf0e10cSrcweir 	pEditPage3PresTimeTMF->SetSelection( aSel1 );
557cdf0e10cSrcweir 	pEditPage3BreakTMF->SetSelection( aSel2 );
558cdf0e10cSrcweir 
559*87131587Smseidel 	// Page 4
560cdf0e10cSrcweir 	maAssistentFunc.InsertControl(4,
561cdf0e10cSrcweir 		mpPage4FB = new FixedBitmap(pWindow,SdResId(FB_PAGE4)));
562cdf0e10cSrcweir 	maAssistentFunc.InsertControl(4,
563cdf0e10cSrcweir 		mpPage4PersonalFL = new FixedLine( pWindow, SdResId(FL_PAGE4_PERSONAL) ));
564cdf0e10cSrcweir 	maAssistentFunc.InsertControl(4,
565cdf0e10cSrcweir 		mpPage4AskNameFT   = new FixedText( pWindow, SdResId(FT_PAGE4_ASKNAME) ));
566cdf0e10cSrcweir 	maAssistentFunc.InsertControl(4,
567cdf0e10cSrcweir 		mpPage4AskNameEDT  = new Edit( pWindow, SdResId(EDT_PAGE4_ASKNAME) ));
568cdf0e10cSrcweir 	maAssistentFunc.InsertControl(4,
569cdf0e10cSrcweir 		mpPage4AskTopicFT= new FixedText( pWindow, SdResId(FT_PAGE4_ASKTOPIC) ));
570cdf0e10cSrcweir 	maAssistentFunc.InsertControl(4,
571cdf0e10cSrcweir 		mpPage4AskTopicEDT = new Edit( pWindow, SdResId(EDT_PAGE4_ASKTOPIC) ));
572cdf0e10cSrcweir 	maAssistentFunc.InsertControl(4,
573cdf0e10cSrcweir 		mpPage4AskInfoFT   = new FixedText( pWindow, SdResId(FT_PAGE4_ASKINFORMATION) ));
574cdf0e10cSrcweir 	maAssistentFunc.InsertControl(4,
575cdf0e10cSrcweir 		mpPage4AskInfoEDT  = new MultiLineEdit( pWindow, SdResId(EDT_PAGE4_ASKINFORMATION) ));
576cdf0e10cSrcweir 
577cdf0e10cSrcweir 	mpPage4AskNameEDT->SetModifyHdl(LINK(this,AssistentDlgImpl,UpdateUserDataHdl));
578cdf0e10cSrcweir 	mpPage4AskTopicEDT->SetModifyHdl(LINK(this,AssistentDlgImpl,UpdateUserDataHdl));
579cdf0e10cSrcweir 	mpPage4AskInfoEDT->SetModifyHdl(LINK(this,AssistentDlgImpl,UpdateUserDataHdl));
580cdf0e10cSrcweir 
581*87131587Smseidel 	// Page 5
582cdf0e10cSrcweir 	maAssistentFunc.InsertControl(5, &maPreview );
583cdf0e10cSrcweir 	maAssistentFunc.InsertControl(5, &maPreviewFlag );
584cdf0e10cSrcweir 	maAssistentFunc.InsertControl(5,
585cdf0e10cSrcweir 		mpPage5FB = new FixedBitmap(pWindow,SdResId(FB_PAGE5)));
586cdf0e10cSrcweir 	maAssistentFunc.InsertControl(5,
587cdf0e10cSrcweir 		mpPage5PageListFT = new FixedText( pWindow, SdResId( FT_PAGE5_PAGELIST ) ));
588cdf0e10cSrcweir 	maAssistentFunc.InsertControl(5,
589cdf0e10cSrcweir 		mpPage5PageListCT = new SdPageListControl( pWindow, SdResId( CT_PAGE5_PAGELIST ) ));
590cdf0e10cSrcweir 	maAssistentFunc.InsertControl(5,
591cdf0e10cSrcweir 		mpPage5SummaryCB  = new CheckBox( pWindow, SdResId( CB_PAGE5_SUMMARY ) ));
592cdf0e10cSrcweir 
593cdf0e10cSrcweir 	mpPage5PageListCT->SetSelectHdl(LINK(this,AssistentDlgImpl, PageSelectHdl));
594cdf0e10cSrcweir 
595cdf0e10cSrcweir 
596*87131587Smseidel 	// General
597*87131587Smseidel 	InterpolateFixedBitmap( mpPage1FB );
598*87131587Smseidel 	InterpolateFixedBitmap( mpPage2FB );
599*87131587Smseidel 	InterpolateFixedBitmap( mpPage3FB );
600*87131587Smseidel 	InterpolateFixedBitmap( mpPage4FB );
601*87131587Smseidel 	InterpolateFixedBitmap( mpPage5FB );
602cdf0e10cSrcweir 
603cdf0e10cSrcweir 	maLastPageButton.SetClickHdl(LINK(this,AssistentDlgImpl, LastPageHdl ));
604cdf0e10cSrcweir 	maNextPageButton.SetClickHdl(LINK(this,AssistentDlgImpl, NextPageHdl ));
605cdf0e10cSrcweir 
606cdf0e10cSrcweir 	maPreviewFlag.Check( mbPreview );
607cdf0e10cSrcweir 	maPreviewFlag.SetClickHdl(LINK(this, AssistentDlgImpl, PreviewFlagHdl ));
608cdf0e10cSrcweir 	maPreview.SetClickHdl(LINK(this,AssistentDlgImpl, EffectPreviewHdl ));
609cdf0e10cSrcweir 
610*87131587Smseidel 	// setzt die Ausgangsseite
611cdf0e10cSrcweir 	maAssistentFunc.GotoPage(1);
612cdf0e10cSrcweir 	maLastPageButton.Disable();
613cdf0e10cSrcweir 
614cdf0e10cSrcweir 	maPrevTimer.SetTimeout( 200 );
615cdf0e10cSrcweir 	maPrevTimer.SetTimeoutHdl( LINK( this, AssistentDlgImpl, UpdatePreviewHdl));
616cdf0e10cSrcweir 
617cdf0e10cSrcweir 	maEffectPrevTimer.SetTimeout( 50 );
618cdf0e10cSrcweir 	maEffectPrevTimer.SetTimeoutHdl( LINK( this, AssistentDlgImpl, EffectPreviewHdl ));
619cdf0e10cSrcweir 
620cdf0e10cSrcweir 	maUpdatePageListTimer.SetTimeout( 50 );
621cdf0e10cSrcweir 	maUpdatePageListTimer.SetTimeoutHdl( LINK( this, AssistentDlgImpl, UpdatePageListHdl));
622cdf0e10cSrcweir 
623cdf0e10cSrcweir 	SetStartType( ST_EMPTY );
624cdf0e10cSrcweir 
625cdf0e10cSrcweir 	ChangePage();
626cdf0e10cSrcweir 
627*87131587Smseidel 	mpWindowUpdater->RegisterWindow (&maPreview);
628cdf0e10cSrcweir 
629cdf0e10cSrcweir 	UpdatePreview( sal_True );
630cdf0e10cSrcweir 
631*87131587Smseidel 	// check whether we should start with a template document initially and preselect it
632cdf0e10cSrcweir 	const ::rtl::OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.PresentationDocument" ) );
633*87131587Smseidel 	String aStandardTemplate( SfxObjectFactory::GetStandardTemplate( aServiceName ) );
634*87131587Smseidel 	if( aStandardTemplate.Len() )
635*87131587Smseidel 	{
636*87131587Smseidel 		ProvideTemplates();
637*87131587Smseidel 
638*87131587Smseidel 		// find aStandardTemplate in maPresentList
639*87131587Smseidel 		TemplateDir*   pStandardTemplateDir = 0;
640*87131587Smseidel 		TemplateEntry* pStandardTemplateEntry = 0;
641*87131587Smseidel 
642*87131587Smseidel 		std::vector<TemplateDir*>::iterator	I;
643*87131587Smseidel 		for (I=maPresentList.begin(); I!=maPresentList.end(); I++)
644*87131587Smseidel 		{
645*87131587Smseidel 			TemplateDir* pDir = *I;
646*87131587Smseidel 			std::vector<TemplateEntry*>::iterator	J;
647cdf0e10cSrcweir 			for (J=pDir->maEntries.begin(); J!=pDir->maEntries.end(); J++)
648*87131587Smseidel 			{
649*87131587Smseidel 				TemplateEntry* pEntry = *J;
650*87131587Smseidel 				if(pEntry->msPath == aStandardTemplate)
651*87131587Smseidel 				{
652*87131587Smseidel 					pStandardTemplateDir = pDir;
653*87131587Smseidel 					pStandardTemplateEntry = pEntry;
654*87131587Smseidel 					break;
655*87131587Smseidel 				}
656*87131587Smseidel 			}
657*87131587Smseidel 			if(pStandardTemplateDir)
658*87131587Smseidel 				break;
659*87131587Smseidel 		}
660*87131587Smseidel 
661*87131587Smseidel 		// preselect template
662*87131587Smseidel 		if( pStandardTemplateDir && pStandardTemplateEntry )
663*87131587Smseidel 		{
664*87131587Smseidel 			mpPage1RegionLB->SelectEntry( pStandardTemplateDir->msRegion );
665*87131587Smseidel 			SelectTemplateRegion( pStandardTemplateDir->msRegion );
666*87131587Smseidel 			mpPage1TemplateLB->SelectEntry( pStandardTemplateEntry->msTitle );
667*87131587Smseidel 			SelectTemplateHdl(mpPage1TemplateLB);
668*87131587Smseidel 		}
669*87131587Smseidel 	}
670cdf0e10cSrcweir }
671cdf0e10cSrcweir 
672cdf0e10cSrcweir 
673cdf0e10cSrcweir 
674cdf0e10cSrcweir 
~AssistentDlgImpl()675cdf0e10cSrcweir AssistentDlgImpl::~AssistentDlgImpl()
676cdf0e10cSrcweir {
677cdf0e10cSrcweir 	CloseDocShell();
678cdf0e10cSrcweir 
679cdf0e10cSrcweir 	DeletePassords();
680cdf0e10cSrcweir 
681*87131587Smseidel 	// Delete the template file infos.
682cdf0e10cSrcweir 	std::vector<TemplateDir*>::iterator	I;
683cdf0e10cSrcweir 	std::vector<TemplateEntry*>::iterator	J;
684cdf0e10cSrcweir 	for (I=maPresentList.begin(); I!=maPresentList.end(); I++)
685cdf0e10cSrcweir 	{
686cdf0e10cSrcweir 		for (J=(*I)->maEntries.begin(); J!=(*I)->maEntries.end(); J++)
687cdf0e10cSrcweir 			delete (*J);
688cdf0e10cSrcweir 		delete (*I);
689cdf0e10cSrcweir 	}
690cdf0e10cSrcweir 
691*87131587Smseidel 	// Page 1
692cdf0e10cSrcweir 	delete mpPage1FB;
693cdf0e10cSrcweir 	delete mpPage1ArtFL;
694cdf0e10cSrcweir 	delete mpPage1EmptyRB;
695cdf0e10cSrcweir 	delete mpPage1TemplateRB;
696cdf0e10cSrcweir 	delete mpPage1TemplateLB;
697cdf0e10cSrcweir 	delete mpPage1RegionLB;
698cdf0e10cSrcweir 	delete mpPage1OpenRB;
699cdf0e10cSrcweir 	delete mpPage1OpenLB;
700*87131587Smseidel 	delete mpPage1OpenPB;
701cdf0e10cSrcweir 
702*87131587Smseidel 	// Page 2
703cdf0e10cSrcweir 	delete mpPage2FB;
704cdf0e10cSrcweir 	delete mpPage2LayoutFL;
705cdf0e10cSrcweir 	delete mpPage2RegionLB;
706cdf0e10cSrcweir 	delete mpPage2LayoutLB;
707cdf0e10cSrcweir 	delete mpPage2OutTypesFL;
708cdf0e10cSrcweir 	delete mpPage2Medium1RB;
709cdf0e10cSrcweir 	delete mpPage2Medium2RB;
710cdf0e10cSrcweir 	delete mpPage2Medium3RB;
711cdf0e10cSrcweir 	delete mpPage2Medium4RB;
712cdf0e10cSrcweir 	delete mpPage2Medium5RB;
713cdf0e10cSrcweir 
714*87131587Smseidel 	// Page 3
715cdf0e10cSrcweir 	delete mpPage3FB;
716cdf0e10cSrcweir 	delete mpPage3EffectFL;
717cdf0e10cSrcweir 	delete mpPage3EffectFT;
718cdf0e10cSrcweir 	delete mpPage3EffectLB;
719cdf0e10cSrcweir 	delete mpPage3SpeedFT;
720cdf0e10cSrcweir 	delete mpPage3SpeedLB;
721cdf0e10cSrcweir 	delete mpPage3PresTypeFL;
722cdf0e10cSrcweir 	delete mpPage3PresTypeLiveRB;
723cdf0e10cSrcweir 	delete mpPage3PresTypeKioskRB;
724cdf0e10cSrcweir 	delete mpPage3PresTimeFT;
725cdf0e10cSrcweir 	delete mpPage3PresTimeTMF;
726cdf0e10cSrcweir 	delete mpPage3BreakFT;
727cdf0e10cSrcweir 	delete mpPage3BreakTMF;
728cdf0e10cSrcweir 	delete mpPage3LogoCB;
729cdf0e10cSrcweir 
730*87131587Smseidel 	// Page 4
731cdf0e10cSrcweir 	delete mpPage4FB;
732cdf0e10cSrcweir 	delete mpPage4PersonalFL;
733cdf0e10cSrcweir 	delete mpPage4AskNameFT;
734cdf0e10cSrcweir 	delete mpPage4AskNameEDT;
735cdf0e10cSrcweir 	delete mpPage4AskTopicFT;
736cdf0e10cSrcweir 	delete mpPage4AskTopicEDT;
737cdf0e10cSrcweir 	delete mpPage4AskInfoFT;
738cdf0e10cSrcweir 	delete mpPage4AskInfoEDT;
739cdf0e10cSrcweir 
740*87131587Smseidel 	// Page 5
741cdf0e10cSrcweir 	delete mpPage5FB;
742cdf0e10cSrcweir 	delete mpPage5PageListFT;
743cdf0e10cSrcweir 	delete mpPage5PageListCT;
744cdf0e10cSrcweir 	delete mpPage5SummaryCB;
745cdf0e10cSrcweir 
746*87131587Smseidel 	// Delete the file history list.
747cdf0e10cSrcweir 	std::vector<String*>::iterator	I2;
748cdf0e10cSrcweir 	for (I2=maOpenFilesList.begin(); I2!=maOpenFilesList.end(); I2++)
749cdf0e10cSrcweir 		delete *I2;
750cdf0e10cSrcweir }
751cdf0e10cSrcweir 
CloseDocShell()752cdf0e10cSrcweir void AssistentDlgImpl::CloseDocShell()
753cdf0e10cSrcweir {
754cdf0e10cSrcweir 	if(xDocShell.Is())
755cdf0e10cSrcweir 	{
756cdf0e10cSrcweir 		//uno::Reference< lang::XComponent > xModel( xDocShell->GetModel(), uno::UNO_QUERY );
757cdf0e10cSrcweir 		uno::Reference< util::XCloseable > xCloseable( xDocShell->GetModel(), uno::UNO_QUERY );
758cdf0e10cSrcweir 		//if( xModel.is() )
759cdf0e10cSrcweir 		if( xCloseable.is() )
760cdf0e10cSrcweir 		{
761cdf0e10cSrcweir 			xCloseable->close( sal_True );
762cdf0e10cSrcweir 			xDocShell = NULL;
763cdf0e10cSrcweir 			//xModel->dispose();
764cdf0e10cSrcweir 		}
765cdf0e10cSrcweir 		else
766cdf0e10cSrcweir 		{
767cdf0e10cSrcweir 			xDocShell->DoClose();
768cdf0e10cSrcweir 			xDocShell = NULL;
769cdf0e10cSrcweir 		}
770cdf0e10cSrcweir 	}
771cdf0e10cSrcweir }
772cdf0e10cSrcweir 
EndDialog(long)773cdf0e10cSrcweir void AssistentDlgImpl::EndDialog( long )
774cdf0e10cSrcweir {
775cdf0e10cSrcweir 	mpWindow = NULL;
776cdf0e10cSrcweir }
777cdf0e10cSrcweir 
778cdf0e10cSrcweir 
779cdf0e10cSrcweir 
780cdf0e10cSrcweir 
ScanDocmenu(void)781cdf0e10cSrcweir void	AssistentDlgImpl::ScanDocmenu	(void)
782cdf0e10cSrcweir {
783*87131587Smseidel 	if( mbRecentDocumentsReady )
784*87131587Smseidel 		return;
785cdf0e10cSrcweir 
786cdf0e10cSrcweir 	uno::Sequence<uno::Sequence<beans::PropertyValue> > aHistory =
787cdf0e10cSrcweir 		SvtHistoryOptions().GetList (ePICKLIST);
788cdf0e10cSrcweir 
789*87131587Smseidel 	uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
790*87131587Smseidel 	uno::Reference< container::XNameAccess > xFilterFactory( xFactory->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.FilterFactory" ) ) ), uno::UNO_QUERY );
791cdf0e10cSrcweir 
792*87131587Smseidel 	Reference< ::com::sun::star::ucb::XSimpleFileAccess > xFileAccess(
793*87131587Smseidel 		xFactory->createInstance(
794*87131587Smseidel 			::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess"))),
795*87131587Smseidel 		UNO_QUERY_THROW);
796cdf0e10cSrcweir 
797cdf0e10cSrcweir 	sal_uInt32 nCount = aHistory.getLength();
798cdf0e10cSrcweir 	for (sal_uInt32 nItem=0; nItem<nCount; ++nItem)
799cdf0e10cSrcweir 	{
800*87131587Smseidel 		// Get the current history item's properties.
801cdf0e10cSrcweir 		uno::Sequence<beans::PropertyValue> aPropertySet = aHistory[nItem];
802cdf0e10cSrcweir 		rtl::OUString	sURL;
803cdf0e10cSrcweir 		rtl::OUString	sFilter;
804cdf0e10cSrcweir 		rtl::OUString	sTitle;
805cdf0e10cSrcweir 		rtl::OUString	sPassword;
806cdf0e10cSrcweir 		sal_uInt32 nPropertyCount = aPropertySet.getLength();
807cdf0e10cSrcweir 		for (sal_uInt32 nProperty=0; nProperty<nPropertyCount; ++nProperty)
808cdf0e10cSrcweir 			if (aPropertySet[nProperty].Name == HISTORY_PROPERTYNAME_URL)
809cdf0e10cSrcweir 				aPropertySet[nProperty].Value >>= sURL;
810cdf0e10cSrcweir 			else if (aPropertySet[nProperty].Name == HISTORY_PROPERTYNAME_FILTER)
811cdf0e10cSrcweir 				aPropertySet[nProperty].Value >>= sFilter;
812cdf0e10cSrcweir 			else if (aPropertySet[nProperty].Name == HISTORY_PROPERTYNAME_TITLE)
813cdf0e10cSrcweir 				aPropertySet[nProperty].Value >>= sTitle;
814cdf0e10cSrcweir 			else if (aPropertySet[nProperty].Name == HISTORY_PROPERTYNAME_PASSWORD)
815cdf0e10cSrcweir 				aPropertySet[nProperty].Value >>= sPassword;
816cdf0e10cSrcweir 
817*87131587Smseidel 		// If the entry is an Impress file then insert it into the
818*87131587Smseidel 		// history list and the list box.
819*87131587Smseidel 		uno::Sequence< beans::PropertyValue > lProps;
820*87131587Smseidel 		if (xFilterFactory->hasByName(sFilter))
821*87131587Smseidel 		{
822*87131587Smseidel 			uno::Any aFilterPropSet = xFilterFactory->getByName( sFilter );
823*87131587Smseidel 			aFilterPropSet >>= lProps;
824*87131587Smseidel 		}
825*87131587Smseidel 
826*87131587Smseidel 		sal_Int32 nPropCount = lProps.getLength();
827*87131587Smseidel 		rtl::OUString sFactoryName;
828*87131587Smseidel 		for( sal_Int32 i=0; i<nPropCount; ++i )
829*87131587Smseidel 		{
830*87131587Smseidel 			if( lProps[i].Name.compareToAscii( "DocumentService" ) == 0 &&
831*87131587Smseidel 				(lProps[i].Value >>= sFactoryName) &&
832*87131587Smseidel 				sFactoryName.compareToAscii( "com.sun.star.presentation.PresentationDocument" ) == 0 )
833*87131587Smseidel 			{
834*87131587Smseidel 				// yes, it's an Impress document
835*87131587Smseidel 				INetURLObject aURL;
836*87131587Smseidel 
837*87131587Smseidel 				// Do not include the file if it does not exist.
838*87131587Smseidel 				if (xFileAccess.is() && ! xFileAccess->exists(sURL))
839*87131587Smseidel 					continue;
840*87131587Smseidel 
841*87131587Smseidel 				aURL.SetSmartURL (sURL);
842*87131587Smseidel 				// The password is set only when it is not empty.
843*87131587Smseidel 				if (sPassword.getLength() > 0)
844*87131587Smseidel 					aURL.SetPass (sPassword);
845*87131587Smseidel 				maOpenFilesList.push_back (new String (aURL.GetMainURL( INetURLObject::NO_DECODE )));
846*87131587Smseidel 				mpPage1OpenLB->InsertEntry (sTitle);
847*87131587Smseidel 				break;
848*87131587Smseidel 			}
849cdf0e10cSrcweir 		}
850cdf0e10cSrcweir 	}
851*87131587Smseidel 	mbRecentDocumentsReady = sal_True;
852*87131587Smseidel 	try
853*87131587Smseidel 	{
854*87131587Smseidel 		UpdatePreview(sal_True);
855*87131587Smseidel 	}
856*87131587Smseidel 	catch (uno::RuntimeException& )
857*87131587Smseidel 	{
858*87131587Smseidel 		// Ignore all exceptions.
859*87131587Smseidel 	}
860cdf0e10cSrcweir }
861cdf0e10cSrcweir 
862cdf0e10cSrcweir 
863cdf0e10cSrcweir 
ProvideTemplates(void)864cdf0e10cSrcweir void AssistentDlgImpl::ProvideTemplates (void)
865cdf0e10cSrcweir {
866*87131587Smseidel 	if ( ! mbTemplatesReady)
867*87131587Smseidel 	{
868*87131587Smseidel 		TemplateScanner aScanner;
869*87131587Smseidel 		aScanner.Scan ();
870*87131587Smseidel 		TemplateScanDone (aScanner.GetFolderList());
871*87131587Smseidel 
872*87131587Smseidel 		try
873*87131587Smseidel 		{
874*87131587Smseidel 			UpdatePreview(sal_True);
875*87131587Smseidel 		}
876*87131587Smseidel 		catch (uno::RuntimeException& e)
877*87131587Smseidel 		{
878*87131587Smseidel 			// Ignore all exceptions.
879*87131587Smseidel 			(void) e;
880*87131587Smseidel 		}
881*87131587Smseidel 	}
882cdf0e10cSrcweir }
883cdf0e10cSrcweir 
TemplateScanDone(std::vector<TemplateDir * > & rTemplateFolder)884cdf0e10cSrcweir void AssistentDlgImpl::TemplateScanDone (
885*87131587Smseidel 	std::vector<TemplateDir*>& rTemplateFolder)
886cdf0e10cSrcweir {
887*87131587Smseidel 	// This method is called from a thread. Therefore we get the solar mutex.
888cdf0e10cSrcweir 	::vos::OGuard aGuard (Application::GetSolarMutex());
889cdf0e10cSrcweir 
890*87131587Smseidel 	// Copy the contents of the given template folders to a local list.
891*87131587Smseidel 	maPresentList.swap (rTemplateFolder);
892cdf0e10cSrcweir 
893*87131587Smseidel 	// Fill in the list box on the first page.
894cdf0e10cSrcweir 	int nFirstEntry = 0;
895cdf0e10cSrcweir 	mpPage1RegionLB->Clear();
896cdf0e10cSrcweir 	std::vector<TemplateDir*>::iterator	I;
897cdf0e10cSrcweir 	int	i;
898cdf0e10cSrcweir 	for (i=0,I=maPresentList.begin(); I!=maPresentList.end(); I++,i++)
899cdf0e10cSrcweir 	{
900cdf0e10cSrcweir 		TemplateDir* pDir = *I;
901*87131587Smseidel 		if (pDir == NULL)
902*87131587Smseidel 			continue;
903*87131587Smseidel 
904*87131587Smseidel 		// HACK! present directory is always initially selected.
905*87131587Smseidel 		// We have to look at the first entry to get a URL.
906*87131587Smseidel 		if (!pDir->maEntries.empty() )
907*87131587Smseidel 		{
908*87131587Smseidel 			TemplateEntry* pEntry = pDir->maEntries.front();
909*87131587Smseidel 			if (pEntry != NULL)
910*87131587Smseidel 				if (pEntry->msPath.SearchAscii("presnt") != STRING_NOTFOUND)
911*87131587Smseidel 					nFirstEntry = i;
912*87131587Smseidel 		}
913cdf0e10cSrcweir 
914cdf0e10cSrcweir 		mpPage1RegionLB->InsertEntry (pDir->msRegion);
915cdf0e10cSrcweir 	}
916cdf0e10cSrcweir 	mpPage1RegionLB->SelectEntryPos ((sal_uInt16)nFirstEntry);
917cdf0e10cSrcweir 	mpPage1RegionLB->Update();
918cdf0e10cSrcweir 	SelectTemplateRegion (mpPage1RegionLB->GetSelectEntry());
919cdf0e10cSrcweir 
920*87131587Smseidel 	// Fill in the list box on the second page.
921cdf0e10cSrcweir 	nFirstEntry = 0;
922cdf0e10cSrcweir 	mpPage2RegionLB->Clear();
923cdf0e10cSrcweir 	for (i=0,I=maPresentList.begin(); I!=maPresentList.end(); I++,i++)
924cdf0e10cSrcweir 	{
925cdf0e10cSrcweir 		TemplateDir* pDir = *I;
926*87131587Smseidel 		if (pDir == NULL)
927*87131587Smseidel 			continue;
928cdf0e10cSrcweir 
929cdf0e10cSrcweir 		// HACK! layout directory is always initially selected.
930*87131587Smseidel 		// We have to look at the first entry to get a URL.
931*87131587Smseidel 		if (!pDir->maEntries.empty() )
932*87131587Smseidel 		{
933*87131587Smseidel 			TemplateEntry* pEntry = pDir->maEntries.front();
934*87131587Smseidel 			if (pEntry != NULL)
935*87131587Smseidel 				if (pEntry->msPath.SearchAscii("layout") != STRING_NOTFOUND)
936*87131587Smseidel 					nFirstEntry = i;
937*87131587Smseidel 		}
938cdf0e10cSrcweir 
939cdf0e10cSrcweir 		mpPage2RegionLB->InsertEntry (pDir->msRegion);
940cdf0e10cSrcweir 	}
941cdf0e10cSrcweir 	mpPage2RegionLB->SelectEntryPos ((sal_uInt16)nFirstEntry);
942cdf0e10cSrcweir 	mpPage2RegionLB->Update();
943cdf0e10cSrcweir 	SelectLayoutRegion (mpPage2RegionLB->GetSelectEntry());
944cdf0e10cSrcweir 
945*87131587Smseidel 	// Make the changes visible.
946cdf0e10cSrcweir 	mbTemplatesReady = sal_True;
947cdf0e10cSrcweir 	if (mpWindow)
948cdf0e10cSrcweir 		UpdatePage();
949cdf0e10cSrcweir }
950cdf0e10cSrcweir 
951cdf0e10cSrcweir 
952cdf0e10cSrcweir 
953cdf0e10cSrcweir 
954cdf0e10cSrcweir // ********************************************************************
955*87131587Smseidel // Status methods
956cdf0e10cSrcweir // ********************************************************************
957cdf0e10cSrcweir 
SetStartType(StartType eType)958cdf0e10cSrcweir void AssistentDlgImpl::SetStartType( StartType eType )
959cdf0e10cSrcweir {
960cdf0e10cSrcweir 	mpPage1EmptyRB->SetState( eType == ST_EMPTY );
961cdf0e10cSrcweir 	mpPage1TemplateRB->SetState( eType == ST_TEMPLATE );
962cdf0e10cSrcweir 	mpPage1OpenRB->SetState( eType == ST_OPEN );
963cdf0e10cSrcweir 	maNextPageButton.Enable( eType != ST_OPEN );
964cdf0e10cSrcweir 
965cdf0e10cSrcweir 	mpPage1RegionLB->Show(eType == ST_TEMPLATE);
966cdf0e10cSrcweir 	mpPage1TemplateLB->Show(eType == ST_TEMPLATE);
967cdf0e10cSrcweir 	mpPage1OpenLB->Show(eType == ST_OPEN);
968cdf0e10cSrcweir 	mpPage1OpenPB->Show(eType == ST_OPEN);
969cdf0e10cSrcweir 
970cdf0e10cSrcweir 	if (eType == ST_OPEN)
971cdf0e10cSrcweir 		maFinishButton.SetText(maOpenStr);
972cdf0e10cSrcweir 	else
973cdf0e10cSrcweir 		maFinishButton.SetText(maCreateStr);
974cdf0e10cSrcweir }
975cdf0e10cSrcweir 
GetStartType()976cdf0e10cSrcweir StartType AssistentDlgImpl::GetStartType()
977cdf0e10cSrcweir {
978cdf0e10cSrcweir 	if( mpPage1EmptyRB->IsChecked() )
979cdf0e10cSrcweir 		return ST_EMPTY;
980cdf0e10cSrcweir 	else if( mpPage1TemplateRB->IsChecked() )
981cdf0e10cSrcweir 		return ST_TEMPLATE;
982cdf0e10cSrcweir 	else
983cdf0e10cSrcweir 		return ST_OPEN;
984cdf0e10cSrcweir }
985cdf0e10cSrcweir 
GetDocFileName()986cdf0e10cSrcweir String AssistentDlgImpl::GetDocFileName()
987cdf0e10cSrcweir {
988cdf0e10cSrcweir 	String aTitle;
989cdf0e10cSrcweir 	if(mpWindow)
990cdf0e10cSrcweir 	{
991cdf0e10cSrcweir 		aTitle = mpWindow->GetText();
992cdf0e10cSrcweir 		sal_uInt16 nPos = aTitle.Search(sal_Unicode('('));
993cdf0e10cSrcweir 		if(nPos != STRING_NOTFOUND)
994cdf0e10cSrcweir 			aTitle.Erase( nPos-1 );
995cdf0e10cSrcweir 	}
996cdf0e10cSrcweir 
997cdf0e10cSrcweir 	String aDocFile;
998cdf0e10cSrcweir 	if( GetStartType() == ST_TEMPLATE )
999cdf0e10cSrcweir 	{
1000cdf0e10cSrcweir 		const sal_uInt16 nEntry = mpPage1TemplateLB->GetSelectEntryPos();
1001cdf0e10cSrcweir 		TemplateEntry* pEntry = NULL;
1002cdf0e10cSrcweir 		if(nEntry != (sal_uInt16)-1)
1003cdf0e10cSrcweir 			pEntry = mpTemplateRegion->maEntries[nEntry];
1004cdf0e10cSrcweir 
1005cdf0e10cSrcweir 		if(pEntry)
1006cdf0e10cSrcweir 		{
1007cdf0e10cSrcweir 			aDocFile = pEntry->msPath;
1008cdf0e10cSrcweir 
1009cdf0e10cSrcweir 			aTitle.AppendAscii( RTL_CONSTASCII_STRINGPARAM(  " (" ) );
1010cdf0e10cSrcweir 			aTitle.Append( pEntry->msTitle );
1011cdf0e10cSrcweir 			aTitle.Append( sal_Unicode(')') );
1012cdf0e10cSrcweir 		}
1013cdf0e10cSrcweir 	}
1014cdf0e10cSrcweir 	else if( GetStartType() == ST_OPEN )
1015cdf0e10cSrcweir 	{
1016cdf0e10cSrcweir 		const sal_uInt16 nEntry = mpPage1OpenLB->GetSelectEntryPos();
1017cdf0e10cSrcweir 		if(nEntry != (sal_uInt16)-1 )
1018cdf0e10cSrcweir 			aDocFile = *maOpenFilesList[nEntry];
1019cdf0e10cSrcweir 	}
1020cdf0e10cSrcweir 
1021cdf0e10cSrcweir 	if(mpWindow)
1022cdf0e10cSrcweir 		mpWindow->SetText(aTitle);
1023cdf0e10cSrcweir 
1024cdf0e10cSrcweir 	return aDocFile;
1025cdf0e10cSrcweir }
1026cdf0e10cSrcweir 
GetLayoutFileName()1027cdf0e10cSrcweir String AssistentDlgImpl::GetLayoutFileName()
1028cdf0e10cSrcweir {
1029cdf0e10cSrcweir 	String aFile;
1030cdf0e10cSrcweir 	const sal_uInt16 nEntry = mpPage2LayoutLB->GetSelectEntryPos();
1031cdf0e10cSrcweir 	TemplateEntry* pEntry = NULL;
1032cdf0e10cSrcweir 	if(nEntry != (sal_uInt16)-1 && nEntry > 0)
1033cdf0e10cSrcweir 		pEntry = mpLayoutRegion->maEntries[nEntry-1];
1034cdf0e10cSrcweir 
1035cdf0e10cSrcweir 	if(pEntry)
1036cdf0e10cSrcweir 		aFile = pEntry->msPath;
1037cdf0e10cSrcweir 
1038cdf0e10cSrcweir 	return aFile;
1039cdf0e10cSrcweir }
1040cdf0e10cSrcweir 
GetDocument()1041cdf0e10cSrcweir SfxObjectShellLock AssistentDlgImpl::GetDocument()
1042cdf0e10cSrcweir {
1043*87131587Smseidel // mbPreview = sal_False; // Document nicht anzeigen
1044*87131587Smseidel 	UpdatePreview(sal_False); // aber komplett laden
1045cdf0e10cSrcweir 	UpdatePageList();
1046cdf0e10cSrcweir 
1047cdf0e10cSrcweir 	SfxObjectShell* pShell = xDocShell;
1048cdf0e10cSrcweir 	::sd::DrawDocShell* pDocShell = PTR_CAST(::sd::DrawDocShell,pShell);
1049cdf0e10cSrcweir 	SdDrawDocument* pDoc = pDocShell?pDocShell->GetDoc():NULL;
1050cdf0e10cSrcweir 
1051cdf0e10cSrcweir 	if(pDoc)
1052cdf0e10cSrcweir 	{
1053cdf0e10cSrcweir 		const sal_uInt16 nPageCount = pDoc->GetSdPageCount(PK_STANDARD);
1054cdf0e10cSrcweir 		sal_Bool bKiosk = mpPage3PresTypeKioskRB->IsChecked();
1055cdf0e10cSrcweir 		sal_uInt32 nNewTime = (sal_uInt32)mpPage3PresTimeTMF->GetTime().GetMSFromTime() / 1000;
1056cdf0e10cSrcweir 		if(bKiosk)
1057cdf0e10cSrcweir 		{
1058cdf0e10cSrcweir 			PresentationSettings& rSettings = pDoc->getPresentationSettings();
1059cdf0e10cSrcweir 			rSettings.mbEndless = bKiosk;
1060cdf0e10cSrcweir 			rSettings.mnPauseTimeout = (sal_Int32)mpPage3BreakTMF->GetTime().GetMSFromTime() / 1000;
1061cdf0e10cSrcweir 			rSettings.mbShowPauseLogo = mpPage3LogoCB->IsChecked();
1062cdf0e10cSrcweir 		}
1063cdf0e10cSrcweir 
1064cdf0e10cSrcweir 		sal_uInt16 nPgAbsNum = 0;
1065cdf0e10cSrcweir 		sal_uInt16 nPgRelNum = 0;
1066cdf0e10cSrcweir 		while( nPgAbsNum < nPageCount )
1067cdf0e10cSrcweir 		{
1068cdf0e10cSrcweir 			SdPage* pPage = pDoc->GetSdPage( nPgRelNum, PK_STANDARD );
1069cdf0e10cSrcweir 			if( mpPage5PageListCT->IsPageChecked(nPgAbsNum) )
1070cdf0e10cSrcweir 			{
1071cdf0e10cSrcweir 				mpPage3EffectLB->applySelected(pPage);
1072cdf0e10cSrcweir 				const sal_uInt16 nPos = mpPage3SpeedLB->GetSelectEntryPos();
1073*87131587Smseidel 				pPage->setTransitionDuration( (nPos == 0) ? 3.0 : (nPos == 1) ? 2.0 : 1.0 );
1074cdf0e10cSrcweir 				if(bKiosk)
1075cdf0e10cSrcweir 				{
1076cdf0e10cSrcweir 					pPage->SetPresChange( PRESCHANGE_AUTO );
1077cdf0e10cSrcweir 					pPage->SetTime(nNewTime);
1078cdf0e10cSrcweir 				}
1079cdf0e10cSrcweir 				nPgRelNum++;
1080cdf0e10cSrcweir 			}
1081cdf0e10cSrcweir 			else
1082cdf0e10cSrcweir 			{
1083*87131587Smseidel 				// delete this page
1084*87131587Smseidel 				pDoc->DeletePage( (nPgRelNum << 1) + 2 ); // NotizPage loeschen
1085*87131587Smseidel 				pDoc->DeletePage( (nPgRelNum << 1) + 1 ); // delete page
1086cdf0e10cSrcweir 			}
1087cdf0e10cSrcweir 
1088cdf0e10cSrcweir 			nPgAbsNum++;
1089cdf0e10cSrcweir 		}
1090cdf0e10cSrcweir 	}
1091cdf0e10cSrcweir 	else
1092cdf0e10cSrcweir 	{
1093cdf0e10cSrcweir 		DBG_ERROR("sd::AssistentDlgImpl::GetDocument(), no template?");
1094cdf0e10cSrcweir 	}
1095cdf0e10cSrcweir 
1096cdf0e10cSrcweir 	SfxObjectShellLock xRet = xDocShell;
1097cdf0e10cSrcweir 	xDocShell = NULL;
1098cdf0e10cSrcweir 
1099cdf0e10cSrcweir 	return xRet;
1100cdf0e10cSrcweir }
1101cdf0e10cSrcweir 
LeavePage()1102cdf0e10cSrcweir void AssistentDlgImpl::LeavePage()
1103cdf0e10cSrcweir {
1104cdf0e10cSrcweir 	int nPage = maAssistentFunc.GetCurrentPage();
1105cdf0e10cSrcweir 
1106cdf0e10cSrcweir 	if( nPage == 4 && mbUserDataDirty )
1107cdf0e10cSrcweir 		maPrevTimer.Start();
1108cdf0e10cSrcweir }
1109cdf0e10cSrcweir 
ChangePage()1110cdf0e10cSrcweir void AssistentDlgImpl::ChangePage()
1111cdf0e10cSrcweir {
1112cdf0e10cSrcweir 	maNextPageButton.Enable(!maAssistentFunc.IsLastPage());
1113cdf0e10cSrcweir 	maLastPageButton.Enable(!maAssistentFunc.IsFirstPage());
1114cdf0e10cSrcweir 
1115cdf0e10cSrcweir 	sal_uInt16 nPage = (sal_uInt16)maAssistentFunc.GetCurrentPage();
1116cdf0e10cSrcweir 
1117cdf0e10cSrcweir 	if( mpWindow )
1118cdf0e10cSrcweir 	{
1119cdf0e10cSrcweir 		mpWindow->SetHelpId( PageHelpIds[nPage-1]);
1120cdf0e10cSrcweir 	}
1121cdf0e10cSrcweir 
1122cdf0e10cSrcweir 	UpdatePage();
1123cdf0e10cSrcweir 
1124cdf0e10cSrcweir 	if( maNextPageButton.IsEnabled() )
1125cdf0e10cSrcweir 	{
1126*87131587Smseidel 		maNextPageButton.ForceFocusEventBroadcast();
1127cdf0e10cSrcweir 	}
1128cdf0e10cSrcweir 	else
1129cdf0e10cSrcweir 		maFinishButton.GrabFocus();
1130cdf0e10cSrcweir }
1131cdf0e10cSrcweir 
UpdatePage()1132cdf0e10cSrcweir void AssistentDlgImpl::UpdatePage()
1133cdf0e10cSrcweir {
1134cdf0e10cSrcweir 	sal_uInt16 nPage = (sal_uInt16)maAssistentFunc.GetCurrentPage();
1135cdf0e10cSrcweir 
1136cdf0e10cSrcweir 	switch(nPage)
1137cdf0e10cSrcweir 	{
1138cdf0e10cSrcweir 	case 1:
1139cdf0e10cSrcweir 		{
1140*87131587Smseidel 			// Elemente auf der ersten Page abhaengig vom Starttype zeigen
1141cdf0e10cSrcweir 			SetStartType( GetStartType() );
1142cdf0e10cSrcweir 			mpPage1TemplateRB->Enable(sal_True /*mbTemplatesReady*/);
1143cdf0e10cSrcweir 			break;
1144cdf0e10cSrcweir 		}
1145cdf0e10cSrcweir 
1146cdf0e10cSrcweir 	case 2:
1147cdf0e10cSrcweir 		{
1148cdf0e10cSrcweir 			mpPage2RegionLB->Enable(mbTemplatesReady);
1149cdf0e10cSrcweir 			mpPage2LayoutLB->Enable(mbTemplatesReady);
1150cdf0e10cSrcweir 
1151cdf0e10cSrcweir 			if( GetStartType() != ST_EMPTY )
1152cdf0e10cSrcweir 			{
1153cdf0e10cSrcweir 				mpPage2Medium5RB->Enable( sal_True );
1154cdf0e10cSrcweir 			}
1155cdf0e10cSrcweir 			else
1156cdf0e10cSrcweir 			{
1157cdf0e10cSrcweir 				mpPage2Medium5RB->Enable( sal_False );
1158cdf0e10cSrcweir 				if(mpPage2Medium5RB->IsChecked())
1159cdf0e10cSrcweir 					mpPage2Medium1RB->Check();
1160cdf0e10cSrcweir 			}
1161cdf0e10cSrcweir 
1162cdf0e10cSrcweir 			break;
1163cdf0e10cSrcweir 		}
1164cdf0e10cSrcweir 	case 5:
1165cdf0e10cSrcweir 		{
1166cdf0e10cSrcweir 			if(mbDocPreview || maPageListFile != maDocFile)
1167cdf0e10cSrcweir 				mpPage5PageListCT->Clear();
1168cdf0e10cSrcweir 
1169cdf0e10cSrcweir 			maUpdatePageListTimer.Start();
1170cdf0e10cSrcweir 			break;
1171cdf0e10cSrcweir 		}
1172cdf0e10cSrcweir 
1173cdf0e10cSrcweir 	case 3:
1174cdf0e10cSrcweir 		{
1175cdf0e10cSrcweir 			if(GetStartType() != ST_TEMPLATE)
1176cdf0e10cSrcweir 				maNextPageButton.Enable(false);
1177cdf0e10cSrcweir 
1178cdf0e10cSrcweir 			sal_Bool bKiosk = mpPage3PresTypeKioskRB->IsChecked();
1179cdf0e10cSrcweir 			mpPage3PresTimeFT->Enable(bKiosk);
1180cdf0e10cSrcweir 			mpPage3BreakFT->Enable(bKiosk);
1181cdf0e10cSrcweir 			mpPage3PresTimeTMF->Enable(bKiosk);
1182cdf0e10cSrcweir 			mpPage3BreakTMF->Enable(bKiosk);
1183cdf0e10cSrcweir 			mpPage3LogoCB->Enable(bKiosk);
1184cdf0e10cSrcweir 			break;
1185cdf0e10cSrcweir 		}
1186cdf0e10cSrcweir 	}
1187cdf0e10cSrcweir }
1188cdf0e10cSrcweir 
1189cdf0e10cSrcweir // ********************************************************************
1190cdf0e10cSrcweir // UI-Handler
1191cdf0e10cSrcweir // ********************************************************************
1192cdf0e10cSrcweir 
IMPL_LINK(AssistentDlgImpl,SelectRegionHdl,ListBox *,pLB)1193cdf0e10cSrcweir IMPL_LINK( AssistentDlgImpl, SelectRegionHdl, ListBox *, pLB )
1194cdf0e10cSrcweir {
1195cdf0e10cSrcweir 	if( pLB == mpPage1RegionLB )
1196cdf0e10cSrcweir 	{
1197cdf0e10cSrcweir 		SelectTemplateRegion( pLB->GetSelectEntry() );
1198cdf0e10cSrcweir 		SetStartType( ST_TEMPLATE );
1199cdf0e10cSrcweir 		mpPage2Medium5RB->Check();
1200cdf0e10cSrcweir 	}
1201cdf0e10cSrcweir 	else
1202cdf0e10cSrcweir 	{
1203cdf0e10cSrcweir 		SelectLayoutRegion( pLB->GetSelectEntry() );
1204cdf0e10cSrcweir 	}
1205cdf0e10cSrcweir 
1206cdf0e10cSrcweir 	return 0;
1207cdf0e10cSrcweir }
1208cdf0e10cSrcweir 
IMPL_LINK(AssistentDlgImpl,SelectEffectHdl,void *,EMPTYARG)1209cdf0e10cSrcweir IMPL_LINK( AssistentDlgImpl, SelectEffectHdl, void*, EMPTYARG )
1210cdf0e10cSrcweir {
1211cdf0e10cSrcweir 	maEffectPrevTimer.Start();
1212cdf0e10cSrcweir 	return 0;
1213cdf0e10cSrcweir }
1214cdf0e10cSrcweir 
IMPL_LINK(AssistentDlgImpl,OpenButtonHdl,Button *,pButton)1215cdf0e10cSrcweir IMPL_LINK( AssistentDlgImpl, OpenButtonHdl, Button*, pButton )
1216cdf0e10cSrcweir {
1217*87131587Smseidel 	// Clear the selection and forward the call.
1218*87131587Smseidel 	mpPage1OpenLB->SetNoSelection();
1219*87131587Smseidel 	return mpPage1OpenLB->GetDoubleClickHdl().Call(pButton);
1220cdf0e10cSrcweir }
1221cdf0e10cSrcweir 
IMPL_LINK(AssistentDlgImpl,EffectPreviewHdl,Button *,EMPTYARG)1222cdf0e10cSrcweir IMPL_LINK( AssistentDlgImpl, EffectPreviewHdl, Button *, EMPTYARG )
1223cdf0e10cSrcweir {
1224cdf0e10cSrcweir 	if(mbPreview && xDocShell.Is() )
1225cdf0e10cSrcweir 	{
1226cdf0e10cSrcweir 		SfxObjectShell* pShell = xDocShell;
1227cdf0e10cSrcweir 		DrawDocShell* pDocShell = dynamic_cast< DrawDocShell * >(pShell);
1228cdf0e10cSrcweir 		if( pDocShell )
1229cdf0e10cSrcweir 		{
1230cdf0e10cSrcweir 			SdDrawDocument* pDoc = pDocShell->GetDoc();
1231cdf0e10cSrcweir 			if( pDoc )
1232cdf0e10cSrcweir 			{
1233cdf0e10cSrcweir 				SdPage* pPage = pDoc->GetSdPage( mnShowPage, PK_STANDARD );
1234cdf0e10cSrcweir 				if( pPage )
1235cdf0e10cSrcweir 					mpPage3EffectLB->applySelected(pPage);
1236cdf0e10cSrcweir 			}
1237cdf0e10cSrcweir 		}
1238cdf0e10cSrcweir 		maPreview.startPreview();
1239cdf0e10cSrcweir 	}
1240cdf0e10cSrcweir 	return 0;
1241cdf0e10cSrcweir }
1242cdf0e10cSrcweir 
IMPL_LINK(AssistentDlgImpl,PreviewFlagHdl,CheckBox *,EMPTYARG)1243cdf0e10cSrcweir IMPL_LINK( AssistentDlgImpl, PreviewFlagHdl, CheckBox *, EMPTYARG )
1244cdf0e10cSrcweir 
1245cdf0e10cSrcweir {
1246cdf0e10cSrcweir 	if( maPreviewFlag.IsChecked() != mbPreview )
1247cdf0e10cSrcweir 	{
1248cdf0e10cSrcweir 		mbPreview = maPreviewFlag.IsChecked();
1249cdf0e10cSrcweir 		UpdatePreview(sal_True);
1250cdf0e10cSrcweir 	}
1251cdf0e10cSrcweir 	return 0;
1252cdf0e10cSrcweir }
1253cdf0e10cSrcweir 
IMPL_LINK(AssistentDlgImpl,SelectTemplateHdl,ListBox *,EMPTYARG)1254cdf0e10cSrcweir IMPL_LINK( AssistentDlgImpl, SelectTemplateHdl, ListBox *, EMPTYARG )
1255cdf0e10cSrcweir {
1256cdf0e10cSrcweir 	SetStartType( ST_TEMPLATE );
1257cdf0e10cSrcweir 	mpPage2Medium5RB->Check();
1258cdf0e10cSrcweir 	mpPage2LayoutLB->SelectEntryPos(0);
1259cdf0e10cSrcweir 	maPrevTimer.Start();
1260cdf0e10cSrcweir 	return 0;
1261cdf0e10cSrcweir }
1262cdf0e10cSrcweir 
IMPL_LINK(AssistentDlgImpl,SelectLayoutHdl,ListBox *,EMPTYARG)1263cdf0e10cSrcweir IMPL_LINK( AssistentDlgImpl, SelectLayoutHdl, ListBox *, EMPTYARG )
1264cdf0e10cSrcweir {
1265cdf0e10cSrcweir 	maPrevTimer.Start();
1266cdf0e10cSrcweir 	return 0;
1267cdf0e10cSrcweir }
1268cdf0e10cSrcweir 
IMPL_LINK(AssistentDlgImpl,SelectFileHdl,ListBox *,EMPTYARG)1269cdf0e10cSrcweir IMPL_LINK( AssistentDlgImpl, SelectFileHdl, ListBox *, EMPTYARG )
1270cdf0e10cSrcweir {
1271cdf0e10cSrcweir 	SetStartType( ST_OPEN );
1272cdf0e10cSrcweir 	maPrevTimer.Start();
1273cdf0e10cSrcweir 	return 0;
1274cdf0e10cSrcweir }
1275cdf0e10cSrcweir 
IMPL_LINK(AssistentDlgImpl,PageSelectHdl,Control *,EMPTYARG)1276cdf0e10cSrcweir IMPL_LINK( AssistentDlgImpl, PageSelectHdl, Control *, EMPTYARG )
1277cdf0e10cSrcweir {
1278cdf0e10cSrcweir 	sal_uInt16 nPage = mpPage5PageListCT->GetSelectedPage();
1279cdf0e10cSrcweir 	if( mnShowPage != nPage )
1280cdf0e10cSrcweir 	{
1281cdf0e10cSrcweir 		mnShowPage = nPage;
1282cdf0e10cSrcweir 		UpdatePreview(sal_False);
1283cdf0e10cSrcweir 	}
1284cdf0e10cSrcweir 
1285cdf0e10cSrcweir 	return 0;
1286cdf0e10cSrcweir }
1287cdf0e10cSrcweir 
IMPL_LINK(AssistentDlgImpl,UpdatePageListHdl,void *,EMPTYARG)1288cdf0e10cSrcweir IMPL_LINK( AssistentDlgImpl, UpdatePageListHdl, void *, EMPTYARG )
1289cdf0e10cSrcweir {
1290cdf0e10cSrcweir 	UpdatePageList();
1291cdf0e10cSrcweir 	return 0;
1292cdf0e10cSrcweir }
1293cdf0e10cSrcweir 
IMPL_LINK(AssistentDlgImpl,UpdatePreviewHdl,void *,EMPTYARG)1294cdf0e10cSrcweir IMPL_LINK( AssistentDlgImpl, UpdatePreviewHdl, void *, EMPTYARG )
1295cdf0e10cSrcweir {
1296cdf0e10cSrcweir 	UpdatePreview( sal_True );
1297cdf0e10cSrcweir 	return 0;
1298cdf0e10cSrcweir }
1299cdf0e10cSrcweir 
IMPL_LINK(AssistentDlgImpl,StartTypeHdl,RadioButton *,pButton)1300cdf0e10cSrcweir IMPL_LINK( AssistentDlgImpl, StartTypeHdl, RadioButton *, pButton )
1301cdf0e10cSrcweir {
1302cdf0e10cSrcweir 	StartType eType = pButton == mpPage1EmptyRB?ST_EMPTY:pButton == mpPage1TemplateRB?ST_TEMPLATE:ST_OPEN;
1303cdf0e10cSrcweir 
1304cdf0e10cSrcweir 	if(eType == ST_TEMPLATE)
1305*87131587Smseidel 		ProvideTemplates();
1306*87131587Smseidel 	else if(eType == ST_OPEN)
1307*87131587Smseidel 		ScanDocmenu();
1308cdf0e10cSrcweir 
1309cdf0e10cSrcweir 	SetStartType( eType );
1310cdf0e10cSrcweir 
1311cdf0e10cSrcweir 	if(eType == ST_TEMPLATE)
1312cdf0e10cSrcweir 	{
1313cdf0e10cSrcweir 		mpPage1TemplateLB->SelectEntryPos(0);
1314cdf0e10cSrcweir 		mpPage2Medium5RB->Check();
1315cdf0e10cSrcweir 	}
1316cdf0e10cSrcweir 	else if(eType == ST_OPEN)
1317cdf0e10cSrcweir 		mpPage1OpenLB->SelectEntryPos(0);
1318cdf0e10cSrcweir 
1319cdf0e10cSrcweir 	maPrevTimer.Start();
1320cdf0e10cSrcweir 	return 0;
1321cdf0e10cSrcweir }
1322cdf0e10cSrcweir 
1323cdf0e10cSrcweir 
IMPL_LINK(AssistentDlgImpl,NextPageHdl,PushButton *,EMPTYARG)1324cdf0e10cSrcweir IMPL_LINK( AssistentDlgImpl, NextPageHdl, PushButton *, EMPTYARG )
1325cdf0e10cSrcweir {
1326*87131587Smseidel 	// When changing from the first to the second page make sure that the
1327*87131587Smseidel 	// templates are present.
1328cdf0e10cSrcweir 	if (maAssistentFunc.GetCurrentPage() == 1)
1329*87131587Smseidel 		ProvideTemplates();
1330cdf0e10cSrcweir 
1331*87131587Smseidel 	// Change to the next page.
1332cdf0e10cSrcweir 	LeavePage();
1333cdf0e10cSrcweir 	maAssistentFunc.NextPage();
1334cdf0e10cSrcweir 	ChangePage();
1335cdf0e10cSrcweir 	return 0;
1336cdf0e10cSrcweir }
1337cdf0e10cSrcweir 
IMPL_LINK(AssistentDlgImpl,LastPageHdl,PushButton *,EMPTYARG)1338cdf0e10cSrcweir IMPL_LINK( AssistentDlgImpl, LastPageHdl, PushButton *, EMPTYARG )
1339cdf0e10cSrcweir {
1340cdf0e10cSrcweir 	LeavePage();
1341cdf0e10cSrcweir 	maAssistentFunc.PreviousPage();
1342cdf0e10cSrcweir 	ChangePage();
1343cdf0e10cSrcweir 	return 0;
1344cdf0e10cSrcweir }
1345cdf0e10cSrcweir 
IMPL_LINK(AssistentDlgImpl,PresTypeHdl,RadioButton *,EMPTYARG)1346cdf0e10cSrcweir IMPL_LINK( AssistentDlgImpl, PresTypeHdl, RadioButton*, EMPTYARG )
1347cdf0e10cSrcweir {
1348cdf0e10cSrcweir 	if(maDocFile.Len() == 0)
1349*87131587Smseidel 		{
1350*87131587Smseidel 			maNextPageButton.Enable(false);
1351*87131587Smseidel 		}
1352cdf0e10cSrcweir 
1353cdf0e10cSrcweir 	sal_Bool bKiosk = mpPage3PresTypeKioskRB->IsChecked();
1354cdf0e10cSrcweir 	mpPage3PresTimeFT->Enable(bKiosk);
1355cdf0e10cSrcweir 	mpPage3BreakFT->Enable(bKiosk);
1356cdf0e10cSrcweir 	mpPage3PresTimeTMF->Enable(bKiosk);
1357cdf0e10cSrcweir 	mpPage3BreakTMF->Enable(bKiosk);
1358cdf0e10cSrcweir 	mpPage3LogoCB->Enable(bKiosk);
1359cdf0e10cSrcweir 	return 0;
1360cdf0e10cSrcweir }
1361cdf0e10cSrcweir 
IMPL_LINK(AssistentDlgImpl,UpdateUserDataHdl,Edit *,EMPTYARG)1362cdf0e10cSrcweir IMPL_LINK( AssistentDlgImpl, UpdateUserDataHdl, Edit*, EMPTYARG )
1363cdf0e10cSrcweir {
1364cdf0e10cSrcweir 	mbUserDataDirty = sal_True;
1365cdf0e10cSrcweir 	String aTopic = mpPage4AskTopicEDT->GetText();
1366cdf0e10cSrcweir 	String aName  = mpPage4AskNameEDT->GetText();
1367cdf0e10cSrcweir 	String aInfo  = mpPage4AskInfoEDT->GetText();
1368cdf0e10cSrcweir 
1369cdf0e10cSrcweir 	if(aTopic.Len() == 0 && aName.Len() == 0 && aInfo.Len() == 0)
1370cdf0e10cSrcweir 		maDocFile.Erase();
1371cdf0e10cSrcweir 
1372cdf0e10cSrcweir 	return 0;
1373cdf0e10cSrcweir }
1374cdf0e10cSrcweir 
1375cdf0e10cSrcweir // ********************************************************************
1376cdf0e10cSrcweir // ********************************************************************
1377cdf0e10cSrcweir 
SelectTemplateRegion(const String & rRegion)1378cdf0e10cSrcweir void AssistentDlgImpl::SelectTemplateRegion( const String& rRegion )
1379cdf0e10cSrcweir {
1380cdf0e10cSrcweir 	mpPage1TemplateLB->Clear();
1381cdf0e10cSrcweir 	std::vector<TemplateDir*>::iterator	I;
1382cdf0e10cSrcweir 	for (I=maPresentList.begin(); I!=maPresentList.end(); I++)
1383cdf0e10cSrcweir 	{
1384cdf0e10cSrcweir 		TemplateDir * pDir = *I;
1385cdf0e10cSrcweir 		mpTemplateRegion = *I;
1386cdf0e10cSrcweir 		if (pDir->msRegion.Equals( rRegion ) )
1387cdf0e10cSrcweir 		{
1388cdf0e10cSrcweir 			std::vector<TemplateEntry*>::iterator	J;
1389cdf0e10cSrcweir 			for (J=pDir->maEntries.begin(); J!=pDir->maEntries.end(); J++)
1390cdf0e10cSrcweir 				mpPage1TemplateLB->InsertEntry ((*J)->msTitle);
1391cdf0e10cSrcweir 			mpPage1TemplateLB->Update();
1392cdf0e10cSrcweir 			if(GetStartType() == ST_TEMPLATE)
1393cdf0e10cSrcweir 			{
1394cdf0e10cSrcweir 				mpPage1TemplateLB->SelectEntryPos( 0 );
1395cdf0e10cSrcweir 				SelectTemplateHdl(NULL);
1396cdf0e10cSrcweir 			}
1397cdf0e10cSrcweir 			break;
1398cdf0e10cSrcweir 		}
1399cdf0e10cSrcweir 	}
1400cdf0e10cSrcweir }
1401cdf0e10cSrcweir 
SelectLayoutRegion(const String & rRegion)1402cdf0e10cSrcweir void AssistentDlgImpl::SelectLayoutRegion( const String& rRegion )
1403cdf0e10cSrcweir {
1404cdf0e10cSrcweir 	mpPage2LayoutLB->Clear();
1405cdf0e10cSrcweir 	mpPage2LayoutLB->InsertEntry(String(SdResId(STR_WIZARD_ORIGINAL)));
1406cdf0e10cSrcweir 	std::vector<TemplateDir*>::iterator	I;
1407cdf0e10cSrcweir 	for (I=maPresentList.begin(); I!=maPresentList.end(); I++)
1408cdf0e10cSrcweir 	{
1409cdf0e10cSrcweir 		TemplateDir * pDir = *I;
1410cdf0e10cSrcweir 		mpLayoutRegion = *I;
1411cdf0e10cSrcweir 
1412cdf0e10cSrcweir 		if (pDir->msRegion.Equals (rRegion))
1413cdf0e10cSrcweir 		{
1414cdf0e10cSrcweir 			std::vector<TemplateEntry*>::iterator	J;
1415cdf0e10cSrcweir 			for (J=pDir->maEntries.begin(); J!=pDir->maEntries.end(); J++)
1416cdf0e10cSrcweir 				mpPage2LayoutLB->InsertEntry ((*J)->msTitle);
1417cdf0e10cSrcweir 			mpPage2LayoutLB->Update();
1418cdf0e10cSrcweir 			break;
1419cdf0e10cSrcweir 		}
1420cdf0e10cSrcweir 	}
1421cdf0e10cSrcweir }
1422cdf0e10cSrcweir 
UpdateUserData()1423cdf0e10cSrcweir void AssistentDlgImpl::UpdateUserData()
1424cdf0e10cSrcweir {
1425cdf0e10cSrcweir 	String aTopic = mpPage4AskTopicEDT->GetText();
1426cdf0e10cSrcweir 	String aName  = mpPage4AskNameEDT->GetText();
1427cdf0e10cSrcweir 	String aInfo  = mpPage4AskInfoEDT->GetText();
1428cdf0e10cSrcweir 
1429cdf0e10cSrcweir 	SfxObjectShell* pShell = xDocShell;
1430cdf0e10cSrcweir 	DrawDocShell* pDocShell = PTR_CAST(DrawDocShell,pShell);
1431cdf0e10cSrcweir 	SdDrawDocument* pDoc = pDocShell?pDocShell->GetDoc():NULL;
1432cdf0e10cSrcweir 	SdPage* pPage = pDoc?pDoc->GetSdPage(0, PK_STANDARD):NULL;
1433cdf0e10cSrcweir 
1434cdf0e10cSrcweir 	if(pPage && ( aTopic.Len() != 0 || aName.Len() != 0 || aInfo.Len() != 0 ) )
1435cdf0e10cSrcweir 	{
1436cdf0e10cSrcweir 		if( pPage->GetAutoLayout() == AUTOLAYOUT_NONE )
1437cdf0e10cSrcweir 			pPage->SetAutoLayout(AUTOLAYOUT_TITLE, sal_True);
1438cdf0e10cSrcweir 
1439cdf0e10cSrcweir 		SdrTextObj* pObj;
1440cdf0e10cSrcweir 		String aEmptyString;
1441cdf0e10cSrcweir 
1442cdf0e10cSrcweir 		if( aTopic.Len() )
1443cdf0e10cSrcweir 		{
1444*87131587Smseidel 			pObj = dynamic_cast<SdrTextObj*>( pPage->GetPresObj( PRESOBJ_TITLE ) );
1445cdf0e10cSrcweir 			if( pObj )
1446cdf0e10cSrcweir 			{
1447cdf0e10cSrcweir 				pPage->SetObjText( pObj, NULL, PRESOBJ_TITLE, aTopic );
1448cdf0e10cSrcweir 				pObj->NbcSetStyleSheet( pPage->GetStyleSheetForPresObj( PRESOBJ_TITLE ), sal_True );
1449cdf0e10cSrcweir 				pObj->SetEmptyPresObj(sal_False);
1450cdf0e10cSrcweir 			}
1451cdf0e10cSrcweir 
1452cdf0e10cSrcweir 		}
1453cdf0e10cSrcweir 
1454cdf0e10cSrcweir 		if ( aName.Len() || aInfo.Len() )
1455cdf0e10cSrcweir 		{
1456cdf0e10cSrcweir 			String aStrTmp( aName );
1457cdf0e10cSrcweir 			if( aName.Len() )
1458cdf0e10cSrcweir 				aStrTmp.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "\n\n" ) );
1459cdf0e10cSrcweir 			aStrTmp.Append( aInfo );
1460cdf0e10cSrcweir 
1461cdf0e10cSrcweir 			pObj = dynamic_cast<SdrTextObj*>( pPage->GetPresObj( PRESOBJ_OUTLINE ) );
1462cdf0e10cSrcweir 			if( pObj )
1463cdf0e10cSrcweir 			{
1464cdf0e10cSrcweir 				pPage->SetObjText( pObj, NULL, PRESOBJ_OUTLINE, aStrTmp );
1465cdf0e10cSrcweir 				pObj->NbcSetStyleSheet( pPage->GetStyleSheetForPresObj( PRESOBJ_OUTLINE ), sal_True );
1466cdf0e10cSrcweir 				pObj->SetEmptyPresObj(sal_False);
1467cdf0e10cSrcweir 			}
1468cdf0e10cSrcweir 			else
1469cdf0e10cSrcweir 			{
1470cdf0e10cSrcweir 				pObj = dynamic_cast<SdrTextObj*>( pPage->GetPresObj( PRESOBJ_TEXT ) );
1471cdf0e10cSrcweir 				if( pObj )
1472cdf0e10cSrcweir 				{
1473cdf0e10cSrcweir 					pPage->SetObjText( pObj, NULL, PRESOBJ_TEXT, aStrTmp );
1474cdf0e10cSrcweir 					pObj->NbcSetStyleSheet( pPage->GetStyleSheetForPresObj( PRESOBJ_TEXT ), sal_True );
1475cdf0e10cSrcweir 					pObj->SetEmptyPresObj(sal_False);
1476cdf0e10cSrcweir 				}
1477cdf0e10cSrcweir 			}
1478cdf0e10cSrcweir 		}
1479cdf0e10cSrcweir 	}
1480cdf0e10cSrcweir 
1481cdf0e10cSrcweir 	mbUserDataDirty = sal_False;
1482cdf0e10cSrcweir }
1483cdf0e10cSrcweir 
UpdatePageList()1484cdf0e10cSrcweir void AssistentDlgImpl::UpdatePageList()
1485cdf0e10cSrcweir {
1486cdf0e10cSrcweir 	if(mbDocPreview || !mbPreview)
1487cdf0e10cSrcweir 		UpdatePreview(sal_False);
1488cdf0e10cSrcweir 	else if(maPageListFile == maDocFile)
1489cdf0e10cSrcweir 		return;
1490cdf0e10cSrcweir 
1491cdf0e10cSrcweir 	maPageListFile = maDocFile;
1492cdf0e10cSrcweir 
1493cdf0e10cSrcweir 	SfxObjectShell* pShell = xDocShell;
1494cdf0e10cSrcweir 	DrawDocShell* pDocShell = PTR_CAST(DrawDocShell,pShell);
1495cdf0e10cSrcweir 	SdDrawDocument* pDoc = pDocShell?pDocShell->GetDoc():NULL;
1496cdf0e10cSrcweir 
1497cdf0e10cSrcweir 	mpPage5PageListCT->Clear();
1498cdf0e10cSrcweir 
1499cdf0e10cSrcweir 	if(pDoc)
1500cdf0e10cSrcweir 		mpPage5PageListCT->Fill(pDoc);
1501cdf0e10cSrcweir }
1502cdf0e10cSrcweir 
UpdatePreview(sal_Bool bDocPreview)1503cdf0e10cSrcweir void AssistentDlgImpl::UpdatePreview( sal_Bool bDocPreview )
1504cdf0e10cSrcweir {
1505*87131587Smseidel 	// Guard against multiple concurrent execution to this method caused either
1506*87131587Smseidel 	// by calls from different threads or recursion.
1507*87131587Smseidel 	::osl::MutexGuard aGuard (maMutex);
1508*87131587Smseidel 	if (mbPreviewUpdating)
1509*87131587Smseidel 		return;
1510*87131587Smseidel 	mbPreviewUpdating = sal_True;
1511cdf0e10cSrcweir 
1512cdf0e10cSrcweir 	if(!mbPreview && bDocPreview)
1513cdf0e10cSrcweir 	{
1514cdf0e10cSrcweir 		maPreview.Invalidate();
1515cdf0e10cSrcweir 		maPreview.SetObjectShell(0);
1516*87131587Smseidel 		mbPreviewUpdating = sal_False;
1517cdf0e10cSrcweir 		return;
1518cdf0e10cSrcweir 	}
1519cdf0e10cSrcweir 
1520cdf0e10cSrcweir 	String aDocFile = GetDocFileName();
1521cdf0e10cSrcweir 	String aLayoutFile = GetLayoutFileName();
1522cdf0e10cSrcweir 	String aEmptyStr;
1523cdf0e10cSrcweir 
1524cdf0e10cSrcweir 	SfxApplication *pSfxApp = SFX_APP();
1525cdf0e10cSrcweir 	sal_uLong lErr;
1526cdf0e10cSrcweir 	sal_Bool bChangeMaster = aLayoutFile.Len() != 0;
1527cdf0e10cSrcweir 
1528cdf0e10cSrcweir 	if( aDocFile.Len() == 0 )
1529cdf0e10cSrcweir 	{
1530cdf0e10cSrcweir 		if( !xDocShell.Is() || maDocFile.Len() != 0 ||
1531cdf0e10cSrcweir 			(maDocFile.Len() == 0 && maLayoutFile.Len() != 0 && aLayoutFile.Len() == 0 ))
1532cdf0e10cSrcweir 		{
1533cdf0e10cSrcweir 			CloseDocShell();
1534cdf0e10cSrcweir 
1535cdf0e10cSrcweir 			DrawDocShell* pNewDocSh;
1536cdf0e10cSrcweir 			xDocShell = pNewDocSh = new DrawDocShell(SFX_CREATE_MODE_STANDARD, sal_False);
1537cdf0e10cSrcweir 			pNewDocSh->DoInitNew(NULL);
1538cdf0e10cSrcweir 			SdDrawDocument* pDoc = pNewDocSh->GetDoc();
1539cdf0e10cSrcweir 			pDoc->CreateFirstPages();
1540cdf0e10cSrcweir 			pDoc->StopWorkStartupDelay();
1541cdf0e10cSrcweir 			mbDocPreview = sal_False;
1542cdf0e10cSrcweir 
1543cdf0e10cSrcweir 			maDocFile = aDocFile;
1544cdf0e10cSrcweir 			mbUserDataDirty = sal_True;
1545cdf0e10cSrcweir 		}
1546cdf0e10cSrcweir 		else
1547cdf0e10cSrcweir 			bChangeMaster = (aLayoutFile.Len() != 0) && (maLayoutFile != aLayoutFile);
1548cdf0e10cSrcweir 	}
1549cdf0e10cSrcweir 	else if( aDocFile == maDocFile && ( mbDocPreview == bDocPreview || bDocPreview ) )
1550cdf0e10cSrcweir 	{
1551cdf0e10cSrcweir 		if( aLayoutFile != maLayoutFile )
1552cdf0e10cSrcweir 		{
1553cdf0e10cSrcweir 			SfxObjectShell* pShell = xDocShell;
1554cdf0e10cSrcweir 			DrawDocShell* pDocShell = PTR_CAST(DrawDocShell,pShell);
1555*87131587Smseidel 			::svl::IUndoManager* pUndoMgr = pDocShell?pDocShell->GetUndoManager():NULL;
1556cdf0e10cSrcweir 			if(pUndoMgr)
1557cdf0e10cSrcweir 				pUndoMgr->Undo();
1558cdf0e10cSrcweir 			mbUserDataDirty = sal_True;
1559cdf0e10cSrcweir 		}
1560cdf0e10cSrcweir 		else
1561cdf0e10cSrcweir 			bChangeMaster = sal_False;
1562cdf0e10cSrcweir 	}
1563cdf0e10cSrcweir 	else
1564cdf0e10cSrcweir 	{
1565cdf0e10cSrcweir 		CloseDocShell();
1566cdf0e10cSrcweir 
1567cdf0e10cSrcweir 		::Window *pParent = Application::GetDefDialogParent();
1568cdf0e10cSrcweir 		Application::SetDefDialogParent( mpWindow );
1569cdf0e10cSrcweir 
1570cdf0e10cSrcweir 		SfxErrorContext eEC(ERRCTX_SFX_LOADTEMPLATE,mpWindow);
1571cdf0e10cSrcweir 
1572cdf0e10cSrcweir 		SfxItemSet* pSet = new SfxAllItemSet( pSfxApp->GetPool() );
1573cdf0e10cSrcweir 		if(IsOwnFormat(aDocFile))
1574cdf0e10cSrcweir 		{
1575cdf0e10cSrcweir 			pSet->Put( SfxBoolItem( SID_TEMPLATE, sal_True ) );
1576cdf0e10cSrcweir 			if(bDocPreview)
1577cdf0e10cSrcweir 				pSet->Put( SfxBoolItem( SID_PREVIEW, sal_True ) );
1578cdf0e10cSrcweir 			RestorePassword( pSet, aDocFile );
1579*87131587Smseidel 			if( (lErr = pSfxApp->LoadTemplate( xDocShell, aDocFile, sal_True, pSet )) != 0 )
1580cdf0e10cSrcweir 				ErrorHandler::HandleError(lErr);
1581cdf0e10cSrcweir 			else
1582cdf0e10cSrcweir 				SavePassword( xDocShell, aDocFile );
1583cdf0e10cSrcweir 		}
1584cdf0e10cSrcweir 		else
1585cdf0e10cSrcweir 		{
1586cdf0e10cSrcweir 			const String aTargetStr( RTL_CONSTASCII_USTRINGPARAM("_default") );
1587cdf0e10cSrcweir 
1588cdf0e10cSrcweir 			SfxRequest aReq( SID_OPENDOC, SFX_CALLMODE_SYNCHRON, SFX_APP()->GetPool() );
1589cdf0e10cSrcweir 			aReq.AppendItem( SfxStringItem( SID_FILE_NAME, aDocFile ));
1590cdf0e10cSrcweir 			aReq.AppendItem( SfxStringItem( SID_REFERER, aEmptyStr ) );
1591*87131587Smseidel 			aReq.AppendItem( SfxStringItem( SID_TARGETNAME, aTargetStr ) );
1592cdf0e10cSrcweir 			aReq.AppendItem( SfxBoolItem( SID_HIDDEN, sal_True ) );
1593cdf0e10cSrcweir 			aReq.AppendItem( SfxBoolItem( SID_PREVIEW, bDocPreview ) );
1594cdf0e10cSrcweir 
1595*87131587Smseidel 			const SfxViewFrameItem* pRet = PTR_CAST( SfxViewFrameItem, SFX_APP()->ExecuteSlot( aReq ) );
1596cdf0e10cSrcweir 
1597cdf0e10cSrcweir 			if ( pRet && pRet->GetFrame() && pRet->GetFrame()->GetObjectShell() )
1598cdf0e10cSrcweir 				xDocShell = pRet->GetFrame()->GetObjectShell();
1599cdf0e10cSrcweir 		}
1600cdf0e10cSrcweir 
1601cdf0e10cSrcweir 
1602cdf0e10cSrcweir 		Application::SetDefDialogParent( pParent );
1603cdf0e10cSrcweir 
1604cdf0e10cSrcweir 		mnShowPage = 0;
1605cdf0e10cSrcweir 		mbDocPreview = bDocPreview;
1606cdf0e10cSrcweir 		maDocFile = aDocFile;
1607cdf0e10cSrcweir 		mbUserDataDirty = sal_True;
1608cdf0e10cSrcweir 	}
1609cdf0e10cSrcweir 
1610cdf0e10cSrcweir 	if(bChangeMaster && (aLayoutFile != maDocFile))
1611cdf0e10cSrcweir 	{
1612cdf0e10cSrcweir 		// Layoutvorlage laden
1613cdf0e10cSrcweir 		SfxObjectShellLock xLayoutDocShell;
1614cdf0e10cSrcweir 		SfxErrorContext eEC(ERRCTX_SFX_LOADTEMPLATE,mpWindow);
1615cdf0e10cSrcweir 		SfxItemSet* pSet = new SfxAllItemSet( pSfxApp->GetPool() );
1616cdf0e10cSrcweir 
1617cdf0e10cSrcweir 		::Window *pParent = Application::GetDefDialogParent();
1618cdf0e10cSrcweir 		Application::SetDefDialogParent( mpWindow );
1619cdf0e10cSrcweir 
1620cdf0e10cSrcweir 		if(IsOwnFormat(aLayoutFile))
1621cdf0e10cSrcweir 		{
1622cdf0e10cSrcweir 			pSet->Put( SfxBoolItem( SID_TEMPLATE, sal_True ) );
1623cdf0e10cSrcweir 			pSet->Put( SfxBoolItem( SID_PREVIEW, sal_True ) );
1624cdf0e10cSrcweir 
1625cdf0e10cSrcweir 			RestorePassword( pSet, aLayoutFile );
1626*87131587Smseidel 			if( (lErr = pSfxApp->LoadTemplate( xLayoutDocShell, aLayoutFile, sal_True, pSet )) != 0 )
1627cdf0e10cSrcweir 				ErrorHandler::HandleError(lErr);
1628cdf0e10cSrcweir 			SavePassword( xLayoutDocShell, aLayoutFile );
1629cdf0e10cSrcweir 		}
1630cdf0e10cSrcweir 
1631cdf0e10cSrcweir 		Application::SetDefDialogParent( pParent );
1632cdf0e10cSrcweir 
1633cdf0e10cSrcweir 		// die Implementierung ermitteln
1634cdf0e10cSrcweir 		SfxObjectShell* pShell = xDocShell;
1635cdf0e10cSrcweir 		DrawDocShell* pDocShell = PTR_CAST(DrawDocShell,pShell);
1636cdf0e10cSrcweir 		SdDrawDocument* pDoc = pDocShell?pDocShell->GetDoc():NULL;
1637cdf0e10cSrcweir 
1638cdf0e10cSrcweir 		pShell = xLayoutDocShell;
1639cdf0e10cSrcweir 		pDocShell = PTR_CAST(DrawDocShell,pShell);
1640cdf0e10cSrcweir 		SdDrawDocument* pLayoutDoc = pDocShell?pDocShell->GetDoc():NULL;
1641cdf0e10cSrcweir 
1642cdf0e10cSrcweir 		if( pDoc && pLayoutDoc )
1643cdf0e10cSrcweir 		{
1644*87131587Smseidel 			pDoc->SetMasterPage(0, aEmptyStr, pLayoutDoc, sal_True, sal_False );
1645cdf0e10cSrcweir 		}
1646cdf0e10cSrcweir 		else
1647cdf0e10cSrcweir 		{
1648cdf0e10cSrcweir 			DBG_ERROR("sd::AssistentDlgImpl::UpdatePreview(), no document for preview?");
1649cdf0e10cSrcweir 		}
1650cdf0e10cSrcweir 
1651cdf0e10cSrcweir 		mbUserDataDirty = sal_True;
1652cdf0e10cSrcweir 	}
1653cdf0e10cSrcweir 	maLayoutFile = aLayoutFile;
1654cdf0e10cSrcweir 
1655cdf0e10cSrcweir 	if(mbUserDataDirty)
1656cdf0e10cSrcweir 		UpdateUserData();
1657cdf0e10cSrcweir 
1658cdf0e10cSrcweir 	if ( !xDocShell.Is() || !mbPreview )
1659cdf0e10cSrcweir 		maPreview.SetObjectShell( 0 );
1660cdf0e10cSrcweir 	else
1661cdf0e10cSrcweir 	{
1662cdf0e10cSrcweir 		maPreview.SetObjectShell( xDocShell, mnShowPage );
1663cdf0e10cSrcweir 	}
1664cdf0e10cSrcweir 
1665*87131587Smseidel 	mbPreviewUpdating = sal_False;
1666cdf0e10cSrcweir }
1667cdf0e10cSrcweir 
SavePassword(SfxObjectShellLock xDoc,const String & rPath)1668cdf0e10cSrcweir void AssistentDlgImpl::SavePassword( SfxObjectShellLock xDoc, const String& rPath )
1669cdf0e10cSrcweir {
1670cdf0e10cSrcweir 	if(xDoc.Is())
1671cdf0e10cSrcweir 	{
1672cdf0e10cSrcweir 		SfxMedium * pMedium = xDoc->GetMedium();
1673cdf0e10cSrcweir 		if(pMedium && pMedium->IsStorage())
1674cdf0e10cSrcweir 		{
1675cdf0e10cSrcweir 			SfxItemSet * pSet = pMedium->GetItemSet();
1676*87131587Smseidel 			const SfxPoolItem *pItem = 0;
1677*87131587Smseidel 			if( pSet->GetItemState(SID_PASSWORD, sal_True, &pItem) == SFX_ITEM_SET )
1678*87131587Smseidel 			{
1679*87131587Smseidel 				// TODO/MBA: testing
1680*87131587Smseidel 				String aPass( ((const SfxStringItem*)pItem)->GetValue());
1681*87131587Smseidel 				if(aPass.Len() == 0)
1682*87131587Smseidel 					return;
1683*87131587Smseidel 
1684*87131587Smseidel 			PasswordEntry* pEntry = maPasswordList.First();
1685*87131587Smseidel 			while(pEntry)
1686*87131587Smseidel 			{
1687*87131587Smseidel 				if(pEntry->maPath == rPath)
1688*87131587Smseidel 					break;
1689*87131587Smseidel 
1690*87131587Smseidel 				pEntry = maPasswordList.Next();
1691*87131587Smseidel 
1692*87131587Smseidel 			}
1693*87131587Smseidel 
1694*87131587Smseidel 			if(pEntry == NULL)
1695*87131587Smseidel 			{
1696*87131587Smseidel 				pEntry = new PasswordEntry();
1697*87131587Smseidel 				pEntry->maPath = rPath;
1698*87131587Smseidel 				maPasswordList.Insert( pEntry );
1699*87131587Smseidel 			}
1700*87131587Smseidel 
1701*87131587Smseidel 			if(pEntry)
1702*87131587Smseidel 				pEntry->maPassword = aPass;
1703*87131587Smseidel 			}
1704cdf0e10cSrcweir 		}
1705cdf0e10cSrcweir 	}
1706cdf0e10cSrcweir }
1707cdf0e10cSrcweir 
RestorePassword(SfxItemSet * pSet,const String & rPath)1708cdf0e10cSrcweir void AssistentDlgImpl::RestorePassword( SfxItemSet* pSet, const String& rPath )
1709cdf0e10cSrcweir {
1710cdf0e10cSrcweir 	String aPassword( GetPassword( rPath ) );
1711cdf0e10cSrcweir 
1712cdf0e10cSrcweir 	if(aPassword.Len())
1713cdf0e10cSrcweir 		pSet->Put( SfxStringItem( SID_PASSWORD, aPassword ) );
1714cdf0e10cSrcweir }
1715cdf0e10cSrcweir 
GetPassword(const String rPath)1716cdf0e10cSrcweir String AssistentDlgImpl::GetPassword( const String rPath )
1717cdf0e10cSrcweir {
1718cdf0e10cSrcweir 	PasswordEntry* pEntry = maPasswordList.First();
1719cdf0e10cSrcweir 	while(pEntry)
1720cdf0e10cSrcweir 	{
1721cdf0e10cSrcweir 		if(pEntry->maPath == rPath)
1722cdf0e10cSrcweir 			return pEntry->maPassword;
1723cdf0e10cSrcweir 
1724cdf0e10cSrcweir 		pEntry = maPasswordList.Next();
1725cdf0e10cSrcweir 	}
1726cdf0e10cSrcweir 
1727cdf0e10cSrcweir 	return String();
1728cdf0e10cSrcweir }
1729cdf0e10cSrcweir 
DeletePassords()1730cdf0e10cSrcweir void AssistentDlgImpl::DeletePassords()
1731cdf0e10cSrcweir {
1732cdf0e10cSrcweir 	PasswordEntry* pEntry = maPasswordList.First();
1733cdf0e10cSrcweir 	while(pEntry)
1734cdf0e10cSrcweir 	{
1735cdf0e10cSrcweir 		delete pEntry;
1736cdf0e10cSrcweir 		pEntry = maPasswordList.Next();
1737cdf0e10cSrcweir 	}
1738cdf0e10cSrcweir }
1739cdf0e10cSrcweir 
IsOwnFormat(const String & rPath)1740cdf0e10cSrcweir sal_Bool AssistentDlgImpl::IsOwnFormat( const String& rPath )
1741cdf0e10cSrcweir {
1742cdf0e10cSrcweir 	INetURLObject	aURL( rPath );
1743cdf0e10cSrcweir 	String			aExt( aURL.GetFileExtension() );
1744cdf0e10cSrcweir 
1745cdf0e10cSrcweir 	DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
1746cdf0e10cSrcweir 
1747cdf0e10cSrcweir 	return !aExt.EqualsIgnoreCaseAscii( "ppt" );
1748cdf0e10cSrcweir }
1749cdf0e10cSrcweir 
1750cdf0e10cSrcweir 
1751cdf0e10cSrcweir 
1752cdf0e10cSrcweir 
GetUiTextForCommand(const::rtl::OUString & sCommandURL)1753cdf0e10cSrcweir String AssistentDlgImpl::GetUiTextForCommand (const ::rtl::OUString& sCommandURL)
1754cdf0e10cSrcweir {
1755*87131587Smseidel 	String sLabel;
1756*87131587Smseidel 	Reference<container::XNameAccess> xUICommandLabels;
1757*87131587Smseidel 
1758*87131587Smseidel 	try
1759*87131587Smseidel 	{
1760*87131587Smseidel 		do
1761*87131587Smseidel 		{
1762*87131587Smseidel 			if (sCommandURL.getLength() == 0)
1763*87131587Smseidel 				break;
1764*87131587Smseidel 
1765*87131587Smseidel 			// Retrieve popup menu labels
1766*87131587Smseidel 			Reference<lang::XMultiServiceFactory> xFactory (
1767*87131587Smseidel 				::comphelper::getProcessServiceFactory ());
1768*87131587Smseidel 			if ( ! xFactory.is())
1769*87131587Smseidel 				break;
1770*87131587Smseidel 
1771*87131587Smseidel 			::rtl::OUString sModuleIdentifier (
1772*87131587Smseidel 				RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PresentationDocument"));
1773*87131587Smseidel 			Reference<container::XNameAccess> xNameAccess (
1774*87131587Smseidel 				xFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
1775*87131587Smseidel 					"com.sun.star.frame.UICommandDescription"))),
1776*87131587Smseidel 				UNO_QUERY);
1777*87131587Smseidel 			if ( ! xNameAccess.is())
1778*87131587Smseidel 				break;
1779*87131587Smseidel 			Any a = xNameAccess->getByName(sModuleIdentifier);
1780*87131587Smseidel 			a >>= xUICommandLabels;
1781*87131587Smseidel 			if ( ! xUICommandLabels.is())
1782*87131587Smseidel 				break;
1783*87131587Smseidel 
1784*87131587Smseidel 			::rtl::OUString sString;
1785*87131587Smseidel 			Sequence<beans::PropertyValue> aProperties;
1786*87131587Smseidel 			Any aAny (xUICommandLabels->getByName(sCommandURL));
1787*87131587Smseidel 			if (aAny >>= aProperties)
1788*87131587Smseidel 			{
1789*87131587Smseidel 				sal_Int32 nCount (aProperties.getLength());
1790*87131587Smseidel 				for (sal_Int32 i=0; i<nCount; i++)
1791*87131587Smseidel 				{
1792*87131587Smseidel 					::rtl::OUString sPropertyName (aProperties[i].Name);
1793*87131587Smseidel 					if (sPropertyName.equalsAscii("Label"))
1794*87131587Smseidel 					{
1795*87131587Smseidel 						aProperties[i].Value >>= sString;
1796*87131587Smseidel 						break;
1797*87131587Smseidel 					}
1798*87131587Smseidel 				}
1799*87131587Smseidel 			}
1800*87131587Smseidel 			sLabel = sString;
1801*87131587Smseidel 		}
1802*87131587Smseidel 		while(false);
1803*87131587Smseidel 	}
1804*87131587Smseidel 	catch (com::sun::star::uno::Exception& rException)
1805*87131587Smseidel 	{
1806*87131587Smseidel 		(void)rException;
1807*87131587Smseidel 	}
1808*87131587Smseidel 
1809*87131587Smseidel 	return sLabel;
1810cdf0e10cSrcweir }
1811cdf0e10cSrcweir 
1812cdf0e10cSrcweir 
1813cdf0e10cSrcweir 
1814cdf0e10cSrcweir 
GetUiIconForCommand(const::rtl::OUString & sCommandURL)1815cdf0e10cSrcweir Image AssistentDlgImpl::GetUiIconForCommand (const ::rtl::OUString& sCommandURL)
1816cdf0e10cSrcweir {
1817*87131587Smseidel 	Image aIcon;
1818*87131587Smseidel 	Reference<container::XNameAccess> xUICommandLabels;
1819*87131587Smseidel 
1820*87131587Smseidel 	try
1821*87131587Smseidel 	{
1822*87131587Smseidel 		do
1823*87131587Smseidel 		{
1824*87131587Smseidel 			if (sCommandURL.getLength() == 0)
1825*87131587Smseidel 				break;
1826*87131587Smseidel 
1827*87131587Smseidel 			// Retrieve popup menu labels
1828*87131587Smseidel 			Reference<lang::XMultiServiceFactory> xFactory (
1829*87131587Smseidel 				::comphelper::getProcessServiceFactory ());
1830*87131587Smseidel 			if ( ! xFactory.is())
1831*87131587Smseidel 				break;
1832*87131587Smseidel 
1833*87131587Smseidel 			::rtl::OUString sModuleIdentifier (
1834*87131587Smseidel 				RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PresentationDocument"));
1835*87131587Smseidel 
1836*87131587Smseidel 			Reference<com::sun::star::ui::XModuleUIConfigurationManagerSupplier> xSupplier (
1837*87131587Smseidel 				xFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
1838*87131587Smseidel 					"com.sun.star.ui.ModuleUIConfigurationManagerSupplier"))),
1839*87131587Smseidel 				UNO_QUERY_THROW);
1840*87131587Smseidel 
1841*87131587Smseidel 			Reference<com::sun::star::ui::XUIConfigurationManager> xManager (
1842*87131587Smseidel 				xSupplier->getUIConfigurationManager(sModuleIdentifier));
1843*87131587Smseidel 			if ( ! xManager.is())
1844*87131587Smseidel 				break;
1845*87131587Smseidel 
1846*87131587Smseidel 			Reference<com::sun::star::ui::XImageManager> xImageManager (
1847*87131587Smseidel 				xManager->getImageManager(),
1848*87131587Smseidel 				UNO_QUERY_THROW);
1849*87131587Smseidel 
1850*87131587Smseidel 			Sequence<rtl::OUString> aCommandList(1);
1851*87131587Smseidel 			aCommandList[0] = sCommandURL;
1852*87131587Smseidel 			Sequence<Reference<graphic::XGraphic> > xIconList (
1853*87131587Smseidel 				xImageManager->getImages(0,aCommandList));
1854*87131587Smseidel 			if ( ! xIconList.hasElements())
1855*87131587Smseidel 				break;
1856*87131587Smseidel 
1857*87131587Smseidel 			aIcon = Graphic(xIconList[0]).GetBitmapEx();
1858*87131587Smseidel 		}
1859*87131587Smseidel 		while(false);
1860*87131587Smseidel 	}
1861*87131587Smseidel 	catch (com::sun::star::uno::Exception& rException)
1862*87131587Smseidel 	{
1863*87131587Smseidel 		(void)rException;
1864*87131587Smseidel 	}
1865*87131587Smseidel 
1866*87131587Smseidel 	return aIcon;
1867cdf0e10cSrcweir }
1868cdf0e10cSrcweir 
1869cdf0e10cSrcweir 
1870cdf0e10cSrcweir //////////////////////////////////////////////
1871cdf0e10cSrcweir 
AssistentDlg(Window * pParent,sal_Bool bAutoPilot)1872cdf0e10cSrcweir AssistentDlg::AssistentDlg(Window* pParent, sal_Bool bAutoPilot) :
1873cdf0e10cSrcweir 	ModalDialog(pParent,SdResId(DLG_ASS))
1874cdf0e10cSrcweir {
1875cdf0e10cSrcweir 	Link aFinishLink = LINK(this,AssistentDlg, FinishHdl);
1876cdf0e10cSrcweir 	mpImpl = new AssistentDlgImpl( this, aFinishLink, bAutoPilot );
1877cdf0e10cSrcweir 
1878*87131587Smseidel 	// Buttonbelegung
1879cdf0e10cSrcweir 	mpImpl->maFinishButton.SetClickHdl(LINK(this,AssistentDlg,FinishHdl));
1880cdf0e10cSrcweir 
1881cdf0e10cSrcweir 	FreeResource();
1882cdf0e10cSrcweir }
1883cdf0e10cSrcweir 
IMPL_LINK(AssistentDlg,FinishHdl,OKButton *,EMPTYARG)1884cdf0e10cSrcweir IMPL_LINK( AssistentDlg, FinishHdl, OKButton *, EMPTYARG )
1885cdf0e10cSrcweir {
1886*87131587Smseidel 	if( GetStartType() == ST_OPEN )
1887cdf0e10cSrcweir 	{
1888*87131587Smseidel 		// if we do not have a file here asked for one before ending the dialog
1889*87131587Smseidel 		String aFileToOpen = GetDocPath();
1890cdf0e10cSrcweir 		if(aFileToOpen.Len() == 0)
1891cdf0e10cSrcweir 		{
1892*87131587Smseidel 			sfx2::FileDialogHelper aFileDlg( WB_OPEN, ::String::CreateFromAscii("simpress") );
1893cdf0e10cSrcweir 
1894cdf0e10cSrcweir 			if ( aFileDlg.Execute() == ERRCODE_NONE )
1895cdf0e10cSrcweir 				aFileToOpen = aFileDlg.GetPath();
1896*87131587Smseidel 			if( aFileToOpen.Len() == 0)
1897*87131587Smseidel 				return 1;
1898*87131587Smseidel 			else
1899*87131587Smseidel 			{
1900*87131587Smseidel 				//add the selected file to the recent-file-listbox and select the new entry
1901*87131587Smseidel 				//this is necessary for 'GetDocPath()' returning the selected file after end of dialog
1902*87131587Smseidel 
1903*87131587Smseidel 				INetURLObject aURL;
1904*87131587Smseidel 				aURL.SetSmartURL(aFileToOpen);
1905*87131587Smseidel 				mpImpl->maOpenFilesList.push_back (new String (aURL.GetMainURL( INetURLObject::NO_DECODE )));
1906*87131587Smseidel 				sal_uInt16 nNewPos = mpImpl->mpPage1OpenLB->InsertEntry(aURL.getName());
1907*87131587Smseidel 				mpImpl->mpPage1OpenLB->SelectEntryPos(nNewPos);
1908*87131587Smseidel 			}
1909cdf0e10cSrcweir 		}
1910*87131587Smseidel 	}
1911cdf0e10cSrcweir 
1912*87131587Smseidel 	// End
1913cdf0e10cSrcweir 	mpImpl->EndDialog(RET_OK);
1914cdf0e10cSrcweir 	EndDialog(RET_OK);
1915cdf0e10cSrcweir 	return 0;
1916cdf0e10cSrcweir }
1917cdf0e10cSrcweir 
~AssistentDlg()1918cdf0e10cSrcweir AssistentDlg::~AssistentDlg()
1919cdf0e10cSrcweir {
1920cdf0e10cSrcweir 	delete mpImpl;
1921cdf0e10cSrcweir }
1922cdf0e10cSrcweir 
1923cdf0e10cSrcweir 
GetDocument()1924cdf0e10cSrcweir SfxObjectShellLock AssistentDlg::GetDocument()
1925cdf0e10cSrcweir {
1926cdf0e10cSrcweir 	return mpImpl->GetDocument();
1927cdf0e10cSrcweir }
1928cdf0e10cSrcweir 
GetOutputMedium() const1929cdf0e10cSrcweir OutputType AssistentDlg::GetOutputMedium() const
1930cdf0e10cSrcweir {
1931cdf0e10cSrcweir 	if(mpImpl->mpPage2Medium1RB->IsChecked())
1932*87131587Smseidel 		return OUTPUT_PRESENTATION_4_BY_3;
1933cdf0e10cSrcweir 	else if(mpImpl->mpPage2Medium2RB->IsChecked())
1934cdf0e10cSrcweir 		return OUTPUT_SLIDE;
1935cdf0e10cSrcweir 	else if(mpImpl->mpPage2Medium3RB->IsChecked())
1936cdf0e10cSrcweir 		return OUTPUT_OVERHEAD;
1937cdf0e10cSrcweir 	else if(mpImpl->mpPage2Medium4RB->IsChecked())
1938cdf0e10cSrcweir 		return OUTPUT_PAGE;
1939cdf0e10cSrcweir 	else
1940cdf0e10cSrcweir 		return OUTPUT_ORIGINAL;
1941cdf0e10cSrcweir }
1942cdf0e10cSrcweir 
IsSummary() const1943cdf0e10cSrcweir sal_Bool AssistentDlg::IsSummary() const
1944cdf0e10cSrcweir {
1945cdf0e10cSrcweir 	return mpImpl->mpPage5SummaryCB->IsChecked();
1946cdf0e10cSrcweir }
1947cdf0e10cSrcweir 
GetStartType() const1948cdf0e10cSrcweir StartType AssistentDlg::GetStartType() const
1949cdf0e10cSrcweir {
1950cdf0e10cSrcweir 	return mpImpl->GetStartType();
1951cdf0e10cSrcweir }
1952cdf0e10cSrcweir 
GetDocPath() const1953cdf0e10cSrcweir String AssistentDlg::GetDocPath() const
1954cdf0e10cSrcweir {
1955cdf0e10cSrcweir 	return mpImpl->GetDocFileName();
1956cdf0e10cSrcweir }
1957cdf0e10cSrcweir 
GetStartWithFlag() const1958cdf0e10cSrcweir sal_Bool AssistentDlg::GetStartWithFlag() const
1959cdf0e10cSrcweir {
1960cdf0e10cSrcweir 	return !mpImpl->maStartWithFlag.IsChecked();
1961cdf0e10cSrcweir }
1962cdf0e10cSrcweir 
IsDocEmpty() const1963cdf0e10cSrcweir sal_Bool AssistentDlg::IsDocEmpty() const
1964cdf0e10cSrcweir {
1965cdf0e10cSrcweir 	return mpImpl->GetDocFileName().Len() == 0 &&
1966cdf0e10cSrcweir 		   mpImpl->GetLayoutFileName().Len() == 0;
1967cdf0e10cSrcweir }
1968cdf0e10cSrcweir 
GetPassword()1969cdf0e10cSrcweir String AssistentDlg::GetPassword()
1970cdf0e10cSrcweir {
1971cdf0e10cSrcweir 	return mpImpl->GetPassword( mpImpl->maDocFile );
1972cdf0e10cSrcweir }
1973cdf0e10cSrcweir 
1974cdf0e10cSrcweir 
1975cdf0e10cSrcweir 
1976cdf0e10cSrcweir 
1977cdf0e10cSrcweir //===== NextButton ============================================================
1978cdf0e10cSrcweir 
NextButton(::Window * pParent,const ResId & rResId)1979cdf0e10cSrcweir NextButton::NextButton (::Window* pParent, const ResId& rResId)
1980*87131587Smseidel 	: maNextButton1(pParent, rResId),
1981*87131587Smseidel 	  maNextButton2(pParent, rResId),
1982*87131587Smseidel 	  mbIsFirstButtonActive(true)
1983cdf0e10cSrcweir {
1984*87131587Smseidel 	// Hide the unused button.
1985*87131587Smseidel 	maNextButton2.Hide();
1986cdf0e10cSrcweir }
1987cdf0e10cSrcweir 
1988cdf0e10cSrcweir 
1989cdf0e10cSrcweir 
1990cdf0e10cSrcweir 
ForceFocusEventBroadcast(void)1991cdf0e10cSrcweir void NextButton::ForceFocusEventBroadcast (void)
1992cdf0e10cSrcweir {
1993*87131587Smseidel 	// Hide the currently visible button and show and focus the other one.
1994*87131587Smseidel 	if (mbIsFirstButtonActive)
1995*87131587Smseidel 	{
1996*87131587Smseidel 		mbIsFirstButtonActive = false;
1997*87131587Smseidel 		maNextButton2.Show();
1998*87131587Smseidel 		maNextButton2.GrabFocus();
1999*87131587Smseidel 		maNextButton1.Hide();
2000*87131587Smseidel 	}
2001*87131587Smseidel 	else
2002*87131587Smseidel 	{
2003*87131587Smseidel 		mbIsFirstButtonActive = true;
2004*87131587Smseidel 		maNextButton1.Show();
2005*87131587Smseidel 		maNextButton1.GrabFocus();
2006*87131587Smseidel 		maNextButton2.Hide();
2007*87131587Smseidel 	}
2008cdf0e10cSrcweir }
2009cdf0e10cSrcweir 
2010cdf0e10cSrcweir 
2011cdf0e10cSrcweir 
2012cdf0e10cSrcweir 
SetClickHdl(const Link & rLink)2013cdf0e10cSrcweir void NextButton::SetClickHdl (const Link& rLink)
2014cdf0e10cSrcweir {
2015*87131587Smseidel 	// Forward the setting of the click handler to the two buttons
2016*87131587Smseidel 	// regardless of which one is currently visible.
2017*87131587Smseidel 	maNextButton1.SetClickHdl(rLink);
2018*87131587Smseidel 	maNextButton2.SetClickHdl(rLink);
2019cdf0e10cSrcweir }
2020cdf0e10cSrcweir 
2021cdf0e10cSrcweir 
2022cdf0e10cSrcweir 
2023cdf0e10cSrcweir 
IsEnabled(void)2024cdf0e10cSrcweir bool NextButton::IsEnabled (void)
2025cdf0e10cSrcweir {
2026*87131587Smseidel 	// Because the buttons are both either enabled or disabled, it is
2027*87131587Smseidel 	// sufficient to ask one to determine the state.
2028*87131587Smseidel 	return maNextButton1.IsEnabled();
2029cdf0e10cSrcweir }
2030cdf0e10cSrcweir 
2031cdf0e10cSrcweir 
2032cdf0e10cSrcweir 
2033cdf0e10cSrcweir 
Enable(bool bEnable)2034cdf0e10cSrcweir void NextButton::Enable (bool bEnable)
2035cdf0e10cSrcweir {
2036*87131587Smseidel 	// Enable or disable both buttons but do not change visibility or focus.
2037*87131587Smseidel 	maNextButton1.Enable(bEnable);
2038*87131587Smseidel 	maNextButton2.Enable(bEnable);
2039cdf0e10cSrcweir }
2040*87131587Smseidel 
2041*87131587Smseidel /* vim: set noet sw=4 ts=4: */
2042