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

Generated by: LCOV version 1.11