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

#include <CHMLFiltTextHelper.h>

Public Member Functions

 CHMLFiltTextHelper (const UIDRef &textModelUIDRef, const RangeData &targetRangeData)
 
 CHMLFiltTextHelper (const UIDRef &textModelUIDRef)
 
virtual ~CHMLFiltTextHelper ()
 
ErrorCode InsertText (const WideString &wstr)
 
ErrorCode Apply ()
 
void AddUnderline ()
 
void AddNonUnderline ()
 
void AddAlignment (ICompositionStyle::TextAlignment alignment)
 
void AddBold ()
 
void AddDefaultFont ()
 
void AddPointSize (const PMReal &pointSize)
 
void AddFont (const PMString &fontName)
 
void Reset (const RangeData &targetRangeData)
 
void Reset (const TextIndex &position)
 

Protected Member Functions

void checkInvariant ()
 
ErrorCode doApplyAttributes (boost::shared_ptr< AttributeBossList > &attrList, const ClassID &which)
 

Detailed Description

Helper methods to ease text manipulations; these can be used to add overrides to both character and paragraph attributes to a specified text model and range (RangeData). Note that the overrides will not be applied until the Apply method is called on the instance. This enables several different overrides to be stored up and then applied by processing a single command rather than lots of individual commands for each override.

Constructor & Destructor Documentation

CHMLFiltTextHelper::CHMLFiltTextHelper (const UIDReftextModelUIDRef,
const RangeDatatargetRangeData 
)

Constructor taking a text model and a range.

Parameters
textModelUIDRefIN text model to encapsulate
targetRangeDataIN range over which this will operate
CHMLFiltTextHelper::CHMLFiltTextHelper (const UIDReftextModelUIDRef)

Constructor taking just a text model but no range.

Parameters
textModelUIDRefIN text model to encapsulate
CHMLFiltTextHelper::~CHMLFiltTextHelper ()
virtual

Destructor

Member Function Documentation

void CHMLFiltTextHelper::AddAlignment (ICompositionStyle::TextAlignment alignment)

Add an alignment override (paragraph level attribute)

Parameters
alignmentIN specifies the type of alignment to set
Precondition
there should be a range set
Postcondition
alignment override is stored ready to be applied when Apply called
void CHMLFiltTextHelper::AddBold ()

Add a override to add a bold style

Precondition
there should be a range set
Postcondition
bold override stored ready to be applied when Apply called
void CHMLFiltTextHelper::AddDefaultFont ()

Add override to restore the default font (e.g. to remove bold)

Precondition
there should be a range set
Postcondition
default font attribute ready to be applied when Apply called
void CHMLFiltTextHelper::AddFont (const PMStringfontName)

Add a font override

Parameters
fontNameIN name of font to apply
Precondition
there should be a range set and the font should ideally exist in the document
Postcondition
a font override is stored ready for an Apply
void CHMLFiltTextHelper::AddNonUnderline ()

Add an override to remove underlining

Precondition
there should be a range set
Postcondition
the underline override will be turned off on the range stored in this when the Apply method is called
void CHMLFiltTextHelper::AddPointSize (const PMRealpointSize)

Add a point size override

Parameters
pointSizeIN point size of override.
Precondition
pointSize should be > 0 and a range set
Postcondition
point size is stored ready to be applied
void CHMLFiltTextHelper::AddUnderline ()

Add an underline override.

Precondition
there should be a range set
Postcondition
an underline override attribute is stored in this ready to be applied on the range
ErrorCode CHMLFiltTextHelper::Apply ()

Applies the overrides stored in this object to appropriate targets such as the strand for paragraph attributes (kParaAttrStrandBoss) or character attributes (kCharAttrStrandBoss).

Precondition
some overrides ought to have been added
Returns
kSuccess if overrides could be applied, kFailure otherwise
Postcondition
text in range specified by encapsulated RangeData and text model would have overrides indicated, override lists flushed for next Apply
ErrorCode CHMLFiltTextHelper::InsertText (const WideStringwstr)

Method to insert a WideString into the text model at the current insertion position (start of encapsulated range or the insertion position stored in this).

Parameters
wstrIN text to insert
Precondition
wstr should not be an empty string
Returns
kSuccess on a successful insertion, kFailure otherwise
Postcondition
on success the text model will now contain the contents of wstr at insertion position or start of range stored in this
void CHMLFiltTextHelper::Reset (const RangeDatatargetRangeData)

Change the encapsulated text range (stored in a RangeData)

Parameters
targetRangeDataIN new range
Postcondition
the encapsulated range has changed
void CHMLFiltTextHelper::Reset (const TextIndex & position)

Change from a range to an insertion position

Parameters
positionIN insertion position in text model.
Precondition
position should lie in the span of the text model
Postcondition
we now encapsulate an insertion position