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