1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svl/zforlist.hxx>
21 #include <editeng/editeng.hxx>
23 #include "poolhelp.hxx"
24 #include "document.hxx"
25 #include "docpool.hxx"
26 #include "stlpool.hxx"
28 // -----------------------------------------------------------------------
30 ScPoolHelper::ScPoolHelper( ScDocument
* pSourceDoc
)
34 ,m_pSourceDoc(pSourceDoc
)
36 OSL_ENSURE( pSourceDoc
, "ScPoolHelper: no document" );
37 pDocPool
= new ScDocumentPool
;
38 pDocPool
->FreezeIdRanges();
40 mxStylePool
= new ScStyleSheetPool( *pDocPool
, pSourceDoc
);
43 ScPoolHelper::~ScPoolHelper()
45 SfxItemPool::Free(pEnginePool
);
46 SfxItemPool::Free(pEditPool
);
49 SfxItemPool::Free(pDocPool
);
51 SfxItemPool
* ScPoolHelper::GetEditPool() const
55 pEditPool
= EditEngine::CreatePool();
56 pEditPool
->SetDefaultMetric( SFX_MAPUNIT_100TH_MM
);
57 pEditPool
->FreezeIdRanges();
58 pEditPool
->SetFileFormatVersion( SOFFICE_FILEFORMAT_50
); // used in ScGlobal::EETextObjEqual
62 SfxItemPool
* ScPoolHelper::GetEnginePool() const
66 pEnginePool
= EditEngine::CreatePool();
67 pEnginePool
->SetDefaultMetric( SFX_MAPUNIT_100TH_MM
);
68 pEnginePool
->FreezeIdRanges();
69 } // ifg ( pEnginePool )
72 SvNumberFormatter
* ScPoolHelper::GetFormTable() const
75 pFormTable
= CreateNumberFormatter();
79 void ScPoolHelper::UseDocOptions() const
84 aOpt
.GetDate( d
,m
,y
);
85 pFormTable
->ChangeNullDate( d
,m
,y
);
86 pFormTable
->ChangeStandardPrec( (sal_uInt16
)aOpt
.GetStdPrecision() );
87 pFormTable
->SetYear2000( aOpt
.GetYear2000() );
91 void ScPoolHelper::SetFormTableOpt(const ScDocOptions
& rOpt
)
94 UseDocOptions(); // #i105512# if the number formatter exists, update its settings
97 SvNumberFormatter
* ScPoolHelper::CreateNumberFormatter() const
99 SvNumberFormatter
* p
= NULL
;
101 osl::MutexGuard
aGuard(&maMtxCreateNumFormatter
);
102 p
= new SvNumberFormatter(comphelper::getProcessComponentContext(), ScGlobal::eLnge
);
104 p
->SetColorLink( LINK(m_pSourceDoc
, ScDocument
, GetUserDefinedColor
) );
105 p
->SetEvalDateFormat(NF_EVALDATEFORMAT_INTL_FORMAT
);
108 aOpt
.GetDate(d
, m
, y
);
109 p
->ChangeNullDate(d
, m
, y
);
110 p
->ChangeStandardPrec(aOpt
.GetStdPrecision());
111 p
->SetYear2000(aOpt
.GetYear2000());
115 void ScPoolHelper::SourceDocumentGone()
117 // reset all pointers to the source document
118 mxStylePool
->SetDocument( NULL
);
120 pFormTable
->SetColorLink( Link() );
123 // -----------------------------------------------------------------------
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */