LCOV - code coverage report
Current view: top level - sc/source/core/data - poolhelp.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 57 57 100.0 %
Date: 2014-04-11 Functions: 10 10 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         970 : ScPoolHelper::ScPoolHelper( ScDocument* pSourceDoc )
      29             : :pFormTable(NULL)
      30             : ,pEditPool(NULL)
      31             : ,pEnginePool(NULL)
      32         970 : ,m_pSourceDoc(pSourceDoc)
      33             : {
      34             :     OSL_ENSURE( pSourceDoc, "ScPoolHelper: no document" );
      35         970 :     pDocPool = new ScDocumentPool;
      36         970 :     pDocPool->FreezeIdRanges();
      37             : 
      38         970 :     mxStylePool = new ScStyleSheetPool( *pDocPool, pSourceDoc );
      39         970 : }
      40             : 
      41        2397 : ScPoolHelper::~ScPoolHelper()
      42             : {
      43         799 :     SfxItemPool::Free(pEnginePool);
      44         799 :     SfxItemPool::Free(pEditPool);
      45         799 :     delete pFormTable;
      46         799 :     mxStylePool.clear();
      47         799 :     SfxItemPool::Free(pDocPool);
      48        1598 : }
      49        1142 : SfxItemPool*        ScPoolHelper::GetEditPool() const
      50             : {
      51        1142 :     if ( !pEditPool )
      52             :     {
      53         347 :         pEditPool = EditEngine::CreatePool();
      54         347 :         pEditPool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
      55         347 :         pEditPool->FreezeIdRanges();
      56         347 :         pEditPool->SetFileFormatVersion( SOFFICE_FILEFORMAT_50 );   // used in ScGlobal::EETextObjEqual
      57             :     }
      58        1142 :     return pEditPool;
      59             : }
      60        1299 : SfxItemPool*        ScPoolHelper::GetEnginePool() const
      61             : {
      62        1299 :     if ( !pEnginePool )
      63             :     {
      64         344 :         pEnginePool = EditEngine::CreatePool();
      65         344 :         pEnginePool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
      66         344 :         pEnginePool->FreezeIdRanges();
      67             :     } // ifg ( pEnginePool )
      68        1299 :     return pEnginePool;
      69             : }
      70      207430 : SvNumberFormatter*  ScPoolHelper::GetFormTable() const
      71             : {
      72      207430 :     if (!pFormTable)
      73         506 :         pFormTable = CreateNumberFormatter();
      74      207430 :     return pFormTable;
      75             : }
      76             : 
      77        1698 : void ScPoolHelper::UseDocOptions() const
      78             : {
      79        1698 :     if (pFormTable)
      80             :     {
      81             :         sal_uInt16 d,m,y;
      82        1304 :         aOpt.GetDate( d,m,y );
      83        1304 :         pFormTable->ChangeNullDate( d,m,y );
      84        1304 :         pFormTable->ChangeStandardPrec( (sal_uInt16)aOpt.GetStdPrecision() );
      85        1304 :         pFormTable->SetYear2000( aOpt.GetYear2000() );
      86             :     }
      87        1698 : }
      88             : 
      89        1698 : void ScPoolHelper::SetFormTableOpt(const ScDocOptions& rOpt)
      90             : {
      91        1698 :     aOpt = rOpt;
      92        1698 :     UseDocOptions();        // #i105512# if the number formatter exists, update its settings
      93        1698 : }
      94             : 
      95         506 : SvNumberFormatter* ScPoolHelper::CreateNumberFormatter() const
      96             : {
      97         506 :     SvNumberFormatter* p = NULL;
      98             :     {
      99         506 :         osl::MutexGuard aGuard(&maMtxCreateNumFormatter);
     100         506 :         p = new SvNumberFormatter(comphelper::getProcessComponentContext(), ScGlobal::eLnge);
     101             :     }
     102         506 :     p->SetColorLink( LINK(m_pSourceDoc, ScDocument, GetUserDefinedColor) );
     103         506 :     p->SetEvalDateFormat(NF_EVALDATEFORMAT_INTL_FORMAT);
     104             : 
     105             :     sal_uInt16 d,m,y;
     106         506 :     aOpt.GetDate(d, m, y);
     107         506 :     p->ChangeNullDate(d, m, y);
     108         506 :     p->ChangeStandardPrec(aOpt.GetStdPrecision());
     109         506 :     p->SetYear2000(aOpt.GetYear2000());
     110         506 :     return p;
     111             : }
     112             : 
     113        1657 : void ScPoolHelper::SourceDocumentGone()
     114             : {
     115             :     //  reset all pointers to the source document
     116        1657 :     mxStylePool->SetDocument( NULL );
     117        1657 :     if ( pFormTable )
     118        1233 :         pFormTable->SetColorLink( Link() );
     119        1657 : }
     120             : 
     121             : 
     122             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10