InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ITextModel.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: EricM
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 __ITEXTMODEL__
25 #define __ITEXTMODEL__
26 
27 #include "IPMUnknown.h"
28 #include "PMTextUtils.h"
29 #include "TextID.h"
30 #include "WideString.h"
31 #include "K2SmartPtr.h"
32 #include "ErrorUtils.h"
33 #include "ITextFocusManager.h"
34 
35 class ICommand;
36 class AttributeBossList;
37 class ReplaceInfo;
38 class VOS_SavedData;
39 class PasteData;
40 class ILanguage;
41 class IParcel;
42 class ITextStoryThread;
43 class ITextParcelList;
44 class IFrameList;
45 
60 class ITextModel : public IPMUnknown
61 {
62  public:
63  enum { kDefaultIID = IID_ITEXTMODEL };
64 
69  virtual UID GetFrameListUID() const = 0;
70 
74  virtual IFrameList * QueryFrameList() const = 0;
75 
81  virtual UID GetStrandFromClass(ClassID klass) const = 0;
82 
88  virtual IPMUnknown *QueryStrand(ClassID clsID, PMIID faceID) const = 0;
89 
95  virtual IPMUnknown *QueryNthStrand(int32 n, PMIID faceID) const = 0;
96 
106  virtual ErrorCode CopyRange(TextIndex start, int32 length, boost::shared_ptr<PasteData>&pasteData ) = 0;
107 
116  virtual ErrorCode CopyRange(Text::StoryRangeList* list, boost::shared_ptr<PasteData>&pasteData) = 0;
117 
123  virtual void DoForceCompositionDamage(TextIndex start, int32 len) = 0;
124 
131  virtual void DoForceContentDamage(TextIndex start, int32 len) = 0;
132 
133  //-------------------------------------------------------------------------------
135 
136 
139  virtual int32 TotalLength() const = 0;
140 
144  virtual int32 GetPrimaryStoryThreadSpan() const = 0;
145 
146 #ifdef ID_DEPRECATED
147  // 11/26/07 dwaterfa: The ownership of this API, that is, who gets to
148  // set it is unclear. Currently it is owned by InCopy. Our direction
149  // is to remove this InCopy "special" and make them use the new change
150  // counters.
154  virtual bool16 HasChanged() const = 0;
155 #endif
156 
162  virtual uint32 GetTextChangeCount() const = 0;
163 
170  virtual uint32 GetAttrChangeCount() const = 0;
171 
182  virtual uint32 GetOtherChangeCount() const = 0;
183 
191  virtual uint32 GetChangeCount() const = 0;
192 
198  virtual void GetSurroundingParaBoundaries(int32& newstart, int32& newlen) const = 0;
199 
206  virtual bool16 FindStoryThread(UID threadDictUID, uint32 threadDictKey,
207  TextIndex *pStart = nil,
208  int32 *pLen = nil) const = 0;
209 
215  virtual ITextStoryThread* QueryStoryThread(TextIndex at,
216  TextIndex *pStart = nil,
217  int32 *pSpan = nil) const = 0;
218 
225  virtual int32 GetStoryThreadSpan(TextIndex at, TextIndex *pStart,
226  int32 *pSpan = nil) const = 0;
227 
232  virtual RangeData GetStoryThreadRange(TextIndex at) const = 0;
233 
243  virtual UID GetStoryThreadStyle(TextIndex at , TextIndex * pStart = nil, TextIndex * pSpan = nil) const = 0;
244 
249  virtual ITextParcelList* QueryTextParcelList(TextIndex at) const = 0;
251 
252 #ifdef DEBUG
253  //-------------------------------------------------------------------------------
255 
256  virtual void LockModel( bool16 bLock ) = 0;
257  virtual bool16 IsModelLocked() const = 0;
259 #endif
260 
261 public:
262  //-------------------------------------------------------------------------------
269 
270 
278  virtual ErrorCode Insert(TextIndex start, const WideString* data, const ILanguage *language = nil ) = 0;
279 
286  virtual ErrorCode Delete( TextIndex start, int32 len) = 0;
287 
293  virtual ErrorCode Delete(const RangeData& range) = 0;
294 
305  virtual ErrorCode Cut(TextIndex start, int32 len, boost::shared_ptr<PasteData>& pasteData) = 0;
306 
316  virtual ErrorCode Cut(const RangeData& range, boost::shared_ptr<PasteData>& pasteData) = 0;
317 
327  virtual ErrorCode Replace(TextIndex start,
328  int32 len,
329  const WideString *data,
330  const ILanguage *language = nil,
331  bool16 clearNonContinuingAttrs = kTrue) = 0;
332 
340  virtual ErrorCode Paste(TextIndex start, const boost::shared_ptr<PasteData>& data) = 0;
341 
352  virtual ErrorCode ApplyStyle(TextIndex start, int32 len, UID styleref, ClassID which, bool16 destroyAll, bool16 keepOldStyleAsOverrides = kTrue) = 0;
353 
362  virtual ErrorCode ApplyOverrides(TextIndex start, int32 len, const AttributeBossList *these, ClassID which) = 0;
363 
372  virtual ErrorCode ClearOverrides(TextIndex start, int32 length, const AttributeBossList *these, ClassID which) = 0;
373 
389  virtual ErrorCode InsertStoryThread(TextIndex start,
390  UID threadDictUID,
391  uint32 threadDictKey,
392  const WideString* data,
393  const ILanguage* language=nil) = 0;
394 
406  virtual ErrorCode CreateStoryThreads(TextIndex start,
407  UID threadDictUID,
408  const K2Vector<uint32>& threadDictKeyList,
409  const K2Vector<int32>& threadLenList) = 0;
410 
419  virtual ErrorCode JoinStoryThreads(TextIndex start, int32 len) = 0;
420 
426  virtual ErrorCode RegisterStrand(UID strand) = 0;
427 
433  virtual ErrorCode UnregisterStrand(UID strand) = 0;
434 
442  virtual ErrorCode RemoveRedundantOverrides
443  (TextIndex start, int32 len) = 0;
444 
445 #ifdef ID_DEPRECATED
446  // 11/26/07 dwaterfa: The ownership of this API, that is, who gets to
447  // set it is unclear. Currently it is owned by InCopy. Our direction
448  // is to remove this InCopy "special" and make them use the new change
449  // counters.
454  virtual void SetChanged(bool16 changed = kTrue) = 0;
455 #endif
456 
464  virtual uint32 IncrementAttrChangeCount() = 0;
465 
471  virtual uint32 IncrementOtherChangeCount() = 0;
472 
481  {
482  typedef object_type data_type;
483 
485  fPosition(kInvalidTextIndex),
486  fFoundStringLen(0),
487  fReplacementStringLen(0),
488  fReplacementString()
489  {}
490 
492  fPosition(rVal.fPosition),
493  fFoundStringLen(rVal.fFoundStringLen),
494  fReplacementStringLen(rVal.fReplacementStringLen),
495  fReplacementString(rVal.fReplacementString)
496  {}
497 
498  TextIndex fPosition;
499  int32 fFoundStringLen;
500  int32 fReplacementStringLen;
501  boost::shared_ptr<WideString> fReplacementString;
502  };
503 
505 
514  virtual ErrorCode Replace(const boost::shared_ptr<ReplacementList>& replacementList,
515  const ILanguage *language,
516  bool16 clearNonContinuingAttrs = kTrue) = 0;
517  virtual void StartRecordingChanges_ForUndoRedo() = 0;
518  virtual void EndRecordingChanges_ForUndoRedo() = 0;
520 
521 };
522 
523 #endif