Bug 145151 - Apply numbering in a selected table cell leaks to another table cell (when selecting "backwards")
Summary: Apply numbering in a selected table cell leaks to another table cell (when se...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Justin L
URL:
Whiteboard: target:7.5.0
Keywords:
Depends on:
Blocks: Writer-Tables-Select
  Show dependency treegraph
 
Reported: 2021-10-15 10:05 UTC by Justin L
Modified: 2022-08-07 19:21 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
leakingNumbering.odt: example document (13.70 KB, application/vnd.oasis.opendocument.text)
2021-10-15 10:05 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Justin L 2021-10-15 10:05:36 UTC
Created attachment 175755 [details]
leakingNumbering.odt: example document

Similar to bug 93747, but much more insidious, is apply numbering to a backwards selected table cell's contents. The numbering also affects the non-selected cell on the left.

1. Open leakingNumbering.odt and put your cursor behind "XYZ"
2. Select backwards until it turns into table select mode. (At this point, it has selected both columns two and three.) Change the selection to only include column three.
3.) select bulleting or numbering. Notice that column two is affected as well.
Comment 1 Dieter 2021-11-01 15:13:40 UTC
I confirm it with

Version: 7.3.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: 273a25c796fca9afa0dfadac57dc3f336831221c
CPU threads: 4; OS: Windows 10.0 Build 19043; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: en-GB
Calc: CL
Comment 2 Justin L 2022-05-23 15:57:56 UTC
Lots of problems here. This goes back to the initial code dump.

1.) sw/source/core/edit/ednumber.cxx SelectionHasNumber needs to use for(SwPaM& rPaM : GetCursor()->GetRingContainer()) instead of
SwPamRanges aRangeArr(*GetCursor()) which can't detect is PaM.HasMark(). And of course SelectionHasBullet has the same issue.

2.) DelNumRules has the same issue.

3.) SetCurNumRule has the same issue.

sw/source/uibase/shells/txtnum.cxx ExecEnterNum is where the command to turn on numbering exists.  It calls sw/source/uibase/wrtsh/wrtsh1.cxx NumOrBulletOn which calls these problematic functions.
Comment 3 Justin L 2022-06-09 00:24:36 UTC
Of course, the entire problem can be fixed if the selection itself is correct. However, that is a nasty and apparently rather complicated business.

AFAICS, the problem is ultimately from sw/sources/core/crsr/swcrsr's 
SwTableCursor::MakeBoxSels
            if( bDel )
            {
                SwPaM* pDel = pCur->GetPrev();

                if( pDel == pCurrentCursor )
                    pCurrentCursor->DeleteMark();
                else
                    delete pDel;
            }
In the reverse-select case, pCurrentCursor is pDel - so it isn't deleting that multiselection.
Comment 4 Commit Notification 2022-06-13 07:52:44 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/9a2e7bade3aa8b115f1973be532ec86fa0369171

tdf#145151 sw IsTableMode NumRule: unselected cells

It will be available in 7.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 5 Commit Notification 2022-06-14 23:29:15 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/5036c5a7afdd043c3fa5c108c985cd0d8ed352fa

tdf#145151 sw IsTableMode SelectionHasNumber: unselected cells

It will be available in 7.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2022-06-15 17:57:06 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/6b6bedecf61e084e8db6b20a362a231dbac0e70a

tdf#145151 sw IsTableMode GetNumRuleAtCurrCursorPos: unselected cells

It will be available in 7.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Justin L 2022-06-15 17:58:35 UTC
No intention to backport. Next I'm going to try a fix based on comment 3 which will obsolete most of these changes - but is a bit more dangerous.
Comment 8 Commit Notification 2022-06-29 11:25:07 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/0031f34d0ba99de5384e13843e99ffbb01f729d0

tdf#145151 tdf#119540 sw IsTableMode: deselect unselected cell

It will be available in 7.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 9 Commit Notification 2022-06-29 22:19:49 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/fcbd1e8363f14fcbdcef9bb2a6bca8a2cb7644ac

tdf#tdf#93747 tdf#145151 sw IsTableMode: revert obsolete one-offs

It will be available in 7.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 10 Dieter 2022-08-07 19:21:40 UTC
VERIFIED with

Version: 7.5.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: a56d0c34716f381accbd9d2e3040a62d3583d18d
CPU threads: 4; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: en-GB
Calc: CL

Justin, thanks for fixing it!