InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
UserDictWordList.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: hhorton
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //
23 // Proj:
24 //
25 //========================================================================================
26 
27 #ifndef __USERDICTWORDLIST__
28 #define __USERDICTWORDLIST__
29 
30 #include "IUserDictService.h" // for IUserDictService::WordType
31 #include "TextCharBuffer.h"
32 #include "K2Vector.h"
33 #include "ScriptData.h"
34 
35 class IUserDictIterator;
36 
37 #ifdef PUBLIC_BUILD
38 #endif
39  int16 CompareUserDictString(const WideString& a, const WideString& b, bool16 caseSensitive, bool16 stripHyphens);
40 #ifdef PUBLIC_BUILD
41 #endif
42 
43 
50 {
51  public:
53  {}
55  { *this = copy; }
56 
58 
59  UserDictWordList& operator=(const UserDictWordList& other);
60  bool16 operator==(const UserDictWordList& other) const
61  { return fList == other.fList; }
62  bool16 operator!=(const UserDictWordList& other) const
63  { return fList != other.fList; }
64 
65  const WideString& operator[](int32 i) const
66  { return *(fList[i]); }
67 
68  void SetChunkSize(int32 chunk)
69  { fList.reserve(chunk); }
70  bool16 Preallocate(int32 newlen)
71  { fList.reserve(newlen); return kTrue; }
72 
76  void clear();
77 
81  void Clear()
82  { clear(); }
83 
89  void Remove(int32 at)
90  { delete fList[at]; fList.erase(fList.begin() + at); }
91 
97  bool16 InsertUnique(const WideString& t);
98 
104  int32 InsertUserDict(IUserDictService *pService, IUserDict* userDict, IUserDictIterator *dictIter, IUserDictService::WordType type);
105 
111  int32 InsertScriptList( const ScriptListData& scriptWordList );
112 
113  int32 ChunkSize() const
114  { return 8; } //AW_TODO: Possibly deprecate this?
115  int32 Length() const
116  { return (int32)fList.size(); }
117  bool16 IsEmpty() const
118  { return fList.empty(); }
119  const WideString& First() const
120  { return *(fList.front()); }
121  const WideString& Last() const
122  { return *(fList.back()); }
123 
131  int32 ExactLocation(const WideString& t) const;
132 
141  int32 ExactLocation(const textchar *buffer, int32 length) const
142  { WideString str(buffer, length); return ExactLocation(str); }
143 
151  int32 ExactLocation(const TextCharBuffer& wrapper) const
152  { WideString str(wrapper.begin_raw(), wrapper.end_raw()); return ExactLocation(str); }
153 
161  int32 Location(const WideString& t) const;
162 
171  int32 Location(const textchar *buffer, int32 length) const
172  { WideString str(buffer, length); return Location(str); }
173 
181  int32 Location(const TextCharBuffer& wrapper) const
182  { WideString str(wrapper.begin_raw(), wrapper.end_raw()); return Location(str); }
183 
184  void ReadWrite(IPMStream* s);
185 
186  private:
187  // returns position to insert, if not found
188  int32 ExactLocationHint(const WideString& t, bool16& found) const;
189  int32 BasicLocationHint(const WideString& t, bool16& found) const;
190 
191  K2Vector<WideString*> fList;
192 };
193 
194 
195 #endif