poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 54860] New: Range.getTable(...) doesn't initialize previous Paragraph for comparison
Date Thu, 18 Apr 2013 08:01:26 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=54860

            Bug ID: 54860
           Summary: Range.getTable(...) doesn't initialize previous
                    Paragraph for comparison
           Product: POI
           Version: 3.8
          Hardware: PC
                OS: Windows Vista
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HWPF
          Assignee: dev@poi.apache.org
          Reporter: bork@yatta.de
    Classification: Unclassified

org.apache.poi.hwpf.usermodel.Range.getTable(Paragraph) checks if a given
Paragraph is the first in the table by comparing it with the previous
paragraph. So the previous paragraph is created in line 926 by calling 

<code>
            Paragraph previous = Paragraph.newParagraph( this,
                    _paragraphs.get( r._parStart - 1 ) );
</code>

Unfortunatly, the end index in the sections list of the Range of the previous
Paragraph is not correctly initialized.

So the comparison in line 931 fails, if r._sectionStart is larger than 1 (as
previous._sectionEnd is still 0.

<code>
            if ( previous.isInTable() && //
                    previous.getTableLevel() == tableLevel //
                    && previous._sectionEnd >= r._sectionStart )
</code>

Resolution: Initialize the previous Paragraph by calling initAll():

<code>
        if ( r._parStart != 0 )
        {
            Paragraph previous = Paragraph.newParagraph( this,
                    _paragraphs.get( r._parStart - 1 ) );
            previous.initAll(); // initialize sections for proper comparison
            if ( previous.isInTable() && //
                    previous.getTableLevel() == tableLevel //
                    && previous._sectionEnd >= r._sectionStart )
            {
                throw new IllegalArgumentException(
                        "This paragraph is not the first one in the table" );
            }
        }

</code>

-- 
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


Mime
View raw message