onyx-intl/boox-opensource — pull request #22 by macnuts (2013-08-20 05:51:47+00:00)
Title: cr3: change current position on UI action only.

This pull request fixes the following problem:

Cool Reader 3 is not preserving last viewed page on document reload when a document is displayed in full screen (without system status bar at the bottom).

The problem is with LVDocView::checkPos() and LVDocView::getCurrentFileHistRecord functions. Beside doing thier work these functions update current position to the first element on page. It is not necessary and wrong actually, as both pre-call current position and post-call current position are always on the same page.

Newly loaded document is rendered (with LCDocView::Render) at least twice before it is displayed in full screen. After that it is displayed on the screen. By then, current position may be different from the original one.

First render operation is performed for non-full screen page dimension; during that render operation original current position is altered and points to first element on page. Then, page is resized to full screen and next render operation is triggered. In most cases that element would fit a previous page (pages are larger and can hold more elements). In the end, wrong page is displayed to a user on document load.

LVDocView::checkPos() is ment to assure that current position bookmark is on current page, if not then this function changes current page accordingly. New current page is determined from current position bookmark regardless if it was first element on page or one of the following. But page change operation reset a current postion bookmark to the first one on new page.

LVDocView::getCurrentFileHistRecord is ment to return all saved bookmarks for enumeration including current postion. It is using getBookmark() instead of already set _posBookmark, which holds actual current postion (when not null). getBookmark() returns a position to the first element on current page.

Handlers for any explicit user action which changes current position are unaffected.