glens 2004/08/25 20:17:57
Modified: src/documentation/content/xdocs status.xml
src/java/org/apache/poi/hssf/record/formula StringPtg.java
Added: src/examples/src/org/apache/poi/hssf/usermodel/examples
HyperlinkFormula.java
Log:
Bugzilla Bug 29976 [PATCH] HSSF hyperlink formula size problem
Revision Changes Path
1.11 +4 -0 jakarta-poi/src/documentation/content/xdocs/status.xml
Index: status.xml
===================================================================
RCS file: /home/cvs/jakarta-poi/src/documentation/content/xdocs/status.xml,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- status.xml 23 Aug 2004 08:52:26 -0000 1.10
+++ status.xml 26 Aug 2004 03:17:54 -0000 1.11
@@ -12,6 +12,10 @@
<changes>
+ <release version="unreleased" date="???">
+ <action dev="POI-DEVELOPERS" type="fix" context="All">Bugzilla Bug
29976 [PATCH] HSSF hyperlink formula size problem</action>
+ </release>
+
<release version="2.5.1-FINAL" date="29 Feburary 2004">
<action dev="POI-DEVELOPERS" type="add" context="All">Outlining
support</action>
<action dev="POI-DEVELOPERS" type="fix" context="All">27574 - [PATCH]
HSSFDateUtil.getExcelDate() is one hour off when DST changes</action>
1.12 +9 -7
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/StringPtg.java
Index: StringPtg.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/StringPtg.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- StringPtg.java 23 Aug 2004 08:52:29 -0000 1.11
+++ StringPtg.java 26 Aug 2004 03:17:55 -0000 1.12
@@ -25,6 +25,7 @@
* Stores a String value in a formula value stored in the format <length 2
bytes>char[]
* @author Werner Froidevaux
* @author Jason Height (jheight at chariot dot net dot au)
+ * @author Bernard Chesnoy
*/
public class StringPtg
@@ -34,7 +35,7 @@
public final static byte sid = 0x17;
//NOTE: OO doc says 16bit lenght, but BiffViewer says 8
// Book says something totally different, so dont look there!
- byte field_1_length;
+ int field_1_length;
byte field_2_options;
BitField fHighByte = new BitField(0x01);
private String field_3_string;
@@ -47,14 +48,14 @@
public StringPtg(byte [] data, int offset)
{
offset++;
- field_1_length = data[offset];
+ field_1_length = data[offset] & 0xFF;
field_2_options = data[offset+1];
if (fHighByte.isSet(field_2_options)) {
- field_3_string=
StringUtil.getFromUnicodeBE(data,offset+2,field_1_length);
+ field_3_string=
StringUtil.getFromUnicodeLE(data,offset+2,field_1_length);
}else {
field_3_string=StringUtil.getFromCompressedUnicode(data,offset+2,field_1_length);
}
-
+
//setValue(new String(data, offset+3, data[offset+1] + 256*data[offset+2]));
}
@@ -70,7 +71,7 @@
this.field_2_options=0;
this.fHighByte.setBoolean(field_2_options, false);
this.field_3_string=value;
- this.field_1_length=(byte)value.length(); //for the moment, we support only
ASCII strings in formulas we create
+ this.field_1_length=value.length(); //for the moment, we support only ASCII
strings in formulas we create
}
/*
@@ -88,7 +89,7 @@
public void writeBytes(byte [] array, int offset)
{
array[ offset + 0 ] = sid;
- array[ offset + 1 ] = field_1_length;
+ array[ offset + 1 ] = (byte)field_1_length;
array[ offset + 2 ] = field_2_options;
if (fHighByte.isSet(field_2_options)) {
StringUtil.putUnicodeLE(getValue(),array,offset+3);
@@ -101,7 +102,7 @@
{
if (fHighByte.isSet(field_2_options)) {
return 2*field_1_length+3;
- }else {
+ } else {
return field_1_length+3;
}
}
@@ -123,3 +124,4 @@
}
}
+
1.1
jakarta-poi/src/examples/src/org/apache/poi/hssf/usermodel/examples/HyperlinkFormula.java
Index: HyperlinkFormula.java
===================================================================
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hssf.usermodel.examples;
import org.apache.poi.hssf.usermodel.*;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* Test if hyperlink formula, with url that got more than 127 charaters, works
*
* @author Bernard Chesnoy
*/
public class HyperlinkFormula
{
public static void main(String[] args)
throws IOException
{
HSSFCell cell;
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");
HSSFRow row = sheet.createRow((short) 0);
cell = row.createCell((short)0);
cell.setCellType(HSSFCell.CELL_TYPE_FORMULA);
cell.setCellFormula("HYPERLINK(\"http://127.0.0.1:8080/toto/truc/index.html?test=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
\"test\")");
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]