LibreOffice Module sc (master) 1
poolhelp.cxx
Go to the documentation of this file.
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
21#include <svl/numformat.hxx>
22#include <svl/zforlist.hxx>
23#include <editeng/editeng.hxx>
24
25#include <poolhelp.hxx>
26#include <document.hxx>
27#include <docpool.hxx>
28#include <stlpool.hxx>
29
31 : pDocPool(new ScDocumentPool)
32{
33 pDocPool->FreezeIdRanges();
34
35 mxStylePool = new ScStyleSheetPool( *pDocPool, &rSourceDoc );
36}
37
39{
40 pEnginePool.clear();
41 pEditPool.clear();
42 pFormTable.reset();
43 mxStylePool.clear();
44 pDocPool.clear();
45}
46
48{
49 if ( !pEditPool )
50 {
52 pEditPool->SetDefaultMetric( MapUnit::Map100thMM );
53 pEditPool->FreezeIdRanges();
54 }
55 return pEditPool.get();
56}
57
59{
60 if ( !pEnginePool )
61 {
63 pEnginePool->SetDefaultMetric( MapUnit::Map100thMM );
64 pEnginePool->FreezeIdRanges();
65 } // ifg ( pEnginePool )
66 return pEnginePool.get();
67}
69{
70 if (!pFormTable)
72 return pFormTable.get();
73}
74
76{
77 aOpt = rOpt;
78 // #i105512# if the number formatter exists, update its settings
79 if (pFormTable)
80 {
81 sal_uInt16 d,m;
82 sal_Int16 y;
83 aOpt.GetDate( d,m,y );
84 pFormTable->ChangeNullDate( d,m,y );
85 pFormTable->ChangeStandardPrec( aOpt.GetStdPrecision() );
86 pFormTable->SetYear2000( aOpt.GetYear2000() );
87 }
88}
89
90std::unique_ptr<SvNumberFormatter> ScPoolHelper::CreateNumberFormatter() const
91{
92 std::unique_ptr<SvNumberFormatter> p;
93 {
94 std::scoped_lock aGuard(maMtxCreateNumFormatter);
96 }
97 assert(mxStylePool->GetDocument());
98 p->SetColorLink( LINK(mxStylePool->GetDocument(), ScDocument, GetUserDefinedColor));
99 p->SetEvalDateFormat(NF_EVALDATEFORMAT_INTL_FORMAT);
100
101 sal_uInt16 d,m;
102 sal_Int16 y;
103 aOpt.GetDate(d, m, y);
104 p->ChangeNullDate(d, m, y);
105 p->ChangeStandardPrec(aOpt.GetStdPrecision());
106 p->SetYear2000(aOpt.GetYear2000());
107 return p;
108}
109
111{
112 // reset all pointers to the source document
113 mxStylePool->SetDocument( nullptr );
114 if ( pFormTable )
115 pFormTable->SetColorLink( Link<sal_uInt16,Color*>() );
116}
117
118/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
double d
static rtl::Reference< SfxItemPool > CreatePool()
sal_uInt16 GetYear2000() const
Definition: docoptio.hxx:85
void GetDate(sal_uInt16 &rD, sal_uInt16 &rM, sal_Int16 &rY) const
Definition: docoptio.hxx:66
sal_uInt16 GetStdPrecision() const
Definition: docoptio.hxx:78
rtl::Reference< ScDocumentPool > pDocPool
Definition: poolhelp.hxx:39
SfxItemPool * GetEnginePool() const
Definition: poolhelp.cxx:58
rtl::Reference< SfxItemPool > pEditPool
Definition: poolhelp.hxx:42
void SourceDocumentGone()
Definition: poolhelp.cxx:110
rtl::Reference< SfxItemPool > pEnginePool
Definition: poolhelp.hxx:43
SfxItemPool * GetEditPool() const
Definition: poolhelp.cxx:47
std::unique_ptr< SvNumberFormatter > pFormTable
Definition: poolhelp.hxx:41
void SetFormTableOpt(const ScDocOptions &rOpt)
Definition: poolhelp.cxx:75
rtl::Reference< ScStyleSheetPool > mxStylePool
Definition: poolhelp.hxx:40
std::mutex maMtxCreateNumFormatter
Definition: poolhelp.hxx:37
virtual ~ScPoolHelper() override
Definition: poolhelp.cxx:38
ScPoolHelper(ScDocument &rSourceDoc)
Definition: poolhelp.cxx:30
ScDocOptions aOpt
Definition: poolhelp.hxx:38
SvNumberFormatter * GetFormTable() const
Definition: poolhelp.cxx:68
std::unique_ptr< SvNumberFormatter > CreateNumberFormatter() const
Definition: poolhelp.cxx:90
float y
void * p
#define LANGUAGE_SYSTEM
Reference< XComponentContext > getProcessComponentContext()
m
NF_EVALDATEFORMAT_INTL_FORMAT