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

Generated by: LCOV version 1.10