diff options
author | Martin Maher <mmaher@openoffice.org> | 2002-10-09 09:05:13 +0000 |
---|---|---|
committer | Martin Maher <mmaher@openoffice.org> | 2002-10-09 09:05:13 +0000 |
commit | 5f55f94c553d8cc116014ce555475fde6be334b0 (patch) | |
tree | 3223b64e0bcdf4921c0abcff9d546688884f2faf | |
parent | d24d89f5b69b6cec8ec6ef391f3743d16b1971c6 (diff) |
Added the new code to parse formula and rename Records to records in java/org/openoffice/xmerge/converter/xml/sxc/pexcel
55 files changed, 3505 insertions, 48 deletions
diff --git a/xmerge/build.xml b/xmerge/build.xml index 3e4aa09c9810..ce566533739d 100644 --- a/xmerge/build.xml +++ b/xmerge/build.xml @@ -147,13 +147,21 @@ <!-- java package --> - <target name="xmrg_jooxcxsp_Records" depends="prepare"> - <ant dir="java/org/openoffice/xmerge/converter/xml/sxc/pexcel/Records" target="main"> - <property name="target" value="xmrg_jooxcxsp_Records"/> + <target name="xmrg_jooxcxsp_records" depends="prepare"> + <ant dir="java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records" target="main"> + <property name="target" value="xmrg_jooxcxsp_records"/> <property name="prj" value="../../../../../../../../.."/> </ant> </target> + <!-- java package --> + <target name="xmrg_jooxcxspr_formula" depends="prepare"> + <ant + dir="java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula" target="main"> + <property name="target" value="xmrg_jooxcxspr_formula"/> + <property name="prj" value="../../../../../../../../../.."/> + </ant> + </target> <!-- java package --> <target name="xmrg_jooxcxs_pexcel" depends="prepare"> @@ -280,7 +288,8 @@ <!-- util --> - <target name="xmrg_util" depends="prepare,xmrg_joo_xmerge,xmrg_jooxc_xml,xmrg_jooxcx_sxc,xmrg_jooxcxsp_Records,xmrg_jooxcxs_pexcel,xmrg_jooxcx_sxw,xmrg_jooxcxs_aportisdoc,xmrg_jooxcxs_pocketword,xmrg_jooxcx_xslt,xmrg_joox_merger,xmrg_jooxm_diff,xmrg_jooxm_merge,xmrg_joox_test,xmrg_joox_util,xmrg_jooxu_registry,xmrg_jooxc_palm,xmrg_jooxc_dom,xmrg_javadoc"> + <target name="xmrg_util" + depends="prepare,xmrg_joo_xmerge,xmrg_jooxc_xml,xmrg_jooxcx_sxc,xmrg_jooxcxsp_records,xmrg_jooxcxspr_formula, xmrg_jooxcxs_pexcel,xmrg_jooxcx_sxw,xmrg_jooxcxs_aportisdoc,xmrg_jooxcxs_pocketword,xmrg_jooxcx_xslt,xmrg_joox_merger,xmrg_jooxm_diff,xmrg_jooxm_merge,xmrg_joox_test,xmrg_joox_util,xmrg_jooxu_registry,xmrg_jooxc_palm,xmrg_jooxc_dom,xmrg_javadoc"> <ant dir="util" target="main"> <property name="target" value="xmrg_util"/> <property name="prj" value="."/> diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PluginFactoryImpl.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PluginFactoryImpl.java index 65a2be8c71c1..8046d9c6a2ee 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PluginFactoryImpl.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PluginFactoryImpl.java @@ -68,7 +68,7 @@ import org.openoffice.xmerge.DocumentMerger; import org.openoffice.xmerge.ConverterCapabilities; import org.openoffice.xmerge.converter.xml.sxc.DocumentMergerImpl; import org.openoffice.xmerge.converter.xml.sxc.SxcPluginFactory; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.Records.Workbook; +import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; import org.openoffice.xmerge.util.registry.ConverterInfo; /** diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelDecoder.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelDecoder.java index 5c4df689fe45..de9c1f3e943d 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelDecoder.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelDecoder.java @@ -72,12 +72,12 @@ import org.openoffice.xmerge.util.Debug; import org.openoffice.xmerge.converter.xml.sxc.SxcDocumentDeserializer; import org.openoffice.xmerge.converter.xml.sxc.SpreadsheetDecoder; import org.openoffice.xmerge.converter.xml.sxc.Format; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.Records.Worksheet; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.Records.Formula; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.Records.LabelCell; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.Records.CellValue; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.Records.FloatNumber; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.Records.Workbook; +import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Worksheet; +import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Formula; +import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.LabelCell; +import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.CellValue; +import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.FloatNumber; +import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; /** * This class is used by {@link diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelEncoder.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelEncoder.java index 4f641aa4addb..7f4916b4aac2 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelEncoder.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelEncoder.java @@ -67,7 +67,7 @@ import org.openoffice.xmerge.util.IntArrayList; import org.openoffice.xmerge.converter.xml.sxc.SpreadsheetEncoder; import org.openoffice.xmerge.converter.xml.sxc.Format; import org.openoffice.xmerge.converter.xml.OfficeConstants; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.Records.Workbook; +import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; /** * This class is used by {@link diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentDeserializerImpl.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentDeserializerImpl.java index 68250f90910f..973e1d5d1ffd 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentDeserializerImpl.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentDeserializerImpl.java @@ -64,7 +64,7 @@ import org.openoffice.xmerge.ConvertData; import org.openoffice.xmerge.converter.xml.sxc.SpreadsheetDecoder; import org.openoffice.xmerge.converter.xml.sxc.SxcDocumentDeserializer; import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelDecoder; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.Records.Workbook; +import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; /** diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentSerializerImpl.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentSerializerImpl.java index 47f22d328b4d..b61d6fea4b48 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentSerializerImpl.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentSerializerImpl.java @@ -69,7 +69,7 @@ import org.openoffice.xmerge.ConvertData; import org.openoffice.xmerge.ConvertException; import org.openoffice.xmerge.converter.xml.sxc.Format; import org.openoffice.xmerge.converter.xml.sxc.SxcDocumentSerializer; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.Records.Workbook; +import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; /** * <p>Pocket Excel implementation of <code>SxcDocumentDeserializer</code> diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BIFFRecord.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BIFFRecord.java index 0c23955f35bb..aefa6fd57133 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BIFFRecord.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BIFFRecord.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.DataInputStream; import java.io.OutputStream; diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BeginningOfFile.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BeginningOfFile.java index f418f0e8246b..11b4189c47eb 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BeginningOfFile.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BeginningOfFile.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.InputStream; import java.io.OutputStream; @@ -61,7 +61,7 @@ import java.io.IOException; import org.openoffice.xmerge.util.Debug; import org.openoffice.xmerge.util.EndianConverter; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.Records.PocketExcelBiffConstants; +import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.PocketExcelBiffConstants; /** * This class describes the beginning of file. It is the diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BlankCell.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BlankCell.java index 983aac73e0c5..ca3cdb042841 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BlankCell.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BlankCell.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.DataInputStream; import java.io.OutputStream; @@ -62,7 +62,7 @@ import java.io.IOException; import org.openoffice.xmerge.util.Debug; import org.openoffice.xmerge.util.EndianConverter; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.Records.PocketExcelBiffConstants; +import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.PocketExcelBiffConstants; /** * Represents a BIFF Record that describes a blank cell diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BoolErrCell.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BoolErrCell.java index f95aed48d1c6..23967d741d4b 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BoolErrCell.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BoolErrCell.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.DataInputStream; import java.io.OutputStream; diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BoundSheet.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BoundSheet.java index 691c1d1da3d2..2bbc6bd8bf22 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BoundSheet.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BoundSheet.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.IOException; import java.io.UnsupportedEncodingException; diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/CellValue.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/CellValue.java index 2913adfb5da0..878a7d364e6d 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/CellValue.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/CellValue.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.DataInputStream; import java.io.OutputStream; diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/CodePage.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/CodePage.java index 128368b55d36..031e3a7d736b 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/CodePage.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/CodePage.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.DataInputStream; import java.io.OutputStream; diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/ColInfo.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/ColInfo.java index d759f5d4d9e9..79ba867810f8 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/ColInfo.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/ColInfo.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.IOException; import java.io.DataInputStream; diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefColWidth.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefColWidth.java index a597886abc4b..c0d2ebd28ee8 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefColWidth.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefColWidth.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.DataInputStream; import java.io.OutputStream; diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefRowHeight.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefRowHeight.java index 064abe19bdd1..0b00ad24bb10 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefRowHeight.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefRowHeight.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.DataInputStream; import java.io.OutputStream; diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefinedName.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefinedName.java index 2a68deecb92e..b36018f38f00 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefinedName.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefinedName.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.DataInputStream; import java.io.OutputStream; diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Eof.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Eof.java index a0c53e1504ab..74149982939b 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Eof.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Eof.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.DataInputStream; import java.io.OutputStream; diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/ExtendedFormat.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/ExtendedFormat.java index 487df723de7d..fe0f26fff750 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/ExtendedFormat.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/ExtendedFormat.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.DataInputStream; import java.io.OutputStream; diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FloatNumber.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FloatNumber.java index edf5bbfb3d7c..388fa10deaab 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FloatNumber.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FloatNumber.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.DataInputStream; import java.io.OutputStream; diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FontDescription.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FontDescription.java index 2c5f0c826d0e..6233a7805a35 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FontDescription.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FontDescription.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.DataInputStream; import java.io.OutputStream; diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Formula.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Formula.java index b5389ca99c99..365404a51658 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Formula.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Formula.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.DataInputStream; import java.io.OutputStream; diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/LabelCell.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/LabelCell.java index 1ae7d944413c..8224e069a6a6 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/LabelCell.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/LabelCell.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.DataInputStream; import java.io.InputStream; diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/NumberFormat.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/NumberFormat.java index 57197b9cd1c6..382254d258a4 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/NumberFormat.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/NumberFormat.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.DataInputStream; import java.io.OutputStream; diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Pane.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Pane.java index 7398cbc90d16..d449d68d3712 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Pane.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Pane.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.DataInputStream; import java.io.OutputStream; diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Row.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Row.java index 1889021aa9e7..676d4c981e5b 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Row.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Row.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.DataInputStream; import java.io.OutputStream; diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Selection.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Selection.java index fbecd1f87bf7..4bf6f7d803c4 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Selection.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Selection.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.DataInputStream; import java.io.OutputStream; diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/StringValue.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/StringValue.java index c440f3eb1c0f..42df2593f329 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/StringValue.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/StringValue.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.DataInputStream; import java.io.OutputStream; diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/UnsupportedFormulaException.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/UnsupportedFormulaException.java index 5825556054da..864a10aa4b3b 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/UnsupportedFormulaException.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/UnsupportedFormulaException.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.lang.Exception; diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Window1.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Window1.java index 45b7efd091fb..a027b7eb9a7a 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Window1.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Window1.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.DataInputStream; import java.io.OutputStream; diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Window2.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Window2.java index 728e33f22339..366c4ee33f1e 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Window2.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Window2.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.DataInputStream; import java.io.OutputStream; diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Workbook.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Workbook.java index 9bd1b6e241fe..4e4db605ee38 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Workbook.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Workbook.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.OutputStream; import java.io.InputStream; diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Worksheet.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Worksheet.java index 3e446409a2f1..5d70c995275c 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Worksheet.java +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Worksheet.java @@ -53,7 +53,7 @@ * ************************************************************************/ -package org.openoffice.xmerge.converter.xml.sxc.pexcel.Records; +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; import java.io.OutputStream; import java.io.InputStream; diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/build.xml b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/build.xml index c94e80e54fd8..c2ddc6da4ef1 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/build.xml +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/build.xml @@ -52,7 +52,7 @@ # # --> -<project name="xmrg_jooxcxsp_Records" default="main" basedir="."> +<project name="xmrg_jooxcxsp_records" default="main" basedir="."> <!-- ================================================================= --> <!-- settings --> @@ -62,7 +62,7 @@ <property name="prj.prefix" value="xmrg"/> <!-- name of this sub target used in recursive builds --> - <property name="target" value="xmrg_jooxcxsp_Records"/> + <property name="target" value="xmrg_jooxcxsp_records"/> <!-- relative path to project directory --> <property name="prj" value="../../../../../../../../.."/> @@ -72,7 +72,7 @@ <!-- path component for current java package --> <property name="package" - value="org/openoffice/xmerge/converter/xml/sxc/pexcel/Records"/> + value="org/openoffice/xmerge/converter/xml/sxc/pexcel/records"/> <!-- define how to handle CLASSPATH environment --> <property name="build.sysclasspath" value="ignore"/> diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaCompiler.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaCompiler.java new file mode 100644 index 000000000000..e96403bb3f1d --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaCompiler.java @@ -0,0 +1,293 @@ +/************************************************************************ + * + * FormulaCompiler.java + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2001 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; + +import java.util.*; +import org.openoffice.xmerge.util.Debug; + +/** + * FormulaCompiler converts Calc formula string into PocketXL bytes + * and PocketXL formula bytes into Calc Formula strings + * + * For converting from infix to Reverse Polish (or Postfix) notation the string is + * converted into a vector of Tokens and then re-ordered based on a modified version + * of the standard Infix to RPN conversion algorithms. + * <pre> + * Infix2Rpn(tokens) + * while have more tokens + * if token is operand + * push to stack + * else if token is function, argument separater, or open bracket + * push token + * extract tokens to matching close bracket into param + * Infix2Rpn(param) + * else if token is close bracket + * pop from stack into result until close bracket or function + * else + * while stack.top.priority >= token.priority + * add stack.pop to result + * push token onto stack + * </pre> + * For converting from RPN to Infix the following algorithm is applied: + * <pre> + * while have more tokens + * if token is operand + * push token to stack + * else if token is function or operator + * pop from stack number of args required by token + * apply token to params to make expr + * push expr to stack + * return stack.pop + * </pre> + */ +public class FormulaCompiler { + /** + * Constructs a FormulaCompiler object + */ + public FormulaCompiler() { + } + + private boolean isOpenBrace(Token pt) { + return pt.getTokenID() == TokenConstants.TPAREN; + } + + private boolean isCloseBrace(Token pt) { + return pt.getValue().compareTo(")") == 0; + } + + private boolean isParamDelimiter(Token pt) { + return pt.getTokenID() == TokenConstants.TARGSEP; + } + + private boolean isBinaryOperator(Token pt) { + return false; + } + + /** + * Re-order into Infix format + * @param tokens The tokens in RPN form + * @return The vector of tokens re-ordered in Infix notation + */ + public Vector RPN2Infix(Vector tokens) { + Vector infixExpr = new Vector(15); + ListIterator iter = tokens.listIterator(); + Stack evalStack = new Stack(); + Stack args = new Stack(); + + while (iter.hasNext()) { + Token pt = (Token)iter.next(); + if (pt.isOperand()) { + Vector expr = new Vector(5); + expr.add(pt); + evalStack.push(expr); + } else if (pt.isOperator() || pt.isFunction()) { + args.clear(); + for (int i=0; i< pt.getNumArgs(); i++) { + args.push(evalStack.pop()); + } + evalStack.push(makeExpression(pt, args)); + } + } + return (Vector)evalStack.elementAt(0); + } + + /** + * Convert the infix expression to RPN. Note that open brackets are saved onto the stack to preserve the users bracketing. + * <p>Also note that the open bracket following functions is not pushed onto the stack - it is always implied when + * writing out results + * + * @param tokens The vector of tokens in Infix form + * + * @return A vector of tokens for the expression in Reverse Polish Notation order + */ + public Vector infix2RPN(Vector tokens) { + Vector rpnExpr = new Vector(15); + Stack evalStack = new Stack(); + ListIterator iter = tokens.listIterator(); + while (iter.hasNext()) { + Token pt = (Token)iter.next(); + + if (pt.isOperand()) { //Operands are output immediately + rpnExpr.add(pt); + } else if (pt.isFunction() || isParamDelimiter(pt) || isOpenBrace(pt)) { //Extract parameters after afunction or comma + evalStack.push(pt); + if (pt.isFunction()) { + iter.next(); + } + Vector param = extractParameter(iter); + Debug.log(Debug.TRACE, "Extracted parameter " + param); + rpnExpr.addAll(infix2RPN(param)); + } else if (isCloseBrace(pt)) { //Pop off stack till you meet a function or an open bracket + Token tmpTok = null; + boolean bPop = true; + while (bPop) { + if (evalStack.isEmpty()) { + bPop = false; + } else { + tmpTok = (Token)evalStack.pop(); + //if (!(isOpenBrace(tmpTok) || isParamDelimiter(tmpTok))) { //Don't output brackets and commas + if (!isParamDelimiter(tmpTok)) { //Don't output commas + rpnExpr.add(tmpTok); + } + if (tmpTok.isFunction() || isOpenBrace(tmpTok)) { + bPop = false; + } + } + } + } else { + if (!evalStack.isEmpty()) { + while (!evalStack.isEmpty() && + (((Token)evalStack.peek()).getTokenPriority() >=pt.getTokenPriority())) { + Token topTok = (Token)evalStack.peek(); + if (topTok.isFunction() || isOpenBrace(topTok)) { + break; + } + rpnExpr.add(evalStack.pop()); + } + } + evalStack.push(pt); + } + } + + while (!evalStack.isEmpty()) { + Token topTok = (Token)evalStack.peek(); + if (!(isOpenBrace(topTok) || isParamDelimiter(topTok))) { //Don't output brackets and commas + rpnExpr.add(evalStack.pop()); + } + else + { + evalStack.pop(); + } + } + return rpnExpr; + } + + /** + * Extract a parameter or bracketed sub-expression + * @param iter an iterator into the list + * @return A complete sub-expression + */ + protected Vector extractParameter(ListIterator iter) { + Vector param = new Vector(5); + int subExprCount = 0; + + while (iter.hasNext()) { + Token pt = (Token)iter.next(); + Debug.log(Debug.TRACE, "Token is " + pt + " and subExprCount is " + subExprCount); + if (isOpenBrace(pt)) { + subExprCount++; + param.add(pt); + } else if (isCloseBrace(pt)) { + if (subExprCount == 0) { + iter.previous(); + return param; + } else { + subExprCount--; + param.add(pt); + } + } else if (isParamDelimiter(pt) && (subExprCount == 0)) { + iter.previous(); + return param; + } else { + param.add(pt); + } + } + return param; + } + + /** + * Given the operator and it's operators + * @param pt The operator token + * @param args The arguments for this operator + * @return A correctly ordered expression + */ + protected Vector makeExpression(Token pt, Stack args) { + Vector tmp = new Vector(5); + TokenFactory tf = new TokenFactory(); + if (pt.isOperator()) { + if (pt.getNumArgs()==2) { //Binary operator + tmp.addAll((Vector)args.pop()); + tmp.add(pt); + tmp.addAll((Vector)args.pop()); + } else if (pt.getNumArgs() == 1) { + tmp.add(pt); + tmp.addAll((Vector)args.elementAt(0)); + if (isOpenBrace(pt)) { + tmp.add(tf.getOperatorToken(")",1)); + } + } + } else if (pt.isFunction()) { + tmp.add(pt); + tmp.add(tf.getOperatorToken("(",1)); + if (!args.isEmpty()) { + Vector v = (Vector)args.pop(); + tmp.addAll(v); + } + while (!args.isEmpty()) { + tmp.add(tf.getOperatorToken(",",1)); + Vector v = (Vector)args.pop(); + tmp.addAll(v); + + } + tmp.add(tf.getOperatorToken(")",1)); + } + + return tmp; + } +} diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaHelper.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaHelper.java new file mode 100644 index 000000000000..f9b627bb7f45 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaHelper.java @@ -0,0 +1,120 @@ +/************************************************************************ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): Michael Hayes (mhayes@openoffice.org) and Martin Maher + * + * + ************************************************************************/ + +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.Vector; +import java.util.Enumeration; + +/** + * This Helper class provides a simplified interface to conversion between PocketXL formula representation + * and Calc formula representation.<p> + * The class is used by {@link org.openoffice.xmerge.converter.xml.sxc.pexcel.Records.Formula} + */ +public class FormulaHelper { + private static FormulaParser parser; + private static FormulaCompiler compiler; + private static TokenEncoder encoder; + private static TokenDecoder decoder; + + static { + parser = new FormulaParser(); + compiler = new FormulaCompiler(); + encoder = new TokenEncoder(); + decoder = new TokenDecoder(); + } + + /** + * Convertes a string representation of a calc formula into an array of PocketXL bytes + * @param formula The Formula String (e.g. 1+SUM(A1,B1)) + * + * @throws UnsupportedFunctionException Thrown if a function in the formula is nto supported by Pocket Excel + * @throws FormulaParsingException Thrown when the formula is not well formed + * + */ + public byte[] convertCalcToPXL(String formula) throws UnsupportedFunctionException, FormulaParsingException { + Vector parseTokens = parser.parse(formula); + Vector rpnTokens = compiler.infix2RPN(parseTokens); + + ByteArrayOutputStream bytes = null; + try { + bytes = new ByteArrayOutputStream(); + for (Enumeration e = rpnTokens.elements(); e.hasMoreElements();) { + bytes.write(encoder.getByte((Token)e.nextElement())); + } + } catch (IOException e) { + } + + return bytes.toByteArray(); + } + + /** + * Converts a PocketXL byte array into a Calc function string + * @param formula A byte array that contains the PocketXL bytes for a formula + * + */ + public String convertPXLToCalc(byte[] formula) { + Vector parseTokens = decoder.getTokenVector(formula); + Vector infixTokens = compiler.RPN2Infix(parseTokens); + + StringBuffer buff = new StringBuffer(); + for (Enumeration e = infixTokens.elements();e.hasMoreElements();) { + buff.append(((Token)e.nextElement()).toString()); + } + return buff.toString(); + } +} diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParser.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParser.java new file mode 100644 index 000000000000..6f6fb2028962 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParser.java @@ -0,0 +1,536 @@ +/************************************************************************ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2001 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; + + +import java.io.*; +import java.util.Vector; +import java.util.Enumeration; + +import org.openoffice.xmerge.util.Debug; + +/** + * This is the Formula Parser based on an article written by Jack Crenshaw. It is a + * top down parser with some basic error handling. It handles + * +,-,*,/,>,<,>=,<=,=,<>, unary + and - as well as functions. + * The BNF notation for this parser is + * <pre> + * <expression> ::= <unary op> <term> [<addop>|<logop> <term>] + * <term> ::= <factor> [<mulop> <factor>] + * <factor> ::= <integer> | <CellRef> | <expression> + * </pre> + */ +public class FormulaParser { + + private char look; + private String formulaStr; + private int index = 1; + private TokenFactory tokenFactory; + private Vector tokenVector; + private StringBuffer currentMatch = new StringBuffer(""); + + /** + * Default constructor + */ + public FormulaParser() { + + Debug.log(Debug.TRACE,"Creating a Formula Parser"); + tokenFactory = new TokenFactory(); + tokenVector = new Vector(); + } + + + /** + * Parse method for parsing from a String to a byte[] + * + * @param formula A <code>String</code> representation of a formula + * starting with the '=' character + * @return A <code>Vector</code> containing the parsed <code>Token</code>s + */ + public Vector parse(String formula) throws FormulaParsingException { + + if(formula.startsWith("=")){ + + formulaStr = formula; + Debug.log(Debug.TRACE,"Creating a Formula Parser"); + getChar(); + expression(); + } else { + throw new FormulaParsingException("No equals found!"); + } + return tokenVector; + } + + /** + * Identify white spaces (ie. spaces or tab) + * + * @param The character which is to be identified + * @return A boolean returning the result of the comparison + */ + private boolean isWhite(char c) { + + boolean eq; + + if(c==' ' | c=='\t') + eq = true; + else + eq = false; + return eq; + } + + /** + * Identify + and - operators + * + * @param c The character which is to be identified + * @return A boolean returning the result of the comparison + */ + private boolean isAddOp(char c) { + + boolean eq; + + if(c=='-' | c=='+') + eq = true; + else + eq = false; + return eq; + } + + /** + * Determine if the current character is a multiop + * + * @return A boolean returning the result of the comparison + */ + private boolean isMultiOp() { + return look=='*' || look =='/' || look == '^' || look == '&'; + } + + /** + * Identify <, >, <=, >=, =, <> using the index to find the current character(s) + * + * @return A boolean returning the result of the comparison + */ + private boolean isLogicalOp() { + if (!isLogicalOpChar(look)) { + return false; + } else if ((index+1) >= formulaStr.length()) {//logical operators in their own right : if at end then return true + return true; + } else if (!isLogicalOpChar(formulaStr.charAt(index))) { // we have >, < or = on their own + return true; + } else if ((look == '<') && ((formulaStr.charAt(index) == '>') || formulaStr.charAt(index) == '=')) { // <>, or <= + return true; + } else if ((look == '>') && (formulaStr.charAt(index) == '=')) { // >= + return true; + } + + return false; + } + + /** + * Identify <, >, <=, >=, =, <> + * + * @param The <code>String</code> which is to be identified + * @return A boolean returning the result of the comparison + */ + private boolean isLogicalOp(String op) { + return ((op.compareTo(">") == 0) || + (op.compareTo("<") == 0) || + (op.compareTo(">=") == 0) || + (op.compareTo("<=") == 0) || + (op.compareTo("=") == 0) || + (op.compareTo("<>") == 0)); + } + + + /** + * Identify characters that MAY be logical operator characters + * + * @param c The character which is to be identified + * @return A boolean returning the result of the comparison + */ + private boolean isLogicalOpChar(char c) { + return (c == '>') || (c == '<') || (c == '='); + } + + /** + * Identify special Cell Reference charaters + * + * @param c The character which is to be identified + * @return A boolean returning the result of the comparison + */ + private boolean isCellRefSpecialChar(char c) { + + boolean eq; + + if(c==':' || c=='$') + eq = true; + else + eq = false; + return eq; + } + + /** + * Identify letters + * + * @param c The character which is to be identified + * @return A boolean returning the result of the comparison + */ + private boolean isAlpha(char c) { + return(Character.isLetter(c)); + } + + /** + * Identify numbers + * + * @param c The character which is to be identified + * @return A boolean returning the result of the comparison + */ + private boolean isDigit(char c) { + return(Character.isDigit(c)); + } + + /** + * Identify letters or numbers + * + * @param c The character which is to be identified + * @return A boolean returning the result of the comparison + */ + private boolean isAlphaNum(char c) { + return(isAlpha(c) || isDigit(c)); + } + + /** + * Identify valid Characters for cell references + * + * @param c The character which is to be identified + * @return A boolean returning the result of the comparison + */ + private boolean isCellRef(char c) { + return(isAlpha(c) || isDigit(c) || isCellRefSpecialChar(c)); + } + + /** + * Test if current character is a match and move to next character + * + * @param c The character which is to be matched + */ + private void match(char c) throws FormulaParsingException { + + if(look==c) { + Debug.log(Debug.TRACE,"Operator Found : " + look); + getChar(); + skipWhite(); + } + else + throw new FormulaParsingException("Unexpected character '" + c + "'"); + } + + /** + * Test if current character is a match and move to next character + * + * @param symbol The <code>String</code> to be matched. + */ + private void match(String symbol) throws FormulaParsingException { + + int numChars = symbol.length(); + boolean bContinue = true; + currentMatch.delete(0,currentMatch.length()); + for (int i=0;i<numChars && bContinue; i++) { + if (look == symbol.charAt(i)) { + currentMatch.append(symbol.charAt(i)); + bContinue = getChar(); + skipWhite(); + } else { + throw new FormulaParsingException("Unexpected character '" + symbol + "'"); + } + } + } + + /** + * Skip over whitespaces (ie. spaces and tabs) + */ + private void skipWhite() throws FormulaParsingException { + + boolean success = true; + + while(isWhite(look) && success) { + success = getChar(); + } + } + + /** + * This is a factor for multiplication and division operators + */ + private void factor() throws FormulaParsingException { + if(look=='(') { + match('('); + tokenVector.add(tokenFactory.getOperatorToken("(", 1)); + expression(); + match(')'); + tokenVector.add(tokenFactory.getOperatorToken(")", 1)); + } else if(isDigit(look)){ + getNum(); + } else { + ident(); + } + } + + /** + * Pulls the next character from the <code>String</code> + * + * @return boolean false if the end if the statement + * is reached otherwise true + */ + private boolean getChar() throws FormulaParsingException { + + boolean success = true; + + if(index<formulaStr.length()) { + look = formulaStr.charAt(index); + index++; + if(look==',') + success = false; + } else { + success = false; + } + return success; + } + + /** + * Parses the number of arguments in a function + * + * @return The number of arguments + */ + private int arguments() throws FormulaParsingException { + int numArgs; + + skipWhite(); + if(look==')') + numArgs = 0; + else + numArgs = 1; + + while(look!=')') { + expression(); + if(look==',') { + numArgs++; + match(','); + tokenVector.add(tokenFactory.getOperatorToken(",", 1)); + } + } + return numArgs; + } + + /** + * Test to see if we have come across a cell reference or a function and + * add the resulting toek nto the tokenVector. + */ + private void ident() throws FormulaParsingException { + + String cell = getTokenString(); + if(look=='(') { + Debug.log(Debug.TRACE,"Found Function : " + cell); + + int index = tokenVector.size(); + match('('); + tokenVector.add(tokenFactory.getOperatorToken("(", 1)); + int numArgs = arguments(); + match(')'); + tokenVector.add(tokenFactory.getOperatorToken(")", 1)); + tokenVector.insertElementAt(tokenFactory.getFunctionToken(cell, numArgs), index); + } else { + if(cell.indexOf(':')!=-1) { + tokenVector.add(tokenFactory.getOperandToken(cell, "CELL_AREA_REFERENCE")); + } else { + tokenVector.add(tokenFactory.getOperandToken(cell, "CELL_REFERENCE")); + } + } + } + + /** + * Will keep pulling valid logical operators from the formula and return + * the resultant <code>String</code>. + * + * @return a <code>String<code> representing a logical operator + */ + private String getLogicalOperator() throws FormulaParsingException { + String op = new String(); + boolean status; + + do { + op += look; + status = getChar(); + } while(isLogicalOpChar(look) && status); + skipWhite(); + return op; + } + + /** + * Keeps pulling characters from the statement until we get an + * operator and returns the resulting string. + * + * @return A <code>String</code>representing the next token + */ + private String getTokenString() throws FormulaParsingException { + + if(!isAlpha(look) && look!='$') + throw new FormulaParsingException("Expected Cell Reference"); + else { + String cell = new String(); + boolean status; + do { + cell += look; + status = getChar(); + } while(isCellRef(look) && status); + skipWhite(); + return cell; + } + } + + /** + * Keeps pulling numbers from the statement and add the resulting integer + * token to the tokenVector. + */ + private void getNum() throws FormulaParsingException { + + if(!isDigit(look)) + throw new FormulaParsingException("Expected Integer"); + else { + String num = new String(); + boolean status; + + do { + num += look; + status = getChar(); + } while(isDigit(look) && status); + skipWhite(); + tokenVector.add(tokenFactory.getOperandToken(num, "INTEGER")); + Debug.log(Debug.TRACE,"Number parsed : " + num); + } + } + + + /** + * Term will parse multiplication/division expressions + */ + private void term() throws FormulaParsingException { + factor(); + while(isMultiOp()) { + multiOp(Character.toString(look)); + } + } + + /** + * Expression is the entry point for the parser. It is the code + * that parses addition/subtraction expressions. + */ + private void expression() throws FormulaParsingException { + + if(isAddOp(look)) { + Character ch = new Character(look); + tokenVector.add(tokenFactory.getOperatorToken(ch.toString(), 1)); + } else { + term(); + } + while(isAddOp(look) || isLogicalOp()) { + if (isAddOp(look)) { + addOp(Character.toString(look)); + } else if (isLogicalOp()) { + logicalOp(); + } + } + } + + /** + * Test to see if the next token (represented as a <code>String</code>) is + * the same as the String passed in. Move the index along to the end of + * that String and add that <code>Token</code> to the tokenVector. Then + * call <code>term</code> to parse the right hand side of the operator. + * + * @param op A <code>String</code> representing the operator + */ + private void addOp(String op) throws FormulaParsingException { + match(op); + tokenVector.add(tokenFactory.getOperatorToken(op, 2)); + term(); + } + + /** + * Test to see if the next token (represented as a <code>String</code>) is + * the same as the String passed in. Move the index along to the end of + * that String and add that <code>Token</code> to the tokenVector. Then + * call <code>factor</code> to parse the right hand side of the operator. + * + * @param op A <code>String</code> representing the operator + */ + private void multiOp(String op) throws FormulaParsingException { + match(op); + tokenVector.add(tokenFactory.getOperatorToken(op, 2)); + factor(); + } + + /** + * Pull a logical operator starting at the current index, add a token for + * that operator to the tokenVector and call <code>term<code> to parse the + * right hand side of the operator + */ + private void logicalOp() throws FormulaParsingException { + String op = getLogicalOperator(); + tokenVector.add(tokenFactory.getOperatorToken(op, 2)); + term(); + } + } + diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParsingException.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParsingException.java new file mode 100644 index 000000000000..6ba7a05e8d19 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParsingException.java @@ -0,0 +1,76 @@ +/************************************************************************ + * + * EndianConverter.java + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2001 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; + +/* + * If the formula failed to be parsed properly this exception will be thrown + * + * Martin Maher + */ + +import java.io.*; + +import org.openoffice.xmerge.util.Debug; + +public class FormulaParsingException extends Exception { + + public FormulaParsingException(String message) { + super(message); + } + } diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FunctionLookup.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FunctionLookup.java new file mode 100644 index 000000000000..ae604e39e0c5 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FunctionLookup.java @@ -0,0 +1,268 @@ +/************************************************************************ + * FunctionLookup.java + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2001 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; + +import org.openoffice.xmerge.util.Debug; + +import java.util.HashMap; + +public class FunctionLookup implements SymbolLookup { + private static HashMap stringToArgs = null; + private static HashMap stringToID = null; + private static HashMap idToString = null; + + /** + * The default constructor - invokes {@link #initialize() initialize()} + */ + public FunctionLookup() { + initialize(); + } + + /** + * Initialize the lookup table for functions + */ + public synchronized void initialize() { + if ((stringToID != null) || (idToString != null) || (stringToArgs !=null)) { + return; + } + stringToID = new HashMap(); + idToString = new HashMap(); + stringToArgs = new HashMap(); + + // Functions with Variable number of Arguments + // Math and Trig + addEntry("SUM", TokenConstants.TSUM, -1); + addEntry("MIN", TokenConstants.TMIN, -1); + addEntry("PRODUCT", TokenConstants.TPRODUCT, -1); + addEntry("LOG", TokenConstants.TLOG, -1); + addEntry("SUMIF", TokenConstants.TSUMIF, -1); + addEntry("TRUNC", TokenConstants.TRUNC, -1); + // Financial + addEntry("DDB", TokenConstants.TDDB, -1); + addEntry("FV", TokenConstants.TFV, -1); + addEntry("IRR", TokenConstants.TIRR, -1); + addEntry("NPER", TokenConstants.TNPER, -1); + addEntry("NPV", TokenConstants.TNPV, -1); + addEntry("PMT", TokenConstants.TPMT, -1); + addEntry("PV", TokenConstants.TPV, -1); + addEntry("RATE", TokenConstants.TRATE, -1); + // Statistical + addEntry("AVERAGE", TokenConstants.TAVERAGE, -1); + addEntry("COUNT", TokenConstants.TCOUNT, -1); + addEntry("COUNTA", TokenConstants.TCOUNTA, -1); + addEntry("MAX", TokenConstants.TMAX, -1 ); + addEntry("MIN", TokenConstants.TMIN, -1); + addEntry("STDEV", TokenConstants.TSTDEV, -1 ); + addEntry("VAR", TokenConstants.TVAR, -1); + addEntry("VARP", TokenConstants.TVARP, -1); + // Lookup + addEntry("CHOOSE", TokenConstants.TCHOOSE, -1); + addEntry("HLOOKUP", TokenConstants.THLOOKUP, -1); + addEntry("INDEX", TokenConstants.TINDEX, -1); + addEntry("MATCH", TokenConstants.TMATCH, -1) ; + addEntry("VLOOKUP", TokenConstants.TVLOOKUP, -1); + // Text + addEntry("RIGHT", TokenConstants.TRIGHT, -1); + addEntry("SUBSTITUTE", TokenConstants.TSUBSTITUTE, -1); + addEntry("FIND", TokenConstants.TFIND, -1); + addEntry("LEFT", TokenConstants.TLEFT, -1); + // Logical + addEntry("AND", TokenConstants.TAND, -1 ); + addEntry("IF", TokenConstants.TIF, -1) ; + addEntry("OR", TokenConstants.TOR, -1); + + // Functions with Fixed number of Arguments + // Math and Trig + addEntry("ABS", TokenConstants.TABS, 1); + addEntry("ACOS", TokenConstants.TACOS, 1); + addEntry("ASIN", TokenConstants.TASIN, 1); + addEntry("ATAN", TokenConstants.TATAN, 1); + addEntry("ATAN2", TokenConstants.TATAN2, 1); + addEntry("COS", TokenConstants.TCOS, 1); + addEntry("COUNTIF", TokenConstants.TCOUNTIF, 1); + addEntry("DEGREES", TokenConstants.TDEGREES, 1); + addEntry("EXP", TokenConstants.TEXP, 1); + addEntry("FACT", TokenConstants.TFACT, 1); + addEntry("INT", TokenConstants.TINTE, 1); + addEntry("LN", TokenConstants.TLN, 1); + addEntry("LOG10", TokenConstants.TLOG10, 1); + addEntry("MOD", TokenConstants.TMOD, 1); + addEntry("PI", TokenConstants.TPI, 0); + addEntry("POWER", TokenConstants.TPOWERF, 2); + addEntry("RADIANS", TokenConstants.TRADIANS, 1); + addEntry("RAND", TokenConstants.TRAND, 1); + addEntry("ROUND", TokenConstants.TROUND, 1); + addEntry("SQRT", TokenConstants.TSQRT, 1); + addEntry("TAN", TokenConstants.TTAN, 1); + // Financial + addEntry("SLN", TokenConstants.TSLN, 3); + addEntry("SYD", TokenConstants.TSYD, 4); + // Date and Time + addEntry("DATE", TokenConstants.TDATE, 3); + addEntry("DATEVALUE", TokenConstants.TDATEVALUE, 1); + addEntry("DAY", TokenConstants.TDAY, 1); + addEntry("HOUR", TokenConstants.THOUR, 1); + addEntry("MINUTE", TokenConstants.TMINUTE, 1 ); + addEntry("MONTH", TokenConstants.TMONTH, 1); + addEntry("NOW", TokenConstants.TNOW, 0); + addEntry("SECOND", TokenConstants.TSECOND, 1); + addEntry("TIME", TokenConstants.TTIME, 3); + addEntry("TIMEVALUE", TokenConstants.TTIMEVALUE, 1); + addEntry("YEAR", TokenConstants.TYEAR, 1); + // Statistical + addEntry("COUNTBLANK", TokenConstants.TCOUNTBLANK, 1); + // lookup + addEntry("COLUMNS", TokenConstants.TCOLUMNS, 1); + addEntry("ROWS", TokenConstants.TROWS, 1); + // Database + addEntry("DAVERAGE", TokenConstants.TDAVAERAGE, 3); + addEntry("DCOUNT", TokenConstants.TDCOUNT, 3); + addEntry("DCOUNTA", TokenConstants.TDCOUNTA, 2); + addEntry("DGET", TokenConstants.TDGET, 3); + addEntry("DMAX", TokenConstants.TDMAX, 3); + addEntry("DMIN", TokenConstants.TDMIN, 3); + addEntry("DPRODUCT", TokenConstants.TDPRODUCT, 3); + addEntry("DSTDEV", TokenConstants.TDSTDEV, 3); + addEntry("DSTDEVP", TokenConstants.TDSTDEVP, 3) ; + addEntry("DSUM", TokenConstants.TDSUM, 3); + addEntry("TRUNC", TokenConstants.TDVAR, 3); + addEntry("DVARP", TokenConstants.TDVARP, 3); + // Text + addEntry("EXACT", TokenConstants.TEXACT, 2); + addEntry("LEN", TokenConstants.TLEN, 1); + addEntry("LOWER", TokenConstants.TLOWER, 1); + addEntry("MID", TokenConstants.TMID, 3); // ?????? + addEntry("PROPER", TokenConstants.TPROPER, 1); + addEntry("REPLACE", TokenConstants.TREPLACE, 4); + addEntry("REPT", TokenConstants.TREPT, 2); + addEntry("T", TokenConstants.TT, 1); + addEntry("TRIM", TokenConstants.TRIM, 1); + addEntry("UPPER", TokenConstants.TUPPER, 1); + addEntry("VALUE", TokenConstants.TVALUE, 1); + // Logical + addEntry("FALSE", TokenConstants.TFALSE, 0); + addEntry("NOT", TokenConstants.TNOT, 1); + addEntry("TRUE", TokenConstants.TTRUE, 0); + // Informational + addEntry("ERRORTYPE", TokenConstants.TERRORTYPE, 1); + addEntry("ISBLANK", TokenConstants.TISBLANK, 1); + addEntry("ISERR", TokenConstants.TISERR, 1); + addEntry("ISERROR", TokenConstants.TISERROR, 1); + addEntry("ISLOGICAL", TokenConstants.TISLOGICAL, 1); + addEntry("ISNA", TokenConstants.TISNA, 1); + addEntry("ISNONTEXT", TokenConstants.TISNONTEXT, 1); + addEntry("ISNUMBER", TokenConstants.TISNUMBER, 1); + addEntry("ISTEXT", TokenConstants.TISTEXT, 1); + addEntry("N", TokenConstants.TN, 1); + addEntry("NA", TokenConstants.TNA, 0); + + } + + /** + * Associate a function with an identifier + * @param symbol The function string that will act as the key in the lookup table + * @param id The identifier for the function + */ + public void addEntry(String symbol, int id) { + Integer iObj = new Integer(id); + stringToID.put(symbol,iObj); + idToString.put(iObj,symbol); + } + + /** + * Associate a function with an identifier and specifiy the number of arguments for that function + * @param symbol The function string that will act as the key in the lookup table + * @param id The identifier for the function + * @param args The number of arguments this function requires + */ + public void addEntry(String symbol, int id, int args) { + addEntry(symbol, id); + stringToArgs.put(symbol, new Integer(args)); + } + + /** + * Retrieve the function string associated with a given id + * @param id The identfier for the function + * @return The function string + */ + public String getStringFromID(int id) { + return (String)idToString.get(new Integer(id)); + } + + /** + * Retrieve the identifier associated with a given function + * @param symbol The function name + * @throws UnsupportedFunctionException Thown when the function is not found in the lookup table + * @return The identifier associated with this function in the lookup table. + */ + public int getIDFromString(String symbol) throws UnsupportedFunctionException { + Integer i = (Integer)stringToID.get(symbol); + if (i == null) + throw new UnsupportedFunctionException("Function '" + symbol + "' not supported by Pocket Excel"); + return ((Integer)stringToID.get(symbol)).intValue(); + } + + /** + * Retrieve the number of arguments for this function + * @param symbol The function name + * @return The number of arguments required by this function + */ + public int getArgCountFromString(String symbol) { + return ((Integer)stringToArgs.get(symbol)).intValue(); + } +} diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperandLookup.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperandLookup.java new file mode 100644 index 000000000000..bc17d23dd13d --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperandLookup.java @@ -0,0 +1,122 @@ +/************************************************************************ + * + * OperandLookup.java + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2001 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; +import java.util.HashMap; + +import org.openoffice.xmerge.util.Debug; + +/** + * A lookup table containing information about operands + */ +public class OperandLookup implements SymbolLookup { + private static HashMap stringToID = null; + private static HashMap idToString = null; + + + /** + * The default constructor - invokes {@link #initialize() initialize()} + */ + public OperandLookup() { + initialize(); + } + + /** + * Initialize the lookup table for operandss + */ + public synchronized void initialize() { + if ((stringToID != null) || (idToString != null)) { + return; + } + stringToID = new HashMap(); + idToString = new HashMap(); + addEntry("CELL_REFERENCE", TokenConstants.TREF); + addEntry("CELL_AREA_REFERENCE", TokenConstants.TAREA); + addEntry("INTEGER", TokenConstants.TINT); + addEntry("NUMBER", TokenConstants.TNUM); + } + + /** + * Associate an operand with an identifier + * @param symbol The operand that will act as the key in the lookup table + * @param id The identifier for the operand + */ + public void addEntry(String symbol, int id) { + Integer iObj = new Integer(id); + stringToID.put(symbol,iObj); + idToString.put(iObj,symbol); + } + + /** + * Retrieve the operand string associated with a given id + * @param id The identfier for the operand + * @return The operand string + */ + public String getStringFromID(int id) { + return (String)idToString.get(new Integer(id)); + } + + /** + * Retrieve the identifier associated with a given operator + * @param symbol The operand name + * @return The identifier associated with this operand in the lookup table. + */ + public int getIDFromString(String symbol) { + return ((Integer)stringToID.get(symbol)).intValue(); + } +} diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperatorLookup.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperatorLookup.java new file mode 100644 index 000000000000..fbc44d86f779 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperatorLookup.java @@ -0,0 +1,135 @@ +/************************************************************************ + * + * OperatorLookup.java + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2001 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; + +import java.util.HashMap; + +import org.openoffice.xmerge.util.Debug; + +/** + * A lookup table containing information about operators + */ +public class OperatorLookup { + private static HashMap stringToID = null; + private static HashMap idToString = null; + + /** + * The default constructor - invokes {@link #initialize() initialize()} + */ + public OperatorLookup() { + initialize(); + } + + /** + * Initialize the lookup table for operators + */ + public synchronized void initialize() { + if ((stringToID != null) || (idToString != null)) { + return; + } + stringToID = new HashMap(); + idToString = new HashMap(); + addEntry("UNARY_PLUS", TokenConstants.TUPLUS); + addEntry("UNARY_MINUS", TokenConstants.TUMINUS); + addEntry("+", TokenConstants.TADD); + addEntry("-", TokenConstants.TSUB); + addEntry("*", TokenConstants.TMUL); + addEntry("/", TokenConstants.TDIV); + addEntry(",", TokenConstants.TARGSEP); + addEntry("^", TokenConstants.TPOWER); + addEntry("&", TokenConstants.TCONCAT); + addEntry("(", TokenConstants.TPAREN); + addEntry(")", TokenConstants.TCLOSEPAREN); + addEntry("<", TokenConstants.TLESS); + addEntry(">", TokenConstants.TGREATER); + addEntry(">=", TokenConstants.TGTEQUALS); + addEntry("<=", TokenConstants.TLESSEQUALS); + addEntry("=", TokenConstants.TEQUALS); + addEntry("<>", TokenConstants.TNEQUALS); + } + + /** + * Associate an operator with an identifier + * @param symbol The operator that will act as the key in the lookup table + * @param id The identifier for the operator + */ + public void addEntry(String symbol, int id) { + Integer iObj = new Integer(id); + stringToID.put(symbol, iObj); + idToString.put(iObj, symbol); + } + + /** + * Retrieve the operator string associated with a given id + * @param id The identfier for the operator + * @return The operator string + */ + public String getStringFromID(int id) { + return (String)idToString.get(new Integer(id)); + } + + /** + * Retrieve the identifier associated with a given operator + * @param symbol The operator name + * @return The identifier associated with this operator in the lookup table. + */ + public int getIDFromString(String symbol) { + return ((Integer)stringToID.get(symbol)).intValue(); + } +} diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/ParseToken.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/ParseToken.java new file mode 100644 index 000000000000..2de6f52d94c6 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/ParseToken.java @@ -0,0 +1,71 @@ +/************************************************************************ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2001 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; + +public interface ParseToken +{ + public boolean isOperand(); + public boolean isOperator(); + public int getTokenType(); + + //GENERIC TOKENS (MOSTLY UNUSED + public static final int TOKEN_OPERATOR = 1; + public static final int TOKEN_OPERAND = 2; + public static final int TOKEN_FUNCTION_FIXED = 3; + public static final int TOKEN_FUNCTION_VARIABLE = 4; + +} diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/PrecedenceTable.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/PrecedenceTable.java new file mode 100644 index 000000000000..826784b3a924 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/PrecedenceTable.java @@ -0,0 +1,115 @@ +/************************************************************************ + * + * PrecedenceTable.java + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2001 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; + +import java.util.HashMap; + +/** + * This class defines the precedence applied to each operator when performing a conversion {@link + org.openoffice.xmerge.converter.xml.sxc.pexce.Records.formula.FormulaCompiler.infix2 from infix to RPN.}. + */ +public class PrecedenceTable { + public static final int DEFAULT_PRECEDENCE = 0; + public static final int EQNEQ_PRECEDENCE = 1; // =, <> + public static final int GTLTEQ_PRECEDENCE = 1; // >=, <= + public static final int GTLT_PRECEDENCE = 2; // >, < + public static final int ADDOP_PRECEDENCE = 4; // +, - + public static final int MULTOP_PRECEDENCE = 5; // *, / + public static final int FACTOR_PRECEDENCE = 6; // ^ + public static final int CONCAT_PRECEDENCE = 6; // & + public static final int UNARY_PRECEDENCE = 7; // !, Unary +, Unary - + public static final int PAREN_PRECEDENCE = 8; // (, ) + public static final int FUNCTION_PRECEDENCE = 8; + public static final int COMMA_PRECEDENCE = 8; + + private static HashMap map; + static { + map = new HashMap(); + + map.put("+", new Integer(ADDOP_PRECEDENCE)); + map.put("-", new Integer(ADDOP_PRECEDENCE)); + map.put("*", new Integer(MULTOP_PRECEDENCE)); + map.put("/", new Integer(MULTOP_PRECEDENCE)); + map.put("(", new Integer(PAREN_PRECEDENCE)); + map.put(")", new Integer(PAREN_PRECEDENCE)); + map.put(",", new Integer(COMMA_PRECEDENCE)); + map.put(">", new Integer(GTLT_PRECEDENCE)); + map.put("<", new Integer(GTLT_PRECEDENCE)); + map.put("=", new Integer(EQNEQ_PRECEDENCE)); + map.put("&", new Integer(CONCAT_PRECEDENCE)); + map.put("^", new Integer(FACTOR_PRECEDENCE)); + map.put(">=", new Integer(GTLTEQ_PRECEDENCE)); + map.put("<=", new Integer(GTLTEQ_PRECEDENCE)); + map.put("<>", new Integer(EQNEQ_PRECEDENCE)); + map.put("FUNCTION", new Integer(FUNCTION_PRECEDENCE)); + } + + /** + * Retrieve the precedence value for a given operator. + * @param op Look up the precedence for this operator + * @return an integer representing the integer value of the operator + */ + public static int getPrecedence(String op) { + Object obj = map.get(op); + if (obj == null) { + return DEFAULT_PRECEDENCE; + } + return ((Integer)obj).intValue(); + } +} diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/SymbolLookup.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/SymbolLookup.java new file mode 100644 index 000000000000..270e459db3d8 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/SymbolLookup.java @@ -0,0 +1,94 @@ +/************************************************************************ + * + * SymbolLookup.java + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2001 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; + +/** + * This interface defines the attributes of a lookup table for this plugin. + * Symbols will generally be either operators (_, -, *, etc) or funtion names. + */ +public interface SymbolLookup { + /** + * Perform lookup table specific initialization. This would typically entail loading values into + * the lookup table. It is best to optimize this process so that data is loaded statically and shared + * across all instances of the lookup table. + */ + public void initialize(); + + /** + * Associate a symbol with a numeric value in the lookup table + * @param symbol The symbol that will act as the key in the lookup table + * @param value The value to be associated with a given symbol + */ + public void addEntry(String symbol, int value); + + /** + * Retrieve the symbol associated with a given identifier + * @param id The identfier for which we need to retieve the symbol string + * @return The string associated with this identifier in the lookup table. + */ + public String getStringFromID(int id); + + /** + * Retrieve the identifier associated with a given symbol + * @param symbol The symbol for which we need to retieve the identifier + * @throws UnsupportedFunctionException Thown when the symbol is not found in the lookup table + * @return The identifier associated with this string in the lookup table. + */ + public int getIDFromString(String symbol) throws UnsupportedFunctionException; +} diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/Token.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/Token.java new file mode 100644 index 000000000000..1902b8cb8484 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/Token.java @@ -0,0 +1,182 @@ +/************************************************************************ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2001 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; + + +import java.io.*; + +/** + * A Token is the basic building block of any formula. + * A Token can be of four types (Operator, Operand, Function with fixed + * arguments and function with a variable number of arguments. Each type can + * have numerous id's. Thetypes are define in <code>ParseToken</code> and the + * id's are defined in <code>TokenConstants</code>. The other member variables + * are priority which is returned from the <code>PrecedenceTable</code>, the + * value which is the String equivalent of the token (eg. "+", "$A$12", "SUM") + * and the number of arguments which is only valid for operators and functions. + * Tokens should never be created directly and instead are created by the + * <code>TokenFactory</code> + */ +public class Token implements ParseToken { + + private String value; + private int type; // operator, operand, function fixed, function variable + private int id; // cell reference, SUM, integer + private int priority; + private int numArgs=-1; + + public Token(String op, int type, int id, int args) { + this.value = op; + this.type = type; + this.id = id; + this.numArgs = args; + if(type==ParseToken.TOKEN_FUNCTION_VARIABLE) { + priority = PrecedenceTable.getPrecedence("FUNCTION"); + } else if(type==ParseToken.TOKEN_OPERATOR) { + priority = PrecedenceTable.getPrecedence(op); + } else { + priority = PrecedenceTable.getPrecedence("DEFAULT"); + } + } + + /** + * Checks if the current token is an operator + * + * @return A <code>boolean</code> result of the comaparison + */ + public boolean isOperator() { + return type == ParseToken.TOKEN_OPERATOR; + } + + /** + * Checks if the current token is an operand + * + * @return A <code>boolean</code> result of the comaparison + */ + public boolean isOperand() { + return type == ParseToken.TOKEN_OPERAND; + } + + /** + * Checks if the current token is a function + * + * @return A <code>boolean</code> result of the comaparison + */ + public boolean isFunction() { + return (type==ParseToken.TOKEN_FUNCTION_FIXED) || (type==ParseToken.TOKEN_FUNCTION_VARIABLE); + } + + /** + * Returns the token type. This can be one of four values (TOKEN_OPERATOR, + * TOKEN_OPERAND, TOKEN_FUNCTION_FIXED, TOKEN_FUNCTION_VARIABLE) defined in + * <code>ParseToken</code> + * + * @return A <code>boolean</code> result of the comparison + */ + public int getTokenType() { + + return type; + } + + /** + * Returns the ID of this token. This ID is equivalent to the pexcel hex + * value and is defined in <code>ParseToken</code> + * + * @return Returns the id of this token + */ + public int getTokenID() { + + return id; + } + + /** + * Returns the <code>String</code> equivalent of this token + * + * @return The <code>String</code> representing this Token + */ + public String getValue() { + return value; + } + + /** + * Returns the number of arguments if this token represents an operator or + * function. Otherwise returns -1. + * + * @return The number of arguments + */ + public int getNumArgs() { + return numArgs; + } + + /** + * Checks if the current token is an operator + * + * @return A <code>boolean</code> result of the comparison + */ + public int getTokenPriority() { + return priority; + } + + /** + * Returns the <code>String</code> equivalent of this token + * + * @return The <code>String</code> representing this Token + */ + public String toString() { + return getValue(); + } +} diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenConstants.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenConstants.java new file mode 100644 index 000000000000..dce1bd75ec3d --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenConstants.java @@ -0,0 +1,228 @@ +/************************************************************************ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2001 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; + +import java.io.*; + +public interface TokenConstants { + + // Unary Operator Tokens + public static final int TUPLUS = 0x12; + public static final int TUMINUS = 0x13; + public static final int TPERCENT = 0x14; + public static final int TPAREN = 0x15; + // Binary Operator Tokens + public static final int TADD = 0x03; + public static final int TSUB = 0x04; + public static final int TMUL = 0x05; + public static final int TDIV = 0x06; + public static final int TPOWER = 0x07; + public static final int TCONCAT = 0x08; + + //Logical operators + public static final int TLESS = 0x09; + public static final int TLESSEQUALS = 0x0A; + public static final int TEQUALS = 0x0B; + public static final int TGTEQUALS = 0x0C; + public static final int TGREATER = 0x0D; + public static final int TNEQUALS = 0x0E; + + // Function Operator Tokens + public static final int TFUNC = 0x41; + public static final int TFUNCVAR = 0x42; + + // Constant Operand Tokens + public static final int TINT = 0x1E; + public static final int TNUM = 0x1F; + // Operand Tokens + public static final int TREF = 0x44; + public static final int TAREA = 0x25; + + // + public static final int TARGSEP = 0x1001; + public static final int TCLOSEPAREN = 0x1002; + + // Variable argument Functions + // Math and Trig + public static final int TSUM = 0x04; + public static final int TPRODUCT = 0xB7; + public static final int TSUMIF = 0x0159; + public static final int TLOG = 0x6D; + public static final int TRUNC = 0xC5; + // Financial + public static final int TDDB = 0x90; + public static final int TFV = 0x39; + public static final int TIRR = 0x3E; + public static final int TNPER = 0x3A; + public static final int TNPV = 0x0B; + public static final int TPMT = 0x3B; + public static final int TPV = 0x38; + public static final int TRATE = 0x3C; + // Statistical + public static final int TAVERAGE = 0x05; + public static final int TCOUNT = 0x00; + public static final int TCOUNTA = 0xA9; + public static final int TMAX = 0x07 ; + public static final int TMIN = 0x06 ; + public static final int TSTDEV = 0x0C ; + public static final int TVAR = 0x2E ; + public static final int TVARP = 0xC2 ; + // Lookup + public static final int TCHOOSE = 0x64 ; + public static final int THLOOKUP = 0x65 ; + public static final int TINDEX = 0x1D ; + public static final int TMATCH = 0x40 ; + public static final int TVLOOKUP = 0x66 ; + // Text + public static final int TRIGHT = 0x74 ; + public static final int TSUBSTITUTE = 0x78 ; + public static final int TFIND = 0x7c ; + public static final int TLEFT = 0x73 ; + // Logical + public static final int TAND = 0x24 ; // 42 + public static final int TIF = 0x01 ; // 42 + public static final int TOR = 0x25 ; // 42 + + // Fixed argument Functions + // Math and Trig + public static final int TABS = 0x18; + public static final int TACOS = 0x63; + public static final int TASIN = 0x62; + public static final int TATAN = 0x12; + public static final int TATAN2 = 0x61; + public static final int TCOS = 0x10; + + public static final int TCOUNTIF = 0x015A; + public static final int TDEGREES = 0x0157; + public static final int TEXP = 0x15; + public static final int TFACT = 0xB8; + public static final int TINTE = 0x19; + public static final int TLN = 0x16; + + public static final int TLOG10 = 0x17; + public static final int TMOD = 0x27; + public static final int TPI = 0x13; + + public static final int TPOWERF = 0x0151; + public static final int TRADIANS = 0x0156; + public static final int TRAND = 0x3F; + public static final int TROUND = 0x1B; + public static final int TSQRT = 0x14; + public static final int TTAN = 0x11; + + public static final int TSLN = 0x8E; + public static final int TSYD = 0x8F; + + // Date and Time + public static final int TDATE = 0x41; + public static final int TDATEVALUE = 0x8C; + public static final int TDAY = 0x43; + public static final int THOUR = 0x47; + public static final int TMINUTE = 0x48; + public static final int TMONTH = 0x44; + public static final int TNOW = 0x4A; + public static final int TSECOND = 0x49; + public static final int TTIME = 0x42; + public static final int TTIMEVALUE = 0x8D; + public static final int TYEAR = 0x45; + // Statistical + public static final int TCOUNTBLANK = 0x015B ; + // lookup + public static final int TCOLUMNS = 0x4D ; + public static final int TROWS = 0x4C ; + // Database + public static final int TDAVAERAGE = 0x2A ; + public static final int TDCOUNT = 0x28 ; + public static final int TDCOUNTA = 0xC7 ; + public static final int TDGET = 0xEB ; + public static final int TDMAX = 0x2C ; + public static final int TDMIN = 0x2B ; + public static final int TDPRODUCT = 0xBD ; + public static final int TDSTDEV = 0x2D ; + public static final int TDSTDEVP = 0xC3 ; + public static final int TDSUM = 0x29 ; + public static final int TDVAR = 0x2F ; + public static final int TDVARP = 0xC4 ; + // Text + public static final int TEXACT = 0x75 ; + public static final int TLEN = 0x20 ; + public static final int TLOWER = 0x70 ; + public static final int TMID = 0x1F ; // ?????? + public static final int TPROPER = 0x72 ; + public static final int TREPLACE = 0x77 ; + public static final int TREPT = 0x1E ; + public static final int TT = 0x82 ; + public static final int TRIM = 0x76 ; + public static final int TUPPER = 0x71 ; + public static final int TVALUE = 0x21 ; + // Logical + public static final int TFALSE = 0x23 ; + public static final int TNOT = 0x26 ; + public static final int TTRUE = 0x22 ; + // Informational + public static final int TERRORTYPE = 0x05 ; + public static final int TISBLANK = 0x81 ; + public static final int TISERR = 0x7E ; + public static final int TISERROR = 0x03 ; + public static final int TISLOGICAL = 0xC6 ; + public static final int TISNA = 0x02 ; + public static final int TISNONTEXT = 0xBE ; + public static final int TISNUMBER = 0x80 ; + public static final int TISTEXT = 0x7F ; + public static final int TN = 0x83 ; + public static final int TNA = 0x0A ; +} diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenDecoder.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenDecoder.java new file mode 100644 index 000000000000..3a71a07c073f --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenDecoder.java @@ -0,0 +1,336 @@ +/************************************************************************ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2001 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; + +import java.io.*; +import java.util.Vector; + +import org.openoffice.xmerge.util.Debug; +import org.openoffice.xmerge.util.EndianConverter; +/** + * The TokenDecoder decodes a byte[] to an equivalent <code>String</code>. The only + * public method apart from the default constructor is the getTokenVector method. + * This method takes an entire formula as a pexcel byte[] and decodes it into + * a series of <code>Token</code>s. It adds these to a <code>Vector</code> which + * is returned once all the tokens have been decoded. The Decoder supports + * the following tokens.<br><br> + * + * Operands Floating point's, Cell references (absolute and relative), + * cell ranges<br> + * Operators +,-,*,/,<,>.<=,>=,<><br> + * Functions All pexcel fixed and varaible argument functions + * + */ +public class TokenDecoder { + + private TokenFactory tf; + private FunctionLookup fl; + private OperatorLookup operatorLookup; + private OperandLookup operandLookup; + + /** + * Default Constructor initializes the <code>TokenFactory</code> for generating + * <code>Token</code> and the <code>SymbolLookup</code> for generating + * Strings from hex values. + */ + public TokenDecoder() { + tf = new TokenFactory(); + fl = new FunctionLookup(); + operatorLookup = new OperatorLookup(); + operandLookup = new OperandLookup(); + } + + /** + * Returns a <code>Vector</code> of <code>Token</code> decoded from a + * byte[]. The byte[] is first converted to a + * <code>ByteArrayInputStream</code> as this is the easiest way of reading + * bytes. + * + * @param formula A Pocket Excel Formula byte[] + * @return A <code>Vector</code> of deoded <code>Token</code> + */ + public Vector getTokenVector(byte[] formula) { + + Vector v = new Vector(); + + ByteArrayInputStream bis = new ByteArrayInputStream(formula); + int b = 0 ; + Token t; + + while (bis.available()!=0) + { + b = bis.read(); + + switch (b) { + + case TokenConstants.TREF : + v.add(readCellRefToken(bis)); + Debug.log(Debug.TRACE, "Decoded Cell Reference: " + v.lastElement()); + break; + case TokenConstants.TAREA : + v.add(readCellAreaRefToken(bis)); + Debug.log(Debug.TRACE, "Decoded Cell Area Reference: " + v.lastElement()); + break; + case TokenConstants.TNUM : + v.add(readNumToken(bis)); + Debug.log(Debug.TRACE, "Decoded number : " + v.lastElement()); + break; + case TokenConstants.TFUNCVAR : + v.add(readFunctionVarToken(bis)); + Debug.log(Debug.TRACE, "Decoded variable argument function: " + v.lastElement()); + break; + case TokenConstants.TFUNC : + v.add(readFunctionToken(bis)); + Debug.log(Debug.TRACE, "Decoded function: " + v.lastElement()); + break; + case TokenConstants.TADD : + case TokenConstants.TSUB : + case TokenConstants.TMUL : + case TokenConstants.TDIV : + case TokenConstants.TLESS : + case TokenConstants.TLESSEQUALS : + case TokenConstants.TEQUALS : + case TokenConstants.TGTEQUALS : + case TokenConstants.TGREATER : + case TokenConstants.TNEQUALS : + v.add(readOperatorToken(b)); + + Debug.log(Debug.TRACE, "Decoded binary operator : " + v.lastElement()); + break; + default : + Debug.log(Debug.TRACE, "Unrecognized byte : " + b); + } + } + return v; + } + + /** + * Converts a zero based integer to a char (eg. a=0, b=1). + * It assumes the integer is less than 26. + * + * @param i A 0 based index + * @return The equivalent character + */ + private char int2Char(int i) { + return (char) ('A' + i); + } + + /** + * Reads a Cell Reference token from the <code>ByteArrayInputStream</code> + * + * @param bis The <code>ByteArrayInputStream</code> from which we read the + * bytes. + * @return The decoded Cell Reference <code>Token</code> + */ + private Token readCellRefToken(ByteArrayInputStream bis) { + byte buffer[] = new byte[2]; + String outputString = new String(); + + buffer[0] = (byte) bis.read(); + buffer[1] = (byte) bis.read(); + int formulaRow = EndianConverter.readShort(buffer); + int relativeFlags = (formulaRow & 0xC000)>>14; + formulaRow &= 0x3FFF; + int formulaCol = (byte) bis.read(); + + outputString = int2CellStr(formulaRow, formulaCol, relativeFlags); + + return (tf.getOperandToken(outputString,"CELL_REFERENCE")); + } + + /** + * Converts a row and col 0 based index to a spreadsheet cell reference. + * It also has a relativeFlags which indicates whether or not the + * Cell Reference is relative or absolute (Absolute is denoted with '$') + * + * 00 = absolute row, absolute col + * 01 = absolute row, relative col + * 10 = relative row, absolute col + * 11 = relative row, relative col + * + * @param row The cell reference 0 based index to the row + * @param col The cell reference 0 based index to the row + * @param relativeFlags Flags indicating addressing of row and column + * @return A <code>String</code> representing a cell reference + */ + private String int2CellStr(int row, int col, int relativeFlags) { + String outputString = ""; + int firstChar = (col + 1) / 26; + + if((relativeFlags & 1) == 0) { + outputString += "$"; + } + + if(firstChar>0) { + int secondChar = (col + 1) % 26; + outputString += Character.toString(int2Char(firstChar - 1)) + Character.toString(int2Char(secondChar - 1)); + } else { + outputString += Character.toString(int2Char(col)); + } + if((relativeFlags & 2) == 0) { + outputString += "$"; + } + outputString += Integer.toString(row+1); + return outputString; + } + + /** + * Reads a Cell Area Reference (cell range) <code>Token</code> from + * the <code>ByteArrayInputStream</code> + * + * @param bis The <code>ByteArrayInputStream</code> from which we read the + * bytes. + * @return The equivalent Cell Area Reference (cell range) + * <code>Token</code> + */ + private Token readCellAreaRefToken(ByteArrayInputStream bis) { + byte buffer[] = new byte[2]; + int formulaRow1, formulaRow2; + int formulaCol1, formulaCol2; + + String outputString = new String(); + + buffer[0] = (byte) bis.read(); + buffer[1] = (byte) bis.read(); + formulaRow1 = EndianConverter.readShort(buffer); + int relativeFlags1 = (formulaRow1 & 0xC000)>>14; + formulaRow1 &= 0x3FFF; + buffer[0] = (byte) bis.read(); + buffer[1] = (byte) bis.read(); + formulaRow2 = EndianConverter.readShort(buffer); + int relativeFlags2 = (formulaRow2 & 0xC000)>>14; + formulaRow2 &= 0x3FFF; + + formulaCol1 = (byte) bis.read(); + formulaCol2 = (byte) bis.read(); + + outputString = int2CellStr(formulaRow1, formulaCol1, relativeFlags1); + outputString += (":" + int2CellStr(formulaRow2, formulaCol2, relativeFlags2)); + + return (tf.getOperandToken(outputString,"CELL_AREA_REFERENCE")); + } + + + /** + * Reads a Number (floating point) token from the <code>ByteArrayInputStream</code> + * + * @param bis The <code>ByteArrayInputStream</code> from which we read the + * bytes. + * @return The decoded Integer <code>Token</code> + */ + private Token readNumToken(ByteArrayInputStream bis) { + + byte numBuffer[] = new byte[8]; + + for(int j=0;j<8;j++) { + numBuffer[j]=(byte) bis.read(); + } + + return (tf.getOperandToken(Double.toString(EndianConverter.readDouble(numBuffer)),"NUMBER")); + } + + /** + * Read an Operator token from the <code>ByteArrayInputStream</code> + * + * @param b A Pocket Excel number representing an operator. + * @return The decoded Operator <code>Token</code> + */ + private Token readOperatorToken(int b) { + + return tf.getOperatorToken(operatorLookup.getStringFromID(b), 2); + } + + /** + * Read a Function token from the <code>ByteArrayInputStream</code> + * This function can have any number of arguments and this number is read + * in with the record + * + * @param bis The <code>ByteArrayInputStream</code> from which we read the + * bytes. + * @return The decoded variable argument Function <code>Token</code> + */ + private Token readFunctionVarToken(ByteArrayInputStream bis) { + + int numArgs = 0; + numArgs = bis.read(); + byte buffer[] = new byte[2]; + buffer[0] = (byte) bis.read(); + buffer[1] = (byte) bis.read(); + int functionID = EndianConverter.readShort(buffer); + return (tf.getFunctionToken(fl.getStringFromID(functionID),numArgs)); + } + + /** + * Read a Function token from the <code>ByteArrayInputStream</code> + * This function has a fixed number of arguments which it will get + * from <code>FunctionLookup</code>. + * + * @param bis The <code>ByteArrayInputStream</code> from which we read the + * bytes. + * @return The decoded fixed argument Function <code>Token</code> + */ + private Token readFunctionToken(ByteArrayInputStream bis) { + + byte buffer[] = new byte[2]; + buffer[0] = (byte) bis.read(); + buffer[1] = (byte) bis.read(); + int functionID = EndianConverter.readShort(buffer); + String functionName = fl.getStringFromID(functionID); + return (tf.getFunctionToken(functionName,fl.getArgCountFromString(functionName))); + } + +} diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenEncoder.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenEncoder.java new file mode 100644 index 000000000000..4e2b4c17e034 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenEncoder.java @@ -0,0 +1,366 @@ +/************************************************************************ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2001 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; + +import java.io.*; +import java.util.Vector; +import java.util.Enumeration; + +import org.openoffice.xmerge.util.Debug; +import org.openoffice.xmerge.util.EndianConverter; + +/** + * The TokenEncoder encodes a Token to an equivalent pexcel byte[]. The only + * public method apart from the default constructor is the getByte method. + * This method picks an encoder based onthe Token's type or id field and uses + * that encoder to return a byte[] which it returns. This Encoder supports + * Operands Floating point's, Cell references (absolute and relative), + * cell ranges + * Operators +,-,*,/,<,>.<=,>=,<> + * Functions All pexcel fixed and varaible argument functions + * + */ +public class TokenEncoder { + + FunctionLookup fl; + String parseString; + int index; + + /** + * Default Constructor + */ + public TokenEncoder() { + parseString = new String(); + fl = new FunctionLookup(); + } + + /** + * Return the byte[] equivalent of a <code>Token</code>. The various + * encoders return <code>Vector</code> of <code>Byte</code> instead + * of byte[] because the number of bytes returned varies with each + * <code>Token</code> encoded. After the encoding is finished the Vector + * in converted to a byte[]. + * + * @param t The <code>Token</code> to be encoded + * @return An equivalent Pocket Excel byte[] + */ + public byte[] getByte(Token t) throws IOException { + + Vector tmpByteArray = null; // we use this cause we don't know till after + // the encoding takes place how big the byte [] will be + + if(t.getTokenType()==ParseToken.TOKEN_OPERATOR) { + tmpByteArray = OperatorEncoder(t); + } else if (t.getTokenType()==ParseToken.TOKEN_FUNCTION_VARIABLE || t.getTokenType()==ParseToken.TOKEN_FUNCTION_FIXED){ + tmpByteArray = FunctionEncoder(t); + } else { // Operands and functions + switch(t.getTokenID()) { + case TokenConstants.TREF : + tmpByteArray = CellRefEncoder(t); + break; + case TokenConstants.TAREA : + tmpByteArray = AreaRefEncoder(t); + break; + case TokenConstants.TINT : + tmpByteArray = IntEncoder(t); + break; + default : + Debug.log(Debug.ERROR, "Encoder found unrecognized Token"); + } + } + + byte cellRefArray[] = new byte[tmpByteArray.size()]; + int i = 0; + Debug.log(Debug.TRACE, "Token Encoder : "); + for(Enumeration e = tmpByteArray.elements();e.hasMoreElements();) { + Byte tmpByte = (Byte) e.nextElement(); + Debug.log(Debug.TRACE, tmpByte + " "); + cellRefArray[i] = tmpByte.byteValue(); + i++; + } + Debug.log(Debug.TRACE, ""); + return cellRefArray; + } + + /** + * An Operator Encoder. + * + * @param t <code>Token</code> to be encoded + * @return A <code>Vector</code> of pexcel <code>Byte</code> + */ + private Vector OperatorEncoder(Token t) { + + Vector tmpByteArray = new Vector(); + tmpByteArray.add(new Byte((byte)t.getTokenID())); + return tmpByteArray; + } + + + /** + * An Integer Encoder. + * + * @param t <code>Token</code> to be encoded + * @return A <code>Vector</code> of pexcel <code>Byte</code> + */ + private Vector IntEncoder(Token t) { + + Vector tmpByteArray = new Vector(); + + double cellLong = (double) Double.parseDouble(t.getValue()); + tmpByteArray.add(new Byte((byte)t.getTokenID())); + byte[] tempByte = EndianConverter.writeDouble(cellLong); + for(int byteIter=0;byteIter<tempByte.length;byteIter++) { + tmpByteArray.add(new Byte(tempByte[byteIter])); + } + return tmpByteArray; + } + + /** + * Converts a char to an int. It is zero based + * so a=0, b=1 etc. + * + * @param ch the character to be converted + * @return -1 if not a character otherwise a 0 based index + */ + private int char2int(char ch) { + if(!Character.isLetter(ch)) + return -1; + + ch = Character.toUpperCase(ch); + return ch-'A'; + } + + /** + * Identify letters + * + * @param c The character which is to be identified + * @return A boolean returning the result of the comparison + */ + private boolean isAlpha(char c) { + return(Character.isLetter(c)); + } + + /** + * Identify numbers + * + * @param c The character which is to be identified + * @return A boolean returning the result of the comparison + */ + private boolean isDigit(char c) { + return(Character.isDigit(c)); + } + + /** + * Identify letters or numbers + * + * @param c The character which is to be identified + * @return A boolean returning the result of the comparison + */ + private boolean isAlphaNum(char c) { + return(isAlpha(c) || isDigit(c)); + } + + /** + * Parses a column reference and returns it's integer equivalent. (eg. + * A=0, D=3, BA=27) + * + * @return an 0 based index to a column + */ + private int column() { + char ch = parseString.charAt(index); + String columnStr = new String(); + int col = 0; + + while(isAlpha(ch)) { + columnStr += ch; + index++; + ch = parseString.charAt(index); + } + + if(columnStr.length()==1) { + col = char2int(columnStr.charAt(0)); + } else if (columnStr.length()==2) { + col = char2int(columnStr.charAt(0)) + 1; + col = (col*26) + char2int(columnStr.charAt(1)); + } else { + Debug.log(Debug.ERROR, "Invalid Column Reference"); + } + + + return col; + } + + /** + * Parses a column reference and returns it's integer equivalent. (eg. + * A=0, D=3, BA=27) + * + * @return an 0 based index to a column + */ + private int row() { + char ch = parseString.charAt(index); + String rowStr = new String(); + int row = 0; + boolean status = true; + + do { + rowStr += ch; + index++; + if(index>=parseString.length()) { + status = false; + } else { + ch = parseString.charAt(index); + } + } while(isDigit(ch) && status); + return Integer.parseInt(rowStr)-1; // Pexcel uses a 0 based index + } + + /** + * A Cell Reference Encoder. It supports absolute and relative addressing + * but not sheetnames. + * + * @param t <code>Token</code> to be encoded + * @return A <code>Vector</code> of pexcel <code>Byte</code> + */ + private Vector CellRefEncoder(Token t) { + Vector tmpByteArray = new Vector(); + int col = 0, row = 0; + int addressing = 0xC000; + boolean colAbs = false, rowAbs = false; + + parseString = t.getValue(); + tmpByteArray.add(new Byte((byte)t.getTokenID())); + if(parseString.charAt(index)=='$') { + addressing &= 0x8000; + index++; + } + col = column(); + if(parseString.charAt(index)=='$') { + addressing &= 0x4000; + index++; + } + row = row(); // Pexcel uses a 0 based index + row |= addressing; + tmpByteArray.add(new Byte((byte)row)); + tmpByteArray.add(new Byte((byte)(row>>8))); + tmpByteArray.add(new Byte((byte)col)); + index = 0; + return tmpByteArray; + } + + /** + * A Cell Range Encoder. + * + * @param t <code>Token</code> to be encoded + * @return A <code>Vector</code> of pexcel <code>Byte</code> + */ + private Vector AreaRefEncoder(Token t) { + Vector tmpByteArray = new Vector(); + int row = 0, col1 = 0, col2 = 0; + boolean rowAbs = false, colAbs = false; + + tmpByteArray.add(new Byte((byte)t.getTokenID())); + parseString = t.getValue(); + if(parseString.charAt(index)=='$') { + colAbs = true; + index++; + } + col1 = column(); + row = row(); + row |= 0xC000; + tmpByteArray.add(new Byte((byte)row)); + tmpByteArray.add(new Byte((byte)(row>>8))); + if(parseString.charAt(index)==':') { + index++; + } else { + Debug.log(Debug.ERROR, "Invalid Cell Range, could not find :"); + } + col2 = column(); + row = row(); + row |= 0xC000; + tmpByteArray.add(new Byte((byte)row)); + tmpByteArray.add(new Byte((byte)(row>>8))); + + tmpByteArray.add(new Byte((byte)col1)); + tmpByteArray.add(new Byte((byte)col2)); + index = 0; + return tmpByteArray; + } + + /** + * A Function Encoder. + * + * @param t <code>Token</code> to be encoded + * @return A <code>Vector</code> of pexcel <code>Byte</code> + */ + private Vector FunctionEncoder(Token t) { + Vector tmpByteArray = new Vector(); + + int id = t.getTokenID(); + if(t.getTokenType()==ParseToken.TOKEN_FUNCTION_VARIABLE) { + tmpByteArray.add(new Byte((byte)TokenConstants.TFUNCVAR)); + tmpByteArray.add(new Byte((byte)t.getNumArgs())); + } else { + tmpByteArray.add(new Byte((byte)TokenConstants.TFUNC)); + } + + tmpByteArray.add(new Byte((byte)id)); + tmpByteArray.add(new Byte((byte)(id>>8))); + return tmpByteArray; + } + + +} diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenFactory.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenFactory.java new file mode 100644 index 000000000000..cc26addea904 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenFactory.java @@ -0,0 +1,140 @@ +/************************************************************************ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2001 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; + +import java.io.*; +import java.util.Vector; +import java.util.Enumeration; + +import org.openoffice.xmerge.util.Debug; + +/** + * This is the Factory class responsible for creating a <code>Token</code>. + * It has three methods for returning three different types of Tokens + * (Operator, Operand and Function). + * This utility class is used by either the <code>FormulaParser</code> or the + * <code>FormulaDecoder</code>. + */ +public class TokenFactory { + + private OperatorLookup operatorLookup; + private OperandLookup operandLookup; + private FunctionLookup fl; + + /** + * Default Constructor + */ + public TokenFactory() { + operatorLookup = new OperatorLookup(); + operandLookup = new OperandLookup(); + fl = new FunctionLookup(); + } + + /** + * The Factory method for creating function Tokens + * + * @return The created <code>Token</code> + */ + public Token getFunctionToken(String s, int args) { + Token t = null; + // We will have to fix this later to include fixed function tokens + // Also will need to handle errors where functions names are incorrect??? + try { + t = new Token(s, ParseToken.TOKEN_FUNCTION_VARIABLE, fl.getIDFromString(s), args); + } catch (UnsupportedFunctionException eFn) { + + Debug.log(Debug.ERROR, eFn.getMessage()); + } + return t; + } + + /** + * The Factory method for creating operator Tokens + * + * @return The created <code>Token</code> + */ + public Token getOperatorToken(String s, int args) { + + Token t = null; + + if(args==1) { + if(s.equals("+")) { + t = new Token(s, ParseToken.TOKEN_OPERATOR, operatorLookup.getIDFromString("UNARY_PLUS"), args); + } else if (s.equals("-")) { + t = new Token(s, ParseToken.TOKEN_OPERATOR, operatorLookup.getIDFromString("UNARY_MINUS"), args); + } else { + t = new Token(s, ParseToken.TOKEN_OPERATOR, operatorLookup.getIDFromString(s), args); + } + } else { + t = new Token(s, ParseToken.TOKEN_OPERATOR, operatorLookup.getIDFromString(s), args); + } + return t; + } + + /** + * The Factory method for creating Operand Tokens + * + * @return The created <code>Token</code> + */ + public Token getOperandToken(String s, String type) { + Token t; + + t = new Token(s, ParseToken.TOKEN_OPERAND, operandLookup.getIDFromString(type), 0); + + return t; + } +} diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/UnsupportedFunctionException.java b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/UnsupportedFunctionException.java new file mode 100644 index 000000000000..4977ea395626 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/UnsupportedFunctionException.java @@ -0,0 +1,71 @@ +/************************************************************************ + * + * UnsupportedFunctionException.java + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2001 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; + +/* + * Exception thrown when a function specified in a calc formula has no equivalent in Pocket Excel + * + * @author : Mike Hayes + */ + +public class UnsupportedFunctionException extends Exception { + UnsupportedFunctionException(String message) { + super(message); + } +} diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/build.xml b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/build.xml new file mode 100644 index 000000000000..ec303abb5cce --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/build.xml @@ -0,0 +1,168 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + # The Contents of this file are made available subject to the terms of + # either of the following licenses + # + # - GNU Lesser General Public License Version 2.1 + # - Sun Industry Standards Source License Version 1.1 + # + # Sun Microsystems Inc., October, 2000 + # + # GNU Lesser General Public License Version 2.1 + # ============================================= + # Copyright 2000 by Sun Microsystems, Inc. + # 901 San Antonio Road, Palo Alto, CA 94303, USA + # + # This library is free software; you can redistribute it and/or + # modify it under the terms of the GNU Lesser General Public + # License version 2.1, as published by the Free Software Foundation. + # + # This library is distributed in the hope that it will be useful, + # but WITHOUT ANY WARRANTY; without even the implied warranty of + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + # Lesser General Public License for more details. + # + # You should have received a copy of the GNU Lesser General Public + # License along with this library; if not, write to the Free Software + # Foundation, Inc., 59 Temple Place, Suite 330, Boston, + # MA 02111-1307 USA + # + # + # Sun Industry Standards Source License Version 1.1 + # ================================================= + # The contents of this file are subject to the Sun Industry Standards + # Source License Version 1.1 (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.openoffice.org/license.html. + # + # Software provided under this License is provided on an "AS IS" basis, + # WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + # WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + # MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + # See the License for the specific provisions governing your rights and + # obligations concerning the Software. + # + # The Initial Developer of the Original Code is: Sun Microsystems, Inc. + # + # Copyright: 2000 by Sun Microsystems, Inc. + # + # All Rights Reserved. + # + # Contributor(s): _______________________________________ + # + # + --> +<project name="xmrg_jooxcxspr_formula" default="main" basedir="."> + + <!-- ================================================================= --> + <!-- settings --> + <!-- ================================================================= --> + + <!-- project prefix, used for targets and build.lst --> + <property name="prj.prefix" value="xmrg"/> + + <!-- name of this sub target used in recursive builds --> + <property name="target" value="xmrg_jooxcxspr_formula"/> + + <!-- relative path to project directory --> + <property name="prj" value="../../../../../../../../../.."/> + + <!-- start of java source code package structure --> + <property name="java.dir" value="${prj}/java"/> + + <!-- path component for current java package --> + <property name="package" + value="org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula"/> + + <!-- define how to handle CLASSPATH environment --> + <property name="build.sysclasspath" value="ignore"/> + + <!-- classpath settings for javac tasks --> + <path id="classpath"> + <pathelement location="${build.class}"/> + <pathelement location="${solar.jar}/parser.jar"/> + <pathelement location="${solar.jar}/jaxp.jar"/> + </path> + + <!-- set wether we want to compile with or without deprecation --> + <property name="deprecation" value="on"/> + + <!-- ================================================================= --> + <!-- solar build environment targets --> + <!-- ================================================================= --> + + <target name="build_dir" unless="build.dir"> + <property name="build.dir" value="${out}"/> + </target> + + <target name="solar" depends="build_dir" if="solar.update"> + <property name="solar.properties" + value="${solar.bin}/solar.properties"/> + </target> + + <target name="init" depends="solar"> + <property name="build.compiler" value="classic"/> + <property file="${solar.properties}"/> + <property file="${build.dir}/class/solar.properties"/> + </target> + + <target name="info"> + <echo message="--------------------"/> + <echo message="${target}"/> + <echo message="--------------------"/> + </target> + + + <!-- ================================================================= --> + <!-- custom targets --> + <!-- ================================================================= --> + + <!-- the main target, called in recursive builds --> + <target name="main" depends="info,prepare,compile"/> + + <!-- prepare output directories --> + <target name="prepare" depends="init" if="build.class"> + <mkdir dir="${build.dir}"/> + <mkdir dir="${build.class}"/> + </target> + + <!-- compile java sources in ${package} --> + <target name="compile" depends="prepare" if="build.class"> + <javac srcdir="${java.dir}" + destdir="${build.class}" + debug="${debug}" + deprecation="${deprecation}" + optimize="${optimize}"> + <classpath refid="classpath"/> + <include name="${package}/FormulaCompiler.java"/> + <include name="${package}/FormulaHelper.java"/> + <include name="${package}/FormulaParser.java"/> + <include name="${package}/FormulaParsingException.java"/> + <include name="${package}/FunctionLookup.java"/> + <include name="${package}/OperandLookup.java"/> + <include name="${package}/Operatorookup.java"/> + <include name="${package}/ParseToken.java"/> + <include name="${package}/PrecedenceTable.java"/> + <include name="${package}/SymbolLookup.java"/> + <include name="${package}/Token.java"/> + <include name="${package}/TokenConstants.java"/> + <include name="${package}/TokenDecoder.java"/> + <include name="${package}/TokenEncoder.java"/> + <include name="${package}/TokenFactory.java"/> + <include name="${package}/UnsupportedFunctionException.java"/> + </javac> + </target> + + <!-- clean up --> + <target name="clean" depends="prepare"> + <delete includeEmptyDirs="true"> + <fileset dir="${build.class}"> + <patternset> + <include name="${package}/*.class"/> + </patternset> + </fileset> + </delete> + </target> + +</project> + diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/makefile.mk b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/makefile.mk new file mode 100644 index 000000000000..094ad28f7360 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/makefile.mk @@ -0,0 +1,59 @@ +#*************************************************************************** +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (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.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +#*************************************************************************** + +TARGET=xmrg_jooxcxs_pexcel +PRJ=../../../../../../../../.. + +.INCLUDE : ant.mk +ALLTAR: ANTBUILD diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/package.html b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/package.html new file mode 100644 index 000000000000..73ace0e19743 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/package.html @@ -0,0 +1,67 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> +<head> + <!-- + # The Contents of this file are made available subject to the terms of + # either of the following licenses + # + # - GNU Lesser General Public License Version 2.1 + # - Sun Industry Standards Source License Version 1.1 + # + # Sun Microsystems Inc., October, 2000 + # + # GNU Lesser General Public License Version 2.1 + # ============================================= + # Copyright 2000 by Sun Microsystems, Inc. + # 901 San Antonio Road, Palo Alto, CA 94303, USA + # + # This library is free software; you can redistribute it and/or + # modify it under the terms of the GNU Lesser General Public + # License version 2.1, as published by the Free Software Foundation. + # + # This library is distributed in the hope that it will be useful, + # but WITHOUT ANY WARRANTY; without even the implied warranty of + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + # Lesser General Public License for more details. + # + # You should have received a copy of the GNU Lesser General Public + # License along with this library; if not, write to the Free Software + # Foundation, Inc., 59 Temple Place, Suite 330, Boston, + # MA 02111-1307 USA + # + # + # Sun Industry Standards Source License Version 1.1 + # ================================================= + # The contents of this file are subject to the Sun Industry Standards + # Source License Version 1.1 (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.openoffice.org/license.html. + # + # Software provided under this License is provided on an "AS IS" basis, + # WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + # WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + # MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + # See the License for the specific provisions governing your rights and + # obligations concerning the Software. + # + # The Initial Developer of the Original Code is: Sun Microsystems, Inc. + # + # Copyright: 2000 by Sun Microsystems, Inc. + # + # All Rights Reserved. + # + # Contributor(s): _______________________________________ + # + # + --> + + <title>org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula package</title> + +</head> + <body bgcolor="white"> + +<p> This package contains the classes necessary for converting pexcel formula +to and from StarCalc Formula.</p> + +</body> +</html> diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/package.html b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/package.html index 7f13267a1d7c..de93f03c361c 100644 --- a/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/package.html +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/package.html @@ -55,7 +55,7 @@ # --> - <title>org.openoffice.xmerge.converter.xml.sxc.pexcel.Records package</title> + <title>org.openoffice.xmerge.converter.xml.sxc.pexcel.records package</title> </head> <body bgcolor="white"> diff --git a/xmerge/util/build.xml b/xmerge/util/build.xml index a27c82d08aa6..511d72bdd9e1 100644 --- a/xmerge/util/build.xml +++ b/xmerge/util/build.xml @@ -184,7 +184,8 @@ <jar jarfile="${build.class}/${jarname5}.jar" basedir="${build.class}"> <include name="${pexcel}/**"/> - <include name="${pexcel}/Records/**"/> + <include name="${pexcel}/records/**"/> + <include name="${pexcel}/records/formula/**"/> <metainf dir="${java.dir}/${pexcel}" includes="converter.xml"/> </jar> </target> |