poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject svn commit: r627544 [1/2] - in /poi/branches/ooxml: ./ src/documentation/content/xdocs/ src/documentation/content/xdocs/getinvolved/ src/documentation/content/xdocs/hssf/ src/examples/src/org/apache/poi/hssf/usermodel/examples/ src/java/org/apache/poi/...
Date Wed, 13 Feb 2008 17:34:59 GMT
Author: ugo
Date: Wed Feb 13 09:34:43 2008
New Revision: 627544

URL: http://svn.apache.org/viewvc?rev=627544&view=rev
Log:
Merged revisions 618680-620582 via svnmerge from 
https://svn.apache.org/repos/asf/poi/trunk

........
  r618680 | nick | 2008-02-05 16:51:29 +0100 (Tue, 05 Feb 2008) | 1 line
  
  Add java.lang.Iterable style methods for iterating over rows and cells, but don't actually implement that, as it wasn't in jdk 1.3 or jdk 1.4, with is rather tedious
........
  r618690 | nick | 2008-02-05 17:21:21 +0100 (Tue, 05 Feb 2008) | 1 line
  
  Tweaks to the iterator use guides for hssf
........
  r618692 | nick | 2008-02-05 17:32:45 +0100 (Tue, 05 Feb 2008) | 1 line
  
  Few tweaks to the patching guide
........
  r618940 | yegor | 2008-02-06 10:47:13 +0100 (Wed, 06 Feb 2008) | 1 line
  
  3.0.2-FINAL released
........
  r619001 | nick | 2008-02-06 15:35:05 +0100 (Wed, 06 Feb 2008) | 1 line
  
  Implement hashCode and equals for HSSFFont and HSSFCellStyle
........
  r619310 | yegor | 2008-02-07 09:56:59 +0100 (Thu, 07 Feb 2008) | 1 line
  
  support for excel hypelrinks
........
  r619382 | nick | 2008-02-07 13:39:12 +0100 (Thu, 07 Feb 2008) | 1 line
  
  Patch from bug #44373 - Have HSSFDateUtil.isADateFormat support more date formats
........
  r619502 | nick | 2008-02-07 17:53:23 +0100 (Thu, 07 Feb 2008) | 1 line
  
  Handle timezones better with cell.setCellValue(Calendar), so now 20:00-03:00, 20:00+00:00 and 20:00+03:00 will all be recorded as 20:00, and not 17:00 / 20:00 / 23:00 (pass a Date not a Calendar for old behaviour) - patch from bug #38641
........
  r619509 | nick | 2008-02-07 18:12:09 +0100 (Thu, 07 Feb 2008) | 1 line
  
  Add (disabled) failing testcase for bug #44375
........
  r619848 | klute | 2008-02-08 12:55:43 +0100 (Fri, 08 Feb 2008) | 1 line
  
  - Fixed bug 44375 - HPSF now copes with a broken dictionary in Document Summary Information stream. RuntimeExceptions that occured when trying to read bogus data are now caught. Dictionary entries up to but not including the bogus one are preserved, the rest is ignored.
........
  r619849 | klute | 2008-02-08 12:56:11 +0100 (Fri, 08 Feb 2008) | 1 line
  
  - Fixed bug 44375 - HPSF now copes with a broken dictionary in Document Summary Information stream. RuntimeExceptions that occured when trying to read bogus data are now caught. Dictionary entries up to but not including the bogus one are preserved, the rest is ignored.
........
  r619851 | nick | 2008-02-08 13:02:10 +0100 (Fri, 08 Feb 2008) | 1 line
  
  Copy Rainer's change note from changes.xml to status.xml, as it's needed in both
........
  r619968 | nick | 2008-02-08 19:17:29 +0100 (Fri, 08 Feb 2008) | 1 line
  
  Tweak layout
........
  r620341 | nick | 2008-02-10 22:54:13 +0100 (Sun, 10 Feb 2008) | 1 line
  
  Test for bug #42564 - appears to already be fixed
........
  r620557 | nick | 2008-02-11 18:55:09 +0100 (Mon, 11 Feb 2008) | 1 line
  
  Another test relating to bug #42564 - this one is still failing
........
  r620582 | nick | 2008-02-11 20:14:04 +0100 (Mon, 11 Feb 2008) | 1 line
  
  If we have a document with a hpsf stream that exists, but is of the wrong type, then log a warning but continue
........

Added:
    poi/branches/ooxml/src/examples/src/org/apache/poi/hssf/usermodel/examples/Hyperlinks.java
      - copied unchanged from r620582, poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/Hyperlinks.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hwpf/data/ProblemExtracting.doc
      - copied unchanged from r620582, poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/data/ProblemExtracting.doc
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractorBugs.java
      - copied unchanged from r620582, poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractorBugs.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hpsf/basic/TestReadAllFiles.java
      - copied unchanged from r620582, poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestReadAllFiles.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hpsf/data/TestBug44375.xls
      - copied unchanged from r620582, poi/trunk/src/testcases/org/apache/poi/hpsf/data/TestBug44375.xls
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/42564-2.xls
      - copied unchanged from r620582, poi/trunk/src/testcases/org/apache/poi/hssf/data/42564-2.xls
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/42564.xls
      - copied unchanged from r620582, poi/trunk/src/testcases/org/apache/poi/hssf/data/42564.xls
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java
      - copied unchanged from r620582, poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java
Modified:
    poi/branches/ooxml/   (props changed)
    poi/branches/ooxml/src/documentation/content/xdocs/changes.xml
    poi/branches/ooxml/src/documentation/content/xdocs/getinvolved/index.xml
    poi/branches/ooxml/src/documentation/content/xdocs/hssf/quick-guide.xml
    poi/branches/ooxml/src/documentation/content/xdocs/index.xml
    poi/branches/ooxml/src/documentation/content/xdocs/status.xml
    poi/branches/ooxml/src/java/org/apache/poi/POIDocument.java
    poi/branches/ooxml/src/java/org/apache/poi/hpsf/Property.java
    poi/branches/ooxml/src/java/org/apache/poi/hpsf/Section.java
    poi/branches/ooxml/src/java/org/apache/poi/hpsf/VariantSupport.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/ExtendedFormatRecord.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/FontRecord.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFFont.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hpsf/basic/TestBasic.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java

Propchange: poi/branches/ooxml/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Feb 13 09:34:43 2008
@@ -1 +1 @@
-/poi/trunk:1-612483,612512,612520,613395-613401,614211,614274,614870,614878-614909,615190-618235,618328
+/poi/trunk:1-612483,612512,612520,613395-613401,614211,614274,614870,614878-614909,615190-618235,618328,618680-620582

Modified: poi/branches/ooxml/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/documentation/content/xdocs/changes.xml?rev=627544&r1=627543&r2=627544&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/changes.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/changes.xml Wed Feb 13 09:34:43 2008
@@ -36,6 +36,11 @@
 
 		<!-- Don't forget to update status.xml too! -->
         <release version="3.1-beta1" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">44375 - Cope with a broken dictionary in Document Summary Information stream. RuntimeExceptions that occured when trying to read bogus data are now caught. Dictionary entries up to but not including the bogus one are preserved, the rest is ignored.</action>
+           <action dev="POI-DEVELOPERS" type="fix">38641 - Handle timezones better with cell.setCellValue(Calendar), so now 20:00-03:00, 20:00+00:00 and 20:00+03:00 will all be recorded as 20:00, and not 17:00 / 20:00 / 23:00 (pass a Date not a Calendar for old behaviour)</action>
+           <action dev="POI-DEVELOPERS" type="fix">44373 - Have HSSFDateUtil.isADateFormat recognize more formats as being dates</action>
+           <action dev="POI-DEVELOPERS" type="add">37923 - Support for Excel hyperlinks</action>
+           <action dev="POI-DEVELOPERS" type="add">Implement hashCode() and equals(obj) on HSSFFont and HSSFCellStyle</action>
            <action dev="POI-DEVELOPERS" type="fix">44345 - Implement CountA, CountIf, Index, Rows and Columns functions</action>
            <action dev="POI-DEVELOPERS" type="fix">44336 - Properly escape sheet names as required when figuring out the text of formulas</action>
            <action dev="POI-DEVELOPERS" type="add">44326 - Improvements to how SystemOutLogger and CommonsLogger log messages with exceptions, and avoid an infinite loop with certain log messages with exceptions</action>

Modified: poi/branches/ooxml/src/documentation/content/xdocs/getinvolved/index.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/documentation/content/xdocs/getinvolved/index.xml?rev=627544&r1=627543&r2=627544&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/getinvolved/index.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/getinvolved/index.xml Wed Feb 13 09:34:43 2008
@@ -96,7 +96,8 @@
      Create patches by getting the latest sources from Subversion.
      Alter or add files as appropriate.  Then, from the poi directiory,
      type svn diff > mypatch.patch.  This will capture all of your changes
-     in a patch file of the appropriate format.  Next, if you've added any 
+     in a patch file of the appropriate format. However, svn diff won't
+     capture any new files you may have added. So, if you've added any 
      files, create an archive (tar.bz2 preferred as its the smallest) in a 
      path-preserving archive format, relative to your poi directory. 
      You'll attach both files in the next step.
@@ -117,6 +118,33 @@
      Standards</link>).  Patches that are of low quality may be rejected or 
      the contributer may be asked to bring them up to spec.
    </p>
+   <p>If you use a unix shell, you may find the following following
+    sequence of commands useful for building the files to attach.</p>
+   <source>
+# Run this in the root of the checkout, i.e. the directory holding
+#  build.xml and poi.pom
+
+# Build the directory to hold new files
+mkdir /tmp/poi-patch/
+mkdir /tmp/poi-patch/new-files/
+
+# Get changes to existing files
+svn diff > /tmp/poi-patch/diff.txt
+
+# Capture any new files, as svn diff won't include them
+# Preserve the path
+svn status | grep "^\?" | awk '{printf "cp --parents %s /tmp/poi-patch/new-files/\n", $2 }' | sh -s
+
+# tar up the new files
+cd /tmp/poi-patch/new-files/
+tar jcvf ../new-files.tar.bz2
+cd ..
+
+# Upload these to bugzilla
+echo "Please upload to bugzilla:"
+echo "   /tmp/poi-patch/diff.txt"
+echo "   /tmp/poi-patch/new-files.tar.bz2"
+   </source>
   </section>
 
 </body>

Modified: poi/branches/ooxml/src/documentation/content/xdocs/hssf/quick-guide.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/documentation/content/xdocs/hssf/quick-guide.xml?rev=627544&r1=627543&r2=627544&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/hssf/quick-guide.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/hssf/quick-guide.xml Wed Feb 13 09:34:43 2008
@@ -69,6 +69,7 @@
                     <li><link href="#NamedRanges">Named Ranges and Named Cells</link></li>
                     <li><link href="#CellComments">How to set cell comments</link></li>
                     <li><link href="#Autofit">How to adjust column width to fit the contents</link></li>
+                    <li><link href="#Hyperlinks">Hyperlinks</link></li>
                 </ul>
             </section>
             <section><title>Features</title>
@@ -236,16 +237,51 @@
                     </source>
                 </section>
                 <anchor id="Iterator"/>
-                <section><title>Iterate over rows and cells (including Java 5 foreach loops)</title>
+                <section><title>Iterate over rows and cells</title>
 				<p>Sometimes, you'd like to just iterate over all the rows in
-				a sheet, or all the cells in a row. If you are using Java
-				5 or later, then this is especially handy, as it'll allow the
-				new foreach loop support to work.</p>
+				a sheet, or all the cells in a row. This is possible with
+				a simple for loop.</p>
 				<p>Luckily, this is very easy. HSSFRow defines a 
 				<em>CellIterator</em> inner class to handle iterating over 
 				the cells (get one with a call to <em>row.cellIterator()</em>),
 				and HSSFSheet provides a <em>rowIterator()</em> method to
 				give an iterator over all the rows.</p>
+				<p>(Unfortunately, due to the broken and
+				backwards-incompatible way that Java 5 foreach loops were
+				implemented, it isn't possible to use them on a codebase
+				that supports Java 1.4, as POI does)</p>
+				<source>
+	HSSFSheet sheet = wb.getSheetAt(0);
+	for (Iterator rit = sheet.rowIterator(); rit.hasNext(); ) {
+		HSSFRow row = (HSSFRow)rit.next();
+		for (Iterator cit = row.cellIterator(); cit.hasNext(); ) {
+			HSSFCell cell = (HSSFCell)cit.next();
+			// Do something here
+		}
+	}
+				</source>
+				<source>
+	HSSFSheet sheet = wb.getSheetAt(0);
+	for (Iterator&lt;HSSFRow&gt; rit = (Iterator&lt;HSSFRow&gt;)sheet.rowIterator(); rit.hasNext(); ) {
+		HSSFRow row = rit.next();
+		for (Iterator&lt;HSSFCell&gt; cit = (Iterator&lt;HSSFCell&gt;)row.cellIterator(); cit.hasNext(); ) {
+			HSSFCell cell = cit.next();
+			// Do something here
+		}
+	}
+				</source>
+                </section>
+                <section><title>Iterate over rows and cells using Java 1.5 foreach loops - OOXML Branch Only</title>
+				<p>Sometimes, you'd like to just iterate over all the rows in
+				a sheet, or all the cells in a row. If you are using Java
+				5 or later, then this is especially handy, as it'll allow the
+				new foreach loop support to work.</p>
+				<p>Luckily, this is very easy. Both HSSFSheet and HSSFRow
+				implement <em>java.lang.Iterable</em> to allow foreach
+				loops. For HSSFRow this allows access to the 
+				<em>CellIterator</em> inner class to handle iterating over 
+				the cells, and for HSSFSheet gives the 
+				<em>rowIterator()</em> to iterator over all the rows.</p>
 				<source>
 	HSSFSheet sheet = wb.getSheetAt(0);
 	for (HSSFRow row : sheet.rowIterator()) {
@@ -254,6 +290,7 @@
 		}
 	}
 				</source>
+				<note>This only works on the OOXML branch of POI</note>
                 </section>
                 <anchor id="TextExtraction"/>
                 <section><title>Text Extraction</title>
@@ -1285,6 +1322,76 @@
     set the following system property: <code> java.awt.headless=true </code>
     (either via <code>-Djava.awt.headless=true</code> startup parameter or via <code>System.setProperty("java.awt.headless", "true")</code>).
         </warning>
+     </section>
+     <anchor id="Hyperlinks"/>
+     <section><title>How to read hyperlinks</title>
+        <source>
+    HSSFSheet sheet = workbook.getSheetAt(0);
+
+    HSSFCell cell = sheet.getRow(0).getCell((short)0);
+    HSSFHyperlink link = cell.getHyperlink();
+    if(link != null){
+        System.out.println(link.getAddress());
+    }
+      </source>
+     </section>
+     <section><title>How to create hyperlinks</title>
+        <source>
+    HSSFWorkbook wb = new HSSFWorkbook();
+
+    //cell style for hyperlinks
+    //by default hypelrinks are blue and underlined
+    HSSFCellStyle hlink_style = wb.createCellStyle();
+    HSSFFont hlink_font = wb.createFont();
+    hlink_font.setUnderline(HSSFFont.U_SINGLE);
+    hlink_font.setColor(HSSFColor.BLUE.index);
+    hlink_style.setFont(hlink_font);
+
+    HSSFCell cell;
+    HSSFSheet sheet = wb.createSheet("Hyperlinks");
+
+    //URL
+    cell = sheet.createRow(0).createCell((short)0);
+    cell.setCellValue("URL Link");
+    HSSFHyperlink link = new HSSFHyperlink(HSSFHyperlink.LINK_URL);
+    link.setAddress("http://poi.apache.org/");
+    cell.setHyperlink(link);
+    cell.setCellStyle(hlink_style);
+
+    //link to a file in the current directory
+    cell = sheet.createRow(1).createCell((short)0);
+    cell.setCellValue("File Link");
+    link = new HSSFHyperlink(HSSFHyperlink.LINK_FILE);
+    link.setAddress("link1.xls");
+    cell.setHyperlink(link);
+    cell.setCellStyle(hlink_style);
+
+    //e-mail link
+    cell = sheet.createRow(2).createCell((short)0);
+    cell.setCellValue("Email Link");
+    link = new HSSFHyperlink(HSSFHyperlink.LINK_EMAIL);
+    //note, if subject contains white spaces, make sure they are url-encoded
+    link.setAddress("mailto:poi@apache.org?subject=Hyperlinks");
+    cell.setHyperlink(link);
+    cell.setCellStyle(hlink_style);
+
+    //link to a place in this workbook
+
+    //create a target sheet and cell
+    HSSFSheet sheet2 = wb.createSheet("Target Sheet");
+    sheet2.createRow(0).createCell((short)0).setCellValue("Target Cell");
+
+    cell = sheet.createRow(3).createCell((short)0);
+    cell.setCellValue("Worksheet Link");
+    link = new HSSFHyperlink(HSSFHyperlink.LINK_DOCUMENT);
+    link.setAddress("'Target Sheet'!A1");
+    cell.setHyperlink(link);
+    cell.setCellStyle(hlink_style);
+
+    FileOutputStream out = new FileOutputStream("hssf-links.xls");
+    wb.write(out);
+    out.close();
+    </source>
      </section>
 
     </body>

Modified: poi/branches/ooxml/src/documentation/content/xdocs/index.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/documentation/content/xdocs/index.xml?rev=627544&r1=627543&r2=627544&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/index.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/index.xml Wed Feb 13 09:34:43 2008
@@ -31,16 +31,17 @@
   </header>
 
   <body>
-    <section><title>POI 3.0.2 BETA2 Release</title>
- 	  <p>The latest release of Apache POI is 3.0.2 BETA2 which was promoted to "Beta" on 12 January 2008. It contains a mixture of
-		new features and bug fixes, compared to 3.0.1. A full list of changes
-		is available in 
-		<link href="./changes.html">the changelog</link>, and 
-		<link href="http://www.apache.org/dyn/closer.cgi/poi/dev/">download</link>
+    <section><title>February 06 2008 - POI 3.0.2 Released</title>
+      <p>The POI team is pleased to announce POI 3.0.2, the latest release of Apache POI.
+        There have been many important bug fixes since the 3.0.1 release and a lot of new features.  A full list of changes	is available in 
+      <link href="./changes.html">the changelog</link>, and 
+		<link href="http://www.apache.org/dyn/closer.cgi/poi/release/">download</link>
 		the source and binaries from your
-    <link href="http://www.apache.org/dyn/closer.cgi/poi/dev/">local mirror</link>.
-     The release is also available from the central Maven repository under Group ID "org.apache.poi".
+    <link href="http://www.apache.org/dyn/closer.cgi/poi/release/">local mirror</link>.
   </p>
+    <p>
+      The release is also available from the central Maven repository under Group ID "org.apache.poi" and Version "3.0.2-FINAL".
+    </p>  
   </section>
 
   <section><title>POI 3.0.1 Release</title>

Modified: poi/branches/ooxml/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/documentation/content/xdocs/status.xml?rev=627544&r1=627543&r2=627544&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/status.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/status.xml Wed Feb 13 09:34:43 2008
@@ -33,6 +33,11 @@
 	<!-- Don't forget to update changes.xml too! -->
     <changes>
         <release version="3.1-beta1" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">44375 - Cope with a broken dictionary in Document Summary Information stream. RuntimeExceptions that occured when trying to read bogus data are now caught. Dictionary entries up to but not including the bogus one are preserved, the rest is ignored.</action>
+           <action dev="POI-DEVELOPERS" type="fix">38641 - Handle timezones better with cell.setCellValue(Calendar), so now 20:00-03:00, 20:00+00:00 and 20:00+03:00 will all be recorded as 20:00, and not 17:00 / 20:00 / 23:00 (pass a Date not a Calendar for old behaviour)</action>
+           <action dev="POI-DEVELOPERS" type="fix">44373 - Have HSSFDateUtil.isADateFormat recognize more formats as being dates</action>
+           <action dev="POI-DEVELOPERS" type="add">37923 - Support for Excel hyperlinks</action>
+           <action dev="POI-DEVELOPERS" type="add">Implement hashCode() and equals(obj) on HSSFFont and HSSFCellStyle</action>
            <action dev="POI-DEVELOPERS" type="fix">44345 - Implement CountA, CountIf, Index, Rows and Columns functions</action>
            <action dev="POI-DEVELOPERS" type="fix">44336 - Properly escape sheet names as required when figuring out the text of formulas</action>
            <action dev="POI-DEVELOPERS" type="add">44326 - Improvements to how SystemOutLogger and CommonsLogger log messages with exceptions, and avoid an infinite loop with certain log messages with exceptions</action>

Modified: poi/branches/ooxml/src/java/org/apache/poi/POIDocument.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/POIDocument.java?rev=627544&r1=627543&r2=627544&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/POIDocument.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/POIDocument.java Wed Feb 13 09:34:43 2008
@@ -67,14 +67,28 @@
 
 	/**
 	 * Find, and create objects for, the standard
-	 *  Documment Information Properties (HPSF)
+	 *  Documment Information Properties (HPSF).
+	 * If a given property set is missing or corrupt,
+	 *  it will remain null;
 	 */
 	protected void readProperties() {
+		PropertySet ps;
+		
 		// DocumentSummaryInformation
-		dsInf = (DocumentSummaryInformation)getPropertySet(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
+		ps = getPropertySet(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
+		if(ps != null && ps instanceof DocumentSummaryInformation) {
+			dsInf = (DocumentSummaryInformation)ps;
+		} else if(ps != null) {
+			logger.log(POILogger.WARN, "DocumentSummaryInformation property set came back with wrong class - ", ps.getClass());
+		}
 
 		// SummaryInformation
-		sInf = (SummaryInformation)getPropertySet(SummaryInformation.DEFAULT_STREAM_NAME);
+		ps = getPropertySet(SummaryInformation.DEFAULT_STREAM_NAME);
+		if(ps instanceof SummaryInformation) {
+			sInf = (SummaryInformation)ps;
+		} else if(ps != null) {
+			logger.log(POILogger.WARN, "SummaryInformation property set came back with wrong class - ", ps.getClass());
+		}
 	}
 
 	/** 

Modified: poi/branches/ooxml/src/java/org/apache/poi/hpsf/Property.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hpsf/Property.java?rev=627544&r1=627543&r2=627544&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hpsf/Property.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hpsf/Property.java Wed Feb 13 09:34:43 2008
@@ -23,6 +23,8 @@
 
 import org.apache.poi.util.HexDump;
 import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 
 /**
  * <p>A property in a {@link Section} of a {@link PropertySet}.</p>
@@ -113,7 +115,8 @@
      * 
      * @param id the property's ID.
      * @param type the property's type, see {@link Variant}.
-     * @param value the property's value. Only certain types are allowed, see {@link Variant}. 
+     * @param value the property's value. Only certain types are allowed, see
+     *        {@link Variant}.
      */
     public Property(final long id, final long type, final Object value)
     {
@@ -210,68 +213,80 @@
         o += LittleEndian.INT_SIZE;
 
         final Map m = new HashMap((int) nrEntries, (float) 1.0);
-        for (int i = 0; i < nrEntries; i++)
+
+        try
         {
-            /* The key. */
-            final Long id = new Long(LittleEndian.getUInt(src, o));
-            o += LittleEndian.INT_SIZE;
-
-            /* The value (a string). The length is the either the
-             * number of (two-byte) characters if the character set is Unicode
-             * or the number of bytes if the character set is not Unicode.
-             * The length includes terminating 0x00 bytes which we have to strip
-             * off to create a Java string. */
-            long sLength = LittleEndian.getUInt(src, o);
-            o += LittleEndian.INT_SIZE;
-
-            /* Read the string. */
-            final StringBuffer b = new StringBuffer();
-            switch (codepage)
+            for (int i = 0; i < nrEntries; i++)
             {
-                case -1:
-                {
-                    /* Without a codepage the length is equal to the number of
-                     * bytes. */
-                    b.append(new String(src, o, (int) sLength));
-                    break;
-                }
-                case Constants.CP_UNICODE:
+                /* The key. */
+                final Long id = new Long(LittleEndian.getUInt(src, o));
+                o += LittleEndian.INT_SIZE;
+
+                /* The value (a string). The length is the either the
+                 * number of (two-byte) characters if the character set is Unicode
+                 * or the number of bytes if the character set is not Unicode.
+                 * The length includes terminating 0x00 bytes which we have to strip
+                 * off to create a Java string. */
+                long sLength = LittleEndian.getUInt(src, o);
+                o += LittleEndian.INT_SIZE;
+
+                /* Read the string. */
+                final StringBuffer b = new StringBuffer();
+                switch (codepage)
                 {
-                    /* The length is the number of characters, i.e. the number
-                     * of bytes is twice the number of the characters. */
-                    final int nrBytes = (int) (sLength * 2);
-                    final byte[] h = new byte[nrBytes];
-                    for (int i2 = 0; i2 < nrBytes; i2 += 2)
+                    case -1:
+                    {
+                        /* Without a codepage the length is equal to the number of
+                         * bytes. */
+                        b.append(new String(src, o, (int) sLength));
+                        break;
+                    }
+                    case Constants.CP_UNICODE:
+                    {
+                        /* The length is the number of characters, i.e. the number
+                         * of bytes is twice the number of the characters. */
+                        final int nrBytes = (int) (sLength * 2);
+                        final byte[] h = new byte[nrBytes];
+                        for (int i2 = 0; i2 < nrBytes; i2 += 2)
+                        {
+                            h[i2] = src[o + i2 + 1];
+                            h[i2 + 1] = src[o + i2];
+                        }
+                        b.append(new String(h, 0, nrBytes,
+                                VariantSupport.codepageToEncoding(codepage)));
+                        break;
+                    }
+                    default:
                     {
-                        h[i2] = src[o + i2 + 1];
-                        h[i2 + 1] = src[o + i2];
+                        /* For encodings other than Unicode the length is the number
+                         * of bytes. */
+                        b.append(new String(src, o, (int) sLength,
+                                 VariantSupport.codepageToEncoding(codepage)));
+                        break;
                     }
-                    b.append(new String(h, 0, nrBytes,
-                            VariantSupport.codepageToEncoding(codepage)));
-                    break;
                 }
-                default:
+
+                /* Strip 0x00 characters from the end of the string: */
+                while (b.length() > 0 && b.charAt(b.length() - 1) == 0x00)
+                    b.setLength(b.length() - 1);
+                if (codepage == Constants.CP_UNICODE)
                 {
-                    /* For encodings other than Unicode the length is the number
-                     * of bytes. */
-                    b.append(new String(src, o, (int) sLength,
-                             VariantSupport.codepageToEncoding(codepage)));
-                    break;
+                    if (sLength % 2 == 1)
+                        sLength++;
+                    o += (sLength + sLength);
                 }
+                else
+                    o += sLength;
+                m.put(id, b.toString());
             }
-
-            /* Strip 0x00 characters from the end of the string: */
-            while (b.length() > 0 && b.charAt(b.length() - 1) == 0x00)
-                b.setLength(b.length() - 1);
-            if (codepage == Constants.CP_UNICODE)
-            {
-                if (sLength % 2 == 1)
-                    sLength++;
-                o += (sLength + sLength);
-            }
-            else
-                o += sLength;
-            m.put(id, b.toString());
+        }
+        catch (RuntimeException ex)
+        {
+            final POILogger l = POILogFactory.getLogger(getClass());
+            l.log(POILogger.WARN,
+                    "The property set's dictionary contains bogus data. "
+                    + "All dictionary entries starting with the one with ID "
+                    + id + " will be ignored.", ex);
         }
         return m;
     }
@@ -320,11 +335,10 @@
 
 
     /**
-     * <p>Compares two properties.</p>
-     * 
-     * <p>Please beware that a property with ID == 0 is a special case: It does not have a type, and its value is the section's
-     * dictionary. Another special case are strings: Two properties may have
-     * the different types Variant.VT_LPSTR and Variant.VT_LPWSTR;</p>
+     * <p>Compares two properties.</p> <p>Please beware that a property with
+     * ID == 0 is a special case: It does not have a type, and its value is the
+     * section's dictionary. Another special case are strings: Two properties
+     * may have the different types Variant.VT_LPSTR and Variant.VT_LPWSTR;</p>
      * 
      * @see Object#equals(java.lang.Object)
      */

Modified: poi/branches/ooxml/src/java/org/apache/poi/hpsf/Section.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hpsf/Section.java?rev=627544&r1=627543&r2=627544&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hpsf/Section.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hpsf/Section.java Wed Feb 13 09:34:43 2008
@@ -210,7 +210,7 @@
         
         /* Pass 1: Read the property list. */
         int pass1Offset = o1;
-        List propertyList = new ArrayList(propertyCount);
+        final List propertyList = new ArrayList(propertyCount);
         PropertyListEntry ple;
         for (int i = 0; i < properties.length; i++)
         {

Modified: poi/branches/ooxml/src/java/org/apache/poi/hpsf/VariantSupport.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hpsf/VariantSupport.java?rev=627544&r1=627543&r2=627544&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hpsf/VariantSupport.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hpsf/VariantSupport.java Wed Feb 13 09:34:43 2008
@@ -109,25 +109,51 @@
     }
 
 
+    /**
+     * <p>HPSF is able to read these {@link Variant} types.</p>
+     */
+    final static public int[] SUPPORTED_TYPES = { Variant.VT_EMPTY,
+            Variant.VT_I2, Variant.VT_I4, Variant.VT_I8, Variant.VT_R8,
+            Variant.VT_FILETIME, Variant.VT_LPSTR, Variant.VT_LPWSTR,
+            Variant.VT_CF, Variant.VT_BOOL };
+
+
+
+    /**
+     * <p>Checks whether HPSF supports the specified variant type. Unsupported
+     * types should be implemented included in the {@link #SUPPORTED_TYPES}
+     * array.</p>
+     * 
+     * @see Variant
+     * @param variantType the variant type to check
+     * @return <code>true</code> if HPFS supports this type, else
+     *         <code>false</code>
+     */
+    public boolean isSupportedType(final int variantType)
+    {
+        for (int i = 0; i < SUPPORTED_TYPES.length; i++)
+            if (variantType == SUPPORTED_TYPES[i])
+                return true;
+        return false;
+    }
+
+
 
     /**
      * <p>Reads a variant type from a byte array.</p>
-     *
+     * 
      * @param src The byte array
-     * @param offset The offset in the byte array where the variant
-     * starts
-     * @param length The length of the variant including the variant
-     * type field
+     * @param offset The offset in the byte array where the variant starts
+     * @param length The length of the variant including the variant type field
      * @param type The variant type to read
-     * @param codepage The codepage to use to write non-wide strings
-     * @return A Java object that corresponds best to the variant
-     * field. For example, a VT_I4 is returned as a {@link Long}, a
-     * VT_LPSTR as a {@link String}.
+     * @param codepage The codepage to use for non-wide strings
+     * @return A Java object that corresponds best to the variant field. For
+     *         example, a VT_I4 is returned as a {@link Long}, a VT_LPSTR as a
+     *         {@link String}.
      * @exception ReadingNotSupportedException if a property is to be written
-     * who's variant type HPSF does not yet support
+     *            who's variant type HPSF does not yet support
      * @exception UnsupportedEncodingException if the specified codepage is not
-     * supported.
-     *
+     *            supported.
      * @see Variant
      */
     public static Object read(final byte[] src, final int offset,

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/ExtendedFormatRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/ExtendedFormatRecord.java?rev=627544&r1=627543&r2=627544&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/ExtendedFormatRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/ExtendedFormatRecord.java Wed Feb 13 09:34:43 2008
@@ -1814,4 +1814,56 @@
     {
         return sid;
     }
+
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime * result + field_1_font_index;
+		result = prime * result + field_2_format_index;
+		result = prime * result + field_3_cell_options;
+		result = prime * result + field_4_alignment_options;
+		result = prime * result + field_5_indention_options;
+		result = prime * result + field_6_border_options;
+		result = prime * result + field_7_palette_options;
+		result = prime * result + field_8_adtl_palette_options;
+		result = prime * result + field_9_fill_palette_options;
+		return result;
+	}
+
+	/**
+	 * Will consider two different records with the same
+	 *  contents as equals, as the various indexes
+	 *  that matter are embedded in the records
+	 */
+	public boolean equals(Object obj) {
+		if (this == obj)
+			return true;
+		if (obj == null)
+			return false;
+		if (obj instanceof ExtendedFormatRecord) {
+			final ExtendedFormatRecord other = (ExtendedFormatRecord) obj;
+			if (field_1_font_index != other.field_1_font_index)
+				return false;
+			if (field_2_format_index != other.field_2_format_index)
+				return false;
+			if (field_3_cell_options != other.field_3_cell_options)
+				return false;
+			if (field_4_alignment_options != other.field_4_alignment_options)
+				return false;
+			if (field_5_indention_options != other.field_5_indention_options)
+				return false;
+			if (field_6_border_options != other.field_6_border_options)
+				return false;
+			if (field_7_palette_options != other.field_7_palette_options)
+				return false;
+			if (field_8_adtl_palette_options != other.field_8_adtl_palette_options)
+				return false;
+			if (field_9_fill_palette_options != other.field_9_fill_palette_options)
+				return false;
+			return true;
+		}
+		return false;
+	}
+    
+    
 }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/FontRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/FontRecord.java?rev=627544&r1=627543&r2=627544&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/FontRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/FontRecord.java Wed Feb 13 09:34:43 2008
@@ -538,4 +538,37 @@
     {
         return sid;
     }
+
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime
+				* result
+				+ ((field_11_font_name == null) ? 0 : field_11_font_name
+						.hashCode());
+		result = prime * result + field_1_font_height;
+		result = prime * result + field_2_attributes;
+		result = prime * result + field_3_color_palette_index;
+		result = prime * result + field_4_bold_weight;
+		result = prime * result + field_5_super_sub_script;
+		result = prime * result + field_6_underline;
+		result = prime * result + field_7_family;
+		result = prime * result + field_8_charset;
+		result = prime * result + field_9_zero;
+		result = prime * result + field_10_font_name_len;
+		return result;
+	}
+
+	/**
+	 * Only returns two for the same exact object -
+	 *  creating a second FontRecord with the same
+	 *  properties won't be considered equal, as 
+	 *  the record's position in the record stream
+	 *  matters.
+	 */
+	public boolean equals(Object obj) {
+		if (this == obj)
+			return true;
+		return false;
+	}
 }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java?rev=627544&r1=627543&r2=627544&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java Wed Feb 13 09:34:43 2008
@@ -1,29 +1,27 @@
 /* ====================================================================
- 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.
- ==================================================================== */
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You 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.record;
 
 import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import java.util.Arrays;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.StringUtil;
+import org.apache.poi.util.HexDump;
 
 /**
  * The <code>HyperlinkRecord</code> wraps an HLINK-record 
@@ -31,146 +29,283 @@
  * Supports only external links for now (eg http://) 
  *
  * @author      Mark Hissink Muller <a href="mailto:mark@hissinkmuller.nl >mark&064;hissinkmuller.nl</a>
+ * @author      Yegor Kozlov (yegor at apache dot org)
  */
-public class HyperlinkRecord extends Record implements CellValueRecordInterface
-{
-    /** Indicates the URL in the Record */
-    private static byte[] GUID_OF_URL_MONIKER =
-    { -32, -55, -22, 121, -7, -70, -50, 17, -116, -126, 0, -86, 0, 75, -87, 11 };
-
-    /** Indicates the STD_LINK in the Record */
-    // MHM: to be added when necessary
-    private static byte[] GUID_OF_STD_LINK =  {};
+public class HyperlinkRecord extends Record {
+    /**
+     * Link flags
+     */
+    protected static final int  HLINK_URL    = 0x01;  // File link or URL.
+    protected static final int  HLINK_ABS    = 0x02;  // Absolute path.
+    protected static final int  HLINK_LABEL  = 0x14;  // Has label.
+    protected static final int  HLINK_PLACE  = 0x08;  // Place in worksheet.
 
-    /** Logger */
-    public static final Log log = LogFactory.getLog(HyperlinkRecord.class);
 
-    // quick and dirty
-    private static final boolean _DEBUG_ = true;
+    protected final static byte[] STD_MONIKER = {(byte)0xD0, (byte)0xC9, (byte)0xEA, 0x79, (byte)0xF9, (byte)0xBA, (byte)0xCE, 0x11,
+                                                 (byte)0x8C, (byte)0x82, 0x00, (byte)0xAA, 0x00, 0x4B, (byte)0xA9, 0x0B };
+    protected final static byte[] URL_MONIKER = {(byte)0xE0, (byte)0xC9, (byte)0xEA, 0x79, (byte)0xF9, (byte)0xBA, (byte)0xCE, 0x11,
+                                                 (byte)0x8C, (byte)0x82, 0x00, (byte)0xAA, 0x00, 0x4B, (byte)0xA9, 0x0B };
+    protected final static byte[] FILE_MONIKER = {0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte)0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46};
 
+    /**
+     * Tail of a URL link
+     */
+    protected final static byte[] URL_TAIL = {0x79, 0x58, (byte)0x81, (byte)0xF4, 0x3B, 0x1D, 0x7F, 0x48, (byte)0xAF, 0x2C,
+                                              (byte)0x82, 0x5D, (byte)0xC4, (byte)0x85, 0x27, 0x63, 0x00, 0x00, 0x00,
+                                               0x00, (byte)0xA5, (byte)0xAB, 0x00, 0x00};
+
+    /**
+     * Tail of a file link
+     */
+    protected final static byte[] FILE_TAIL = {(byte)0xFF, (byte)0xFF, (byte)0xAD, (byte)0xDE, 0x00, 0x00, 0x00, 0x00,
+                                                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                                                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
     public final static short sid = 0x1b8;
 
-    private short field_1_unknown;
-    private int field_2_row;
-    private short field_3_column;
-    private short field_4_xf_index;
-    private byte[] field_5_unknown;
-    private int field_6_label_opts;
-    private int field_7_url_len;
-    private int field_8_label_len;
-    private String field_9_label;
-    private byte[] field_10_unknown;
-    private int field_11_url_opts;
-    private String field_12_url;
+    /**
+     * First row of the hyperlink
+     */
+    private int rwFirst;
+
+    /**
+     * Last row of the hyperlink
+     */
+    private int rwLast;
+
+    /**
+     * First column of the hyperlink
+     */
+    private short colFirst;
 
-    /** Blank Constructor */
+    /**
+     * Last column of the hyperlink
+     */
+    private short colLast;
+
+    /**
+     * 16-byte GUID
+     */
+    private byte[] guid;
+
+    /**
+     * Some sort of options. Seems to always equal 2
+     */
+    private int label_opts;
+
+    /**
+     * Some sort of options for file links.
+     */
+    private short file_opts;
+
+    /**
+     * Link options. Can include any of HLINK_* flags.
+     */
+    private int link_opts;
+
+    /**
+     * Test label
+     */
+    private String label;
+
+    /**
+     * Moniker. Makes sense only for URL and file links
+     */
+    private byte[] moniker;
+
+    /**
+     * Link
+     */
+    private String address;
+
+    /**
+     * Remaining bytes
+     */
+    private byte[] tail;
+
+    /**
+     * Create a new hyperlink
+     */
     public HyperlinkRecord()
     {
+
     }
 
-    /** Real Constructor */
+    /**
+     * Read hyperlink from input stream
+     *
+     * @param in the stream to read from
+     */
     public HyperlinkRecord(RecordInputStream in)
     {
         super(in);
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.poi.hssf.record.CellValueRecordInterface#getColumn()
+    /**
+     * Return the column of the first cell that contains the hyperlink
+     *
+     * @return the 0-based column of the first cell that contains the hyperlink
      */
-    public short getColumn()
+   public short getFirstColumn()
     {
-        return field_3_column;
+        return colFirst;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.poi.hssf.record.CellValueRecordInterface#getRow()
+    /**
+     * Set the column of the first cell that contains the hyperlink
+     *
+     * @param col the 0-based column of the first cell that contains the hyperlink
      */
-    public int getRow()
+    public void setFirstColumn(short col)
+    {
+        this.colFirst = col;
+    }
+
+    /**
+     * Set the column of the last cell that contains the hyperlink
+     *
+     * @return the 0-based column of the last cell that contains the hyperlink
+    */
+    public short getLastColumn()
     {
-        return field_2_row;
+        return colLast;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.poi.hssf.record.CellValueRecordInterface#getXFIndex()
+    /**
+     * Set the column of the last cell that contains the hyperlink
+     *
+     * @param col the 0-based column of the last cell that contains the hyperlink
      */
-    public short getXFIndex()
+    public void setLastColumn(short col)
     {
-        return field_4_xf_index;
+        this.colLast = col;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.poi.hssf.record.CellValueRecordInterface#isAfter(org.apache.poi.hssf.record.CellValueRecordInterface)
+    /**
+     * Return the row of the first cell that contains the hyperlink
+     *
+     * @return the 0-based row of the first cell that contains the hyperlink
      */
-    public boolean isAfter(CellValueRecordInterface i)
+    public int getFirstRow()
     {
-        if (this.getRow() < i.getRow())
-        {
-            return false;
-        }
-        if ((this.getRow() == i.getRow()) && (this.getColumn() < i.getColumn()))
-        {
-            return false;
-        }
-        if ((this.getRow() == i.getRow()) && (this.getColumn() == i.getColumn()))
-        {
-            return false;
-        }
-        return true;
+        return rwFirst;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.poi.hssf.record.CellValueRecordInterface#isBefore(org.apache.poi.hssf.record.CellValueRecordInterface)
+    /**
+     * Set the row of the first cell that contains the hyperlink
+     *
+     * @param row the 0-based row of the first cell that contains the hyperlink
      */
-    public boolean isBefore(CellValueRecordInterface i)
+    public void setFirstRow(int row)
     {
-        if (this.getRow() > i.getRow())
-        {
-            return false;
-        }
-        if ((this.getRow() == i.getRow()) && (this.getColumn() > i.getColumn()))
-        {
-            return false;
-        }
-        if ((this.getRow() == i.getRow()) && (this.getColumn() == i.getColumn()))
-        {
-            return false;
-        }
-        return true;
+        this.rwFirst = row;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.poi.hssf.record.CellValueRecordInterface#isEqual(org.apache.poi.hssf.record.CellValueRecordInterface)
+    /**
+     * Return the row of the last cell that contains the hyperlink
+     *
+     * @return the 0-based row of the last cell that contains the hyperlink
      */
-    public boolean isEqual(CellValueRecordInterface i)
+    public int getLastRow()
     {
-        return ((this.getRow() == i.getRow()) && (this.getColumn() == i.getColumn()));
+        return rwLast;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.poi.hssf.record.CellValueRecordInterface#setColumn(short)
+    /**
+     * Set the row of the last cell that contains the hyperlink
+     *
+     * @param row the 0-based row of the last cell that contains the hyperlink
      */
-    public void setColumn(short col)
+    public void setLastRow(int row)
     {
-        this.field_3_column = col;
+        this.rwLast = row;
+    }
 
+    /**
+     * Returns a 16-byte guid identifier. Seems to always equal {@link STD_MONIKER}
+     *
+     * @return 16-byte guid identifier
+     */
+    public byte[] getGuid()
+    {
+        return guid;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.poi.hssf.record.CellValueRecordInterface#setRow(int)
+    /**
+     * Returns a 16-byte moniker.
+     *
+     * @return 16-byte moniker
      */
-    public void setRow(int row)
+    public byte[] getMoniker()
     {
-        this.field_2_row = row;
+        return moniker;
+    }
 
+
+    /**
+     * Return text label for this hyperlink
+     *
+     * @return  text to display
+     */
+    public String getLabel()
+    {
+        int idx = label.indexOf('\u0000');
+        return idx == -1 ? label : label.substring(0, idx);
+    }
+
+    /**
+     * Sets text label for this hyperlink
+     *
+     * @param label text label for this hyperlink
+     */
+     public void setLabel(String label)
+    {
+        this.label = label + '\u0000';
+    }
+
+    /**
+     * Hypelink address. Depending on the hyperlink type it can be URL, e-mail, patrh to a file, etc.
+     *
+     * @return  the address of this hyperlink
+     */
+    public String getAddress()
+    {
+        int idx = address.indexOf('\u0000');
+        return idx == -1 ? address : address.substring(0, idx);
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.poi.hssf.record.CellValueRecordInterface#setXFIndex(short)
+    /**
+     * Hypelink address. Depending on the hyperlink type it can be URL, e-mail, patrh to a file, etc.
+     *
+     * @param address  the address of this hyperlink
      */
-    public void setXFIndex(short xf)
+    public void setAddress(String address)
     {
-        this.field_4_xf_index = xf;
+        this.address = address + '\u0000';
+    }
 
+    /**
+     * Link options. Must be a combination of HLINK_* constants.
+     */
+    public int getLinkOptions(){
+        return link_opts;
+    }
+
+    /**
+     * Label options
+     */
+    public int getLabelOptions(){
+        return label_opts;
+    }
+
+    /**
+     * Options for a file link
+     */
+    public int getFileOptions(){
+        return file_opts;
+    }
+
+    public byte[] getTail(){
+        return tail;
     }
 
     /**
@@ -178,57 +313,56 @@
      */
     protected void fillFields(RecordInputStream in)
     {
-//    	System.err.println(in.currentSid);
-//    	System.err.println(in.currentLength);
-//    	for(int i=0; i<300; i++) {
-//    		System.err.println(in.readByte());
-//    	}
-//    	if(1==1)
-//    		throw new IllegalArgumentException("");
-    	
-        field_1_unknown = in.readShort();
-        field_2_row = in.readUShort(); 
-        field_3_column = in.readShort();
-        field_4_xf_index = in.readShort();
-        
-        // Next up is 16 bytes we don't get
-        field_5_unknown = new byte[16];
-        try {
-        in.read(field_5_unknown);
-        } catch(IOException e) { throw new IllegalStateException(e.getMessage()); }
-        
-        // Some sort of opts
-        field_6_label_opts = in.readInt();
-        
-        // Now for lengths, in characters
-        field_7_url_len = in.readInt();
-        field_8_label_len = in.readInt();
-        
-        // Now we have the label, as little endian unicode,
-        //  with a trailing \0
-        field_9_label = in.readUnicodeLEString(field_8_label_len);
-        
-        // Next up is some more data we can't make sense of
-        field_10_unknown = new byte[16];
         try {
-        in.read(field_10_unknown);
-        } catch(IOException e) { throw new IllegalStateException(e.getMessage()); }
-        
-        // Might need to nudge the length by one byte
-        // This is an empirical hack!
-        field_11_url_opts = in.readInt();
-        if(field_11_url_opts == 44) {
-        	field_7_url_len--;
+            rwFirst = in.readShort();
+            rwLast = in.readUShort();
+            colFirst = in.readShort();
+            colLast = in.readShort();
+
+            // 16-byte GUID
+            guid = new byte[16];
+            in.read(guid);
+
+            label_opts = in.readInt();
+            link_opts = in.readInt();
+
+            if ((link_opts & HLINK_LABEL) != 0){
+                int label_len = in.readInt();
+                label = in.readUnicodeLEString(label_len);
+            }
+
+            if ((link_opts & HLINK_URL) != 0){
+                moniker = new byte[16];
+                in.read(moniker);
+
+                if(Arrays.equals(URL_MONIKER, moniker)){
+                    int len = in.readInt();
+
+                    address = in.readUnicodeLEString(len/2);
+
+                    tail = in.readRemainder();
+                } else if (Arrays.equals(FILE_MONIKER, moniker)){
+                    file_opts = in.readShort();
+
+                    int len = in.readInt();
+
+                    byte[] path_bytes = new byte[len];
+                    in.read(path_bytes);
+
+                    address = new String(path_bytes);
+
+                    tail = in.readRemainder();
+                }
+            } else if((link_opts & HLINK_PLACE) != 0){
+                int len = in.readInt();
+                address = in.readUnicodeLEString(len);
+            }
+        } catch (IOException e){
+            throw new RuntimeException(e);
         }
-        
-        // Finally it's the URL
-        int strlen = field_7_url_len > (in.remaining()/2) ? (in.remaining()/2) : field_7_url_len;
-        field_12_url = in.readUnicodeLEString(strlen);
-    }
-    
-    /* (non-Javadoc)
-     * @see org.apache.poi.hssf.record.Record#getSid()
-     */
+
+    }
+
     public short getSid()
     {
         return HyperlinkRecord.sid;
@@ -244,55 +378,75 @@
 
     public int serialize(int offset, byte[] data)
     {
-        LittleEndian.putShort(data, 0 + offset, sid);
-        LittleEndian.putShort(data, 2 + offset,
-                              ( short )(getRecordSize()-4));
-        LittleEndian.putShort(data, 4 + offset, field_1_unknown);
-        LittleEndian.putUShort(data, 6 + offset, field_2_row);
-        LittleEndian.putShort(data, 8 + offset, field_3_column);
-        LittleEndian.putShort(data, 10 + offset, field_4_xf_index);
-        
-        offset += 12;
-        for(int i=0; i<field_5_unknown.length; i++) {
-        	data[offset] = field_5_unknown[i];
-        	offset++;
+        int pos = offset;
+        LittleEndian.putShort(data, pos, sid); pos += 2;
+        LittleEndian.putShort(data, pos, ( short )(getRecordSize()-4)); pos += 2;
+        LittleEndian.putUShort(data, pos, rwFirst); pos += 2;
+        LittleEndian.putUShort(data, pos, rwLast); pos += 2;
+        LittleEndian.putShort(data, pos, colFirst); pos += 2;
+        LittleEndian.putShort(data, pos, colLast); pos += 2;
+
+        System.arraycopy(guid, 0, data, pos, guid.length); pos += guid.length;
+
+        LittleEndian.putInt(data, pos, label_opts); pos += 4;
+        LittleEndian.putInt(data, pos, link_opts); pos += 4;
+
+        if ((link_opts & HLINK_LABEL) != 0){
+            LittleEndian.putInt(data, pos, label.length()); pos += 4;
+            StringUtil.putUnicodeLE(label, data, pos);  pos += label.length()*2;
         }
-        
-        LittleEndian.putInt(data, offset, field_6_label_opts);
-        offset += 4;
-        LittleEndian.putInt(data, offset, field_7_url_len);
-        offset += 4;
-        LittleEndian.putInt(data, offset, field_8_label_len);
-        offset += 4;
-        StringUtil.putUnicodeLE(field_9_label, data, offset);
-        offset += field_9_label.length()*2;
-
-        for(int i=0; i<field_10_unknown.length; i++) {
-        	data[offset] = field_10_unknown[i];
-        	offset++;
+        if ((link_opts & HLINK_URL) != 0){
+            System.arraycopy(moniker, 0, data, pos, moniker.length); pos += moniker.length;
+            if(Arrays.equals(URL_MONIKER, moniker)){
+                LittleEndian.putInt(data, pos, address.length()*2 + tail.length); pos += 4;
+                StringUtil.putUnicodeLE(address, data, pos);  pos += address.length()*2;
+                if(tail.length > 0){
+                    System.arraycopy(tail, 0, data, pos, tail.length); pos += tail.length;
+                }
+            } else if (Arrays.equals(FILE_MONIKER, moniker)){
+                LittleEndian.putShort(data, pos, file_opts); pos += 2;
+                LittleEndian.putInt(data, pos, address.length()); pos += 4;
+                byte[] bytes = address.getBytes();
+                System.arraycopy(bytes, 0, data, pos, bytes.length); pos += bytes.length;
+                if(tail.length > 0){
+                    System.arraycopy(tail, 0, data, pos, tail.length); pos += tail.length;
+                }
+            }
+        } else if((link_opts & HLINK_PLACE) != 0){
+            LittleEndian.putInt(data, pos, address.length()); pos += 4;
+            StringUtil.putUnicodeLE(address, data, pos);  pos += address.length()*2;
         }
-    	
-        LittleEndian.putInt(data, offset, field_11_url_opts);
-        offset += 4;
-        StringUtil.putUnicodeLE(field_12_url, data, offset);
-        
     	return getRecordSize();
     }
 
     public int getRecordSize()
     {
-    	// We have:
-    	// 4 shorts
-    	// junk
-    	// 3 ints
-    	// label
-    	// junk
-    	// int
-    	// url
-    	return 4 + 4*2 + field_5_unknown.length +
-    		3*4 + field_9_label.length()*2 +
-    		field_10_unknown.length + 4 +
-    		field_12_url.length()*2;
+        int size = 4;
+        size += 2 + 2 + 2 + 2;  //rwFirst, rwLast, colFirst, colLast
+        size += guid.length;
+        size += 4;  //label_opts
+        size += 4;  //link_opts
+        if ((link_opts & HLINK_LABEL) != 0){
+            size += 4;  //link length
+            size += label.length()*2;
+        }
+        if ((link_opts & HLINK_URL) != 0){
+            size += moniker.length;  //moniker length
+            if(Arrays.equals(URL_MONIKER, moniker)){
+                size += 4;  //address length
+                size += address.length()*2;
+                size += tail.length;
+            } else if (Arrays.equals(FILE_MONIKER, moniker)){
+                size += 2;  //file_opts
+                size += 4;  //address length
+                size += address.length();
+                size += tail.length;
+            }
+        } else if((link_opts & HLINK_PLACE) != 0){
+            size += 4;  //address length
+            size += address.length()*2;
+        }
+        return size;
     }
 
     public String toString()
@@ -300,71 +454,89 @@
         StringBuffer buffer = new StringBuffer();
 
         buffer.append("[HYPERLINK RECORD]\n");
-        buffer.append("    .row            = ").append(Integer.toHexString(getRow())).append("\n");
-        buffer.append("    .column         = ").append(Integer.toHexString(getColumn())).append("\n");
-        buffer.append("    .xfindex        = ").append(Integer.toHexString(getXFIndex())).append("\n");
-        buffer.append("    .label          = ").append(field_9_label).append("\n");
-        buffer.append("    .url            = ").append(field_12_url).append("\n");
+        buffer.append("    .rwFirst            = ").append(Integer.toHexString(getFirstRow())).append("\n");
+        buffer.append("    .rwLast         = ").append(Integer.toHexString(getLastRow())).append("\n");
+        buffer.append("    .colFirst            = ").append(Integer.toHexString(getFirstColumn())).append("\n");
+        buffer.append("    .colLast         = ").append(Integer.toHexString(getLastColumn())).append("\n");
+        buffer.append("    .guid        = ").append(HexDump.toHex(guid)).append("\n");
+        buffer.append("    .label_opts          = ").append(label_opts).append("\n");
+        buffer.append("    .label          = ").append(getLabel()).append("\n");
+        if((link_opts & HLINK_URL) != 0){
+            buffer.append("    .moniker          = ").append(HexDump.toHex(moniker)).append("\n");
+        }
+        buffer.append("    .address            = ").append(getAddress()).append("\n");
         buffer.append("[/HYPERLINK RECORD]\n");
         return buffer.toString();
     }
 
     /**
-     * @return Returns the label.
+     * Initialize a new url link
      */
-    public String getLabel()
-    {
-    	if(field_9_label.length() == 0) {
-    		return "";
-    	} else {
-    		// Trim off \0
-            return field_9_label.substring(0, field_9_label.length() - 1);
-    	}
+    public void newUrlLink(){
+        rwFirst = 0;
+        rwLast = 0;
+        colFirst = 0;
+        colLast = 0;
+        guid = STD_MONIKER;
+        label_opts = 0x2;
+        link_opts = HLINK_URL | HLINK_ABS | HLINK_LABEL;
+        label = "" + '\u0000';
+        moniker = URL_MONIKER;
+        address = "" + '\u0000';
+        tail = URL_TAIL;
     }
 
     /**
-     * @param label The label to set.
+     * Initialize a new file link
      */
-    public void setLabel(String label)
-    {
-        this.field_9_label = label + '\u0000';
-        this.field_8_label_len = field_9_label.length();
+    public void newFileLink(){
+        rwFirst = 0;
+        rwLast = 0;
+        colFirst = 0;
+        colLast = 0;
+        guid = STD_MONIKER;
+        label_opts = 0x2;
+        link_opts = HLINK_URL | HLINK_LABEL;
+        file_opts = 0;
+        label = "" + '\u0000';
+        moniker = FILE_MONIKER;
+        address = "" + '\0';
+        tail = FILE_TAIL;
     }
 
     /**
-     * @return Returns the Url.
+     * Initialize a new document link
      */
-    public URL getUrl() throws MalformedURLException
-    {
-        return new URL(getUrlString());
-    }
-    public String getUrlString()
-    {
-    	if(field_12_url.length() == 0) {
-    		return "";
-    	} else {
-    		// Trim off \0
-            return field_12_url.substring(0, field_12_url.length() - 1);
-    	}
+    public void newDocumentLink(){
+        rwFirst = 0;
+        rwLast = 0;
+        colFirst = 0;
+        colLast = 0;
+        guid = STD_MONIKER;
+        label_opts = 0x2;
+        link_opts = HLINK_LABEL | HLINK_PLACE;
+        label = "" + '\u0000';
+        moniker = FILE_MONIKER;
+        address = "" + '\0';
+        tail = new byte[]{};
+    }
+
+    public Object clone() {
+        HyperlinkRecord rec = new HyperlinkRecord();
+        rec.rwFirst = rwFirst;
+        rec.rwLast = rwLast;
+        rec.colFirst = colFirst;
+        rec.colLast = colLast;
+        rec.guid = guid;
+        rec.label_opts = label_opts;
+        rec.link_opts = link_opts;
+        rec.file_opts = file_opts;
+        rec.label = label;
+        rec.address = address;
+        rec.moniker = moniker;
+        rec.tail = tail;
+        return rec;
     }
 
-    /**
-     * @param url The url to set.
-     */
-    public void setUrl(URL url)
-    {
-    	setUrl(url.toString());
-    }
-    /**
-     * @param url The url to set.
-     */
-    public void setUrl(String url)
-    {
-        this.field_12_url = url + '\u0000';
-        this.field_7_url_len = field_12_url.length();
-    }
 
-    public int getOptions(){
-        return field_11_url_opts;
-    }
 }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java?rev=627544&r1=627543&r2=627544&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java Wed Feb 13 09:34:43 2008
@@ -550,6 +550,13 @@
     /**
      * set a date value for the cell. Excel treats dates as numeric so you will need to format the cell as
      * a date.
+     * 
+     * This will set the cell value based on the Calendar's timezone. As Excel
+     * does not support timezones this means that both 20:00+03:00 and
+     * 20:00-03:00 will be reported as the same value (20:00) even that there
+     * are 6 hours difference between the two times. This difference can be
+     * preserved by using <code>setCellValue(value.getTime())</code> which will
+     * automatically shift the times to the default timezone.
      *
      * @param value  the date value to set this cell to.  For formulas we'll set the
      *        precalculated value, for numerics we'll set its value. For othertypes we
@@ -557,7 +564,7 @@
      */
     public void setCellValue(Calendar value)
     {
-        setCellValue(value.getTime());
+        setCellValue( HSSFDateUtil.getExcelDate(value, this.book.isUsing1904DateWindowing()) );
     }
 
     /**
@@ -1071,7 +1078,7 @@
             Record rec = ( Record ) it.next();
             if (rec instanceof HyperlinkRecord){
                 HyperlinkRecord link = (HyperlinkRecord)rec;
-                if(link.getColumn() == record.getColumn() && link.getRow() == record.getRow()){
+                if(link.getFirstColumn() == record.getColumn() && link.getFirstRow() == record.getRow()){
                     return new HSSFHyperlink(link);
                 }
             }
@@ -1085,6 +1092,25 @@
      * @param link hypelrink associated with this cell
      */
     public void setHyperlink(HSSFHyperlink link){
+        link.setFirstRow(record.getRow());
+        link.setLastRow(record.getRow());
+        link.setFirstColumn(record.getColumn());
+        link.setLastColumn(record.getColumn());
+
+        switch(link.getType()){
+            case HSSFHyperlink.LINK_EMAIL:
+            case HSSFHyperlink.LINK_URL:
+                link.setLabel("url");
+                break;
+            case HSSFHyperlink.LINK_FILE:
+                link.setLabel("file");
+                break;
+            case HSSFHyperlink.LINK_DOCUMENT:
+                link.setLabel("place");
+                break;
+        }
 
+        int eofLoc = sheet.findFirstRecordLocBySid( EOFRecord.sid );
+        sheet.getRecords().add( eofLoc, link.record );
     }
 }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java?rev=627544&r1=627543&r2=627544&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java Wed Feb 13 09:34:43 2008
@@ -914,4 +914,29 @@
     {
         return format.getFillForeground();
     }
+
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime * result + ((format == null) ? 0 : format.hashCode());
+		result = prime * result + index;
+		return result;
+	}
+
+	public boolean equals(Object obj) {
+		if (this == obj) return true;
+		if (obj == null) return false;
+		if (obj instanceof HSSFCellStyle) {
+			final HSSFCellStyle other = (HSSFCellStyle) obj;
+			if (format == null) {
+				if (other.format != null)
+					return false;
+			} else if (!format.equals(other.format))
+				return false;
+			if (index != other.index)
+				return false;
+			return true;
+		}
+		return false;
+	}
 }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java?rev=627544&r1=627543&r2=627544&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java Wed Feb 13 09:34:43 2008
@@ -70,9 +70,25 @@
     public static double getExcelDate(Date date, boolean use1904windowing) {
         Calendar calStart = new GregorianCalendar();
         calStart.setTime(date);   // If date includes hours, minutes, and seconds, set them to 0
-        
-        if ((!use1904windowing && calStart.get(Calendar.YEAR) < 1900) || 
-            (use1904windowing && calStart.get(Calendar.YEAR) < 1904)) 
+        return internalGetExcelDate(calStart, use1904windowing);
+    }
+    /**
+     * Given a Date in the form of a Calendar, converts it into a double
+     *  representing its internal Excel representation, which is the 
+     *  number of days since 1/1/1900. Fractional days represent hours, 
+     *  minutes, and seconds.
+     *
+     * @return Excel representation of Date (-1 if error - test for error by checking for less than 0.1)
+     * @param date the Calendar holding the date to convert
+     * @param use1904windowing Should 1900 or 1904 date windowing be used?
+     */
+    public static double getExcelDate(Calendar date, boolean use1904windowing) {
+    	// Don't alter the supplied Calendar as we do our work
+    	return internalGetExcelDate( (Calendar)date.clone(), use1904windowing );
+    }
+    private static double internalGetExcelDate(Calendar date, boolean use1904windowing) {
+        if ((!use1904windowing && date.get(Calendar.YEAR) < 1900) || 
+            (use1904windowing && date.get(Calendar.YEAR) < 1904)) 
         {
             return BAD_DATE;
         } else {
@@ -83,12 +99,12 @@
 	    // be 4 hours.
 	    // E.g. 2004-03-28 04:00 CEST - 2004-03-28 00:00 CET is 3 hours
 	    // and 2004-10-31 04:00 CET - 2004-10-31 00:00 CEST is 5 hours
-            double fraction = (((calStart.get(Calendar.HOUR_OF_DAY) * 60
-                                 + calStart.get(Calendar.MINUTE)
-                                ) * 60 + calStart.get(Calendar.SECOND)
-                               ) * 1000 + calStart.get(Calendar.MILLISECOND)
+            double fraction = (((date.get(Calendar.HOUR_OF_DAY) * 60
+                                 + date.get(Calendar.MINUTE)
+                                ) * 60 + date.get(Calendar.SECOND)
+                               ) * 1000 + date.get(Calendar.MILLISECOND)
                               ) / ( double ) DAY_MILLISECONDS;
-            calStart = dayStart(calStart);
+            Calendar calStart = dayStart(date);
             
             double value = fraction + absoluteDay(calStart, use1904windowing);
             
@@ -208,9 +224,9 @@
     	//  who knows what that starting bit is all about
     	fs = fs.replaceAll("\\[\\$\\-.*?\\]", "");
     	
-    	// Otherwise, check it's only made up of:
-    	//  y m d - / ,
-    	if(fs.matches("^[ymd\\-/, ]+$")) {
+    	// Otherwise, check it's only made up, in any case, of:
+    	//  y m d h s - / , . :
+    	if(fs.matches("^[yYmMdDhHsS\\-/,. :]+$")) {
     		return true;
     	}
     	

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFFont.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFFont.java?rev=627544&r1=627543&r2=627544&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFFont.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFFont.java Wed Feb 13 09:34:43 2008
@@ -306,5 +306,28 @@
                 "}";
     }
 
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime * result + ((font == null) ? 0 : font.hashCode());
+		result = prime * result + index;
+		return result;
+	}
 
+	public boolean equals(Object obj) {
+		if (this == obj) return true;
+		if (obj == null) return false;
+		if (obj instanceof HSSFFont) {
+			final HSSFFont other = (HSSFFont) obj;
+			if (font == null) {
+				if (other.font != null)
+					return false;
+			} else if (!font.equals(other.font))
+				return false;
+			if (index != other.index)
+				return false;
+			return true;
+		}
+		return false;
+	}
 }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java?rev=627544&r1=627543&r2=627544&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java Wed Feb 13 09:34:43 2008
@@ -27,9 +27,9 @@
 import java.util.Iterator;
 
 /**
- * Represents a hyperlink.
+ * Represents an Excel hyperlink.
  *
- * @author Yegor Kozlov
+ * @author Yegor Kozlov (yegor at apache dot org)
  */
 public class HSSFHyperlink {
 
@@ -49,67 +49,145 @@
     public static final int LINK_EMAIL = 3;
 
     /**
-     * Unknown type
+     * Link to a file
      */
-    public static final int LINK_UNKNOWN = 4;
+    public static final int LINK_FILE = 4;
 
     /**
      * Low-level record object that stores the actual hyperlink data
      */
-    private HyperlinkRecord record = null;
+    protected HyperlinkRecord record = null;
 
+    /**
+     * If we create a new hypelrink remember its type
+     */
+    protected int link_type;
+
+    /**
+     * Construct a new hyperlink
+     *
+     * @param type the type of hyperlink to create
+     */
+    public HSSFHyperlink( int type )
+    {
+        this.link_type = type;
+        record = new HyperlinkRecord();
+        switch(type){
+            case LINK_URL:
+            case LINK_EMAIL:
+                record.newUrlLink();
+                break;
+            case LINK_FILE:
+                record.newFileLink();
+                break;
+            case LINK_DOCUMENT:
+                record.newDocumentLink();
+                break;
+        }
+    }
+
+    /**
+     * Initialize the hyperlink by a <code>HyperlinkRecord</code> record
+     *
+     * @param record
+     */
     protected HSSFHyperlink( HyperlinkRecord record )
     {
         this.record = record;
     }
 
     /**
-     * Return the row of the cell that contains the hyperlink
+     * Return the row of the first cell that contains the hyperlink
      *
      * @return the 0-based row of the cell that contains the hyperlink
      */
-    public int getRow(){
-        return record.getRow();
+    public int getFirstRow(){
+        return record.getFirstRow();
+    }
+
+    /**
+     * Set the row of the first cell that contains the hyperlink
+     *
+     * @param row the 0-based row of the first cell that contains the hyperlink
+     */
+    public void setFirstRow(int row){
+        record.setFirstRow(row);
+    }
+
+    /**
+     * Return the row of the last cell that contains the hyperlink
+     *
+     * @return the 0-based row of the last cell that contains the hyperlink
+     */
+    public int getLastRow(){
+        return record.getLastRow();
+    }
+
+    /**
+     * Set the row of the last cell that contains the hyperlink
+     *
+     * @param row the 0-based row of the last cell that contains the hyperlink
+     */
+    public void setLastRow(int row){
+        record.setLastRow(row);
+    }
+
+    /**
+     * Return the column of the first cell that contains the hyperlink
+     *
+     * @return the 0-based column of the first cell that contains the hyperlink
+     */
+    public short getFirstColumn(){
+        return record.getFirstColumn();
     }
 
     /**
-     * Set the row of the cell that contains the hyperlink
+     * Set the column of the first cell that contains the hyperlink
      *
-     * @param row the 0-based row of the cell that contains the hyperlink
+     * @param col the 0-based column of the first cell that contains the hyperlink
      */
-    public void setRow(int row){
-        record.setRow(row);
+    public void setFirstColumn(short col){
+        record.setFirstColumn(col);
     }
 
     /**
-     * Return the column of the cell that contains the hyperlink
+     * Return the column of the last cell that contains the hyperlink
      *
-     * @return the 0-based column of the cell that contains the hyperlink
+     * @return the 0-based column of the last cell that contains the hyperlink
      */
-    public short getColumn(){
-        return record.getColumn();
+    public short getLastColumn(){
+        return record.getLastColumn();
     }
 
     /**
-     * Set the column of the cell that contains the hyperlink
+     * Set the column of the last cell that contains the hyperlink
      *
-     * @param col the 0-based column of the cell that contains the hyperlink
+     * @param col the 0-based column of the last cell that contains the hyperlink
      */
-    public void setColumn(short col){
-        record.setColumn(col);
+    public void setLastColumn(short col){
+        record.setLastColumn(col);
     }
 
     /**
-     * Hypelink address. Depending on the hyperlink type it can be URL, e-mail, etc.
+     * Hypelink address. Depending on the hyperlink type it can be URL, e-mail, patrh to a file, etc.
      *
      * @return  the address of this hyperlink
      */
     public String getAddress(){
-        return record.getUrlString();
+        return record.getAddress();
     }
 
     /**
-     * Return text to display for this hyperlink
+     * Hypelink address. Depending on the hyperlink type it can be URL, e-mail, patrh to a file, etc.
+     *
+     * @param address  the address of this hyperlink
+     */
+    public void setAddress(String address){
+        record.setAddress(address);
+    }
+
+    /**
+     * Return text label for this hyperlink
      *
      * @return  text to display
      */
@@ -118,11 +196,20 @@
     }
 
     /**
+     * Sets text label for this hyperlink
+     *
+     * @param label text label for this hyperlink
+     */
+    public void setLabel(String label){
+        record.setLabel(label);
+    }
+
+    /**
      * Return the type of this hyperlink
      *
      * @return the type of this hyperlink
      */
-    public int getType(){
-        throw new RuntimeException("Not implemented");
+    protected int getType(){
+        return link_type;
     }
 }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java?rev=627544&r1=627543&r2=627544&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java Wed Feb 13 09:34:43 2008
@@ -471,7 +471,6 @@
      * @return cell iterator of the physically defined cells.  Note element 4 may
      * actually be row cell depending on how many are defined!
      */
-
     public Iterator cellIterator()
     {
       return new CellIterator();
@@ -481,7 +480,7 @@
      *  foreach loops
      */
     public Iterator iterator() { 
-    	return cellIterator();
+       return cellIterator();
     }
     
     private class CellIterator implements Iterator

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java?rev=627544&r1=627543&r2=627544&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java Wed Feb 13 09:34:43 2008
@@ -724,8 +724,9 @@
      *  foreach loops
      */
     public Iterator iterator() {
-    	return rowIterator();
+        return rowIterator();
     }
+    
 
     /**
      * used internally in the API to get the low level Sheet record represented by this

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hpsf/basic/TestBasic.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hpsf/basic/TestBasic.java?rev=627544&r1=627543&r2=627544&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hpsf/basic/TestBasic.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hpsf/basic/TestBasic.java Wed Feb 13 09:34:43 2008
@@ -20,7 +20,6 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.File;
-import java.io.FileFilter;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
@@ -223,46 +222,6 @@
         Assert.assertEquals(17, s.getPropertyCount());
         Assert.assertEquals("Titel", s.getProperty(2));
         Assert.assertEquals(1748, s.getSize());
-    }
-
-
-
-    /**
-     * <p>This test methods reads all property set streams from all POI
-     * filesystems in the "data" directory.</p>
-     */
-    public void testReadAllFiles()
-    {
-        final File dataDir =
-            new File(System.getProperty("HPSF.testdata.path"));
-        final File[] fileList = dataDir.listFiles(new FileFilter()
-            {
-                public boolean accept(final File f)
-                {
-                    return f.isFile();
-                }
-            });
-        try
-        {
-            for (int i = 0; i < fileList.length; i++)
-            {
-                File f = fileList[i];
-                /* Read the POI filesystem's property set streams: */
-                final POIFile[] psf1 = Util.readPropertySets(f);
-
-                for (int j = 0; j < psf1.length; j++)
-                {
-                    final InputStream in =
-                        new ByteArrayInputStream(psf1[j].getBytes());
-                    PropertySetFactory.create(in);
-                }
-            }
-        }
-        catch (Throwable t)
-        {
-            final String s = org.apache.poi.hpsf.Util.toString(t);
-            fail(s);
-        }
     }
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message