A warning before a major change.


Subject: A warning before a major change.
From: Martin Sevior (msevior@mccubbin.ph.unimelb.edu.au)
Date: Tue Feb 13 2001 - 23:12:46 CST


HI everyone,
            We have a problem with Abiword with page numbers. Right now
page numbers are contained in a section placed at the end of the document.
However the size of the document includes the page number sections. This
means that it is quite possible to to place the cursor at the end of the
text press "right arrow" and enter the page section. The cursor jumps into
the fister header/footer and then any text entered will crash Abiword.

Now eventually this will be a cool feature (Entering text directly into
Abi headers/footers) but it will take some major reworking and in any case
you should not enter the header/footer sections unless you mean to.

The best way to fix this is to have the code that calculates the size of
the document not include the the header/footer sections. I've made the
changes needed in fv_View to do this and have written a new method
in fv_View called

// TODO find clever way to cache the size of the
// header/footer region so we can just subtract it off.
//
bool FV_View::getEditableBounds(bool isEnd, PT_DocPosition &posEOD)

Now this code gets called on every cursor motion in abi so it is important
to realize that this code should be fast. Right now it adds a bit of extra
overhead to abi but I think I can come up with code to speed this up via
caching. Anyway the full code is:

//
// This method keeps the insertion point out of the header/footer end of
// of the document.
// TODO find clever way to cache the size of the
// header/footer region so we can just subtract it off.
//
bool FV_View::getEditableBounds(bool isEnd, PT_DocPosition &posEOD)
{
        bool res;
        if(!isEnd)
        {
               res = m_pDoc->getBounds(isEnd,posEOD);
               return res;
        }
        else
        {
               fl_DocSectionLayout * pSL = m_pLayout->getFirstSection();
               UT_DEBUGMSG(("SEVIOR: Header = %x, Footer = %x
\n",pSL->getHeader(),pSL->getFooter()));
               while(pSL != NULL && pSL->getHeader()== NULL &&
pSL->getFooter()== NULL )
               {
                      UT_DEBUGMSG(("SEVIOR: Header = %x, Footer = %x
\n",pSL->getHeader(),pSL->getFooter()));

                      pSL = pSL->getNextDocSection();
               }
               fl_BlockLayout * pBL;
               if( pSL == NULL || ( pSL->getHeader()== NULL &&
pSL->getFooter()== NULL ))
               {
                      UT_DEBUGMSG(("SEVIOR: NO Header/Footer in doc!
\n"));
                      res = m_pDoc->getBounds(isEnd,posEOD);
                      return res;
               }
               if(pSL->getHeader() != NULL)
               {
                      pBL = pSL->getHeader()->getFirstBlock();
               }
               else
               {
                      pBL = pSL->getFooter()->getFirstBlock();
               }
               UT_DEBUGMSG(("SEVIOR: Header/Footer Exists \n"));
               UT_DEBUGMSG(("SEVIOR: Block Section Type
\n",pBL->getSectionLayout()->getType()));
               posEOD = pBL->getPosition( true);
               pBL = _findBlockAtPosition(posEOD);
               while(pBL->getSectionLayout()->getType() == FL_SECTION_HDRFTR)
               {
                      posEOD--;
                      pBL = _findBlockAtPosition(posEOD);
               UT_DEBUGMSG(("SEVIOR: Block Section Type \n",pBL->getSectionLayout()->getType()));
               }
               posEOD--;
               return res;
        }
}

Cheers

Martin



This archive was generated by hypermail 2b25 : Tue Feb 13 2001 - 23:12:51 CST