Apache OpenOffice (AOO) Bugzilla – Issue 77649
Writer: Change of number format in table cells inconsistent
Last modified: 2013-08-07 14:42:39 UTC
Load bug document. Expected behavior: Change number format (from "text" to e.g. "date") is possible for cells which contains one paragraph. It is not doable for cell with more paragraphs. Try cell "A1" and "A2". Wrong behavior: Cell "B1" contains two paragraphs but the number format is changeable?! Cell "C1" contains a table (in table), a change of the number format (of the outer table cell) will be applied to the inner table cell?!
Created attachment 45291 [details] Bug document
Set target.
Created attachment 45452 [details] The patch file
Hi ama, as your suggestion in the issue 77648, I have fixed this issue. I add a check that if the node (behind the start node) is a start node of a table or a section, the fuction SwTableBox::IsValidNumTxtNd(..) will return ULONG_MAX. please have a look at the patch file.
Add dependency to meta issue
add myself
Created attachment 45483 [details] Colored bug document
I have attached a modified bug document. When you select the complete table and set the number format "date" for all table cells (of the oiuter table), the IsValidNumTxtNd(..) function is responsible for the changing of text. But unfortunately this function works not like expected. How it should work: It should change all cells with green background because their content is one single paragraph which is allowed to be changed. The cells with red background must not be changed because they contents more than one paragraph and/or a table (in table). The current implementation is not able to detect the situation correct in cell B1, C1 and C2 which should return ULONG_MAX. Your patch would return ULONG_MAX for B1, C1 and C2 which is fine, but it would return ULONG_MAX for B2 as well which is wrong.
Created attachment 45502 [details] the patch file
I think I understand. If the cell only contains a section, its number format can be changed, like a single paragraph in the cell. It should reject the change only when the cell contains more than one paragraph or tables (in table).
Yes, you're absolutely right. One situation is not covered by your patch: If a cell contains a section which contains a table with one cell. But this seems to be the last problem I can imagine ;-) BTW: A SwTableNode is always a SwStartNode, it's not necessary to check both.
Created attachment 45544 [details] the patch file
According to your suggestion, I modified the patch file. I change the table node check to if the cell contains a table node between the start node of the cell position and the end the cell of the cell position, the fuction SwTableBox::IsValidNumTxtNd(..) will return ULONG_MAX. I think this patch could cover any situation you mentioned. Thank you very much for you guidance.
I have to construct more complex cases to break your code ;-) Sections could be nested, please check your code if a cell contains the following: <cell> <section A> <section B> <text node X/> </section B> <text node Y/> </section A> </cell> I doubt your check will identify text node B as a problem?! BTW: The check could be less sophisticated: every section contains at least one text node, every table contains at least one text node. You only have to check if there is a second text node behind the first one and before the end of the cell. There is no need to check for other start or table nodes. Okay, first you have to check if your first paragraph is already inside an inner table of course.
Created attachment 45568 [details] the patch file
I think the table node check is valuable. If the cell contains: <cell> <section A> <table 1> <text node X/> </table 1> </section A> </cell> So, According your suggestion, I modified the check in the function SwTableBox::IsValidNumTxtNd(..),to check if there is a second text node behind the first one and before the end of the cell, and add a table node check when the position between the cell start and the cell end.
Yes, your last patch will work for every scenario I'm able to imagine :-) Now we can have a look if it can be optimized. Your new code iterates the cell content, the SwNodes::GoNexct(..) function call iterates the cell content, too. Your iteration is necessary but the old GoNext(..) call can be removed if your iteration delivers the correct text node. Something like this: SwTxtNode *pTextNode = 0; for(..pNext..) { if( IsTableNode() ) { pTextNode = 0; break; // Table found } if( IsTxtNode() ) { if( pTextNode ) { pTextNode = 0; break; } pTextNode = pNext; } } if( pTextNode ) { ..... } else return ULONG_MAX; What do you think?
Created attachment 45707 [details] the patch file
I think you are right! I modified the function SwTableBox::IsValidNumTxtNd(..) as your suggestion, removed the code (SwNodes::GoNext(..)). Please have a look at the new patch file. Thank you!
Fine, I took your code and checked it in for CWS swqbf99. Thank you for your patch!
Ready for QA.
Verified fix in CWS swqbf99.
Checked in 680m222.