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/09 10:20:45 UTC

DO NOT REPLY [Bug 51173] New: XSSFClientAnchor.setDx1() has no effect

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

             Bug #: 51173
           Summary: XSSFClientAnchor.setDx1() has no effect
           Product: POI
           Version: 3.7
          Platform: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: at13@online.de
    Classification: Unclassified


The methods:
setDx1(...)
setDx2(...)   
setDy1(...)
setDy2(...)

have no effect on XSSFClientAnchor.
On HSSFClientAnchor you can position/size a picture within the cell and it
works, on XSSFClientAnchor it does not.
I also tried the newest 3.8-beta2 and it also does not work.

-- 
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 51173] XSSFClientAnchor.setDx1() has no effect

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

--- Comment #3 from at13@online.de 2011-05-11 06:38:35 UTC ---
OK, these methods DOES have an effect. But the parameter values have to be much
bigger in XSSFClientAnchor than in HSSFClientAnchor.
I have not find out yet, how to calculate these values or what unit they have. 
The JavaDoc only says e.g. for setDx1(int dx1):
"dx1 the x coordinate within the first cell"
but not what unit the parameter has.
Is there any documentation for that?
So I think there is no bug, so this bug entry can be closed?

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


[Bug 51173] XSSFClientAnchor.setDx1() has no effect

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

--- Comment #8 from Malcolm McMahon <Ma...@costcutter.com> ---
(In reply to suman saurav from comment #7)
> Hi Nick,
> 
> I have same issue here. And I have tried every EMU value like
> XSSFShape.EMU_PER_PIXEL and multiplied it by 10 and 20, but it doesn't make
> an effect in converted sheet. Images are still coming at the edge of cell.
> 
> Below is the code, i am using write now:
> 
> XSSFClientAnchor anchor = new
> XSSFClientAnchor(XSSFShape.EMU_PER_PIXEL*200,XSSFShape.EMU_PER_PIXEL*200,0,0,
> (short)col,row,(short)col1,row1);
> 
> Please suggest, if i did anything wrong.
> 
> Thanks,
> Saurav


The real problem behind all these bug report seems to be in
XSSFPicture.resize();

In here we find

 anchor.setCol2(col2);

 anchor.setDx1(0);  // !!


 anchor.setDx2(pref.getDx2());


 anchor.setRow2(row2);

 anchor.setDy1(0);  // !!

In other words calling resize discards any offsets you've set in your anchor.

I've replaced the resize call with:

Picture pic = drawing.createPicture(anchor, pictures.get(value));
ClientAnchor pref = pic.getPreferredSize();
anchor.setDx2(pref.getDx2() + anchor.getDx1());
anchor.setDy2(pref.getDy2() + anchor.getDy1());

And it works as expected. Something slightly more complicated would be needed
if the picture extended over more than one cell.


 anchor.setDy2(pref.getDy2());

This kills any offsets you set, and if you don't call resize your picture will
probably collapse.

The resize source could be changed easily enough to preserver dx1 and dy1, and
I don't imagine any existing code would break.

-- 
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 51173] XSSFClientAnchor.setDx1() has no effect

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

--- Comment #4 from Nick Burch <ni...@alfresco.com> 2011-05-11 10:00:02 UTC ---
Could you try creating a few files with HSSF with various dx/dy values, then
open these in Excel, save as .xlsx, and see what the values were written as?
That might give us a hint on the scaling factor different between the two
formats

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


[Bug 51173] XSSFClientAnchor.setDx1() has no effect

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

suman saurav <su...@aptaracorp.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |INVALID

--- Comment #7 from suman saurav <su...@aptaracorp.com> ---
Hi Nick,

I have same issue here. And I have tried every EMU value like
XSSFShape.EMU_PER_PIXEL and multiplied it by 10 and 20, but it doesn't make an
effect in converted sheet. Images are still coming at the edge of cell.

Below is the code, i am using write now:

XSSFClientAnchor anchor = new
XSSFClientAnchor(XSSFShape.EMU_PER_PIXEL*200,XSSFShape.EMU_PER_PIXEL*200,0,0,(short)col,row,(short)col1,row1);

Please suggest, if i did anything wrong.

Thanks,
Saurav

-- 
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 51173] XSSFClientAnchor.setDx1() has no effect

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

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

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

--- Comment #6 from Nick Burch <ni...@alfresco.com> 2011-05-13 09:24:32 UTC ---
Note added in r1102624, thanks for the investigations!

-- 
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 51173] XSSFClientAnchor.setDx1() has no effect

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

--- Comment #2 from at13@online.de 2011-05-10 08:14:54 UTC ---
Hello!
I created two xlsx files one with calling the setdx... methods and one without.
Then I opened these files as zip files and compared the sheet1.xml files in the
folder xl/worksheets. Both of the sheet1.xml-files were exactly the same.
So if I did everything correct, it seems that the methods have no effect on the
creating of the XML. I am not very familiar with the internal structure of the
xslx files.

-- 
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 51173] XSSFClientAnchor.setDx1() has no effect

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

--- Comment #5 from at13@online.de 2011-05-11 13:53:55 UTC ---
The secret is solved!
You have to calculate everything in pixels, the anchor-width and -height, the
image-width and -height and with that the margin values (dx and dy).
In the setDx.../setDy... methods you have to multiply the dx/dy pixel-values
with the constant XSSFShape.EMU_PER_PIXEL and voila, everything works!
Pleeeeeaaaase write JavaDocs for those secret things! I like the apache
libraries and APIs very much and you guys make a great job, but documentation
is very important for using the libraries.

-- 
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 51173] XSSFClientAnchor.setDx1() has no effect

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO
         OS/Version|                            |All

--- Comment #1 from Nick Burch <ni...@alfresco.com> 2011-05-09 15:58:41 UTC ---
Is the problem that the XML isn't changing, or that the expected effect in
excel isn't seen? (These are two very different problems)

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