LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/docshell - docsh2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 57 72 79.2 %
Date: 2012-12-27 Functions: 5 8 62.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             : #include "scitems.hxx"
      21             : #include <svx/drawitem.hxx>
      22             : #include <svl/asiancfg.hxx>
      23             : #include <editeng/forbiddencharacterstable.hxx>
      24             : #include <editeng/unolingu.hxx>
      25             : #include <rtl/logfile.hxx>
      26             : 
      27             : #include "drwlayer.hxx"
      28             : #include "stlpool.hxx"
      29             : #include "docsh.hxx"
      30             : #include "docshimp.hxx"
      31             : #include "docfunc.hxx"
      32             : #include "sc.hrc"
      33             : 
      34             : using namespace com::sun::star;
      35             : 
      36             : //------------------------------------------------------------------
      37             : 
      38          49 : sal_Bool ScDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor )
      39             : {
      40             :     RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::InitNew" );
      41             : 
      42          49 :     sal_Bool bRet = SfxObjectShell::InitNew( xStor );
      43             : 
      44          49 :     aDocument.MakeTable(0);
      45             :     //  zusaetzliche Tabellen werden von der ersten View angelegt,
      46             :     //  wenn bIsEmpty dann noch sal_True ist
      47             : 
      48          49 :     if( bRet )
      49             :     {
      50             :         Size aSize( (long) ( STD_COL_WIDTH           * HMM_PER_TWIPS * OLE_STD_CELLS_X ),
      51          49 :                     (long) ( ScGlobal::nStdRowHeight * HMM_PER_TWIPS * OLE_STD_CELLS_Y ) );
      52             :         // hier muss auch der Start angepasst werden
      53          49 :         SetVisAreaOrSize( Rectangle( Point(), aSize ), sal_True );
      54             :     }
      55             : 
      56          49 :     aDocument.SetDrawDefaults();        // drawing layer defaults that are set only in InitNew
      57             : 
      58             :     // InitOptions sets the document languages, must be called before CreateStandardStyles
      59          49 :     InitOptions(false);
      60             : 
      61          49 :     aDocument.GetStyleSheetPool()->CreateStandardStyles();
      62          49 :     aDocument.UpdStlShtPtrsFrmNms();
      63             : 
      64             :     //  SetDocumentModified ist in Load/InitNew nicht mehr erlaubt!
      65             : 
      66          49 :     InitItems();
      67          49 :     CalcOutputFactor();
      68             : 
      69          49 :     return bRet;
      70             : }
      71             : 
      72             : //------------------------------------------------------------------
      73             : 
      74           0 : bool ScDocShell::IsEmpty() const
      75             : {
      76           0 :     return bIsEmpty;
      77             : }
      78             : 
      79             : 
      80          11 : void ScDocShell::SetEmpty(bool bSet)
      81             : {
      82          11 :     bIsEmpty = bSet;
      83          11 : }
      84             : 
      85             : //------------------------------------------------------------------
      86             : 
      87         139 : void ScDocShell::InitItems()
      88             : {
      89             :     // AllItemSet fuer Controller mit benoetigten Items fuellen:
      90             : 
      91             :     //  Druck-Optionen werden beim Drucken und evtl. in GetPrinter gesetzt
      92             : 
      93         139 :     UpdateFontList();
      94             : 
      95         139 :     ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
      96         139 :     if (pDrawLayer)
      97             :     {
      98          59 :         PutItem( SvxColorListItem  ( pDrawLayer->GetColorList(), SID_COLOR_TABLE ) );
      99          59 :         PutItem( SvxGradientListItem( pDrawLayer->GetGradientList(), SID_GRADIENT_LIST ) );
     100          59 :         PutItem( SvxHatchListItem   ( pDrawLayer->GetHatchList(), SID_HATCH_LIST ) );
     101          59 :         PutItem( SvxBitmapListItem  ( pDrawLayer->GetBitmapList(), SID_BITMAP_LIST ) );
     102          59 :         PutItem( SvxDashListItem    ( pDrawLayer->GetDashList(), SID_DASH_LIST ) );
     103          59 :         PutItem( SvxLineEndListItem ( pDrawLayer->GetLineEndList(), SID_LINEEND_LIST ) );
     104             : 
     105             :             //  andere Anpassungen nach dem Anlegen des DrawLayers
     106             : 
     107          59 :         pDrawLayer->SetNotifyUndoActionHdl( LINK( pDocFunc, ScDocFunc, NotifyDrawUndo ) );
     108             : 
     109          59 :         pDrawLayer->UpdateBasic();          // DocShell-Basic in DrawPages setzen
     110             :     }
     111             :     else
     112             :     {
     113             :         //  always use global color table instead of local copy
     114          80 :         PutItem( SvxColorListItem( XColorList::GetStdColorList(), SID_COLOR_TABLE ) );
     115             :     }
     116             : 
     117         141 :     if ( !aDocument.GetForbiddenCharacters().is() ||
     118           2 :             !aDocument.IsValidAsianCompression() || !aDocument.IsValidAsianKerning() )
     119             :     {
     120             :         //  get settings from SvxAsianConfig
     121         138 :         SvxAsianConfig aAsian;
     122             : 
     123         138 :         if ( !aDocument.GetForbiddenCharacters().is() )
     124             :         {
     125             :             // set forbidden characters if necessary
     126         138 :             uno::Sequence<lang::Locale> aLocales = aAsian.GetStartEndCharLocales();
     127         138 :             if (aLocales.getLength())
     128             :             {
     129             :                 rtl::Reference<SvxForbiddenCharactersTable> xForbiddenTable =
     130           0 :                         new SvxForbiddenCharactersTable( comphelper::getComponentContext(aDocument.GetServiceManager()) );
     131             : 
     132           0 :                 const lang::Locale* pLocales = aLocales.getConstArray();
     133           0 :                 for (sal_Int32 i = 0; i < aLocales.getLength(); i++)
     134             :                 {
     135           0 :                     i18n::ForbiddenCharacters aForbidden;
     136           0 :                     aAsian.GetStartEndChars( pLocales[i], aForbidden.beginLine, aForbidden.endLine );
     137           0 :                     LanguageType eLang = LanguageTag(pLocales[i]).getLanguageType();
     138             : 
     139           0 :                     xForbiddenTable->SetForbiddenCharacters( eLang, aForbidden );
     140           0 :                 }
     141             : 
     142           0 :                 aDocument.SetForbiddenCharacters( xForbiddenTable );
     143         138 :             }
     144             :         }
     145             : 
     146         138 :         if ( !aDocument.IsValidAsianCompression() )
     147             :         {
     148             :             // set compression mode from configuration if not already set (e.g. XML import)
     149          49 :             aDocument.SetAsianCompression( sal::static_int_cast<sal_uInt8>( aAsian.GetCharDistanceCompression() ) );
     150             :         }
     151             : 
     152         138 :         if ( !aDocument.IsValidAsianKerning() )
     153             :         {
     154             :             // set asian punctuation kerning from configuration if not already set (e.g. XML import)
     155          49 :             aDocument.SetAsianKerning( !aAsian.IsKerningWesternTextOnly() );    // reversed
     156         138 :         }
     157             :     }
     158         139 : }
     159             : 
     160             : //------------------------------------------------------------------
     161             : 
     162         108 : void ScDocShell::ResetDrawObjectShell()
     163             : {
     164         108 :     ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
     165         108 :     if (pDrawLayer)
     166          33 :         pDrawLayer->SetObjectShell( NULL );
     167         108 : }
     168             : 
     169             : //------------------------------------------------------------------
     170             : 
     171           0 : void ScDocShell::Activate()
     172             : {
     173           0 : }
     174             : 
     175             : 
     176           0 : void ScDocShell::Deactivate()
     177             : {
     178           0 : }
     179             : 
     180             : //------------------------------------------------------------------
     181             : 
     182             : 
     183         100 : ScDrawLayer* ScDocShell::MakeDrawLayer()
     184             : {
     185         100 :     ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
     186         100 :     if (!pDrawLayer)
     187             :     {
     188             :         RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::MakeDrawLayer" );
     189             : 
     190          36 :         aDocument.InitDrawLayer(this);
     191          36 :         pDrawLayer = aDocument.GetDrawLayer();
     192          36 :         InitItems();                                            // incl. Undo und Basic
     193          36 :         Broadcast( SfxSimpleHint( SC_HINT_DRWLAYER_NEW ) );
     194          36 :         if (nDocumentLock)
     195           2 :             pDrawLayer->setLock(true);
     196             :     }
     197         100 :     return pDrawLayer;
     198             : }
     199             : 
     200             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10