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

Generated by: LCOV version 1.10