InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IRunInStylesUtils.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Eric Menninga
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 __IRunInStylesUtils__
25 #define __IRunInStylesUtils__
26 
27 #include "IPMUnknown.h"
28 
29 #include "K2Vector.h"
30 #include "TextID.h"
31 
32 
33 class ITextModel;
34 class ICompositionStyle;
35 class WideString;
36 class PMString;
37 
38 
40 {
41  public:
43 
44  RunInStyleResult() : fLength(0), fLineRuleIndex(-1), fLinesCount(0)
45  { }
46  RunInStyleResult(UID cs, int32 len) : fLength(len), fLineRuleIndex(-1), fLinesCount(0)
47  { fCharStyles.push_back(cs); }
48  RunInStyleResult(UID cs, int32 len, int32 ndx, int32 lc) : fLength(len), fLineRuleIndex(ndx), fLinesCount(lc)
49  { fCharStyles.push_back(cs); }
50  RunInStyleResult(const CharStyleList& cs, int32 len, int32 ndx, int32 lc) : fLength(len), fLineRuleIndex(ndx), fLinesCount(lc)
51  { fCharStyles = cs; }
52 
53  UID CharStyle(uint32 i) const
54  { return (i < fCharStyles.size()) ? fCharStyles[i] : kInvalidUID; }
55  CharStyleList& CharStyles()
56  { return fCharStyles; }
57  const CharStyleList& CharStyles() const
58  { return fCharStyles; }
59 
60  int32 Length() const
61  { return fLength; }
62  int32& Length()
63  { return fLength; }
64 
65  int32 LineRuleIndex() const
66  { return fLineRuleIndex; }
67  int16& LineRuleIndex()
68  { return fLineRuleIndex; }
69 
70  int32 LinesCount() const
71  { return fLinesCount; }
72  int16& LinesCount()
73  { return fLinesCount; }
74 
75  typedef object_type data_type;
76  private:
77  CharStyleList fCharStyles;
78  int32 fLength;
79  int16 fLineRuleIndex;
80  int16 fLinesCount;
81 };
82 
89 class RunInStyleResults : public K2Vector<RunInStyleResult>
90 {
91 public:
92  void Append(UID cs, int32 len, int32 lineRule, int32 linesCount)
93  {
94  if (empty() || back().LineRuleIndex() != lineRule)
95  push_back(RunInStyleResult(cs, len, lineRule, linesCount));
96  else
97  {
98  const RunInStyleResult::CharStyleList& list = back().CharStyles();
99  if (list.empty() || list.size() > 1 || list[0] != cs)
100  push_back(RunInStyleResult(cs, len, lineRule, linesCount));
101  else
102  back().Length() += len;
103  }
104  }
105 
106  void Append(UID cs, int32 len)
107  {
108  if (empty() || back().LineRuleIndex() >= 0)
109  push_back(RunInStyleResult(cs, len));
110  else
111  {
112  const RunInStyleResult::CharStyleList& list = back().CharStyles();
113  if (list.empty() || list.size() > 1 || list[0] != cs)
114  push_back(RunInStyleResult(cs, len));
115  else
116  back().Length() += len;
117  }
118  }
119 
120  void RemoveFirst()
121  { erase(begin(), begin() + 1); }
122 };
123 
124 
130 {
131  public:
132  enum { kDefaultIID = IID_IRUNINSTYLESUTILS };
133 
151 // enum HandleUncomposedNestedLines { kIgnoreNestedLines, kRestOfParagraphNestedLines };
152  virtual bool16 ParseParagraphForRunInStyles(const ITextModel *model, TextIndex position,
153  const ICompositionStyle *paragraphStyle, RunInStyleResults& results, //HandleUncomposedNestedLines lines = kIgnoreNestedLines,
154  int32 *pParagraphLengthLeft = nil, bool16 moveBackwards = kFalse) = 0;
155 
163  virtual void MapExpressionToPMString(const WideString& expression, PMString *pOutput, int32 *pCount, bool16 *pInclusive) = 0;
164 
171  virtual void MapPMStringToExpression(const PMString& nicePhrase, int32 count, bool16 inclusive, WideString *pExpression) = 0;
172 
178  virtual bool16 ToggleExpressionInclusion(const WideString& original, WideString *pToggled) = 0;
179 
186  virtual int32 CalculateDropCapCount(const TextIterator& beginPosition, int16 baseCharCount, WideString * dcText) = 0;
187 };
188 
189 
190 #endif // __IRunInStylesUtils__