Subject: Re: Piece Table Walkthrough
jeff@abisource.com
Date: Fri Feb 18 2000 - 23:00:33 CST
On Fri, Feb 18, 2000 at 06:21:14PM -0600, sam th wrote:
> In attempting to write the Word Count dialog, I need to walk through the
> entire Piece Table. However, I have no real idea how I would need to do
> this. There is a nice document on the website describing the
> data structure, but it is hopeless inaccurate. For example, the most
> important class for my purposes, according to the documen would be
> PieceList, which no longer exists. I am wondering if someone could let me
> know how we currently store data, and what the proper procedure would be
> for walking through it.
> Thanks
you don't want to be in the piece table (trust me :-)
you can do everything thru formatter access routines.
look at the guts of src/text/fmt/xp/fv_View.cpp::cmdContextAdd()
for a starter.
you want to do something that looks like this:
fl_DocSectionLayout * pSL = m_pLayout->getFirstSection()
while (pSL)
{
fl_BlockLayout * pBL = pSL->getFirstBlock()
while (pBL)
{
UT_GrowBuf gb(1024);
pBL->getBlockBuf(&gb);
const UT_UCSChar * pSpan = gb.getPointer(0);
int len = gb.getLength();
// count words in pSpan[0..len]
pBL = pBL->getNext();
}
pSL = pSL->getNext();
}
more or less...
this approach will give you the text of each paragraph in a buffer
with all of the formatting and other omitted.
also, there's some spell-check-related code somewhere (paul??)
that decides where word-breaks are that you should be
able to hook into as well.
hope this helps,
jeff
This archive was generated by hypermail 2b25 : Fri Feb 18 2000 - 23:00:35 CST