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