Gtk-WARNING gtktreestore.c:1047: Invalid column number 1 added to iter
[LibreOffice.git] / sc / source / core / data / poolhelp.cxx
blob6eb5e1232da03a5f732e97e529aebcb09770dc92
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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()
38 pEnginePool.clear();
39 pEditPool.clear();
40 pFormTable.reset();
41 mxStylePool.clear();
42 pDocPool.clear();
45 SfxItemPool* ScPoolHelper::GetEditPool() const
47 if ( !pEditPool )
49 pEditPool = EditEngine::CreatePool();
50 pEditPool->SetDefaultMetric( MapUnit::Map100thMM );
52 return pEditPool.get();
55 SfxItemPool* ScPoolHelper::GetEnginePool() const
57 if ( !pEnginePool )
59 pEnginePool = EditEngine::CreatePool();
60 pEnginePool->SetDefaultMetric( MapUnit::Map100thMM );
61 } // ifg ( pEnginePool )
62 return pEnginePool.get();
64 SvNumberFormatter* ScPoolHelper::GetFormTable() const
66 if (!pFormTable)
67 pFormTable = CreateNumberFormatter();
68 return pFormTable.get();
71 void ScPoolHelper::SetFormTableOpt(const ScDocOptions& rOpt)
73 aOpt = rOpt;
74 // #i105512# if the number formatter exists, update its settings
75 if (pFormTable)
77 sal_uInt16 d,m;
78 sal_Int16 y;
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);
97 sal_uInt16 d,m;
98 sal_Int16 y;
99 aOpt.GetDate(d, m, y);
100 p->ChangeNullDate(d, m, y);
101 p->ChangeStandardPrec(aOpt.GetStdPrecision());
102 p->SetYear2000(aOpt.GetYear2000());
103 return p;
106 void ScPoolHelper::SourceDocumentGone()
108 // reset all pointers to the source document
109 mxStylePool->SetDocument( nullptr );
110 if ( pFormTable )
111 pFormTable->SetColorLink( Link<sal_uInt16,Color*>() );
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */