Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / core / data / mtvelements.cxx
blob1110ab6d2a04594f6389e3cf87a9402e1a0f45dd
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/.
8 */
10 #include "mtvelements.hxx"
11 #include "globalnames.hxx"
12 #include "document.hxx"
13 #include "cellvalue.hxx"
15 namespace sc {
17 CellTextAttr::CellTextAttr() :
18 mnTextWidth(TEXTWIDTH_DIRTY),
19 mnScriptType(SC_SCRIPTTYPE_UNKNOWN) {}
21 CellTextAttr::CellTextAttr(const CellTextAttr& r) :
22 mnTextWidth(r.mnTextWidth),
23 mnScriptType(r.mnScriptType) {}
25 CellTextAttr::CellTextAttr(sal_uInt16 nTextWidth, sal_uInt8 nScriptType) :
26 mnTextWidth(nTextWidth),
27 mnScriptType(nScriptType) {}
29 ColumnBlockPositionSet::ColumnBlockPositionSet(ScDocument& rDoc) : mrDoc(rDoc) {}
31 ColumnBlockPosition* ColumnBlockPositionSet::getBlockPosition(SCTAB nTab, SCCOL nCol)
33 osl::MutexGuard aGuard(&maMtxTables);
35 TablesType::iterator itTab = maTables.find(nTab);
36 if (itTab == maTables.end())
38 std::pair<TablesType::iterator,bool> r =
39 maTables.insert(TablesType::value_type(nTab, ColumnsType()));
40 if (!r.second)
41 // insertion failed.
42 return NULL;
44 itTab = r.first;
47 ColumnsType& rCols = itTab->second;
49 ColumnsType::iterator it = rCols.find(nCol);
50 if (it != rCols.end())
51 // Block position for this column has already been fetched.
52 return &it->second;
54 std::pair<ColumnsType::iterator,bool> r =
55 rCols.insert(
56 ColumnsType::value_type(nCol, ColumnBlockPosition()));
58 if (!r.second)
59 // insertion failed.
60 return NULL;
62 it = r.first;
64 if (!mrDoc.InitColumnBlockPosition(it->second, nTab, nCol))
65 return NULL;
67 return &it->second;
70 void ColumnBlockPositionSet::clear()
72 osl::MutexGuard aGuard(&maMtxTables);
73 maTables.clear();
76 ScRefCellValue toRefCell( const sc::CellStoreType::const_iterator& itPos, size_t nOffset )
78 switch (itPos->type)
80 case sc::element_type_numeric:
81 // Numeric cell
82 return ScRefCellValue(sc::numeric_block::at(*itPos->data, nOffset));
83 case sc::element_type_string:
84 // String cell
85 return ScRefCellValue(&sc::string_block::at(*itPos->data, nOffset));
86 case sc::element_type_edittext:
87 // Edit cell
88 return ScRefCellValue(sc::edittext_block::at(*itPos->data, nOffset));
89 break;
90 case sc::element_type_formula:
91 // Formula cell
92 return ScRefCellValue(sc::formula_block::at(*itPos->data, nOffset));
93 default:
97 return ScRefCellValue();
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */