Bug 38884

Summary: Improve Up/Down movement in writer
Product: LibreOffice Reporter: Björn Michaelsen <bjoern.michaelsen>
Component: WriterAssignee: Juergen Funk <juergen.funk_ml>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: libreoffice
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard: EasyHack DifficultyInteresting SkillCpp TopicUi target:4.4.0
i915 platform: i915 features:

Description Björn Michaelsen 2011-07-01 07:09:43 UTC
Improve Up/Down movement

Background: Up and down movement of the visual caret is currently done by looping over the coordinates of all caret positions. Then the caret position with the closest coordinate in the direction of movement is chosen. That is when moving downwards (hitting the arrow down key) the caret position with the closet coordinate below the coordinate of the current caret position is chosen as the next caret position. However, to avoid jump to the left and right like crazy a heuristic function is applied to the distance, so that dx imposes more penalty than dy, for down movement. Current heuristic is just a more or less random choice, so this could definitively be improved. The code is in SmCursor::Move, any improvement of the behavior would be welcome. In the long run it might also be interesting to consider fontsize, scale and other things that might have impact on the coordinates. This task is probably best solved through trial and error. If you try a lot of solutions please write them down, and note your results so we can discuss them... The code for this task is very isolated, and it shouldn't be hard to find a better solution, but a near flawless solution is probably very hard and not needed, any improvement is welcome.

Skills: Building, C++
Comment 1 Forest Johnson 2011-11-28 21:56:58 UTC
Is this just for normal text in writer? Why is this even an issue? I was under the impression that this was for special equation notation cursors, but It doesn't even look like there is a cursor that moves up and down when you are writing equations.
Comment 2 Noel Grandin 2011-11-29 03:38:05 UTC
The only SmCursor::Move method is in the starmath module, here:

http://opengrok.libreoffice.org/xref/core/starmath/source/cursor.cxx#36
Comment 3 Florian Reisinger 2012-05-18 09:01:44 UTC
Deteted "Easyhack" from summary
Comment 4 Björn Michaelsen 2013-10-04 18:46:49 UTC
adding LibreOffice developer list as CC to unresolved EasyHacks for better visibility.

see e.g. http://nabble.documentfoundation.org/minutes-of-ESC-call-td4076214.html for details
Comment 5 Michal Strnad 2014-03-19 10:12:57 UTC
Hello,

I am starting work on this bug.
Comment 6 Juergen Funk 2014-09-12 10:29:46 UTC
I think the right behavior is the start postion. When move down i expect that the caret is on the same postion. But when a line is shorter then he jump to the end of this line (jump left). When the follow line is longer the position is where i started (jump right). But in this case the caret jump left and right, but i think the positon is importent point. 
That is the behavior of WORD, maybe i a little bit MS contaminated.
Comment 7 Juergen Funk 2014-09-15 08:25:30 UTC
Hi Michal Strnad,

i would like do fix this bug look to my "Comment 6". 
Do you have a problem with that?
Comment 8 Juergen Funk 2014-09-18 08:22:31 UTC
Checkin in Master https://gerrit.libreoffice.org/#/c/11500/

My first checkin i hope it is okay.

The main problem is after the cursor down get a event from i don't know but in the stack i see 

- swlo.dll!SwCrsrShell::UpdateCrsr
.
.
- sfxlo.dll!SfxObjectShell::FlushDocInfo
.
.
- swlo.dll!SfxStubSwViewStateStatusLine
.
.
- sfxlo.dll!SfxBindings::LinkStubNextJob_Impl

i am not sure is that needed to update the cursor, without this event my fix is not necessary?

The next i have see is 
ActionPend() && BasicActionPend()
when ActionPend = TRUE  the BasicActionPend is TRUE too
when ActionPend = FALSE the BasicActionPend is FALSE too

The BasicActionPend is not needed!?


The change in crstrvl.cxx is only for the consistency
Comment 9 Adolfo Jayme 2014-09-19 06:58:25 UTC
Hi Juergen, welcome to the LibreOffice community! We hope you enjoy your stay :-)

I’m marking this bug “ASSIGNED”, and when your patch is accepted into the core repository, we can change the status to “FIXED”. Thanks for your contribution!
Comment 10 Commit Notification 2014-09-22 08:04:09 UTC
Juergen Funk committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=d58bea0ffa2a2fe79103ab7aa743aea63e27a0fd

Fix fdo#38884 Improve Up/Down movement in writer



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 11 Commit Notification 2014-09-30 14:15:14 UTC
Juergen Funk committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=e98e9fda34736731e4c539b1799abb4257219988

fdo#38884 Fix setting X position with dbgutil enabled



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.