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  , m_rSourceDoc(rSourceDoc)
33 {
34  pDocPool->FreezeIdRanges();
35 
36  mxStylePool = new ScStyleSheetPool( *pDocPool, &rSourceDoc );
37 }
38 
40 {
41  pEnginePool.clear();
42  pEditPool.clear();
43  pFormTable.reset();
44  mxStylePool.clear();
45  pDocPool.clear();
46 }
47 
49 {
50  if ( !pEditPool )
51  {
53  pEditPool->SetDefaultMetric( MapUnit::Map100thMM );
54  pEditPool->FreezeIdRanges();
55  }
56  return pEditPool.get();
57 }
58 
60 {
61  if ( !pEnginePool )
62  {
64  pEnginePool->SetDefaultMetric( MapUnit::Map100thMM );
65  pEnginePool->FreezeIdRanges();
66  } // ifg ( pEnginePool )
67  return pEnginePool.get();
68 }
70 {
71  if (!pFormTable)
73  return pFormTable.get();
74 }
75 
77 {
78  aOpt = rOpt;
79  // #i105512# if the number formatter exists, update its settings
80  if (pFormTable)
81  {
82  sal_uInt16 d,m;
83  sal_Int16 y;
84  aOpt.GetDate( d,m,y );
85  pFormTable->ChangeNullDate( d,m,y );
86  pFormTable->ChangeStandardPrec( aOpt.GetStdPrecision() );
87  pFormTable->SetYear2000( aOpt.GetYear2000() );
88  }
89 }
90 
91 std::unique_ptr<SvNumberFormatter> ScPoolHelper::CreateNumberFormatter() const
92 {
93  std::unique_ptr<SvNumberFormatter> p;
94  {
95  std::scoped_lock aGuard(maMtxCreateNumFormatter);
97  }
98  p->SetColorLink( LINK(&m_rSourceDoc, 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: */
SfxItemPool * GetEditPool() const
Definition: poolhelp.cxx:48
ScDocOptions aOpt
Definition: poolhelp.hxx:38
virtual ~ScPoolHelper() override
Definition: poolhelp.cxx:39
std::unique_ptr< SvNumberFormatter > CreateNumberFormatter() const
Definition: poolhelp.cxx:91
ScDocument & m_rSourceDoc
Definition: poolhelp.hxx:44
SvNumberFormatter * GetFormTable() const
Definition: poolhelp.cxx:69
static rtl::Reference< SfxItemPool > CreatePool()
rtl::Reference< ScStyleSheetPool > mxStylePool
Definition: poolhelp.hxx:40
double d
float y
ScPoolHelper(ScDocument &rSourceDoc)
Definition: poolhelp.cxx:30
#define LANGUAGE_SYSTEM
void SourceDocumentGone()
Definition: poolhelp.cxx:110
rtl::Reference< SfxItemPool > pEditPool
Definition: poolhelp.hxx:42
NF_EVALDATEFORMAT_INTL_FORMAT
SfxItemPool * GetEnginePool() const
Definition: poolhelp.cxx:59
rtl::Reference< ScDocumentPool > pDocPool
Definition: poolhelp.hxx:39
std::mutex maMtxCreateNumFormatter
Definition: poolhelp.hxx:37
void * p
Reference< XComponentContext > getProcessComponentContext()
sal_uInt16 GetYear2000() const
Definition: docoptio.hxx:85
sal_uInt16 GetStdPrecision() const
Definition: docoptio.hxx:78
std::unique_ptr< SvNumberFormatter > pFormTable
Definition: poolhelp.hxx:41
tuple m
void SetFormTableOpt(const ScDocOptions &rOpt)
Definition: poolhelp.cxx:76
rtl::Reference< SfxItemPool > pEnginePool
Definition: poolhelp.hxx:43
void GetDate(sal_uInt16 &rD, sal_uInt16 &rM, sal_Int16 &rY) const
Definition: docoptio.hxx:66