From 4ab00acc7cf8a56a22153c84ec203707cd413846 Mon Sep 17 00:00:00 2001 From: Yegor Kozlov Date: Thu, 7 Feb 2008 08:56:59 +0000 Subject: support for excel hypelrinks git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@619310 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/hssf/record/TestHyperlinkRecord.java | 407 +++++++++++++++------ .../apache/poi/hssf/usermodel/TestHSSFCell.java | 14 +- .../poi/hssf/usermodel/TestHSSFHyperlink.java | 191 ++++++++++ 3 files changed, 500 insertions(+), 112 deletions(-) create mode 100755 src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java (limited to 'src/testcases/org/apache/poi') diff --git a/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java b/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java index 70548fe95f..3d2ca406ce 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java @@ -18,114 +18,311 @@ package org.apache.poi.hssf.record; import java.io.ByteArrayInputStream; import java.net.URL; +import java.util.Arrays; import junit.framework.TestCase; +/** + * Test HyperlinkRecord + * + * @author Nick Burch + * @author Yegor Kozlov + */ public class TestHyperlinkRecord extends TestCase { - protected void setUp() throws Exception { - super.setUp(); - } - - private byte[] data = new byte[] { - -72, 1, 110, 0, - // ??, Row, col, xf - 6, 0, 3, 0, 2, 0, 2, 0, - - // ?? - -48, -55, -22, 121, -7, -70, -50, 17, - -116, -126, 0, -86, 0, 75, -87, 11, - 2, 0, 0, 0, - - // URL length - 23, 0, 0, 0, - - // Label length - 4, 0, 0, 0, - - // Label - 76, 0, 44, 0, 65, 0, 0, 0, - - // ?? - -32, -55, -22, 121, -7, -70, -50, 17, - -116, -126, 0, -86, 0, 75, -87, 11, - 46, 0, 0, 0, - - // URL - 104, 0, 116, 0, 116, 0, 112, 0, 58, 0, 47, 0, 47, 0, 119, - 0, 119, 0, 119, 0, 46, 0, 108, 0, 97, 0, 107, 0, 105, - 0, 110, 0, 103, 0, 115, 0, 46, 0, 99, 0, 111, 0, - 109, 0, - 0, 0 }; - - private byte[] data2 = new byte[] { - -72, 1, -126, 0, - // ??, Row, col, xf - 2, 0, 2, 0, 4, 0, 4, 0, - - // ?? - -48, -55, -22, 121, -7, -70, -50, 17, - -116, -126, 0, -86, 0, 75, -87, 11, - 2, 0, 0, 0, - - // URL and Label lengths - 23, 0, 0, 0, - 15, 0, 0, 0, - - // Label - 83, 0, 116, 0, 97, 0, 99, 0, 105, 0, - 101, 0, 64, 0, 65, 0, 66, 0, 67, 0, - 46, 0, 99, 0, 111, 0, 109, 0, 0, 0, - - // ?? - -32, -55, -22, 121, -7, -70, -50, 17, - -116, -126, 0, -86, 0, 75, -87, 11, - 44, 0, 0, 0, - - // URL - 109, 0, 97, 0, 105, 0, 108, 0, 116, 0, - 111, 0, 58, 0, 83, 0, 116, 0, 97, 0, - 99, 0, 105, 0, 101, 0, 64, 0, 65, 0, - 66, 0, 67, 0, 46, 0, 99, 0, 111, 0, - 109, 0, 0, 0 }; - - public void testRecordParsing() throws Exception { - RecordInputStream inp = new RecordInputStream( - new ByteArrayInputStream(data) - ); - inp.nextRecord(); - - HyperlinkRecord r = new HyperlinkRecord(inp); - - assertEquals(3, r.getRow()); - assertEquals(2, r.getColumn()); - assertEquals(2, r.getXFIndex()); - - assertEquals("L,A", r.getLabel()); - assertEquals("http://www.lakings.com", r.getUrlString()); - assertEquals(new URL("http://www.lakings.com"), r.getUrl()); - - // Check it serialises as expected - assertEquals(data.length, r.getRecordSize()); - byte[] d = r.serialize(); - assertEquals(data.length, d.length); - for(int i=0; i