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 <comphelper/processfactory.hxx>
21 #include <svl/numformat.hxx>
22 #include <svl/zforlist.hxx>
23 #include <editeng/editeng.hxx>
25 #include <poolhelp.hxx>
26 #include <document.hxx>
27 #include <docpool.hxx>
28 #include <stlpool.hxx>
30 ScPoolHelper::ScPoolHelper( ScDocument
& rSourceDoc
)
31 : pDocPool(new ScDocumentPool
)
33 mxStylePool
= new ScStyleSheetPool( *pDocPool
, &rSourceDoc
);
36 ScPoolHelper::~ScPoolHelper()
45 SfxItemPool
* ScPoolHelper::GetEditPool() const
49 pEditPool
= EditEngine::CreatePool();
50 pEditPool
->SetDefaultMetric( MapUnit::Map100thMM
);
52 return pEditPool
.get();
55 SfxItemPool
* ScPoolHelper::GetEnginePool() const
59 pEnginePool
= EditEngine::CreatePool();
60 pEnginePool
->SetDefaultMetric( MapUnit::Map100thMM
);
61 } // ifg ( pEnginePool )
62 return pEnginePool
.get();
64 SvNumberFormatter
* ScPoolHelper::GetFormTable() const
67 pFormTable
= CreateNumberFormatter();
68 return pFormTable
.get();
71 void ScPoolHelper::SetFormTableOpt(const ScDocOptions
& rOpt
)
74 // #i105512# if the number formatter exists, update its settings
79 aOpt
.GetDate( d
,m
,y
);
80 pFormTable
->ChangeNullDate( d
,m
,y
);
81 pFormTable
->ChangeStandardPrec( aOpt
.GetStdPrecision() );
82 pFormTable
->SetYear2000( aOpt
.GetYear2000() );
86 std::unique_ptr
<SvNumberFormatter
> ScPoolHelper::CreateNumberFormatter() const
88 std::unique_ptr
<SvNumberFormatter
> p
;
90 std::scoped_lock
aGuard(maMtxCreateNumFormatter
);
91 p
.reset(new SvNumberFormatter(comphelper::getProcessComponentContext(), LANGUAGE_SYSTEM
));
93 assert(mxStylePool
->GetDocument());
94 p
->SetColorLink( LINK(mxStylePool
->GetDocument(), ScDocument
, GetUserDefinedColor
));
95 p
->SetEvalDateFormat(NF_EVALDATEFORMAT_INTL_FORMAT
);
99 aOpt
.GetDate(d
, m
, y
);
100 p
->ChangeNullDate(d
, m
, y
);
101 p
->ChangeStandardPrec(aOpt
.GetStdPrecision());
102 p
->SetYear2000(aOpt
.GetYear2000());
106 void ScPoolHelper::SourceDocumentGone()
108 // reset all pointers to the source document
109 mxStylePool
->SetDocument( nullptr );
111 pFormTable
->SetColorLink( Link
<sal_uInt16
,Color
*>() );
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */