InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SnpTextModelHelper Class Reference

#include <SnpTextModelHelper.h>

Public Member Functions

 SnpTextModelHelper ()
 
virtual ~SnpTextModelHelper ()
 
ErrorCode InsertText (ITextModel *textModel, const TextIndex position, const boost::shared_ptr< WideString > &text)
 
ErrorCode DeleteText (ITextModel *textModel, const TextIndex position, const int32 length)
 
ErrorCode ReplaceText (ITextModel *textModel, const TextIndex position, const int32 length, const boost::shared_ptr< WideString > &text)
 
ErrorCode ApplyOverrides (ITextModel *textModel, const TextIndex position, const int32 length, const boost::shared_ptr< AttributeBossList > &attr, ClassID whichStrand)
 
ErrorCode ClearOverrides (ITextModel *textModel, const TextIndex position, const int32 length, const boost::shared_ptr< AttributeBossList > &attr, ClassID whichStrand)
 
ErrorCode ProcessCopyStoryRangeCmd (const UIDRef &sourceStory, TextIndex sourceStart, int32 sourceLength, const UIDRef &destStory, TextIndex destStart, int32 destLength)
 
bool16 IsStoryOverset (InterfacePtr< ITextModel > textModel)
 
bool16 IsTextFrameOverset (const InterfacePtr< ITextFrameColumn > textFrameColumn)
 
bool16 IsParcelOverset (const InterfacePtr< IParcel > parcel)
 
IParcelQueryParcelContaining (ITextModel *textModel, const TextIndex at)
 
InDesign::TextRange GetParcelTextRange (IParcel *parcel)
 
WideString GetWideStringFromTextRange (const InDesign::TextRange &range)
 
WideString GetWideStringFromParcel (IParcel *parcel)
 

Detailed Description

  • Provide helper method to insert, replace, delete text in a story using ITextModelCmds.
  • Provide helper method to apply/clear text attributes overrides using ITextModelCmds.
  • Provide helper method to copy text from one story to another using kCopyStoryRangeCmdBoss.
  • Provide helper method to detect if a story or parcel is overset.
  • Provide helper method to determine that parcel that displays a given TextIndex.
  • Provide helper method to determine the range of characters displayed by a parcel.
See Also
ITextModel
ITextModelCmds
IParcel
IParcelList
ITextParcelList
ITextParcelListComposer

Constructor & Destructor Documentation

SnpTextModelHelper::SnpTextModelHelper ()

Constructor.

SnpTextModelHelper::~SnpTextModelHelper ()
virtual

Destructor

Member Function Documentation

ErrorCode SnpTextModelHelper::ApplyOverrides (ITextModeltextModel,
const TextIndex position,
const int32 length,
const boost::shared_ptr< AttributeBossList > & attr,
ClassID whichStrand 
)

Apply paragraph alignment, the point size, leading and underline overrides using ITextModelCmds::ApplyCmd.

Parameters
textModelof story to be changed.
positionindex of first character to be formatted.
lengthnumber of characters to be formatted.
attrattribute boss lists that contains the point size, leading and underline overrides we want to apply here.
whichStrandwhich strand this attribute overrides are to apply, it has to be either kParaAttrStrandBoss or kCharAttrStrandBoss.
Returns
kSuccess on success, other ErrorCode otherwise.
ErrorCode SnpTextModelHelper::ClearOverrides (ITextModeltextModel,
const TextIndex position,
const int32 length,
const boost::shared_ptr< AttributeBossList > & attr,
ClassID whichStrand 
)

Clear paragraph alignment, character point size, leading and underline overrides using ITextModelCmds::ApplyCmd.

Parameters
textModelof story to be changed.
positionindex of first character to be formatted.
lengthnumber of characters to be formatted.
attrattribute boss lists that contains the point size, leading and underline overrides we want to clear here.
whichStrandwhich strand this attribute overrides are to apply, it has to be either kParaAttrStrandBoss or kCharAttrStrandBoss.
Returns
kSuccess on success, other ErrorCode otherwise.
ErrorCode SnpTextModelHelper::DeleteText (ITextModeltextModel,
const TextIndex position,
const int32 length 
)

Delete text from a story using ITextModelCmds::DeleteCmd.

Parameters
textModelof story to be changed.
positionindex first character to be deleted.
lengthnumber of characters to be deleted.
Returns
kSuccess on success, other ErrorCode otherwise.
InDesign::TextRange SnpTextModelHelper::GetParcelTextRange (IParcelparcel)

Return the range of text displayed by the given parcel.

Parameters
parcel
Returns
the range of text displayed by the given parcel.
WideString SnpTextModelHelper::GetWideStringFromParcel (IParcelparcel)

Return string containing the text displayed in the given parcel.

Parameters
parcelspecifies the object whose text is wanted.
Returns
string containing the text displayed in the given parcel.
WideString SnpTextModelHelper::GetWideStringFromTextRange (const InDesign::TextRangerange)

Return string containing the given range of text from the text model.

Parameters
rangespecifies the text model and range of characters wanted.
Returns
string containing the given range of text from the text model.
ErrorCode SnpTextModelHelper::InsertText (ITextModeltextModel,
const TextIndex position,
const boost::shared_ptr< WideString > & text 
)

Insert text into a story using ITextModelCmds::InsertCmd.

Parameters
textModelof story to be changed.
positionindex at which insertion to be made.
textto be inserted.
Returns
kSuccess on success, other ErrorCode otherwise.
bool16 SnpTextModelHelper::IsParcelOverset (const InterfacePtr< IParcelparcel)

Detect if a parcel is overset.

bool16 SnpTextModelHelper::IsStoryOverset (InterfacePtr< ITextModeltextModel)

Detect if the text in a story is overset via ITextUtils::IsOverset.

Parameters
textModelfor story to be tested.
Returns
kTrue if overset, kFalse otherwise.
See Also
ITextUtils::IsOverset
bool16 SnpTextModelHelper::IsTextFrameOverset (const InterfacePtr< ITextFrameColumntextFrameColumn)

Detect if a text frame is overset. When a frame is not large enough to show all of the remaining characters of the the story it displays it is considered by this method as overset.

ErrorCode SnpTextModelHelper::ProcessCopyStoryRangeCmd (const UIDRefsourceStory,
TextIndex sourceStart,
int32 sourceLength,
const UIDRefdestStory,
TextIndex destStart,
int32 destLength 
)

Process kCopyStoryRangeCmdBoss to copy a given range of text from the source story to the destination story. By specifying a destLength

0 the text copied from the source story can replace text in the

destination story. The sourceStory and destStory UIDRefs can refer to the same story if text is to be copied around inside a story or they can refer to different stories in the same document or to stories in different documents.

Parameters
sourceStoryUIDRef of story from which to copy content
sourceStartindex of text to be copied
sourceLengthamount of text to be copied
destStoryUIDRef of story to which content is to be copied
destStartindex where text to be copied
destLength0 to insert text in destination story, >0 to replace
Precondition
0 <= sourceStart < ITextModel::GetPrimaryStoryThreadSpan() for sourceStory
1 <= sourceLength <= ITextModel::GetPrimaryStoryThreadSpan() for sourceStory
0 <= destStart < ITextModel::GetPrimaryStoryThreadSpan() for destStory
0 <= destLength <= ITextModel::GetPrimaryStoryThreadSpan() for destStory
Returns
kSuccess on success, some other ErrorCode otherwise.
See Also
kCopyStoryRangeCmdBoss
ITextUtils for wrapper methods.
IParcel * SnpTextModelHelper::QueryParcelContaining (ITextModeltextModel,
const TextIndex at 
)

Return interface pointer to parcel that displays the given TextIndex or nil if the TextIndex is not displayed.

Parameters
textModel
at
Returns
interface pointer to parcel that displays the given TextIndex or nil if the TextIndex is not displayed.
ErrorCode SnpTextModelHelper::ReplaceText (ITextModeltextModel,
const TextIndex position,
const int32 length,
const boost::shared_ptr< WideString > & text 
)

Replace text in a story using ITextModelCmds::ReplaceCmd.

Parameters
textModelof story to be changed.
positionindex first character to be replaced.
lengthnumber of characters to be replaced.
texttext to replace.
Returns
kSuccess on success, other ErrorCode otherwise.