InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ITextModel Class Referenceabstract

#include <ITextModel.h>

Inheritance diagram for ITextModel:
IPMUnknown

Classes

struct  SingleReplacementInfo
 

Public Types

enum  { kDefaultIID = IID_ITEXTMODEL }
 

Public Member Functions

virtual UID GetFrameListUID () const =0
 
virtual IFrameListQueryFrameList () const =0
 
virtual UID GetStrandFromClass (ClassID klass) const =0
 
virtual IPMUnknownQueryStrand (ClassID clsID, PMIID faceID) const =0
 
virtual IPMUnknownQueryNthStrand (int32 n, PMIID faceID) const =0
 
virtual ErrorCode CopyRange (TextIndex start, int32 length, boost::shared_ptr< PasteData > &pasteData)=0
 
virtual ErrorCode CopyRange (Text::StoryRangeList *list, boost::shared_ptr< PasteData > &pasteData)=0
 
virtual void DoForceCompositionDamage (TextIndex start, int32 len)=0
 
virtual void DoForceContentDamage (TextIndex start, int32 len)=0
 
Retrieve data functions
virtual int32 TotalLength () const =0
 
virtual int32 GetPrimaryStoryThreadSpan () const =0
 
virtual uint32 GetTextChangeCount () const =0
 
virtual uint32 GetAttrChangeCount () const =0
 
virtual uint32 GetOtherChangeCount () const =0
 
virtual uint32 GetChangeCount () const =0
 
virtual void GetSurroundingParaBoundaries (int32 &newstart, int32 &newlen) const =0
 
virtual bool16 FindStoryThread (UID threadDictUID, uint32 threadDictKey, TextIndex *pStart=nil, int32 *pLen=nil) const =0
 
virtual ITextStoryThreadQueryStoryThread (TextIndex at, TextIndex *pStart=nil, int32 *pSpan=nil) const =0
 
virtual int32 GetStoryThreadSpan (TextIndex at, TextIndex *pStart, int32 *pSpan=nil) const =0
 
virtual RangeData GetStoryThreadRange (TextIndex at) const =0
 
virtual UID GetStoryThreadStyle (TextIndex at, TextIndex *pStart=nil, TextIndex *pSpan=nil) const =0
 
virtual ITextParcelListQueryTextParcelList (TextIndex at) const =0
 
- Public Member Functions inherited from IPMUnknown
virtual IPMUnknownQueryInterface (PMIID interfaceID) const =0
 
virtual void AddRef () const =0
 
virtual void Release () const =0
 

Text operations

The following functions perform specific text operations. The parameter is false when the client wants irreversible changes. The case of parameter true is currently exclusive to internal use. ErrorCode returns the global error state which may be set if embedded commands fail.

typedef K2Vector
< SingleReplacementInfo
ReplacementList
 
virtual ErrorCode Insert (TextIndex start, const WideString *data, const ILanguage *language=nil)=0
 
virtual ErrorCode Delete (TextIndex start, int32 len)=0
 
virtual ErrorCode Delete (const RangeData &range)=0
 
virtual ErrorCode Cut (TextIndex start, int32 len, boost::shared_ptr< PasteData > &pasteData)=0
 
virtual ErrorCode Cut (const RangeData &range, boost::shared_ptr< PasteData > &pasteData)=0
 
virtual ErrorCode Replace (TextIndex start, int32 len, const WideString *data, const ILanguage *language=nil, bool16 clearNonContinuingAttrs=kTrue)=0
 
virtual ErrorCode Paste (TextIndex start, const boost::shared_ptr< PasteData > &data)=0
 
virtual ErrorCode ApplyStyle (TextIndex start, int32 len, UID styleref, ClassID which, bool16 destroyAll, bool16 keepOldStyleAsOverrides=kTrue)=0
 
virtual ErrorCode ApplyOverrides (TextIndex start, int32 len, const AttributeBossList *these, ClassID which)=0
 
virtual ErrorCode ClearOverrides (TextIndex start, int32 length, const AttributeBossList *these, ClassID which)=0
 
virtual ErrorCode InsertStoryThread (TextIndex start, UID threadDictUID, uint32 threadDictKey, const WideString *data, const ILanguage *language=nil)=0
 
virtual ErrorCode CreateStoryThreads (TextIndex start, UID threadDictUID, const K2Vector< uint32 > &threadDictKeyList, const K2Vector< int32 > &threadLenList)=0
 
virtual ErrorCode JoinStoryThreads (TextIndex start, int32 len)=0
 
virtual ErrorCode RegisterStrand (UID strand)=0
 
virtual ErrorCode UnregisterStrand (UID strand)=0
 
virtual ErrorCode RemoveRedundantOverrides (TextIndex start, int32 len)=0
 
virtual uint32 IncrementAttrChangeCount ()=0
 
virtual uint32 IncrementOtherChangeCount ()=0
 
virtual ErrorCode Replace (const boost::shared_ptr< ReplacementList > &replacementList, const ILanguage *language, bool16 clearNonContinuingAttrs=kTrue)=0
 
virtual void StartRecordingChanges_ForUndoRedo ()=0
 
virtual void EndRecordingChanges_ForUndoRedo ()=0
 

Detailed Description

This is the main interface for a text story. It has the following responsibilities:

  1. Strand management: a story is represented by multiple strands of data Text, Paragraph Attrs, Character Attrs, Story Thread, etc. Each strand is a separate boss, made available here.
  2. Copying selections: a range can be copied into a fairly raw format PasteData that is pretty implementation restricted
  3. The actual functions for major operations (insert, delete, paste, apply) are here.
  4. A couple of misc functions: TotalLength() - number of chars in story including the non-editable, must-have carriage return at the end.

Note: use ITextModelCmds to get to text edit commands.

Member Function Documentation

virtual ErrorCode ITextModel::ApplyOverrides (TextIndex start,
int32 len,
const AttributeBossListthese,
ClassID which 
)
pure virtual

Apply attribute boss list to a range.

Parameters
startIN start of apply range.
lenIN length of apply range.
theseIN attribute boss list to apply.
whichIN indicates whether the applied attributes are paragraph or character attributes.
Returns
whether the operation succeeded or failed.
virtual ErrorCode ITextModel::ApplyStyle (TextIndex start,
int32 len,
UID styleref,
ClassID which,
bool16 destroyAll,
bool16 keepOldStyleAsOverrides = kTrue 
)
pure virtual

Apply style to a range.

Parameters
startIN start of apply range.
lenIN length of apply range.
stylerefIN style to apply.
whichIN whether this is a character or a paragraph style.
destroyAllIN whether overrides must be removed along with the application of the style.
keepOldStyleAsOverridesIN whether to apply current style as overrides before setting new style.
Returns
whether the operation succeeded or failed.
virtual ErrorCode ITextModel::ClearOverrides (TextIndex start,
int32 length,
const AttributeBossListthese,
ClassID which 
)
pure virtual

Clear attribute boss list from range.

Parameters
startIN start of clear range.
lengthIN length of clear range.
theseIN attribute boss list to clear.
whichIN whether the attributes to clear are paragraph or character attributes.
Returns
whether the operation succeeded or failed.
virtual ErrorCode ITextModel::CopyRange (TextIndex start,
int32 length,
boost::shared_ptr< PasteData > & pasteData 
)
pure virtual

Takes data from the model to store it in a stream (clipboard, database, ...)

Parameters
startIN start of copy range.
lengthIN length of copy range.
pasteDataOUT is the copied data. It should be used by caller to paste the data somewhere else in the same story, another story in the same document, or another story in another document. pasteData is a shared pointer.
See Also
K2SmartPtr.h for usage of shared_ptr.
Returns
error code
virtual ErrorCode ITextModel::CopyRange (Text::StoryRangeListlist,
boost::shared_ptr< PasteData > & pasteData 
)
pure virtual

Takes data from the model to store it in a stream (clipboard, database, ...)

Parameters
listIN list of ranges to copy from.
pasteDataOUT is the copied data. It should be used by caller to paste the data somewhere else in the same story, another story in the same document, or another story in another document. pasteData is a shared pointer.
See Also
K2SmartPtr.h for usage of shared_ptr.
Returns
error code
virtual ErrorCode ITextModel::CreateStoryThreads (TextIndex start,
UID threadDictUID,
const K2Vector< uint32 > & threadDictKeyList,
const K2Vector< int32 > & threadLenList 
)
pure virtual

Create one or more StoryThreads sharing the same Dictionary uid There are a few restrctions: start must be > 1. There must be a CR at (start - 1). Each threadLenList[] value must be at least 1 and there must be a CR at the end of each new StoryThread. This method does not change the length of the TextModel.

Parameters
startIN insert position.
threadDictUIDIN thread disctionary uid.
threadDictKeyListIN story thread key list.
threadLenListIN story thread length list.
Returns
whether the operation succeeded or failed.
virtual ErrorCode ITextModel::Cut (TextIndex start,
int32 len,
boost::shared_ptr< PasteData > & pasteData 
)
pure virtual

Cut range of text from story.

Parameters
startIN start of cut range.
lenIN length of cut range.
pasteDataOUT is the cut data. It should be used by caller to paste the data somewhere else in the same story, another story in the same document, or another story in another document. pasteData is a shared pointer.
See Also
K2SmartPtr.h for usage of shared_ptr.
Returns
whether the operation succeeded or failed.
virtual ErrorCode ITextModel::Cut (const RangeDatarange,
boost::shared_ptr< PasteData > & pasteData 
)
pure virtual

Cut range of text from story.

Parameters
rangeIN cut range.
pasteDataOUT is the cut data. It should be used by caller to paste the data somewhere else in the same story, another story in the same document, or another story in another document. pasteData is a shared pointer.
See Also
K2SmartPtr.h for usage of shared_ptr.
Returns
whether the operation succeeded or failed.
virtual ErrorCode ITextModel::Delete (TextIndex start,
int32 len 
)
pure virtual

Delete text range from story

Parameters
startIN range start.
lenIN range len.
Returns
whether the operation succeeded or failed.
virtual ErrorCode ITextModel::Delete (const RangeDatarange)
pure virtual

Delete text range.

Parameters
rangeIN range to delete.
Returns
whether the operation succeeded or failed.
virtual void ITextModel::DoForceCompositionDamage (TextIndex start,
int32 len 
)
pure virtual

Forces recomposition within a range. Most operations do this automatically, sometimes damage must be forced. e.g. dragging an inline graphic.

Parameters
startIN start of recomposition range.
lenIN length of recomposition range.
virtual void ITextModel::DoForceContentDamage (TextIndex start,
int32 len 
)
pure virtual

Forces recomposition within a range. Most operations do this automatically, sometimes damage must be forced. e.g. dragging an inline graphic. Incase where we do not want to delete wax line and merely want to invalidate so that it will be reconsidered for composition

Parameters
startIN start of recomposition range.
lenIN length of recomposition range.
virtual bool16 ITextModel::FindStoryThread (UID threadDictUID,
uint32 threadDictKey,
TextIndex * pStart = nil,
int32 * pLen = nil 
) const
pure virtual

Gets the offset boundaries of a storythread.

Parameters
threadDictUIDIN thread disctionary uid.
threadDictKeyIN, thread dictionary key.
pStartOUT start of range
pSpanOUT span of range.
virtual uint32 ITextModel::GetAttrChangeCount () const
pure virtual

The TextModel maintains a counter that will be incremented whenever the effective attribute applied to any chracters may have changed. This includes changes to applied styles and overrides.

Returns
Current counter value for Char/Para Attribute Strand changes
virtual uint32 ITextModel::GetChangeCount () const
pure virtual

The TextModel maintains a counter that will be incremented for any change to the above counters, be it Text, Attribute or Other. This is intended to simplify most clients who are not interested in particular details.

Returns
Current counter value for all changes
virtual UID ITextModel::GetFrameListUID () const
pure virtual

Returns the wax strand (a.k.a frame list) uid. The frame list is set by registering the frame list boss as a strand.

virtual uint32 ITextModel::GetOtherChangeCount () const
pure virtual

The TextModel maintains a counter that should be changed by entities which are associated with the TextModel, such as Inlines, Tables, etc, when some appropriate aspect of them changes. An easy example of this is Tables - a change to a Table stroke does represent an effective change to the TextModel, that is an export of the contents of the TextModel will be different after the change than before the change - and so the TableModel will use this counter to signal change.

Returns
Current counter value for Non Text and Char/Para Attribute Strand changes
virtual int32 ITextModel::GetPrimaryStoryThreadSpan () const
pure virtual

Returns the total number of characters in the primary story thread. (It does not include any characters that are part of story threads for table cells.)

virtual RangeData ITextModel::GetStoryThreadRange (TextIndex at) const
pure virtual

Returns range of storythread

Parameters
atIN text index where to look for storythread.
virtual int32 ITextModel::GetStoryThreadSpan (TextIndex at,
TextIndex * pStart,
int32 * pSpan = nil 
) const
pure virtual

Gets the range of a storythread

Parameters
atIN text index where to look for storythread.
pStartOUT start of storythread range.
pSpanOUT length of storythread range.
virtual UID ITextModel::GetStoryThreadStyle (TextIndex at,
TextIndex * pStart = nil,
TextIndex * pSpan = nil 
) const
pure virtual

Returns the story thread style at a particular index (a UID for an object that implements ITextAttributes). Optionally a start and a span are returned through runStart and runSpan. This start and span forms a run of adjoining story threads that have the same story thread styles.

Parameters
atIN The index to get the story thread style for.
pStartOUT the index this story thread style begins being good for.
pSpanOUT how far from runStart is this story thread applied.
virtual UID ITextModel::GetStrandFromClass (ClassID klass) const
pure virtual

Returns the UID of the strand attached to the model that has a particular class. kInvalidUID is returned when no such a strand is found.

Parameters
klassIN strand class.
virtual void ITextModel::GetSurroundingParaBoundaries (int32 & newstart,
int32 & newlen 
) const
pure virtual
Returns the boundaries of the wrapping paragraph.

Parameters
newstartIN specifies a position to look for paragraph boundaries. This argument is also an out argument. It returns the actual start of the paragraph.
newlenOUT returns the actual length of the paragraph.
virtual uint32 ITextModel::GetTextChangeCount () const
pure virtual

The TextModel maintains a counter that will be incremented whenever a character is inserted, removed or replaced in the TextModel.

Returns
Current counter value for Text Strand changes
virtual uint32 ITextModel::IncrementAttrChangeCount ()
pure virtual

Increments the changed counter associated with Char/Para Attr changes. The TextModel will handle this internally for normal sorts of applies but actions that take place outside the view of the TextModel, such as Style deletion, must result in a call to this method.

Returns
The previous value of the attr changed counter
virtual uint32 ITextModel::IncrementOtherChangeCount ()
pure virtual

Increments the change counter associated with non Text and Char/Para Attr changes.

Returns
The previous value of the other change counter
virtual ErrorCode ITextModel::Insert (TextIndex start,
const WideStringdata,
const ILanguagelanguage = nil 
)
pure virtual

Insert string at a text index.

Parameters
startIN insert position.
dataIN string to insert.
languageIN language of text inserted.
Returns
whether the operation succeeded or failed.
virtual ErrorCode ITextModel::InsertStoryThread (TextIndex start,
UID threadDictUID,
uint32 threadDictKey,
const WideStringdata,
const ILanguagelanguage = nil 
)
pure virtual

Insert a new StoryThread. There are a few restrictions : start must be the first TextIndex after an existing StoryThread. This means you are either inserting at the beginning of any StoryThread other than the one at TextIndex 0 or you are at the end of the TextModel (at TotalLength()). Note that this is the only permitted way to insert past the end of the TextModel.

Parameters
startIN insert position.
threadDictUIDIN thread disctionary uid.
threadDictKeyIN, thread dictionary key.
dataIN string to insert.
languageIN of inserted string. It must end with a carriage return.
Returns
whether the operation succeeded or failed.
virtual ErrorCode ITextModel::JoinStoryThreads (TextIndex start,
int32 len 
)
pure virtual

The inverse of CreateStoryThread. The span of the joined StoryThread(s) are given back to the preceding StoryThread. This method does not change the length of the TextModel.

Parameters
startIN start join range.
lenIN length of join range.
Returns
whether the operation succeeded or failed.
virtual ErrorCode ITextModel::Paste (TextIndex start,
const boost::shared_ptr< PasteData > & data 
)
pure virtual

Paste data into story.

Parameters
startIN insertion position.
dataIN paste data to insert. data is a shared pointer.
See Also
K2SmartPtr.h for usage of shared_ptr.
Returns
whether the operation succeeded or failed.
virtual IFrameList* ITextModel::QueryFrameList () const
pure virtual

Returns a pointer to the wax strand boss.

virtual IPMUnknown* ITextModel::QueryNthStrand (int32 n,
PMIID faceID 
) const
pure virtual

Returns a pointer to an interface on the Nth strand attached to the model.

Parameters
nIN strand index.
faceIDIN id of an interface on the strand boss. When faceID is equal IID_IUNKNOWN, a pointer to the strand boss is returned.
virtual ITextStoryThread* ITextModel::QueryStoryThread (TextIndex at,
TextIndex * pStart = nil,
int32 * pSpan = nil 
) const
pure virtual

Returns a pointer to the storythread at a particular text index

Parameters
atIN text index where to look for storythread.
pStartOUT start of storythread range.
pSpanOUT length of storythread range.
virtual IPMUnknown* ITextModel::QueryStrand (ClassID clsID,
PMIID faceID 
) const
pure virtual

Returns a pointer to an interface on the strand attached to the model that has a particular class.

Parameters
clsIDIN strand class.
faceIDIN id of an interface on the strand boss. When faceID is equal IID_IUNKOWN, a pointer to the strand boss is returned.
virtual ITextParcelList* ITextModel::QueryTextParcelList (TextIndex at) const
pure virtual

Returns a pointer to the text parcel list at an offset.

Parameters
atIN text index to look for parcel list.
virtual ErrorCode ITextModel::RegisterStrand (UID strand)
pure virtual

Attach strand to text model.

Parameters
strandIN strand uid.
Returns
whether the operation succeeded or failed.
virtual ErrorCode ITextModel::RemoveRedundantOverrides (TextIndex start,
int32 len 
)
pure virtual

Remove redundant overrides from range. These are the overrides that have no effect because they exist in the applied styles.

Parameters
startIN range start
lenIN range length.
Returns
whether the operation succeeded or failed.
virtual ErrorCode ITextModel::Replace (TextIndex start,
int32 len,
const WideStringdata,
const ILanguagelanguage = nil,
bool16 clearNonContinuingAttrs = kTrue 
)
pure virtual

Replace text in a range

Parameters
startIN replace range start.
lenIN replace range length.
dataIN replacement string.
languageIN replacement string language.
clearNonContinuingAttrsIN whether non-continuing attributes should be cleared after insert.
Returns
whether the operation succeeded or failed.
virtual ErrorCode ITextModel::Replace (const boost::shared_ptr< ReplacementList > & replacementList,
const ILanguagelanguage,
bool16 clearNonContinuingAttrs = kTrue 
)
pure virtual

Used to perform a set of replacements on the text model. This is an optmized form for doing multiple replacements. The list of ranges must be in ascending text index order.

Parameters
replacementListIN list of ranges and replacement strings. This is a shared_ptr.
See Also
K2SmartPtr.h for usage of shared_ptr.
Returns
whether the operation succeeded or failed.
virtual int32 ITextModel::TotalLength () const
pure virtual

Returns the total number of characters in the text model (including data for embedded tables).

virtual ErrorCode ITextModel::UnregisterStrand (UID strand)
pure virtual

Detach strand from text model.

Parameters
strandIN strand uid.
Returns
whether the operation succeeded or failed.