merged tag LIBREOFFICE_3_2_99_3
[LibreOffice.git] / sd / source / ui / dlg / dlgass.cxx
blob5ef9531f1a077e47a1c5c991f1fd6f6e2d49f08b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 // MARKER(update_precomp.py): autogen include statement, do not remove
30 #include "precompiled_sd.hxx"
32 #ifdef SD_DLLIMPLEMENTATION
33 #undef SD_DLLIMPLEMENTATION
34 #endif
35 #include <com/sun/star/presentation/ClickAction.hpp>
36 #include <vcl/svapp.hxx>
37 #include <osl/mutex.hxx>
38 #include <vcl/msgbox.hxx>
39 #include <vcl/lstbox.hxx>
40 #include <vcl/combobox.hxx>
41 #include <sfx2/doctempl.hxx>
42 #include <svl/lstner.hxx>
43 #include <sfx2/objsh.hxx>
44 #include <svtools/ehdl.hxx>
45 #include <svtools/sfxecode.hxx>
46 #include <tools/urlobj.hxx>
47 #include <com/sun/star/presentation/FadeEffect.hpp>
48 #include <fadedef.h>
49 #include <sfx2/sfxsids.hrc>
50 #include <svl/undo.hxx>
51 #include "DrawDocShell.hxx"
52 #include <vcl/gdimtf.hxx>
53 #include <vcl/wintypes.hxx>
54 #include "docprev.hxx"
55 #include <sfx2/app.hxx>
56 #include <sfx2/docfile.hxx>
57 #include <sfx2/dispatch.hxx>
58 #include <sfx2/request.hxx>
59 #include <com/sun/star/sdbc/XResultSet.hpp>
60 #include <com/sun/star/lang/XComponent.hpp>
61 #include <com/sun/star/util/XCloseable.hpp>
62 #include <com/sun/star/uno/RuntimeException.hpp>
63 #include <com/sun/star/frame/XModuleManager.hpp>
64 #include <com/sun/star/ucb/XSimpleFileAccess.hpp>
65 #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
66 #include <com/sun/star/ui/XImageManager.hpp>
67 #include <unotools/historyoptions.hxx>
68 #include <tools/urlobj.hxx>
69 #include <osl/file.hxx>
70 #include <sfx2/filedlghelper.hxx>
72 #include "sdpage.hxx"
73 #include "helpids.h"
74 #include "assclass.hxx"
75 #include "dlgass.hrc"
76 #include "dlgass.hxx"
77 #include "dlgctrls.hxx"
78 #include "strings.hrc"
79 #include "dlgassim.hxx"
80 #include "TemplateScanner.hxx"
81 #include "WindowUpdater.hxx"
83 #include <comphelper/processfactory.hxx>
85 using namespace ::com::sun::star;
86 using namespace ::com::sun::star::uno;
87 using namespace ::sd;
90 void InterpolateFixedBitmap( FixedBitmap * pBitmap )
92 Bitmap aBmp( pBitmap->GetBitmap() );
93 Size aSize = pBitmap->GetSizePixel();
94 aBmp.Scale( aSize, BMP_SCALE_INTERPOLATE );
95 pBitmap->SetBitmap( aBmp );
99 // ====================================================================
100 // ====================================================================
102 UINT32 PageHelpIds[] =
104 HID_SD_AUTOPILOT_PAGE1,
105 HID_SD_AUTOPILOT_PAGE2,
106 HID_SD_AUTOPILOT_PAGE3,
107 HID_SD_AUTOPILOT_PAGE4,
108 HID_SD_AUTOPILOT_PAGE5
111 // ====================================================================
113 class PasswordEntry
115 public:
116 String maPassword;
117 String maPath;
120 DECLARE_LIST( PasswordEntryList, PasswordEntry * )
122 // ====================================================================
124 /** A simple wrapper that looks like a PushButton and is used to force the
125 broadcasting of focus events primarly for accessibility tools.
126 Forcing focus events is achieved by using two identical PushButtons
127 which, when the focus event is requested, are exchanged and play focus
128 ping-pong by moving the focus from one to the other.
130 class NextButton
132 public:
133 NextButton (::Window* pParent, const ResId& rResId);
135 void ForceFocusEventBroadcast (void);
136 void SetClickHdl (const Link& rLink);
137 bool IsEnabled (void);
138 void Enable (bool bEnable);
140 private:
141 PushButton maNextButton1;
142 PushButton maNextButton2;
143 bool mbIsFirstButtonActive;
148 // ====================================================================
150 class AssistentDlgImpl : public SfxListener
152 public:
153 AssistentDlgImpl( ::Window* pWindow, const Link& rFinishLink, BOOL bAutoPilot );
154 ~AssistentDlgImpl();
156 /// Local mutex used to serialize concurrent method calls.
157 ::osl::Mutex maMutex;
159 SfxObjectShellLock GetDocument();
161 /** closes the current preview docshell */
162 void CloseDocShell();
164 /** Extract form the history list of recently used files the impress
165 files and insert them into a listbox.
167 void ScanDocmenu (void);
168 /** Flag that is set to TRUE after the recently used files have been
169 scanned.
171 BOOL mbRecentDocumentsReady;
173 /** When the list of templates has not been scanned already this is done
174 when this method is called. That includes requesting the whole list
175 of templates from UCB and extracting from that list the impress
176 templates and layouts and storing them for later use in
177 <member>maPresentList</member>. Note that the first call to this
178 method after installing a new Office may take some time.
180 void ProvideTemplates (void);
182 /** This method transfers the template folders from the template scanner
183 to the internal structures of this class. On termination it sets
184 the flag <member>mbTemplatesReady</member> to <TRUE/> to indicate
185 that the templates are available.
186 @param rTemplateFolders
187 This is a list of template folders. This method takes ownership
188 of the supplied entries by removing them from the list and
189 transferring them to an internal structure.
191 void TemplateScanDone (std::vector<TemplateDir*>& rTemplateFolders);
193 /** Flag that is set to TRUE after the impress templates have been
194 scanned.
196 BOOL mbTemplatesReady;
198 /** Flag used to prevent nested or concurrent calls to the
199 <member>UpdatePreview</memember> method. A <TRUE/> value indicates
200 that a preview update is currently active.
202 BOOL mbPreviewUpdating;
204 ::Window* mpWindow;
206 void SavePassword( SfxObjectShellLock xDoc, const String& rPath );
207 void RestorePassword( SfxItemSet* pSet, const String& rPath );
208 String GetPassword( const String rPath );
209 void DeletePassords();
211 PasswordEntryList maPasswordList;
213 String maDocFile;
214 String maLayoutFile;
216 String GetDocFileName();
217 String GetLayoutFileName();
219 /// List of URLs of recently used impress files.
220 std::vector<String*> maOpenFilesList;
222 /// List of folders containing data about impress templates.
223 std::vector<TemplateDir*> maPresentList;
225 /// Currently selected template folder.
226 TemplateDir* mpTemplateRegion;
228 /// Currently selected layout folder.
229 TemplateDir* mpLayoutRegion;
231 // preview
232 BOOL mbUserDataDirty;
233 Timer maPrevTimer;
234 Timer maEffectPrevTimer;
235 Timer maUpdatePageListTimer;
236 Timer maStartScanTimer;
238 SfxObjectShellLock xDocShell;
240 ::std::auto_ptr<WindowUpdater> mpWindowUpdater;
242 BOOL mbPreview;
243 USHORT mnShowPage;
244 BOOL mbDocPreview;
246 ULONG mnTemplate;
248 String maPageListFile;
250 void UpdatePreview( BOOL bDocPreview );
251 void UpdatePageList();
252 void UpdateUserData();
254 BOOL IsOwnFormat( const String& rPath );
256 // dlg status
257 void EndDialog( long nResult = 0 );
259 void SetStartType( StartType eType );
260 StartType GetStartType();
262 void SelectTemplateRegion( const String& rRegion );
263 void SelectLayoutRegion( const String& rRegion );
265 void UpdatePage();
266 void ChangePage();
267 void LeavePage();
269 String GetUiTextForCommand (const ::rtl::OUString& aCommandURL);
270 Image GetUiIconForCommand (const ::rtl::OUString& aCommandURL);
272 DECL_LINK( StartScanHdl, void * );
273 DECL_LINK( SelectFileHdl, ListBox * );
274 DECL_LINK( SelectRegionHdl, ListBox * );
275 DECL_LINK( UpdatePreviewHdl, void * );
276 DECL_LINK( UpdatePageListHdl, void * );
277 DECL_LINK( StartTypeHdl, RadioButton * );
278 DECL_LINK( SelectTemplateHdl, ListBox * );
279 DECL_LINK( NextPageHdl, PushButton * );
280 DECL_LINK( LastPageHdl, PushButton * );
281 DECL_LINK( PreviewFlagHdl, CheckBox * );
282 DECL_LINK( EffectPreviewHdl, Button * );
283 DECL_LINK( SelectLayoutHdl, ListBox * );
284 DECL_LINK( PageSelectHdl, Control * );
285 DECL_LINK( PresTypeHdl, RadioButton * );
286 DECL_LINK( UpdateUserDataHdl, Edit* );
287 DECL_LINK( SelectEffectHdl, void* );
288 DECL_LINK( OpenButtonHdl, Button * );
290 // Common
291 Assistent maAssistentFunc;
292 CheckBox maPreviewFlag;
293 CheckBox maStartWithFlag;
294 HelpButton maHelpButton;
295 CancelButton maCancelButton;
296 PushButton maLastPageButton;
297 NextButton maNextPageButton;
298 OKButton maFinishButton;
299 SdDocPreviewWin maPreview;
301 String maCreateStr;
302 String maOpenStr;
304 // Seite 1
305 FixedBitmap* mpPage1FB;
306 FixedLine* mpPage1ArtFL;
307 RadioButton* mpPage1EmptyRB;
308 RadioButton* mpPage1TemplateRB;
309 ListBox* mpPage1RegionLB;
310 ListBox* mpPage1TemplateLB;
311 RadioButton* mpPage1OpenRB;
312 ListBox* mpPage1OpenLB;
313 PushButton* mpPage1OpenPB;
315 // Seite 2
316 FixedBitmap* mpPage2FB;
317 FixedLine* mpPage2LayoutFL;
318 ListBox* mpPage2RegionLB;
319 ListBox* mpPage2LayoutLB;
320 FixedLine* mpPage2OutTypesFL;
321 RadioButton* mpPage2Medium1RB;
322 RadioButton* mpPage2Medium2RB;
323 RadioButton* mpPage2Medium3RB;
324 RadioButton* mpPage2Medium4RB;
325 RadioButton* mpPage2Medium5RB;
327 // Seite 3
328 FixedBitmap* mpPage3FB;
329 FixedLine* mpPage3EffectFL;
330 FixedText* mpPage3EffectFT;
331 FadeEffectLB* mpPage3EffectLB;
332 FixedText* mpPage3SpeedFT;
333 ListBox* mpPage3SpeedLB;
334 FixedLine* mpPage3PresTypeFL;
335 RadioButton* mpPage3PresTypeLiveRB;
336 RadioButton* mpPage3PresTypeKioskRB;
337 FixedText* mpPage3PresTimeFT;
338 TimeField* mpPage3PresTimeTMF;
339 FixedText* mpPage3BreakFT;
340 TimeField* mpPage3BreakTMF;
341 CheckBox* mpPage3LogoCB;
343 // Seite 4
344 FixedBitmap* mpPage4FB;
345 FixedLine* mpPage4PersonalFL;
346 FixedText* mpPage4AskNameFT;
347 Edit* mpPage4AskNameEDT;
348 FixedText* mpPage4AskTopicFT;
349 Edit* mpPage4AskTopicEDT;
350 FixedText* mpPage4AskInfoFT;
351 MultiLineEdit* mpPage4AskInfoEDT;
353 // Seite 5
354 FixedBitmap* mpPage5FB;
355 FixedText* mpPage5PageListFT;
356 SdPageListControl* mpPage5PageListCT;
357 CheckBox* mpPage5SummaryCB;
363 // ====================================================================
365 AssistentDlgImpl::AssistentDlgImpl( ::Window* pWindow, const Link& rFinishLink, BOOL bAutoPilot ) :
366 mpTemplateRegion(NULL),
367 mpLayoutRegion(NULL),
368 mbUserDataDirty(FALSE),
369 xDocShell (NULL),
370 mpWindowUpdater (new WindowUpdater()),
371 mbPreview(TRUE),
372 mnShowPage(0),
373 mbDocPreview(FALSE),
374 maAssistentFunc(5),
375 maPreviewFlag(pWindow,SdResId(CB_PREVIEW)),
376 maStartWithFlag(pWindow,SdResId(CB_STARTWITH)),
377 maHelpButton(pWindow,SdResId(BUT_HELP)),
378 maCancelButton(pWindow,SdResId(BUT_CANCEL)),
379 maLastPageButton(pWindow,SdResId(BUT_LAST)),
380 maNextPageButton(pWindow,SdResId(BUT_NEXT)),
381 maFinishButton(pWindow,SdResId(BUT_FINISH)),
382 maPreview(pWindow,SdResId(CT_PREVIEW)),
383 maCreateStr(SdResId(STR_CREATE)),
384 maOpenStr(SdResId(STR_OPEN))
386 maPageListFile += sal_Unicode('?'),
387 mbRecentDocumentsReady = FALSE;
388 mbTemplatesReady = FALSE;
389 mbPreviewUpdating = FALSE;
391 mpWindow = pWindow;
393 if(bAutoPilot)
394 maStartWithFlag.Hide();
395 else
396 maAssistentFunc.InsertControl(1, &maStartWithFlag );
398 //page1 wird initialisiert und an die Assistentenfunktionalitaet
399 //uebergeben
400 maAssistentFunc.InsertControl(1, &maPreview );
401 maAssistentFunc.InsertControl(1, &maPreviewFlag );
402 maAssistentFunc.InsertControl(1,
403 mpPage1FB = new FixedBitmap(pWindow,SdResId(FB_PAGE1)));
404 maAssistentFunc.InsertControl(1,
405 mpPage1ArtFL = new FixedLine(pWindow,SdResId(FL_PAGE1_ARTGROUP)));
406 maAssistentFunc.InsertControl(1,
407 mpPage1EmptyRB=new RadioButton(pWindow,SdResId(RB_PAGE1_EMPTY)));
408 maAssistentFunc.InsertControl(1,
409 mpPage1TemplateRB=new RadioButton(pWindow,SdResId(RB_PAGE1_TEMPLATE)));
410 maAssistentFunc.InsertControl(1,
411 mpPage1OpenRB=new RadioButton(pWindow,SdResId(RB_PAGE1_OPEN)));
412 maAssistentFunc.InsertControl(1,
413 mpPage1RegionLB = new ListBox(pWindow,SdResId(LB_PAGE1_REGION)));
414 maAssistentFunc.InsertControl(1,
415 mpPage1TemplateLB=new ListBox(pWindow,SdResId(LB_PAGE1_TEMPLATES)));
416 maAssistentFunc.InsertControl(1,
417 mpPage1OpenPB=new PushButton(pWindow,SdResId(PB_PAGE1_OPEN)));
418 maAssistentFunc.InsertControl(1,
419 mpPage1OpenLB=new ListBox(pWindow,SdResId(LB_PAGE1_OPEN)));
421 // Align the button and list box displayed for the "open existing file"
422 // radio button with the text of that radio button.
424 RadioButton aEmptyRB (mpWindow);
425 sal_Int32 nIndent (aEmptyRB.CalcMinimumSize(0).Width());
426 sal_Int32 nLeft (mpPage1OpenRB->GetPosPixel().X() + nIndent);
427 sal_Int32 nWidth (mpPage1OpenRB->GetSizePixel().Width() - nIndent);
428 mpPage1OpenPB->SetPosSizePixel(
429 Point(nLeft, mpPage1OpenPB->GetPosPixel().Y()),
430 Size(mpPage1OpenPB->GetSizePixel()));
431 mpPage1OpenLB->SetPosSizePixel(
432 Point(nLeft, mpPage1OpenLB->GetPosPixel().Y()),
433 Size(nWidth, mpPage1OpenLB->GetSizePixel().Height()));
436 // Set text and icon of the 'Open...' button.
438 String sText (GetUiTextForCommand(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:Open"))));
439 // Remove the mnemonic and add a leading space so that icon and text
440 // are not too close together.
441 sText.SearchAndReplaceAll(String(RTL_CONSTASCII_STRINGPARAM("~")),String());
442 sText.Insert(String(RTL_CONSTASCII_STRINGPARAM(" ")),0);
443 mpPage1OpenPB->SetText(sText);
444 // Place icon left of text and both centered in the button.
445 mpPage1OpenPB->SetModeImage(
446 GetUiIconForCommand(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:Open"))),
447 BMP_COLOR_NORMAL);
448 mpPage1OpenPB->EnableImageDisplay(TRUE);
449 mpPage1OpenPB->EnableTextDisplay(TRUE);
450 mpPage1OpenPB->SetImageAlign(IMAGEALIGN_LEFT);
451 mpPage1OpenPB->SetStyle(mpPage1OpenPB->GetStyle() | WB_CENTER);
454 // links&handler
455 mpPage1RegionLB->SetSelectHdl(LINK(this,AssistentDlgImpl,SelectRegionHdl));
456 mpPage1RegionLB->SetDropDownLineCount( 6 );
457 mpPage1TemplateLB->SetSelectHdl(LINK(this,AssistentDlgImpl,SelectTemplateHdl));
458 mpPage1TemplateLB->InsertEntry(String(SdResId(STR_ISLOADING)));
460 mpPage1EmptyRB->SetClickHdl(LINK(this,AssistentDlgImpl,StartTypeHdl));
461 mpPage1TemplateRB->SetClickHdl(LINK(this,AssistentDlgImpl,StartTypeHdl));
462 mpPage1OpenRB->SetClickHdl(LINK(this,AssistentDlgImpl,StartTypeHdl));
463 mpPage1OpenLB->SetSelectHdl(LINK(this,AssistentDlgImpl,SelectFileHdl));
464 mpPage1OpenLB->SetDoubleClickHdl(rFinishLink);
465 mpPage1OpenPB->SetClickHdl(LINK(this,AssistentDlgImpl,OpenButtonHdl));
466 // mpPage1OpenLB->InsertEntry(String(SdResId(STR_WIZARD_POSITION)));
468 // Seite 2
469 maAssistentFunc.InsertControl(2, &maPreview );
470 maAssistentFunc.InsertControl(2, &maPreviewFlag );
471 maAssistentFunc.InsertControl(2,
472 mpPage2FB = new FixedBitmap(pWindow,SdResId(FB_PAGE2)));
473 maAssistentFunc.InsertControl(2,
474 mpPage2LayoutFL = new FixedLine( pWindow, SdResId(FL_PAGE2_LAYOUT) ));
475 maAssistentFunc.InsertControl(2,
476 mpPage2RegionLB = new ListBox(pWindow,SdResId(LB_PAGE2_REGION) ));
477 maAssistentFunc.InsertControl(2,
478 mpPage2LayoutLB = new ListBox(pWindow,SdResId(LB_PAGE2_LAYOUT) ));
480 maAssistentFunc.InsertControl(2,
481 mpPage2OutTypesFL = new FixedLine( pWindow, SdResId(FL_PAGE2_OUTPUTTYPES) ));
482 maAssistentFunc.InsertControl(2,
483 mpPage2Medium5RB = new RadioButton( pWindow, SdResId(RB_PAGE2_MEDIUM5) ));
484 maAssistentFunc.InsertControl(2,
485 mpPage2Medium3RB = new RadioButton( pWindow, SdResId(RB_PAGE2_MEDIUM3) ));
486 maAssistentFunc.InsertControl(2,
487 mpPage2Medium4RB = new RadioButton( pWindow, SdResId(RB_PAGE2_MEDIUM4) ));
488 maAssistentFunc.InsertControl(2,
489 mpPage2Medium1RB = new RadioButton( pWindow, SdResId(RB_PAGE2_MEDIUM1) ));
490 maAssistentFunc.InsertControl(2,
491 mpPage2Medium2RB = new RadioButton( pWindow, SdResId(RB_PAGE2_MEDIUM2) ));
492 mpPage2Medium5RB->Check();
494 mpPage2RegionLB->SetSelectHdl(LINK(this,AssistentDlgImpl,SelectRegionHdl));
495 mpPage2RegionLB->SetDropDownLineCount( 6 );
496 mpPage2LayoutLB->SetSelectHdl(LINK(this,AssistentDlgImpl,SelectLayoutHdl));
497 mpPage2LayoutLB->InsertEntry(String(SdResId(STR_ISLOADING)));
499 // Seite 3
500 maAssistentFunc.InsertControl(3, &maPreview );
501 maAssistentFunc.InsertControl(3, &maPreviewFlag );
502 maAssistentFunc.InsertControl(3,
503 mpPage3FB = new FixedBitmap(pWindow,SdResId(FB_PAGE3)));
504 maAssistentFunc.InsertControl(3,
505 mpPage3EffectFL = new FixedLine( pWindow, SdResId(FL_PAGE3_EFFECT) ));
506 maAssistentFunc.InsertControl(3,
507 mpPage3EffectFT = new FixedText( pWindow, SdResId(FT_PAGE3_EFFECT) ));
508 maAssistentFunc.InsertControl(3,
509 mpPage3EffectLB = new FadeEffectLB( pWindow, SdResId(LB_PAGE3_EFFECT) ));
510 maAssistentFunc.InsertControl(3,
511 mpPage3SpeedFT = new FixedText( pWindow, SdResId(FT_PAGE3_SPEED) ));
512 maAssistentFunc.InsertControl(3,
513 mpPage3SpeedLB = new FadeEffectLB( pWindow, SdResId(LB_PAGE3_SPEED) ));
514 maAssistentFunc.InsertControl(3,
515 mpPage3PresTypeFL = new FixedLine( pWindow, SdResId(FL_PAGE3_PRESTYPE) ));
516 maAssistentFunc.InsertControl(3,
517 mpPage3PresTypeLiveRB = new RadioButton( pWindow, SdResId(RB_PAGE3_LIVE) ));
518 maAssistentFunc.InsertControl(3,
519 mpPage3PresTypeKioskRB = new RadioButton( pWindow, SdResId(RB_PAGE3_KIOSK) ));
520 maAssistentFunc.InsertControl(3,
521 mpPage3PresTimeFT = new FixedText( pWindow, SdResId( FT_PAGE3_TIME) ));
522 maAssistentFunc.InsertControl(3,
523 mpPage3PresTimeTMF = new TimeField( pWindow, SdResId( TMF_PAGE3_TIME) ));
524 maAssistentFunc.InsertControl(3,
525 mpPage3BreakFT = new FixedText( pWindow, SdResId( FT_PAGE3_BREAK) ));
526 maAssistentFunc.InsertControl(3,
527 mpPage3BreakTMF = new TimeField( pWindow, SdResId( TMF_PAGE3_BREAK) ));
528 maAssistentFunc.InsertControl(3,
529 mpPage3LogoCB = new CheckBox( pWindow, SdResId( CB_PAGE3_LOGO) ));
531 mpPage3EffectLB->Fill();
532 // mpPage3EffectLB->SelectEffect( presentation::FadeEffect_NONE );
533 mpPage3EffectLB->SetSelectHdl( LINK(this,AssistentDlgImpl,SelectEffectHdl ));
534 mpPage3EffectLB->SetDropDownLineCount( 12 );
536 mpPage3SpeedLB->InsertEntry( String( SdResId(STR_SLOW) ));
537 mpPage3SpeedLB->InsertEntry( String( SdResId(STR_MEDIUM) ));
538 mpPage3SpeedLB->InsertEntry( String( SdResId(STR_FAST) ));
539 mpPage3SpeedLB->SetDropDownLineCount( 3 );
540 mpPage3SpeedLB->SetSelectHdl( LINK(this,AssistentDlgImpl,SelectEffectHdl ));
541 mpPage3SpeedLB->SelectEntryPos( 1 );
543 mpPage3PresTypeLiveRB->Check();
544 mpPage3PresTypeLiveRB->SetClickHdl( LINK(this,AssistentDlgImpl, PresTypeHdl ));
545 mpPage3PresTypeKioskRB->SetClickHdl( LINK(this,AssistentDlgImpl, PresTypeHdl ));
546 mpPage3PresTimeTMF->SetFormat( TIMEF_SEC );
547 mpPage3PresTimeTMF->SetTime( Time( 0, 0, 10 ) );
548 mpPage3BreakTMF->SetFormat( TIMEF_SEC );
549 mpPage3BreakTMF->SetTime( Time( 0, 0, 10 ) );
550 mpPage3LogoCB->Check();
552 // set cursor in timefield
553 Edit *pEditPage3PresTimeTMF = mpPage3PresTimeTMF->GetField();
554 Edit *pEditPage3BreakTMF = mpPage3BreakTMF->GetField();
555 Selection aSel1( pEditPage3PresTimeTMF->GetMaxTextLen(), pEditPage3PresTimeTMF->GetMaxTextLen() );
556 Selection aSel2( pEditPage3BreakTMF->GetMaxTextLen(), pEditPage3BreakTMF->GetMaxTextLen() );
557 pEditPage3PresTimeTMF->SetSelection( aSel1 );
558 pEditPage3BreakTMF->SetSelection( aSel2 );
560 // Seite 4
561 maAssistentFunc.InsertControl(4,
562 mpPage4FB = new FixedBitmap(pWindow,SdResId(FB_PAGE4)));
563 maAssistentFunc.InsertControl(4,
564 mpPage4PersonalFL = new FixedLine( pWindow, SdResId(FL_PAGE4_PERSONAL) ));
565 maAssistentFunc.InsertControl(4,
566 mpPage4AskNameFT = new FixedText( pWindow, SdResId(FT_PAGE4_ASKNAME) ));
567 maAssistentFunc.InsertControl(4,
568 mpPage4AskNameEDT = new Edit( pWindow, SdResId(EDT_PAGE4_ASKNAME) ));
569 maAssistentFunc.InsertControl(4,
570 mpPage4AskTopicFT= new FixedText( pWindow, SdResId(FT_PAGE4_ASKTOPIC) ));
571 maAssistentFunc.InsertControl(4,
572 mpPage4AskTopicEDT = new Edit( pWindow, SdResId(EDT_PAGE4_ASKTOPIC) ));
573 maAssistentFunc.InsertControl(4,
574 mpPage4AskInfoFT = new FixedText( pWindow, SdResId(FT_PAGE4_ASKINFORMATION) ));
575 maAssistentFunc.InsertControl(4,
576 mpPage4AskInfoEDT = new MultiLineEdit( pWindow, SdResId(EDT_PAGE4_ASKINFORMATION) ));
578 mpPage4AskNameEDT->SetModifyHdl(LINK(this,AssistentDlgImpl,UpdateUserDataHdl));
579 mpPage4AskTopicEDT->SetModifyHdl(LINK(this,AssistentDlgImpl,UpdateUserDataHdl));
580 mpPage4AskInfoEDT->SetModifyHdl(LINK(this,AssistentDlgImpl,UpdateUserDataHdl));
582 // page 5
583 maAssistentFunc.InsertControl(5, &maPreview );
584 maAssistentFunc.InsertControl(5, &maPreviewFlag );
585 maAssistentFunc.InsertControl(5,
586 mpPage5FB = new FixedBitmap(pWindow,SdResId(FB_PAGE5)));
587 maAssistentFunc.InsertControl(5,
588 mpPage5PageListFT = new FixedText( pWindow, SdResId( FT_PAGE5_PAGELIST ) ));
589 maAssistentFunc.InsertControl(5,
590 mpPage5PageListCT = new SdPageListControl( pWindow, SdResId( CT_PAGE5_PAGELIST ) ));
591 maAssistentFunc.InsertControl(5,
592 mpPage5SummaryCB = new CheckBox( pWindow, SdResId( CB_PAGE5_SUMMARY ) ));
594 mpPage5PageListCT->SetSelectHdl(LINK(this,AssistentDlgImpl, PageSelectHdl));
597 // generell
598 InterpolateFixedBitmap( mpPage1FB );
599 InterpolateFixedBitmap( mpPage2FB );
600 InterpolateFixedBitmap( mpPage3FB );
601 InterpolateFixedBitmap( mpPage4FB );
602 InterpolateFixedBitmap( mpPage5FB );
604 maLastPageButton.SetClickHdl(LINK(this,AssistentDlgImpl, LastPageHdl ));
605 maNextPageButton.SetClickHdl(LINK(this,AssistentDlgImpl, NextPageHdl ));
607 maPreviewFlag.Check( mbPreview );
608 maPreviewFlag.SetClickHdl(LINK(this, AssistentDlgImpl, PreviewFlagHdl ));
609 maPreview.SetClickHdl(LINK(this,AssistentDlgImpl, EffectPreviewHdl ));
611 //setzt die Ausgangsseite
612 maAssistentFunc.GotoPage(1);
613 maLastPageButton.Disable();
615 maPrevTimer.SetTimeout( 200 );
616 maPrevTimer.SetTimeoutHdl( LINK( this, AssistentDlgImpl, UpdatePreviewHdl));
618 maEffectPrevTimer.SetTimeout( 50 );
619 maEffectPrevTimer.SetTimeoutHdl( LINK( this, AssistentDlgImpl, EffectPreviewHdl ));
621 maUpdatePageListTimer.SetTimeout( 50 );
622 maUpdatePageListTimer.SetTimeoutHdl( LINK( this, AssistentDlgImpl, UpdatePageListHdl));
624 SetStartType( ST_EMPTY );
626 ChangePage();
628 mpWindowUpdater->RegisterWindow (&maPreview);
630 UpdatePreview( TRUE );
632 //check wether we should start with a template document initialy and preselect it
633 const ::rtl::OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.PresentationDocument" ) );
634 String aStandardTemplate( SfxObjectFactory::GetStandardTemplate( aServiceName ) );
635 if( aStandardTemplate.Len() )
637 ProvideTemplates();
639 //find aStandardTemplate in maPresentList
640 TemplateDir* pStandardTemplateDir = 0;
641 TemplateEntry* pStandardTemplateEntry = 0;
643 std::vector<TemplateDir*>::iterator I;
644 for (I=maPresentList.begin(); I!=maPresentList.end(); I++)
646 TemplateDir* pDir = *I;
647 std::vector<TemplateEntry*>::iterator J;
648 for (J=pDir->maEntries.begin(); J!=pDir->maEntries.end(); J++)
650 TemplateEntry* pEntry = *J;
651 if(pEntry->msPath == aStandardTemplate)
653 pStandardTemplateDir = pDir;
654 pStandardTemplateEntry = pEntry;
655 break;
658 if(pStandardTemplateDir)
659 break;
662 //preselect template
663 if( pStandardTemplateDir && pStandardTemplateEntry )
665 mpPage1RegionLB->SelectEntry( pStandardTemplateDir->msRegion );
666 SelectTemplateRegion( pStandardTemplateDir->msRegion );
667 mpPage1TemplateLB->SelectEntry( pStandardTemplateEntry->msTitle );
668 SelectTemplateHdl(mpPage1TemplateLB);
676 AssistentDlgImpl::~AssistentDlgImpl()
678 CloseDocShell();
680 DeletePassords();
682 // Delete the template file infos.
683 std::vector<TemplateDir*>::iterator I;
684 std::vector<TemplateEntry*>::iterator J;
685 for (I=maPresentList.begin(); I!=maPresentList.end(); I++)
687 for (J=(*I)->maEntries.begin(); J!=(*I)->maEntries.end(); J++)
688 delete (*J);
689 delete (*I);
692 // Seite 1
693 delete mpPage1FB;
694 delete mpPage1ArtFL;
695 delete mpPage1EmptyRB;
696 delete mpPage1TemplateRB;
697 delete mpPage1TemplateLB;
698 delete mpPage1RegionLB;
699 delete mpPage1OpenRB;
700 delete mpPage1OpenLB;
701 delete mpPage1OpenPB;
703 // Seite 2
704 delete mpPage2FB;
705 delete mpPage2LayoutFL;
706 delete mpPage2RegionLB;
707 delete mpPage2LayoutLB;
708 delete mpPage2OutTypesFL;
709 delete mpPage2Medium1RB;
710 delete mpPage2Medium2RB;
711 delete mpPage2Medium3RB;
712 delete mpPage2Medium4RB;
713 delete mpPage2Medium5RB;
715 // Seite 3
716 delete mpPage3FB;
717 delete mpPage3EffectFL;
718 delete mpPage3EffectFT;
719 delete mpPage3EffectLB;
720 delete mpPage3SpeedFT;
721 delete mpPage3SpeedLB;
722 delete mpPage3PresTypeFL;
723 delete mpPage3PresTypeLiveRB;
724 delete mpPage3PresTypeKioskRB;
725 delete mpPage3PresTimeFT;
726 delete mpPage3PresTimeTMF;
727 delete mpPage3BreakFT;
728 delete mpPage3BreakTMF;
729 delete mpPage3LogoCB;
731 // Seite 4
732 delete mpPage4FB;
733 delete mpPage4PersonalFL;
734 delete mpPage4AskNameFT;
735 delete mpPage4AskNameEDT;
736 delete mpPage4AskTopicFT;
737 delete mpPage4AskTopicEDT;
738 delete mpPage4AskInfoFT;
739 delete mpPage4AskInfoEDT;
741 // Seite 5
742 delete mpPage5FB;
743 delete mpPage5PageListFT;
744 delete mpPage5PageListCT;
745 delete mpPage5SummaryCB;
747 // Delete the file history list.
748 std::vector<String*>::iterator I2;
749 for (I2=maOpenFilesList.begin(); I2!=maOpenFilesList.end(); I2++)
750 delete *I2;
753 void AssistentDlgImpl::CloseDocShell()
755 if(xDocShell.Is())
757 //uno::Reference< lang::XComponent > xModel( xDocShell->GetModel(), uno::UNO_QUERY );
758 uno::Reference< util::XCloseable > xCloseable( xDocShell->GetModel(), uno::UNO_QUERY );
759 //if( xModel.is() )
760 if( xCloseable.is() )
762 xCloseable->close( sal_True );
763 xDocShell = NULL;
764 //xModel->dispose();
766 else
768 xDocShell->DoClose();
769 xDocShell = NULL;
774 void AssistentDlgImpl::EndDialog( long )
776 mpWindow = NULL;
782 void AssistentDlgImpl::ScanDocmenu (void)
784 if( mbRecentDocumentsReady )
785 return;
787 uno::Sequence<uno::Sequence<beans::PropertyValue> > aHistory =
788 SvtHistoryOptions().GetList (ePICKLIST);
790 uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
791 uno::Reference< container::XNameAccess > xFilterFactory( xFactory->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.FilterFactory" ) ) ), uno::UNO_QUERY );
793 Reference< ::com::sun::star::ucb::XSimpleFileAccess > xFileAccess(
794 xFactory->createInstance(
795 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess"))),
796 UNO_QUERY_THROW);
798 sal_uInt32 nCount = aHistory.getLength();
799 for (sal_uInt32 nItem=0; nItem<nCount; ++nItem)
801 // Get the current history item's properties.
802 uno::Sequence<beans::PropertyValue> aPropertySet = aHistory[nItem];
803 rtl::OUString sURL;
804 rtl::OUString sFilter;
805 rtl::OUString sTitle;
806 rtl::OUString sPassword;
807 sal_uInt32 nPropertyCount = aPropertySet.getLength();
808 for (sal_uInt32 nProperty=0; nProperty<nPropertyCount; ++nProperty)
809 if (aPropertySet[nProperty].Name == HISTORY_PROPERTYNAME_URL)
810 aPropertySet[nProperty].Value >>= sURL;
811 else if (aPropertySet[nProperty].Name == HISTORY_PROPERTYNAME_FILTER)
812 aPropertySet[nProperty].Value >>= sFilter;
813 else if (aPropertySet[nProperty].Name == HISTORY_PROPERTYNAME_TITLE)
814 aPropertySet[nProperty].Value >>= sTitle;
815 else if (aPropertySet[nProperty].Name == HISTORY_PROPERTYNAME_PASSWORD)
816 aPropertySet[nProperty].Value >>= sPassword;
818 // If the entry is an impress file then insert it into the
819 // history list and the list box.
820 uno::Sequence< beans::PropertyValue > lProps;
821 if (xFilterFactory->hasByName(sFilter))
823 uno::Any aFilterPropSet = xFilterFactory->getByName( sFilter );
824 aFilterPropSet >>= lProps;
827 sal_Int32 nPropCount = lProps.getLength();
828 rtl::OUString sFactoryName;
829 for( sal_Int32 i=0; i<nPropCount; ++i )
831 if( lProps[i].Name.compareToAscii( "DocumentService" ) == 0 &&
832 (lProps[i].Value >>= sFactoryName) &&
833 sFactoryName.compareToAscii( "com.sun.star.presentation.PresentationDocument" ) == 0 )
835 // yes, it's an impress document
836 INetURLObject aURL;
838 // Do not include the file if it does not exist.
839 if (xFileAccess.is() && ! xFileAccess->exists(sURL))
840 continue;
842 aURL.SetSmartURL (sURL);
843 // The password is set only when it is not empty.
844 if (sPassword.getLength() > 0)
845 aURL.SetPass (sPassword);
846 maOpenFilesList.push_back (new String (aURL.GetMainURL( INetURLObject::NO_DECODE )));
847 mpPage1OpenLB->InsertEntry (sTitle);
848 break;
852 mbRecentDocumentsReady = TRUE;
855 UpdatePreview(TRUE);
857 catch (uno::RuntimeException& )
859 // Ignore all exceptions.
865 void AssistentDlgImpl::ProvideTemplates (void)
867 if ( ! mbTemplatesReady)
869 TemplateScanner aScanner;
870 aScanner.Scan ();
871 TemplateScanDone (aScanner.GetFolderList());
875 UpdatePreview(TRUE);
877 catch (uno::RuntimeException& e)
879 // Ignore all exceptions.
880 (void) e;
885 void AssistentDlgImpl::TemplateScanDone (
886 std::vector<TemplateDir*>& rTemplateFolder)
888 // This method is called from a thread. Therefore we get the solar mutex.
889 SolarMutexGuard aGuard;
891 // Copy the contents of the given template folders to a local list.
892 maPresentList.swap (rTemplateFolder);
894 // Fill in the list box on the first page.
895 int nFirstEntry = 0;
896 mpPage1RegionLB->Clear();
897 std::vector<TemplateDir*>::iterator I;
898 int i;
899 for (i=0,I=maPresentList.begin(); I!=maPresentList.end(); I++,i++)
901 TemplateDir* pDir = *I;
902 if (pDir == NULL)
903 continue;
905 // HACK! presnt directory is always initially selected.
906 // We have to look at the first entry to get a URL.
907 if (pDir->maEntries.size() > 0)
909 TemplateEntry* pEntry = pDir->maEntries.front();
910 if (pEntry != NULL)
911 if (pEntry->msPath.SearchAscii("presnt") != STRING_NOTFOUND)
912 nFirstEntry = i;
915 mpPage1RegionLB->InsertEntry (pDir->msRegion);
917 mpPage1RegionLB->SelectEntryPos ((USHORT)nFirstEntry);
918 mpPage1RegionLB->Update();
919 SelectTemplateRegion (mpPage1RegionLB->GetSelectEntry());
921 // Fill in the list box on the second page.
922 nFirstEntry = 0;
923 mpPage2RegionLB->Clear();
924 for (i=0,I=maPresentList.begin(); I!=maPresentList.end(); I++,i++)
926 TemplateDir* pDir = *I;
927 if (pDir == NULL)
928 continue;
930 // HACK! layout directory is always initially selected.
931 // We have to look at the first entry to get a URL.
932 if (pDir->maEntries.size() > 0)
934 TemplateEntry* pEntry = pDir->maEntries.front();
935 if (pEntry != NULL)
936 if (pEntry->msPath.SearchAscii("layout") != STRING_NOTFOUND)
937 nFirstEntry = i;
940 mpPage2RegionLB->InsertEntry (pDir->msRegion);
942 mpPage2RegionLB->SelectEntryPos ((USHORT)nFirstEntry);
943 mpPage2RegionLB->Update();
944 SelectLayoutRegion (mpPage2RegionLB->GetSelectEntry());
946 // Make the changes visible.
947 mbTemplatesReady = TRUE;
948 if (mpWindow)
949 UpdatePage();
955 // ********************************************************************
956 // Status Methoden
957 // ********************************************************************
959 void AssistentDlgImpl::SetStartType( StartType eType )
961 mpPage1EmptyRB->SetState( eType == ST_EMPTY );
962 mpPage1TemplateRB->SetState( eType == ST_TEMPLATE );
963 mpPage1OpenRB->SetState( eType == ST_OPEN );
964 maNextPageButton.Enable( eType != ST_OPEN );
966 mpPage1RegionLB->Show(eType == ST_TEMPLATE);
967 mpPage1TemplateLB->Show(eType == ST_TEMPLATE);
968 mpPage1OpenLB->Show(eType == ST_OPEN);
969 mpPage1OpenPB->Show(eType == ST_OPEN);
971 if (eType == ST_OPEN)
972 maFinishButton.SetText(maOpenStr);
973 else
974 maFinishButton.SetText(maCreateStr);
977 StartType AssistentDlgImpl::GetStartType()
979 if( mpPage1EmptyRB->IsChecked() )
980 return ST_EMPTY;
981 else if( mpPage1TemplateRB->IsChecked() )
982 return ST_TEMPLATE;
983 else
984 return ST_OPEN;
987 String AssistentDlgImpl::GetDocFileName()
989 String aTitle;
990 if(mpWindow)
992 aTitle = mpWindow->GetText();
993 USHORT nPos = aTitle.Search(sal_Unicode('('));
994 if(nPos != STRING_NOTFOUND)
995 aTitle.Erase( nPos-1 );
998 String aDocFile;
999 if( GetStartType() == ST_TEMPLATE )
1001 const USHORT nEntry = mpPage1TemplateLB->GetSelectEntryPos();
1002 TemplateEntry* pEntry = NULL;
1003 if(nEntry != (USHORT)-1)
1004 pEntry = mpTemplateRegion->maEntries[nEntry];
1006 if(pEntry)
1008 aDocFile = pEntry->msPath;
1010 aTitle.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " (" ) );
1011 aTitle.Append( pEntry->msTitle );
1012 aTitle.Append( sal_Unicode(')') );
1015 else if( GetStartType() == ST_OPEN )
1017 const USHORT nEntry = mpPage1OpenLB->GetSelectEntryPos();
1018 if(nEntry != (USHORT)-1 )
1019 aDocFile = *maOpenFilesList[nEntry];
1022 if(mpWindow)
1023 mpWindow->SetText(aTitle);
1025 return aDocFile;
1028 String AssistentDlgImpl::GetLayoutFileName()
1030 String aFile;
1031 const USHORT nEntry = mpPage2LayoutLB->GetSelectEntryPos();
1032 TemplateEntry* pEntry = NULL;
1033 if(nEntry != (USHORT)-1 && nEntry > 0)
1034 pEntry = mpLayoutRegion->maEntries[nEntry-1];
1036 if(pEntry)
1037 aFile = pEntry->msPath;
1039 return aFile;
1042 SfxObjectShellLock AssistentDlgImpl::GetDocument()
1044 // mbPreview = FALSE; // Document nicht anzeigen
1045 UpdatePreview(FALSE); // aber komplett laden
1046 UpdatePageList();
1048 SfxObjectShell* pShell = xDocShell;
1049 ::sd::DrawDocShell* pDocShell = PTR_CAST(::sd::DrawDocShell,pShell);
1050 SdDrawDocument* pDoc = pDocShell?pDocShell->GetDoc():NULL;
1052 if(pDoc)
1054 const USHORT nPageCount = pDoc->GetSdPageCount(PK_STANDARD);
1055 BOOL bKiosk = mpPage3PresTypeKioskRB->IsChecked();
1056 UINT32 nNewTime = (UINT32)mpPage3PresTimeTMF->GetTime().GetMSFromTime() / 1000;
1057 if(bKiosk)
1059 PresentationSettings& rSettings = pDoc->getPresentationSettings();
1060 rSettings.mbEndless = bKiosk;
1061 rSettings.mnPauseTimeout = (sal_Int32)mpPage3BreakTMF->GetTime().GetMSFromTime() / 1000;
1062 rSettings.mbShowPauseLogo = mpPage3LogoCB->IsChecked();
1065 USHORT nPgAbsNum = 0;
1066 USHORT nPgRelNum = 0;
1067 while( nPgAbsNum < nPageCount )
1069 SdPage* pPage = pDoc->GetSdPage( nPgRelNum, PK_STANDARD );
1070 if( mpPage5PageListCT->IsPageChecked(nPgAbsNum) )
1072 mpPage3EffectLB->applySelected(pPage);
1073 const sal_uInt16 nPos = mpPage3SpeedLB->GetSelectEntryPos();
1074 pPage->setTransitionDuration( (nPos == 0) ? 3.0 : (nPos == 1) ? 2.0 : 1.0 );
1075 if(bKiosk)
1077 pPage->SetPresChange( PRESCHANGE_AUTO );
1078 pPage->SetTime(nNewTime);
1080 nPgRelNum++;
1082 else
1084 // diese Seite loeschen
1085 pDoc->DeletePage( (nPgRelNum << 1) + 2 ); // Notizseite loeschen
1086 pDoc->DeletePage( (nPgRelNum << 1) + 1 ); // Seite loeschen
1089 nPgAbsNum++;
1092 else
1094 DBG_ERROR("sd::AssistentDlgImpl::GetDocument(), no template?");
1097 SfxObjectShellLock xRet = xDocShell;
1098 xDocShell = NULL;
1100 return xRet;
1103 void AssistentDlgImpl::LeavePage()
1105 int nPage = maAssistentFunc.GetCurrentPage();
1107 if( nPage == 4 && mbUserDataDirty )
1108 maPrevTimer.Start();
1111 void AssistentDlgImpl::ChangePage()
1113 maNextPageButton.Enable(!maAssistentFunc.IsLastPage());
1114 maLastPageButton.Enable(!maAssistentFunc.IsFirstPage());
1116 USHORT nPage = (USHORT)maAssistentFunc.GetCurrentPage();
1118 if( mpWindow )
1119 mpWindow->SetHelpId( PageHelpIds[nPage-1]);
1121 UpdatePage();
1123 if( maNextPageButton.IsEnabled() )
1125 maNextPageButton.ForceFocusEventBroadcast();
1127 else
1128 maFinishButton.GrabFocus();
1131 void AssistentDlgImpl::UpdatePage()
1133 USHORT nPage = (USHORT)maAssistentFunc.GetCurrentPage();
1135 switch(nPage)
1137 case 1:
1139 // Elemente auf der ersten Seite abhaengig vom Starttype Zeigen
1140 SetStartType( GetStartType() );
1141 mpPage1TemplateRB->Enable(TRUE /*mbTemplatesReady*/);
1142 break;
1145 case 2:
1147 mpPage2RegionLB->Enable(mbTemplatesReady);
1148 mpPage2LayoutLB->Enable(mbTemplatesReady);
1150 if( GetStartType() != ST_EMPTY )
1152 mpPage2Medium5RB->Enable( TRUE );
1154 else
1156 mpPage2Medium5RB->Enable( FALSE );
1157 if(mpPage2Medium5RB->IsChecked())
1158 mpPage2Medium1RB->Check();
1161 break;
1163 case 5:
1165 if(mbDocPreview || maPageListFile != maDocFile)
1166 mpPage5PageListCT->Clear();
1168 maUpdatePageListTimer.Start();
1169 break;
1172 case 3:
1174 if(GetStartType() != ST_TEMPLATE)
1175 maNextPageButton.Enable(false);
1177 BOOL bKiosk = mpPage3PresTypeKioskRB->IsChecked();
1178 mpPage3PresTimeFT->Enable(bKiosk);
1179 mpPage3BreakFT->Enable(bKiosk);
1180 mpPage3PresTimeTMF->Enable(bKiosk);
1181 mpPage3BreakTMF->Enable(bKiosk);
1182 mpPage3LogoCB->Enable(bKiosk);
1183 break;
1188 // ********************************************************************
1189 // UI-Handler
1190 // ********************************************************************
1192 IMPL_LINK( AssistentDlgImpl, SelectRegionHdl, ListBox *, pLB )
1194 if( pLB == mpPage1RegionLB )
1196 SelectTemplateRegion( pLB->GetSelectEntry() );
1197 SetStartType( ST_TEMPLATE );
1198 mpPage2Medium5RB->Check();
1200 else
1202 SelectLayoutRegion( pLB->GetSelectEntry() );
1205 return 0;
1208 IMPL_LINK( AssistentDlgImpl, SelectEffectHdl, void*, EMPTYARG )
1210 maEffectPrevTimer.Start();
1211 return 0;
1214 IMPL_LINK( AssistentDlgImpl, OpenButtonHdl, Button*, pButton )
1216 // Clear the selection and forward the call.
1217 mpPage1OpenLB->SetNoSelection();
1218 return mpPage1OpenLB->GetDoubleClickHdl().Call(pButton);
1221 IMPL_LINK( AssistentDlgImpl, EffectPreviewHdl, Button *, EMPTYARG )
1223 if(mbPreview && xDocShell.Is() )
1225 SfxObjectShell* pShell = xDocShell;
1226 DrawDocShell* pDocShell = dynamic_cast< DrawDocShell * >(pShell);
1227 if( pDocShell )
1229 SdDrawDocument* pDoc = pDocShell->GetDoc();
1230 if( pDoc )
1232 SdPage* pPage = pDoc->GetSdPage( mnShowPage, PK_STANDARD );
1233 if( pPage )
1234 mpPage3EffectLB->applySelected(pPage);
1237 maPreview.startPreview();
1239 return 0;
1242 IMPL_LINK( AssistentDlgImpl, PreviewFlagHdl, CheckBox *, EMPTYARG )
1245 if( maPreviewFlag.IsChecked() != mbPreview )
1247 mbPreview = maPreviewFlag.IsChecked();
1248 UpdatePreview(TRUE);
1250 return 0;
1253 IMPL_LINK( AssistentDlgImpl, SelectTemplateHdl, ListBox *, EMPTYARG )
1255 SetStartType( ST_TEMPLATE );
1256 mpPage2Medium5RB->Check();
1257 mpPage2LayoutLB->SelectEntryPos(0);
1258 maPrevTimer.Start();
1259 return 0;
1262 IMPL_LINK( AssistentDlgImpl, SelectLayoutHdl, ListBox *, EMPTYARG )
1264 maPrevTimer.Start();
1265 return 0;
1268 IMPL_LINK( AssistentDlgImpl, SelectFileHdl, ListBox *, EMPTYARG )
1270 SetStartType( ST_OPEN );
1271 maPrevTimer.Start();
1272 return 0;
1275 IMPL_LINK( AssistentDlgImpl, PageSelectHdl, Control *, EMPTYARG )
1277 USHORT nPage = mpPage5PageListCT->GetSelectedPage();
1278 if( mnShowPage != nPage )
1280 mnShowPage = nPage;
1281 UpdatePreview(FALSE);
1284 return 0;
1287 IMPL_LINK( AssistentDlgImpl, UpdatePageListHdl, void *, EMPTYARG )
1289 UpdatePageList();
1290 return 0;
1293 IMPL_LINK( AssistentDlgImpl, UpdatePreviewHdl, void *, EMPTYARG )
1295 UpdatePreview( TRUE );
1296 return 0;
1299 IMPL_LINK( AssistentDlgImpl, StartTypeHdl, RadioButton *, pButton )
1301 StartType eType = pButton == mpPage1EmptyRB?ST_EMPTY:pButton == mpPage1TemplateRB?ST_TEMPLATE:ST_OPEN;
1303 if(eType == ST_TEMPLATE)
1304 ProvideTemplates();
1305 else if(eType == ST_OPEN)
1306 ScanDocmenu();
1308 SetStartType( eType );
1310 if(eType == ST_TEMPLATE)
1312 mpPage1TemplateLB->SelectEntryPos(0);
1313 mpPage2Medium5RB->Check();
1315 else if(eType == ST_OPEN)
1316 mpPage1OpenLB->SelectEntryPos(0);
1318 maPrevTimer.Start();
1319 return 0;
1323 IMPL_LINK( AssistentDlgImpl, NextPageHdl, PushButton *, EMPTYARG )
1325 // When changing from the first to the second page make sure that the
1326 // templates are present.
1327 if (maAssistentFunc.GetCurrentPage() == 1)
1328 ProvideTemplates();
1330 // Change to the next page.
1331 LeavePage();
1332 maAssistentFunc.NextPage();
1333 ChangePage();
1334 return 0;
1337 IMPL_LINK( AssistentDlgImpl, LastPageHdl, PushButton *, EMPTYARG )
1339 LeavePage();
1340 maAssistentFunc.PreviousPage();
1341 ChangePage();
1342 return 0;
1345 IMPL_LINK( AssistentDlgImpl, PresTypeHdl, RadioButton*, EMPTYARG )
1347 if(maDocFile.Len() == 0)
1349 maNextPageButton.Enable(false);
1352 BOOL bKiosk = mpPage3PresTypeKioskRB->IsChecked();
1353 mpPage3PresTimeFT->Enable(bKiosk);
1354 mpPage3BreakFT->Enable(bKiosk);
1355 mpPage3PresTimeTMF->Enable(bKiosk);
1356 mpPage3BreakTMF->Enable(bKiosk);
1357 mpPage3LogoCB->Enable(bKiosk);
1358 return 0;
1361 IMPL_LINK( AssistentDlgImpl, UpdateUserDataHdl, Edit*, EMPTYARG )
1363 mbUserDataDirty = TRUE;
1364 String aTopic = mpPage4AskTopicEDT->GetText();
1365 String aName = mpPage4AskNameEDT->GetText();
1366 String aInfo = mpPage4AskInfoEDT->GetText();
1368 if(aTopic.Len() == 0 && aName.Len() == 0 && aInfo.Len() == 0)
1369 maDocFile.Erase();
1371 return 0;
1374 // ********************************************************************
1375 // ********************************************************************
1377 void AssistentDlgImpl::SelectTemplateRegion( const String& rRegion )
1379 mpPage1TemplateLB->Clear();
1380 std::vector<TemplateDir*>::iterator I;
1381 for (I=maPresentList.begin(); I!=maPresentList.end(); I++)
1383 TemplateDir * pDir = *I;
1384 mpTemplateRegion = *I;
1385 if (pDir->msRegion.Equals( rRegion ) )
1387 std::vector<TemplateEntry*>::iterator J;
1388 for (J=pDir->maEntries.begin(); J!=pDir->maEntries.end(); J++)
1389 mpPage1TemplateLB->InsertEntry ((*J)->msTitle);
1390 mpPage1TemplateLB->Update();
1391 if(GetStartType() == ST_TEMPLATE)
1393 mpPage1TemplateLB->SelectEntryPos( 0 );
1394 SelectTemplateHdl(NULL);
1396 break;
1401 void AssistentDlgImpl::SelectLayoutRegion( const String& rRegion )
1403 mpPage2LayoutLB->Clear();
1404 mpPage2LayoutLB->InsertEntry(String(SdResId(STR_WIZARD_ORIGINAL)));
1405 std::vector<TemplateDir*>::iterator I;
1406 for (I=maPresentList.begin(); I!=maPresentList.end(); I++)
1408 TemplateDir * pDir = *I;
1409 mpLayoutRegion = *I;
1411 if (pDir->msRegion.Equals (rRegion))
1413 std::vector<TemplateEntry*>::iterator J;
1414 for (J=pDir->maEntries.begin(); J!=pDir->maEntries.end(); J++)
1415 mpPage2LayoutLB->InsertEntry ((*J)->msTitle);
1416 mpPage2LayoutLB->Update();
1417 break;
1422 void AssistentDlgImpl::UpdateUserData()
1424 String aTopic = mpPage4AskTopicEDT->GetText();
1425 String aName = mpPage4AskNameEDT->GetText();
1426 String aInfo = mpPage4AskInfoEDT->GetText();
1428 SfxObjectShell* pShell = xDocShell;
1429 DrawDocShell* pDocShell = PTR_CAST(DrawDocShell,pShell);
1430 SdDrawDocument* pDoc = pDocShell?pDocShell->GetDoc():NULL;
1431 SdPage* pPage = pDoc?pDoc->GetSdPage(0, PK_STANDARD):NULL;
1433 if(pPage && ( aTopic.Len() != 0 || aName.Len() != 0 || aInfo.Len() != 0 ) )
1435 if( pPage->GetAutoLayout() == AUTOLAYOUT_NONE )
1436 pPage->SetAutoLayout(AUTOLAYOUT_TITLE, TRUE);
1438 SdrTextObj* pObj;
1439 String aEmptyString;
1441 if( aTopic.Len() )
1443 pObj = dynamic_cast<SdrTextObj*>( pPage->GetPresObj( PRESOBJ_TITLE ) );
1444 if( pObj )
1446 pPage->SetObjText( pObj, NULL, PRESOBJ_TITLE, aTopic );
1447 pObj->NbcSetStyleSheet( pPage->GetStyleSheetForPresObj( PRESOBJ_TITLE ), TRUE );
1448 pObj->SetEmptyPresObj(FALSE);
1453 if ( aName.Len() || aInfo.Len() )
1455 String aStrTmp( aName );
1456 if( aName.Len() )
1457 aStrTmp.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "\n\n" ) );
1458 aStrTmp.Append( aInfo );
1460 pObj = dynamic_cast<SdrTextObj*>( pPage->GetPresObj( PRESOBJ_OUTLINE ) );
1461 if( pObj )
1463 pPage->SetObjText( pObj, NULL, PRESOBJ_OUTLINE, aStrTmp );
1464 pObj->NbcSetStyleSheet( pPage->GetStyleSheetForPresObj( PRESOBJ_OUTLINE ), TRUE );
1465 pObj->SetEmptyPresObj(FALSE);
1467 else
1469 pObj = dynamic_cast<SdrTextObj*>( pPage->GetPresObj( PRESOBJ_TEXT ) );
1470 if( pObj )
1472 pPage->SetObjText( pObj, NULL, PRESOBJ_TEXT, aStrTmp );
1473 pObj->NbcSetStyleSheet( pPage->GetStyleSheetForPresObj( PRESOBJ_TEXT ), TRUE );
1474 pObj->SetEmptyPresObj(FALSE);
1480 mbUserDataDirty = FALSE;
1483 void AssistentDlgImpl::UpdatePageList()
1485 if(mbDocPreview || !mbPreview)
1486 UpdatePreview(FALSE);
1487 else if(maPageListFile == maDocFile)
1488 return;
1490 maPageListFile = maDocFile;
1492 SfxObjectShell* pShell = xDocShell;
1493 DrawDocShell* pDocShell = PTR_CAST(DrawDocShell,pShell);
1494 SdDrawDocument* pDoc = pDocShell?pDocShell->GetDoc():NULL;
1496 mpPage5PageListCT->Clear();
1498 if(pDoc)
1499 mpPage5PageListCT->Fill(pDoc);
1502 void AssistentDlgImpl::UpdatePreview( BOOL bDocPreview )
1504 // Guard against multiple concurrent execution to this method caused either
1505 // by calls from different threads or recursion.
1506 ::osl::MutexGuard aGuard (maMutex);
1507 if (mbPreviewUpdating)
1508 return;
1509 mbPreviewUpdating = TRUE;
1511 if(!mbPreview && bDocPreview)
1513 maPreview.Invalidate();
1514 maPreview.SetObjectShell(0);
1515 mbPreviewUpdating = FALSE;
1516 return;
1519 String aDocFile = GetDocFileName();
1520 String aLayoutFile = GetLayoutFileName();
1521 String aEmptyStr;
1523 SfxApplication *pSfxApp = SFX_APP();
1524 ULONG lErr;
1525 BOOL bChangeMaster = aLayoutFile.Len() != 0;
1527 if( aDocFile.Len() == 0 )
1529 if( !xDocShell.Is() || maDocFile.Len() != 0 ||
1530 (maDocFile.Len() == 0 && maLayoutFile.Len() != 0 && aLayoutFile.Len() == 0 ))
1532 CloseDocShell();
1534 DrawDocShell* pNewDocSh;
1535 xDocShell = pNewDocSh = new DrawDocShell(SFX_CREATE_MODE_STANDARD, FALSE);
1536 pNewDocSh->DoInitNew(NULL);
1537 SdDrawDocument* pDoc = pNewDocSh->GetDoc();
1538 pDoc->CreateFirstPages();
1539 pDoc->StopWorkStartupDelay();
1540 mbDocPreview = FALSE;
1542 maDocFile = aDocFile;
1543 mbUserDataDirty = TRUE;
1545 else
1546 bChangeMaster = (aLayoutFile.Len() != 0) && (maLayoutFile != aLayoutFile);
1548 else if( aDocFile == maDocFile && ( mbDocPreview == bDocPreview || bDocPreview ) )
1550 if( aLayoutFile != maLayoutFile )
1552 SfxObjectShell* pShell = xDocShell;
1553 DrawDocShell* pDocShell = PTR_CAST(DrawDocShell,pShell);
1554 SfxUndoManager* pUndoMgr = pDocShell?pDocShell->GetUndoManager():NULL;
1555 if(pUndoMgr)
1556 pUndoMgr->Undo();
1557 mbUserDataDirty = TRUE;
1559 else
1560 bChangeMaster = FALSE;
1562 else
1564 CloseDocShell();
1566 ::Window *pParent = Application::GetDefDialogParent();
1567 Application::SetDefDialogParent( mpWindow );
1569 SfxErrorContext eEC(ERRCTX_SFX_LOADTEMPLATE,mpWindow);
1571 SfxItemSet* pSet = new SfxAllItemSet( pSfxApp->GetPool() );
1572 if(IsOwnFormat(aDocFile))
1574 pSet->Put( SfxBoolItem( SID_TEMPLATE, TRUE ) );
1575 if(bDocPreview)
1576 pSet->Put( SfxBoolItem( SID_PREVIEW, TRUE ) );
1577 RestorePassword( pSet, aDocFile );
1578 if( (lErr = pSfxApp->LoadTemplate( xDocShell, aDocFile, TRUE, pSet )) != 0 )
1579 ErrorHandler::HandleError(lErr);
1580 else
1581 SavePassword( xDocShell, aDocFile );
1583 else
1585 const String aTargetStr( RTL_CONSTASCII_USTRINGPARAM("_default") );
1587 SfxRequest aReq( SID_OPENDOC, SFX_CALLMODE_SYNCHRON, SFX_APP()->GetPool() );
1588 aReq.AppendItem( SfxStringItem( SID_FILE_NAME, aDocFile ));
1589 aReq.AppendItem( SfxStringItem( SID_REFERER, aEmptyStr ) );
1590 aReq.AppendItem( SfxStringItem( SID_TARGETNAME, aTargetStr ) );
1591 aReq.AppendItem( SfxBoolItem( SID_HIDDEN, TRUE ) );
1592 aReq.AppendItem( SfxBoolItem( SID_PREVIEW, bDocPreview ) );
1594 const SfxViewFrameItem* pRet = PTR_CAST( SfxViewFrameItem, SFX_APP()->ExecuteSlot( aReq ) );
1596 if ( pRet && pRet->GetFrame() && pRet->GetFrame()->GetObjectShell() )
1597 xDocShell = pRet->GetFrame()->GetObjectShell();
1601 Application::SetDefDialogParent( pParent );
1603 mnShowPage = 0;
1604 mbDocPreview = bDocPreview;
1605 maDocFile = aDocFile;
1606 mbUserDataDirty = TRUE;
1609 if(bChangeMaster && (aLayoutFile != maDocFile))
1611 // Layoutvorlage laden
1612 SfxObjectShellLock xLayoutDocShell;
1613 SfxErrorContext eEC(ERRCTX_SFX_LOADTEMPLATE,mpWindow);
1614 SfxItemSet* pSet = new SfxAllItemSet( pSfxApp->GetPool() );
1616 ::Window *pParent = Application::GetDefDialogParent();
1617 Application::SetDefDialogParent( mpWindow );
1619 if(IsOwnFormat(aLayoutFile))
1621 pSet->Put( SfxBoolItem( SID_TEMPLATE, TRUE ) );
1622 pSet->Put( SfxBoolItem( SID_PREVIEW, TRUE ) );
1624 RestorePassword( pSet, aLayoutFile );
1625 if( (lErr = pSfxApp->LoadTemplate( xLayoutDocShell, aLayoutFile, TRUE, pSet )) != 0 )
1626 ErrorHandler::HandleError(lErr);
1627 SavePassword( xLayoutDocShell, aLayoutFile );
1630 Application::SetDefDialogParent( pParent );
1632 // die Implementierung ermitteln
1633 SfxObjectShell* pShell = xDocShell;
1634 DrawDocShell* pDocShell = PTR_CAST(DrawDocShell,pShell);
1635 SdDrawDocument* pDoc = pDocShell?pDocShell->GetDoc():NULL;
1637 pShell = xLayoutDocShell;
1638 pDocShell = PTR_CAST(DrawDocShell,pShell);
1639 SdDrawDocument* pLayoutDoc = pDocShell?pDocShell->GetDoc():NULL;
1641 if( pDoc && pLayoutDoc )
1643 pDoc->SetMasterPage(0, aEmptyStr, pLayoutDoc, TRUE, FALSE );
1645 else
1647 DBG_ERROR("sd::AssistentDlgImpl::UpdatePreview(), no document for preview?");
1650 mbUserDataDirty = TRUE;
1652 maLayoutFile = aLayoutFile;
1654 if(mbUserDataDirty)
1655 UpdateUserData();
1657 if ( !xDocShell.Is() || !mbPreview )
1658 maPreview.SetObjectShell( 0 );
1659 else
1661 maPreview.SetObjectShell( xDocShell, mnShowPage );
1664 mbPreviewUpdating = FALSE;
1667 void AssistentDlgImpl::SavePassword( SfxObjectShellLock xDoc, const String& rPath )
1669 if(xDoc.Is())
1671 SfxMedium * pMedium = xDoc->GetMedium();
1672 if(pMedium && pMedium->IsStorage())
1674 SfxItemSet * pSet = pMedium->GetItemSet();
1675 const SfxPoolItem *pItem = 0;
1676 if( pSet->GetItemState(SID_PASSWORD, TRUE, &pItem) == SFX_ITEM_SET )
1678 //TODO/MBA: testing
1679 String aPass( ((const SfxStringItem*)pItem)->GetValue());
1680 if(aPass.Len() == 0)
1681 return;
1683 PasswordEntry* pEntry = maPasswordList.First();
1684 while(pEntry)
1686 if(pEntry->maPath == rPath)
1687 break;
1689 pEntry = maPasswordList.Next();
1693 if(pEntry == NULL)
1695 pEntry = new PasswordEntry();
1696 pEntry->maPath = rPath;
1697 maPasswordList.Insert( pEntry );
1700 if(pEntry)
1701 pEntry->maPassword = aPass;
1707 void AssistentDlgImpl::RestorePassword( SfxItemSet* pSet, const String& rPath )
1709 String aPassword( GetPassword( rPath ) );
1711 if(aPassword.Len())
1712 pSet->Put( SfxStringItem( SID_PASSWORD, aPassword ) );
1715 String AssistentDlgImpl::GetPassword( const String rPath )
1717 PasswordEntry* pEntry = maPasswordList.First();
1718 while(pEntry)
1720 if(pEntry->maPath == rPath)
1721 return pEntry->maPassword;
1723 pEntry = maPasswordList.Next();
1726 return String();
1729 void AssistentDlgImpl::DeletePassords()
1731 PasswordEntry* pEntry = maPasswordList.First();
1732 while(pEntry)
1734 delete pEntry;
1735 pEntry = maPasswordList.Next();
1739 BOOL AssistentDlgImpl::IsOwnFormat( const String& rPath )
1741 INetURLObject aURL( rPath );
1742 String aExt( aURL.GetFileExtension() );
1744 DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
1746 return !aExt.EqualsIgnoreCaseAscii( "ppt" );
1752 String AssistentDlgImpl::GetUiTextForCommand (const ::rtl::OUString& sCommandURL)
1754 String sLabel;
1755 Reference<container::XNameAccess> xUICommandLabels;
1761 if (sCommandURL.getLength() == 0)
1762 break;
1764 // Retrieve popup menu labels
1765 Reference<lang::XMultiServiceFactory> xFactory (
1766 ::comphelper::getProcessServiceFactory ());
1767 if ( ! xFactory.is())
1768 break;
1770 ::rtl::OUString sModuleIdentifier (
1771 RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PresentationDocument"));
1772 Reference<container::XNameAccess> xNameAccess (
1773 xFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
1774 "com.sun.star.frame.UICommandDescription"))),
1775 UNO_QUERY);
1776 if ( ! xNameAccess.is())
1777 break;
1778 Any a = xNameAccess->getByName(sModuleIdentifier);
1779 a >>= xUICommandLabels;
1780 if ( ! xUICommandLabels.is())
1781 break;
1783 ::rtl::OUString sString;
1784 Sequence<beans::PropertyValue> aProperties;
1785 Any aAny (xUICommandLabels->getByName(sCommandURL));
1786 if (aAny >>= aProperties)
1788 sal_Int32 nCount (aProperties.getLength());
1789 for (sal_Int32 i=0; i<nCount; i++)
1791 ::rtl::OUString sPropertyName (aProperties[i].Name);
1792 if (sPropertyName.equalsAscii("Label"))
1794 aProperties[i].Value >>= sString;
1795 break;
1799 sLabel = sString;
1801 while(false);
1803 catch (com::sun::star::uno::Exception& rException)
1805 (void)rException;
1808 return sLabel;
1814 Image AssistentDlgImpl::GetUiIconForCommand (const ::rtl::OUString& sCommandURL)
1816 Image aIcon;
1817 Reference<container::XNameAccess> xUICommandLabels;
1823 if (sCommandURL.getLength() == 0)
1824 break;
1826 // Retrieve popup menu labels
1827 Reference<lang::XMultiServiceFactory> xFactory (
1828 ::comphelper::getProcessServiceFactory ());
1829 if ( ! xFactory.is())
1830 break;
1832 ::rtl::OUString sModuleIdentifier (
1833 RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PresentationDocument"));
1835 Reference<com::sun::star::ui::XModuleUIConfigurationManagerSupplier> xSupplier (
1836 xFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
1837 "com.sun.star.ui.ModuleUIConfigurationManagerSupplier"))),
1838 UNO_QUERY_THROW);
1840 Reference<com::sun::star::ui::XUIConfigurationManager> xManager (
1841 xSupplier->getUIConfigurationManager(sModuleIdentifier));
1842 if ( ! xManager.is())
1843 break;
1845 Reference<com::sun::star::ui::XImageManager> xImageManager (
1846 xManager->getImageManager(),
1847 UNO_QUERY_THROW);
1849 Sequence<rtl::OUString> aCommandList(1);
1850 aCommandList[0] = sCommandURL;
1851 Sequence<Reference<graphic::XGraphic> > xIconList (
1852 xImageManager->getImages(0,aCommandList));
1853 if ( ! xIconList.hasElements())
1854 break;
1856 aIcon = Graphic(xIconList[0]).GetBitmapEx();
1858 while(false);
1860 catch (com::sun::star::uno::Exception& rException)
1862 (void)rException;
1865 return aIcon;
1869 //////////////////////////////////////////////
1871 AssistentDlg::AssistentDlg(Window* pParent, BOOL bAutoPilot) :
1872 ModalDialog(pParent,SdResId(DLG_ASS))
1874 Link aFinishLink = LINK(this,AssistentDlg, FinishHdl);
1875 mpImpl = new AssistentDlgImpl( this, aFinishLink, bAutoPilot );
1877 //Buttonbelegung
1878 mpImpl->maFinishButton.SetClickHdl(LINK(this,AssistentDlg,FinishHdl));
1880 FreeResource();
1883 IMPL_LINK( AssistentDlg, FinishHdl, OKButton *, EMPTYARG )
1885 if( GetStartType() == ST_OPEN )
1887 //if we do not have a file here asked for one before ending the dialog
1888 String aFileToOpen = GetDocPath();
1889 if(aFileToOpen.Len() == 0)
1891 sfx2::FileDialogHelper aFileDlg( WB_OPEN, ::String::CreateFromAscii("simpress") );
1893 if ( aFileDlg.Execute() == ERRCODE_NONE )
1894 aFileToOpen = aFileDlg.GetPath();
1895 if( aFileToOpen.Len() == 0)
1896 return 1;
1897 else
1899 //add the selected file to the recent-file-listbox and select the new entry
1900 //this is necessary for 'GetDocPath()' returning the selected file after end of dialog
1902 INetURLObject aURL;
1903 aURL.SetSmartURL(aFileToOpen);
1904 mpImpl->maOpenFilesList.push_back (new String (aURL.GetMainURL( INetURLObject::NO_DECODE )));
1905 USHORT nNewPos = mpImpl->mpPage1OpenLB->InsertEntry(aURL.getName());
1906 mpImpl->mpPage1OpenLB->SelectEntryPos(nNewPos);
1911 //Ende
1912 mpImpl->EndDialog(RET_OK);
1913 EndDialog(RET_OK);
1914 return 0;
1917 AssistentDlg::~AssistentDlg()
1919 delete mpImpl;
1923 SfxObjectShellLock AssistentDlg::GetDocument()
1925 return mpImpl->GetDocument();
1928 OutputType AssistentDlg::GetOutputMedium() const
1930 if(mpImpl->mpPage2Medium1RB->IsChecked())
1931 return OUTPUT_PRESENTATION;
1932 else if(mpImpl->mpPage2Medium2RB->IsChecked())
1933 return OUTPUT_SLIDE;
1934 else if(mpImpl->mpPage2Medium3RB->IsChecked())
1935 return OUTPUT_OVERHEAD;
1936 else if(mpImpl->mpPage2Medium4RB->IsChecked())
1937 return OUTPUT_PAGE;
1938 else
1939 return OUTPUT_ORIGINAL;
1942 BOOL AssistentDlg::IsSummary() const
1944 return mpImpl->mpPage5SummaryCB->IsChecked();
1947 StartType AssistentDlg::GetStartType() const
1949 return mpImpl->GetStartType();
1952 String AssistentDlg::GetDocPath() const
1954 return mpImpl->GetDocFileName();
1957 BOOL AssistentDlg::GetStartWithFlag() const
1959 return !mpImpl->maStartWithFlag.IsChecked();
1962 BOOL AssistentDlg::IsDocEmpty() const
1964 return mpImpl->GetDocFileName().Len() == 0 &&
1965 mpImpl->GetLayoutFileName().Len() == 0;
1968 String AssistentDlg::GetPassword()
1970 return mpImpl->GetPassword( mpImpl->maDocFile );
1976 //===== NextButton ============================================================
1978 NextButton::NextButton (::Window* pParent, const ResId& rResId)
1979 : maNextButton1(pParent, rResId),
1980 maNextButton2(pParent, rResId),
1981 mbIsFirstButtonActive(true)
1983 // Hide the unused button.
1984 maNextButton2.Hide();
1990 void NextButton::ForceFocusEventBroadcast (void)
1992 // Hide the currently visible button and show and focus the other one.
1993 if (mbIsFirstButtonActive)
1995 mbIsFirstButtonActive = false;
1996 maNextButton2.Show();
1997 maNextButton2.GrabFocus();
1998 maNextButton1.Hide();
2000 else
2002 mbIsFirstButtonActive = true;
2003 maNextButton1.Show();
2004 maNextButton1.GrabFocus();
2005 maNextButton2.Hide();
2012 void NextButton::SetClickHdl (const Link& rLink)
2014 // Forward the setting of the click handler to the two buttons
2015 // regardless of which one is currently visible.
2016 maNextButton1.SetClickHdl(rLink);
2017 maNextButton2.SetClickHdl(rLink);
2023 bool NextButton::IsEnabled (void)
2025 // Because the buttons are both either enabled or disabled, it is
2026 // sufficient to ask one to determine the state.
2027 return maNextButton1.IsEnabled();
2033 void NextButton::Enable (bool bEnable)
2035 // Enable or disable both buttons but do not change visibility or focus.
2036 maNextButton1.Enable(bEnable);
2037 maNextButton2.Enable(bEnable);
2040 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */