LCOV - code coverage report
Current view: top level - libreoffice/sc/source/core/data - poolhelp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 49 49 100.0 %
Date: 2012-12-17 Functions: 9 9 100.0 %
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 <svl/zforlist.hxx>
      21             : #include <editeng/editeng.hxx>
      22             : 
      23             : #include "poolhelp.hxx"
      24             : #include "document.hxx"
      25             : #include "docpool.hxx"
      26             : #include "stlpool.hxx"
      27             : 
      28             : // -----------------------------------------------------------------------
      29             : 
      30         586 : ScPoolHelper::ScPoolHelper( ScDocument* pSourceDoc )
      31             : :pFormTable(NULL)
      32             : ,pEditPool(NULL)
      33             : ,pEnginePool(NULL)
      34         586 : ,m_pSourceDoc(pSourceDoc)
      35             : {
      36             :     OSL_ENSURE( pSourceDoc, "ScPoolHelper: no document" );
      37         586 :     pDocPool = new ScDocumentPool;
      38         586 :     pDocPool->FreezeIdRanges();
      39             : 
      40         586 :     mxStylePool = new ScStyleSheetPool( *pDocPool, pSourceDoc );
      41         586 : }
      42             : 
      43        1260 : ScPoolHelper::~ScPoolHelper()
      44             : {
      45         420 :     SfxItemPool::Free(pEnginePool);
      46         420 :     SfxItemPool::Free(pEditPool);
      47         420 :     delete pFormTable;
      48         420 :     mxStylePool.clear();
      49         420 :     SfxItemPool::Free(pDocPool);
      50         840 : }
      51         381 : SfxItemPool*        ScPoolHelper::GetEditPool() const
      52             : {
      53         381 :     if ( !pEditPool )
      54             :     {
      55          54 :         pEditPool = EditEngine::CreatePool();
      56          54 :         pEditPool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
      57          54 :         pEditPool->FreezeIdRanges();
      58          54 :         pEditPool->SetFileFormatVersion( SOFFICE_FILEFORMAT_50 );   // used in ScGlobal::EETextObjEqual
      59             :     }
      60         381 :     return pEditPool;
      61             : }
      62         111 : SfxItemPool*        ScPoolHelper::GetEnginePool() const
      63             : {
      64         111 :     if ( !pEnginePool )
      65             :     {
      66          48 :         pEnginePool = EditEngine::CreatePool();
      67          48 :         pEnginePool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
      68          48 :         pEnginePool->FreezeIdRanges();
      69             :     } // ifg ( pEnginePool )
      70         111 :     return pEnginePool;
      71             : }
      72       61092 : SvNumberFormatter*  ScPoolHelper::GetFormTable() const
      73             : {
      74       61092 :     if ( !pFormTable )
      75             :     {
      76         238 :         pFormTable = new SvNumberFormatter( m_pSourceDoc->GetServiceManager(), ScGlobal::eLnge );
      77         238 :         pFormTable->SetColorLink( LINK( m_pSourceDoc, ScDocument, GetUserDefinedColor ) );
      78         238 :         pFormTable->SetEvalDateFormat( NF_EVALDATEFORMAT_INTL_FORMAT );
      79             : 
      80         238 :         UseDocOptions();        // null date, year2000, std precision
      81             :     }
      82       61092 :     return pFormTable;
      83             : }
      84             : 
      85        1226 : void ScPoolHelper::UseDocOptions() const
      86             : {
      87        1226 :     if (pFormTable)
      88             :     {
      89             :         sal_uInt16 d,m,y;
      90        1054 :         aOpt.GetDate( d,m,y );
      91        1054 :         pFormTable->ChangeNullDate( d,m,y );
      92        1054 :         pFormTable->ChangeStandardPrec( (sal_uInt16)aOpt.GetStdPrecision() );
      93        1054 :         pFormTable->SetYear2000( aOpt.GetYear2000() );
      94             :     }
      95        1226 : }
      96             : 
      97         988 : void ScPoolHelper::SetFormTableOpt(const ScDocOptions& rOpt)
      98             : {
      99         988 :     aOpt = rOpt;
     100         988 :     UseDocOptions();        // #i105512# if the number formatter exists, update its settings
     101         988 : }
     102             : 
     103         504 : void ScPoolHelper::SourceDocumentGone()
     104             : {
     105             :     //  reset all pointers to the source document
     106         504 :     mxStylePool->SetDocument( NULL );
     107         504 :     if ( pFormTable )
     108         228 :         pFormTable->SetColorLink( Link() );
     109         504 : }
     110             : 
     111             : // -----------------------------------------------------------------------
     112             : 
     113             : 
     114             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10