Bug 45312 - HSSFSimpleShape can not draw line properly.
Summary: HSSFSimpleShape can not draw line properly.
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: unspecified
Hardware: PC Windows XP
: P2 major with 8 votes (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2008-06-29 23:47 UTC by namsu
Modified: 2014-08-31 11:42 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description namsu 2008-06-29 23:47:54 UTC
I draw two lines by using HSSFSimpleShape.

I expected that it looks like a V mark ("\/").

But it looks "\_" at the excel of ms office 2007.

and looks "\ \" at the excel of ms office 2003.

If end_x or end_y is greater than start_x or start_y then it dose not go properly.

The following is the part of source.

            HSSFClientAnchor a1 = new HSSFClientAnchor();
            a1.setAnchor( (short)1, 1, 0, 0, (short) 1, 1, 512, 100);
            HSSFSimpleShape shape1 = patriarch.createSimpleShape(a1);
            HSSFClientAnchor a1 = new HSSFClientAnchor();
            a1.setAnchor( (short)1, 1, 512, 100, (short) 1, 1, 1024, 0);
            HSSFSimpleShape shape1 = patriarch.createSimpleShape(a1);

The original source code from 
Comment 1 Dominik Stadler 2014-08-31 09:20:52 UTC
I did some analysis: it seems Excel and OpenOffice use a flag "FLIPVERT" and reverse vertical coordinates for the second drawing, so a workaround currently is to use the following:

                HSSFClientAnchor a1 = new HSSFClientAnchor();
                a1.setAnchor( (short)2, 2, 512, 0, (short) 2, 2, 1024, 100);
                HSSFSimpleShape shape1 = patriarch.createSimpleShape(a1);

we probably need to search the spec if this behavior is described, when the record is serialized, the data ends up in two separate sub-records of the EscherContainerRecord:

           Child 0:
              RecordId: 0xF00A
              Version: 0x0002
              ShapeType: 0x0014
              ShapeId: 1025
              Flags: FLIPVERT|HAVEANCHOR|HASSHAPETYPE (0x00000A80)
           Child 2:
              RecordId: 0xF010
              Version: 0x0000
              Instance: 0x0000
              Flag: 0
              Col1: 2
              DX1: 512
              Row1: 2
              DY1: 0
              Col2: 2
              DX2: 1024
              Row2: 2
              DY2: 100
              Extra Data:
            No Data
Comment 2 Dominik Stadler 2014-08-31 11:42:19 UTC
I looked at the spec, there is no mention of this behavior and I don't see an easy way of handling this inside POI with correct backwards compatibility. 

Therefore I have updated javadoc via r1621586 to mention that some flipping might be necessary.

So overall this Bug is WONTFIX as we don't fix it in POI as the behavior is caused by Excel itself in an undocumented way.