Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <svl/zforlist.hxx>
30 : : #include <editeng/editeng.hxx>
31 : :
32 : : #include "poolhelp.hxx"
33 : : #include "document.hxx"
34 : : #include "docpool.hxx"
35 : : #include "stlpool.hxx"
36 : :
37 : : // -----------------------------------------------------------------------
38 : :
39 : 846 : ScPoolHelper::ScPoolHelper( ScDocument* pSourceDoc )
40 : : :pFormTable(NULL)
41 : : ,pEditPool(NULL)
42 : : ,pEnginePool(NULL)
43 [ + - ]: 846 : ,m_pSourceDoc(pSourceDoc)
44 : : {
45 : : OSL_ENSURE( pSourceDoc, "ScPoolHelper: no document" );
46 [ + - ][ + - ]: 846 : pDocPool = new ScDocumentPool;
47 [ + - ]: 846 : pDocPool->FreezeIdRanges();
48 : :
49 [ + - ][ + - ]: 846 : mxStylePool = new ScStyleSheetPool( *pDocPool, pSourceDoc );
50 : 846 : }
51 : :
52 [ + - ]: 695 : ScPoolHelper::~ScPoolHelper()
53 : : {
54 [ + - ]: 695 : SfxItemPool::Free(pEnginePool);
55 [ + - ]: 695 : SfxItemPool::Free(pEditPool);
56 [ + + ][ + - ]: 695 : delete pFormTable;
57 : 695 : mxStylePool.clear();
58 [ + - ]: 695 : SfxItemPool::Free(pDocPool);
59 [ - + ]: 1390 : }
60 : 3868 : SfxItemPool* ScPoolHelper::GetEditPool() const
61 : : {
62 [ + + ]: 3868 : if ( !pEditPool )
63 : : {
64 : 251 : pEditPool = EditEngine::CreatePool();
65 : 251 : pEditPool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
66 : 251 : pEditPool->FreezeIdRanges();
67 : 251 : pEditPool->SetFileFormatVersion( SOFFICE_FILEFORMAT_50 ); // used in ScGlobal::EETextObjEqual
68 : : }
69 : 3868 : return pEditPool;
70 : : }
71 : 2941 : SfxItemPool* ScPoolHelper::GetEnginePool() const
72 : : {
73 [ + + ]: 2941 : if ( !pEnginePool )
74 : : {
75 : 248 : pEnginePool = EditEngine::CreatePool();
76 : 248 : pEnginePool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
77 : 248 : pEnginePool->FreezeIdRanges();
78 : : } // ifg ( pEnginePool )
79 : 2941 : return pEnginePool;
80 : : }
81 : 160783 : SvNumberFormatter* ScPoolHelper::GetFormTable() const
82 : : {
83 [ + + ]: 160783 : if ( !pFormTable )
84 : : {
85 [ + - ][ + - ]: 489 : pFormTable = new SvNumberFormatter( m_pSourceDoc->GetServiceManager(), ScGlobal::eLnge );
86 : 489 : pFormTable->SetColorLink( LINK( m_pSourceDoc, ScDocument, GetUserDefinedColor ) );
87 : 489 : pFormTable->SetEvalDateFormat( NF_EVALDATEFORMAT_INTL_FORMAT );
88 : :
89 : 489 : UseDocOptions(); // null date, year2000, std precision
90 : : }
91 : 160783 : return pFormTable;
92 : : }
93 : :
94 : 1953 : void ScPoolHelper::UseDocOptions() const
95 : : {
96 [ + + ]: 1953 : if (pFormTable)
97 : : {
98 : : sal_uInt16 d,m,y;
99 : 1538 : aOpt.GetDate( d,m,y );
100 [ + - ]: 1538 : pFormTable->ChangeNullDate( d,m,y );
101 [ + - ]: 1538 : pFormTable->ChangeStandardPrec( (sal_uInt16)aOpt.GetStdPrecision() );
102 [ + - ]: 1538 : pFormTable->SetYear2000( aOpt.GetYear2000() );
103 : : }
104 : 1953 : }
105 : :
106 : 1464 : void ScPoolHelper::SetFormTableOpt(const ScDocOptions& rOpt)
107 : : {
108 : 1464 : aOpt = rOpt;
109 : 1464 : UseDocOptions(); // #i105512# if the number formatter exists, update its settings
110 : 1464 : }
111 : :
112 : 1585 : void ScPoolHelper::SourceDocumentGone()
113 : : {
114 : : // reset all pointers to the source document
115 : 1585 : mxStylePool->SetDocument( NULL );
116 [ + + ]: 1585 : if ( pFormTable )
117 : 1267 : pFormTable->SetColorLink( Link() );
118 : 1585 : }
119 : :
120 : : // -----------------------------------------------------------------------
121 : :
122 : :
123 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|