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

Generated by: LCOV version 1.10