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/zforlist.hxx>
22 #include <editeng/editeng.hxx>
23 #include <osl/diagnose.h>
24 
25 #include <poolhelp.hxx>
26 #include <document.hxx>
27 #include <docpool.hxx>
28 #include <stlpool.hxx>
29 
31  : pEditPool(nullptr)
32  , pEnginePool(nullptr)
33  , m_rSourceDoc(rSourceDoc)
34 {
37 
38  mxStylePool = new ScStyleSheetPool( *pDocPool, &rSourceDoc );
39 }
40 
42 {
45  pFormTable.reset();
46  mxStylePool.clear();
48 }
50 {
51  if ( !pEditPool )
52  {
54  pEditPool->SetDefaultMetric( MapUnit::Map100thMM );
56  }
57  return pEditPool;
58 }
60 {
61  if ( !pEnginePool )
62  {
64  pEnginePool->SetDefaultMetric( MapUnit::Map100thMM );
66  } // ifg ( pEnginePool )
67  return pEnginePool;
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  osl::MutexGuard 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:49
osl::Mutex maMtxCreateNumFormatter
Definition: poolhelp.hxx:37
ScDocOptions aOpt
Definition: poolhelp.hxx:38
virtual ~ScPoolHelper() override
Definition: poolhelp.cxx:41
std::unique_ptr< SvNumberFormatter > CreateNumberFormatter() const
Definition: poolhelp.cxx:91
SfxItemPool * pEditPool
Definition: poolhelp.hxx:42
ScDocument & m_rSourceDoc
Definition: poolhelp.hxx:44
void FreezeIdRanges()
SvNumberFormatter * GetFormTable() const
Definition: poolhelp.cxx:69
rtl::Reference< ScStyleSheetPool > mxStylePool
Definition: poolhelp.hxx:40
double d
SfxItemPool * pEnginePool
Definition: poolhelp.hxx:43
float y
ScPoolHelper(ScDocument &rSourceDoc)
Definition: poolhelp.cxx:30
ScDocumentPool * pDocPool
Definition: poolhelp.hxx:39
#define LANGUAGE_SYSTEM
void SourceDocumentGone()
Definition: poolhelp.cxx:110
static SfxItemPool * CreatePool()
NF_EVALDATEFORMAT_INTL_FORMAT
static void Free(SfxItemPool *pPool)
SfxItemPool * GetEnginePool() const
Definition: poolhelp.cxx:59
void SetDefaultMetric(MapUnit eNewMetric)
void * p
Reference< XComponentContext > getProcessComponentContext()
sal_uInt16 GetYear2000() const
Definition: docoptio.hxx:86
sal_uInt16 GetStdPrecision() const
Definition: docoptio.hxx:79
std::unique_ptr< SvNumberFormatter > pFormTable
Definition: poolhelp.hxx:41
tuple m
void SetFormTableOpt(const ScDocOptions &rOpt)
Definition: poolhelp.cxx:76
void GetDate(sal_uInt16 &rD, sal_uInt16 &rM, sal_Int16 &rY) const
Definition: docoptio.hxx:67