fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / core / data / poolhelp.cxx
blob2a0f08530aba3d6ec42a30ed5da1ae2cc90edff0
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 <svl/zforlist.hxx>
21 #include <editeng/editeng.hxx>
23 #include "poolhelp.hxx"
24 #include "document.hxx"
25 #include "docpool.hxx"
26 #include "stlpool.hxx"
28 ScPoolHelper::ScPoolHelper( ScDocument* pSourceDoc )
29 :pFormTable(NULL)
30 ,pEditPool(NULL)
31 ,pEnginePool(NULL)
32 ,m_pSourceDoc(pSourceDoc)
34 OSL_ENSURE( pSourceDoc, "ScPoolHelper: no document" );
35 pDocPool = new ScDocumentPool;
36 pDocPool->FreezeIdRanges();
38 mxStylePool = new ScStyleSheetPool( *pDocPool, pSourceDoc );
41 ScPoolHelper::~ScPoolHelper()
43 SfxItemPool::Free(pEnginePool);
44 SfxItemPool::Free(pEditPool);
45 delete pFormTable;
46 mxStylePool.clear();
47 SfxItemPool::Free(pDocPool);
49 SfxItemPool* ScPoolHelper::GetEditPool() const
51 if ( !pEditPool )
53 pEditPool = EditEngine::CreatePool();
54 pEditPool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
55 pEditPool->FreezeIdRanges();
56 pEditPool->SetFileFormatVersion( SOFFICE_FILEFORMAT_50 ); // used in ScGlobal::EETextObjEqual
58 return pEditPool;
60 SfxItemPool* ScPoolHelper::GetEnginePool() const
62 if ( !pEnginePool )
64 pEnginePool = EditEngine::CreatePool();
65 pEnginePool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
66 pEnginePool->FreezeIdRanges();
67 } // ifg ( pEnginePool )
68 return pEnginePool;
70 SvNumberFormatter* ScPoolHelper::GetFormTable() const
72 if (!pFormTable)
73 pFormTable = CreateNumberFormatter();
74 return pFormTable;
77 void ScPoolHelper::UseDocOptions() const
79 if (pFormTable)
81 sal_uInt16 d,m,y;
82 aOpt.GetDate( d,m,y );
83 pFormTable->ChangeNullDate( d,m,y );
84 pFormTable->ChangeStandardPrec( (sal_uInt16)aOpt.GetStdPrecision() );
85 pFormTable->SetYear2000( aOpt.GetYear2000() );
89 void ScPoolHelper::SetFormTableOpt(const ScDocOptions& rOpt)
91 aOpt = rOpt;
92 UseDocOptions(); // #i105512# if the number formatter exists, update its settings
95 SvNumberFormatter* ScPoolHelper::CreateNumberFormatter() const
97 SvNumberFormatter* p = NULL;
99 osl::MutexGuard aGuard(&maMtxCreateNumFormatter);
100 p = new SvNumberFormatter(comphelper::getProcessComponentContext(), ScGlobal::eLnge);
102 p->SetColorLink( LINK(m_pSourceDoc, ScDocument, GetUserDefinedColor) );
103 p->SetEvalDateFormat(NF_EVALDATEFORMAT_INTL_FORMAT);
105 sal_uInt16 d,m,y;
106 aOpt.GetDate(d, m, y);
107 p->ChangeNullDate(d, m, y);
108 p->ChangeStandardPrec(aOpt.GetStdPrecision());
109 p->SetYear2000(aOpt.GetYear2000());
110 return p;
113 void ScPoolHelper::SourceDocumentGone()
115 // reset all pointers to the source document
116 mxStylePool->SetDocument( NULL );
117 if ( pFormTable )
118 pFormTable->SetColorLink( Link<>() );
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */