LibreOffice Module sc (master)  1
spellcheckcontext.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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  */
9 
10 #include <spellcheckcontext.hxx>
11 #include <boost/functional/hash.hpp>
12 
13 namespace sc {
14 
16 {
17  std::size_t seed = 0;
18  boost::hash_combine(seed, rPos.mnCol);
19  boost::hash_combine(seed, rPos.mnRow);
20  return seed;
21 }
22 
25 
27 {
28  mnCol = -1;
29  mnRow = -1;
30 }
31 
33 {
34  return mnCol >= 0 && mnRow >= 0;
35 }
36 
38 {
39  mnCol = 0;
40  mnRow = 0;
41 }
42 
44 {
45  return mnCol == r.mnCol && mnRow == r.mnRow;
46 }
47 
49 {
50 }
51 
53 {
54  return maMisspellCells.count(CellPos(nCol, nRow)) > 0;
55 }
56 
57 const std::vector<editeng::MisspellRanges>* SpellCheckContext::getMisspellRanges(
58  SCCOL nCol, SCROW nRow ) const
59 {
60  CellMapType::const_iterator it = maMisspellCells.find(CellPos(nCol,nRow));
61  if (it == maMisspellCells.end())
62  return nullptr;
63 
64  return &it->second;
65 }
66 
68  SCCOL nCol, SCROW nRow, const std::vector<editeng::MisspellRanges>* pRanges )
69 {
70  CellPos aPos(nCol, nRow);
71  CellMapType::iterator it = maMisspellCells.find(aPos);
72 
73  if (pRanges)
74  {
75  if (it == maMisspellCells.end())
76  maMisspellCells.emplace(aPos, *pRanges);
77  else
78  it->second = *pRanges;
79  }
80  else
81  {
82  if (it != maMisspellCells.end())
83  maMisspellCells.erase(it);
84  }
85 }
86 
88 {
89  maPos.reset();
90  maMisspellCells.clear();
91 }
92 
93 }
94 
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool operator==(const CellPos &r) const
sal_Int32 mnCol
void setMisspellRanges(SCCOL nCol, SCROW nRow, const std::vector< editeng::MisspellRanges > *pRanges)
bool isMisspelled(SCCOL nCol, SCROW nRow) const
sal_Int16 SCCOL
Definition: types.hxx:22
const std::vector< editeng::MisspellRanges > * getMisspellRanges(SCCOL nCol, SCROW nRow) const
size_t operator()(const CellPos &rPos) const
sal_Int32 SCROW
Definition: types.hxx:18
sal_Int32 mnRow