1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #include "spellcheckcontext.hxx"
14 size_t SpellCheckContext::CellPos::Hash::operator() (const CellPos
& rPos
) const
16 size_t nVal
= rPos
.mnCol
;
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()
31 bool SpellCheckContext::CellPos::isValid() const
33 return mnCol
>= 0 && mnRow
>= 0;
36 void SpellCheckContext::CellPos::reset()
42 bool SpellCheckContext::CellPos::operator< (const CellPos
& r
) const
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())
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
);
82 if (it
== maMisspellCells
.end())
83 maMisspellCells
.insert(CellMapType::value_type(aPos
, *pRanges
));
85 it
->second
= *pRanges
;
89 if (it
!= maMisspellCells
.end())
90 maMisspellCells
.erase(it
);
94 void SpellCheckContext::reset()
97 maMisspellCells
.clear();
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */