InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TextRange.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: zwilliam
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 // Purpose:
24 //
25 //========================================================================================
26 
27 #ifndef __TextRange__
28 #define __TextRange__
29 
30 
31 #include "ITextModel.h"
32 #include "ITextFocus.h"
33 #include "RangeData.h"
34 #include "UIDRef.h"
35 
36 namespace InDesign {
37 
38 
39 class TextRange
40 {
41  public:
42  typedef object_type data_type;
43 
44  TextRange() : fRange(0, RangeData::kLeanForward), fValid(kFalse)
45  {}
46 
47  explicit TextRange(const ITextFocus * focus);
48 
49  TextRange(ITextModel * model, TextIndex start, int32 length, RangeData::Lean lean = RangeData::kLeanForward);
50  TextRange(const UIDRef& modelRef, TextIndex start, int32 length, RangeData::Lean lean = RangeData::kLeanForward);
51  TextRange(ITextModel * model, const RangeData& range);
52 
53  bool operator==(const TextRange&) const
54  { ASSERT_FAIL("appease K2Vector.Location"); return false; }
55 
56  ITextModel * QueryModel() const;
57  UIDRef GetModelRef() const
58  { return fModel; }
59 
60  TextIndex Start() const
61  { return fValid ? fRange.Start(nil) : kInvalidTextIndex; }
62  int32 Length() const
63  { return fValid ? fRange.Length() : 0; }
64  TextIndex End() const
65  { return fValid ? fRange.End() : kInvalidTextIndex; } // One off the end
66 
67  bool16 IsValid() const
68  { return fValid && fModel != nil; }
69 
70  const RangeData& GetRange() const
71  { return fRange; }
72 
73  private:
74  UIDRef fModel;
75  RangeData fRange;
76  bool16 fValid;
77 };
78 
79 }
80 
81 #endif