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 
24 #include <poolhelp.hxx>
25 #include <document.hxx>
26 #include <docpool.hxx>
27 #include <stlpool.hxx>
28 
30  : pEditPool(nullptr)
31  , pEnginePool(nullptr)
32  , m_rSourceDoc(rSourceDoc)
33 {
36 
37  mxStylePool = new ScStyleSheetPool( *pDocPool, &rSourceDoc );
38 }
39 
41 {
44  pFormTable.reset();
45  mxStylePool.clear();
47 }
49 {
50  if ( !pEditPool )
51  {
53  pEditPool->SetDefaultMetric( MapUnit::Map100thMM );
55  }
56  return pEditPool;
57 }
59 {
60  if ( !pEnginePool )
61  {
63  pEnginePool->SetDefaultMetric( MapUnit::Map100thMM );
65  } // ifg ( pEnginePool )
66  return pEnginePool;
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 
90 std::unique_ptr<SvNumberFormatter> ScPoolHelper::CreateNumberFormatter() const
91 {
92  std::unique_ptr<SvNumberFormatter> p;
93  {
94  osl::MutexGuard aGuard(&maMtxCreateNumFormatter);
96  }
97  p->SetColorLink( LINK(&m_rSourceDoc, ScDocument, GetUserDefinedColor) );
98  p->SetEvalDateFormat(NF_EVALDATEFORMAT_INTL_FORMAT);
99 
100  sal_uInt16 d,m;
101  sal_Int16 y;
102  aOpt.GetDate(d, m, y);
103  p->ChangeNullDate(d, m, y);
104  p->ChangeStandardPrec(aOpt.GetStdPrecision());
105  p->SetYear2000(aOpt.GetYear2000());
106  return p;
107 }
108 
110 {
111  // reset all pointers to the source document
112  mxStylePool->SetDocument( nullptr );
113  if ( pFormTable )
114  pFormTable->SetColorLink( Link<sal_uInt16,Color*>() );
115 }
116 
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxItemPool * GetEditPool() const
Definition: poolhelp.cxx:48
osl::Mutex maMtxCreateNumFormatter
Definition: poolhelp.hxx:37
ScDocOptions aOpt
Definition: poolhelp.hxx:38
virtual ~ScPoolHelper() override
Definition: poolhelp.cxx:40
std::unique_ptr< SvNumberFormatter > CreateNumberFormatter() const
Definition: poolhelp.cxx:90
SfxItemPool * pEditPool
Definition: poolhelp.hxx:42
ScDocument & m_rSourceDoc
Definition: poolhelp.hxx:44
void FreezeIdRanges()
SvNumberFormatter * GetFormTable() const
Definition: poolhelp.cxx:68
rtl::Reference< ScStyleSheetPool > mxStylePool
Definition: poolhelp.hxx:40
double d
SfxItemPool * pEnginePool
Definition: poolhelp.hxx:43
float y
ScPoolHelper(ScDocument &rSourceDoc)
Definition: poolhelp.cxx:29
ScDocumentPool * pDocPool
Definition: poolhelp.hxx:39
#define LANGUAGE_SYSTEM
void SourceDocumentGone()
Definition: poolhelp.cxx:109
static SfxItemPool * CreatePool()
NF_EVALDATEFORMAT_INTL_FORMAT
static void Free(SfxItemPool *pPool)
SfxItemPool * GetEnginePool() const
Definition: poolhelp.cxx:58
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:75
void GetDate(sal_uInt16 &rD, sal_uInt16 &rM, sal_Int16 &rY) const
Definition: docoptio.hxx:67