1 /* AbiWord
2  * Copyright (C) 1998,1999 AbiSource, Inc.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301 USA.
18  */
19 
20 #ifndef FL_SQUIGGLES_H
21 #define FL_SQUIGGLES_H
22 
23 #include <vector>
24 
25 #include "fl_BlockLayout.h"
26 
27 typedef enum
28 {
29   FL_SQUIGGLE_SPELL,
30   FL_SQUIGGLE_GRAMMAR
31 } FL_SQUIGGLE_TYPE;
32 
33 class ABI_EXPORT fl_Squiggles
34 {
35 public:
36 	fl_Squiggles(fl_BlockLayout* pOwner, FL_SQUIGGLE_TYPE iType);
37 virtual	~fl_Squiggles(void);
38 
39 	void					add(const fl_PartOfBlockPtr& pPOB);
40 	void					markForRedraw(const fl_PartOfBlockPtr& pPOB);
41 
42 	bool					deleteAll(void);
43 
44 	fl_PartOfBlockPtr		get(UT_sint32 iOffset) const;
getNth(UT_sint32 n)45 	inline const fl_PartOfBlockPtr&	getNth(UT_sint32 n) const
46 		{ return m_vecSquiggles.at(n); }
47 
48 	void					clear(const fl_PartOfBlockPtr& pPOB);
49 
50 	void					textInserted(UT_sint32 iOffset,
51 										 UT_sint32 iLength);
52 	void					textDeleted(UT_sint32 iOffset,
53 										UT_sint32 iLength);
54 
55 	void                    textRevised(UT_sint32 iOffset,
56 										UT_sint32 iLength);
57 
getSquiggleType(void)58 	FL_SQUIGGLE_TYPE        getSquiggleType(void) const
59 	  { return m_iSquiggleType;}
60 
61 	void                    updatePOBs(UT_sint32 iOffset, UT_sint32 shift);
62 	void					join(UT_sint32 iOffset,
63 								 fl_BlockLayout* pPrevBL);
64 	void					split(UT_sint32 iOffset,
65 								  fl_BlockLayout* pNewBL);
66 
67 	bool					findRange(UT_sint32 iStart, UT_sint32 iEnd,
68 									  UT_sint32& iFirst,
69 									  UT_sint32& iLast, bool bDontExpand = false) const;
70 
71 	bool					recheckIgnoredWords(const UT_UCSChar* pBlockText);
72 
73 #ifdef FMT_TEST
74 	void					__dump(FILE * fp) const;
75 #endif
76 
77 private:
78 	void					_purge(void);
79 
80 	void					_deleteNth(UT_sint32 iIndex);
81 	bool					_deleteAtOffset(UT_sint32 iOffset);
82 
83 	bool					_findFirstAfter(UT_sint32 iOffset,
84 											UT_sint32& iIndex) const;
85 	UT_sint32				_find(UT_sint32 iOffset) const;
86 
87 	void					_move(UT_sint32 iOffset, UT_sint32 chg,
88 								  fl_BlockLayout* pBlock=NULL);
89 
_getCount(void)90 	inline UT_sint32		_getCount(void) const
91 		{ return m_vecSquiggles.size(); }
92 
93 	std::vector<fl_PartOfBlockPtr>	m_vecSquiggles;
94 	fl_BlockLayout*			m_pOwner;
95 	FL_SQUIGGLE_TYPE                m_iSquiggleType;
96 };
97 
98 class ABI_EXPORT fl_SpellSquiggles : public fl_Squiggles
99 {
100  public:
101   fl_SpellSquiggles(fl_BlockLayout* pOwner);
102 };
103 
104 class ABI_EXPORT fl_GrammarSquiggles : public fl_Squiggles
105 {
106  public:
107   fl_GrammarSquiggles(fl_BlockLayout* pOwner);
108 };
109 
110 #endif /* FL_SQUIGGLES_H */
111 
112 
113 
114 
115