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 : // -----------------------------------------------------------------------
29 :
30 578 : ScPoolHelper::ScPoolHelper( ScDocument* pSourceDoc )
31 : :pFormTable(NULL)
32 : ,pEditPool(NULL)
33 : ,pEnginePool(NULL)
34 578 : ,m_pSourceDoc(pSourceDoc)
35 : {
36 : OSL_ENSURE( pSourceDoc, "ScPoolHelper: no document" );
37 578 : pDocPool = new ScDocumentPool;
38 578 : pDocPool->FreezeIdRanges();
39 :
40 578 : mxStylePool = new ScStyleSheetPool( *pDocPool, pSourceDoc );
41 578 : }
42 :
43 1407 : ScPoolHelper::~ScPoolHelper()
44 : {
45 469 : SfxItemPool::Free(pEnginePool);
46 469 : SfxItemPool::Free(pEditPool);
47 469 : delete pFormTable;
48 469 : mxStylePool.clear();
49 469 : SfxItemPool::Free(pDocPool);
50 938 : }
51 2401 : SfxItemPool* ScPoolHelper::GetEditPool() const
52 : {
53 2401 : if ( !pEditPool )
54 : {
55 281 : pEditPool = EditEngine::CreatePool();
56 281 : pEditPool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
57 281 : pEditPool->FreezeIdRanges();
58 281 : pEditPool->SetFileFormatVersion( SOFFICE_FILEFORMAT_50 ); // used in ScGlobal::EETextObjEqual
59 : }
60 2401 : return pEditPool;
61 : }
62 2602 : SfxItemPool* ScPoolHelper::GetEnginePool() const
63 : {
64 2602 : if ( !pEnginePool )
65 : {
66 278 : pEnginePool = EditEngine::CreatePool();
67 278 : pEnginePool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
68 278 : pEnginePool->FreezeIdRanges();
69 : } // ifg ( pEnginePool )
70 2602 : return pEnginePool;
71 : }
72 178667 : SvNumberFormatter* ScPoolHelper::GetFormTable() const
73 : {
74 178667 : if ( !pFormTable )
75 : {
76 369 : pFormTable = new SvNumberFormatter( comphelper::getProcessComponentContext(), ScGlobal::eLnge );
77 369 : pFormTable->SetColorLink( LINK( m_pSourceDoc, ScDocument, GetUserDefinedColor ) );
78 369 : pFormTable->SetEvalDateFormat( NF_EVALDATEFORMAT_INTL_FORMAT );
79 :
80 369 : UseDocOptions(); // null date, year2000, std precision
81 : }
82 178667 : return pFormTable;
83 : }
84 :
85 1624 : void ScPoolHelper::UseDocOptions() const
86 : {
87 1624 : if (pFormTable)
88 : {
89 : sal_uInt16 d,m,y;
90 1310 : aOpt.GetDate( d,m,y );
91 1310 : pFormTable->ChangeNullDate( d,m,y );
92 1310 : pFormTable->ChangeStandardPrec( (sal_uInt16)aOpt.GetStdPrecision() );
93 1310 : pFormTable->SetYear2000( aOpt.GetYear2000() );
94 : }
95 1624 : }
96 :
97 1255 : void ScPoolHelper::SetFormTableOpt(const ScDocOptions& rOpt)
98 : {
99 1255 : aOpt = rOpt;
100 1255 : UseDocOptions(); // #i105512# if the number formatter exists, update its settings
101 1255 : }
102 :
103 1305 : void ScPoolHelper::SourceDocumentGone()
104 : {
105 : // reset all pointers to the source document
106 1305 : mxStylePool->SetDocument( NULL );
107 1305 : if ( pFormTable )
108 1135 : pFormTable->SetColorLink( Link() );
109 1398 : }
110 :
111 : // -----------------------------------------------------------------------
112 :
113 :
114 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|