InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Strand.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: robin briggs
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 __STRAND__
25 #define __STRAND__
26 
27 #include "IStrand.h"
28 #include "HelperInterface.h"
29 #include "CPMUnknown.h"
30 #include "VOSSavedData.h"
31 #include "IStrandPastePiece.h"
32 
33 class StrandPastePiece;
34 
35 
36 #ifdef PUBLIC_BUILD
37 #endif
38 
39 class Strand : public IStrand
40 {
41  public:
42  Strand(IPMUnknown *boss);
43 
44  virtual UID CreatePage () = 0;
45  virtual UID GetFirstPage();
46  virtual UID SetFirstPage(UID firstPage);
47 
48  virtual ClassID GetObjectClass() const = 0;
49 
50  virtual ICommand* QueryRemoveFromDocumentCmd(UID textModelUID);
51 
52  // hardly any strands will care about damage. This does nothing
53  virtual void ForceCompositionDamage(TextIndex position, int32 numChars);
54  // hardly any strands will care about damage. This does nothing
55  virtual void ForceContentDamage(TextIndex position, int32 numChars){}
56 
57  virtual UID GetOwningStoryUID() const;
58  virtual void StrandAttachedToStory(UID textModelUID, int32 length);
59  virtual void StrandDetachedFromStory(UID textModelUID);
60 
61  virtual void InsertStoryThread(UID dictUID, uint32 dictKey,
62  const WideString* data, TextIndex pos);
63  virtual bool16 CreateStoryThreads(UID dictUID,
64  const K2Vector<uint32>& dictKeyList,
65  const K2Vector<int32>& lenList,
66  TextIndex pos);
67  virtual bool16 JoinStoryThreads(TextIndex start, int32 len);
68  virtual void IncreaseSpan(TextIndex at, int32 len);
69 
70  virtual void CollectMementosForDelete(TextIndex pos, int32 len,
71  MementoList& list)
72  { CollectMementos(pos, len, list); }
73  virtual void CollectMementosForCut(TextIndex pos, int32 len,
74  MementoList& list)
75  { CollectMementos(pos, len, list); }
76  virtual void CollectMementosForCopyRange(TextIndex pos, int32 len,
77  MementoList& list) const
78  { CollectMementos(pos, len, list); }
79  virtual void CollectMementosForReplace(TextIndex pos, int32 len,
80  MementoList& list)
81  { CollectMementos(pos, len, list); }
82 
83  virtual void Delete(TextIndex startpos, int32 numchars);
84  virtual void Replace(const boost::shared_ptr<ITextModel::ReplacementList >& replList, bool16 clearNonContinuingAttrs);
85  void ReadWrite(IPMStream *s, ImplementationID prop);
86 
87  protected:
88  UID CreatePage (ClassID pageClass);
89 
90  virtual void CollectMementos(TextIndex pos, int32 len,
91  MementoList& list) const;
92 
93  UID fStoryUID;
94 
95  private:
96  UID fFirstPage;
97 
98 
99 };
100 
101 
102 
103 class StrandPastePiece : public CPMUnknown<IStrandPastePiece>
104 {
105  public:
108  fVOSData(nil)
109  { }
110 
111  virtual ~StrandPastePiece()
112  { if (fVOSData) delete fVOSData; }
113 
114  //
115  // Inherited methods.
116  //
117  virtual ClassID GetStrandClassID() const
118  { return fStrandID; }
119 
120  virtual ErrorCode OnCopyRange()
121  { return fVOSData? fVOSData->OnCopy() : kSuccess; }
122 
123  virtual ErrorCode PreTransferTo(PasteDataXRefContext* xRefC)
124  { return fVOSData? fVOSData->PreTransferTo(xRefC) : kSuccess; }
125 
126  virtual ErrorCode TransferTo(PasteDataXRefContext* xRefC)
127  { return fVOSData? fVOSData->TransferTo(xRefC) : kSuccess; }
128 
129  virtual ErrorCode OnPaste()
130  { return fVOSData? fVOSData->OnPaste() : kSuccess; }
131 
132  //
133  // Additional methods.
134  //
135  virtual void SetStrandClassID(ClassID strandID)
136  { fStrandID = strandID; }
137  virtual void SetVOSData(VOS_SavedData *d)
138  {
139  if (fVOSData)
140  delete fVOSData;
141  fVOSData = d;
142  }
143 
144  virtual VOS_SavedData* PeekVOSData() const
145  { return fVOSData; }
146 
147  protected:
148  ClassID fStrandID;
149  VOS_SavedData* fVOSData;
150 };
151 
152 // pre-2.0 IStrand implementations that derived from Strand only persisted
153 // the fFirstPage field. This conversion adds in a kInvalidUID fStoryUID
154 // field which will be initialized by a phase2 conversion call to
155 // IStrand::StrandAttachedToStory(newStoryUID, 0) from the Text plugin.
156  void ConvertCStrandImpl(IPMStream* inStream, IPMStream* outStream);
157 
158 
159 #ifdef PUBLIC_BUILD
160 #endif
161 
162 
163 #endif // __STRAND__