You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2011/05/04 11:40:04 UTC

DO NOT REPLY [Bug 51148] New: XWPFDocument.removeBodyElement(int pos) error

https://issues.apache.org/bugzilla/show_bug.cgi?id=51148

             Bug #: 51148
           Summary: XWPFDocument.removeBodyElement(int pos) error
           Product: POI
           Version: 3.7
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: major
          Priority: P2
         Component: XWPF
        AssignedTo: dev@poi.apache.org
        ReportedBy: ptorrodellas@fihoca.com
    Classification: Unclassified


XWPFDocument.removeBodyElement(int pos) throws IndexOutOfBoundsException
whatever the value of the element index.

I think that this is caused by two XWPFDocument class code errors:

1 - In removeBodyElement(int pos), the statement:

bodyElements.remove(pos);

should be placed AFTER the statements:

Integer tablePos = getTablePos(pos); 

and

Integer paraPos = getParagraphPos(pos);

instead of before, otherwise the element is not there in the bodyElements List
to be used to locate it in the paragraphs or tables Lists.

2 - In getParagraphPos(int pos) and getTablePos(int pos), the for loop should
be:
for(int i = startPos; i >= 0; i--) {
....
}

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 51148] XWPFDocument.removeBodyElement(int pos) error

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51148

Nick Burch <ni...@alfresco.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #1 from Nick Burch <ni...@alfresco.com> 2011-05-06 02:14:48 UTC ---
Good spot. I've cleaned up the code a bit (the table/paragraph code is now
generic), and added a bunch of unit tests for it. Fixed in r1100027.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org