Apache OpenOffice (AOO) Bugzilla – Issue 56229
Bug selecting nested tables
Last modified: 2013-08-07 14:42:49 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.)
Created attachment 30617 [details] writer document
MRU->OS: place cursor somewhere in the outer table. Ctrl-A or menu command "select table" will always select the inner table.
Reassigned to fme and target set to OOo 3.0
.
->fme: I want to work on this issue. Could I assign this issue to me ?
fme->lijian: Thank you for your help. I'll assign this issue to you.
Created attachment 47944 [details] patch for this issue
->fme: I have submitted a patch for this issue. Please review it. Thank you!
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.
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.
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.
Created attachment 48470 [details] patch 2 for this issue
->fme: 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.
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().
Created attachment 48950 [details] patch 4 for i56229
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.
fme->lijian: Thank you for your patch. I'll have a look...
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 Table Row Cell 1 Section Para 1 /Section Para2 /Cell 1 Cell 2 Para 3 /Cell 1 /Row /Table 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.
Created attachment 49022 [details] patch 5
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.
fme: Fixed in cws swqbf105
FME: Ready for QA.
Verified fix in CWS swqbf105.
Checked fix in OO 2.4 dev build 680m237.
*** Issue 87772 has been marked as a duplicate of this issue. ***