[patch] EOL near forced page break

Matt Kimball (robozapp@xmission.com)
Sun, 25 Apr 1999 18:45:27 -0600


--2oS5YaxWCcQjTEyO
Content-Type: text/plain; charset=us-ascii

Ok, here's the problem:

1. Force a page break in the middle of a line of text.
2. Go to somewhere on the line before the page break.
3. Press End to go to the end of line.

You will end up on the beginning of the line on the next page, not at
the end of the line. This is annoying, so I fixed it. Attached is
the patch.

(I used more context than usual in the diff because some code in
fp_Run.h is very similar).

-- 
Matt Kimball
mkimball@xmission.com

--2oS5YaxWCcQjTEyO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="abi-eol-pgbrk.patch"

diff -u12r ../abi-0.5.4/src/text/fmt/xp/fp_Run.h ./src/text/fmt/xp/fp_Run.h --- ../abi-0.5.4/src/text/fmt/xp/fp_Run.h Wed Apr 7 14:46:43 1999 +++ ./src/text/fmt/xp/fp_Run.h Sun Apr 25 19:02:02 1999 @@ -97,24 +97,25 @@ void draw(dg_DrawArgs*); void clearScreen(UT_Bool bFullLineHeightRect = UT_FALSE); virtual UT_uint32 containsOffset(UT_uint32 iOffset); virtual UT_Bool canContainPoint(void) const; const PP_AttrProp* getAP(void) const; virtual void fetchCharWidths(UT_GrowBuf * pgbCharWidths); virtual UT_Bool recalcWidth(void); virtual void _draw(dg_DrawArgs*) = 0; virtual void _clearScreen(UT_Bool bFullLineHeightRect) = 0; virtual UT_Bool canBreakAfter(void) const = 0; virtual UT_Bool canBreakBefore(void) const = 0; + virtual UT_Bool isForcedBreak(void) const { return UT_FALSE; } virtual UT_Bool alwaysFits(void) const { return UT_FALSE; } virtual UT_Bool findMaxLeftFitSplitPoint(UT_sint32 iMaxLeftWidth, fp_RunSplitInfo& si, UT_Bool bForce=UT_FALSE) = 0; virtual void mapXYToPosition(UT_sint32 xPos, UT_sint32 yPos, PT_DocPosition& pos, UT_Bool& bBOL, UT_Bool& bEOL) = 0; virtual void findPointCoords(UT_uint32 iOffset, UT_sint32& x, UT_sint32& y, UT_sint32& height) = 0; virtual void lookupProperties(void) = 0; #ifndef NDEBUG virtual void debug_dump(void); #endif protected: unsigned char m_iType; @@ -155,60 +156,63 @@ class fp_ForcedLineBreakRun : public fp_Run { public: fp_ForcedLineBreakRun(fl_BlockLayout* pBL, GR_Graphics* pG, UT_uint32 iOffsetFirst, UT_uint32 iLen); virtual UT_Bool canContainPoint(void) const; virtual UT_uint32 containsOffset(UT_uint32 iOffset); virtual void lookupProperties(void); virtual void mapXYToPosition(UT_sint32 xPos, UT_sint32 yPos, PT_DocPosition& pos, UT_Bool& bBOL, UT_Bool& bEOL); virtual void findPointCoords(UT_uint32 iOffset, UT_sint32& x, UT_sint32& y, UT_sint32& height); virtual UT_Bool canBreakAfter(void) const; virtual UT_Bool canBreakBefore(void) const; + virtual UT_Bool isForcedBreak(void) const { return UT_TRUE; } virtual UT_Bool findMaxLeftFitSplitPoint(UT_sint32 iMaxLeftWidth, fp_RunSplitInfo& si, UT_Bool bForce=UT_FALSE); protected: virtual void _draw(dg_DrawArgs*); virtual void _clearScreen(UT_Bool bFullLineHeightRect); }; class fp_ForcedColumnBreakRun : public fp_Run { public: fp_ForcedColumnBreakRun(fl_BlockLayout* pBL, GR_Graphics* pG, UT_uint32 iOffsetFirst, UT_uint32 iLen); virtual UT_Bool canContainPoint(void) const; virtual UT_uint32 containsOffset(UT_uint32 iOffset); virtual void lookupProperties(void); virtual void mapXYToPosition(UT_sint32 xPos, UT_sint32 yPos, PT_DocPosition& pos, UT_Bool& bBOL, UT_Bool& bEOL); virtual void findPointCoords(UT_uint32 iOffset, UT_sint32& x, UT_sint32& y, UT_sint32& height); virtual UT_Bool canBreakAfter(void) const; virtual UT_Bool canBreakBefore(void) const; + virtual UT_Bool isForcedBreak(void) const { return UT_TRUE; } virtual UT_Bool findMaxLeftFitSplitPoint(UT_sint32 iMaxLeftWidth, fp_RunSplitInfo& si, UT_Bool bForce=UT_FALSE); protected: virtual void _draw(dg_DrawArgs*); virtual void _clearScreen(UT_Bool bFullLineHeightRect); }; class fp_ForcedPageBreakRun : public fp_Run { public: fp_ForcedPageBreakRun(fl_BlockLayout* pBL, GR_Graphics* pG, UT_uint32 iOffsetFirst, UT_uint32 iLen); virtual UT_Bool canContainPoint(void) const; virtual UT_uint32 containsOffset(UT_uint32 iOffset); virtual void lookupProperties(void); virtual void mapXYToPosition(UT_sint32 xPos, UT_sint32 yPos, PT_DocPosition& pos, UT_Bool& bBOL, UT_Bool& bEOL); virtual void findPointCoords(UT_uint32 iOffset, UT_sint32& x, UT_sint32& y, UT_sint32& height); virtual UT_Bool canBreakAfter(void) const; virtual UT_Bool canBreakBefore(void) const; + virtual UT_Bool isForcedBreak(void) const { return UT_TRUE; } virtual UT_Bool findMaxLeftFitSplitPoint(UT_sint32 iMaxLeftWidth, fp_RunSplitInfo& si, UT_Bool bForce=UT_FALSE); protected: virtual void _draw(dg_DrawArgs*); virtual void _clearScreen(UT_Bool bFullLineHeightRect); }; class fp_ImageRun : public fp_Run { public: fp_ImageRun(fl_BlockLayout* pBL, GR_Graphics* pG, UT_uint32 iOffsetFirst, UT_uint32 iLen, GR_Image* pImage); virtual ~fp_ImageRun(); diff -u12r ../abi-0.5.4/src/text/fmt/xp/fv_View.cpp ./src/text/fmt/xp/fv_View.cpp --- ../abi-0.5.4/src/text/fmt/xp/fv_View.cpp Tue Apr 6 14:00:13 1999 +++ ./src/text/fmt/xp/fv_View.cpp Sun Apr 25 19:05:47 1999 @@ -568,25 +568,37 @@ case FV_DOCPOS_BOL: { fp_Run* pFirstRun = pLine->getFirstRun(); iPos = pFirstRun->getBlockOffset() + pBlock->getPosition(); } break; case FV_DOCPOS_EOL: { fp_Run* pLastRun = pLine->getLastRun(); - iPos = pLastRun->getBlockOffset() + pLastRun->getLength() + pBlock->getPosition(); + while (!pLastRun->isFirstRunOnLine() && pLastRun->isForcedBreak()) + { + pLastRun = pLastRun->getPrev(); + } + + if(pLastRun->isForcedBreak()) + { + iPos = pBlock->getPosition() + pLastRun->getBlockOffset(); + } + else + { + iPos = pBlock->getPosition() + pLastRun->getBlockOffset() + pLastRun->getLength(); + } } break; case FV_DOCPOS_EOD: { UT_Bool bRes = m_pDoc->getBounds(UT_TRUE, iPos); UT_ASSERT(bRes); } break; case FV_DOCPOS_BOB: {

--2oS5YaxWCcQjTEyO--



This archive was generated by hypermail 1.03b2.