InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IHyphenatedWord.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Bernd Paradies
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 
24 #ifndef __IHyphenatedWord__
25 #define __IHyphenatedWord__
26 
27 #include "GRRefCountedObj.h"
28 #include "InterfacePtr.h"
29 
30 #include "K2Vector.h"
31 #include "KeyValuePair.h"
32 
33 
34 class WideString;
35 
36 
43 {
44  typedef base_type data_type;
45 
46  HyphenPoint(int32 pos, int32 val) : nPosition(pos), nValue(val)
47  {}
48 
49  int32 nPosition; // the position of the break.
50  int32 nValue; // the "quality" of the brea.
51 };
52 
57 
58 
59 
65 {
66 public:
69  enum { kNoHyphenPoint = 0,
70  kVeryUnpreferredHyphenPoint = 10,
71  kUnpreferredHyphenPoint = 25,
72  kRegularHyphenPoint = 50,
73  kPreferredHyphenPoint = 75,
74  kDiscretionaryHyphenPoint = 80,
75  kHardHyphenPoint = 90,
76 
77  kBestHyphenPoint = 100,
78  kWorstHyphenPoint = 0,
79  kForcedHyphenPoint = kBestHyphenPoint,
80  kRefusedHyphenPoint = kWorstHyphenPoint,
81 
82  kInvalidHyphenPoint = -1
83  };
84 
85 
88  virtual int32 GetPointCount() const = 0;
89 
93  virtual int32 GetIndexOfPoint( int32 nNthPoint ) const = 0;
94 
98  virtual int32 GetQualityOfPoint( int32 nNthPoint ) const = 0;
99 
102  virtual WideString GetWord() const = 0;
103 
110  virtual void GetPartsOfPoint( int32 nNthPoint, WideString *pFirstPart, WideString *pLastPart ) const = 0;
111 
117  virtual void GetFirstPartOfPoint( int32 nNthPoint, WideString *pPart ) const = 0;
118 
123  virtual void GetLastPartOfPoint( int32 nNthPoint, WideString *pPart ) const = 0;
124 
129  virtual void Merge( const IHyphenatedWord *pToMergeWith ) = 0;
130 
132  virtual void ValidatePointRanges(void) = 0;
133 };
134 
135 
137 template <>
139 {
140 public:
141  InterfacePtr(IHyphenatedWord * pFace = nil) : fFace(pFace)
142  {}
143 
144 // template <class OtherType>
145 // InterfacePtr(const InterfacePtr<OtherType>& p)
146 // :fFace(AddRef_(p.get()))
147 // { /* Implementation Note: we use a template member fucntion here to do the right thing
148 // when an InterfacePtr<const IFoo> is constructed from an InterfacePtr<IFoo> */
149 // }
150 
156  :fFace(AddRef_(p.get())) { }
157 
162  template <class OtherType>
164  {
165  // Take ownership of p
166  reset(AddRef_(p.get()));
167  return *this;
168  /* Implementation Note: we use a template member function here to do the right thing
169  when an InterfacePtr<const IFoo> is constructed from an InterfacePtr<IFoo> */
170  }
171 
177  {
178  // Take ownership of p
179  reset(AddRef_(p.get()));
180  return *this;
181  }
182 
183  ~InterfacePtr()
184  {
185  Release_(fFace);
186  }
187 
188  operator IHyphenatedWord*() const
189  { return fFace; }
190 
191  IHyphenatedWord * operator ->() const
192  {
193  #ifdef DEBUG
194  ASSERT_MSG(fFace != nil,"About to use nil interface ptr!");
195  #endif
196  return fFace;
197  }
198 
199  // Null test
200  bool16 operator!() const
201  { return fFace == nil; }
202 
203  IHyphenatedWord* forget() // was release
204  {
205  IHyphenatedWord* result = fFace;
206  fFace = 0;
207  return result;
208  }
209 
210  IHyphenatedWord* get() const
211  { return fFace; }
212 
213  void reset(IHyphenatedWord* p = 0)
214  {
215  IHyphenatedWord* oldFace = fFace;
216  fFace = p;
217  Release_(oldFace);
218  }
219 
220 private:
221  IHyphenatedWord * fFace;
222 
223  static IHyphenatedWord* AddRef_(const IHyphenatedWord* p)
224  { if(p) p->AddRef(); return const_cast<IHyphenatedWord*>(p);}
225 
226  static void Release_(IHyphenatedWord* p)
227  { if(p) p->Release(); }
228 
231  template <class OtherType>
232  InterfacePtr<IHyphenatedWord>& operator=(OtherType* p); // intentionally unimplemented
233 };
234 
235 #endif
236  // __IHyphenatedWord__
237