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