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