Public Member Functions | Private Member Functions | Private Attributes

fl_Squiggles Class Reference

#include <fl_Squiggles.h>

Inheritance diagram for fl_Squiggles:
fl_GrammarSquiggles fl_SpellSquiggles

List of all members.

Public Member Functions

 fl_Squiggles (fl_BlockLayout *pOwner, FL_SQUIGGLE_TYPE iType)
virtual ~fl_Squiggles (void)
void add (const fl_PartOfBlockPtr &pPOB)
void markForRedraw (const fl_PartOfBlockPtr &pPOB)
bool deleteAll (void)
fl_PartOfBlockPtr get (UT_sint32 iOffset) const
const fl_PartOfBlockPtrgetNth (UT_sint32 n) const
void clear (const fl_PartOfBlockPtr &pPOB)
void textInserted (UT_sint32 iOffset, UT_sint32 iLength)
void textDeleted (UT_sint32 iOffset, UT_sint32 iLength)
void textRevised (UT_sint32 iOffset, UT_sint32 iLength)
FL_SQUIGGLE_TYPE getSquiggleType (void) const
void updatePOBs (UT_sint32 iOffset, UT_sint32 shift)
void join (UT_sint32 iOffset, fl_BlockLayout *pPrevBL)
void split (UT_sint32 iOffset, fl_BlockLayout *pNewBL)
bool findRange (UT_sint32 iStart, UT_sint32 iEnd, UT_sint32 &iFirst, UT_sint32 &iLast, bool bDontExpand=false) const
bool recheckIgnoredWords (const UT_UCSChar *pBlockText)

Private Member Functions

void _purge (void)
void _deleteNth (UT_sint32 iIndex)
bool _deleteAtOffset (UT_sint32 iOffset)
bool _findFirstAfter (UT_sint32 iOffset, UT_sint32 &iIndex) const
UT_sint32 _find (UT_sint32 iOffset) const
void _move (UT_sint32 iOffset, UT_sint32 chg, fl_BlockLayout *pBlock=NULL)
UT_sint32 _getCount (void) const

Private Attributes

std::vector< fl_PartOfBlockPtrm_vecSquiggles
fl_BlockLayoutm_pOwner
FL_SQUIGGLE_TYPE m_iSquiggleType

Constructor & Destructor Documentation

fl_Squiggles::fl_Squiggles ( fl_BlockLayout pOwner,
FL_SQUIGGLE_TYPE  iType 
)

Constructor

Parameters:
pOwner The owning block
fl_Squiggles::~fl_Squiggles ( void   )  [virtual]

Destructor

Only purges the vector. It is assumed the squiggles have already been cleared from the screen.

References _purge().


Member Function Documentation

bool fl_Squiggles::_deleteAtOffset ( UT_sint32  iOffset  )  [private]

Delete squiggle at offset

Parameters:
iOffset Offset
Returns:
True if a squiggle was deleted, otherwise false

If a squiggle spans the offset, delete it.

References _deleteNth(), _find(), _getCount(), FL_SQUIGGLE_GRAMMAR, getNth(), getSquiggleType(), and xxx_UT_DEBUGMSG.

Referenced by join(), split(), textInserted(), and textRevised().

void fl_Squiggles::_deleteNth ( UT_sint32  iIndex  )  [private]

Delete Nth squiggle

Parameters:
iIndex Index of squiggle to delete Clear squiggle from screen and g_free the POB's memory

References clear(), getNth(), m_vecSquiggles, and xxx_UT_DEBUGMSG.

Referenced by _deleteAtOffset(), add(), deleteAll(), recheckIgnoredWords(), and textDeleted().

UT_sint32 fl_Squiggles::_find ( UT_sint32  iOffset  )  const [private]

Find squiggle spanning offset

Parameters:
iOffset Offset
Returns:
Index of squiggle spanning the offset, or -1 if there is no squiggle at the offset.

References _getCount(), getNth(), and xxx_UT_DEBUGMSG.

Referenced by _deleteAtOffset(), and get().

bool fl_Squiggles::_findFirstAfter ( UT_sint32  iOffset,
UT_sint32 iIndex 
) const [private]

Find first squiggle after the given offset

Parameters:
iOffset Offset
Returns:
iIndex Index of POB, or index of last POB+1
True if found, otherwise false
Note:
Callers may use the iIndex result even if the search fails: this allows them to look at the last POB on the line which may span the point they are looking for (remember this function finds the squiggle past a given offset, not the one spanning it
  • there may well be a squiggle spanning a point without there being further squiggles behind it).

This function should be rewritten using binary search

References _getCount(), and getNth().

Referenced by add(), and findRange().

UT_sint32 fl_Squiggles::_getCount ( void   )  const [inline, private]
void fl_Squiggles::_move ( UT_sint32  iOffset,
UT_sint32  chg,
fl_BlockLayout pNewBlock = NULL 
) [private]

Move squiggles to new block

Parameters:
iOffset Offset at which to split
chg Offset change. If >0 it's a new absolute position, if <0 it's relative to the current offset.
pNewBlock New block the squiggles should be moved to, or NULL to keep them in the current block.

Move existing squiggles to reflect insert/delete at iOffset. All subsequent squiggles should be switched to (non-null) pBlock.

Note:
Only squiggles after the offset are moved. Squiggles spanning the offset must be handled elsewhere.

References _getCount(), fl_ContainerLayout::add(), clear(), getNth(), m_pOwner, m_vecSquiggles, UT_ASSERT, and xxx_UT_DEBUGMSG.

Referenced by join(), split(), textDeleted(), and textInserted().

void fl_Squiggles::_purge ( void   )  [private]

Purge squiggles Purges the squiggle list. This does not clear the squiggles on the display.

References m_vecSquiggles.

Referenced by ~fl_Squiggles().

void fl_Squiggles::add ( const fl_PartOfBlockPtr pPOB  ) 

Add squiggle

Parameters:
POB for squiggle Insert POB sorted by offset in vector.

References _deleteNth(), _findFirstAfter(), _getCount(), FL_SQUIGGLE_SPELL, getNth(), getSquiggleType(), m_vecSquiggles, markForRedraw(), UT_ASSERT, and xxx_UT_DEBUGMSG.

void fl_Squiggles::clear ( const fl_PartOfBlockPtr pPOB  ) 
bool fl_Squiggles::deleteAll ( void   ) 

Delete all squiggles

Returns:
True if display should be updated, otherwise false Clear all squiggles from display, and purge the list.

References _deleteNth(), _getCount(), and xxx_UT_DEBUGMSG.

Referenced by join(), and split().

bool fl_Squiggles::findRange ( UT_sint32  iStart,
UT_sint32  iEnd,
UT_sint32 iFirst,
UT_sint32 iLast,
bool  bDontExpand = false 
) const

Find squiggles intersecting with region

Parameters:
iStart Start offset of region
iEnd End offset of region
Returns:
iFirst Index of first squiggle intersecting with region
iLast Index of last squiggle intersecting with region
True if range is not empty, otherwise false

References _findFirstAfter(), _getCount(), FL_SQUIGGLE_GRAMMAR, getNth(), getSquiggleType(), s, UT_ASSERT, and xxx_UT_DEBUGMSG.

Referenced by textDeleted().

fl_PartOfBlockPtr fl_Squiggles::get ( UT_sint32  iOffset  )  const

Get squiggle at offset

Parameters:
iOffset Offset
Returns:
pointer to POB (maybe NULL if there is no squiggle at the offset)

References _find(), and getNth().

const fl_PartOfBlockPtr& fl_Squiggles::getNth ( UT_sint32  n  )  const [inline]
FL_SQUIGGLE_TYPE fl_Squiggles::getSquiggleType ( void   )  const [inline]
void fl_Squiggles::join ( UT_sint32  iOffset,
fl_BlockLayout pPrevBL 
)

Join squiggles

Parameters:
iOffset Offset to where squiggles are moved
pPrevBlock Block they should be moved to

This function is called when a paragrah break is deleted and two blocks are joined.

If either block is pending a background spell-check, the combined block is checked in full.

Any squiggle touching the IP is deleted and the word touching the IP becomes the pending word. The previously pending word, if any, becomes irrelevant.

References _deleteAtOffset(), _move(), fl_BlockLayout::_recalcPendingWord(), deleteAll(), FL_SQUIGGLE_SPELL, fl_BlockLayout::getDocLayout(), getSquiggleType(), fl_BlockLayout::isHdrFtr(), m_pOwner, UT_return_if_fail, and xxx_UT_DEBUGMSG.

void fl_Squiggles::markForRedraw ( const fl_PartOfBlockPtr pPOB  ) 

Mark all the runs overlapping with the POB for Redraw.

References fp_Run::getBlockOffset(), fl_BlockLayout::getFirstRun(), fp_Run::getLength(), fp_Run::getNextRun(), m_pOwner, and fp_Run::markAsDirty().

Referenced by add(), and clear().

bool fl_Squiggles::recheckIgnoredWords ( const UT_UCSChar pBlockText  ) 

Recheck ignored words

Parameters:
pBlockText The block's text
Returns:
True if any words squiggled, false otherwise

References _deleteNth(), fl_BlockLayout::_doCheckWord(), _getCount(), getNth(), m_pOwner, and xxx_UT_DEBUGMSG.

void fl_Squiggles::split ( UT_sint32  iOffset,
fl_BlockLayout pNewBL 
)

Split squiggles

Parameters:
iOffset Offset of split
pNewBL New block

Move squiggles after the offset to the new block. If there's a squiggle spanning the offset, delete it.

If the old block is pending a background spell-check, check both it and the new block.

Any pending word is forgotten (since we're splitting the word) and the word (if any) at the end of the line is checked, while the word at the start of the new line (if any) is made pending.

References _deleteAtOffset(), _move(), fl_BlockLayout::_recalcPendingWord(), deleteAll(), FL_SQUIGGLE_SPELL, fl_BlockLayout::getDocLayout(), getSquiggleType(), fl_BlockLayout::isHdrFtr(), m_pOwner, UT_return_if_fail, and xxx_UT_DEBUGMSG.

void fl_Squiggles::textDeleted ( UT_sint32  iOffset,
UT_sint32  iLength 
)

Text deleted - update squiggles

Parameters:
iOffset Offset of deletion
iLength Length of deletion

References _deleteNth(), _move(), fl_BlockLayout::_recalcPendingWord(), findRange(), FL_SQUIGGLE_SPELL, fl_BlockLayout::getDocLayout(), getSquiggleType(), fl_BlockLayout::isHdrFtr(), m_pOwner, and xxx_UT_DEBUGMSG.

void fl_Squiggles::textInserted ( UT_sint32  iOffset,
UT_sint32  iLength 
)

Text inserted - update squiggles

Parameters:
iOffset Location at which insertion happens
iLength Length of inserted text

References _deleteAtOffset(), _move(), fl_BlockLayout::_recalcPendingWord(), FL_SQUIGGLE_SPELL, fl_BlockLayout::getDocLayout(), getSquiggleType(), fl_BlockLayout::isHdrFtr(), m_pOwner, and xxx_UT_DEBUGMSG.

void fl_Squiggles::textRevised ( UT_sint32  iOffset,
UT_sint32  iLength 
)

change of fmt that impacts on spelling (e.g., delete in revisions mode, or undo of delete in revisions mode)

Parameters:
iOffset Location at which insertion happens
iLength Length of inserted text

References _deleteAtOffset(), fl_BlockLayout::_recalcPendingWord(), FL_SQUIGGLE_SPELL, fl_BlockLayout::getDocLayout(), getSquiggleType(), fl_BlockLayout::isHdrFtr(), m_pOwner, and xxx_UT_DEBUGMSG.

void fl_Squiggles::updatePOBs ( UT_sint32  iFirstOffset,
UT_sint32  iShift 
)

Update the offsets in the POB's. We shifts the offsets around after text inside an emebdded section (like a footnote is changed).

Parameters:
iFirstOffset this is the first offset that is changed.
iShift this is the amount that the text is shifted.

References m_vecSquiggles.


Member Data Documentation


The documentation for this class was generated from the following files: