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_sw.hxx" 26 27 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 28 #include <com/sun/star/frame/XDispatchHelper.hpp> 29 30 #include <comphelper/processfactory.hxx> 31 32 #include <hintids.hxx> 33 #include <tools/urlobj.hxx> 34 #include <unotools/tempfile.hxx> 35 #include <vcl/wrkwin.hxx> 36 #include <vcl/msgbox.hxx> 37 #include <svl/lckbitem.hxx> 38 #include <svl/eitem.hxx> 39 #include <svl/zforlist.hxx> 40 #include <svl/zformat.hxx> 41 #include <unotools/pathoptions.hxx> 42 #include <svtools/transfer.hxx> 43 #include <sfx2/dialogs.hrc> 44 #include <sfx2/dinfdlg.hxx> 45 #include <sfx2/request.hxx> 46 #include <sfx2/dispatch.hxx> 47 #include <sfx2/new.hxx> 48 #include <sfx2/filedlghelper.hxx> 49 #include <sfx2/printer.hxx> 50 #include <sfx2/evntconf.hxx> 51 #include <svtools/sfxecode.hxx> 52 #include <sfx2/docfile.hxx> 53 #include <sfx2/docfilt.hxx> 54 #include <svx/svxids.hrc> 55 #include <svx/drawitem.hxx> 56 #include <editeng/svxacorr.hxx> 57 #include <editeng/langitem.hxx> 58 #include <svx/fmshell.hxx> 59 60 #include <svtools/htmlcfg.hxx> 61 //#include <svx/paletteitem.hxx> 62 #include <SwSmartTagMgr.hxx> 63 #include <sfx2/app.hxx> 64 #include <basic/sbstar.hxx> 65 #include <basic/basmgr.hxx> 66 #include <sot/storage.hxx> 67 #include <sot/clsids.hxx> 68 #include <swunodef.hxx> 69 #include <fmtcol.hxx> 70 #include <swevent.hxx> 71 #include <view.hxx> // fuer die aktuelle Sicht 72 #include <docsh.hxx> // Dokumenterzeugung 73 #include <wrtsh.hxx> 74 #include <fldbas.hxx> 75 #include <viewopt.hxx> 76 #include <globdoc.hxx> 77 #include <fldwrap.hxx> 78 #include <redlndlg.hxx> 79 #include <docstyle.hxx> 80 #include <doc.hxx> 81 #include <IDocumentUndoRedo.hxx> 82 #include <pagedesc.hxx> 83 #include <shellio.hxx> 84 #include <pview.hxx> 85 #include <srcview.hxx> 86 #include <poolfmt.hxx> 87 #include <usrpref.hxx> 88 #include <wdocsh.hxx> 89 #include <unotxdoc.hxx> 90 #include <acmplwrd.hxx> 91 #include <swmodule.hxx> 92 #include <unobaseclass.hxx> 93 #include <swwait.hxx> 94 #include <swcli.hxx> 95 96 #include <cmdid.h> 97 #include <globals.h> 98 #include <helpid.h> 99 #include <app.hrc> 100 #include <poolfmt.hrc> 101 #include <globals.hrc> 102 #include <com/sun/star/ui/dialogs/XFilePicker.hpp> 103 #include <com/sun/star/ui/dialogs/XFilterManager.hpp> 104 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> 105 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> 106 #include <com/sun/star/ui/dialogs/ListboxControlActions.hpp> 107 #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp> 108 #include "com/sun/star/ui/dialogs/TemplateDescription.hpp" 109 #ifdef FUTURE_VBA 110 #include <com/sun/star/script/vba/XVBAEventProcessor.hpp> 111 #include <com/sun/star/script/vba/VBAEventId.hpp> 112 #endif 113 #include <editeng/acorrcfg.hxx> 114 #include <SwStyleNameMapper.hxx> 115 116 #include <sfx2/fcontnr.hxx> 117 118 #include "swabstdlg.hxx" 119 #include "dialog.hrc" 120 #include "swabstdlg.hxx" 121 122 #include <ndtxt.hxx> //#outline level,add by zhaojianwei 123 124 using namespace ::com::sun::star::ui::dialogs; 125 using namespace ::com::sun::star::lang; 126 using namespace ::com::sun::star::uno; 127 using namespace ::com::sun::star; 128 using ::rtl::OUString; 129 using namespace ::sfx2; 130 extern sal_Bool FindPhyStyle( SwDoc& , const String& , SfxStyleFamily ); 131 132 /*-------------------------------------------------------------------- 133 Beschreibung: DocInfo kreieren (virtuell) 134 --------------------------------------------------------------------*/ 135 136 SfxDocumentInfoDialog* SwDocShell::CreateDocumentInfoDialog( 137 Window *pParent, const SfxItemSet &rSet) 138 { 139 SfxDocumentInfoDialog* pDlg = new SfxDocumentInfoDialog(pParent, rSet); 140 //nur mit Statistik, wenn dieses Doc auch angezeigt wird, nicht 141 //aus dem Doc-Manager 142 SwDocShell* pDocSh = (SwDocShell*) SfxObjectShell::Current(); 143 if( pDocSh == this ) 144 { 145 //Nicht fuer SourceView. 146 SfxViewShell *pVSh = SfxViewShell::Current(); 147 if ( pVSh && !pVSh->ISA(SwSrcView) ) 148 { 149 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 150 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 151 pDlg->AddTabPage(TP_DOC_STAT, SW_RESSTR(STR_DOC_STAT),pFact->GetTabPageCreatorFunc( TP_DOC_STAT ),0); 152 } 153 } 154 return pDlg; 155 } 156 157 // Disable "multiple layout" 158 159 void SwDocShell::ToggleBrowserMode(sal_Bool bSet, SwView* _pView ) 160 { 161 GetDoc()->set(IDocumentSettingAccess::BROWSE_MODE, bSet ); 162 UpdateFontList(); 163 SwView* pTempView = _pView ? _pView : (SwView*)GetView(); 164 if( pTempView ) 165 { 166 pTempView->GetViewFrame()->GetBindings().Invalidate(FN_SHADOWCURSOR); 167 if( !GetDoc()->getPrinter( false ) ) 168 pTempView->SetPrinter( GetDoc()->getPrinter( false ), SFX_PRINTER_PRINTER | SFX_PRINTER_JOBSETUP ); 169 GetDoc()->CheckDefaultPageFmt(); 170 SfxViewFrame *pTmpFrm = SfxViewFrame::GetFirst(this, sal_False); 171 do { 172 if( pTmpFrm != pTempView->GetViewFrame() ) 173 { 174 pTmpFrm->DoClose(); 175 pTmpFrm = SfxViewFrame::GetFirst(this, sal_False); 176 } 177 else 178 pTmpFrm = pTmpFrm->GetNext(*pTmpFrm, this, sal_False); 179 180 } while ( pTmpFrm ); 181 const SwViewOption& rViewOptions = *pTempView->GetWrtShell().GetViewOptions(); 182 pTempView->GetWrtShell().CheckBrowseView( sal_True ); 183 pTempView->CheckVisArea(); 184 if( bSet ) 185 { 186 const SvxZoomType eType = (SvxZoomType)rViewOptions.GetZoomType(); 187 if ( SVX_ZOOM_PERCENT != eType) 188 ((SwView*)GetView())->SetZoom( eType ); 189 } 190 pTempView->InvalidateBorder(); 191 pTempView->SetNewWindowAllowed(!bSet); 192 } 193 } 194 // End of disabled "multiple layout" 195 196 /// update text fields on document properties changes 197 void SwDocShell::DoFlushDocInfo() 198 { 199 if ( !pDoc ) return; 200 201 bool bUnlockView(true); 202 if ( pWrtShell ) { 203 bUnlockView = !pWrtShell->IsViewLocked(); 204 pWrtShell->LockView( sal_True ); // lock visible section 205 pWrtShell->StartAllAction(); 206 } 207 208 pDoc->DocInfoChgd(); 209 210 if ( pWrtShell ) { 211 pWrtShell->EndAllAction(); 212 if ( bUnlockView ) { 213 pWrtShell->LockView( sal_False ); 214 } 215 } 216 } 217 218 #ifdef FUTURE_VBA 219 void lcl_processCompatibleSfxHint( const uno::Reference< script::vba::XVBAEventProcessor >& xVbaEvents, const SfxHint& rHint ) 220 { 221 using namespace com::sun::star::script::vba::VBAEventId; 222 if ( rHint.ISA( SfxEventHint ) ) 223 { 224 uno::Sequence< uno::Any > aArgs; 225 sal_uLong nEventId = ((SfxEventHint&)rHint).GetEventId(); 226 switch( nEventId ) 227 { 228 case SFX_EVENT_CREATEDOC: 229 xVbaEvents->processVbaEvent( DOCUMENT_NEW, aArgs ); 230 break; 231 case SFX_EVENT_OPENDOC: 232 xVbaEvents->processVbaEvent( DOCUMENT_OPEN, aArgs ); 233 break; 234 } 235 } 236 } 237 #endif 238 239 /*-------------------------------------------------------------------- 240 Beschreibung: Benachrichtigung bei geaenderter DocInfo 241 --------------------------------------------------------------------*/ 242 243 void SwDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) 244 { 245 if( !pDoc ) 246 { 247 //MA: Kommt bei der OLE-Registration vor! 248 // ASSERT( !this, "DocShell ist nicht richtig initialisiert!" ); 249 return ; 250 } 251 252 #ifdef FUTURE_VBA 253 uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents = pDoc->GetVbaEventProcessor(); 254 if( xVbaEvents.is() ) 255 lcl_processCompatibleSfxHint( xVbaEvents, rHint ); 256 #endif 257 258 sal_uInt16 nAction = 0; 259 if( rHint.ISA(SfxSimpleHint) ) 260 { 261 // swithc for more actions 262 switch( ((SfxSimpleHint&) rHint).GetId() ) 263 { 264 case SFX_HINT_TITLECHANGED: 265 if( GetMedium() ) 266 nAction = 2; 267 break; 268 } 269 } 270 else if( rHint.ISA(SfxEventHint) && 271 ((SfxEventHint&) rHint).GetEventId() == SFX_EVENT_LOADFINISHED ) 272 { 273 // --> OD 2004-12-03 #i38126# - own action id 274 nAction = 3; 275 // <-- 276 } 277 278 if( nAction ) 279 { 280 sal_Bool bUnlockView = sal_True; //initializing prevents warning 281 if( pWrtShell ) 282 { 283 bUnlockView = !pWrtShell->IsViewLocked(); 284 pWrtShell->LockView( sal_True ); //lock visible section 285 pWrtShell->StartAllAction(); 286 } 287 switch( nAction ) 288 { 289 case 2: 290 pDoc->GetSysFldType( RES_FILENAMEFLD )->UpdateFlds(); 291 break; 292 // --> OD 2004-12-03 #i38126# - own action for event LOADFINISHED 293 // in order to avoid a modified document. 294 // --> OD 2005-02-01 #i41679# - Also for the instance of <SwDoc> 295 // it has to be assured, that it's not modified. 296 // Perform the same as for action id 1, but disable <SetModified>. 297 case 3: 298 { 299 const bool bResetModified = IsEnableSetModified(); 300 if ( bResetModified ) 301 EnableSetModified( sal_False ); 302 // --> OD 2005-02-01 #i41679# 303 const bool bIsDocModified = pDoc->IsModified(); 304 // <-- 305 306 pDoc->DocInfoChgd( ); 307 308 // --> OD 2005-02-01 #i41679# 309 if ( !bIsDocModified ) 310 pDoc->ResetModified(); 311 // <-- 312 if ( bResetModified ) 313 EnableSetModified( sal_True ); 314 } 315 break; 316 // <-- 317 } 318 319 if( pWrtShell ) 320 { 321 pWrtShell->EndAllAction(); 322 if( bUnlockView ) 323 pWrtShell->LockView( sal_False ); 324 } 325 } 326 } 327 328 /*-------------------------------------------------------------------- 329 Beschreibung: Benachrichtigung Doc schliessen 330 --------------------------------------------------------------------*/ 331 332 sal_uInt16 SwDocShell::PrepareClose( sal_Bool bUI, sal_Bool bForBrowsing ) 333 { 334 sal_uInt16 nRet = SfxObjectShell::PrepareClose( bUI, bForBrowsing ); 335 336 if( sal_True == nRet ) //Unbedingt auf sal_True abfragen! (RET_NEWTASK) 337 EndListening( *this ); 338 339 #ifdef FUTURE_VBA 340 if( pDoc && IsInPrepareClose() ) 341 { 342 uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents = pDoc->GetVbaEventProcessor(); 343 if( xVbaEvents.is() ) 344 { 345 using namespace com::sun::star::script::vba::VBAEventId; 346 uno::Sequence< uno::Any > aArgs; 347 xVbaEvents->processVbaEvent( DOCUMENT_CLOSE, aArgs ); 348 } 349 } 350 #endif 351 return nRet; 352 } 353 354 /*-------------------------------------------------------------------- 355 Beschreibung: Organizer 356 --------------------------------------------------------------------*/ 357 358 sal_Bool SwDocShell::Insert( SfxObjectShell &rSource, 359 sal_uInt16 nSourceIdx1, // SourcePool: oberste Inhaltsebene (Vorlagen/Makros) 360 sal_uInt16 nSourceIdx2, // Index in den Inhalt 361 sal_uInt16 nSourceIdx3, // Index in die Inhaltsebene 362 sal_uInt16 &rIdx1, // und das gleiche fuer den DestinationPool 363 sal_uInt16 &rIdx2, // "" 364 sal_uInt16 &rIdx3, // "" 365 sal_uInt16 &rRemovedIdx ) // falls doppelte geloescht werden, Pos zurueck 366 { 367 // --> OD 2005-05-10 #i48949# - actions aren't undoable. Thus, allow no undo 368 // actions 369 // Note: The undo action stack is cleared at the end of this method. 370 ::sw::UndoGuard const undoGuard(GetDoc()->GetIDocumentUndoRedo()); 371 // <-- 372 373 sal_Bool bRet = sal_False; 374 375 if (INDEX_IGNORE == rIdx1 && CONTENT_STYLE == nSourceIdx1) 376 rIdx1 = CONTENT_STYLE; 377 378 if (CONTENT_STYLE == nSourceIdx1 && CONTENT_STYLE == rIdx1) 379 { 380 SfxStyleSheetBasePool* pHisPool = rSource.GetStyleSheetPool(); 381 SwDocStyleSheetPool* pMyPool = 382 (SwDocStyleSheetPool*)GetStyleSheetPool(); 383 384 // wir koennen nicht in uns selbst hin und her moven 385 if( pHisPool == pMyPool ) 386 return sal_False; 387 388 if( INDEX_IGNORE == rIdx2 ) 389 rIdx2 = pMyPool->Count(); 390 391 // erstmal auf die Such-Maske "positionieren" 392 pHisPool->First(); 393 SfxStyleSheetBase* pHisSheet = (*pHisPool)[nSourceIdx2]; 394 395 // wenn so eine Vorlage schon existiert: loeschen! 396 const String& rOldName = pHisSheet->GetName(); 397 SfxStyleFamily eOldFamily( pHisSheet->GetFamily() ); 398 399 // dflt. PageDesc und StandardZeichenvorlage nie loeschen !!! 400 if( ( SFX_STYLE_FAMILY_PAGE == eOldFamily && 401 const_cast<const SwDoc *>(pDoc)->GetPageDesc(0).GetName() == 402 rOldName ) || 403 ( SFX_STYLE_FAMILY_CHAR == eOldFamily && 404 rOldName == *SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD - 405 RES_POOLCOLL_TEXT_BEGIN ] )) 406 return sal_False; 407 408 SfxStyleFamily eMyOldFamily( pMyPool->GetSearchFamily() ); 409 sal_uInt16 nMySrchMask = pMyPool->GetSearchMask(); 410 411 SfxStyleSheetBase* pExist; 412 if( ::FindPhyStyle( *pDoc, rOldName, eOldFamily ) ) 413 { 414 // Bug 20365: nur uebernehmen, wenn das gewuenscht ist! 415 if( ERRCODE_BUTTON_OK != ErrorHandler::HandleError( 416 *new MessageInfo( ERRCODE_SFXMSG_STYLEREPLACE, rOldName )) ) 417 { 418 return sal_False; 419 } 420 421 // Da Replace den aStyleSheet-Member selbst benoetigt, muss 422 // das Ergebnis vom Find kopiert werden (s.u.)) 423 rtl::Reference< SwDocStyleSheet > xExist( new SwDocStyleSheet( 424 *(SwDocStyleSheet*)pMyPool->Find( rOldName, eOldFamily ) ) ); 425 pMyPool->Replace( *pHisSheet, *xExist.get() ); 426 427 // An der Reihenfolge der Vorlagen im Pool aendert sich nichts. 428 rIdx2 = rIdx1 = INDEX_IGNORE; 429 430 GetDoc()->SetModified(); 431 432 return sal_True; 433 } 434 435 pMyPool->SetSearchMask( eOldFamily, nMySrchMask ); 436 437 // MIB 18.12.98: SwDocStyleSheetPool::Make liefert einen 438 // Pointer auf SwDocStyleSheetPool::aStyleSheet zurueck. 439 // Der gleiche Member von SwDocStyleSheetPool::Find benutzt. 440 // Deshalb muss hier mit einer Kopie gearbeitet werden. 441 // Vorsicht: SfxStyleSheetBase::SetFollow ruft seinerseits 442 // ein SwDocStyleSheetPool::Find auf, do dass es nicht genuegt 443 // die Find-Aufrufe in dieser Methode zu eleminieren. 444 445 rtl::Reference< SwDocStyleSheet > xNewSheet( new SwDocStyleSheet( (SwDocStyleSheet&)pMyPool 446 ->Make(rOldName, eOldFamily, pHisSheet->GetMask() ) ) ); 447 if( SFX_STYLE_FAMILY_PAGE == eOldFamily && rSource.ISA(SwDocShell) ) 448 { 449 // gesondert behandeln!! 450 SwPageDesc* pDestDsc = (SwPageDesc*)xNewSheet->GetPageDesc(); 451 SwPageDesc* pCpyDsc = (SwPageDesc*)((SwDocStyleSheet*)pHisSheet)->GetPageDesc(); 452 pDoc->CopyPageDesc( *pCpyDsc, *pDestDsc ); 453 } 454 else 455 // die neue Vorlage mit den Attributen fuellen 456 xNewSheet->SetItemSet( pHisSheet->GetItemSet() ); 457 458 pMyPool->SetSearchMask( SFX_STYLE_FAMILY_ALL, nMySrchMask ); 459 460 if( xNewSheet->IsUserDefined() || xNewSheet->IsUsed() ) 461 { 462 // Benutzte und Benutzer-definierte Vorlagen werden angezeigt. 463 // Dshalb muss hier der Index der neuen Vorlage im Pool 464 // ermittelt werden. 465 pExist = pMyPool->First(); 466 sal_uInt16 nIdx = 0; 467 while( pExist ) 468 { 469 if( pExist->GetName() == rOldName && 470 eOldFamily == pExist->GetFamily() ) 471 { 472 rIdx2 = nIdx; 473 break; 474 } 475 pExist = pMyPool->Next(); 476 nIdx++; 477 } 478 } 479 else 480 { 481 // Andere Vorlagen werden nicht angezeigt. 482 rIdx1 = rIdx2 = INDEX_IGNORE; 483 } 484 485 /* pMyPool->Count(); //interne Liste neu fuellen lassen!!!!! 486 487 // suchen, um die richige Insert-Position returnen zu koennen 488 pMyPool->Find( rOldName, SFX_STYLE_FAMILY_ALL, nMySrchMask ); 489 rIdx2 = pMyPool->GetFindPos();*/ 490 491 // wer bekommt den Neuen als Parent? wer benutzt den Neuen als Follow? 492 // (immer nur ueber die Instanziierten!!!) 493 pMyPool->SetSearchMask( eOldFamily, nMySrchMask ); 494 pMyPool->SetOrganizerMode( sal_True ); 495 SfxStyleSheetBase* pTestSheet = pMyPool->First(); 496 while (pTestSheet) 497 { 498 if (pTestSheet->GetFamily() == eOldFamily && 499 pTestSheet->HasParentSupport() && 500 pTestSheet->GetParent() == rOldName) 501 { 502 pTestSheet->SetParent(rOldName); // Verknuepfung neu aufbauen 503 } 504 505 if (pTestSheet->GetFamily() == eOldFamily && 506 pTestSheet->HasFollowSupport() && 507 pTestSheet->GetFollow() == rOldName) 508 { 509 pTestSheet->SetFollow(rOldName); // Verknuepfung neu aufbauen 510 } 511 512 pTestSheet = pMyPool->Next(); 513 } 514 pMyPool->SetOrganizerMode( SFX_CREATE_MODE_ORGANIZER == GetCreateMode() ); 515 516 // hat der Neue einen Parent? wenn ja, mit gleichem Namen bei uns suchen 517 if (pHisSheet->HasParentSupport()) 518 { 519 const String& rParentName = pHisSheet->GetParent(); 520 if (0 != rParentName.Len()) 521 { 522 SfxStyleSheetBase* pParentOfNew = pMyPool->Find(rParentName, 523 eOldFamily); 524 if (pParentOfNew) 525 { 526 xNewSheet->SetParent(rParentName); 527 } 528 pMyPool->SetSearchMask( eOldFamily, nMySrchMask ); 529 } 530 } 531 532 // hat der Neue einen Follow? wenn ja, mit gleichem Namen bei uns suchen 533 if (pHisSheet->HasFollowSupport()) 534 { 535 const String& rFollowName = pHisSheet->GetFollow(); 536 if (0 != rFollowName.Len()) 537 { 538 SfxStyleSheetBase* pFollowOfNew = pMyPool->Find(rFollowName, 539 eOldFamily); 540 if (pFollowOfNew) 541 { 542 xNewSheet->SetFollow(rFollowName); 543 } 544 pMyPool->SetSearchMask( eOldFamily, nMySrchMask ); 545 } 546 } 547 548 // Bug 27347: alte Einstellung wieder setzen 549 pMyPool->SetSearchMask( eMyOldFamily, nMySrchMask ); 550 551 // Model geaendert 552 ASSERT(pDoc, "Doc fehlt"); 553 GetDoc()->SetModified(); 554 555 bRet = sal_True; 556 } 557 else 558 bRet = SfxObjectShell::Insert( rSource, 559 nSourceIdx1, 560 nSourceIdx2, 561 nSourceIdx3, 562 rIdx1, 563 rIdx2, 564 rIdx3, 565 rRemovedIdx); 566 567 // --> OD 2005-05-10 #i48949# - actions aren't undoable and could have change 568 // the document node array. Thus, clear the undo action stack. 569 if (undoGuard.UndoWasEnabled()) 570 { 571 GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj(); 572 } 573 // <-- 574 575 return bRet; 576 } 577 578 /*-------------------------------------------------------------------- 579 Beschreibung: Vorlagen Remove 580 --------------------------------------------------------------------*/ 581 582 sal_Bool SwDocShell::Remove(sal_uInt16 nIdx1, // siehe Insert 583 sal_uInt16 nIdx2, 584 sal_uInt16 nIdx3) 585 { 586 sal_Bool bRet = sal_False; 587 588 if (CONTENT_STYLE == nIdx1) 589 { 590 SwDocStyleSheetPool* pMyPool = (SwDocStyleSheetPool*)GetStyleSheetPool(); 591 592 pMyPool->First(); // vorm Zugriff Pool aktualisieren!! 593 SfxStyleSheetBase* pMySheet = (*pMyPool)[nIdx2]; 594 595 String aName( pMySheet->GetName() ); 596 SfxStyleFamily eFamily( pMySheet->GetFamily() ); 597 598 // dflt. PageDesc und StandardZeichenvorlage nie loeschen !!! 599 if( ( SFX_STYLE_FAMILY_PAGE == eFamily && 600 const_cast<const SwDoc *>(pDoc)->GetPageDesc(0).GetName() 601 == aName ) || 602 ( SFX_STYLE_FAMILY_CHAR == eFamily && 603 aName == *SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD - 604 RES_POOLCOLL_TEXT_BEGIN ] )) 605 return sal_False; 606 607 // also loeschen 608 pMyPool->Remove( pMySheet ); 609 610 // jetzt noch die Parents/Follows aller Instanziierten korrigieren 611 pMyPool->SetOrganizerMode( sal_True ); 612 SfxStyleSheetBase* pTestSheet = pMyPool->First(); 613 while (pTestSheet) 614 { 615 if (pTestSheet->GetFamily() == eFamily && 616 pTestSheet->HasParentSupport() && 617 pTestSheet->GetParent() == aName) 618 { 619 pTestSheet->SetParent( aEmptyStr ); // Verknuepfung aufloesen 620 } 621 622 if (pTestSheet->GetFamily() == eFamily && 623 pTestSheet->HasFollowSupport() && 624 pTestSheet->GetFollow() == aName) 625 { 626 pTestSheet->SetFollow( aEmptyStr ); // Verknuepfung aufloesen 627 } 628 629 pTestSheet = pMyPool->Next(); 630 } 631 pMyPool->SetOrganizerMode( SFX_CREATE_MODE_ORGANIZER == GetCreateMode() ); 632 633 bRet = sal_True; 634 } 635 else 636 bRet = SfxObjectShell::Remove( nIdx1, 637 nIdx2, 638 nIdx3 ); 639 640 641 // Model geaendert 642 ASSERT(pDoc, "Doc fehlt"); 643 GetDoc()->SetModified(); 644 645 return bRet; 646 } 647 648 /*-------------------------------------------------------------------- 649 Beschreibung: 650 --------------------------------------------------------------------*/ 651 652 void SwDocShell::Execute(SfxRequest& rReq) 653 { 654 const SfxItemSet* pArgs = rReq.GetArgs(); 655 const SfxPoolItem* pItem; 656 sal_uInt16 nWhich = rReq.GetSlot(); 657 sal_Bool bDone = sal_False; 658 switch ( nWhich ) 659 { 660 case SID_AUTO_CORRECT_DLG: 661 { 662 SvxSwAutoFmtFlags* pAFlags = &SvxAutoCorrCfg::Get()->GetAutoCorrect()->GetSwFlags(); 663 SwAutoCompleteWord& rACW = SwDoc::GetAutoCompleteWords(); 664 665 sal_Bool bOldLocked = rACW.IsLockWordLstLocked(), 666 bOldAutoCmpltCollectWords = pAFlags->bAutoCmpltCollectWords; 667 668 rACW.SetLockWordLstLocked( sal_True ); 669 670 SvStringsISortDtor aTmpLst; 671 aTmpLst.Insert( &rACW.GetWordList() ); 672 pAFlags->pAutoCmpltList = &aTmpLst; 673 674 SfxApplication* pApp = SFX_APP(); 675 SfxRequest aAppReq(SID_AUTO_CORRECT_DLG, SFX_CALLMODE_SYNCHRON, pApp->GetPool()); 676 SfxBoolItem aSwOptions( SID_AUTO_CORRECT_DLG, sal_True ); 677 aAppReq.AppendItem(aSwOptions); 678 679 // SMARTTAGS 680 pAFlags->pSmartTagMgr = &SwSmartTagMgr::Get(); 681 682 //pApp->ExecuteSlot(aAppReq); 683 684 SfxItemSet aSet( pApp->GetPool(), SID_AUTO_CORRECT_DLG, SID_AUTO_CORRECT_DLG, SID_OPEN_SMARTTAGOPTIONS, SID_OPEN_SMARTTAGOPTIONS, 0 ); 685 aSet.Put( aSwOptions ); 686 687 const SfxPoolItem* pOpenSmartTagOptionsItem = 0; 688 if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_OPEN_SMARTTAGOPTIONS, sal_False, &pOpenSmartTagOptionsItem ) ) 689 aSet.Put( *static_cast<const SfxBoolItem*>(pOpenSmartTagOptionsItem) ); 690 691 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); 692 SfxAbstractTabDialog* pDlg = pFact->CreateTabDialog( RID_OFA_AUTOCORR_DLG, NULL, &aSet, NULL ); 693 pDlg->Execute(); 694 delete pDlg; 695 696 rACW.SetLockWordLstLocked( bOldLocked ); 697 698 SwEditShell::SetAutoFmtFlags( pAFlags ); 699 rACW.SetMinWordLen( pAFlags->nAutoCmpltWordLen ); 700 rACW.SetMaxCount( pAFlags->nAutoCmpltListLen ); 701 if( pAFlags->pAutoCmpltList ) // any changes? 702 { 703 rACW.CheckChangedList( aTmpLst ); 704 // clear the temp WordList pointer 705 pAFlags->pAutoCmpltList = 0; 706 } 707 // remove all pointer we never delete the strings 708 aTmpLst.Remove( (sal_uInt16)0, aTmpLst.Count() ); 709 710 if( !bOldAutoCmpltCollectWords && bOldAutoCmpltCollectWords != 711 pAFlags->bAutoCmpltCollectWords ) 712 { 713 // call on all Docs the idle formatter to start 714 // the collection of Words 715 TypeId aType = TYPE(SwDocShell); 716 for( SwDocShell *pDocSh = (SwDocShell*)SfxObjectShell::GetFirst(&aType); 717 pDocSh; 718 pDocSh = (SwDocShell*)SfxObjectShell::GetNext( *pDocSh, &aType ) ) 719 { 720 SwDoc* pTmp = pDocSh->GetDoc(); 721 if ( pTmp->GetCurrentViewShell() ) //swmod 071108//swmod 071225 722 pTmp->InvalidateAutoCompleteFlag(); 723 } 724 } 725 } 726 break; 727 728 case SID_PRINTPREVIEW: 729 { 730 sal_Bool bSet = sal_False, bFound = sal_False, bOnly = sal_True; 731 SfxViewFrame *pTmpFrm = SfxViewFrame::GetFirst(this); 732 SfxViewShell* pViewShell = SfxViewShell::Current(); 733 SwView* pCurrView = dynamic_cast< SwView *> ( pViewShell ); 734 sal_Bool bCurrent = IS_TYPE( SwPagePreView, pViewShell ); 735 736 while( pTmpFrm ) // search PreView 737 { 738 if( IS_TYPE( SwView, pTmpFrm->GetViewShell()) ) 739 bOnly = sal_False; 740 else if( IS_TYPE( SwPagePreView, pTmpFrm->GetViewShell())) 741 { 742 pTmpFrm->GetFrame().Appear(); 743 bFound = sal_True; 744 } 745 if( bFound && !bOnly ) 746 break; 747 pTmpFrm = pTmpFrm->GetNext(*pTmpFrm, this); 748 } 749 750 if( pArgs && SFX_ITEM_SET == 751 pArgs->GetItemState( SID_PRINTPREVIEW, sal_False, &pItem )) 752 bSet = ((SfxBoolItem*)pItem)->GetValue(); 753 else 754 bSet = !bCurrent; 755 756 sal_uInt16 nSlotId = 0; 757 if( bSet && !bFound ) // Keine gefunden, daher neue Preview anlegen 758 nSlotId = SID_VIEWSHELL1; 759 else if( bFound && !bSet ) 760 nSlotId = bOnly ? SID_VIEWSHELL0 : SID_VIEWSHELL1; 761 762 if( nSlotId ) 763 { 764 //JP 23.8.2001: Bug 91360 - PagePreView in the WebDocShell 765 // is found under Id ViewShell2. 766 if( ISA(SwWebDocShell) && SID_VIEWSHELL1 == nSlotId ) 767 nSlotId = SID_VIEWSHELL2; 768 769 if( pCurrView && pCurrView->GetDocShell() == this ) 770 pTmpFrm = pCurrView->GetViewFrame(); 771 else 772 pTmpFrm = SfxViewFrame::GetFirst( this ); 773 774 pTmpFrm->GetDispatcher()->Execute( nSlotId, 0, 0, SFX_CALLMODE_ASYNCHRON ); 775 } 776 777 rReq.SetReturnValue(SfxBoolItem(SID_PRINTPREVIEW, bSet )); 778 } 779 break; 780 case SID_TEMPLATE_LOAD: 781 { 782 String aFileName; 783 static sal_Bool bText = sal_True; 784 static sal_Bool bFrame = sal_False; 785 static sal_Bool bPage = sal_False; 786 static sal_Bool bNum = sal_False; 787 static sal_Bool bMerge = sal_False; 788 sal_uInt16 nRet = USHRT_MAX; 789 790 sal_uInt16 nFlags = bFrame ? SFX_LOAD_FRAME_STYLES : 0; 791 if(bPage) 792 nFlags|= SFX_LOAD_PAGE_STYLES; 793 if(bNum) 794 nFlags|= SFX_LOAD_NUM_STYLES; 795 if(!nFlags || bText) 796 nFlags|= SFX_LOAD_TEXT_STYLES; 797 if(bMerge) 798 nFlags|= SFX_MERGE_STYLES; 799 800 if ( pArgs ) 801 { 802 SFX_REQUEST_ARG( rReq, pTemplateItem, SfxStringItem, SID_TEMPLATE_NAME, sal_False ); 803 if ( pTemplateItem ) 804 { 805 aFileName = pTemplateItem->GetValue(); 806 SFX_REQUEST_ARG( rReq, pFlagsItem, SfxInt32Item, SID_TEMPLATE_LOAD, sal_False ); 807 if ( pFlagsItem ) 808 nFlags = (sal_uInt16) pFlagsItem->GetValue(); 809 } 810 } 811 812 if ( !aFileName.Len() ) 813 { 814 SvtPathOptions aPathOpt; 815 SfxNewFileDialog* pNewFileDlg = 816 new SfxNewFileDialog(&GetView()->GetViewFrame()->GetWindow(), SFXWB_LOAD_TEMPLATE); 817 pNewFileDlg->SetTemplateFlags(nFlags); 818 819 nRet = pNewFileDlg->Execute(); 820 if(RET_TEMPLATE_LOAD == nRet) 821 { 822 FileDialogHelper aDlgHelper( TemplateDescription::FILEOPEN_SIMPLE, 0 ); 823 uno::Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker(); 824 825 xFP->setDisplayDirectory( aPathOpt.GetWorkPath() ); 826 827 SfxObjectFactory &rFact = GetFactory(); 828 SfxFilterMatcher aMatcher( String::CreateFromAscii(rFact.GetShortName()) ); 829 SfxFilterMatcherIter aIter( &aMatcher ); 830 uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY); 831 const SfxFilter* pFlt = aIter.First(); 832 while( pFlt ) 833 { 834 // --> OD #i117339# 835 // if( pFlt && pFlt->IsAllowedAsTemplate() ) 836 if( pFlt && pFlt->IsAllowedAsTemplate() && 837 ( pFlt->GetUserData().EqualsAscii("CXML") || 838 pFlt->GetUserData().EqualsAscii("CXMLV") ) ) 839 { 840 const String sWild = ((WildCard&)pFlt->GetWildcard()).GetWildCard(); 841 xFltMgr->appendFilter( pFlt->GetUIName(), sWild ); 842 } 843 pFlt = aIter.Next(); 844 } 845 sal_Bool bWeb = 0 != dynamic_cast< SwWebDocShell *>( this ); 846 const SfxFilter *pOwnFlt = 847 SwDocShell::Factory().GetFilterContainer()-> 848 GetFilter4FilterName(String::CreateFromAscii("writer8")); 849 850 //#b6439685# make sure the default file format is also available 851 if(bWeb) 852 { 853 const String sWild = ((WildCard&)pOwnFlt->GetWildcard()).GetWildCard(); 854 xFltMgr->appendFilter( pOwnFlt->GetUIName(), sWild ); 855 } 856 857 bool bError = false; 858 //#b6439685# catch expception if wrong filter is selected - should not happen anymore 859 try 860 { 861 xFltMgr->setCurrentFilter( pOwnFlt->GetUIName() ); 862 } 863 catch( const uno::Exception& ) 864 { 865 bError = true; 866 } 867 868 if( !bError && ERRCODE_NONE == aDlgHelper.Execute() ) 869 { 870 aFileName = xFP->getFiles().getConstArray()[0]; 871 } 872 } 873 else if( RET_OK == nRet) 874 { 875 aFileName = pNewFileDlg->GetTemplateFileName(); 876 } 877 878 nFlags = pNewFileDlg->GetTemplateFlags(); 879 rReq.AppendItem( SfxStringItem( SID_TEMPLATE_NAME, aFileName ) ); 880 rReq.AppendItem( SfxInt32Item( SID_TEMPLATE_LOAD, (long) nFlags ) ); 881 delete pNewFileDlg; 882 } 883 884 if( aFileName.Len() ) 885 { 886 SwgReaderOption aOpt; 887 aOpt.SetTxtFmts( bText = (0 != (nFlags&SFX_LOAD_TEXT_STYLES) )); 888 aOpt.SetFrmFmts( bFrame = (0 != (nFlags&SFX_LOAD_FRAME_STYLES))); 889 aOpt.SetPageDescs( bPage = (0 != (nFlags&SFX_LOAD_PAGE_STYLES ))); 890 aOpt.SetNumRules( bNum = (0 != (nFlags&SFX_LOAD_NUM_STYLES ))); 891 //different meaning between SFX_MERGE_STYLES and aOpt.SetMerge! 892 bMerge = 0 != (nFlags&SFX_MERGE_STYLES); 893 aOpt.SetMerge( !bMerge ); 894 895 SetError( LoadStylesFromFile( aFileName, aOpt, sal_False ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) )); 896 if ( !GetError() ) 897 rReq.Done(); 898 } 899 } 900 break; 901 case SID_SOURCEVIEW: 902 { 903 SfxViewShell* pViewShell = GetView() 904 ? (SfxViewShell*)GetView() 905 : SfxViewShell::Current(); 906 SfxViewFrame* pViewFrm = pViewShell->GetViewFrame(); 907 SwSrcView* pSrcView = dynamic_cast< SwSrcView *>( pViewShell ); 908 if(!pSrcView) 909 { 910 // 3 possible state: 911 // 1 - file unsaved -> save as HTML 912 // 2 - file modified and HTML filter active -> save 913 // 3 - file saved in non-HTML -> QueryBox to save as HTML 914 const SfxFilter* pHtmlFlt = 915 SwIoSystem::GetFilterOfFormat( 916 String::CreateFromAscii("HTML"), 917 SwWebDocShell::Factory().GetFilterContainer() ); 918 sal_Bool bLocalHasName = HasName(); 919 if(bLocalHasName) 920 { 921 //check for filter type 922 const SfxFilter* pFlt = GetMedium()->GetFilter(); 923 if(!pFlt || pFlt->GetUserData() != pHtmlFlt->GetUserData()) 924 { 925 QueryBox aQuery(&pViewFrm->GetWindow(), SW_RES(MSG_SAVEAS_HTML_QUERY)); 926 if(RET_YES == aQuery.Execute()) 927 bLocalHasName = sal_False; 928 else 929 break; 930 } 931 } 932 if(!bLocalHasName) 933 { 934 FileDialogHelper aDlgHelper( TemplateDescription::FILESAVE_AUTOEXTENSION, 0 ); 935 aDlgHelper.AddFilter( pHtmlFlt->GetFilterName(), pHtmlFlt->GetDefaultExtension() ); 936 aDlgHelper.SetCurrentFilter( pHtmlFlt->GetFilterName() ); 937 if( ERRCODE_NONE != aDlgHelper.Execute()) 938 { 939 break; 940 } 941 String sPath = aDlgHelper.GetPath(); 942 SfxStringItem aName(SID_FILE_NAME, sPath); 943 SfxStringItem aFilter(SID_FILTER_NAME, pHtmlFlt->GetName()); 944 const SfxBoolItem* pBool = (const SfxBoolItem*) 945 pViewFrm->GetDispatcher()->Execute( 946 SID_SAVEASDOC, SFX_CALLMODE_SYNCHRON, &aName, &aFilter, 0L ); 947 if(!pBool || !pBool->GetValue()) 948 break; 949 } 950 } 951 #ifdef DBG_UTIL 952 { 953 sal_Bool bWeb = 0 != dynamic_cast<SwWebDocShell*>(this); 954 DBG_ASSERT(bWeb == sal_True, "SourceView nur in der WebDocShell"); 955 } 956 #endif 957 // die SourceView ist fuer die SwWebDocShell die 1 958 sal_uInt16 nSlot = SID_VIEWSHELL1; 959 sal_Bool bSetModified = sal_False; 960 SfxPrinter* pSavePrinter = 0; 961 if( 0 != pSrcView) 962 { 963 SfxPrinter* pTemp = GetDoc()->getPrinter( false ); 964 if(pTemp) 965 pSavePrinter = new SfxPrinter(*pTemp); 966 bSetModified = IsModified() || pSrcView->IsModified(); 967 if(pSrcView->IsModified()||pSrcView->HasSourceSaved()) 968 { 969 utl::TempFile aTempFile; 970 aTempFile.EnableKillingFile(); 971 pSrcView->SaveContent(aTempFile.GetURL()); 972 bDone = sal_True; 973 SvxMacro aMac(aEmptyStr, aEmptyStr, STARBASIC); 974 SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_OPENDOC ), aMac, this); 975 SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_PREPARECLOSEDOC ), aMac, this); 976 SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_ACTIVATEDOC ), aMac, this); 977 SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_DEACTIVATEDOC ), aMac, this); 978 ReloadFromHtml(aTempFile.GetURL(), pSrcView); 979 nSlot = 0; 980 } 981 else 982 { 983 nSlot = SID_VIEWSHELL0; 984 } 985 } 986 /* OS 10.04.97 14.20: Im Web-Writer gibt es keinen Unterschied zwischen 987 Export in den SourceMode und dem Speichern des Docs 988 else if(IsModified()) 989 { 990 sal_uInt16 nRet = QueryBox( SFX_APPWINDOW ,SW_RES(MSG_SAVE_HTML_QUERY)).Execute(); 991 if(RET_YES == nRet) 992 { 993 S F X _DISPATCHER().Execute(SID_SAVEDOC, 994 SFX_CALLMODE_SYNCHRON); 995 // der ReturnValue von SID_SAVEDOC ist etwas schwer verstaendlich 996 if(IsModified()) 997 nSlot = 0; 998 } 999 else if( RET_CANCEL == nRet ) 1000 { 1001 nSlot = 0; 1002 } 1003 }*/ 1004 if(nSlot) 1005 pViewFrm->GetDispatcher()->Execute(nSlot, SFX_CALLMODE_SYNCHRON); 1006 if(bSetModified) 1007 GetDoc()->SetModified(); 1008 if(pSavePrinter) 1009 { 1010 GetDoc()->setPrinter( pSavePrinter, true, true); 1011 //pSavePrinter darf nicht wieder geloescht werden 1012 } 1013 pViewFrm->GetBindings().SetState(SfxBoolItem(SID_SOURCEVIEW, nSlot == SID_VIEWSHELL2)); 1014 pViewFrm->GetBindings().Invalidate( SID_NEWWINDOW ); 1015 pViewFrm->GetBindings().Invalidate( SID_BROWSER_MODE ); 1016 pViewFrm->GetBindings().Invalidate( FN_PRINT_LAYOUT ); 1017 } 1018 break; 1019 case SID_GET_COLORTABLE: 1020 { 1021 const SvxColorTableItem* pColItem = static_cast< const SvxColorTableItem* >(GetItem(SID_COLOR_TABLE)); 1022 XColorListSharedPtr aTable = pColItem->GetColorTable(); 1023 1024 rReq.SetReturnValue(SvxColorTableItem(aTable, SID_GET_COLORTABLE)); 1025 } 1026 break; 1027 case FN_ABSTRACT_STARIMPRESS: 1028 case FN_ABSTRACT_NEWDOC: 1029 { 1030 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 1031 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 1032 1033 AbstractSwInsertAbstractDlg* pDlg = pFact->CreateSwInsertAbstractDlg(0, DLG_INSERT_ABSTRACT ); 1034 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 1035 if(RET_OK == pDlg->Execute()) 1036 { 1037 sal_uInt8 nLevel = pDlg->GetLevel(); 1038 sal_uInt8 nPara = pDlg->GetPara(); 1039 SwDoc* pSmryDoc = new SwDoc(); 1040 SfxObjectShellLock xDocSh( new SwDocShell( pSmryDoc, SFX_CREATE_MODE_STANDARD)); 1041 xDocSh->DoInitNew( 0 ); 1042 1043 sal_Bool bImpress = FN_ABSTRACT_STARIMPRESS == nWhich; 1044 pDoc->Summary( pSmryDoc, nLevel, nPara, bImpress ); 1045 if( bImpress ) 1046 { 1047 WriterRef xWrt; 1048 // mba: looks as if relative URLs don't make sense here 1049 ::GetRTFWriter( aEmptyStr, String(), xWrt ); 1050 SvMemoryStream *pStrm = new SvMemoryStream(); 1051 pStrm->SetBufferSize( 16348 ); 1052 SwWriter aWrt( *pStrm, *pSmryDoc ); 1053 ErrCode eErr = aWrt.Write( xWrt ); 1054 if( !ERRCODE_TOERROR( eErr ) ) 1055 { 1056 uno::Reference< lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory(); 1057 uno::Reference< frame::XDispatchProvider > xProv( 1058 xORB->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.drawing.ModuleDispatcher")), UNO_QUERY ); 1059 if ( xProv.is() ) 1060 { 1061 ::rtl::OUString aCmd = ::rtl::OUString::createFromAscii( "SendOutlineToImpress" ); 1062 uno::Reference< frame::XDispatchHelper > xHelper( 1063 xORB->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.frame.DispatchHelper")), UNO_QUERY ); 1064 if ( xHelper.is() ) 1065 { 1066 pStrm->Seek( STREAM_SEEK_TO_END ); 1067 *pStrm << '\0'; 1068 pStrm->Seek( STREAM_SEEK_TO_BEGIN ); 1069 1070 // Transfer ownership of stream to a lockbytes object 1071 SvLockBytes aLockBytes( pStrm, sal_True ); 1072 SvLockBytesStat aStat; 1073 if ( aLockBytes.Stat( &aStat, SVSTATFLAG_DEFAULT ) == ERRCODE_NONE ) 1074 { 1075 sal_uInt32 nLen = aStat.nSize; 1076 sal_uLong nRead = 0; 1077 uno::Sequence< sal_Int8 > aSeq( nLen ); 1078 aLockBytes.ReadAt( 0, aSeq.getArray(), nLen, &nRead ); 1079 1080 uno::Sequence< beans::PropertyValue > aArgs(1); 1081 aArgs[0].Name = ::rtl::OUString::createFromAscii("RtfOutline"); 1082 aArgs[0].Value <<= aSeq; 1083 xHelper->executeDispatch( xProv, aCmd, ::rtl::OUString(), 0, aArgs ); 1084 } 1085 } 1086 } 1087 } 1088 else 1089 ErrorHandler::HandleError(ErrCode( eErr )); 1090 } 1091 else 1092 { 1093 // Neues Dokument erzeugen. 1094 SfxViewFrame *pFrame = SfxViewFrame::LoadDocument( *xDocSh, 0 ); 1095 SwView *pCurrView = (SwView*) pFrame->GetViewShell(); 1096 1097 // Dokumenttitel setzen 1098 String aTmp( SW_RES(STR_ABSTRACT_TITLE) ); 1099 aTmp += GetTitle(); 1100 xDocSh->SetTitle( aTmp ); 1101 pCurrView->GetWrtShell().SetNewDoc(); 1102 pFrame->Show(); 1103 pSmryDoc->SetModified(); 1104 } 1105 1106 } 1107 delete pDlg; 1108 } 1109 break; 1110 case FN_OUTLINE_TO_CLIPBOARD: 1111 case FN_OUTLINE_TO_IMPRESS: 1112 { 1113 sal_Bool bEnable = IsEnableSetModified(); 1114 EnableSetModified( sal_False ); 1115 WriterRef xWrt; 1116 // mba: looks as if relative URLs don't make sense here 1117 ::GetRTFWriter( 'O', String(), xWrt ); 1118 SvMemoryStream *pStrm = new SvMemoryStream(); 1119 pStrm->SetBufferSize( 16348 ); 1120 SwWriter aWrt( *pStrm, *GetDoc() ); 1121 ErrCode eErr = aWrt.Write( xWrt ); 1122 EnableSetModified( bEnable ); 1123 if( !ERRCODE_TOERROR( eErr ) ) 1124 { 1125 pStrm->Seek( STREAM_SEEK_TO_END ); 1126 *pStrm << '\0'; 1127 pStrm->Seek( STREAM_SEEK_TO_BEGIN ); 1128 if ( nWhich == FN_OUTLINE_TO_IMPRESS ) 1129 { 1130 uno::Reference< lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory(); 1131 uno::Reference< frame::XDispatchProvider > xProv( 1132 xORB->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.drawing.ModuleDispatcher")), UNO_QUERY ); 1133 if ( xProv.is() ) 1134 { 1135 ::rtl::OUString aCmd = ::rtl::OUString::createFromAscii( "SendOutlineToImpress" ); 1136 uno::Reference< frame::XDispatchHelper > xHelper( 1137 xORB->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.frame.DispatchHelper")), UNO_QUERY ); 1138 if ( xHelper.is() ) 1139 { 1140 pStrm->Seek( STREAM_SEEK_TO_END ); 1141 *pStrm << '\0'; 1142 pStrm->Seek( STREAM_SEEK_TO_BEGIN ); 1143 1144 // Transfer ownership of stream to a lockbytes object 1145 SvLockBytes aLockBytes( pStrm, sal_True ); 1146 SvLockBytesStat aStat; 1147 if ( aLockBytes.Stat( &aStat, SVSTATFLAG_DEFAULT ) == ERRCODE_NONE ) 1148 { 1149 sal_uInt32 nLen = aStat.nSize; 1150 sal_uLong nRead = 0; 1151 uno::Sequence< sal_Int8 > aSeq( nLen ); 1152 aLockBytes.ReadAt( 0, aSeq.getArray(), nLen, &nRead ); 1153 1154 uno::Sequence< beans::PropertyValue > aArgs(1); 1155 aArgs[0].Name = ::rtl::OUString::createFromAscii("RtfOutline"); 1156 aArgs[0].Value <<= aSeq; 1157 xHelper->executeDispatch( xProv, aCmd, ::rtl::OUString(), 0, aArgs ); 1158 } 1159 } 1160 } 1161 } 1162 else 1163 { 1164 TransferDataContainer* pClipCntnr = 1165 new TransferDataContainer; 1166 STAR_REFERENCE( datatransfer::XTransferable ) 1167 xRef( pClipCntnr ); 1168 1169 pClipCntnr->CopyAnyData( FORMAT_RTF, (sal_Char*) 1170 pStrm->GetData(), pStrm->GetEndOfData() ); 1171 pClipCntnr->CopyToClipboard( 1172 GetView()? (Window*)&GetView()->GetEditWin() : 0 ); 1173 delete pStrm; 1174 } 1175 } 1176 else 1177 ErrorHandler::HandleError(ErrCode( eErr )); 1178 } 1179 break; 1180 case SID_SPELLCHECKER_CHANGED: 1181 //! sal_False, sal_True, sal_True is on the save side but a probably overdone 1182 SW_MOD()->CheckSpellChanges(sal_False, sal_True, sal_True, sal_False ); 1183 break; 1184 1185 case SID_MAIL_PREPAREEXPORT: 1186 { 1187 //pWrtShell is not set in page preview 1188 if(pWrtShell) 1189 pWrtShell->StartAllAction(); 1190 pDoc->UpdateFlds( NULL, false ); 1191 pDoc->EmbedAllLinks(); 1192 pDoc->RemoveInvisibleContent(); 1193 if(pWrtShell) 1194 pWrtShell->EndAllAction(); 1195 } 1196 break; 1197 1198 case SID_MAIL_EXPORT_FINISHED: 1199 { 1200 if(pWrtShell) 1201 pWrtShell->StartAllAction(); 1202 //try to undo the removal of invisible content 1203 pDoc->RestoreInvisibleContent(); 1204 if(pWrtShell) 1205 pWrtShell->EndAllAction(); 1206 } 1207 break; 1208 case FN_NEW_HTML_DOC: 1209 case FN_NEW_GLOBAL_DOC: 1210 { 1211 bDone = sal_False; 1212 sal_Bool bCreateHtml = FN_NEW_HTML_DOC == nWhich; 1213 1214 sal_Bool bCreateByOutlineLevel = false; //#outline level,add by zhaojianwei 1215 sal_Int32 nTemplateOutlineLevel = 0 ; //#outline level,add by zhaojianwei 1216 1217 String aFileName, aTemplateName; 1218 if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nWhich, sal_False, &pItem ) ) 1219 { 1220 aFileName = ((const SfxStringItem*)pItem)->GetValue(); 1221 SFX_ITEMSET_ARG( pArgs, pTemplItem, SfxStringItem, SID_TEMPLATE_NAME, sal_False ); 1222 if ( pTemplItem ) 1223 aTemplateName = pTemplItem->GetValue(); 1224 } 1225 bool bError = false; 1226 if ( !aFileName.Len() ) 1227 { 1228 FileDialogHelper aDlgHelper( TemplateDescription::FILESAVE_AUTOEXTENSION_TEMPLATE, 0 ); 1229 1230 const sal_Int16 nControlIds[] = { 1231 CommonFilePickerElementIds::PUSHBUTTON_OK, 1232 CommonFilePickerElementIds::PUSHBUTTON_CANCEL, 1233 CommonFilePickerElementIds::LISTBOX_FILTER, 1234 CommonFilePickerElementIds::CONTROL_FILEVIEW, 1235 CommonFilePickerElementIds::EDIT_FILEURL, 1236 ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 1237 ExtendedFilePickerElementIds::LISTBOX_TEMPLATE, 1238 0 1239 }; 1240 1241 const char* aHTMLHelpIds[] = 1242 { 1243 HID_SEND_HTML_CTRL_PUSHBUTTON_OK, 1244 HID_SEND_HTML_CTRL_PUSHBUTTON_CANCEL, 1245 HID_SEND_HTML_CTRL_LISTBOX_FILTER, 1246 HID_SEND_HTML_CTRL_CONTROL_FILEVIEW, 1247 HID_SEND_HTML_CTRL_EDIT_FILEURL, 1248 HID_SEND_HTML_CTRL_CHECKBOX_AUTOEXTENSION, 1249 HID_SEND_HTML_CTRL_LISTBOX_TEMPLATE, 1250 "" 1251 }; 1252 1253 const char* aMasterHelpIds[] = 1254 { 1255 HID_SEND_MASTER_CTRL_PUSHBUTTON_OK, 1256 HID_SEND_MASTER_CTRL_PUSHBUTTON_CANCEL, 1257 HID_SEND_MASTER_CTRL_LISTBOX_FILTER, 1258 HID_SEND_MASTER_CTRL_CONTROL_FILEVIEW, 1259 HID_SEND_MASTER_CTRL_EDIT_FILEURL, 1260 HID_SEND_MASTER_CTRL_CHECKBOX_AUTOEXTENSION, 1261 HID_SEND_MASTER_CTRL_LISTBOX_TEMPLATE, 1262 "" 1263 }; 1264 1265 const char** pHelpIds = bCreateHtml ? aHTMLHelpIds : aMasterHelpIds; 1266 aDlgHelper.SetControlHelpIds( nControlIds, pHelpIds ); 1267 uno::Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker(); 1268 1269 const SfxFilter* pFlt; 1270 sal_uInt16 nStrId; 1271 1272 if( bCreateHtml ) 1273 { 1274 // fuer HTML gibts es nur einen Filter!! 1275 pFlt = SwIoSystem::GetFilterOfFormat( 1276 String::CreateFromAscii("HTML"), 1277 SwWebDocShell::Factory().GetFilterContainer() ); 1278 nStrId = STR_LOAD_HTML_DOC; 1279 } 1280 else 1281 { 1282 // Fuer Global-Dokumente bieten wir jetzt auch nur 1283 // noch den aktuellen an. 1284 pFlt = SwGlobalDocShell::Factory().GetFilterContainer()-> 1285 GetFilter4Extension( String::CreateFromAscii("odm") ); 1286 nStrId = STR_LOAD_GLOBAL_DOC; 1287 } 1288 1289 if( pFlt ) 1290 { 1291 uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY); 1292 const String sWild = ((WildCard&)pFlt->GetWildcard()).GetWildCard(); 1293 xFltMgr->appendFilter( pFlt->GetUIName(), sWild ); 1294 try 1295 { 1296 xFltMgr->setCurrentFilter( pFlt->GetUIName() ) ; 1297 } 1298 catch( const uno::Exception& ) 1299 { 1300 bError = true; 1301 } 1302 } 1303 if(!bError) 1304 { 1305 uno::Reference<XFilePickerControlAccess> xCtrlAcc(xFP, UNO_QUERY); 1306 1307 //#removed by zhaojianwei 1308 1309 // const sal_uInt16 nCount = pDoc->GetTxtFmtColls()->Count(); 1310 // Sequence<OUString> aListBoxEntries(nCount); 1311 // OUString* pEntries = aListBoxEntries.getArray(); 1312 // sal_Int32 nIdx = 0; 1313 // sal_Int16 nSelect = 0; 1314 // OUString sStartTemplate; 1315 // SwTxtFmtColl *pFnd = 0, *pAny = 0; 1316 // for(sal_uInt16 i = 0; i < nCount; ++i) 1317 // { 1318 // SwTxtFmtColl &rTxtColl = 1319 // *pDoc->GetTxtFmtColls()->GetObject( i ); 1320 // if( !rTxtColl.IsDefault() && rTxtColl.IsAtDocNodeSet() ) 1321 // { 1322 // //if( MAXLEVEL >= rTxtColl.GetOutlineLevel() && ( !pFnd || //#outline level,zhaojianwei 1323 //if( rTxtColl.IsAssignedToListLevelOfOutlineStyle() && ( !pFnd || //<-end,zhaojianwei 1324 // pFnd->GetAssignedOutlineStyleLevel() > rTxtColl.GetAssignedOutlineStyleLevel() )) 1325 // { 1326 // nSelect = (sal_Int16)nIdx; 1327 // pFnd = &rTxtColl; 1328 // sStartTemplate = rTxtColl.GetName(); 1329 // } 1330 // else if( !pAny ) 1331 // pAny = &rTxtColl; 1332 // //pEntries[nIdx++] = rTxtColl.GetName(); //#outline level,remove by zhaojianwei 1333 // pEntries[nIdx++] = sStyles + rTxtColl.GetName(); //#outline level,add by zhaojianwei 1334 // } 1335 // } 1336 // if(!sStartTemplate.getLength() && pAny) 1337 // sStartTemplate = pAny->GetName(); 1338 // aListBoxEntries.realloc(nIdx); 1339 //<-end,zhaojianwei 1340 1341 1342 //#outline level,add by zhaojianwei 1343 ///////////////////////////////////////////////////////////////////// 1344 1345 bool bOutline[MAXLEVEL] = {false}; 1346 const SwOutlineNodes& rOutlNds = pDoc->GetNodes().GetOutLineNds(); 1347 if( rOutlNds.Count() ) 1348 { 1349 int nLevel; 1350 for(sal_uInt16 n = 0; n < rOutlNds.Count(); ++n ) 1351 if( ( nLevel = rOutlNds[n]->GetTxtNode()->GetAttrOutlineLevel()) > 0 && 1352 ! bOutline[nLevel-1] ) 1353 { 1354 bOutline[nLevel-1] = true; 1355 } 1356 } 1357 1358 const sal_uInt16 nStyleCount = pDoc->GetTxtFmtColls()->Count(); 1359 Sequence<OUString> aListBoxEntries( MAXLEVEL + nStyleCount); 1360 OUString* pEntries = aListBoxEntries.getArray(); 1361 sal_Int32 nIdx = 0 ; 1362 1363 OUString sOutline( SW_RESSTR(STR_FDLG_OUTLINE_LEVEL) ); 1364 for( sal_uInt16 i = 0; i < MAXLEVEL; ++i ) 1365 { 1366 if( bOutline[i] ) 1367 pEntries[nIdx++] = sOutline + String::CreateFromInt32( i+1 ); 1368 } 1369 1370 OUString sStyle( SW_RESSTR(STR_FDLG_STYLE) ); 1371 for(sal_uInt16 i = 0; i < nStyleCount; ++i) 1372 { 1373 SwTxtFmtColl &rTxtColl = 1374 *pDoc->GetTxtFmtColls()->GetObject( i ); 1375 if( !rTxtColl.IsDefault() && rTxtColl.IsAtDocNodeSet() ) 1376 { 1377 pEntries[nIdx++] = sStyle + rTxtColl.GetName(); 1378 } 1379 } 1380 1381 aListBoxEntries.realloc(nIdx); 1382 sal_Int16 nSelect = 0; 1383 ///////////////////////////////////////////////////////////////////// 1384 //<-end,zhaojianwei 1385 1386 try 1387 { 1388 Any aTemplates(&aListBoxEntries, ::getCppuType(&aListBoxEntries)); 1389 1390 xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE, 1391 ListboxControlActions::ADD_ITEMS , aTemplates ); 1392 Any aSelectPos(&nSelect, ::getCppuType(&nSelect)); 1393 xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE, 1394 ListboxControlActions::SET_SELECT_ITEM, aSelectPos ); 1395 xCtrlAcc->setLabel( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE, 1396 String(SW_RES( STR_FDLG_TEMPLATE_NAME ))); 1397 } 1398 catch(Exception& ) 1399 { 1400 DBG_ERROR("control acces failed"); 1401 } 1402 1403 xFP->setTitle( SW_RESSTR( nStrId )); 1404 SvtPathOptions aPathOpt; 1405 xFP->setDisplayDirectory( aPathOpt.GetWorkPath() ); 1406 if( ERRCODE_NONE == aDlgHelper.Execute()) 1407 { 1408 aFileName = xFP->getFiles().getConstArray()[0]; 1409 Any aTemplateValue = xCtrlAcc->getValue( 1410 ExtendedFilePickerElementIds::LISTBOX_TEMPLATE, 1411 ListboxControlActions::GET_SELECTED_ITEM ); 1412 OUString sTmpl; 1413 aTemplateValue >>= sTmpl; 1414 //aTemplateName = sTmpl; //#outline level,removed by zhaojianwei 1415 //#outline level,add by zhaojianwei 1416 1417 sal_Int32 nColonPos = sTmpl.indexOf( sal_Unicode(':') ); 1418 OUString sPrefix = sTmpl.copy( 0L, nColonPos ); 1419 if( sPrefix.equalsAscii("Style")) 1420 { 1421 aTemplateName = sTmpl.copy( 7L ); //get string behind "Style: " 1422 } 1423 else if( sPrefix.equalsAscii("Outline")) 1424 { 1425 nTemplateOutlineLevel = ( sTmpl.copy( 15L )).toInt32(); //get string behind "Outline: Leve "; 1426 bCreateByOutlineLevel = true; 1427 } 1428 //<-end,zhaojianwei 1429 1430 if ( aFileName.Len() ) 1431 { 1432 rReq.AppendItem( SfxStringItem( nWhich, aFileName ) ); 1433 if( aTemplateName.Len() ) 1434 rReq.AppendItem( SfxStringItem( SID_TEMPLATE_NAME, aTemplateName ) ); 1435 } 1436 } 1437 } 1438 } 1439 1440 //const SwTxtFmtColl* pSplitColl = 0; //#outline level,removed by zhaojianwei 1441 // if ( aTemplateName.Len() ) 1442 // pSplitColl = pDoc->FindTxtFmtCollByName(aTemplateName); 1443 //<-end,zhaojianwei 1444 if( aFileName.Len() ) 1445 { 1446 if( PrepareClose( sal_False ) ) 1447 { 1448 SwWait aWait( *this, sal_True ); 1449 1450 //bDone = bCreateHtml //#outline level,removed by zhaojianwei 1451 // ? pDoc->GenerateHTMLDoc( aFileName, pSplitColl ) 1452 // : pDoc->GenerateGlobalDoc( aFileName, pSplitColl ); 1453 if ( bCreateByOutlineLevel ) //add by zhaojianwei 1454 { 1455 bDone = bCreateHtml //#outline level,removed by zhaojianwei 1456 ? pDoc->GenerateHTMLDoc( aFileName, nTemplateOutlineLevel ) 1457 : pDoc->GenerateGlobalDoc( aFileName, nTemplateOutlineLevel ); 1458 } 1459 else 1460 { 1461 const SwTxtFmtColl* pSplitColl = 0; 1462 if ( aTemplateName.Len() ) 1463 pSplitColl = pDoc->FindTxtFmtCollByName(aTemplateName); 1464 bDone = bCreateHtml //#outline level,removed by zhaojianwei 1465 ? pDoc->GenerateHTMLDoc( aFileName, pSplitColl ) 1466 : pDoc->GenerateGlobalDoc( aFileName, pSplitColl ); 1467 } 1468 //<-end,zhaojianwei 1469 if( bDone ) 1470 { 1471 SfxStringItem aName( SID_FILE_NAME, aFileName ); 1472 SfxStringItem aReferer( SID_REFERER, aEmptyStr ); 1473 SfxViewShell* pViewShell = SfxViewShell::GetFirst(); 1474 while(pViewShell) 1475 { 1476 //search for the view that created the call 1477 if(pViewShell->GetObjectShell() == this && pViewShell->GetDispatcher()) 1478 { 1479 SfxFrameItem* pFrameItem = new SfxFrameItem( SID_DOCFRAME, 1480 pViewShell->GetViewFrame() ); 1481 SfxDispatcher* pDispatch = pViewShell->GetDispatcher(); 1482 pDispatch->Execute( 1483 SID_OPENDOC, 1484 SFX_CALLMODE_ASYNCHRON, 1485 &aName, 1486 &aReferer, 1487 pFrameItem, 0L ); 1488 1489 delete pFrameItem; 1490 break; 1491 } 1492 pViewShell = SfxViewShell::GetNext(*pViewShell); 1493 } 1494 } 1495 } 1496 if( !bDone && !rReq.IsAPI() ) 1497 { 1498 InfoBox( 0, SW_RESSTR( STR_CANTCREATE )).Execute(); 1499 } 1500 } 1501 } 1502 rReq.SetReturnValue(SfxBoolItem( nWhich, bDone )); 1503 if (bDone) 1504 rReq.Done(); 1505 else 1506 rReq.Ignore(); 1507 break; 1508 1509 case SID_ATTR_YEAR2000: 1510 if ( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nWhich , sal_False, &pItem )) 1511 { 1512 DBG_ASSERT(pItem->ISA(SfxUInt16Item), "falsches Item"); 1513 sal_uInt16 nYear2K = ((SfxUInt16Item*)pItem)->GetValue(); 1514 //ueber Views iterieren und den State an den FormShells setzen 1515 1516 SfxViewFrame* pVFrame = SfxViewFrame::GetFirst( this ); 1517 SfxViewShell* pViewShell = pVFrame ? pVFrame->GetViewShell() : 0; 1518 SwView* pCurrView = dynamic_cast< SwView* >( pViewShell ); 1519 while(pCurrView) 1520 { 1521 FmFormShell* pFormShell = pCurrView->GetFormShell(); 1522 if(pFormShell) 1523 pFormShell->SetY2KState(nYear2K); 1524 pVFrame = SfxViewFrame::GetNext( *pVFrame, this ); 1525 pViewShell = pVFrame ? pVFrame->GetViewShell() : 0; 1526 pCurrView = dynamic_cast<SwView*>( pViewShell ); 1527 } 1528 pDoc->GetNumberFormatter(sal_True)->SetYear2000(nYear2K); 1529 } 1530 break; 1531 1532 default: DBG_ERROR("falscher Dispatcher"); 1533 } 1534 } 1535 1536 1537 /*-------------------------------------------------------------------- 1538 Beschreibung: 1539 --------------------------------------------------------------------*/ 1540 1541 long SwDocShell::DdeGetData( const String& rItem, const String& rMimeType, 1542 uno::Any & rValue ) 1543 { 1544 return pDoc->GetData( rItem, rMimeType, rValue ); 1545 } 1546 1547 1548 /*-------------------------------------------------------------------- 1549 Beschreibung: 1550 --------------------------------------------------------------------*/ 1551 1552 long SwDocShell::DdeSetData( const String& rItem, const String& rMimeType, 1553 const uno::Any & rValue ) 1554 { 1555 return pDoc->SetData( rItem, rMimeType, rValue ); 1556 } 1557 1558 1559 /*-------------------------------------------------------------------- 1560 Beschreibung: 1561 --------------------------------------------------------------------*/ 1562 1563 ::sfx2::SvLinkSource* SwDocShell::DdeCreateLinkSource( const String& rItem ) 1564 { 1565 return pDoc->CreateLinkSource( rItem ); 1566 } 1567 1568 /*-------------------------------------------------------------------- 1569 Beschreibung: 1570 --------------------------------------------------------------------*/ 1571 1572 void SwDocShell::FillClass( SvGlobalName * pClassName, 1573 sal_uInt32 * pClipFormat, 1574 String * /*pAppName*/, 1575 String * pLongUserName, 1576 String * pUserName, 1577 sal_Int32 nVersion, 1578 sal_Bool bTemplate /* = sal_False */) const 1579 { 1580 if (nVersion == SOFFICE_FILEFORMAT_60) 1581 { 1582 *pClassName = SvGlobalName( SO3_SW_CLASSID_60 ); 1583 *pClipFormat = SOT_FORMATSTR_ID_STARWRITER_60; 1584 *pLongUserName = SW_RESSTR(STR_WRITER_DOCUMENT_FULLTYPE); 1585 } 1586 else if (nVersion == SOFFICE_FILEFORMAT_8) 1587 { 1588 *pClassName = SvGlobalName( SO3_SW_CLASSID_60 ); 1589 *pClipFormat = bTemplate ? SOT_FORMATSTR_ID_STARWRITER_8_TEMPLATE : SOT_FORMATSTR_ID_STARWRITER_8; 1590 *pLongUserName = SW_RESSTR(STR_WRITER_DOCUMENT_FULLTYPE); 1591 } 1592 1593 *pUserName = SW_RESSTR(STR_HUMAN_SWDOC_NAME); 1594 } 1595 1596 1597 /*-------------------------------------------------------------------- 1598 Beschreibung: 1599 --------------------------------------------------------------------*/ 1600 1601 void SwDocShell::SetModified( sal_Bool bSet ) 1602 { 1603 SfxObjectShell::SetModified( bSet ); 1604 if( IsEnableSetModified()) 1605 { 1606 if (!pDoc->IsInCallModified() ) 1607 { 1608 EnableSetModified( sal_False ); 1609 if( bSet ) 1610 { 1611 sal_Bool bOld = pDoc->IsModified(); 1612 pDoc->SetModified(); 1613 if( !bOld ) 1614 { 1615 pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified(); 1616 } 1617 } 1618 else 1619 pDoc->ResetModified(); 1620 1621 EnableSetModified( sal_True ); 1622 } 1623 1624 UpdateChildWindows(); 1625 Broadcast(SfxSimpleHint(SFX_HINT_DOCCHANGED)); 1626 } 1627 } 1628 1629 /*-------------------------------------------------------------------- 1630 Beschreibung: 1631 --------------------------------------------------------------------*/ 1632 1633 void SwDocShell::UpdateChildWindows() 1634 { 1635 // Flddlg ggf neu initialisieren (z.B. fuer TYP_SETVAR) 1636 if(!GetView()) 1637 return; 1638 SfxViewFrame* pVFrame = GetView()->GetViewFrame(); 1639 SwFldDlgWrapper *pWrp = (SwFldDlgWrapper*)pVFrame-> 1640 GetChildWindow( SwFldDlgWrapper::GetChildWindowId() ); 1641 if( pWrp ) 1642 pWrp->ReInitDlg( this ); 1643 1644 // RedlineDlg ggf neu initialisieren 1645 SwRedlineAcceptChild *pRed = (SwRedlineAcceptChild*)pVFrame-> 1646 GetChildWindow( SwRedlineAcceptChild::GetChildWindowId() ); 1647 if( pRed ) 1648 pRed->ReInitDlg( this ); 1649 } 1650 1651 /*-------------------------------------------------------------------- 1652 Beschreibung: 1653 --------------------------------------------------------------------*/ 1654 // --> OD 2005-08-02 #i48748# 1655 class SwReloadFromHtmlReader : public SwReader 1656 { 1657 public: 1658 SwReloadFromHtmlReader( SfxMedium& _rTmpMedium, 1659 const String& _rFilename, 1660 SwDoc* _pDoc ) 1661 : SwReader( _rTmpMedium, _rFilename, _pDoc ) 1662 { 1663 SetBaseURL( _rFilename ); 1664 } 1665 }; 1666 // <-- 1667 void SwDocShell::ReloadFromHtml( const String& rStreamName, SwSrcView* pSrcView ) 1668 { 1669 sal_Bool bModified = IsModified(); 1670 1671 // MIB 23.6.97: Die HTTP-Header-Felder muessen geloescht werden, 1672 // sonst gibt es welche aus Meta-Tags hinter doppelt und dreifach. 1673 ClearHeaderAttributesForSourceViewHack(); 1674 1675 // MIB 24.07.97: Das Dokument-Basic muss auch noch d'ran glauben ... 1676 SvxHtmlOptions* pHtmlOptions = SvxHtmlOptions::Get(); 1677 //#59620# HasBasic() zeigt an, dass es schon einen BasicManager an der DocShell 1678 // gibt. Der wurde im HTML-Import immer angelegt, wenn Macros im Quelltext 1679 // vorhanden sind. 1680 if( pHtmlOptions && pHtmlOptions->IsStarBasic() && HasBasic()) 1681 { 1682 BasicManager *pBasicMan = GetBasicManager(); 1683 if( pBasicMan && (pBasicMan != SFX_APP()->GetBasicManager()) ) 1684 { 1685 sal_uInt16 nLibCount = pBasicMan->GetLibCount(); 1686 while( nLibCount ) 1687 { 1688 StarBASIC *pBasic = pBasicMan->GetLib( --nLibCount ); 1689 if( pBasic ) 1690 { 1691 // Die IDE benachrichtigen 1692 SfxUsrAnyItem aShellItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, makeAny( GetModel() ) ); 1693 String aLibName( pBasic->GetName() ); 1694 SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName ); 1695 pSrcView->GetViewFrame()->GetDispatcher()->Execute( 1696 SID_BASICIDE_LIBREMOVED, 1697 SFX_CALLMODE_SYNCHRON, 1698 &aShellItem, &aLibNameItem, 0L ); 1699 1700 // Aus der Standard-Lib werden nur die Module geloescht 1701 if( nLibCount ) 1702 pBasicMan->RemoveLib( nLibCount, sal_True ); 1703 else 1704 pBasic->Clear(); 1705 } 1706 } 1707 1708 ASSERT( pBasicMan->GetLibCount() <= 1, 1709 "Loschen des Basics hat nicht geklappt" ); 1710 } 1711 } 1712 sal_Bool bWasBrowseMode = pDoc->get(IDocumentSettingAccess::BROWSE_MODE); 1713 RemoveLink(); 1714 1715 //jetzt muss auch das UNO-Model ueber das neue Doc informiert werden #51535# 1716 uno::Reference<text::XTextDocument> xDoc(GetBaseModel(), uno::UNO_QUERY); 1717 text::XTextDocument* pxDoc = xDoc.get(); 1718 ((SwXTextDocument*)pxDoc)->InitNewDoc(); 1719 1720 AddLink(); 1721 //#116402# update font list when new document is created 1722 UpdateFontList(); 1723 pDoc->set(IDocumentSettingAccess::BROWSE_MODE, bWasBrowseMode); 1724 pSrcView->SetPool(&GetPool()); 1725 1726 1727 const String& rMedname = GetMedium()->GetName(); 1728 1729 // fix #51032#: Die HTML-Vorlage muss noch gesetzt werden 1730 SetHTMLTemplate( *GetDoc() ); //Styles aus HTML.vor 1731 1732 SfxViewShell* pViewShell = GetView() ? (SfxViewShell*)GetView() 1733 : SfxViewShell::Current(); 1734 SfxViewFrame* pViewFrm = pViewShell->GetViewFrame(); 1735 pViewFrm->GetDispatcher()->Execute( SID_VIEWSHELL0, SFX_CALLMODE_SYNCHRON ); 1736 1737 SubInitNew(); 1738 1739 SfxMedium aMed( rStreamName, STREAM_READ, sal_False ); 1740 // --> OD 2005-08-01 #i48748# - use class <SwReloadFromHtmlReader>, because 1741 // the base URL has to be set to the filename of the document <rMedname> 1742 // and not to the base URL of the temporary file <aMed> in order to get 1743 // the URLs of the linked graphics correctly resolved. 1744 SwReloadFromHtmlReader aReader( aMed, rMedname, pDoc ); 1745 // <-- 1746 aReader.Read( *ReadHTML ); 1747 1748 const SwView* pCurrView = GetView(); 1749 //in print layout the first page(s) may have been formatted as a mix of browse 1750 //and print layout 1751 if(!bWasBrowseMode && pCurrView) 1752 { 1753 SwWrtShell& rWrtSh = pCurrView->GetWrtShell(); 1754 if( rWrtSh.GetLayout()) 1755 rWrtSh.CheckBrowseView( sal_True ); 1756 } 1757 1758 1759 // MIB 23.6.97: Die HTTP-Header-Attribute wieder in die DokInfo 1760 // uebernehmen. Die Base-URL ist hier egal, da TLX zum absolutieren die 1761 // vom Dokument nimmt. 1762 SetHeaderAttributesForSourceViewHack(); 1763 1764 if(bModified && !IsReadOnly()) 1765 SetModified(); 1766 else 1767 pDoc->ResetModified(); 1768 } 1769 1770 sal_uLong SwDocShell::LoadStylesFromFile( const String& rURL, 1771 SwgReaderOption& rOpt, sal_Bool bUnoCall ) 1772 { 1773 sal_uLong nErr = 0; 1774 1775 // Create a URL from filename 1776 INetURLObject aURLObj( rURL ); 1777 String sURL( aURLObj.GetMainURL( INetURLObject::NO_DECODE ) ); 1778 1779 // Filter bestimmen: 1780 // const SfxFilter* pFlt = SwIoSystem::GetFileFilter( rURL, aEmptyStr ); 1781 String sFactory(String::CreateFromAscii(SwDocShell::Factory().GetShortName())); 1782 SfxFilterMatcher aMatcher( sFactory ); 1783 1784 //#b6445961# search for filter in WebDocShell, too 1785 SfxMedium aMed( rURL, STREAM_STD_READ, sal_False ); 1786 const SfxFilter* pFlt = 0; 1787 aMatcher.DetectFilter( aMed, &pFlt, sal_False, sal_False ); 1788 if(!pFlt) 1789 { 1790 String sWebFactory(String::CreateFromAscii(SwWebDocShell::Factory().GetShortName())); 1791 SfxFilterMatcher aWebMatcher( sWebFactory ); 1792 aWebMatcher.DetectFilter( aMed, &pFlt, sal_False, sal_False ); 1793 } 1794 // --> OD #i117339# - trigger import only for own formats 1795 // if( aMed.IsStorage() ) 1796 bool bImport( false ); 1797 { 1798 if ( aMed.IsStorage() ) 1799 { 1800 // As <SfxMedium.GetFilter().IsOwnFormat() resp. IsOwnTemplateFormat() 1801 // does not work correct (e.g., MS Word 2007 XML Template), 1802 // use workaround provided by MAV. 1803 uno::Reference< embed::XStorage > xStorage = aMed.GetStorage(); 1804 if ( xStorage.is() ) 1805 { 1806 // use <try-catch> on retrieving <MediaType> in order to check, 1807 // if the storage is one of our own ones. 1808 try 1809 { 1810 uno::Reference< beans::XPropertySet > xProps( xStorage, uno::UNO_QUERY_THROW ); 1811 const ::rtl::OUString aMediaTypePropName( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ); 1812 xProps->getPropertyValue( aMediaTypePropName ); 1813 bImport = true; 1814 } 1815 catch( const uno::Exception& ) 1816 { 1817 bImport = false; 1818 } 1819 } 1820 } 1821 } 1822 if ( bImport ) 1823 // <-- 1824 { 1825 DBG_ASSERT((pFlt ? pFlt->GetVersion() : 0) >= SOFFICE_FILEFORMAT_60, "which file version?"); 1826 SwRead pRead = ReadXML; 1827 SwReader* pReader = 0; 1828 SwPaM* pPam = 0; 1829 // the SW3IO - Reader need the pam/wrtshell, because only then he 1830 // insert the styles! 1831 if( bUnoCall ) 1832 { 1833 SwNodeIndex aIdx( pDoc->GetNodes().GetEndOfContent(), -1 ); 1834 pPam = new SwPaM( aIdx ); 1835 pReader = new SwReader( aMed, rURL, *pPam ); 1836 } 1837 else 1838 { 1839 pReader = new SwReader( aMed, rURL, *pWrtShell->GetCrsr() ); 1840 } 1841 1842 pRead->GetReaderOpt().SetTxtFmts( rOpt.IsTxtFmts() ); 1843 pRead->GetReaderOpt().SetFrmFmts( rOpt.IsFrmFmts() ); 1844 pRead->GetReaderOpt().SetPageDescs( rOpt.IsPageDescs() ); 1845 pRead->GetReaderOpt().SetNumRules( rOpt.IsNumRules() ); 1846 pRead->GetReaderOpt().SetMerge( rOpt.IsMerge() ); 1847 1848 if( bUnoCall ) 1849 { 1850 UnoActionContext aAction( pDoc ); 1851 nErr = pReader->Read( *pRead ); 1852 } 1853 else 1854 { 1855 pWrtShell->StartAllAction(); 1856 nErr = pReader->Read( *pRead ); 1857 pWrtShell->EndAllAction(); 1858 } 1859 delete pPam; 1860 delete pReader; 1861 } 1862 1863 return nErr; 1864 } 1865 1866 /*-------------------------------------------------------------------- 1867 Get a client for an embedded object if possible. 1868 --------------------------------------------------------------------*/ 1869 SfxInPlaceClient* SwDocShell::GetIPClient( const ::svt::EmbeddedObjectRef& xObjRef ) 1870 { 1871 SfxInPlaceClient* pResult = NULL; 1872 1873 SwWrtShell* pShell = GetWrtShell(); 1874 if ( pShell ) 1875 { 1876 pResult = pShell->GetView().FindIPClient( xObjRef.GetObject(), (Window*)&pShell->GetView().GetEditWin() ); 1877 if ( !pResult ) 1878 pResult = new SwOleClient( &pShell->GetView(), &pShell->GetView().GetEditWin(), xObjRef ); 1879 } 1880 1881 return pResult; 1882 } 1883 1884