--- Dr William Bland <[EMAIL PROTECTED]> wrote: > On Wed, Oct 30, 2002 at 11:38:08AM +1100, Martin > Sevior wrote: > > I wrote a little method in PD_Document to display > > the properties associated with struxes around a > > strux that I used for debugging purposes. > > > > PD_Document::miniDump(PL_StruxDocHandle sdh, > > UT_sint32 nstruxes) > > > Thanks Martin, reading your miniDump code was very > instructive. In the end I wrote my own code for > stepping through the document (also borrowing from > the text exporter as Dom suggested): > > > // Get the current frame, view, etc that the user is > in. > XAP_Frame *pFrame = > XAP_App::getApp()->getLastFocussedFrame(); > FV_View* pView = > static_cast<FV_View*>(pFrame->getCurrentView()); > PD_Document* mydoc = pView->getDocument(); > pt_PieceTable* mypt = mydoc->getPieceTable(); > pf_Fragments* myfrags = &(mypt->getFragments()); > > // Iterate through all the fragments in the > document. > for( pf_Frag* pf = myfrags->getFirst(); (pf); > pf=pf->getNext() ) > { > switch( pf->getType() ) > { > case pf_Frag::PFT_Text: > printf( "Found a text fragment\n" ); > break; > case pf_Frag::PFT_Strux: > printf( "Found a strux fragment\n" ); > break; > case pf_Frag::PFT_Object: > printf( "Found an object fragment\n" ); > break; > case pf_Frag::PFT_FmtMark: > printf( "Found an format-mark > fragment\n" ); > break; > case pf_Frag::PFT_EndOfDoc: > printf( "Found an end-of-document > fragment\n" ); > break; > default: > printf( "Found an unknown fragment\n" ); > break; > } > } > > > > I will probably write a little tutorial on doing > this kind of thing (once I'm sure I understand it!) > so if anyone hates the way I've done this, please > let me know before I start telling the world to do > it this way ;-)
Hey don't just tell the world how to do it, give them APIs to do it. One time is plenty for inventing wheels: http://bugzilla.abisource.com/show_bug.cgi?id=4117 "RFE: APIs to iterate through document" Andrew Dunbar. > Best wishes, > Bill. ===== http://linguaphile.sourceforge.net/cgi-bin/translator.pl http://www.abisource.com __________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com