xref: /aoo4110/main/sc/source/core/data/poolhelp.cxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26 
27 
28 
29 // INCLUDE ---------------------------------------------------------------
30 
31 #include <svl/zforlist.hxx>
32 #include <editeng/editeng.hxx>
33 
34 #include "poolhelp.hxx"
35 #include "document.hxx"
36 #include "docpool.hxx"
37 #include "stlpool.hxx"
38 
39 // -----------------------------------------------------------------------
40 
ScPoolHelper(ScDocument * pSourceDoc)41 ScPoolHelper::ScPoolHelper( ScDocument* pSourceDoc )
42 :pFormTable(NULL)
43 ,pEditPool(NULL)
44 ,pEnginePool(NULL)
45 ,m_pSourceDoc(pSourceDoc)
46 {
47 	DBG_ASSERT( pSourceDoc, "ScPoolHelper: no document" );
48 	pDocPool = new ScDocumentPool;
49 	pDocPool->FreezeIdRanges();
50 
51 	mxStylePool = new ScStyleSheetPool( *pDocPool, pSourceDoc );
52 }
53 
~ScPoolHelper()54 ScPoolHelper::~ScPoolHelper()
55 {
56 	SfxItemPool::Free(pEnginePool);
57 	SfxItemPool::Free(pEditPool);
58 	delete pFormTable;
59 	mxStylePool.clear();
60 	SfxItemPool::Free(pDocPool);
61 }
GetEditPool() const62 SfxItemPool*		ScPoolHelper::GetEditPool() const
63 {
64     if ( !pEditPool )
65     {
66         pEditPool = EditEngine::CreatePool();
67 	    pEditPool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
68 	    pEditPool->FreezeIdRanges();
69 	    pEditPool->SetFileFormatVersion( SOFFICE_FILEFORMAT_50 );	// used in ScGlobal::EETextObjEqual
70     }
71     return pEditPool;
72 }
GetEnginePool() const73 SfxItemPool*		ScPoolHelper::GetEnginePool() const
74 {
75     if ( !pEnginePool )
76     {
77         pEnginePool = EditEngine::CreatePool();
78 	    pEnginePool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
79 	    pEnginePool->FreezeIdRanges();
80     } // ifg ( pEnginePool )
81     return pEnginePool;
82 }
GetFormTable() const83 SvNumberFormatter*	ScPoolHelper::GetFormTable() const
84 {
85     if ( !pFormTable )
86     {
87         pFormTable = new SvNumberFormatter( m_pSourceDoc->GetServiceManager(), ScGlobal::eLnge );
88         pFormTable->SetColorLink( LINK( m_pSourceDoc, ScDocument, GetUserDefinedColor ) );
89 	    pFormTable->SetEvalDateFormat( NF_EVALDATEFORMAT_INTL_FORMAT );
90 
91         UseDocOptions();        // null date, year2000, std precision
92     }
93     return pFormTable;
94 }
95 
UseDocOptions() const96 void ScPoolHelper::UseDocOptions() const
97 {
98     if (pFormTable)
99     {
100         sal_uInt16 d,m,y;
101         aOpt.GetDate( d,m,y );
102         pFormTable->ChangeNullDate( d,m,y );
103 	    pFormTable->ChangeStandardPrec( (sal_uInt16)aOpt.GetStdPrecision() );
104 	    pFormTable->SetYear2000( aOpt.GetYear2000() );
105     }
106 }
107 
SetFormTableOpt(const ScDocOptions & rOpt)108 void ScPoolHelper::SetFormTableOpt(const ScDocOptions& rOpt)
109 {
110     aOpt = rOpt;
111     UseDocOptions();        // #i105512# if the number formatter exists, update its settings
112 }
113 
SourceDocumentGone()114 void ScPoolHelper::SourceDocumentGone()
115 {
116 	//	reset all pointers to the source document
117 	mxStylePool->SetDocument( NULL );
118     if ( pFormTable )
119         pFormTable->SetColorLink( Link() );
120 }
121 
122 // -----------------------------------------------------------------------
123 
124 
125