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

Generated by: LCOV version 1.10