merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / dlg / dlgass.cxx
blobd20b57cdead4c303d96cbe354d0e19ada848a916
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dlgass.cxx,v $
10 * $Revision: 1.47 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #ifdef SD_DLLIMPLEMENTATION
35 #undef SD_DLLIMPLEMENTATION
36 #endif
37 #include <com/sun/star/presentation/ClickAction.hpp>
38 #include <vcl/svapp.hxx>
39 #include <vos/mutex.hxx>
40 #include <vcl/msgbox.hxx>
41 #include <vcl/lstbox.hxx>
42 #include <vcl/combobox.hxx>
43 #include <sfx2/doctempl.hxx>
44 #include <svtools/lstner.hxx>
45 #include <sfx2/objsh.hxx>
46 #include <svtools/ehdl.hxx>
47 #include <svtools/sfxecode.hxx>
48 #include <tools/urlobj.hxx>
49 #include <com/sun/star/presentation/FadeEffect.hpp>
50 #include <fadedef.h>
51 #include <sfx2/sfxsids.hrc>
52 #include <svtools/undo.hxx>
53 #include "DrawDocShell.hxx"
54 #include <vcl/gdimtf.hxx>
55 #include <vcl/wintypes.hxx>
56 #include "docprev.hxx"
57 #include <sfx2/app.hxx>
58 #include <sfx2/docfile.hxx>
59 #include <sfx2/dispatch.hxx>
60 #include <sfx2/request.hxx>
61 #include <com/sun/star/sdbc/XResultSet.hpp>
62 #include <com/sun/star/lang/XComponent.hpp>
63 #include <com/sun/star/util/XCloseable.hpp>
64 #include <com/sun/star/uno/RuntimeException.hpp>
65 #include <com/sun/star/frame/XModuleManager.hpp>
66 #include <com/sun/star/ucb/XSimpleFileAccess.hpp>
67 #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
68 #include <com/sun/star/ui/XImageManager.hpp>
69 #include <svtools/historyoptions.hxx>
70 #include <tools/urlobj.hxx>
71 #include <osl/file.hxx>
72 #include <sfx2/filedlghelper.hxx>
74 #include "sdpage.hxx"
75 #include "helpids.h"
76 #include "assclass.hxx"
77 #include "dlgass.hrc"
78 #include "dlgass.hxx"
79 #include "dlgctrls.hxx"
80 #ifndef _SD_CFGID_HXX
81 #include "strings.hrc"
82 #endif
83 #ifndef _DATETIMEITEM_HXX
84 #include "dlgassim.hxx"
85 #endif
86 #include "TemplateScanner.hxx"
87 #include "WindowUpdater.hxx"
89 #include <comphelper/processfactory.hxx>
91 using namespace ::com::sun::star;
92 using namespace ::com::sun::star::uno;
93 using namespace ::sd;
96 void InterpolateFixedBitmap( FixedBitmap * pBitmap )
98 Bitmap aBmp( pBitmap->GetBitmap() );
99 Size aSize = pBitmap->GetSizePixel();
100 aBmp.Scale( aSize, BMP_SCALE_INTERPOLATE );
101 pBitmap->SetBitmap( aBmp );
105 // ====================================================================
106 // ====================================================================
108 UINT32 PageHelpIds[] =
110 HID_SD_AUTOPILOT_PAGE1,
111 HID_SD_AUTOPILOT_PAGE2,
112 HID_SD_AUTOPILOT_PAGE3,
113 HID_SD_AUTOPILOT_PAGE4,
114 HID_SD_AUTOPILOT_PAGE5
117 // ====================================================================
119 class PasswordEntry
121 public:
122 String maPassword;
123 String maPath;
126 DECLARE_LIST( PasswordEntryList, PasswordEntry * )
128 // ====================================================================
130 /** A simple wrapper that looks like a PushButton and is used to force the
131 broadcasting of focus events primarly for accessibility tools.
132 Forcing focus events is achieved by using two identical PushButtons
133 which, when the focus event is requested, are exchanged and play focus
134 ping-pong by moving the focus from one to the other.
136 class NextButton
138 public:
139 NextButton (::Window* pParent, const ResId& rResId);
141 void ForceFocusEventBroadcast (void);
142 void SetClickHdl (const Link& rLink);
143 bool IsEnabled (void);
144 void Enable (bool bEnable);
146 private:
147 PushButton maNextButton1;
148 PushButton maNextButton2;
149 bool mbIsFirstButtonActive;
154 // ====================================================================
156 class AssistentDlgImpl : public SfxListener
158 public:
159 AssistentDlgImpl( ::Window* pWindow, const Link& rFinishLink, BOOL bAutoPilot );
160 ~AssistentDlgImpl();
162 /// Local mutex used to serialize concurrent method calls.
163 ::osl::Mutex maMutex;
165 SfxObjectShellLock GetDocument();
167 /** closes the current preview docshell */
168 void CloseDocShell();
170 /** Extract form the history list of recently used files the impress
171 files and insert them into a listbox.
173 void ScanDocmenu (void);
174 /** Flag that is set to TRUE after the recently used files have been
175 scanned.
177 BOOL mbRecentDocumentsReady;
179 /** When the list of templates has not been scanned already this is done
180 when this method is called. That includes requesting the whole list
181 of templates from UCB and extracting from that list the impress
182 templates and layouts and storing them for later use in
183 <member>maPresentList</member>. Note that the first call to this
184 method after installing a new Office may take some time.
186 void ProvideTemplates (void);
188 /** This method transfers the template folders from the template scanner
189 to the internal structures of this class. On termination it sets
190 the flag <member>mbTemplatesReady</member> to <TRUE/> to indicate
191 that the templates are available.
192 @param rTemplateFolders
193 This is a list of template folders. This method takes ownership
194 of the supplied entries by removing them from the list and
195 transferring them to an internal structure.
197 void TemplateScanDone (std::vector<TemplateDir*>& rTemplateFolders);
199 /** Flag that is set to TRUE after the impress templates have been
200 scanned.
202 BOOL mbTemplatesReady;
204 /** Flag used to prevent nested or concurrent calls to the
205 <member>UpdatePreview</memember> method. A <TRUE/> value indicates
206 that a preview update is currently active.
208 BOOL mbPreviewUpdating;
210 ::Window* mpWindow;
212 void SavePassword( SfxObjectShellLock xDoc, const String& rPath );
213 void RestorePassword( SfxItemSet* pSet, const String& rPath );
214 String GetPassword( const String rPath );
215 void DeletePassords();
217 PasswordEntryList maPasswordList;
219 String maDocFile;
220 String maLayoutFile;
222 String GetDocFileName();
223 String GetLayoutFileName();
225 /// List of URLs of recently used impress files.
226 std::vector<String*> maOpenFilesList;
228 /// List of folders containing data about impress templates.
229 std::vector<TemplateDir*> maPresentList;
231 /// Currently selected template folder.
232 TemplateDir* mpTemplateRegion;
234 /// Currently selected layout folder.
235 TemplateDir* mpLayoutRegion;
237 // preview
238 BOOL mbUserDataDirty;
239 Timer maPrevTimer;
240 Timer maEffectPrevTimer;
241 Timer maUpdatePageListTimer;
242 Timer maStartScanTimer;
244 SfxObjectShellLock xDocShell;
246 ::std::auto_ptr<WindowUpdater> mpWindowUpdater;
248 BOOL mbPreview;
249 USHORT mnShowPage;
250 BOOL mbDocPreview;
252 ULONG mnTemplate;
254 String maPageListFile;
256 void UpdatePreview( BOOL bDocPreview );
257 void UpdatePageList();
258 void UpdateUserData();
260 BOOL IsOwnFormat( const String& rPath );
262 // dlg status
263 void EndDialog( long nResult = 0 );
265 void SetStartType( StartType eType );
266 StartType GetStartType();
268 void SelectTemplateRegion( const String& rRegion );
269 void SelectLayoutRegion( const String& rRegion );
271 void UpdatePage();
272 void ChangePage();
273 void LeavePage();
275 String GetUiTextForCommand (const ::rtl::OUString& aCommandURL);
276 Image GetUiIconForCommand (const ::rtl::OUString& aCommandURL);
278 DECL_LINK( StartScanHdl, void * );
279 DECL_LINK( SelectFileHdl, ListBox * );
280 DECL_LINK( SelectRegionHdl, ListBox * );
281 DECL_LINK( UpdatePreviewHdl, void * );
282 DECL_LINK( UpdatePageListHdl, void * );
283 DECL_LINK( StartTypeHdl, RadioButton * );
284 DECL_LINK( SelectTemplateHdl, ListBox * );
285 DECL_LINK( NextPageHdl, PushButton * );
286 DECL_LINK( LastPageHdl, PushButton * );
287 DECL_LINK( PreviewFlagHdl, CheckBox * );
288 DECL_LINK( EffectPreviewHdl, Button * );
289 DECL_LINK( SelectLayoutHdl, ListBox * );
290 DECL_LINK( PageSelectHdl, Control * );
291 DECL_LINK( PresTypeHdl, RadioButton * );
292 DECL_LINK( UpdateUserDataHdl, Edit* );
293 DECL_LINK( SelectEffectHdl, void* );
294 DECL_LINK( OpenButtonHdl, Button * );
296 // Common
297 Assistent maAssistentFunc;
298 CheckBox maPreviewFlag;
299 CheckBox maStartWithFlag;
300 HelpButton maHelpButton;
301 CancelButton maCancelButton;
302 PushButton maLastPageButton;
303 NextButton maNextPageButton;
304 OKButton maFinishButton;
305 SdDocPreviewWin maPreview;
307 String maCreateStr;
308 String maOpenStr;
310 // Seite 1
311 FixedBitmap* mpPage1FB;
312 FixedLine* mpPage1ArtFL;
313 RadioButton* mpPage1EmptyRB;
314 RadioButton* mpPage1TemplateRB;
315 ListBox* mpPage1RegionLB;
316 ListBox* mpPage1TemplateLB;
317 RadioButton* mpPage1OpenRB;
318 ListBox* mpPage1OpenLB;
319 PushButton* mpPage1OpenPB;
321 // Seite 2
322 FixedBitmap* mpPage2FB;
323 FixedLine* mpPage2LayoutFL;
324 ListBox* mpPage2RegionLB;
325 ListBox* mpPage2LayoutLB;
326 FixedLine* mpPage2OutTypesFL;
327 RadioButton* mpPage2Medium1RB;
328 RadioButton* mpPage2Medium2RB;
329 RadioButton* mpPage2Medium3RB;
330 RadioButton* mpPage2Medium4RB;
331 RadioButton* mpPage2Medium5RB;
333 // Seite 3
334 FixedBitmap* mpPage3FB;
335 FixedLine* mpPage3EffectFL;
336 FixedText* mpPage3EffectFT;
337 FadeEffectLB* mpPage3EffectLB;
338 FixedText* mpPage3SpeedFT;
339 ListBox* mpPage3SpeedLB;
340 FixedLine* mpPage3PresTypeFL;
341 RadioButton* mpPage3PresTypeLiveRB;
342 RadioButton* mpPage3PresTypeKioskRB;
343 FixedText* mpPage3PresTimeFT;
344 TimeField* mpPage3PresTimeTMF;
345 FixedText* mpPage3BreakFT;
346 TimeField* mpPage3BreakTMF;
347 CheckBox* mpPage3LogoCB;
349 // Seite 4
350 FixedBitmap* mpPage4FB;
351 FixedLine* mpPage4PersonalFL;
352 FixedText* mpPage4AskNameFT;
353 Edit* mpPage4AskNameEDT;
354 FixedText* mpPage4AskTopicFT;
355 Edit* mpPage4AskTopicEDT;
356 FixedText* mpPage4AskInfoFT;
357 MultiLineEdit* mpPage4AskInfoEDT;
359 // Seite 5
360 FixedBitmap* mpPage5FB;
361 FixedText* mpPage5PageListFT;
362 SdPageListControl* mpPage5PageListCT;
363 CheckBox* mpPage5SummaryCB;
369 // ====================================================================
371 AssistentDlgImpl::AssistentDlgImpl( ::Window* pWindow, const Link& rFinishLink, BOOL bAutoPilot ) :
372 mpTemplateRegion(NULL),
373 mpLayoutRegion(NULL),
374 mbUserDataDirty(FALSE),
375 xDocShell (NULL),
376 mpWindowUpdater (new WindowUpdater()),
377 mbPreview(TRUE),
378 mnShowPage(0),
379 mbDocPreview(FALSE),
380 maAssistentFunc(5),
381 maPreviewFlag(pWindow,SdResId(CB_PREVIEW)),
382 maStartWithFlag(pWindow,SdResId(CB_STARTWITH)),
383 maHelpButton(pWindow,SdResId(BUT_HELP)),
384 maCancelButton(pWindow,SdResId(BUT_CANCEL)),
385 maLastPageButton(pWindow,SdResId(BUT_LAST)),
386 maNextPageButton(pWindow,SdResId(BUT_NEXT)),
387 maFinishButton(pWindow,SdResId(BUT_FINISH)),
388 maPreview(pWindow,SdResId(CT_PREVIEW)),
389 maCreateStr(SdResId(STR_CREATE)),
390 maOpenStr(SdResId(STR_OPEN))
392 maPageListFile += sal_Unicode('?'),
393 mbRecentDocumentsReady = FALSE;
394 mbTemplatesReady = FALSE;
395 mbPreviewUpdating = FALSE;
397 mpWindow = pWindow;
399 if(bAutoPilot)
400 maStartWithFlag.Hide();
401 else
402 maAssistentFunc.InsertControl(1, &maStartWithFlag );
404 //page1 wird initialisiert und an die Assistentenfunktionalitaet
405 //uebergeben
406 maAssistentFunc.InsertControl(1, &maPreview );
407 maAssistentFunc.InsertControl(1, &maPreviewFlag );
408 maAssistentFunc.InsertControl(1,
409 mpPage1FB = new FixedBitmap(pWindow,SdResId(FB_PAGE1)));
410 maAssistentFunc.InsertControl(1,
411 mpPage1ArtFL = new FixedLine(pWindow,SdResId(FL_PAGE1_ARTGROUP)));
412 maAssistentFunc.InsertControl(1,
413 mpPage1EmptyRB=new RadioButton(pWindow,SdResId(RB_PAGE1_EMPTY)));
414 maAssistentFunc.InsertControl(1,
415 mpPage1TemplateRB=new RadioButton(pWindow,SdResId(RB_PAGE1_TEMPLATE)));
416 maAssistentFunc.InsertControl(1,
417 mpPage1OpenRB=new RadioButton(pWindow,SdResId(RB_PAGE1_OPEN)));
418 maAssistentFunc.InsertControl(1,
419 mpPage1RegionLB = new ListBox(pWindow,SdResId(LB_PAGE1_REGION)));
420 maAssistentFunc.InsertControl(1,
421 mpPage1TemplateLB=new ListBox(pWindow,SdResId(LB_PAGE1_TEMPLATES)));
422 maAssistentFunc.InsertControl(1,
423 mpPage1OpenPB=new PushButton(pWindow,SdResId(PB_PAGE1_OPEN)));
424 maAssistentFunc.InsertControl(1,
425 mpPage1OpenLB=new ListBox(pWindow,SdResId(LB_PAGE1_OPEN)));
427 // Align the button and list box displayed for the "open existing file"
428 // radio button with the text of that radio button.
430 RadioButton aEmptyRB (mpWindow);
431 sal_Int32 nIndent (aEmptyRB.CalcMinimumSize(0).Width());
432 sal_Int32 nLeft (mpPage1OpenRB->GetPosPixel().X() + nIndent);
433 sal_Int32 nWidth (mpPage1OpenRB->GetSizePixel().Width() - nIndent);
434 mpPage1OpenPB->SetPosSizePixel(
435 Point(nLeft, mpPage1OpenPB->GetPosPixel().Y()),
436 Size(mpPage1OpenPB->GetSizePixel()));
437 mpPage1OpenLB->SetPosSizePixel(
438 Point(nLeft, mpPage1OpenLB->GetPosPixel().Y()),
439 Size(nWidth, mpPage1OpenLB->GetSizePixel().Height()));
442 // Set text and icon of the 'Open...' button.
444 String sText (GetUiTextForCommand(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:Open"))));
445 // Remove the mnemonic and add a leading space so that icon and text
446 // are not too close together.
447 sText.SearchAndReplaceAll(String(RTL_CONSTASCII_STRINGPARAM("~")),String());
448 sText.Insert(String(RTL_CONSTASCII_STRINGPARAM(" ")),0);
449 mpPage1OpenPB->SetText(sText);
450 // Place icon left of text and both centered in the button.
451 mpPage1OpenPB->SetModeImage(
452 GetUiIconForCommand(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:Open"))),
453 BMP_COLOR_NORMAL);
454 mpPage1OpenPB->EnableImageDisplay(TRUE);
455 mpPage1OpenPB->EnableTextDisplay(TRUE);
456 mpPage1OpenPB->SetImageAlign(IMAGEALIGN_LEFT);
457 mpPage1OpenPB->SetStyle(mpPage1OpenPB->GetStyle() | WB_CENTER);
460 // links&handler
461 mpPage1RegionLB->SetSelectHdl(LINK(this,AssistentDlgImpl,SelectRegionHdl));
462 mpPage1RegionLB->SetDropDownLineCount( 6 );
463 mpPage1TemplateLB->SetSelectHdl(LINK(this,AssistentDlgImpl,SelectTemplateHdl));
464 mpPage1TemplateLB->InsertEntry(String(SdResId(STR_ISLOADING)));
466 mpPage1EmptyRB->SetClickHdl(LINK(this,AssistentDlgImpl,StartTypeHdl));
467 mpPage1TemplateRB->SetClickHdl(LINK(this,AssistentDlgImpl,StartTypeHdl));
468 mpPage1OpenRB->SetClickHdl(LINK(this,AssistentDlgImpl,StartTypeHdl));
469 mpPage1OpenLB->SetSelectHdl(LINK(this,AssistentDlgImpl,SelectFileHdl));
470 mpPage1OpenLB->SetDoubleClickHdl(rFinishLink);
471 mpPage1OpenPB->SetClickHdl(LINK(this,AssistentDlgImpl,OpenButtonHdl));
472 // mpPage1OpenLB->InsertEntry(String(SdResId(STR_WIZARD_POSITION)));
474 // Seite 2
475 maAssistentFunc.InsertControl(2, &maPreview );
476 maAssistentFunc.InsertControl(2, &maPreviewFlag );
477 maAssistentFunc.InsertControl(2,
478 mpPage2FB = new FixedBitmap(pWindow,SdResId(FB_PAGE2)));
479 maAssistentFunc.InsertControl(2,
480 mpPage2LayoutFL = new FixedLine( pWindow, SdResId(FL_PAGE2_LAYOUT) ));
481 maAssistentFunc.InsertControl(2,
482 mpPage2RegionLB = new ListBox(pWindow,SdResId(LB_PAGE2_REGION) ));
483 maAssistentFunc.InsertControl(2,
484 mpPage2LayoutLB = new ListBox(pWindow,SdResId(LB_PAGE2_LAYOUT) ));
486 maAssistentFunc.InsertControl(2,
487 mpPage2OutTypesFL = new FixedLine( pWindow, SdResId(FL_PAGE2_OUTPUTTYPES) ));
488 maAssistentFunc.InsertControl(2,
489 mpPage2Medium5RB = new RadioButton( pWindow, SdResId(RB_PAGE2_MEDIUM5) ));
490 maAssistentFunc.InsertControl(2,
491 mpPage2Medium3RB = new RadioButton( pWindow, SdResId(RB_PAGE2_MEDIUM3) ));
492 maAssistentFunc.InsertControl(2,
493 mpPage2Medium4RB = new RadioButton( pWindow, SdResId(RB_PAGE2_MEDIUM4) ));
494 maAssistentFunc.InsertControl(2,
495 mpPage2Medium1RB = new RadioButton( pWindow, SdResId(RB_PAGE2_MEDIUM1) ));
496 maAssistentFunc.InsertControl(2,
497 mpPage2Medium2RB = new RadioButton( pWindow, SdResId(RB_PAGE2_MEDIUM2) ));
498 mpPage2Medium5RB->Check();
500 mpPage2RegionLB->SetSelectHdl(LINK(this,AssistentDlgImpl,SelectRegionHdl));
501 mpPage2RegionLB->SetDropDownLineCount( 6 );
502 mpPage2LayoutLB->SetSelectHdl(LINK(this,AssistentDlgImpl,SelectLayoutHdl));
503 mpPage2LayoutLB->InsertEntry(String(SdResId(STR_ISLOADING)));
505 // Seite 3
506 maAssistentFunc.InsertControl(3, &maPreview );
507 maAssistentFunc.InsertControl(3, &maPreviewFlag );
508 maAssistentFunc.InsertControl(3,
509 mpPage3FB = new FixedBitmap(pWindow,SdResId(FB_PAGE3)));
510 maAssistentFunc.InsertControl(3,
511 mpPage3EffectFL = new FixedLine( pWindow, SdResId(FL_PAGE3_EFFECT) ));
512 maAssistentFunc.InsertControl(3,
513 mpPage3EffectFT = new FixedText( pWindow, SdResId(FT_PAGE3_EFFECT) ));
514 maAssistentFunc.InsertControl(3,
515 mpPage3EffectLB = new FadeEffectLB( pWindow, SdResId(LB_PAGE3_EFFECT) ));
516 maAssistentFunc.InsertControl(3,
517 mpPage3SpeedFT = new FixedText( pWindow, SdResId(FT_PAGE3_SPEED) ));
518 maAssistentFunc.InsertControl(3,
519 mpPage3SpeedLB = new FadeEffectLB( pWindow, SdResId(LB_PAGE3_SPEED) ));
520 maAssistentFunc.InsertControl(3,
521 mpPage3PresTypeFL = new FixedLine( pWindow, SdResId(FL_PAGE3_PRESTYPE) ));
522 maAssistentFunc.InsertControl(3,
523 mpPage3PresTypeLiveRB = new RadioButton( pWindow, SdResId(RB_PAGE3_LIVE) ));
524 maAssistentFunc.InsertControl(3,
525 mpPage3PresTypeKioskRB = new RadioButton( pWindow, SdResId(RB_PAGE3_KIOSK) ));
526 maAssistentFunc.InsertControl(3,
527 mpPage3PresTimeFT = new FixedText( pWindow, SdResId( FT_PAGE3_TIME) ));
528 maAssistentFunc.InsertControl(3,
529 mpPage3PresTimeTMF = new TimeField( pWindow, SdResId( TMF_PAGE3_TIME) ));
530 maAssistentFunc.InsertControl(3,
531 mpPage3BreakFT = new FixedText( pWindow, SdResId( FT_PAGE3_BREAK) ));
532 maAssistentFunc.InsertControl(3,
533 mpPage3BreakTMF = new TimeField( pWindow, SdResId( TMF_PAGE3_BREAK) ));
534 maAssistentFunc.InsertControl(3,
535 mpPage3LogoCB = new CheckBox( pWindow, SdResId( CB_PAGE3_LOGO) ));
537 mpPage3EffectLB->Fill();
538 // mpPage3EffectLB->SelectEffect( presentation::FadeEffect_NONE );
539 mpPage3EffectLB->SetSelectHdl( LINK(this,AssistentDlgImpl,SelectEffectHdl ));
540 mpPage3EffectLB->SetDropDownLineCount( 12 );
542 mpPage3SpeedLB->InsertEntry( String( SdResId(STR_SLOW) ));
543 mpPage3SpeedLB->InsertEntry( String( SdResId(STR_MEDIUM) ));
544 mpPage3SpeedLB->InsertEntry( String( SdResId(STR_FAST) ));
545 mpPage3SpeedLB->SetDropDownLineCount( 3 );
546 mpPage3SpeedLB->SetSelectHdl( LINK(this,AssistentDlgImpl,SelectEffectHdl ));
547 mpPage3SpeedLB->SelectEntryPos( 1 );
549 mpPage3PresTypeLiveRB->Check();
550 mpPage3PresTypeLiveRB->SetClickHdl( LINK(this,AssistentDlgImpl, PresTypeHdl ));
551 mpPage3PresTypeKioskRB->SetClickHdl( LINK(this,AssistentDlgImpl, PresTypeHdl ));
552 mpPage3PresTimeTMF->SetFormat( TIMEF_SEC );
553 mpPage3PresTimeTMF->SetTime( Time( 0, 0, 10 ) );
554 mpPage3BreakTMF->SetFormat( TIMEF_SEC );
555 mpPage3BreakTMF->SetTime( Time( 0, 0, 10 ) );
556 mpPage3LogoCB->Check();
558 // set cursor in timefield
559 Edit *pEditPage3PresTimeTMF = mpPage3PresTimeTMF->GetField();
560 Edit *pEditPage3BreakTMF = mpPage3BreakTMF->GetField();
561 Selection aSel1( pEditPage3PresTimeTMF->GetMaxTextLen(), pEditPage3PresTimeTMF->GetMaxTextLen() );
562 Selection aSel2( pEditPage3BreakTMF->GetMaxTextLen(), pEditPage3BreakTMF->GetMaxTextLen() );
563 pEditPage3PresTimeTMF->SetSelection( aSel1 );
564 pEditPage3BreakTMF->SetSelection( aSel2 );
566 // Seite 4
567 maAssistentFunc.InsertControl(4,
568 mpPage4FB = new FixedBitmap(pWindow,SdResId(FB_PAGE4)));
569 maAssistentFunc.InsertControl(4,
570 mpPage4PersonalFL = new FixedLine( pWindow, SdResId(FL_PAGE4_PERSONAL) ));
571 maAssistentFunc.InsertControl(4,
572 mpPage4AskNameFT = new FixedText( pWindow, SdResId(FT_PAGE4_ASKNAME) ));
573 maAssistentFunc.InsertControl(4,
574 mpPage4AskNameEDT = new Edit( pWindow, SdResId(EDT_PAGE4_ASKNAME) ));
575 maAssistentFunc.InsertControl(4,
576 mpPage4AskTopicFT= new FixedText( pWindow, SdResId(FT_PAGE4_ASKTOPIC) ));
577 maAssistentFunc.InsertControl(4,
578 mpPage4AskTopicEDT = new Edit( pWindow, SdResId(EDT_PAGE4_ASKTOPIC) ));
579 maAssistentFunc.InsertControl(4,
580 mpPage4AskInfoFT = new FixedText( pWindow, SdResId(FT_PAGE4_ASKINFORMATION) ));
581 maAssistentFunc.InsertControl(4,
582 mpPage4AskInfoEDT = new MultiLineEdit( pWindow, SdResId(EDT_PAGE4_ASKINFORMATION) ));
584 mpPage4AskNameEDT->SetModifyHdl(LINK(this,AssistentDlgImpl,UpdateUserDataHdl));
585 mpPage4AskTopicEDT->SetModifyHdl(LINK(this,AssistentDlgImpl,UpdateUserDataHdl));
586 mpPage4AskInfoEDT->SetModifyHdl(LINK(this,AssistentDlgImpl,UpdateUserDataHdl));
588 // page 5
589 maAssistentFunc.InsertControl(5, &maPreview );
590 maAssistentFunc.InsertControl(5, &maPreviewFlag );
591 maAssistentFunc.InsertControl(5,
592 mpPage5FB = new FixedBitmap(pWindow,SdResId(FB_PAGE5)));
593 maAssistentFunc.InsertControl(5,
594 mpPage5PageListFT = new FixedText( pWindow, SdResId( FT_PAGE5_PAGELIST ) ));
595 maAssistentFunc.InsertControl(5,
596 mpPage5PageListCT = new SdPageListControl( pWindow, SdResId( CT_PAGE5_PAGELIST ) ));
597 maAssistentFunc.InsertControl(5,
598 mpPage5SummaryCB = new CheckBox( pWindow, SdResId( CB_PAGE5_SUMMARY ) ));
600 mpPage5PageListCT->SetSelectHdl(LINK(this,AssistentDlgImpl, PageSelectHdl));
603 // generell
604 InterpolateFixedBitmap( mpPage1FB );
605 InterpolateFixedBitmap( mpPage2FB );
606 InterpolateFixedBitmap( mpPage3FB );
607 InterpolateFixedBitmap( mpPage4FB );
608 InterpolateFixedBitmap( mpPage5FB );
610 maLastPageButton.SetClickHdl(LINK(this,AssistentDlgImpl, LastPageHdl ));
611 maNextPageButton.SetClickHdl(LINK(this,AssistentDlgImpl, NextPageHdl ));
613 maPreviewFlag.Check( mbPreview );
614 maPreviewFlag.SetClickHdl(LINK(this, AssistentDlgImpl, PreviewFlagHdl ));
615 maPreview.SetClickHdl(LINK(this,AssistentDlgImpl, EffectPreviewHdl ));
617 //setzt die Ausgangsseite
618 maAssistentFunc.GotoPage(1);
619 maLastPageButton.Disable();
621 maPrevTimer.SetTimeout( 200 );
622 maPrevTimer.SetTimeoutHdl( LINK( this, AssistentDlgImpl, UpdatePreviewHdl));
624 maEffectPrevTimer.SetTimeout( 50 );
625 maEffectPrevTimer.SetTimeoutHdl( LINK( this, AssistentDlgImpl, EffectPreviewHdl ));
627 maUpdatePageListTimer.SetTimeout( 50 );
628 maUpdatePageListTimer.SetTimeoutHdl( LINK( this, AssistentDlgImpl, UpdatePageListHdl));
630 SetStartType( ST_EMPTY );
632 ChangePage();
634 mpWindowUpdater->RegisterWindow (&maPreview);
636 UpdatePreview( TRUE );
638 //check wether we should start with a template document initialy and preselect it
639 const ::rtl::OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.PresentationDocument" ) );
640 String aStandardTemplate( SfxObjectFactory::GetStandardTemplate( aServiceName ) );
641 if( aStandardTemplate.Len() )
643 ProvideTemplates();
645 //find aStandardTemplate in maPresentList
646 TemplateDir* pStandardTemplateDir = 0;
647 TemplateEntry* pStandardTemplateEntry = 0;
649 std::vector<TemplateDir*>::iterator I;
650 for (I=maPresentList.begin(); I!=maPresentList.end(); I++)
652 TemplateDir* pDir = *I;
653 std::vector<TemplateEntry*>::iterator J;
654 for (J=pDir->maEntries.begin(); J!=pDir->maEntries.end(); J++)
656 TemplateEntry* pEntry = *J;
657 if(pEntry->msPath == aStandardTemplate)
659 pStandardTemplateDir = pDir;
660 pStandardTemplateEntry = pEntry;
661 break;
664 if(pStandardTemplateDir)
665 break;
668 //preselect template
669 if( pStandardTemplateDir && pStandardTemplateEntry )
671 mpPage1RegionLB->SelectEntry( pStandardTemplateDir->msRegion );
672 SelectTemplateRegion( pStandardTemplateDir->msRegion );
673 mpPage1TemplateLB->SelectEntry( pStandardTemplateEntry->msTitle );
674 SelectTemplateHdl(mpPage1TemplateLB);
682 AssistentDlgImpl::~AssistentDlgImpl()
684 CloseDocShell();
686 DeletePassords();
688 // Delete the template file infos.
689 std::vector<TemplateDir*>::iterator I;
690 std::vector<TemplateEntry*>::iterator J;
691 for (I=maPresentList.begin(); I!=maPresentList.end(); I++)
693 for (J=(*I)->maEntries.begin(); J!=(*I)->maEntries.end(); J++)
694 delete (*J);
695 delete (*I);
698 // Seite 1
699 delete mpPage1FB;
700 delete mpPage1ArtFL;
701 delete mpPage1EmptyRB;
702 delete mpPage1TemplateRB;
703 delete mpPage1TemplateLB;
704 delete mpPage1RegionLB;
705 delete mpPage1OpenRB;
706 delete mpPage1OpenLB;
707 delete mpPage1OpenPB;
709 // Seite 2
710 delete mpPage2FB;
711 delete mpPage2LayoutFL;
712 delete mpPage2RegionLB;
713 delete mpPage2LayoutLB;
714 delete mpPage2OutTypesFL;
715 delete mpPage2Medium1RB;
716 delete mpPage2Medium2RB;
717 delete mpPage2Medium3RB;
718 delete mpPage2Medium4RB;
719 delete mpPage2Medium5RB;
721 // Seite 3
722 delete mpPage3FB;
723 delete mpPage3EffectFL;
724 delete mpPage3EffectFT;
725 delete mpPage3EffectLB;
726 delete mpPage3SpeedFT;
727 delete mpPage3SpeedLB;
728 delete mpPage3PresTypeFL;
729 delete mpPage3PresTypeLiveRB;
730 delete mpPage3PresTypeKioskRB;
731 delete mpPage3PresTimeFT;
732 delete mpPage3PresTimeTMF;
733 delete mpPage3BreakFT;
734 delete mpPage3BreakTMF;
735 delete mpPage3LogoCB;
737 // Seite 4
738 delete mpPage4FB;
739 delete mpPage4PersonalFL;
740 delete mpPage4AskNameFT;
741 delete mpPage4AskNameEDT;
742 delete mpPage4AskTopicFT;
743 delete mpPage4AskTopicEDT;
744 delete mpPage4AskInfoFT;
745 delete mpPage4AskInfoEDT;
747 // Seite 5
748 delete mpPage5FB;
749 delete mpPage5PageListFT;
750 delete mpPage5PageListCT;
751 delete mpPage5SummaryCB;
753 // Delete the file history list.
754 std::vector<String*>::iterator I2;
755 for (I2=maOpenFilesList.begin(); I2!=maOpenFilesList.end(); I2++)
756 delete *I2;
759 void AssistentDlgImpl::CloseDocShell()
761 if(xDocShell.Is())
763 //uno::Reference< lang::XComponent > xModel( xDocShell->GetModel(), uno::UNO_QUERY );
764 uno::Reference< util::XCloseable > xCloseable( xDocShell->GetModel(), uno::UNO_QUERY );
765 //if( xModel.is() )
766 if( xCloseable.is() )
768 xCloseable->close( sal_True );
769 xDocShell = NULL;
770 //xModel->dispose();
772 else
774 xDocShell->DoClose();
775 xDocShell = NULL;
780 void AssistentDlgImpl::EndDialog( long )
782 mpWindow = NULL;
788 void AssistentDlgImpl::ScanDocmenu (void)
790 if( mbRecentDocumentsReady )
791 return;
793 uno::Sequence<uno::Sequence<beans::PropertyValue> > aHistory =
794 SvtHistoryOptions().GetList (ePICKLIST);
796 uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
797 uno::Reference< container::XNameAccess > xFilterFactory( xFactory->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.FilterFactory" ) ) ), uno::UNO_QUERY );
799 Reference< ::com::sun::star::ucb::XSimpleFileAccess > xFileAccess(
800 xFactory->createInstance(
801 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess"))),
802 UNO_QUERY_THROW);
804 sal_uInt32 nCount = aHistory.getLength();
805 for (sal_uInt32 nItem=0; nItem<nCount; ++nItem)
807 // Get the current history item's properties.
808 uno::Sequence<beans::PropertyValue> aPropertySet = aHistory[nItem];
809 rtl::OUString sURL;
810 rtl::OUString sFilter;
811 rtl::OUString sTitle;
812 rtl::OUString sPassword;
813 sal_uInt32 nPropertyCount = aPropertySet.getLength();
814 for (sal_uInt32 nProperty=0; nProperty<nPropertyCount; ++nProperty)
815 if (aPropertySet[nProperty].Name == HISTORY_PROPERTYNAME_URL)
816 aPropertySet[nProperty].Value >>= sURL;
817 else if (aPropertySet[nProperty].Name == HISTORY_PROPERTYNAME_FILTER)
818 aPropertySet[nProperty].Value >>= sFilter;
819 else if (aPropertySet[nProperty].Name == HISTORY_PROPERTYNAME_TITLE)
820 aPropertySet[nProperty].Value >>= sTitle;
821 else if (aPropertySet[nProperty].Name == HISTORY_PROPERTYNAME_PASSWORD)
822 aPropertySet[nProperty].Value >>= sPassword;
824 // If the entry is an impress file then insert it into the
825 // history list and the list box.
826 uno::Sequence< beans::PropertyValue > lProps;
827 if (xFilterFactory->hasByName(sFilter))
829 uno::Any aFilterPropSet = xFilterFactory->getByName( sFilter );
830 aFilterPropSet >>= lProps;
833 sal_Int32 nPropCount = lProps.getLength();
834 rtl::OUString sFactoryName;
835 for( sal_Int32 i=0; i<nPropCount; ++i )
837 if( lProps[i].Name.compareToAscii( "DocumentService" ) == 0 &&
838 (lProps[i].Value >>= sFactoryName) &&
839 sFactoryName.compareToAscii( "com.sun.star.presentation.PresentationDocument" ) == 0 )
841 // yes, it's an impress document
842 INetURLObject aURL;
844 // Do not include the file if it does not exist.
845 if (xFileAccess.is() && ! xFileAccess->exists(sURL))
846 continue;
848 aURL.SetSmartURL (sURL);
849 // The password is set only when it is not empty.
850 if (sPassword.getLength() > 0)
851 aURL.SetPass (sPassword);
852 maOpenFilesList.push_back (new String (aURL.GetMainURL( INetURLObject::NO_DECODE )));
853 mpPage1OpenLB->InsertEntry (sTitle);
854 break;
858 mbRecentDocumentsReady = TRUE;
861 UpdatePreview(TRUE);
863 catch (uno::RuntimeException& )
865 // Ignore all exceptions.
871 void AssistentDlgImpl::ProvideTemplates (void)
873 if ( ! mbTemplatesReady)
875 TemplateScanner aScanner;
876 aScanner.Scan ();
877 TemplateScanDone (aScanner.GetFolderList());
881 UpdatePreview(TRUE);
883 catch (uno::RuntimeException& e)
885 // Ignore all exceptions.
886 (void) e;
891 void AssistentDlgImpl::TemplateScanDone (
892 std::vector<TemplateDir*>& rTemplateFolder)
894 // This method is called from a thread. Therefore we get the solar mutex.
895 ::vos::OGuard aGuard (Application::GetSolarMutex());
897 // Copy the contents of the given template folders to a local list.
898 maPresentList.swap (rTemplateFolder);
900 // Fill in the list box on the first page.
901 int nFirstEntry = 0;
902 mpPage1RegionLB->Clear();
903 std::vector<TemplateDir*>::iterator I;
904 int i;
905 for (i=0,I=maPresentList.begin(); I!=maPresentList.end(); I++,i++)
907 TemplateDir* pDir = *I;
908 if (pDir == NULL)
909 continue;
911 // HACK! presnt directory is always initially selected.
912 // We have to look at the first entry to get a URL.
913 if (pDir->maEntries.size() > 0)
915 TemplateEntry* pEntry = pDir->maEntries.front();
916 if (pEntry != NULL)
917 if (pEntry->msPath.SearchAscii("presnt") != STRING_NOTFOUND)
918 nFirstEntry = i;
921 mpPage1RegionLB->InsertEntry (pDir->msRegion);
923 mpPage1RegionLB->SelectEntryPos ((USHORT)nFirstEntry);
924 mpPage1RegionLB->Update();
925 SelectTemplateRegion (mpPage1RegionLB->GetSelectEntry());
927 // Fill in the list box on the second page.
928 nFirstEntry = 0;
929 mpPage2RegionLB->Clear();
930 for (i=0,I=maPresentList.begin(); I!=maPresentList.end(); I++,i++)
932 TemplateDir* pDir = *I;
933 if (pDir == NULL)
934 continue;
936 // HACK! layout directory is always initially selected.
937 // We have to look at the first entry to get a URL.
938 if (pDir->maEntries.size() > 0)
940 TemplateEntry* pEntry = pDir->maEntries.front();
941 if (pEntry != NULL)
942 if (pEntry->msPath.SearchAscii("layout") != STRING_NOTFOUND)
943 nFirstEntry = i;
946 mpPage2RegionLB->InsertEntry (pDir->msRegion);
948 mpPage2RegionLB->SelectEntryPos ((USHORT)nFirstEntry);
949 mpPage2RegionLB->Update();
950 SelectLayoutRegion (mpPage2RegionLB->GetSelectEntry());
952 // Make the changes visible.
953 mbTemplatesReady = TRUE;
954 if (mpWindow)
955 UpdatePage();
961 // ********************************************************************
962 // Status Methoden
963 // ********************************************************************
965 void AssistentDlgImpl::SetStartType( StartType eType )
967 mpPage1EmptyRB->SetState( eType == ST_EMPTY );
968 mpPage1TemplateRB->SetState( eType == ST_TEMPLATE );
969 mpPage1OpenRB->SetState( eType == ST_OPEN );
970 maNextPageButton.Enable( eType != ST_OPEN );
972 mpPage1RegionLB->Show(eType == ST_TEMPLATE);
973 mpPage1TemplateLB->Show(eType == ST_TEMPLATE);
974 mpPage1OpenLB->Show(eType == ST_OPEN);
975 mpPage1OpenPB->Show(eType == ST_OPEN);
977 if (eType == ST_OPEN)
978 maFinishButton.SetText(maOpenStr);
979 else
980 maFinishButton.SetText(maCreateStr);
983 StartType AssistentDlgImpl::GetStartType()
985 if( mpPage1EmptyRB->IsChecked() )
986 return ST_EMPTY;
987 else if( mpPage1TemplateRB->IsChecked() )
988 return ST_TEMPLATE;
989 else
990 return ST_OPEN;
993 String AssistentDlgImpl::GetDocFileName()
995 String aTitle;
996 if(mpWindow)
998 aTitle = mpWindow->GetText();
999 USHORT nPos = aTitle.Search(sal_Unicode('('));
1000 if(nPos != STRING_NOTFOUND)
1001 aTitle.Erase( nPos-1 );
1004 String aDocFile;
1005 if( GetStartType() == ST_TEMPLATE )
1007 const USHORT nEntry = mpPage1TemplateLB->GetSelectEntryPos();
1008 TemplateEntry* pEntry = NULL;
1009 if(nEntry != (USHORT)-1)
1010 pEntry = mpTemplateRegion->maEntries[nEntry];
1012 if(pEntry)
1014 aDocFile = pEntry->msPath;
1016 aTitle.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " (" ) );
1017 aTitle.Append( pEntry->msTitle );
1018 aTitle.Append( sal_Unicode(')') );
1021 else if( GetStartType() == ST_OPEN )
1023 const USHORT nEntry = mpPage1OpenLB->GetSelectEntryPos();
1024 if(nEntry != (USHORT)-1 )
1025 aDocFile = *maOpenFilesList[nEntry];
1028 if(mpWindow)
1029 mpWindow->SetText(aTitle);
1031 return aDocFile;
1034 String AssistentDlgImpl::GetLayoutFileName()
1036 String aFile;
1037 const USHORT nEntry = mpPage2LayoutLB->GetSelectEntryPos();
1038 TemplateEntry* pEntry = NULL;
1039 if(nEntry != (USHORT)-1 && nEntry > 0)
1040 pEntry = mpLayoutRegion->maEntries[nEntry-1];
1042 if(pEntry)
1043 aFile = pEntry->msPath;
1045 return aFile;
1048 SfxObjectShellLock AssistentDlgImpl::GetDocument()
1050 // mbPreview = FALSE; // Document nicht anzeigen
1051 UpdatePreview(FALSE); // aber komplett laden
1052 UpdatePageList();
1054 SfxObjectShell* pShell = xDocShell;
1055 ::sd::DrawDocShell* pDocShell = PTR_CAST(::sd::DrawDocShell,pShell);
1056 SdDrawDocument* pDoc = pDocShell?pDocShell->GetDoc():NULL;
1058 if(pDoc)
1060 const USHORT nPageCount = pDoc->GetSdPageCount(PK_STANDARD);
1061 BOOL bKiosk = mpPage3PresTypeKioskRB->IsChecked();
1062 UINT32 nNewTime = (UINT32)mpPage3PresTimeTMF->GetTime().GetMSFromTime() / 1000;
1063 if(bKiosk)
1065 PresentationSettings& rSettings = pDoc->getPresentationSettings();
1066 rSettings.mbEndless = bKiosk;
1067 rSettings.mnPauseTimeout = (sal_Int32)mpPage3BreakTMF->GetTime().GetMSFromTime() / 1000;
1068 rSettings.mbShowPauseLogo = mpPage3LogoCB->IsChecked();
1071 USHORT nPgAbsNum = 0;
1072 USHORT nPgRelNum = 0;
1073 while( nPgAbsNum < nPageCount )
1075 SdPage* pPage = pDoc->GetSdPage( nPgRelNum, PK_STANDARD );
1076 if( mpPage5PageListCT->IsPageChecked(nPgAbsNum) )
1078 mpPage3EffectLB->applySelected(pPage);
1079 const sal_uInt16 nPos = mpPage3SpeedLB->GetSelectEntryPos();
1080 pPage->setTransitionDuration( (nPos == 0) ? 3.0 : (nPos == 1) ? 2.0 : 1.0 );
1081 if(bKiosk)
1083 pPage->SetPresChange( PRESCHANGE_AUTO );
1084 pPage->SetTime(nNewTime);
1086 nPgRelNum++;
1088 else
1090 // diese Seite loeschen
1091 pDoc->DeletePage( (nPgRelNum << 1) + 2 ); // Notizseite loeschen
1092 pDoc->DeletePage( (nPgRelNum << 1) + 1 ); // Seite loeschen
1095 nPgAbsNum++;
1098 else
1100 DBG_ERROR("sd::AssistentDlgImpl::GetDocument(), no template?");
1103 SfxObjectShellLock xRet = xDocShell;
1104 xDocShell = NULL;
1106 return xRet;
1109 void AssistentDlgImpl::LeavePage()
1111 int nPage = maAssistentFunc.GetCurrentPage();
1113 if( nPage == 4 && mbUserDataDirty )
1114 maPrevTimer.Start();
1117 void AssistentDlgImpl::ChangePage()
1119 maNextPageButton.Enable(!maAssistentFunc.IsLastPage());
1120 maLastPageButton.Enable(!maAssistentFunc.IsFirstPage());
1122 USHORT nPage = (USHORT)maAssistentFunc.GetCurrentPage();
1124 if( mpWindow )
1125 mpWindow->SetHelpId( PageHelpIds[nPage-1]);
1127 UpdatePage();
1129 if( maNextPageButton.IsEnabled() )
1131 maNextPageButton.ForceFocusEventBroadcast();
1133 else
1134 maFinishButton.GrabFocus();
1137 void AssistentDlgImpl::UpdatePage()
1139 USHORT nPage = (USHORT)maAssistentFunc.GetCurrentPage();
1141 switch(nPage)
1143 case 1:
1145 // Elemente auf der ersten Seite abhaengig vom Starttype Zeigen
1146 SetStartType( GetStartType() );
1147 mpPage1TemplateRB->Enable(TRUE /*mbTemplatesReady*/);
1148 break;
1151 case 2:
1153 mpPage2RegionLB->Enable(mbTemplatesReady);
1154 mpPage2LayoutLB->Enable(mbTemplatesReady);
1156 if( GetStartType() != ST_EMPTY )
1158 mpPage2Medium5RB->Enable( TRUE );
1160 else
1162 mpPage2Medium5RB->Enable( FALSE );
1163 if(mpPage2Medium5RB->IsChecked())
1164 mpPage2Medium1RB->Check();
1167 break;
1169 case 5:
1171 if(mbDocPreview || maPageListFile != maDocFile)
1172 mpPage5PageListCT->Clear();
1174 maUpdatePageListTimer.Start();
1175 break;
1178 case 3:
1180 if(GetStartType() != ST_TEMPLATE)
1181 maNextPageButton.Enable(false);
1183 BOOL bKiosk = mpPage3PresTypeKioskRB->IsChecked();
1184 mpPage3PresTimeFT->Enable(bKiosk);
1185 mpPage3BreakFT->Enable(bKiosk);
1186 mpPage3PresTimeTMF->Enable(bKiosk);
1187 mpPage3BreakTMF->Enable(bKiosk);
1188 mpPage3LogoCB->Enable(bKiosk);
1189 break;
1194 // ********************************************************************
1195 // UI-Handler
1196 // ********************************************************************
1198 IMPL_LINK( AssistentDlgImpl, SelectRegionHdl, ListBox *, pLB )
1200 if( pLB == mpPage1RegionLB )
1202 SelectTemplateRegion( pLB->GetSelectEntry() );
1203 SetStartType( ST_TEMPLATE );
1204 mpPage2Medium5RB->Check();
1206 else
1208 SelectLayoutRegion( pLB->GetSelectEntry() );
1211 return 0;
1214 IMPL_LINK( AssistentDlgImpl, SelectEffectHdl, void*, EMPTYARG )
1216 maEffectPrevTimer.Start();
1217 return 0;
1220 IMPL_LINK( AssistentDlgImpl, OpenButtonHdl, Button*, pButton )
1222 // Clear the selection and forward the call.
1223 mpPage1OpenLB->SetNoSelection();
1224 return mpPage1OpenLB->GetDoubleClickHdl().Call(pButton);
1227 IMPL_LINK( AssistentDlgImpl, EffectPreviewHdl, Button *, EMPTYARG )
1229 if(mbPreview && xDocShell.Is() )
1231 SfxObjectShell* pShell = xDocShell;
1232 DrawDocShell* pDocShell = dynamic_cast< DrawDocShell * >(pShell);
1233 if( pDocShell )
1235 SdDrawDocument* pDoc = pDocShell->GetDoc();
1236 if( pDoc )
1238 SdPage* pPage = pDoc->GetSdPage( mnShowPage, PK_STANDARD );
1239 if( pPage )
1240 mpPage3EffectLB->applySelected(pPage);
1243 maPreview.startPreview();
1245 return 0;
1248 IMPL_LINK( AssistentDlgImpl, PreviewFlagHdl, CheckBox *, EMPTYARG )
1251 if( maPreviewFlag.IsChecked() != mbPreview )
1253 mbPreview = maPreviewFlag.IsChecked();
1254 UpdatePreview(TRUE);
1256 return 0;
1259 IMPL_LINK( AssistentDlgImpl, SelectTemplateHdl, ListBox *, EMPTYARG )
1261 SetStartType( ST_TEMPLATE );
1262 mpPage2Medium5RB->Check();
1263 mpPage2LayoutLB->SelectEntryPos(0);
1264 maPrevTimer.Start();
1265 return 0;
1268 IMPL_LINK( AssistentDlgImpl, SelectLayoutHdl, ListBox *, EMPTYARG )
1270 maPrevTimer.Start();
1271 return 0;
1274 IMPL_LINK( AssistentDlgImpl, SelectFileHdl, ListBox *, EMPTYARG )
1276 SetStartType( ST_OPEN );
1277 maPrevTimer.Start();
1278 return 0;
1281 IMPL_LINK( AssistentDlgImpl, PageSelectHdl, Control *, EMPTYARG )
1283 USHORT nPage = mpPage5PageListCT->GetSelectedPage();
1284 if( mnShowPage != nPage )
1286 mnShowPage = nPage;
1287 UpdatePreview(FALSE);
1290 return 0;
1293 IMPL_LINK( AssistentDlgImpl, UpdatePageListHdl, void *, EMPTYARG )
1295 UpdatePageList();
1296 return 0;
1299 IMPL_LINK( AssistentDlgImpl, UpdatePreviewHdl, void *, EMPTYARG )
1301 UpdatePreview( TRUE );
1302 return 0;
1305 IMPL_LINK( AssistentDlgImpl, StartTypeHdl, RadioButton *, pButton )
1307 StartType eType = pButton == mpPage1EmptyRB?ST_EMPTY:pButton == mpPage1TemplateRB?ST_TEMPLATE:ST_OPEN;
1309 if(eType == ST_TEMPLATE)
1310 ProvideTemplates();
1311 else if(eType == ST_OPEN)
1312 ScanDocmenu();
1314 SetStartType( eType );
1316 if(eType == ST_TEMPLATE)
1318 mpPage1TemplateLB->SelectEntryPos(0);
1319 mpPage2Medium5RB->Check();
1321 else if(eType == ST_OPEN)
1322 mpPage1OpenLB->SelectEntryPos(0);
1324 maPrevTimer.Start();
1325 return 0;
1329 IMPL_LINK( AssistentDlgImpl, NextPageHdl, PushButton *, EMPTYARG )
1331 // When changing from the first to the second page make sure that the
1332 // templates are present.
1333 if (maAssistentFunc.GetCurrentPage() == 1)
1334 ProvideTemplates();
1336 // Change to the next page.
1337 LeavePage();
1338 maAssistentFunc.NextPage();
1339 ChangePage();
1340 return 0;
1343 IMPL_LINK( AssistentDlgImpl, LastPageHdl, PushButton *, EMPTYARG )
1345 LeavePage();
1346 maAssistentFunc.PreviousPage();
1347 ChangePage();
1348 return 0;
1351 IMPL_LINK( AssistentDlgImpl, PresTypeHdl, RadioButton*, EMPTYARG )
1353 if(maDocFile.Len() == 0)
1355 maNextPageButton.Enable(false);
1358 BOOL bKiosk = mpPage3PresTypeKioskRB->IsChecked();
1359 mpPage3PresTimeFT->Enable(bKiosk);
1360 mpPage3BreakFT->Enable(bKiosk);
1361 mpPage3PresTimeTMF->Enable(bKiosk);
1362 mpPage3BreakTMF->Enable(bKiosk);
1363 mpPage3LogoCB->Enable(bKiosk);
1364 return 0;
1367 IMPL_LINK( AssistentDlgImpl, UpdateUserDataHdl, Edit*, EMPTYARG )
1369 mbUserDataDirty = TRUE;
1370 String aTopic = mpPage4AskTopicEDT->GetText();
1371 String aName = mpPage4AskNameEDT->GetText();
1372 String aInfo = mpPage4AskInfoEDT->GetText();
1374 if(aTopic.Len() == 0 && aName.Len() == 0 && aInfo.Len() == 0)
1375 maDocFile.Erase();
1377 return 0;
1380 // ********************************************************************
1381 // ********************************************************************
1383 void AssistentDlgImpl::SelectTemplateRegion( const String& rRegion )
1385 mpPage1TemplateLB->Clear();
1386 std::vector<TemplateDir*>::iterator I;
1387 for (I=maPresentList.begin(); I!=maPresentList.end(); I++)
1389 TemplateDir * pDir = *I;
1390 mpTemplateRegion = *I;
1391 if (pDir->msRegion.Equals( rRegion ) )
1393 std::vector<TemplateEntry*>::iterator J;
1394 for (J=pDir->maEntries.begin(); J!=pDir->maEntries.end(); J++)
1395 mpPage1TemplateLB->InsertEntry ((*J)->msTitle);
1396 mpPage1TemplateLB->Update();
1397 if(GetStartType() == ST_TEMPLATE)
1399 mpPage1TemplateLB->SelectEntryPos( 0 );
1400 SelectTemplateHdl(NULL);
1402 break;
1407 void AssistentDlgImpl::SelectLayoutRegion( const String& rRegion )
1409 mpPage2LayoutLB->Clear();
1410 mpPage2LayoutLB->InsertEntry(String(SdResId(STR_WIZARD_ORIGINAL)));
1411 std::vector<TemplateDir*>::iterator I;
1412 for (I=maPresentList.begin(); I!=maPresentList.end(); I++)
1414 TemplateDir * pDir = *I;
1415 mpLayoutRegion = *I;
1417 if (pDir->msRegion.Equals (rRegion))
1419 std::vector<TemplateEntry*>::iterator J;
1420 for (J=pDir->maEntries.begin(); J!=pDir->maEntries.end(); J++)
1421 mpPage2LayoutLB->InsertEntry ((*J)->msTitle);
1422 mpPage2LayoutLB->Update();
1423 break;
1428 void AssistentDlgImpl::UpdateUserData()
1430 String aTopic = mpPage4AskTopicEDT->GetText();
1431 String aName = mpPage4AskNameEDT->GetText();
1432 String aInfo = mpPage4AskInfoEDT->GetText();
1434 SfxObjectShell* pShell = xDocShell;
1435 DrawDocShell* pDocShell = PTR_CAST(DrawDocShell,pShell);
1436 SdDrawDocument* pDoc = pDocShell?pDocShell->GetDoc():NULL;
1437 SdPage* pPage = pDoc?pDoc->GetSdPage(0, PK_STANDARD):NULL;
1439 if(pPage && ( aTopic.Len() != 0 || aName.Len() != 0 || aInfo.Len() != 0 ) )
1441 if( pPage->GetAutoLayout() == AUTOLAYOUT_NONE )
1442 pPage->SetAutoLayout(AUTOLAYOUT_TITLE, TRUE);
1444 SdrTextObj* pObj;
1445 String aEmptyString;
1447 if( aTopic.Len() )
1449 pObj = dynamic_cast<SdrTextObj*>( pPage->GetPresObj( PRESOBJ_TITLE ) );
1450 if( pObj )
1452 pPage->SetObjText( pObj, NULL, PRESOBJ_TITLE, aTopic );
1453 pObj->NbcSetStyleSheet( pPage->GetStyleSheetForPresObj( PRESOBJ_TITLE ), TRUE );
1454 pObj->SetEmptyPresObj(FALSE);
1459 if ( aName.Len() || aInfo.Len() )
1461 String aStrTmp( aName );
1462 if( aName.Len() )
1463 aStrTmp.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "\n\n" ) );
1464 aStrTmp.Append( aInfo );
1466 pObj = dynamic_cast<SdrTextObj*>( pPage->GetPresObj( PRESOBJ_OUTLINE ) );
1467 if( pObj )
1469 pPage->SetObjText( pObj, NULL, PRESOBJ_OUTLINE, aStrTmp );
1470 pObj->NbcSetStyleSheet( pPage->GetStyleSheetForPresObj( PRESOBJ_OUTLINE ), TRUE );
1471 pObj->SetEmptyPresObj(FALSE);
1473 else
1475 pObj = dynamic_cast<SdrTextObj*>( pPage->GetPresObj( PRESOBJ_TEXT ) );
1476 if( pObj )
1478 pPage->SetObjText( pObj, NULL, PRESOBJ_TEXT, aStrTmp );
1479 pObj->NbcSetStyleSheet( pPage->GetStyleSheetForPresObj( PRESOBJ_TEXT ), TRUE );
1480 pObj->SetEmptyPresObj(FALSE);
1486 mbUserDataDirty = FALSE;
1489 void AssistentDlgImpl::UpdatePageList()
1491 if(mbDocPreview || !mbPreview)
1492 UpdatePreview(FALSE);
1493 else if(maPageListFile == maDocFile)
1494 return;
1496 maPageListFile = maDocFile;
1498 SfxObjectShell* pShell = xDocShell;
1499 DrawDocShell* pDocShell = PTR_CAST(DrawDocShell,pShell);
1500 SdDrawDocument* pDoc = pDocShell?pDocShell->GetDoc():NULL;
1502 mpPage5PageListCT->Clear();
1504 if(pDoc)
1505 mpPage5PageListCT->Fill(pDoc);
1508 void AssistentDlgImpl::UpdatePreview( BOOL bDocPreview )
1510 // Guard against multiple concurrent execution to this method caused either
1511 // by calls from different threads or recursion.
1512 ::osl::MutexGuard aGuard (maMutex);
1513 if (mbPreviewUpdating)
1514 return;
1515 mbPreviewUpdating = TRUE;
1517 if(!mbPreview && bDocPreview)
1519 maPreview.Invalidate();
1520 maPreview.SetObjectShell(0);
1521 mbPreviewUpdating = FALSE;
1522 return;
1525 String aDocFile = GetDocFileName();
1526 String aLayoutFile = GetLayoutFileName();
1527 String aEmptyStr;
1529 SfxApplication *pSfxApp = SFX_APP();
1530 ULONG lErr;
1531 BOOL bChangeMaster = aLayoutFile.Len() != 0;
1533 if( aDocFile.Len() == 0 )
1535 if( !xDocShell.Is() || maDocFile.Len() != 0 ||
1536 (maDocFile.Len() == 0 && maLayoutFile.Len() != 0 && aLayoutFile.Len() == 0 ))
1538 CloseDocShell();
1540 DrawDocShell* pNewDocSh;
1541 xDocShell = pNewDocSh = new DrawDocShell(SFX_CREATE_MODE_STANDARD, FALSE);
1542 pNewDocSh->DoInitNew(NULL);
1543 SdDrawDocument* pDoc = pNewDocSh->GetDoc();
1544 pDoc->CreateFirstPages();
1545 pDoc->StopWorkStartupDelay();
1546 mbDocPreview = FALSE;
1548 maDocFile = aDocFile;
1549 mbUserDataDirty = TRUE;
1551 else
1552 bChangeMaster = (aLayoutFile.Len() != 0) && (maLayoutFile != aLayoutFile);
1554 else if( aDocFile == maDocFile && ( mbDocPreview == bDocPreview || bDocPreview ) )
1556 if( aLayoutFile != maLayoutFile )
1558 SfxObjectShell* pShell = xDocShell;
1559 DrawDocShell* pDocShell = PTR_CAST(DrawDocShell,pShell);
1560 SfxUndoManager* pUndoMgr = pDocShell?pDocShell->GetUndoManager():NULL;
1561 if(pUndoMgr)
1562 pUndoMgr->Undo();
1563 mbUserDataDirty = TRUE;
1565 else
1566 bChangeMaster = FALSE;
1568 else
1570 CloseDocShell();
1572 ::Window *pParent = Application::GetDefDialogParent();
1573 Application::SetDefDialogParent( mpWindow );
1575 SfxErrorContext eEC(ERRCTX_SFX_LOADTEMPLATE,mpWindow);
1577 SfxItemSet* pSet = new SfxAllItemSet( pSfxApp->GetPool() );
1578 if(IsOwnFormat(aDocFile))
1580 pSet->Put( SfxBoolItem( SID_TEMPLATE, TRUE ) );
1581 if(bDocPreview)
1582 pSet->Put( SfxBoolItem( SID_PREVIEW, TRUE ) );
1583 RestorePassword( pSet, aDocFile );
1584 if( (lErr = pSfxApp->LoadTemplate( xDocShell, aDocFile, TRUE, pSet )) != 0 )
1585 ErrorHandler::HandleError(lErr);
1586 else
1587 SavePassword( xDocShell, aDocFile );
1589 else
1591 const String aTargetStr( RTL_CONSTASCII_USTRINGPARAM("_default") );
1593 SfxRequest aReq( SID_OPENDOC, SFX_CALLMODE_SYNCHRON, SFX_APP()->GetPool() );
1594 aReq.AppendItem( SfxStringItem( SID_FILE_NAME, aDocFile ));
1595 aReq.AppendItem( SfxStringItem( SID_REFERER, aEmptyStr ) );
1596 aReq.AppendItem( SfxStringItem( SID_TARGETNAME, aTargetStr ) );
1597 aReq.AppendItem( SfxBoolItem( SID_VIEW, FALSE ) );
1598 aReq.AppendItem( SfxBoolItem( SID_PREVIEW, bDocPreview ) );
1600 const SfxObjectShellItem* pRet = (SfxObjectShellItem*)
1601 SFX_APP()->ExecuteSlot( aReq );
1603 if( pRet && pRet->GetObjectShell() )
1604 xDocShell = pRet->GetObjectShell();
1608 Application::SetDefDialogParent( pParent );
1610 mnShowPage = 0;
1611 mbDocPreview = bDocPreview;
1612 maDocFile = aDocFile;
1613 mbUserDataDirty = TRUE;
1616 if(bChangeMaster && (aLayoutFile != maDocFile))
1618 // Layoutvorlage laden
1619 SfxObjectShellLock xLayoutDocShell;
1620 SfxErrorContext eEC(ERRCTX_SFX_LOADTEMPLATE,mpWindow);
1621 SfxItemSet* pSet = new SfxAllItemSet( pSfxApp->GetPool() );
1623 ::Window *pParent = Application::GetDefDialogParent();
1624 Application::SetDefDialogParent( mpWindow );
1626 if(IsOwnFormat(aLayoutFile))
1628 pSet->Put( SfxBoolItem( SID_TEMPLATE, TRUE ) );
1629 pSet->Put( SfxBoolItem( SID_PREVIEW, TRUE ) );
1631 RestorePassword( pSet, aLayoutFile );
1632 if( (lErr = pSfxApp->LoadTemplate( xLayoutDocShell, aLayoutFile, TRUE, pSet )) != 0 )
1633 ErrorHandler::HandleError(lErr);
1634 SavePassword( xLayoutDocShell, aLayoutFile );
1637 Application::SetDefDialogParent( pParent );
1639 // die Implementierung ermitteln
1640 SfxObjectShell* pShell = xDocShell;
1641 DrawDocShell* pDocShell = PTR_CAST(DrawDocShell,pShell);
1642 SdDrawDocument* pDoc = pDocShell?pDocShell->GetDoc():NULL;
1644 pShell = xLayoutDocShell;
1645 pDocShell = PTR_CAST(DrawDocShell,pShell);
1646 SdDrawDocument* pLayoutDoc = pDocShell?pDocShell->GetDoc():NULL;
1648 if( pDoc && pLayoutDoc )
1650 pDoc->SetMasterPage(0, aEmptyStr, pLayoutDoc, TRUE, FALSE );
1652 else
1654 DBG_ERROR("sd::AssistentDlgImpl::UpdatePreview(), no document for preview?");
1657 mbUserDataDirty = TRUE;
1659 maLayoutFile = aLayoutFile;
1661 if(mbUserDataDirty)
1662 UpdateUserData();
1664 if ( !xDocShell.Is() || !mbPreview )
1665 maPreview.SetObjectShell( 0 );
1666 else
1668 maPreview.SetObjectShell( xDocShell, mnShowPage );
1671 mbPreviewUpdating = FALSE;
1674 void AssistentDlgImpl::SavePassword( SfxObjectShellLock xDoc, const String& rPath )
1676 if(xDoc.Is())
1678 SfxMedium * pMedium = xDoc->GetMedium();
1679 if(pMedium && pMedium->IsStorage())
1681 SfxItemSet * pSet = pMedium->GetItemSet();
1682 const SfxPoolItem *pItem = 0;
1683 if( pSet->GetItemState(SID_PASSWORD, TRUE, &pItem) == SFX_ITEM_SET )
1685 //TODO/MBA: testing
1686 String aPass( ((const SfxStringItem*)pItem)->GetValue());
1687 if(aPass.Len() == 0)
1688 return;
1690 PasswordEntry* pEntry = maPasswordList.First();
1691 while(pEntry)
1693 if(pEntry->maPath == rPath)
1694 break;
1696 pEntry = maPasswordList.Next();
1700 if(pEntry == NULL)
1702 pEntry = new PasswordEntry();
1703 pEntry->maPath = rPath;
1704 maPasswordList.Insert( pEntry );
1707 if(pEntry)
1708 pEntry->maPassword = aPass;
1714 void AssistentDlgImpl::RestorePassword( SfxItemSet* pSet, const String& rPath )
1716 String aPassword( GetPassword( rPath ) );
1718 if(aPassword.Len())
1719 pSet->Put( SfxStringItem( SID_PASSWORD, aPassword ) );
1722 String AssistentDlgImpl::GetPassword( const String rPath )
1724 PasswordEntry* pEntry = maPasswordList.First();
1725 while(pEntry)
1727 if(pEntry->maPath == rPath)
1728 return pEntry->maPassword;
1730 pEntry = maPasswordList.Next();
1733 return String();
1736 void AssistentDlgImpl::DeletePassords()
1738 PasswordEntry* pEntry = maPasswordList.First();
1739 while(pEntry)
1741 delete pEntry;
1742 pEntry = maPasswordList.Next();
1746 BOOL AssistentDlgImpl::IsOwnFormat( const String& rPath )
1748 INetURLObject aURL( rPath );
1749 String aExt( aURL.GetFileExtension() );
1751 DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
1753 return !aExt.EqualsIgnoreCaseAscii( "ppt" );
1759 String AssistentDlgImpl::GetUiTextForCommand (const ::rtl::OUString& sCommandURL)
1761 String sLabel;
1762 Reference<container::XNameAccess> xUICommandLabels;
1768 if (sCommandURL.getLength() == 0)
1769 break;
1771 // Retrieve popup menu labels
1772 Reference<lang::XMultiServiceFactory> xFactory (
1773 ::comphelper::getProcessServiceFactory ());
1774 if ( ! xFactory.is())
1775 break;
1777 ::rtl::OUString sModuleIdentifier (
1778 RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PresentationDocument"));
1779 Reference<container::XNameAccess> xNameAccess (
1780 xFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
1781 "com.sun.star.frame.UICommandDescription"))),
1782 UNO_QUERY);
1783 if ( ! xNameAccess.is())
1784 break;
1785 Any a = xNameAccess->getByName(sModuleIdentifier);
1786 a >>= xUICommandLabels;
1787 if ( ! xUICommandLabels.is())
1788 break;
1790 ::rtl::OUString sString;
1791 Sequence<beans::PropertyValue> aProperties;
1792 Any aAny (xUICommandLabels->getByName(sCommandURL));
1793 if (aAny >>= aProperties)
1795 sal_Int32 nCount (aProperties.getLength());
1796 for (sal_Int32 i=0; i<nCount; i++)
1798 ::rtl::OUString sPropertyName (aProperties[i].Name);
1799 if (sPropertyName.equalsAscii("Label"))
1801 aProperties[i].Value >>= sString;
1802 break;
1806 sLabel = sString;
1808 while(false);
1810 catch (com::sun::star::uno::Exception& rException)
1812 (void)rException;
1815 return sLabel;
1821 Image AssistentDlgImpl::GetUiIconForCommand (const ::rtl::OUString& sCommandURL)
1823 Image aIcon;
1824 Reference<container::XNameAccess> xUICommandLabels;
1830 if (sCommandURL.getLength() == 0)
1831 break;
1833 // Retrieve popup menu labels
1834 Reference<lang::XMultiServiceFactory> xFactory (
1835 ::comphelper::getProcessServiceFactory ());
1836 if ( ! xFactory.is())
1837 break;
1839 ::rtl::OUString sModuleIdentifier (
1840 RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PresentationDocument"));
1842 Reference<com::sun::star::ui::XModuleUIConfigurationManagerSupplier> xSupplier (
1843 xFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
1844 "com.sun.star.ui.ModuleUIConfigurationManagerSupplier"))),
1845 UNO_QUERY_THROW);
1847 Reference<com::sun::star::ui::XUIConfigurationManager> xManager (
1848 xSupplier->getUIConfigurationManager(sModuleIdentifier));
1849 if ( ! xManager.is())
1850 break;
1852 Reference<com::sun::star::ui::XImageManager> xImageManager (
1853 xManager->getImageManager(),
1854 UNO_QUERY_THROW);
1856 Sequence<rtl::OUString> aCommandList(1);
1857 aCommandList[0] = sCommandURL;
1858 Sequence<Reference<graphic::XGraphic> > xIconList (
1859 xImageManager->getImages(0,aCommandList));
1860 if ( ! xIconList.hasElements())
1861 break;
1863 aIcon = Graphic(xIconList[0]).GetBitmapEx();
1865 while(false);
1867 catch (com::sun::star::uno::Exception& rException)
1869 (void)rException;
1872 return aIcon;
1876 //////////////////////////////////////////////
1878 AssistentDlg::AssistentDlg(Window* pParent, BOOL bAutoPilot) :
1879 ModalDialog(pParent,SdResId(DLG_ASS))
1881 Link aFinishLink = LINK(this,AssistentDlg, FinishHdl);
1882 mpImpl = new AssistentDlgImpl( this, aFinishLink, bAutoPilot );
1884 //Buttonbelegung
1885 mpImpl->maFinishButton.SetClickHdl(LINK(this,AssistentDlg,FinishHdl));
1887 FreeResource();
1890 IMPL_LINK( AssistentDlg, FinishHdl, OKButton *, EMPTYARG )
1892 if( GetStartType() == ST_OPEN )
1894 //if we do not have a file here asked for one before ending the dialog
1895 String aFileToOpen = GetDocPath();
1896 if(aFileToOpen.Len() == 0)
1898 sfx2::FileDialogHelper aFileDlg( WB_OPEN, ::String::CreateFromAscii("simpress") );
1900 if ( aFileDlg.Execute() == ERRCODE_NONE )
1901 aFileToOpen = aFileDlg.GetPath();
1902 if( aFileToOpen.Len() == 0)
1903 return 1;
1904 else
1906 //add the selected file to the recent-file-listbox and select the new entry
1907 //this is necessary for 'GetDocPath()' returning the selected file after end of dialog
1909 INetURLObject aURL;
1910 aURL.SetSmartURL(aFileToOpen);
1911 mpImpl->maOpenFilesList.push_back (new String (aURL.GetMainURL( INetURLObject::NO_DECODE )));
1912 USHORT nNewPos = mpImpl->mpPage1OpenLB->InsertEntry(aURL.getName());
1913 mpImpl->mpPage1OpenLB->SelectEntryPos(nNewPos);
1918 //Ende
1919 mpImpl->EndDialog(RET_OK);
1920 EndDialog(RET_OK);
1921 return 0;
1924 AssistentDlg::~AssistentDlg()
1926 delete mpImpl;
1930 SfxObjectShellLock AssistentDlg::GetDocument()
1932 return mpImpl->GetDocument();
1935 String AssistentDlg::GetTopic() const
1937 return mpImpl->mpPage4AskTopicEDT->GetText();
1940 String AssistentDlg::GetUserName() const
1942 return mpImpl->mpPage4AskNameEDT->GetText();
1945 String AssistentDlg::GetInformation() const
1947 return mpImpl->mpPage4AskInfoEDT->GetText();
1950 OutputType AssistentDlg::GetOutputMedium() const
1952 if(mpImpl->mpPage2Medium1RB->IsChecked())
1953 return OUTPUT_PRESENTATION;
1954 else if(mpImpl->mpPage2Medium2RB->IsChecked())
1955 return OUTPUT_SLIDE;
1956 else if(mpImpl->mpPage2Medium3RB->IsChecked())
1957 return OUTPUT_OVERHEAD;
1958 else if(mpImpl->mpPage2Medium4RB->IsChecked())
1959 return OUTPUT_PAGE;
1960 else
1961 return OUTPUT_ORIGINAL;
1964 BOOL AssistentDlg::IsSummary() const
1966 return mpImpl->mpPage5SummaryCB->IsChecked();
1969 StartType AssistentDlg::GetStartType() const
1971 return mpImpl->GetStartType();
1974 String AssistentDlg::GetDocPath() const
1976 return mpImpl->GetDocFileName();
1979 BOOL AssistentDlg::GetStartWithFlag() const
1981 return !mpImpl->maStartWithFlag.IsChecked();
1984 BOOL AssistentDlg::IsDocEmpty() const
1986 return mpImpl->GetDocFileName().Len() == 0 &&
1987 mpImpl->GetLayoutFileName().Len() == 0;
1990 String AssistentDlg::GetPassword()
1992 return mpImpl->GetPassword( mpImpl->maDocFile );
1998 //===== NextButton ============================================================
2000 NextButton::NextButton (::Window* pParent, const ResId& rResId)
2001 : maNextButton1(pParent, rResId),
2002 maNextButton2(pParent, rResId),
2003 mbIsFirstButtonActive(true)
2005 // Hide the unused button.
2006 maNextButton2.Hide();
2012 void NextButton::ForceFocusEventBroadcast (void)
2014 // Hide the currently visible button and show and focus the other one.
2015 if (mbIsFirstButtonActive)
2017 mbIsFirstButtonActive = false;
2018 maNextButton2.Show();
2019 maNextButton2.GrabFocus();
2020 maNextButton1.Hide();
2022 else
2024 mbIsFirstButtonActive = true;
2025 maNextButton1.Show();
2026 maNextButton1.GrabFocus();
2027 maNextButton2.Hide();
2034 void NextButton::SetClickHdl (const Link& rLink)
2036 // Forward the setting of the click handler to the two buttons
2037 // regardless of which one is currently visible.
2038 maNextButton1.SetClickHdl(rLink);
2039 maNextButton2.SetClickHdl(rLink);
2045 bool NextButton::IsEnabled (void)
2047 // Because the buttons are both either enabled or disabled, it is
2048 // sufficient to ask one to determine the state.
2049 return maNextButton1.IsEnabled();
2055 void NextButton::Enable (bool bEnable)
2057 // Enable or disable both buttons but do not change visibility or focus.
2058 maNextButton1.Enable(bEnable);
2059 maNextButton2.Enable(bEnable);