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