InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TOCEntryInfo.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Yeming Liu
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 // comments: Helper class to do TOC sorting.
24 //
25 //========================================================================================
26 
27 #ifndef __TOCENTRYINFO__
28 #define __TOCENTRYINFO__
29 
30 // ----- Interface files
31 #include "ITOCCmdData.h"
32 #include "IPMStream.h"
33 
34 // ----- Include files
35 //#include "WideString.h"
36 
40 {
41 public:
42  typedef object_type data_type;
43 
52  const PMString& origStyleName, // style name included in TOC
53  const int32& pageIndex, // index of page
54  const UID& bookContentUID, // if kInvalidUID indicates document scope when create TOC
55  const UID& formatUID, // UID of paragraph style to format TOC entries
56  const PMString& textAnchorName): // text anchor name associated with this TOC entry in source story
57  fOrigStyleName(origStyleName),
58  fPageIndex(pageIndex),
59  fBookContentUID(bookContentUID),
60  fFormatUID(formatUID),
61  fTextAnchorName(textAnchorName) {}
62 
63  PMString fOrigStyleName;
64  int32 fPageIndex;
65  UID fBookContentUID;
66  UID fFormatUID;
67  PMString fTextAnchorName;
68 };
69 
73 {
74  public:
75  typedef object_type data_type;
76 
80 
86  const int32 entryIndex, // entry index that needs runin
87  const WideString& runInSep) : // run in separator
88  fEntryIndex(entryIndex),
89  fRunInSep(runInSep) {}
90 
95  bool16 operator==(const TOCEntryRunInInfo& other) const
96  {
97  return ( (fEntryIndex == other.fEntryIndex) &&
98  (fRunInSep == other.fRunInSep) );
99  }
100 
101  int32 fEntryIndex;
102  WideString fRunInSep;
103 };
104 
109 {
110  public:
111  typedef object_type data_type;
112 
116  fSourceDoc(""),
117  fParaFormatStyle(kInvalidUID),
118  fLevel(1),
119  fLevelSort(kFalse),
120  fPosition(ITOCCmdData::kAfterEntry),
121  fPageNumFormatStyle(kInvalidUID),
122  fSeparatorStyle(kInvalidUID),
123  fRunIn(kFalse),
124  fIncludeSectionName(kTrue)
125  {
126  WideString defaultSep;
127  defaultSep.Append(kTextChar_Tab);
128  fSeparator = defaultSep;
129 
130  WideString defaultRunInSep;
131  defaultRunInSep.Append(kTextChar_Semicolon);
132  fRunInSep = defaultRunInSep;
133  }
134 
149  const PMString& sourceDoc, // document name from the paraFormatStyle from
150  const UID paraFormatStyle, // UID of paragraph style to format TOC entries
151  const int32 level, // level of paragraph style included in TOC
152  const bool16 bSort, // sort flag for paragraph style included in TOC
153  const ITOCCmdData::PageNumPosition position, // position for where page number should be inserted
154  const UID pageNumFormatStyle,// UID of character style to format page number of TOC entry
155  const WideString separator, // separator between TOC entry and page number
156  const UID separatorStyle, // UID of character style to separator of TOC entry
157  const bool16 bRunIn, // run in flag for TOC entry
158  const WideString runInSep, // run in separator
159  const bool16 includeSectionName) : // flag for including section name of page number
160  fSourceDoc(sourceDoc),
161  fParaFormatStyle(paraFormatStyle),
162  fLevel(level),
163  fLevelSort(bSort),
164  fPosition(position),
165  fPageNumFormatStyle(pageNumFormatStyle),
166  fSeparator(separator),
167  fSeparatorStyle(separatorStyle),
168  fRunIn(bRunIn),
169  fRunInSep(runInSep),
170  fIncludeSectionName(includeSectionName){}
171 
176  bool16 operator==(const TOCFormatEntryInfo& other) const
177  {
178  return ( (fSourceDoc == other.fSourceDoc) &&
179  (fParaFormatStyle == other.fParaFormatStyle) &&
180  (fLevel == other.fLevel) &&
181  (fLevelSort == other.fLevelSort) &&
182  (fPosition == other.fPosition) &&
183  (fPageNumFormatStyle == other.fPageNumFormatStyle) &&
184  (fSeparator == other.fSeparator) &&
185  (fSeparatorStyle == other.fSeparatorStyle) &&
186  (fRunIn == other.fRunIn) &&
187  (fRunInSep == other.fRunInSep) &&
188  (fIncludeSectionName == other.fIncludeSectionName) );
189  }
190 
195  {
196  /****************************************************************
197  If this ReadWrite method ever changes you MUST update the schema
198  Converter for kTOCStyleInfoImpl in TOCSchemas.fr. That schema is
199  "unrolling this class because it is written deirectly out in the
200  TOCStyleInfo ReadWrite method. Failure to do this will cause bad
201  things to happen.
202  ****************************************************************/
203  fSourceDoc.ReadWrite(s);
204  s->XferReference(fParaFormatStyle);
205  s->XferInt16(fLevel);
206 
207  // --- Due to the lack of UI to set the fLevelSort now,
208  // there is an assert about CStream::XferBool() not a bool.
209  s->XferBool(fLevelSort);
210 
211  if (s->IsReading())
212  {
213  int16 position(0);
214  s->XferInt16(position);
215  fPosition = static_cast<ITOCCmdData::PageNumPosition>(position);
216  }
217  else
218  {
219  int16 position = static_cast<int16>(fPosition);
220  s->XferInt16(position);
221  }
222 
223  s->XferReference(fPageNumFormatStyle);
224  fSeparator.ReadWrite(s);
225  s->XferReference(fSeparatorStyle);
226  s->XferBool(fRunIn);
227  fRunInSep.ReadWrite(s);
228  s->XferBool(fIncludeSectionName);
229  }
230 
231  PMString fSourceDoc;
232  UID fParaFormatStyle;
233  int16 fLevel;
234  bool16 fLevelSort;
236  UID fPageNumFormatStyle;
237  WideString fSeparator;
238  UID fSeparatorStyle;
239  bool16 fRunIn;
240  WideString fRunInSep;
241  bool16 fIncludeSectionName;
242 };
243 
244 #endif // __TOCENTRYINFO__