Bug 58922 - org.apache.poi.xwpf.usermodel.XWPFRun.setFontSize(-1) sets size to +32767
Summary: org.apache.poi.xwpf.usermodel.XWPFRun.setFontSize(-1) sets size to +32767
Status: RESOLVED WORKSFORME
Alias: None
Product: POI
Classification: Unclassified
Component: XWPF (show other bugs)
Version: 3.14-dev
Hardware: PC All
: P2 minor (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-26 13:13 UTC by simon
Modified: 2016-03-29 17:03 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description simon 2016-01-26 13:13:56 UTC
I don't think this is ever intended behavior for org.apache.poi.xwpf.usermodel.XWPFRun;

B.setFontSize(A.getFontSize()); // setFontSize(-1) == +32767
B.setTextPosition(A.getTextPosition()); //similar
Comment 1 Dominik Stadler 2016-03-29 16:09:22 UTC
I tried to reproduce this with the following unit-test, this works for me, not sure what exactly fails for you here.

If this is still a problem for you, then please reopen this bug and attach a complete unit-test which reproduces the problem.


        assertEquals(-1, run.getFontSize());

        run.setFontSize(10);
        assertEquals(10, run.getFontSize());

        run.setFontSize(Short.MAX_VALUE-1);
        assertEquals(Short.MAX_VALUE-1, run.getFontSize());

        run.setFontSize(Short.MAX_VALUE);
        assertEquals(Short.MAX_VALUE, run.getFontSize());

        run.setFontSize(Short.MAX_VALUE+1);
        assertEquals(Short.MAX_VALUE+1, run.getFontSize());

        run.setFontSize(Integer.MAX_VALUE-1);
        assertEquals(Integer.MAX_VALUE-1, run.getFontSize());

        run.setFontSize(Integer.MAX_VALUE);
        assertEquals(Integer.MAX_VALUE, run.getFontSize());

        run.setFontSize(-1);
        assertEquals(-1, run.getFontSize());


        assertEquals(-1, run.getTextPosition());

        run.setTextPosition(10);
        assertEquals(10, run.getTextPosition());

        run.setTextPosition(Short.MAX_VALUE-1);
        assertEquals(Short.MAX_VALUE-1, run.getTextPosition());

        run.setTextPosition(Short.MAX_VALUE);
        assertEquals(Short.MAX_VALUE, run.getTextPosition());

        run.setTextPosition(Short.MAX_VALUE+1);
        assertEquals(Short.MAX_VALUE+1, run.getTextPosition());

        run.setTextPosition(Short.MAX_VALUE+1);
        assertEquals(Short.MAX_VALUE+1, run.getTextPosition());

        run.setTextPosition(Integer.MAX_VALUE-1);
        assertEquals(Integer.MAX_VALUE-1, run.getTextPosition());

        run.setTextPosition(Integer.MAX_VALUE);
        assertEquals(Integer.MAX_VALUE, run.getTextPosition());

        run.setTextPosition(-1);
        assertEquals(-1, run.getTextPosition());
Comment 2 Dominik Stadler 2016-03-29 17:03:29 UTC
I also added a unit-test in r1737018