fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / view / spellcheckcontext.cxx
blob66c218e679b594fdf5b31cf6ed0034c852eab876
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 "spellcheckcontext.hxx"
12 namespace sc {
14 size_t SpellCheckContext::CellPos::Hash::operator() (const CellPos& rPos) const
16 size_t nVal = rPos.mnCol;
17 nVal = nVal << 4;
18 nVal += rPos.mnRow;
19 return nVal;
22 SpellCheckContext::CellPos::CellPos() : mnCol(0), mnRow(0) {}
23 SpellCheckContext::CellPos::CellPos(SCCOL nCol, SCROW nRow) : mnCol(nCol), mnRow(nRow) {}
25 void SpellCheckContext::CellPos::setInvalid()
27 mnCol = -1;
28 mnRow = -1;
31 bool SpellCheckContext::CellPos::isValid() const
33 return mnCol >= 0 && mnRow >= 0;
36 void SpellCheckContext::CellPos::reset()
38 mnCol = 0;
39 mnRow = 0;
42 bool SpellCheckContext::CellPos::operator< (const CellPos& r) const
44 if (mnCol != r.mnCol)
45 return mnCol < r.mnCol;
47 return mnRow < r.mnRow;
50 bool SpellCheckContext::CellPos::operator== (const CellPos& r) const
52 return mnCol == r.mnCol && mnRow == r.mnRow;
55 SpellCheckContext::SpellCheckContext()
59 bool SpellCheckContext::isMisspelled( SCCOL nCol, SCROW nRow ) const
61 return maMisspellCells.count(CellPos(nCol, nRow)) > 0;
64 const std::vector<editeng::MisspellRanges>* SpellCheckContext::getMisspellRanges(
65 SCCOL nCol, SCROW nRow ) const
67 CellMapType::const_iterator it = maMisspellCells.find(CellPos(nCol,nRow));
68 if (it == maMisspellCells.end())
69 return NULL;
71 return &it->second;
74 void SpellCheckContext::setMisspellRanges(
75 SCCOL nCol, SCROW nRow, const std::vector<editeng::MisspellRanges>* pRanges )
77 CellPos aPos(nCol, nRow);
78 CellMapType::iterator it = maMisspellCells.find(aPos);
80 if (pRanges)
82 if (it == maMisspellCells.end())
83 maMisspellCells.insert(CellMapType::value_type(aPos, *pRanges));
84 else
85 it->second = *pRanges;
87 else
89 if (it != maMisspellCells.end())
90 maMisspellCells.erase(it);
94 void SpellCheckContext::reset()
96 maPos.reset();
97 maMisspellCells.clear();
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */