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 28 #include <hintids.hxx> 29 30 #include <svx/dialogs.hrc> 31 #include <i18npool/mslangid.hxx> 32 #include <sot/storinfo.hxx> 33 #include <sot/storage.hxx> 34 #include <svl/zforlist.hxx> 35 #include <svtools/ctrltool.hxx> 36 #include <unotools/lingucfg.hxx> 37 #include <sfx2/docfile.hxx> 38 #include <sfx2/sfxmodelfactory.hxx> 39 #include <sfx2/printer.hxx> 40 #include <sfx2/bindings.hxx> 41 #include <svl/asiancfg.hxx> 42 #include <editeng/unolingu.hxx> 43 #include <sfx2/request.hxx> 44 #include <svl/intitem.hxx> 45 #include <editeng/adjitem.hxx> 46 #include <editeng/akrnitem.hxx> 47 #include <linguistic/lngprops.hxx> 48 #include <com/sun/star/document/UpdateDocMode.hpp> 49 #include <com/sun/star/i18n/ScriptType.hpp> 50 #include <rtl/logfile.hxx> 51 #include <sfx2/docfilt.hxx> 52 #include <svx/xtable.hxx> 53 #include <svx/drawitem.hxx> 54 #include <editeng/fhgtitem.hxx> 55 #include <editeng/fontitem.hxx> 56 #include <editeng/flstitem.hxx> 57 #include <editeng/tstpitem.hxx> 58 #include <editeng/langitem.hxx> 59 #include <editeng/colritem.hxx> 60 #include <editeng/hyznitem.hxx> 61 #include <editeng/svxacorr.hxx> 62 #include <vcl/svapp.hxx> 63 #include <view.hxx> 64 #include <prtopt.hxx> 65 #include <fmtcol.hxx> 66 #include <docsh.hxx> 67 #include <wdocsh.hxx> 68 #include <swmodule.hxx> 69 #include <doc.hxx> 70 #include <docfac.hxx> 71 #include <docstyle.hxx> 72 #include <shellio.hxx> 73 #include <tox.hxx> 74 #include <swdtflvr.hxx> 75 #include <dbmgr.hxx> 76 #include <usrpref.hxx> 77 #include <fontcfg.hxx> 78 #include <poolfmt.hxx> 79 #include <modcfg.hxx> 80 #include <globdoc.hxx> 81 #include <ndole.hxx> 82 #include <mdiexp.hxx> 83 #include <unotxdoc.hxx> 84 #include <linkenum.hxx> 85 #include <swwait.hxx> 86 #include <wrtsh.hxx> 87 #include <swerror.h> 88 #include <globals.hrc> 89 90 // #i18732# 91 #include <fmtfollowtextflow.hxx> 92 93 #include <unochart.hxx> 94 95 // text grid 96 #include <tgrditem.hxx> 97 98 using namespace ::com::sun::star::i18n; 99 using namespace ::com::sun::star::lang; 100 using namespace ::com::sun::star::uno; 101 using namespace ::com::sun::star; 102 using ::rtl::OUString; 103 104 /*-----------------21.09.96 15.29------------------- 105 106 --------------------------------------------------*/ 107 108 109 /*-------------------------------------------------------------------- 110 Beschreibung: Document laden 111 --------------------------------------------------------------------*/ 112 113 114 sal_Bool SwDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor ) 115 { 116 RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "SwDocShell::InitNew" ); 117 118 sal_Bool bRet = SfxObjectShell::InitNew( xStor ); 119 ASSERT( GetMapUnit() == MAP_TWIP, "map unit is not twip!" ); 120 sal_Bool bHTMLTemplSet = sal_False; 121 if( bRet ) 122 { 123 AddLink(); // pDoc / pIo ggf. anlegen 124 125 sal_Bool bWeb = ISA( SwWebDocShell ); 126 if ( bWeb ) 127 bHTMLTemplSet = SetHTMLTemplate( *GetDoc() );//Styles aus HTML.vor 128 else if( ISA( SwGlobalDocShell ) ) 129 GetDoc()->set(IDocumentSettingAccess::GLOBAL_DOCUMENT, true); // Globaldokument 130 131 132 /* 133 //JP 12.07.95: so einfach waere es fuer die neu Mimik 134 pDoc->SetDefault( SvxTabStopItem( 1, 135 GetStar Writer App()->GetUsrPref()->GetDefTabDist(), 136 SVX_TAB_ADJUST_DEFAULT, 137 RES_PARATR_TABSTOP)); 138 */ 139 if ( GetCreateMode() == SFX_CREATE_MODE_EMBEDDED ) 140 SwTransferable::InitOle( this, *pDoc ); 141 142 // set forbidden characters if necessary 143 SvxAsianConfig aAsian; 144 Sequence<Locale> aLocales = aAsian.GetStartEndCharLocales(); 145 if(aLocales.getLength()) 146 { 147 const Locale* pLocales = aLocales.getConstArray(); 148 for(sal_Int32 i = 0; i < aLocales.getLength(); i++) 149 { 150 ForbiddenCharacters aForbidden; 151 aAsian.GetStartEndChars( pLocales[i], aForbidden.beginLine, aForbidden.endLine); 152 LanguageType eLang = SvxLocaleToLanguage(pLocales[i]); 153 pDoc->setForbiddenCharacters( eLang, aForbidden); 154 } 155 } 156 pDoc->set(IDocumentSettingAccess::KERN_ASIAN_PUNCTUATION, 157 !aAsian.IsKerningWesternTextOnly()); 158 pDoc->setCharacterCompressionType(static_cast<SwCharCompressType>(aAsian.GetCharDistanceCompression())); 159 pDoc->setPrintData(*SW_MOD()->GetPrtOptions(bWeb)); 160 161 SubInitNew(); 162 163 // fuer alle 164 165 SwStdFontConfig* pStdFont = SW_MOD()->GetStdFontConfig(); 166 SfxPrinter* pPrt = pDoc->getPrinter( false ); 167 168 String sEntry; 169 sal_uInt16 aFontWhich[] = 170 { RES_CHRATR_FONT, 171 RES_CHRATR_CJK_FONT, 172 RES_CHRATR_CTL_FONT 173 }; 174 sal_uInt16 aFontHeightWhich[] = 175 { 176 RES_CHRATR_FONTSIZE, 177 RES_CHRATR_CJK_FONTSIZE, 178 RES_CHRATR_CTL_FONTSIZE 179 }; 180 sal_uInt16 aFontIds[] = 181 { 182 FONT_STANDARD, 183 FONT_STANDARD_CJK, 184 FONT_STANDARD_CTL 185 }; 186 sal_uInt16 nFontTypes[] = 187 { 188 DEFAULTFONT_LATIN_TEXT, 189 DEFAULTFONT_CJK_TEXT, 190 DEFAULTFONT_CTL_TEXT 191 }; 192 sal_uInt16 aLangTypes[] = 193 { 194 RES_CHRATR_LANGUAGE, 195 RES_CHRATR_CJK_LANGUAGE, 196 RES_CHRATR_CTL_LANGUAGE 197 }; 198 199 for(sal_uInt8 i = 0; i < 3; i++) 200 { 201 sal_uInt16 nFontWhich = aFontWhich[i]; 202 sal_uInt16 nFontId = aFontIds[i]; 203 SvxFontItem* pFontItem = 0; 204 const SvxLanguageItem& rLang = (const SvxLanguageItem&)pDoc->GetDefault( aLangTypes[i] ); 205 LanguageType eLanguage = rLang.GetLanguage(); 206 if(!pStdFont->IsFontDefault(nFontId)) 207 { 208 sEntry = pStdFont->GetFontFor(nFontId); 209 210 Font aFont( sEntry, Size( 0, 10 ) ); 211 if( pPrt ) 212 { 213 aFont = pPrt->GetFontMetric( aFont ); 214 } 215 216 pFontItem = new SvxFontItem(aFont.GetFamily(), aFont.GetName(), 217 aEmptyStr, aFont.GetPitch(), aFont.GetCharSet(), nFontWhich); 218 } 219 else 220 { 221 // #107782# OJ use korean language if latin was used 222 if ( i == 0 ) 223 { 224 LanguageType eUiLanguage = Application::GetSettings().GetUILanguage(); 225 switch( eUiLanguage ) 226 { 227 case LANGUAGE_KOREAN: 228 case LANGUAGE_KOREAN_JOHAB: 229 eLanguage = eUiLanguage; 230 break; 231 } 232 } 233 234 Font aLangDefFont = OutputDevice::GetDefaultFont( 235 nFontTypes[i], 236 eLanguage, 237 DEFAULTFONT_FLAGS_ONLYONE ); 238 pFontItem = new SvxFontItem(aLangDefFont.GetFamily(), aLangDefFont.GetName(), 239 aEmptyStr, aLangDefFont.GetPitch(), aLangDefFont.GetCharSet(), nFontWhich); 240 } 241 pDoc->SetDefault(*pFontItem); 242 if( !bHTMLTemplSet ) 243 { 244 SwTxtFmtColl *pColl = pDoc->GetTxtCollFromPool(RES_POOLCOLL_STANDARD); 245 pColl->ResetFmtAttr(nFontWhich); 246 } 247 delete pFontItem; 248 sal_Int32 nFontHeight = pStdFont->GetFontHeight( FONT_STANDARD, i, eLanguage ); 249 if(nFontHeight <= 0) 250 nFontHeight = pStdFont->GetDefaultHeightFor( nFontId, eLanguage ); 251 pDoc->SetDefault(SvxFontHeightItem( nFontHeight, 100, aFontHeightWhich[i] )); 252 if( !bHTMLTemplSet ) 253 { 254 SwTxtFmtColl *pColl = pDoc->GetTxtCollFromPool(RES_POOLCOLL_STANDARD); 255 pColl->ResetFmtAttr(aFontHeightWhich[i]); 256 } 257 258 } 259 sal_uInt16 aFontIdPoolId[] = 260 { 261 FONT_OUTLINE, RES_POOLCOLL_HEADLINE_BASE, 262 FONT_LIST, RES_POOLCOLL_NUMBUL_BASE, 263 FONT_CAPTION, RES_POOLCOLL_LABEL, 264 FONT_INDEX, RES_POOLCOLL_REGISTER_BASE, 265 FONT_OUTLINE_CJK, RES_POOLCOLL_HEADLINE_BASE, 266 FONT_LIST_CJK, RES_POOLCOLL_NUMBUL_BASE, 267 FONT_CAPTION_CJK, RES_POOLCOLL_LABEL, 268 FONT_INDEX_CJK, RES_POOLCOLL_REGISTER_BASE, 269 FONT_OUTLINE_CTL, RES_POOLCOLL_HEADLINE_BASE, 270 FONT_LIST_CTL, RES_POOLCOLL_NUMBUL_BASE, 271 FONT_CAPTION_CTL, RES_POOLCOLL_LABEL, 272 FONT_INDEX_CTL, RES_POOLCOLL_REGISTER_BASE 273 }; 274 275 sal_uInt16 nFontWhich = RES_CHRATR_FONT; 276 sal_uInt16 nFontHeightWhich = RES_CHRATR_FONTSIZE; 277 LanguageType eLanguage = static_cast<const SvxLanguageItem&>(pDoc->GetDefault( RES_CHRATR_LANGUAGE )).GetLanguage(); 278 for(sal_uInt8 nIdx = 0; nIdx < 24; nIdx += 2) 279 { 280 if(nIdx == 8) 281 { 282 nFontWhich = RES_CHRATR_CJK_FONT; 283 nFontHeightWhich = RES_CHRATR_CJK_FONTSIZE; 284 eLanguage = static_cast<const SvxLanguageItem&>(pDoc->GetDefault( RES_CHRATR_CJK_LANGUAGE )).GetLanguage(); 285 } 286 else if(nIdx == 16) 287 { 288 nFontWhich = RES_CHRATR_CTL_FONT; 289 nFontHeightWhich = RES_CHRATR_CTL_FONTSIZE; 290 eLanguage = static_cast<const SvxLanguageItem&>(pDoc->GetDefault( RES_CHRATR_CTL_LANGUAGE )).GetLanguage(); 291 } 292 SwTxtFmtColl *pColl = 0; 293 if(!pStdFont->IsFontDefault(aFontIdPoolId[nIdx])) 294 { 295 sEntry = pStdFont->GetFontFor(aFontIdPoolId[nIdx]); 296 297 Font aFont( sEntry, Size( 0, 10 ) ); 298 if( pPrt ) 299 aFont = pPrt->GetFontMetric( aFont ); 300 301 pColl = pDoc->GetTxtCollFromPool(aFontIdPoolId[nIdx + 1]); 302 if( !bHTMLTemplSet || 303 SFX_ITEM_SET != pColl->GetAttrSet().GetItemState( 304 nFontWhich, sal_False ) ) 305 { 306 pColl->SetFmtAttr(SvxFontItem(aFont.GetFamily(), aFont.GetName(), 307 aEmptyStr, aFont.GetPitch(), aFont.GetCharSet(), nFontWhich)); 308 } 309 } 310 sal_Int32 nFontHeight = pStdFont->GetFontHeight( static_cast< sal_Int8 >(aFontIdPoolId[nIdx]), 0, eLanguage ); 311 if(nFontHeight <= 0) 312 nFontHeight = pStdFont->GetDefaultHeightFor( aFontIdPoolId[nIdx], eLanguage ); 313 if(!pColl) 314 pColl = pDoc->GetTxtCollFromPool(aFontIdPoolId[nIdx + 1]); 315 SvxFontHeightItem aFontHeight( (const SvxFontHeightItem&)pColl->GetFmtAttr( nFontHeightWhich, sal_True )); 316 if(aFontHeight.GetHeight() != sal::static_int_cast<sal_uInt32, sal_Int32>(nFontHeight)) 317 { 318 aFontHeight.SetHeight(nFontHeight); 319 pColl->SetFmtAttr( aFontHeight ); 320 } 321 } 322 323 // the default for documents created via 'File/New' should be 'on' 324 // (old documents, where this property was not yet implemented, will get the 325 // value 'false' in the SwDoc c-tor) 326 pDoc->set( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT, 327 SW_MOD()->GetUsrPref( bWeb )->IsAlignMathObjectsToBaseline() ); 328 } 329 330 /* #106748# If the default frame direction of a document is RTL 331 the default adjusment is to the right. */ 332 if( !bHTMLTemplSet && 333 FRMDIR_HORI_RIGHT_TOP == GetDefaultFrameDirection(GetAppLanguage()) ) 334 pDoc->SetDefault( SvxAdjustItem(SVX_ADJUST_RIGHT, RES_PARATR_ADJUST ) ); 335 336 // OD 09.10.2003 #i18732# - set dynamic pool default for 337 // item RES_FOLLOW_TEXT_FLOW to sal_False for *new document*. 338 // Thus, redo this change in method <SwDoc::RemoveAllFmtLanguageDependencies()>, 339 // which is called from <SwDocShell::ConvertFrom(..)> in order to restore 340 // the static pool default. 341 pDoc->SetDefault( SwFmtFollowTextFlow( sal_False ) ); 342 343 // --> collapsing borders FME 2005-05-27 #i29550# 344 pDoc->SetDefault( SfxBoolItem( RES_COLLAPSING_BORDERS, sal_True ) ); 345 // <-- collapsing 346 347 //#i16874# AutoKerning as default for new documents 348 pDoc->SetDefault( SvxAutoKernItem( sal_True, RES_CHRATR_AUTOKERN ) ); 349 350 pDoc->SetDrawDefaults(); 351 352 // --> OD 2005-02-10 #i42080# - Due to the several calls of method <SetDefault(..)> 353 // at the document instance, the document is modified. Thus, reset this 354 // status here. Note: In method <SubInitNew()> this is also done. 355 pDoc->ResetModified(); 356 // <-- 357 358 return bRet; 359 } 360 361 /*-------------------------------------------------------------------- 362 Beschreibung: Ctor mit SfxCreateMode ????? 363 --------------------------------------------------------------------*/ 364 365 366 SwDocShell::SwDocShell( SfxObjectCreateMode eMode ) : 367 SfxObjectShell ( eMode ), 368 pDoc(0), 369 pFontList(0), 370 pView( 0 ), 371 pWrtShell( 0 ), 372 pOLEChildList( 0 ), 373 nUpdateDocMode(document::UpdateDocMode::ACCORDING_TO_CONFIG), 374 bInUpdateFontList(false) 375 { 376 RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "SwDocShell::SwDocShell" ); 377 Init_Impl(); 378 } 379 380 /*-------------------------------------------------------------------- 381 Beschreibung: Ctor / Dtor 382 --------------------------------------------------------------------*/ 383 384 385 SwDocShell::SwDocShell( const sal_uInt64 i_nSfxCreationFlags ) : 386 SfxObjectShell ( i_nSfxCreationFlags ), 387 pDoc(0), 388 pFontList(0), 389 pView( 0 ), 390 pWrtShell( 0 ), 391 pOLEChildList( 0 ), 392 nUpdateDocMode(document::UpdateDocMode::ACCORDING_TO_CONFIG), 393 bInUpdateFontList(false) 394 { 395 RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "SwDocShell::SwDocShell" ); 396 Init_Impl(); 397 } 398 399 /*-------------------------------------------------------------------- 400 Beschreibung: Ctor / Dtor 401 --------------------------------------------------------------------*/ 402 403 404 SwDocShell::SwDocShell( SwDoc *pD, SfxObjectCreateMode eMode ): 405 SfxObjectShell ( eMode ), 406 pDoc(pD), 407 pFontList(0), 408 pView( 0 ), 409 pWrtShell( 0 ), 410 pOLEChildList( 0 ), 411 nUpdateDocMode(document::UpdateDocMode::ACCORDING_TO_CONFIG), 412 bInUpdateFontList(false) 413 { 414 RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "SwDocShell::SwDocShell" ); 415 Init_Impl(); 416 } 417 418 /*-------------------------------------------------------------------- 419 Beschreibung: Dtor 420 --------------------------------------------------------------------*/ 421 422 423 SwDocShell::~SwDocShell() 424 { 425 // disable chart related objects now because in ~SwDoc it may be to late for this 426 if( pDoc ) 427 { 428 pDoc->GetChartControllerHelper().Disconnect(); 429 SwChartDataProvider *pPCD = pDoc->GetChartDataProvider(); 430 if (pPCD) 431 pPCD->dispose(); 432 } 433 434 RemoveLink(); 435 delete pFontList; 436 437 // wir als BroadCaster werden auch unser eigener Listener 438 // (fuer DocInfo/FileNamen/....) 439 EndListening( *this ); 440 SvxColorTableItem* pColItem = (SvxColorTableItem*)GetItem(SID_COLOR_TABLE); 441 // wird nur die DocInfo fuer den Explorer gelesen, ist das Item nicht da 442 if(pColItem) 443 { 444 XColorTable* pTable = pColItem->GetColorTable(); 445 // wurde eine neue Table angelegt, muss sie auch geloescht werden. 446 if((void*)pTable != (void*)(XColorTable::GetStdColorTable()) ) 447 delete pTable; 448 } 449 450 delete pOLEChildList; 451 } 452 /* -----------------------------10.09.2001 15:59------------------------------ 453 454 ---------------------------------------------------------------------------*/ 455 void SwDocShell::Init_Impl() 456 { 457 SetPool(&SW_MOD()->GetPool()); 458 SetBaseModel(new SwXTextDocument(this)); 459 // wir als BroadCaster werden auch unser eigener Listener 460 // (fuer DocInfo/FileNamen/....) 461 StartListening( *this ); 462 //position of the "Automatic" style filter for the stylist (app.src) 463 SetAutoStyleFilterIndex(3); 464 465 // set map unit to twip 466 SetMapUnit( MAP_TWIP ); 467 } 468 /*-------------------------------------------------------------------- 469 Beschreibung: AddLink 470 --------------------------------------------------------------------*/ 471 472 473 void SwDocShell::AddLink() 474 { 475 if( !pDoc ) 476 { 477 SwDocFac aFactory; 478 pDoc = aFactory.GetDoc(); 479 pDoc->acquire(); 480 pDoc->set(IDocumentSettingAccess::HTML_MODE, ISA(SwWebDocShell) ); 481 } 482 else 483 pDoc->acquire(); 484 pDoc->SetDocShell( this ); // am Doc den DocShell-Pointer setzen 485 uno::Reference< text::XTextDocument > xDoc(GetBaseModel(), uno::UNO_QUERY); 486 ((SwXTextDocument*)xDoc.get())->Reactivate(this); 487 488 SetPool(&pDoc->GetAttrPool()); 489 490 // am besten erst wenn eine sdbcx::View erzeugt wird !!! 491 pDoc->SetOle2Link(LINK(this, SwDocShell, Ole2ModifiedHdl)); 492 } 493 494 /*-------------------------------------------------------------------- 495 Beschreibung: neue FontList erzeugen Aenderung Drucker 496 --------------------------------------------------------------------*/ 497 498 499 void SwDocShell::UpdateFontList() 500 { 501 if(!bInUpdateFontList) 502 { 503 bInUpdateFontList = true; 504 ASSERT(pDoc, "Kein Doc keine FontList"); 505 if( pDoc ) 506 { 507 delete pFontList; 508 pFontList = new FontList( pDoc->getReferenceDevice( true ) ); 509 PutItem( SvxFontListItem( pFontList, SID_ATTR_CHAR_FONTLIST ) ); 510 } 511 bInUpdateFontList = false; 512 } 513 } 514 515 /*-------------------------------------------------------------------- 516 Beschreibung: RemoveLink 517 --------------------------------------------------------------------*/ 518 519 520 void SwDocShell::RemoveLink() 521 { 522 // Uno-Object abklemmen 523 uno::Reference< text::XTextDocument > xDoc(GetBaseModel(), uno::UNO_QUERY); 524 ((SwXTextDocument*)xDoc.get())->Invalidate(); 525 aFinishedTimer.Stop(); 526 if(pDoc) 527 { 528 if( mxBasePool.is() ) 529 { 530 static_cast<SwDocStyleSheetPool*>(mxBasePool.get())->dispose(); 531 mxBasePool.clear(); 532 } 533 sal_Int8 nRefCt = static_cast< sal_Int8 >(pDoc->release()); 534 pDoc->SetOle2Link(Link()); 535 pDoc->SetDocShell( 0 ); 536 if( !nRefCt ) 537 delete pDoc; 538 pDoc = 0; // wir haben das Doc nicht mehr !! 539 } 540 } 541 void SwDocShell::InvalidateModel() 542 { 543 // Uno-Object abklemmen 544 uno::Reference< text::XTextDocument > xDoc(GetBaseModel(), uno::UNO_QUERY); 545 ((SwXTextDocument*)xDoc.get())->Invalidate(); 546 } 547 void SwDocShell::ReactivateModel() 548 { 549 // Uno-Object abklemmen 550 uno::Reference< text::XTextDocument > xDoc(GetBaseModel(), uno::UNO_QUERY); 551 ((SwXTextDocument*)xDoc.get())->Reactivate(this); 552 } 553 554 /*-------------------------------------------------------------------- 555 Beschreibung: Laden, Default-Format 556 --------------------------------------------------------------------*/ 557 558 559 sal_Bool SwDocShell::Load( SfxMedium& rMedium ) 560 { 561 RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "SwDocShell::Load" ); 562 sal_Bool bRet = sal_False; 563 if( SfxObjectShell::Load( rMedium )) 564 { 565 RTL_LOGFILE_CONTEXT_TRACE( aLog, "after SfxInPlaceObject::Load" ); 566 if( pDoc ) // fuer Letzte Version !! 567 RemoveLink(); // das existierende Loslassen 568 569 AddLink(); // Link setzen und Daten updaten !! 570 571 // Das Laden 572 // fuer MD 573 ASSERT( !mxBasePool.is(), "wer hat seinen Pool nicht zerstoert?" ); 574 mxBasePool = new SwDocStyleSheetPool( *pDoc, SFX_CREATE_MODE_ORGANIZER == GetCreateMode() ); 575 if(GetCreateMode() != SFX_CREATE_MODE_ORGANIZER) 576 { 577 SFX_ITEMSET_ARG( rMedium.GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, sal_False); 578 nUpdateDocMode = pUpdateDocItem ? pUpdateDocItem->GetValue() : document::UpdateDocMode::NO_UPDATE; 579 } 580 581 SwWait aWait( *this, sal_True ); 582 sal_uInt32 nErr = ERR_SWG_READ_ERROR; 583 switch( GetCreateMode() ) 584 { 585 // case SFX_CREATE_MODE_INTERNAL: 586 // nErr = 0; 587 // break; 588 589 case SFX_CREATE_MODE_ORGANIZER: 590 { 591 if( ReadXML ) 592 { 593 ReadXML->SetOrganizerMode( sal_True ); 594 SwReader aRdr( rMedium, aEmptyStr, pDoc ); 595 nErr = aRdr.Read( *ReadXML ); 596 ReadXML->SetOrganizerMode( sal_False ); 597 } 598 } 599 break; 600 601 case SFX_CREATE_MODE_INTERNAL: 602 case SFX_CREATE_MODE_EMBEDDED: 603 { 604 // fuer MWERKS (Mac-Compiler): kann nicht selbststaendig casten 605 SwTransferable::InitOle( this, *pDoc ); 606 } 607 // SfxProgress unterdruecken, wenn man Embedded ist 608 SW_MOD()->SetEmbeddedLoadSave( sal_True ); 609 // kein break; 610 611 case SFX_CREATE_MODE_STANDARD: 612 case SFX_CREATE_MODE_PREVIEW: 613 { 614 Reader *pReader = ReadXML; 615 if( pReader ) 616 { 617 // die DocInfo vom Doc am DocShell-Medium setzen 618 RTL_LOGFILE_CONTEXT_TRACE( aLog, "before ReadDocInfo" ); 619 SwReader aRdr( rMedium, aEmptyStr, pDoc ); 620 RTL_LOGFILE_CONTEXT_TRACE( aLog, "before Read" ); 621 nErr = aRdr.Read( *pReader ); 622 RTL_LOGFILE_CONTEXT_TRACE( aLog, "after Read" ); 623 624 // If a XML document is loaded, the global doc/web doc 625 // flags have to be set, because they aren't loaded 626 // by this formats. 627 if( ISA( SwWebDocShell ) ) 628 { 629 if( !pDoc->get(IDocumentSettingAccess::HTML_MODE) ) 630 pDoc->set(IDocumentSettingAccess::HTML_MODE, true); 631 } 632 if( ISA( SwGlobalDocShell ) ) 633 { 634 if( !pDoc->get(IDocumentSettingAccess::GLOBAL_DOCUMENT) ) 635 pDoc->set(IDocumentSettingAccess::GLOBAL_DOCUMENT, true); 636 } 637 } 638 #ifdef DBG_UTIL 639 else 640 ASSERT( !this, "ohne Sw3Reader geht nichts" ); 641 #endif 642 } 643 break; 644 645 default: 646 ASSERT( !this, "Load: new CreateMode?" ); 647 648 } 649 650 UpdateFontList(); 651 InitDraw(); 652 653 SetError( nErr, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); 654 bRet = !IsError( nErr ); 655 656 // --> OD 2006-11-07 #i59688# 657 // // StartFinishedLoading rufen. 658 // if( bRet && !pDoc->IsInLoadAsynchron() && 659 // GetCreateMode() == SFX_CREATE_MODE_STANDARD ) 660 // StartLoadFinishedTimer(); 661 if ( bRet && !pDoc->IsInLoadAsynchron() && 662 GetCreateMode() == SFX_CREATE_MODE_STANDARD ) 663 { 664 LoadingFinished(); 665 } 666 // <-- 667 668 // SfxProgress unterdruecken, wenn man Embedded ist 669 SW_MOD()->SetEmbeddedLoadSave( sal_False ); 670 } 671 672 return bRet; 673 } 674 675 /*-------------------------------------------------------------------- 676 Beschreibung: 677 --------------------------------------------------------------------*/ 678 679 680 sal_Bool SwDocShell::LoadFrom( SfxMedium& rMedium ) 681 { 682 RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "SwDocShell::LoadFrom" ); 683 sal_Bool bRet = sal_False; 684 if( pDoc ) 685 RemoveLink(); 686 687 AddLink(); // Link setzen und Daten updaten !! 688 689 do { // middle check loop 690 sal_uInt32 nErr = ERR_SWG_READ_ERROR; 691 //const String& rNm = pStor->GetName(); 692 String aStreamName; 693 aStreamName = String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("styles.xml")); 694 uno::Reference < container::XNameAccess > xAccess( rMedium.GetStorage(), uno::UNO_QUERY ); 695 if ( xAccess->hasByName( aStreamName ) && rMedium.GetStorage()->isStreamElement( aStreamName ) ) 696 { 697 // Das Laden 698 SwWait aWait( *this, sal_True ); 699 { 700 ASSERT( !mxBasePool.is(), "wer hat seinen Pool nicht zerstoert?" ); 701 mxBasePool = new SwDocStyleSheetPool( *pDoc, SFX_CREATE_MODE_ORGANIZER == GetCreateMode() ); 702 if( ReadXML ) 703 { 704 ReadXML->SetOrganizerMode( sal_True ); 705 SwReader aRdr( rMedium, aEmptyStr, pDoc ); 706 nErr = aRdr.Read( *ReadXML ); 707 ReadXML->SetOrganizerMode( sal_False ); 708 } 709 } 710 } 711 else 712 { 713 DBG_ERROR("Code removed!"); 714 /* 715 //TODO/LATER: looks like some binary stuff?! 716 // sollte es sich um eine 2. Vrolage handeln ?? 717 if( SvStorage::IsStorageFile( rNm ) ) 718 break; 719 720 const SfxFilter* pFltr = SwIoSystem::GetFileFilter( rNm, aEmptyStr ); 721 if( !pFltr || !pFltr->GetUserData().EqualsAscii( FILTER_SWG )) 722 break; 723 724 SfxMedium aMed( rNm, STREAM_STD_READ, sal_False ); 725 if( 0 == ( nErr = aMed.GetInStream()->GetError() ) ) 726 { 727 SwWait aWait( *this, sal_True ); 728 SwReader aRead( aMed, rNm, pDoc ); 729 nErr = aRead.Read( *ReadSwg ); 730 } 731 */ 732 } 733 734 SetError( nErr, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); 735 bRet = !IsError( nErr ); 736 737 } while( sal_False ); 738 739 SfxObjectShell::LoadFrom( rMedium ); 740 pDoc->ResetModified(); 741 return bRet; 742 } 743 744 745 void SwDocShell::SubInitNew() 746 { 747 ASSERT( !mxBasePool.is(), "wer hat seinen Pool nicht zerstoert?" ); 748 mxBasePool = new SwDocStyleSheetPool( *pDoc, SFX_CREATE_MODE_ORGANIZER == GetCreateMode() ); 749 UpdateFontList(); 750 InitDraw(); 751 752 pDoc->setLinkUpdateMode( GLOBALSETTING ); 753 pDoc->setFieldUpdateFlags( AUTOUPD_GLOBALSETTING ); 754 755 sal_Bool bWeb = ISA(SwWebDocShell); 756 757 sal_uInt16 nRange[] = { 758 RES_PARATR_ADJUST, RES_PARATR_ADJUST, 759 RES_CHRATR_COLOR, RES_CHRATR_COLOR, 760 RES_CHRATR_LANGUAGE, RES_CHRATR_LANGUAGE, 761 RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_LANGUAGE, 762 RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_LANGUAGE, 763 0, 0, 0 }; 764 if(!bWeb) 765 { 766 nRange[ (sizeof(nRange)/sizeof(nRange[0])) - 3 ] = RES_PARATR_TABSTOP; 767 nRange[ (sizeof(nRange)/sizeof(nRange[0])) - 2 ] = RES_PARATR_HYPHENZONE; 768 } 769 SfxItemSet aDfltSet( pDoc->GetAttrPool(), nRange ); 770 771 //! get lingu options without loading lingu DLL 772 SvtLinguOptions aLinguOpt; 773 774 SvtLinguConfig().GetOptions( aLinguOpt ); 775 776 sal_Int16 nVal = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN), 777 eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN), 778 eCTL = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX); 779 aDfltSet.Put( SvxLanguageItem( nVal, RES_CHRATR_LANGUAGE ) ); 780 aDfltSet.Put( SvxLanguageItem( eCJK, RES_CHRATR_CJK_LANGUAGE ) ); 781 aDfltSet.Put( SvxLanguageItem( eCTL, RES_CHRATR_CTL_LANGUAGE ) ); 782 783 if(!bWeb) 784 { 785 SvxHyphenZoneItem aHyp( (SvxHyphenZoneItem&) pDoc->GetDefault( 786 RES_PARATR_HYPHENZONE) ); 787 aHyp.GetMinLead() = static_cast< sal_uInt8 >(aLinguOpt.nHyphMinLeading); 788 aHyp.GetMinTrail() = static_cast< sal_uInt8 >(aLinguOpt.nHyphMinTrailing); 789 790 aDfltSet.Put( aHyp ); 791 792 sal_uInt16 nNewPos = static_cast< sal_uInt16 >(SW_MOD()->GetUsrPref(sal_False)->GetDefTab()); 793 if( nNewPos ) 794 aDfltSet.Put( SvxTabStopItem( 1, nNewPos, 795 SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP ) ); 796 } 797 aDfltSet.Put( SvxColorItem( Color( COL_AUTO ), RES_CHRATR_COLOR ) ); 798 799 pDoc->SetDefault( aDfltSet ); 800 801 //default page mode for text grid 802 if(!bWeb) 803 { 804 sal_Bool bSquaredPageMode = SW_MOD()->GetUsrPref(sal_False)->IsSquaredPageMode(); 805 pDoc->SetDefaultPageMode( bSquaredPageMode ); 806 } 807 808 pDoc->ResetModified(); 809 } 810 811 /* 812 * Document Interface Access 813 */ 814 IDocumentDeviceAccess* SwDocShell::getIDocumentDeviceAccess() { return pDoc; } 815 const IDocumentSettingAccess* SwDocShell::getIDocumentSettingAccess() const { return pDoc; } 816 IDocumentChartDataProviderAccess* SwDocShell::getIDocumentChartDataProviderAccess() { return pDoc; } 817