LCOV - code coverage report
Current view: top level - sw/source/uibase/app - docshini.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 228 290 78.6 %
Date: 2014-11-03 Functions: 19 24 79.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <hintids.hxx>
      21             : 
      22             : #include <svx/dialogs.hrc>
      23             : #include <i18nlangtag/mslangid.hxx>
      24             : #include <sot/storinfo.hxx>
      25             : #include <sot/storage.hxx>
      26             : #include <svl/zforlist.hxx>
      27             : #include <svtools/ctrltool.hxx>
      28             : #include <unotools/lingucfg.hxx>
      29             : #include <sfx2/docfile.hxx>
      30             : #include <sfx2/sfxmodelfactory.hxx>
      31             : #include <sfx2/printer.hxx>
      32             : #include <sfx2/bindings.hxx>
      33             : #include <svl/asiancfg.hxx>
      34             : #include <editeng/unolingu.hxx>
      35             : #include <sfx2/request.hxx>
      36             : #include <svl/intitem.hxx>
      37             : #include <editeng/adjustitem.hxx>
      38             : #include <editeng/autokernitem.hxx>
      39             : #include <linguistic/lngprops.hxx>
      40             : #include <com/sun/star/document/UpdateDocMode.hpp>
      41             : #include <com/sun/star/i18n/ScriptType.hpp>
      42             : #include <sfx2/docfilt.hxx>
      43             : #include <svx/xtable.hxx>
      44             : #include <svx/drawitem.hxx>
      45             : #include <editeng/fhgtitem.hxx>
      46             : #include <editeng/fontitem.hxx>
      47             : #include <editeng/flstitem.hxx>
      48             : #include <editeng/tstpitem.hxx>
      49             : #include <editeng/langitem.hxx>
      50             : #include <editeng/colritem.hxx>
      51             : #include <editeng/hyphenzoneitem.hxx>
      52             : #include <editeng/svxacorr.hxx>
      53             : #include <vcl/svapp.hxx>
      54             : #include <vcl/settings.hxx>
      55             : #include <view.hxx>
      56             : #include <prtopt.hxx>
      57             : #include <fmtcol.hxx>
      58             : #include <docsh.hxx>
      59             : #include <wdocsh.hxx>
      60             : #include <swmodule.hxx>
      61             : #include <doc.hxx>
      62             : #include <IDocumentSettingAccess.hxx>
      63             : #include <IDocumentDeviceAccess.hxx>
      64             : #include <IDocumentDrawModelAccess.hxx>
      65             : #include <IDocumentStylePoolAccess.hxx>
      66             : #include <IDocumentChartDataProviderAccess.hxx>
      67             : #include <IDocumentState.hxx>
      68             : #include <docfac.hxx>
      69             : #include <docstyle.hxx>
      70             : #include <shellio.hxx>
      71             : #include <tox.hxx>
      72             : #include <swdtflvr.hxx>
      73             : #include <dbmgr.hxx>
      74             : #include <usrpref.hxx>
      75             : #include <fontcfg.hxx>
      76             : #include <poolfmt.hxx>
      77             : #include <modcfg.hxx>
      78             : #include <globdoc.hxx>
      79             : #include <ndole.hxx>
      80             : #include <mdiexp.hxx>
      81             : #include <unotxdoc.hxx>
      82             : #include <linkenum.hxx>
      83             : #include <swwait.hxx>
      84             : #include <wrtsh.hxx>
      85             : #include <swerror.h>
      86             : #include <globals.hrc>
      87             : #include <unochart.hxx>
      88             : 
      89             : // text grid
      90             : #include <tgrditem.hxx>
      91             : #include <boost/scoped_ptr.hpp>
      92             : 
      93             : using namespace ::com::sun::star::i18n;
      94             : using namespace ::com::sun::star::lang;
      95             : using namespace ::com::sun::star::uno;
      96             : using namespace ::com::sun::star;
      97             : 
      98             : // Load Document
      99        4736 : bool SwDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor )
     100             : {
     101        4736 :     bool bRet = SfxObjectShell::InitNew( xStor );
     102             :     OSL_ENSURE( GetMapUnit() == MAP_TWIP, "map unit is not twip!" );
     103        4736 :     bool bHTMLTemplSet = false;
     104        4736 :     if( bRet )
     105             :     {
     106        4734 :         AddLink();      // create mpDoc / pIo if applicable
     107             : 
     108        4734 :         bool bWeb = ISA( SwWebDocShell );
     109        4734 :         if ( bWeb )
     110           4 :             bHTMLTemplSet = SetHTMLTemplate( *GetDoc() );// Styles from HTML.vor
     111        4730 :         else if( ISA( SwGlobalDocShell ) )
     112           0 :             GetDoc()->getIDocumentSettingAccess().set(IDocumentSettingAccess::GLOBAL_DOCUMENT, true);       // Globaldokument
     113             : 
     114        4734 :         if ( GetCreateMode() ==  SFX_CREATE_MODE_EMBEDDED )
     115         198 :             SwTransferable::InitOle( this, *mpDoc );
     116             : 
     117             :         // set forbidden characters if necessary
     118        4734 :         SvxAsianConfig aAsian;
     119        9468 :         Sequence<lang::Locale> aLocales =  aAsian.GetStartEndCharLocales();
     120        4734 :         if(aLocales.getLength())
     121             :         {
     122           0 :             const lang::Locale* pLocales = aLocales.getConstArray();
     123           0 :             for(sal_Int32 i = 0; i < aLocales.getLength(); i++)
     124             :             {
     125           0 :                 ForbiddenCharacters aForbidden;
     126           0 :                 aAsian.GetStartEndChars( pLocales[i], aForbidden.beginLine, aForbidden.endLine);
     127           0 :                 LanguageType  eLang = LanguageTag::convertToLanguageType(pLocales[i]);
     128           0 :                 mpDoc->getIDocumentSettingAccess().setForbiddenCharacters( eLang, aForbidden);
     129           0 :             }
     130             :         }
     131        4734 :         mpDoc->getIDocumentSettingAccess().set(IDocumentSettingAccess::KERN_ASIAN_PUNCTUATION,
     132        4734 :                   !aAsian.IsKerningWesternTextOnly());
     133        4734 :         mpDoc->getIDocumentSettingAccess().setCharacterCompressionType(static_cast<SwCharCompressType>(aAsian.GetCharDistanceCompression()));
     134        4734 :         mpDoc->getIDocumentDeviceAccess().setPrintData(*SW_MOD()->GetPrtOptions(bWeb));
     135             : 
     136        4734 :         SubInitNew();
     137             : 
     138             :         // for all
     139             : 
     140        4734 :         SwStdFontConfig* pStdFont = SW_MOD()->GetStdFontConfig();
     141        4734 :         SfxPrinter* pPrt = mpDoc->getIDocumentDeviceAccess().getPrinter( false );
     142             : 
     143        9468 :         OUString sEntry;
     144             :         sal_uInt16 aFontWhich[] =
     145             :         {   RES_CHRATR_FONT,
     146             :             RES_CHRATR_CJK_FONT,
     147             :             RES_CHRATR_CTL_FONT
     148        4734 :         };
     149             :         sal_uInt16 aFontHeightWhich[] =
     150             :         {
     151             :             RES_CHRATR_FONTSIZE,
     152             :             RES_CHRATR_CJK_FONTSIZE,
     153             :             RES_CHRATR_CTL_FONTSIZE
     154        4734 :         };
     155             :         sal_uInt16 aFontIds[] =
     156             :         {
     157             :             FONT_STANDARD,
     158             :             FONT_STANDARD_CJK,
     159             :             FONT_STANDARD_CTL
     160        4734 :         };
     161             :         sal_uInt16 nFontTypes[] =
     162             :         {
     163             :             DEFAULTFONT_LATIN_TEXT,
     164             :             DEFAULTFONT_CJK_TEXT,
     165             :             DEFAULTFONT_CTL_TEXT
     166        4734 :         };
     167             :         sal_uInt16 aLangTypes[] =
     168             :         {
     169             :             RES_CHRATR_LANGUAGE,
     170             :             RES_CHRATR_CJK_LANGUAGE,
     171             :             RES_CHRATR_CTL_LANGUAGE
     172        4734 :         };
     173             : 
     174       18936 :         for(sal_uInt8 i = 0; i < 3; i++)
     175             :         {
     176       14202 :             sal_uInt16 nFontWhich = aFontWhich[i];
     177       14202 :             sal_uInt16 nFontId = aFontIds[i];
     178       14202 :             boost::scoped_ptr<SvxFontItem> pFontItem;
     179       14202 :             const SvxLanguageItem& rLang = (const SvxLanguageItem&)mpDoc->GetDefault( aLangTypes[i] );
     180       14202 :             LanguageType eLanguage = rLang.GetLanguage();
     181       14202 :             if(!pStdFont->IsFontDefault(nFontId))
     182             :             {
     183           0 :                 sEntry = pStdFont->GetFontFor(nFontId);
     184             : 
     185           0 :                 vcl::Font aFont( sEntry, Size( 0, 10 ) );
     186           0 :                 if( pPrt )
     187             :                 {
     188           0 :                     aFont = pPrt->GetFontMetric( aFont );
     189             :                 }
     190             : 
     191             :                 pFontItem.reset(new SvxFontItem(aFont.GetFamily(), aFont.GetName(),
     192           0 :                                                 aEmptyOUStr, aFont.GetPitch(), aFont.GetCharSet(), nFontWhich));
     193             :             }
     194             :             else
     195             :             {
     196             :                 // #107782# OJ use korean language if latin was used
     197       14202 :                 if ( i == 0 )
     198             :                 {
     199        4734 :                         LanguageType eUiLanguage = Application::GetSettings().GetUILanguageTag().getLanguageType();
     200        4734 :                     if (MsLangId::isKorean(eUiLanguage))
     201           0 :                         eLanguage = eUiLanguage;
     202             :                 }
     203             : 
     204             :                 vcl::Font aLangDefFont = OutputDevice::GetDefaultFont(
     205       14202 :                     nFontTypes[i],
     206             :                     eLanguage,
     207       28404 :                     DEFAULTFONT_FLAGS_ONLYONE );
     208             :                 pFontItem.reset(new SvxFontItem(aLangDefFont.GetFamily(), aLangDefFont.GetName(),
     209       14202 :                                                 aEmptyOUStr, aLangDefFont.GetPitch(), aLangDefFont.GetCharSet(), nFontWhich));
     210             :             }
     211       14202 :             mpDoc->SetDefault(*pFontItem);
     212       14202 :             if( !bHTMLTemplSet )
     213             :             {
     214       14190 :                 SwTxtFmtColl *pColl = mpDoc->getIDocumentStylePoolAccess().GetTxtCollFromPool(RES_POOLCOLL_STANDARD);
     215       14190 :                 pColl->ResetFmtAttr(nFontWhich);
     216             :             }
     217       14202 :             pFontItem.reset();
     218       14202 :             sal_Int32 nFontHeight = pStdFont->GetFontHeight( FONT_STANDARD, i, eLanguage );
     219       14202 :             if(nFontHeight <= 0)
     220           0 :                 nFontHeight = SwStdFontConfig::GetDefaultHeightFor( nFontId, eLanguage );
     221       14202 :             mpDoc->SetDefault(SvxFontHeightItem( nFontHeight, 100, aFontHeightWhich[i] ));
     222       14202 :             if( !bHTMLTemplSet )
     223             :             {
     224       14190 :                 SwTxtFmtColl *pColl = mpDoc->getIDocumentStylePoolAccess().GetTxtCollFromPool(RES_POOLCOLL_STANDARD);
     225       14190 :                 pColl->ResetFmtAttr(aFontHeightWhich[i]);
     226             :             }
     227             : 
     228       14202 :         }
     229             :         sal_uInt16 aFontIdPoolId[] =
     230             :         {
     231             :             FONT_OUTLINE,       RES_POOLCOLL_HEADLINE_BASE,
     232             :             FONT_LIST,          RES_POOLCOLL_NUMBUL_BASE,
     233             :             FONT_CAPTION,       RES_POOLCOLL_LABEL,
     234             :             FONT_INDEX,         RES_POOLCOLL_REGISTER_BASE,
     235             :             FONT_OUTLINE_CJK,   RES_POOLCOLL_HEADLINE_BASE,
     236             :             FONT_LIST_CJK,      RES_POOLCOLL_NUMBUL_BASE,
     237             :             FONT_CAPTION_CJK,   RES_POOLCOLL_LABEL,
     238             :             FONT_INDEX_CJK,     RES_POOLCOLL_REGISTER_BASE,
     239             :             FONT_OUTLINE_CTL,   RES_POOLCOLL_HEADLINE_BASE,
     240             :             FONT_LIST_CTL,      RES_POOLCOLL_NUMBUL_BASE,
     241             :             FONT_CAPTION_CTL,   RES_POOLCOLL_LABEL,
     242             :             FONT_INDEX_CTL,     RES_POOLCOLL_REGISTER_BASE
     243        4734 :         };
     244             : 
     245        4734 :         sal_uInt16 nFontWhich = RES_CHRATR_FONT;
     246        4734 :         sal_uInt16 nFontHeightWhich = RES_CHRATR_FONTSIZE;
     247        4734 :         LanguageType eLanguage = static_cast<const SvxLanguageItem&>(mpDoc->GetDefault( RES_CHRATR_LANGUAGE )).GetLanguage();
     248       61542 :         for(sal_uInt8 nIdx = 0; nIdx < 24; nIdx += 2)
     249             :         {
     250       56808 :             if(nIdx == 8)
     251             :             {
     252        4734 :                 nFontWhich = RES_CHRATR_CJK_FONT;
     253        4734 :                 nFontHeightWhich = RES_CHRATR_CJK_FONTSIZE;
     254        4734 :                 eLanguage = static_cast<const SvxLanguageItem&>(mpDoc->GetDefault( RES_CHRATR_CJK_LANGUAGE )).GetLanguage();
     255             :             }
     256       52074 :             else if(nIdx == 16)
     257             :             {
     258        4734 :                 nFontWhich = RES_CHRATR_CTL_FONT;
     259        4734 :                 nFontHeightWhich = RES_CHRATR_CTL_FONTSIZE;
     260        4734 :                 eLanguage = static_cast<const SvxLanguageItem&>(mpDoc->GetDefault( RES_CHRATR_CTL_LANGUAGE )).GetLanguage();
     261             :             }
     262       56808 :             SwTxtFmtColl *pColl = 0;
     263       56808 :             if(!pStdFont->IsFontDefault(aFontIdPoolId[nIdx]))
     264             :             {
     265           0 :                 sEntry = pStdFont->GetFontFor(aFontIdPoolId[nIdx]);
     266             : 
     267           0 :                 vcl::Font aFont( sEntry, Size( 0, 10 ) );
     268           0 :                 if( pPrt )
     269           0 :                     aFont = pPrt->GetFontMetric( aFont );
     270             : 
     271           0 :                 pColl = mpDoc->getIDocumentStylePoolAccess().GetTxtCollFromPool(aFontIdPoolId[nIdx + 1]);
     272           0 :                 if( !bHTMLTemplSet ||
     273           0 :                     SfxItemState::SET != pColl->GetAttrSet().GetItemState(
     274           0 :                                                     nFontWhich, false ) )
     275             :                 {
     276           0 :                     pColl->SetFmtAttr(SvxFontItem(aFont.GetFamily(), aFont.GetName(),
     277           0 :                                                   aEmptyOUStr, aFont.GetPitch(), aFont.GetCharSet(), nFontWhich));
     278           0 :                 }
     279             :             }
     280       56808 :             sal_Int32 nFontHeight = pStdFont->GetFontHeight( static_cast< sal_Int8 >(aFontIdPoolId[nIdx]), 0, eLanguage );
     281       56808 :             if(nFontHeight <= 0)
     282           0 :                 nFontHeight = SwStdFontConfig::GetDefaultHeightFor( aFontIdPoolId[nIdx], eLanguage );
     283       56808 :             if(!pColl)
     284       56808 :                 pColl = mpDoc->getIDocumentStylePoolAccess().GetTxtCollFromPool(aFontIdPoolId[nIdx + 1]);
     285       56808 :             SvxFontHeightItem aFontHeight( (const SvxFontHeightItem&)pColl->GetFmtAttr( nFontHeightWhich, true ));
     286       56808 :             if(aFontHeight.GetHeight() != sal::static_int_cast<sal_uInt32, sal_Int32>(nFontHeight))
     287             :             {
     288       23658 :                 aFontHeight.SetHeight(nFontHeight);
     289       23658 :                 pColl->SetFmtAttr( aFontHeight );
     290             :             }
     291       56808 :         }
     292             : 
     293             :         // the default for documents created via 'File/New' should be 'on'
     294             :         // (old documents, where this property was not yet implemented, will get the
     295             :         // value 'false' in the SwDoc c-tor)
     296        4734 :         mpDoc->getIDocumentSettingAccess().set( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT,
     297        9468 :                 SW_MOD()->GetUsrPref( bWeb )->IsAlignMathObjectsToBaseline() );
     298             :     }
     299             : 
     300             :     /* #106748# If the default frame direction of a document is RTL
     301             :         the default adjusment is to the right. */
     302        9468 :     if( !bHTMLTemplSet &&
     303        4732 :         FRMDIR_HORI_RIGHT_TOP == GetDefaultFrameDirection(GetAppLanguage()) )
     304           0 :         mpDoc->SetDefault( SvxAdjustItem(SVX_ADJUST_RIGHT, RES_PARATR_ADJUST ) );
     305             : 
     306             : // #i29550#
     307        4736 :     mpDoc->SetDefault( SfxBoolItem( RES_COLLAPSING_BORDERS, true ) );
     308             : // <-- collapsing
     309             : 
     310             :     //#i16874# AutoKerning as default for new documents
     311        4736 :     mpDoc->SetDefault( SvxAutoKernItem( true, RES_CHRATR_AUTOKERN ) );
     312             : 
     313             :     // #i42080# - Due to the several calls of method <SetDefault(..)>
     314             :     // at the document instance, the document is modified. Thus, reset this
     315             :     // status here. Note: In method <SubInitNew()> this is also done.
     316        4736 :     mpDoc->getIDocumentState().ResetModified();
     317             : 
     318        4736 :     return bRet;
     319             : }
     320             : 
     321             : // Ctor with SfxCreateMode ?????
     322         298 : SwDocShell::SwDocShell( SfxObjectCreateMode eMode ) :
     323             :     SfxObjectShell ( eMode ),
     324             :     mpDoc(0),
     325             :     mpFontList(0),
     326             :     mbInUpdateFontList(false),
     327             :     mpView( 0 ),
     328             :     mpWrtShell( 0 ),
     329             :     mpOLEChildList( 0 ),
     330             :     mnUpdateDocMode(document::UpdateDocMode::ACCORDING_TO_CONFIG),
     331         298 :     bIsATemplate(false)
     332             : {
     333         298 :     Init_Impl();
     334         298 : }
     335             : 
     336             : // Ctor / Dtor
     337        4696 : SwDocShell::SwDocShell( const sal_uInt64 i_nSfxCreationFlags ) :
     338             :     SfxObjectShell ( i_nSfxCreationFlags ),
     339             :     mpDoc(0),
     340             :     mpFontList(0),
     341             :     mbInUpdateFontList(false),
     342             :     mpView( 0 ),
     343             :     mpWrtShell( 0 ),
     344             :     mpOLEChildList( 0 ),
     345             :     mnUpdateDocMode(document::UpdateDocMode::ACCORDING_TO_CONFIG),
     346        4696 :     bIsATemplate(false)
     347             : {
     348        4696 :     Init_Impl();
     349        4696 : }
     350             : 
     351             : // Ctor / Dtor
     352          62 : SwDocShell::SwDocShell( SwDoc *pD, SfxObjectCreateMode eMode ):
     353             :     SfxObjectShell ( eMode ),
     354             :     mpDoc(pD),
     355             :     mpFontList(0),
     356             :     mbInUpdateFontList(false),
     357             :     mpView( 0 ),
     358             :     mpWrtShell( 0 ),
     359             :     mpOLEChildList( 0 ),
     360             :     mnUpdateDocMode(document::UpdateDocMode::ACCORDING_TO_CONFIG),
     361          62 :     bIsATemplate(false)
     362             : {
     363          62 :     Init_Impl();
     364          62 : }
     365             : 
     366             : // Dtor
     367       15142 : SwDocShell::~SwDocShell()
     368             : {
     369             :     // disable chart related objects now because in ~SwDoc it may be to late for this
     370        5049 :     if( mpDoc )
     371             :     {
     372        5041 :         mpDoc->getIDocumentChartDataProviderAccess().GetChartControllerHelper().Disconnect();
     373        5041 :         SwChartDataProvider *pPCD = mpDoc->getIDocumentChartDataProviderAccess().GetChartDataProvider();
     374        5041 :         if (pPCD)
     375           6 :             pPCD->dispose();
     376             :     }
     377             : 
     378        5049 :     RemoveLink();
     379        5049 :     delete mpFontList;
     380             : 
     381             :     // we, as BroadCaster also become our own Listener
     382             :     // (for DocInfo/FileNames/....)
     383        5049 :     EndListening( *this );
     384             : 
     385        5049 :     delete mpOLEChildList;
     386       10093 : }
     387             : 
     388        5056 : void  SwDocShell::Init_Impl()
     389             : {
     390        5056 :     SetPool(&SW_MOD()->GetPool());
     391        5056 :     SetBaseModel(new SwXTextDocument(this));
     392             :     // we, as BroadCaster also become our own Listener
     393             :     // (for DocInfo/FileNames/....)
     394        5056 :     StartListening( *this );
     395             :     //position of the "Automatic" style filter for the stylist (app.src)
     396        5056 :     SetAutoStyleFilterIndex(3);
     397             : 
     398             :     // set map unit to twip
     399        5056 :     SetMapUnit( MAP_TWIP );
     400        5056 : }
     401             : 
     402        5044 : void SwDocShell::AddLink()
     403             : {
     404        5044 :     if( !mpDoc )
     405             :     {
     406        4984 :         SwDocFac aFactory;
     407        4984 :         mpDoc = aFactory.GetDoc();
     408        4984 :         mpDoc->acquire();
     409        4984 :         mpDoc->getIDocumentSettingAccess().set(IDocumentSettingAccess::HTML_MODE, ISA(SwWebDocShell) );
     410             :     }
     411             :     else
     412          60 :         mpDoc->acquire();
     413        5044 :     mpDoc->SetDocShell( this );      // set the DocShell-Pointer for Doc
     414        5044 :     uno::Reference< text::XTextDocument >  xDoc(GetBaseModel(), uno::UNO_QUERY);
     415        5044 :     ((SwXTextDocument*)xDoc.get())->Reactivate(this);
     416             : 
     417        5044 :     SetPool(&mpDoc->GetAttrPool());
     418             : 
     419             :     // most suitably not until a sdbcx::View is created!!!
     420        5044 :     mpDoc->SetOle2Link(LINK(this, SwDocShell, Ole2ModifiedHdl));
     421        5044 : }
     422             : 
     423             : // create new FontList Change Printer
     424        5304 : void SwDocShell::UpdateFontList()
     425             : {
     426        5304 :     if(!mbInUpdateFontList)
     427             :     {
     428        5294 :         mbInUpdateFontList = true;
     429             :         OSL_ENSURE(mpDoc, "No Doc no FontList");
     430        5294 :         if( mpDoc )
     431             :         {
     432        5294 :             delete mpFontList;
     433        5294 :             mpFontList = new FontList( mpDoc->getIDocumentDeviceAccess().getReferenceDevice( true ) );
     434        5294 :             PutItem( SvxFontListItem( mpFontList, SID_ATTR_CHAR_FONTLIST ) );
     435             :         }
     436        5294 :         mbInUpdateFontList = false;
     437             :     }
     438        5304 : }
     439             : 
     440        5049 : void SwDocShell::RemoveLink()
     441             : {
     442             :     // disconnect Uno-Object
     443        5049 :     uno::Reference< text::XTextDocument >  xDoc(GetBaseModel(), uno::UNO_QUERY);
     444        5049 :     ((SwXTextDocument*)xDoc.get())->Invalidate();
     445        5049 :     aFinishedTimer.Stop();
     446        5049 :     if (mpDoc)
     447             :     {
     448        5041 :         if( mxBasePool.is() )
     449             :         {
     450        5041 :             static_cast<SwDocStyleSheetPool*>(mxBasePool.get())->dispose();
     451        5041 :             mxBasePool.clear();
     452             :         }
     453        5041 :         sal_Int8 nRefCt = static_cast< sal_Int8 >(mpDoc->release());
     454        5041 :         mpDoc->SetOle2Link(Link());
     455        5041 :         mpDoc->SetDocShell( 0 );
     456        5041 :         if( !nRefCt )
     457        4915 :             delete mpDoc;
     458        5041 :         mpDoc = 0;       // we don't have the Doc anymore!!
     459        5049 :     }
     460        5049 : }
     461          22 : void SwDocShell::InvalidateModel()
     462             : {
     463             :     // disconnect Uno-Object
     464          22 :     uno::Reference< text::XTextDocument >  xDoc(GetBaseModel(), uno::UNO_QUERY);
     465          22 :     ((SwXTextDocument*)xDoc.get())->Invalidate();
     466          22 : }
     467          22 : void SwDocShell::ReactivateModel()
     468             : {
     469             :     // disconnect Uno-Object
     470          22 :     uno::Reference< text::XTextDocument >  xDoc(GetBaseModel(), uno::UNO_QUERY);
     471          22 :     ((SwXTextDocument*)xDoc.get())->Reactivate(this);
     472          22 : }
     473             : 
     474             : // Load, Default-Format
     475         310 : bool  SwDocShell::Load( SfxMedium& rMedium )
     476             : {
     477         310 :     bool bRet = false;
     478         310 :     if( SfxObjectShell::Load( rMedium ))
     479             :     {
     480             :         SAL_INFO( "sw.ui", "after SfxInPlaceObject::Load" );
     481         310 :         if (mpDoc)              // for last version!!
     482           0 :             RemoveLink();       // release the existing
     483             : 
     484         310 :         AddLink();      // set Link and update Data!!
     485             : 
     486             :         // Loading
     487             :         // for MD
     488             :         OSL_ENSURE( !mxBasePool.is(), "who hasn't destroyed their Pool?" );
     489         310 :         mxBasePool = new SwDocStyleSheetPool( *mpDoc, SFX_CREATE_MODE_ORGANIZER == GetCreateMode() );
     490         310 :         if(GetCreateMode() != SFX_CREATE_MODE_ORGANIZER)
     491             :         {
     492         310 :             SFX_ITEMSET_ARG( rMedium.GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, false);
     493         310 :             mnUpdateDocMode = pUpdateDocItem ? pUpdateDocItem->GetValue() : document::UpdateDocMode::NO_UPDATE;
     494             :         }
     495             : 
     496         310 :         SwWait aWait( *this, true );
     497         310 :         sal_uInt32 nErr = ERR_SWG_READ_ERROR;
     498         310 :         switch( GetCreateMode() )
     499             :         {
     500             :             case SFX_CREATE_MODE_ORGANIZER:
     501             :                 {
     502           0 :                     if( ReadXML )
     503             :                     {
     504           0 :                         ReadXML->SetOrganizerMode( true );
     505           0 :                         SwReader aRdr( rMedium, aEmptyOUStr, mpDoc );
     506           0 :                         nErr = aRdr.Read( *ReadXML );
     507           0 :                         ReadXML->SetOrganizerMode( false );
     508             :                     }
     509             :                 }
     510           0 :                 break;
     511             : 
     512             :             case SFX_CREATE_MODE_INTERNAL:
     513             :             case SFX_CREATE_MODE_EMBEDDED:
     514             :                 {
     515          14 :                     SwTransferable::InitOle( this, *mpDoc );
     516             :                 }
     517             :                 // suppress SfxProgress, when we are Embedded
     518          14 :                 SW_MOD()->SetEmbeddedLoadSave( true );
     519             :                 // no break;
     520             : 
     521             :             case SFX_CREATE_MODE_STANDARD:
     522             :             case SFX_CREATE_MODE_PREVIEW:
     523             :                 {
     524         310 :                     Reader *pReader = ReadXML;
     525         310 :                     if( pReader )
     526             :                     {
     527             :                         // set Doc's DocInfo at DocShell-Medium
     528             :                         SAL_INFO( "sw.ui", "before ReadDocInfo" );
     529         310 :                         SwReader aRdr( rMedium, aEmptyOUStr, mpDoc );
     530             :                         SAL_INFO( "sw.ui", "before Read" );
     531         310 :                         nErr = aRdr.Read( *pReader );
     532             :                         SAL_INFO( "sw.ui", "after Read" );
     533             :                         // If a XML document is loaded, the global doc/web doc
     534             :                         // flags have to be set, because they aren't loaded
     535             :                         // by this formats.
     536         310 :                         if( ISA( SwWebDocShell ) )
     537             :                         {
     538           0 :                             if( !mpDoc->getIDocumentSettingAccess().get(IDocumentSettingAccess::HTML_MODE) )
     539           0 :                                 mpDoc->getIDocumentSettingAccess().set(IDocumentSettingAccess::HTML_MODE, true);
     540             :                         }
     541         310 :                         if( ISA( SwGlobalDocShell ) )
     542             :                         {
     543           0 :                             if( !mpDoc->getIDocumentSettingAccess().get(IDocumentSettingAccess::GLOBAL_DOCUMENT) )
     544           0 :                                 mpDoc->getIDocumentSettingAccess().set(IDocumentSettingAccess::GLOBAL_DOCUMENT, true);
     545         310 :                         }
     546             :                     }
     547             :                 }
     548         310 :                 break;
     549             : 
     550             :             default:
     551             :                 OSL_ENSURE( false, "Load: new CreateMode?" );
     552             :         }
     553             : 
     554         310 :         UpdateFontList();
     555         310 :         InitDrawModelAndDocShell(this, mpDoc ? mpDoc->getIDocumentDrawModelAccess().GetDrawModel() : 0);
     556             : 
     557         310 :         SetError( nErr, OUString( OSL_LOG_PREFIX ) );
     558         310 :         bRet = !IsError( nErr );
     559             : 
     560         620 :         if ( bRet && !mpDoc->IsInLoadAsynchron() &&
     561         310 :              GetCreateMode() == SFX_CREATE_MODE_STANDARD )
     562             :         {
     563         296 :             LoadingFinished();
     564             :         }
     565             : 
     566             :         // suppress SfxProgress, when we are Embedded
     567         310 :         SW_MOD()->SetEmbeddedLoadSave( false );
     568             :     }
     569             : 
     570         310 :     return bRet;
     571             : }
     572             : 
     573           0 : bool  SwDocShell::LoadFrom( SfxMedium& rMedium )
     574             : {
     575           0 :     bool bRet = false;
     576           0 :     if( mpDoc )
     577           0 :         RemoveLink();
     578             : 
     579           0 :     AddLink();      // set Link and update Data!!
     580             : 
     581             :     do {        // middle check loop
     582           0 :         sal_uInt32 nErr = ERR_SWG_READ_ERROR;
     583           0 :         OUString aStreamName = "styles.xml";
     584           0 :         uno::Reference < container::XNameAccess > xAccess( rMedium.GetStorage(), uno::UNO_QUERY );
     585           0 :         if ( xAccess->hasByName( aStreamName ) && rMedium.GetStorage()->isStreamElement( aStreamName ) )
     586             :         {
     587             :             // Loading
     588           0 :             SwWait aWait( *this, true );
     589             :             {
     590             :                 OSL_ENSURE( !mxBasePool.is(), "who hasn't destroyed their Pool?" );
     591           0 :                 mxBasePool = new SwDocStyleSheetPool( *mpDoc, SFX_CREATE_MODE_ORGANIZER == GetCreateMode() );
     592           0 :                 if( ReadXML )
     593             :                 {
     594           0 :                     ReadXML->SetOrganizerMode( true );
     595           0 :                     SwReader aRdr( rMedium, aEmptyOUStr, mpDoc );
     596           0 :                     nErr = aRdr.Read( *ReadXML );
     597           0 :                     ReadXML->SetOrganizerMode( false );
     598             :                 }
     599           0 :             }
     600             :         }
     601             :         else
     602             :         {
     603             :             OSL_FAIL("Code removed!");
     604             :         }
     605             : 
     606           0 :         SetError( nErr, OUString( OSL_LOG_PREFIX ) );
     607           0 :         bRet = !IsError( nErr );
     608             : 
     609             :     } while( false );
     610             : 
     611           0 :     SfxObjectShell::LoadFrom( rMedium );
     612           0 :     mpDoc->getIDocumentState().ResetModified();
     613           0 :     return bRet;
     614             : }
     615             : 
     616        4734 : void SwDocShell::SubInitNew()
     617             : {
     618             :     OSL_ENSURE( !mxBasePool.is(), "who hasn't destroyed their Pool?" );
     619        4734 :     mxBasePool = new SwDocStyleSheetPool( *mpDoc, SFX_CREATE_MODE_ORGANIZER == GetCreateMode() );
     620        4734 :     UpdateFontList();
     621        4734 :     InitDrawModelAndDocShell(this, mpDoc ? mpDoc->getIDocumentDrawModelAccess().GetDrawModel() : 0);
     622             : 
     623        4734 :     mpDoc->getIDocumentSettingAccess().setLinkUpdateMode( GLOBALSETTING );
     624        4734 :     mpDoc->getIDocumentSettingAccess().setFieldUpdateFlags( AUTOUPD_GLOBALSETTING );
     625             : 
     626        4734 :     bool bWeb = ISA(SwWebDocShell);
     627             : 
     628             :     sal_uInt16 nRange[] =   {
     629             :         RES_PARATR_ADJUST, RES_PARATR_ADJUST,
     630             :         RES_CHRATR_COLOR, RES_CHRATR_COLOR,
     631             :         RES_CHRATR_LANGUAGE, RES_CHRATR_LANGUAGE,
     632             :         RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_LANGUAGE,
     633             :         RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_LANGUAGE,
     634        4734 :         0, 0, 0  };
     635        4734 :     if(!bWeb)
     636             :     {
     637        4730 :         nRange[ (sizeof(nRange)/sizeof(nRange[0])) - 3 ] = RES_PARATR_TABSTOP;
     638        4730 :         nRange[ (sizeof(nRange)/sizeof(nRange[0])) - 2 ] = RES_PARATR_HYPHENZONE;
     639             :     }
     640        4734 :     SfxItemSet aDfltSet( mpDoc->GetAttrPool(), nRange );
     641             : 
     642             :     //! get lingu options without loading lingu DLL
     643        9468 :     SvtLinguOptions aLinguOpt;
     644             : 
     645        4734 :     SvtLinguConfig().GetOptions( aLinguOpt );
     646             : 
     647        4734 :     sal_Int16   nVal = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN),
     648        4734 :                 eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN),
     649        4734 :                 eCTL = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX);
     650        4734 :     aDfltSet.Put( SvxLanguageItem( nVal, RES_CHRATR_LANGUAGE ) );
     651        4734 :     aDfltSet.Put( SvxLanguageItem( eCJK, RES_CHRATR_CJK_LANGUAGE ) );
     652        4734 :     aDfltSet.Put( SvxLanguageItem( eCTL, RES_CHRATR_CTL_LANGUAGE ) );
     653             : 
     654        4734 :     if(!bWeb)
     655             :     {
     656             :         SvxHyphenZoneItem aHyp( (SvxHyphenZoneItem&) mpDoc->GetDefault(
     657        4730 :                                                         RES_PARATR_HYPHENZONE) );
     658        4730 :         aHyp.GetMinLead()   = static_cast< sal_uInt8 >(aLinguOpt.nHyphMinLeading);
     659        4730 :         aHyp.GetMinTrail()  = static_cast< sal_uInt8 >(aLinguOpt.nHyphMinTrailing);
     660             : 
     661        4730 :         aDfltSet.Put( aHyp );
     662             : 
     663        4730 :         sal_uInt16 nNewPos = static_cast< sal_uInt16 >(SW_MOD()->GetUsrPref(false)->GetDefTab());
     664        4730 :         if( nNewPos )
     665             :             aDfltSet.Put( SvxTabStopItem( 1, nNewPos,
     666        4730 :                                           SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP ) );
     667             :     }
     668        4734 :     aDfltSet.Put( SvxColorItem( Color( COL_AUTO ), RES_CHRATR_COLOR ) );
     669             : 
     670        4734 :     mpDoc->SetDefault( aDfltSet );
     671             : 
     672             :     //default page mode for text grid
     673        4734 :     if(!bWeb)
     674             :     {
     675        4730 :         bool bSquaredPageMode = SW_MOD()->GetUsrPref(false)->IsSquaredPageMode();
     676        4730 :         mpDoc->SetDefaultPageMode( bSquaredPageMode );
     677             :     }
     678             : 
     679        9468 :     mpDoc->getIDocumentState().ResetModified();
     680        4734 : }
     681             : 
     682             : /*
     683             :  * Document Interface Access
     684             :  */
     685           0 : IDocumentDeviceAccess* SwDocShell::getIDocumentDeviceAccess() { return &mpDoc->getIDocumentDeviceAccess(); }
     686        1685 : const IDocumentSettingAccess* SwDocShell::getIDocumentSettingAccess() const { return &mpDoc->getIDocumentSettingAccess(); }
     687         270 : IDocumentChartDataProviderAccess* SwDocShell::getIDocumentChartDataProviderAccess() { return &mpDoc->getIDocumentChartDataProviderAccess(); }
     688             : 
     689             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10