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