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