Issue 56229 - Bug selecting nested tables
Summary: Bug selecting nested tables
Alias: None
Product: Writer
Classification: Application
Component: code (show other issues)
Version: 680m122
Hardware: All All
: P3 Trivial (vote)
Target Milestone: ---
Assignee: michael.ruess
QA Contact: issues@sw
: 87772 (view as issue list)
Depends on:
Blocks: 72764
  Show dependency tree
Reported: 2005-10-18 18:29 UTC by norbert2
Modified: 2013-08-07 14:42 UTC (History)
7 users (show)

See Also:
Issue Type: PATCH
Latest Confirmation in: ---
Developer Difficulty: ---

writer document (6.33 KB, application/vnd.oasis.opendocument.text)
2005-10-18 18:29 UTC, norbert2
no flags Details
patch for this issue (593 bytes, text/plain)
2007-09-04 07:57 UTC,
no flags Details
patch 2 for this issue (794 bytes, text/plain)
2007-09-25 10:24 UTC,
no flags Details
patch 4 for i56229 (1.21 KB, text/plain)
2007-10-17 04:39 UTC,
no flags Details
patch 5 (1.74 KB, text/plain)
2007-10-19 08:02 UTC,
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description norbert2 2005-10-18 18:29:01 UTC
- please open the attached writer document
- place the cursor in the outer table (for example within the string "outer table")
- click the menu item table/select/table: The inner table is selected instead of
the outer one.

(Please also have a look at issue 56228.)
Comment 1 norbert2 2005-10-18 18:29:36 UTC
Created attachment 30617 [details]
writer document
Comment 2 michael.ruess 2005-10-19 16:05:36 UTC
MRU->OS: place cursor somewhere in the outer table. Ctrl-A or menu command
"select table" will always select the inner table.
Comment 3 Oliver Specht 2006-05-29 08:03:46 UTC
Reassigned to fme and target set to OOo 3.0
Comment 4 frank.meies 2006-06-26 07:58:52 UTC
Comment 5 2007-08-31 09:11:49 UTC
I want to work on this issue. Could I assign this issue to me ?
Comment 6 frank.meies 2007-08-31 09:20:59 UTC
fme->lijian: Thank you for your help. I'll assign this issue to you.
Comment 7 2007-09-04 07:57:13 UTC
Created attachment 47944 [details]
patch for this issue
Comment 8 2007-09-04 07:58:55 UTC
I have submitted a patch for this issue.
Please review it. Thank you!
Comment 9 frank.meies 2007-09-04 09:30:49 UTC
fme->lijian: Thank you for your patch. I had a look at it and found that it
works in case we can make sure that lcl_FindNextCell and lcl_FindPrevCell work
correctly. For now, let's just consider lcl_FindNextCell, anything that follows
holds also for lcl_FindPrevCell. lcl_FindNextCell is designed to start with the
index of a table node and find the next cell that can contain the cursor. I
think lcl_FindNextCell currently does not work as expected: please check the
case that all the cells of the inner table are protected and the cursor is not
allowed to be inside protected areas.
Comment 10 2007-09-04 10:33:21 UTC
lijian->fme:Thank you for your reply.
I am not sure what you mean. While I will explain what I think:
If the inner table is in other cells of the outer table except the first cell, 
all work fine regarding "select". And in those situations, lcl_FindNextCell 
works fine. So I don't think it's the reason. In fact, the 
statement "rCurCrsr.Move( fnPosTbl, fnGoCntnt )" in Function "GotoCurrTable" in
core\crsr\trvltbl.cxx will always be excuted and it will return the cells in 
which the cursor starts and ends. If there is no txtnode in the first cell of 
the outer table before the inner table, the statement will search for the 
first txtnode even if the txtnode is in the inner table. Then this inner 
txtnode will be stored in Class Pam. So the selected range will be wrong(just 
the inner table). My patch ensures to find the correct table the original 
cursor is located in. 
I still have 2 other questions:
1.what is function SwCursor::IsReadOnlyAvailable used for ?
2.I am not sure what function lcl_FindNextCell is used for.
Comment 11 frank.meies 2007-09-04 11:01:31 UTC
fme->lijian: As I wrote in my last statement, lcl_FindNextCell starts with a
table node and finds the next cell that can contain the cursor. Please check the
example I gave: Make all cells of the inner table protected and disable Tools -
Option - Writer - Formatting Aids - Cursor in protected ... This option is
basically what SwCursor::IsReadOnlyAvailable() says. If you select the whole
table, lcl_FindNextCell does not work as expected. It should find the first cell
of the outer table, and in this case your fix would work. Instead it returns a
value != 0 indicating that no cell could be found, and your new code will not be
called => bug.
Comment 12 2007-09-25 10:24:03 UTC
Created attachment 48470 [details]
patch 2 for this issue
Comment 13 2007-09-25 10:27:23 UTC
I think lcl_FindNextCell forgot the situation "table in table".
So I added a condition to "if" in case the cursor in the outer 
table can not be found.
Comment 14 frank.meies 2007-09-26 14:59:59 UTC
fme->lijian: The point is that lcl_FindNextCell simply does not work as
expected. Your patch does not change that. In my opinion lcl_FindNext cell
should not set rIdx into an inner table cell. That's the contract of the
function. So if you adjust lcl_FindNextCell and lcl_FindPrevCell the way, that
not only protected cells, but also inner cells are skipped, there's no need to
change any code in GotoCurrTable().
Comment 15 2007-10-17 04:39:07 UTC
Created attachment 48950 [details]
patch 4 for i56229
Comment 16 2007-10-17 04:44:14 UTC
lijian->fme:I just modified the function lcl_FindNextCell. Because the last 
item of a cell must be a txtnode before the Endnode, the function 
lcl_FindPrevCell couldn't have the problem of "table in table" I think. So I 
think modification of function lcl_FindPrevCell is unnecessary. What do you 
think about this ? Look forward to your reply.
Comment 17 frank.meies 2007-10-17 09:36:28 UTC
fme->lijian: Thank you for your patch. I'll have a look...
Comment 18 frank.meies 2007-10-17 11:56:38 UTC
fme->lijian: Thank you very much. Almost good, I think. Just two more remarks:

1) I think the first if statement in the for loop is not correct. Imagine the case

    Cell 1
        Para 1
    /Cell 1
    Cell 2
        Para 3
    /Cell 1
Not, if cell1 is protected, lcl_FindNextCell does not correctly set the index to
Para3, instead it returns a value != 0 indicating a failure. So I think the if
statement should check if we have already reached the end of the (outer) table.
And aTmp only has to be incremented in case that pNd is a start node.

2) The last content of a cell does not necessarily have to be a text node in the
outer table, if can also be an inner table. Just try it: Select the whole
content of a table cell and execute "insert table". The outer table cell will
only contain a inner table cell with no surrounding text nodes. We should
consider this case as well.
Comment 19 2007-10-19 08:02:27 UTC
Created attachment 49022 [details]
patch 5
Comment 20 frank.meies 2007-10-19 09:54:30 UTC
fme: I'll take over. lijian and me agreed on some minor changes to the patch.
Thank you lijian for your hard work on this issue.
Comment 21 frank.meies 2007-10-19 12:18:40 UTC
fme: Fixed in cws swqbf105
Comment 22 frank.meies 2007-10-22 13:52:00 UTC
FME: Ready for QA.
Comment 23 michael.ruess 2007-11-06 09:47:50 UTC
Verified fix in CWS swqbf105.
Comment 24 michael.ruess 2007-11-23 14:47:53 UTC
Checked fix in OO 2.4 dev build 680m237.
Comment 25 michael.ruess 2008-04-03 08:37:52 UTC
*** Issue 87772 has been marked as a duplicate of this issue. ***