dist
+build
scripts
*.el
*.ipr
Glen Stampoultzis glens at apache.org
- This build was tested with and 1.5.3 although it will probably work with
+ This build was tested with ant 1.5.3 although it will probably work with
other versions. The following jar files should be installed
into the ant lib directory:
junit(3.8+) http://www.ibiblio.org/maven/junit/jars/
xerces http://www.ibiblio.org/maven/xerces/jars/
jdepend http://www.ibiblio.org/maven/jdepend/jars/
+ xalan http://www.ibiblio.org/maven/xalan/jars/
The ant jar "optional.jar" should also be available otherwise the
build will fail.
<property name="changelog.file" value="${build.site}/changelog.html"/>
<property name="dist.dir" value="build/dist"/>
<property name="jar.name" value="poi"/>
- <property name="version.id" value="2.0-pre1"/>
+ <property name="version.id" value="2.0-pre3"/>
<property name="halt.on.test.failure" value="true"/>
<path id="main.classpath">
<target name="check-jars">
<condition property="jars.present">
+ <or>
<and>
<available file="${main.jar1.dir}"/>
<available file="${main.jar2.dir}"/>
<available file="${contrib.jar1.dir}"/>
<available file="${contrib.jar2.dir}"/>
- <available file="${contrib.jar3.dir}"/>
- <available file="${junit.jar1.dir}"/>
+ <available file="${contrib.jar3.dir}"/>
+ <available file="${junit.jar1.dir}"/>
</and>
+ <isset property="disconnected"/>
+ </or>
</condition>
</target>
</uptodate>
</target>
- <target name="test-main" depends="compile-main,-test-main-check" unless="main.test.notRequired">
- <junit printsummary="yes" showoutput="true" filtertrace="no" fork="no"
- haltonfailure="${halt.on.test.failure}" failureproperty="main.test.failed">
- <classpath>
+ <path id="test.classpath">
<path refid="main.classpath"/>
<pathelement location="${main.output.dir}"/>
<pathelement location="${main.output.test.dir}"/>
<pathelement location="${junit.jar1.dir}"/>
- </classpath>
+ </path>
+ <target name="test-main" depends="compile-main,-test-main-check" unless="main.test.notRequired">
+ <junit printsummary="yes" showoutput="true" filtertrace="no" fork="no"
+ haltonfailure="${halt.on.test.failure}" failureproperty="main.test.failed">
+ <classpath refid="test.classpath"/>
<sysproperty key="HSSF.testdata.path" value="${main.src.test}/org/apache/poi/hssf/data"/>
<sysproperty key="HPSF.testdata.path" value="${main.src.test}/org/apache/poi/hpsf/data"/>
<formatter type="plain"/>
<antcall target="-test-main-write-testfile"/>
</target>
- <target name="single-test" depends="compile-main">
- <junit printsummary="no" showoutput="true" filtertrace="no" fork="no" haltonfailure="${halt.on.test.failure}" failureproperty="main.test.failed" >
- <classpath>
- <path refid="main.classpath"/>
- <pathelement location="${main.output.dir}"/>
- <pathelement location="${main.output.test.dir}"/>
- <pathelement location="${junit.jar1.dir}"/>
- </classpath>
+ <target name="single-test" depends="-test-property-check,compile-main">
+ <junit printsummary="no" showoutput="true" filtertrace="no" haltonfailure="${halt.on.test.failure}" failureproperty="main.test.failed" >
+ <classpath refid="test.classpath"/>
<sysproperty key="HSSF.testdata.path" value="${main.src.test}/org/apache/poi/hssf/data"/>
<sysproperty key="HPSF.testdata.path" value="${main.src.test}/org/apache/poi/hpsf/data"/>
<formatter type="plain" usefile="no"/>
</junit>
</target>
+ <target name="debug-test" depends="-test-property-check,compile-main">
+ <junit printsummary="no" showoutput="true" filtertrace="no" fork="yes" haltonfailure="${halt.on.test.failure}" failureproperty="main.test.failed" >
+ <jvmarg value="-Xdebug"/>
+ <jvmarg value="-Xrunjdwp:transport=dt_socket,address=5001,server=y,suspend=y"/>
+ <sysproperty key="java.compiler" value="NONE"/>
+ <classpath refid="test.classpath"/>
+ <sysproperty key="HSSF.testdata.path" value="${main.src.test}/org/apache/poi/hssf/data"/>
+ <sysproperty key="HPSF.testdata.path" value="${main.src.test}/org/apache/poi/hpsf/data"/>
+ <formatter type="plain" usefile="no"/>
+ <test name="${testcase}" />
+ </junit>
+ </target>
+
+ <target name="-test-property-check" unless="testcase">
+ <echo message="Please use -Dtestcase=org.your.testcase to run a single test"/>
+ <fail/>
+ </target>
+
<target name="-test-main-write-testfile" unless="main.test.failed">
<echo file="${main.testokfile}" append="false" message="testok"/>
</target>
</condition>
</target>
+ <target name="-cvschangelog" unless="disconnected">
+ <cvschangelog destfile="${changelog.file}" daysinpast="30"/>
+
+ <style in="${changelog.file}"
+ out="${build.site.src}/src/documentation/content/changelog.html"
+ style="changelog.xsl">
+ <param name="title" expression="POI Change Log"/>
+ <param name="module" expression="jakarta-poi"/>
+ <param name="cvsweb" expression="http://cvs.apache.org/viewcvs/"/>
+ </style>
+ </target>
+
<target name="reports" depends="-check-reports" unless="reports.notRequired"
description="Creates junit,jdepend and javadoc reports">
<antcall target="test">
out="${jdepend.report.out.dir}/index.html"
style="jdepend.xsl"/>
- <cvschangelog destfile="${changelog.file}" daysinpast="30"/>
-
- <style in="${changelog.file}"
- out="${build.site.src}/src/documentation/content/changelog.html"
- style="changelog.xsl">
- <param name="title" expression="POI Change Log"/>
- <param name="module" expression="jakarta-poi"/>
- <param name="cvsweb" expression="http://cvs.apache.org/viewcvs/"/>
- </style>
+ <antcall target="-cvschangelog"/>
<javadoc
destdir="${apidocs.report.dir}"
<tar destfile="${dist.dir}/${jar.name}-bin-${version.id}-${DSTAMP}.tar.gz" compression="gzip">
<tarfileset dir="${build.site}" prefix="docs"/>
- <tarfileset file="${dist.dir}/${jar.name}-${version.id}.jar"/>
- <tarfileset file="${dist.dir}/${jar.name}-contrib-${version.id}.jar"/>
- <tarfileset file="${dist.dir}/${jar.name}-scratchpad-${version.id}.jar"/>
+ <tarfileset file="${dist.dir}/${jar.name}-${version.id}-${DSTAMP}.jar"/>
+ <tarfileset file="${dist.dir}/${jar.name}-contrib-${version.id}-${DSTAMP}.jar"/>
+ <tarfileset file="${dist.dir}/${jar.name}-scratchpad-${version.id}-${DSTAMP}.jar"/>
<tarfileset dir="legal" prefix="legal"/>
</tar>
<target name="clean-dist" depends="clean,dist" description="Cleans the build directory then creates a distribution"/>
- <target name="gump" depends="jar"/>
+ <target name="gump" depends="jar,test"/>
</project>
--- /dev/null
+<!-- ===================================================================
+
+ Apache Cocoon Documentation Book DTD (Version 1.0)
+
+PURPOSE:
+This DTD defines the */book.xml documentation configuration files.
+
+TYPICAL INVOCATION:
+
+ <!DOCTYPE book PUBLIC
+ "-//APACHE//DTD Cocoon Documentation Book Vx.yz//EN"
+ "book-cocoon-vxyz.dtd">
+
+ where
+
+ x := major version
+ y := minor version
+ z := status identifier (optional)
+
+NOTES:
+We need to replace this DTD with the proper one.
+We are only using this DTD to enable validation during "build docs"
+because every XML instance must declare its ruleset.
+
+This initial minimal DTD has been reverse-engineered from the structure
+of the current documents, e.g.
+ documentation/xdocs/book.xml
+
+AUTHORS:
+ David Crossley <crossley@apache.org>
+
+FIXME:
+ - find the proper DTD for book.xml
+
+CHANGE HISTORY:
+ 20011031 Initial version. (DC)
+
+COPYRIGHT:
+ Copyright (c) @year@ The Apache Software Foundation.
+
+ Permission to copy in any form is granted provided this notice is
+ included in all copies. Permission to redistribute is granted
+ provided this file is distributed untouched in all its parts and
+ included files.
+
+==================================================================== -->
+
+<!ELEMENT book (menu+)>
+<!ELEMENT menu (menu-item|external)*>
+<!ELEMENT menu-item EMPTY>
+<!ELEMENT external EMPTY>
+<!ATTLIST book software CDATA #REQUIRED
+ title CDATA #REQUIRED
+ copyright CDATA #REQUIRED
+ xmlns:xlink CDATA #IMPLIED
+>
+<!ATTLIST menu label CDATA #REQUIRED
+>
+<!ATTLIST menu-item label CDATA #REQUIRED
+ href CDATA #REQUIRED
+ type (visible|hidden) "visible"
+>
+<!ATTLIST external label CDATA #REQUIRED
+ href CDATA #REQUIRED
+ type (visible|hidden) "visible"
+>
+
+<!-- =============================================================== -->
+<!-- End of DTD -->
+<!-- =============================================================== -->
--- /dev/null
+<!-- ===================================================================
+
+ Apache Changes DTD (Version 1.1)
+
+PURPOSE:
+ This DTD was developed to create a simple yet powerful document
+ type for software development changes for use with the Apache projects.
+ It is an XML-compliant DTD and it's maintained by the Apache XML
+ project.
+
+TYPICAL INVOCATION:
+
+ <!DOCTYPE document PUBLIC
+ "-//APACHE//DTD Changes Vx.y//EN"
+ "changes-vxy.dtd">
+
+ where
+
+ x := major version
+ y := minor version
+
+NOTES:
+ It is important, expecially in open developped software projects, to keep
+ track of software changes both to give users indications of bugs that might
+ have been resolved, as well, and not less important, to provide credits
+ for the support given to the project. It is considered vital to provide
+ adequate payback using recognition and credits to let users and developers
+ feel part of the community, thus increasing development power.
+
+AUTHORS:
+ Stefano Mazzocchi <stefano@apache.org>
+
+FIXME:
+
+CHANGE HISTORY:
+[Version 1.0]
+ 19991129 Initial version. (SM)
+ 20000316 Added bugfixing attribute. (SM)
+[Version 1.1]
+ 20011212 Used public identifiers for external entities (SM)
+
+COPYRIGHT:
+ Copyright (c) @year@ The Apache Software Foundation.
+
+ Permission to copy in any form is granted provided this notice is
+ included in all copies. Permission to redistribute is granted
+ provided this file is distributed untouched in all its parts and
+ included files.
+
+==================================================================== -->
+
+<!-- =============================================================== -->
+<!-- Include the Documentation DTD -->
+<!-- =============================================================== -->
+
+<!ENTITY % document PUBLIC
+ "-//APACHE//DTD Documentation V1.1//EN"
+ "document-v11.dtd">
+%document;
+
+<!-- =============================================================== -->
+<!-- Common entities -->
+<!-- =============================================================== -->
+
+<!ENTITY % types "add|remove|update|fix">
+
+<!-- =============================================================== -->
+<!-- Document Type Definition -->
+<!-- =============================================================== -->
+
+<!ELEMENT changes (devs, release*)>
+<!ATTLIST changes %common.att;
+ %title.att;>
+
+ <!ELEMENT devs (person+)>
+ <!ATTLIST devs %common.att;>
+
+ <!ELEMENT release (action+)>
+ <!ATTLIST release %common.att;
+ version CDATA #REQUIRED
+ date CDATA #REQUIRED>
+
+ <!ELEMENT action (%content.mix;)*>
+ <!ATTLIST action %common.att;
+ dev IDREF #REQUIRED
+ type (%types;) #IMPLIED
+ due-to CDATA #IMPLIED
+ due-to-email CDATA #IMPLIED
+ fixes-bug CDATA #IMPLIED>
+
+<!-- =============================================================== -->
+<!-- End of DTD -->
+<!-- =============================================================== -->
--- /dev/null
+<!-- ===================================================================
+
+ Apache Documentation DTD (Version 1.1)
+
+PURPOSE:
+ This DTD was developed to create a simple yet powerful document
+ type for software documentation for use with the Apache projects.
+ It is an XML-compliant DTD and it's maintained by the Apache XML
+ project.
+
+TYPICAL INVOCATION:
+
+ <!DOCTYPE document PUBLIC
+ "-//APACHE//DTD Documentation Vx.y//EN"
+ "document-vxy.dtd">
+
+ where
+
+ x := major version
+ y := minor version
+
+NOTES:
+ Many of the design patterns used in this DTD were take from the
+ W3C XML Specification DTD edited by Eve Maler <elm@arbortext.com>.
+
+ Where possible, great care has been used to reuse HTML tag
+ names to reduce learning efforts and to allow HTML editors to be
+ used for complex authorings like tables and lists.
+
+EXTENSIBILITY:
+ This DTD includes several empty placeholders that can be used to
+ extend it. These placeholders are implemented with empty entities. Here
+ is the list of those empty entities and what they are used for:
+
+ - local.inline: this entity should contain extended definitions of
+ elements that can be used 'inline', or directly inside
+ the content. An example for this entity could be
+
+ <!ENTITY % local.inline "|citation">
+
+ - local.blocks: this entity should contain extended definitions of
+ elements that behave as 'blocks', thus can be visually
+ rendered as areas on the canvas. An example for this
+ entity could be:
+
+ <!ENTITY % local.blocks "|poem">
+
+ - local.sections: this entity should contain extended definitions of
+ elements that behave as 'sections', thus can be considered
+ containers of block-level elements. An example for
+ this entity could be:
+
+ <!ENTITY % local.sections "|chapter">
+
+ - local.headers: this entity should contain extended definitions of
+ elements that behave as parts of the document header.
+ An example for this header could be:
+
+ <!ENTITY % local.headers ", notes?">
+
+ - local.footers: this entity should contain extended definitions of
+ elements that behave as parts of the document footer.
+ An example for this header could be:
+
+ <!ENTITY % local.footers ", annotations*">
+
+
+AUTHORS:
+ Stefano Mazzocchi <stefano@apache.org>
+ Steven Noels <stevenn@outerthought.org>
+
+FIXME:
+ - should "form" tags be included?
+
+CHANGE HISTORY:
+[Version 1.0]
+ 19991121 Initial version. (SM)
+ 19991123 Replaced "res" with more standard "strong" for emphasis. (SM)
+ 19991124 Added "fork" element for window forking behavior. (SM)
+ 19991124 Added "img-inline" element to separate from "img". (SM)
+ 19991129 Removed "affiliation" from "author". (SM)
+ 19991129 Made "author" empty and moved "name|email" as attributes. (SM)
+ 19991215 Simplified table section. (SM)
+ 19991215 Changed "img-block" in more friendly "figure". (SM)
+ 20000125 Added the "icon" image. (SM)
+ 20000126 Allowed "anchor" in all levels. (SM)
+ 20000404 Removed the "role" attribute from common-xxx.att. (SM)
+ 20000815 Allowed "code" inside "strong" and "em". (SM)
+[Version 1.1]
+ 20011212 Used public identifiers for external entities. (SM)
+ 20011212 Removed xlink attributes since not used. (SM)
+ 20011212 Removed "connect" since not required at this level. (SM)
+ 20011218 Added "warning" as a block level object. (SM)
+ 20011218 Removed explicitly numbered sections ("s1|s2|s3|s4"). (SM)
+ 20011218 Added "section" element. (SM)
+ 20011218 Allowed "body" to have blocks without a section. (SM)
+ 20011218 Removed "sl" since not really different from "ul". (SM)
+ 20020214 Moved empty placeholder entity declarations up front (SNS)
+ 20020214 Corrected content model of content.mix parameter entity (SNS)
+
+COPYRIGHT:
+ Copyright (c) @year@ The Apache Software Foundation.
+
+ Permission to copy in any form is granted provided this notice is
+ included in all copies. Permission to redistribute is granted
+ provided this file is distributed untouched in all its parts and
+ included files.
+
+==================================================================== -->
+
+
+
+
+<!-- =============================================================== -->
+<!-- Common character entities (included from external file) -->
+<!-- =============================================================== -->
+
+<!ENTITY % ISOlat1 PUBLIC
+ "ISO 8879:1986//ENTITIES Added Latin 1//EN//XML"
+ "ISOlat1.pen">
+%ISOlat1;
+
+<!ENTITY % ISOpub PUBLIC
+ "ISO 8879:1986//ENTITIES Publishing//EN//XML"
+ "ISOpub.pen">
+%ISOpub;
+
+<!ENTITY % ISOtech PUBLIC
+ "ISO 8879:1986//ENTITIES General Technical//EN//XML"
+ "ISOtech.pen">
+%ISOtech;
+
+<!ENTITY % ISOnum PUBLIC
+ "ISO 8879:1986//ENTITIES Numeric and Special Graphic//EN//XML"
+ "ISOnum.pen">
+%ISOnum;
+
+<!ENTITY % ISOdia PUBLIC
+ "ISO 8879:1986//ENTITIES Diacritical Marks//EN//XML"
+ "ISOdia.pen">
+%ISOdia;
+
+<!-- =============================================================== -->
+<!-- Useful entities for increased DTD readability -->
+<!-- =============================================================== -->
+
+<!ENTITY % text "#PCDATA">
+
+<!-- Entities referred to later on are defined up front -->
+
+<!ENTITY % markup "strong|em|code|sub|sup">
+<!ENTITY % special-inline "br|img|icon">
+<!ENTITY % links "link|jump|fork">
+<!ENTITY % paragraphs "p|source|note|warning|fixme">
+<!ENTITY % tables "table">
+<!ENTITY % lists "ol|ul|dl">
+<!ENTITY % special-blocks "figure|anchor">
+
+
+<!-- =============================================================== -->
+<!-- Entities for general XML compliance -->
+<!-- =============================================================== -->
+
+<!-- Common attributes
+ Every element has an ID attribute (sometimes required,
+ but usually optional) for links. %common.att;
+ is for common attributes where the ID is optional, and
+ %common-idreq.att; is for common attributes where the
+ ID is required.
+-->
+<!ENTITY % common.att
+ 'id ID #IMPLIED
+ xml:lang NMTOKEN #IMPLIED'>
+<!ENTITY % common-idreq.att
+ 'id ID #REQUIRED
+ xml:lang NMTOKEN #IMPLIED'>
+
+
+<!-- xml:space attribute ===============================================
+ Indicates that the element contains white space
+ that the formatter or other application should retain,
+ as appropriate to its function.
+==================================================================== -->
+<!ENTITY % xmlspace.att
+ 'xml:space (default|preserve) #FIXED "preserve"'>
+
+
+<!-- def attribute =====================================================
+ Points to the element where the relevant definition can be
+ found, using the IDREF mechanism. %def.att; is for optional
+ def attributes, and %def-req.att; is for required def
+ attributes.
+==================================================================== -->
+<!ENTITY % def.att
+ 'def IDREF #IMPLIED'>
+<!ENTITY % def-req.att
+ 'def IDREF #REQUIRED'>
+
+
+<!-- ref attribute =====================================================
+ Points to the element where more information can be found,
+ using the IDREF mechanism. %ref.att; is for optional
+ ref attributes, and %ref-req.att; is for required ref
+ attributes.
+================================================================== -->
+<!ENTITY % ref.att
+ 'ref IDREF #IMPLIED'>
+<!ENTITY % ref-req.att
+ 'ref IDREF #REQUIRED'>
+
+
+<!-- =============================================================== -->
+<!-- Entities for general usage -->
+<!-- =============================================================== -->
+
+
+<!-- Key attribute =====================================================
+ Optionally provides a sorting or indexing key, for cases when
+ the element content is inappropriate for this purpose.
+==================================================================== -->
+<!ENTITY % key.att
+ 'key CDATA #IMPLIED'>
+
+
+
+<!-- Title attributes ==================================================
+ Indicates that the element requires to have a title attribute.
+==================================================================== -->
+<!ENTITY % title.att
+ 'title CDATA #REQUIRED'>
+
+
+
+<!-- Name attributes ==================================================
+ Indicates that the element requires to have a name attribute.
+==================================================================== -->
+<!ENTITY % name.att
+ 'name CDATA #REQUIRED'>
+
+
+
+<!-- Email attributes ==================================================
+ Indicates that the element requires to have an email attribute.
+==================================================================== -->
+<!ENTITY % email.att
+ 'email CDATA #REQUIRED'>
+
+
+<!-- Link attributes ===================================================
+ Indicates that the element requires to have hyperlink attributes.
+==================================================================== -->
+
+<!ENTITY % link.att
+ 'href CDATA #IMPLIED
+ role CDATA #IMPLIED
+ title CDATA #IMPLIED '>
+
+
+
+<!-- =============================================================== -->
+<!-- General definitions -->
+<!-- =============================================================== -->
+
+<!-- A person is a general human entity -->
+<!ELEMENT person EMPTY>
+<!ATTLIST person %common.att;
+ %name.att;
+ %email.att;>
+
+
+
+<!-- =============================================================== -->
+<!-- Content definitions -->
+<!-- =============================================================== -->
+
+<!ENTITY % local.inline "">
+
+<!ENTITY % link-content.mix "%text;|%markup;|%special-inline; %local.inline;">
+
+<!ENTITY % content.mix "%link-content.mix;|%links;">
+
+ <!-- ==================================================== -->
+ <!-- Phrase Markup -->
+ <!-- ==================================================== -->
+
+ <!-- Strong (typically bold) -->
+ <!ELEMENT strong (%text;|code)*>
+ <!ATTLIST strong %common.att;>
+
+ <!-- Emphasis (typically italic) -->
+ <!ELEMENT em (%text;|code)*>
+ <!ATTLIST em %common.att;>
+
+ <!-- Code (typically monospaced) -->
+ <!ELEMENT code (%text;)>
+ <!ATTLIST code %common.att;>
+
+ <!-- Superscript (typically smaller and higher) -->
+ <!ELEMENT sup (%text;)>
+ <!ATTLIST sup %common.att;>
+
+ <!-- Subscript (typically smaller and lower) -->
+ <!ELEMENT sub (%text;)>
+ <!ATTLIST sub %common.att;>
+
+ <!-- ==================================================== -->
+ <!-- Hypertextual Links -->
+ <!-- ==================================================== -->
+
+ <!-- hyperlink (equivalent of <a ...>) -->
+ <!ELEMENT link (%link-content.mix;)*>
+ <!ATTLIST link %common.att;
+ %link.att;>
+
+ <!-- windows-replacing link (equivalent of <a ... target="_top">) -->
+ <!ELEMENT jump (%link-content.mix;)*>
+ <!ATTLIST jump %common.att;
+ %link.att;>
+
+ <!-- window-forking link (equivalent of <a ... target="_new">) -->
+ <!ELEMENT fork (%link-content.mix;)*>
+ <!ATTLIST fork %common.att;
+ %link.att;>
+
+ <!-- ==================================================== -->
+ <!-- Specials -->
+ <!-- ==================================================== -->
+
+ <!-- Breakline Object (typically forces line break) -->
+ <!ELEMENT br EMPTY>
+ <!ATTLIST br %common.att;>
+
+ <!-- Image Object (typically an inlined image) -->
+ <!ELEMENT img EMPTY>
+ <!ATTLIST img src CDATA #REQUIRED
+ alt CDATA #REQUIRED
+ height CDATA #IMPLIED
+ width CDATA #IMPLIED
+ usemap CDATA #IMPLIED
+ ismap (ismap) #IMPLIED
+ %common.att;>
+
+ <!-- Image Icon (typically an inlined image placed as graphical item) -->
+ <!ELEMENT icon EMPTY>
+ <!ATTLIST icon src CDATA #REQUIRED
+ alt CDATA #REQUIRED
+ height CDATA #IMPLIED
+ width CDATA #IMPLIED
+ %common.att;>
+
+
+<!-- =============================================================== -->
+<!-- Blocks definitions -->
+<!-- =============================================================== -->
+
+<!ENTITY % local.blocks "">
+
+<!ENTITY % blocks "%paragraphs;|%tables;|%lists;|%special-blocks; %local.blocks;">
+
+ <!-- ==================================================== -->
+ <!-- Paragraphs -->
+ <!-- ==================================================== -->
+
+ <!-- Text Paragraph (normally vertically space delimited) -->
+ <!ELEMENT p (%content.mix;)*>
+ <!ATTLIST p %common.att;>
+
+ <!-- Source Paragraph (normally space is preserved) -->
+ <!ELEMENT source (%content.mix;)*>
+ <!ATTLIST source %common.att;
+ %xmlspace.att;>
+
+ <!-- Note Paragraph (normally shown encapsulated) -->
+ <!ELEMENT note (%content.mix;)*>
+ <!ATTLIST note %common.att;>
+
+ <!-- Warning Paragraph (normally shown with eye-catching colors) -->
+ <!ELEMENT warning (%content.mix;)*>
+ <!ATTLIST warning %common.att;>
+
+ <!-- Fixme Paragraph (normally not shown) -->
+ <!ELEMENT fixme (%content.mix;)*>
+ <!ATTLIST fixme author CDATA #REQUIRED
+ %common.att;>
+
+ <!-- ==================================================== -->
+ <!-- Tables -->
+ <!-- ==================================================== -->
+
+ <!-- Attributes that indicate the spanning of the table cell -->
+ <!ENTITY % cell.span
+ 'colspan CDATA "1"
+ rowspan CDATA "1"'>
+
+ <!-- Table element -->
+ <!ELEMENT table (caption?, tr+)>
+ <!ATTLIST table %common.att;>
+
+ <!-- The table title -->
+ <!ELEMENT caption (%content.mix;)*>
+ <!ATTLIST caption %common.att;>
+
+ <!-- The table row element -->
+ <!ELEMENT tr (th|td)+>
+ <!ATTLIST tr %common.att;>
+
+ <!-- The table row header element -->
+ <!ELEMENT th (%content.mix;)*>
+ <!ATTLIST th %common.att;
+ %cell.span;>
+
+ <!-- The table row description element -->
+ <!ELEMENT td (%content.mix;)*>
+ <!ATTLIST td %common.att;
+ %cell.span;>
+
+ <!-- ==================================================== -->
+ <!-- Lists -->
+ <!-- ==================================================== -->
+
+ <!-- List item -->
+ <!ELEMENT li (%content.mix;|%lists;)*>
+ <!ATTLIST li %common.att;>
+
+ <!-- Unordered list (typically bulleted) -->
+ <!ELEMENT ul (li|%lists;)+>
+ <!-- spacing attribute:
+ Use "normal" to get normal vertical spacing for items;
+ use "compact" to get less spacing. The default is dependent
+ on the stylesheet. -->
+ <!ATTLIST ul
+ %common.att;
+ spacing (normal|compact) #IMPLIED>
+
+ <!-- Ordered list (typically numbered) -->
+ <!ELEMENT ol (li|%lists;)+>
+ <!-- spacing attribute:
+ Use "normal" to get normal vertical spacing for items;
+ use "compact" to get less spacing. The default is dependent
+ on the stylesheet. -->
+ <!ATTLIST ol
+ %common.att;
+ spacing (normal|compact) #IMPLIED>
+
+ <!-- Definition list (typically two-column) -->
+ <!ELEMENT dl (dt,dd)+>
+ <!ATTLIST dl %common.att;>
+
+ <!-- Definition term -->
+ <!ELEMENT dt (%content.mix;)*>
+ <!ATTLIST dt %common.att;>
+
+ <!-- Definition description -->
+ <!ELEMENT dd (%content.mix;)*>
+ <!ATTLIST dd %common.att;>
+
+ <!-- ==================================================== -->
+ <!-- Special Blocks -->
+ <!-- ==================================================== -->
+
+ <!-- Image Block (typically a separated and centered image) -->
+ <!ELEMENT figure EMPTY>
+ <!ATTLIST figure src CDATA #REQUIRED
+ alt CDATA #REQUIRED
+ height CDATA #IMPLIED
+ width CDATA #IMPLIED
+ usemap CDATA #IMPLIED
+ ismap (ismap) #IMPLIED
+ %common.att;>
+
+ <!-- anchor point (equivalent of <a name="...">, typically not rendered) -->
+ <!ELEMENT anchor EMPTY>
+ <!ATTLIST anchor %common-idreq.att;>
+
+
+<!-- =============================================================== -->
+<!-- Document -->
+<!-- =============================================================== -->
+
+<!ELEMENT document (header?, body, footer?)>
+<!ATTLIST document %common.att;>
+
+ <!-- ==================================================== -->
+ <!-- Header -->
+ <!-- ==================================================== -->
+
+ <!ENTITY % local.headers "">
+
+ <!ELEMENT header (title, subtitle?, version?, type?, authors,
+ notice*, abstract? %local.headers;)>
+ <!ATTLIST header %common.att;>
+
+ <!ELEMENT title (%text;)>
+ <!ATTLIST title %common.att;>
+
+ <!ELEMENT subtitle (%text;)>
+ <!ATTLIST subtitle %common.att;>
+
+ <!ELEMENT version (%text;)>
+ <!ATTLIST version %common.att;>
+
+ <!ELEMENT type (%text;)>
+ <!ATTLIST type %common.att;>
+
+ <!ELEMENT authors (person+)>
+ <!ATTLIST authors %common.att;>
+
+ <!ELEMENT notice (%content.mix;)*>
+ <!ATTLIST notice %common.att;>
+
+ <!ELEMENT abstract (%content.mix;)*>
+ <!ATTLIST abstract %common.att;>
+
+ <!-- ==================================================== -->
+ <!-- Body -->
+ <!-- ==================================================== -->
+
+ <!ENTITY % local.sections "">
+
+ <!ENTITY % sections "section %local.sections;">
+
+ <!ELEMENT body (%sections;|%blocks;)+>
+ <!ATTLIST body %common.att;>
+
+ <!ELEMENT section (%sections;|%blocks;)*>
+ <!ATTLIST section %title.att; %common.att;>
+
+ <!-- ==================================================== -->
+ <!-- Footer -->
+ <!-- ==================================================== -->
+
+ <!ENTITY % local.footers "">
+
+ <!ELEMENT footer (legal %local.footers;)>
+
+ <!ELEMENT legal (%content.mix;)*>
+ <!ATTLIST legal %common.att;>
+
+<!-- =============================================================== -->
+<!-- End of DTD -->
+<!-- =============================================================== -->
--- /dev/null
+<!-- ===================================================================
+
+ Apache FAQ DTD (Version 1.1)
+
+PURPOSE:
+ This DTD was developed to create a simple yet powerful document
+ type for software FAQ's for use with the Apache projects.
+ It is an XML-compliant DTD and it's maintained by the Apache XML
+ project.
+
+TYPICAL INVOCATION:
+
+ <!DOCTYPE document PUBLIC
+ "-//APACHE//DTD FAQ Vx.y//EN"
+ "faq-vxy.dtd">
+
+ where
+
+ x := major version
+ y := minor version
+
+NOTES:
+ FAQs represent a powerful knowledge base and a very good way of solving
+ common user problems reducing messages on mail lists and reducing the effort
+ required for software installation and usage. Thid DTD want to be a common
+ format for FAQ interchange to allow FAQ-O-Matic-type workgroup services to
+ be published in other formats as well as enhancing data interchange.
+
+AUTHORS:
+ Stefano Mazzocchi <stefano@apache.org>
+
+FIXME:
+
+CHANGE HISTORY:
+ 19991129 Initial version. (SM)
+ 20011212 Used public identifiers for external entities (SM)
+
+COPYRIGHT:
+ Copyright (c) @year@ The Apache Software Foundation.
+
+ Permission to copy in any form is granted provided this notice is
+ included in all copies. Permission to redistribute is granted
+ provided this file is distributed untouched in all its parts and
+ included files.
+
+==================================================================== -->
+
+<!-- =============================================================== -->
+<!-- Include the Documentation DTD -->
+<!-- =============================================================== -->
+
+<!ENTITY % document PUBLIC
+ "-//APACHE//DTD Documentation V1.1//EN"
+ "document-v11.dtd">
+%document;
+
+<!-- =============================================================== -->
+<!-- Document Type Definition -->
+<!-- =============================================================== -->
+
+<!ELEMENT faqs (authors?, faq)+>
+<!ATTLIST faqs %common.att;
+ %title.att;>
+
+ <!ELEMENT faq (question, answer)>
+ <!ATTLIST faq %common.att;>
+
+ <!ELEMENT question (%content.mix;)*>
+ <!ATTLIST question %common.att;>
+
+ <!ELEMENT answer (%blocks;)*>
+ <!ATTLIST answer author IDREF #IMPLIED>
+
+<!-- =============================================================== -->
+<!-- End of DTD -->
+<!-- =============================================================== -->
--- /dev/null
+<!-- ===================================================================
+
+ Apache JavaDoc DTD (version 0.4-draft)
+
+PURPOSE:
+ This DTD is designed to capture the output of JavaDoc as an XML document
+ through the use of the JavaDocXML Doclet. The hope is that by having the
+ JavaDoc documentation in an XML format, it will be easier for application
+ developers working with XML to treat their java source documentation in the
+ same way they treat any other XML document within their publication framework.
+
+ This DTD should reflect the information contained within the RootDoc object
+ passed to the JavaDocXML Doclet by JavaDoc. The RootDoc object and the rest
+ of the javaDoc Doclet API is specified at
+
+ http://java.sun.com/products/jdk/1.2/docs/tooldocs/javadoc/doclet/index.html
+
+ The only information that appears to be difficult to derive from this DTD
+ that is easy to obtain from the RootDoc object is the information about
+ serialization. However, this information should be derivable by manually
+ looking for the correct serialization methods and other related structures.
+
+TYPICAL INVOCATION:
+
+ <!DOCTYPE document PUBLIC
+ "-//APACHE//DTD JavaDoc Vx.yz//EN"
+ "javadoc-vxyz.dtd">
+
+ where
+
+ x := major version
+ y := minor version
+ z := status identifier (optional)
+
+NOTES:
+ The authors would like to thank the Cocoon's mail list subscribers for
+ providing such great support and feedback for this DTD.
+
+AUTHORS:
+ Kenneth Murphy <murphyk@umsystem.edu>
+
+FIXME:
+
+CHANGE HISTORY:
+ 199909?? Original idea of XML doclet. (KM)
+ 199910?? Initial version of this DTD. (KM)
+ 19991129 Cleaned up DTD. (SM)
+
+COPYRIGHT:
+ Copyright (c) @year@ The Apache Software Foundation.
+
+ Permission to copy in any form is granted provided this notice is
+ included in all copies. Permission to redistribute is granted
+ provided this file is distributed untouched in all its parts and
+ included files.
+
+==================================================================== -->
+
+<!-- =============================================================== -->
+<!-- Common Attribute Entities -->
+<!-- =============================================================== -->
+
+<!ENTITY % name 'name CDATA #REQUIRED'>
+<!ENTITY % dimension 'dimension CDATA #REQUIRED'>
+
+<!ENTITY % abstract 'abstract (true | false) "false"'>
+<!ENTITY % anonymous 'anonymous (true | false) "false"'>
+<!ENTITY % synthetic 'synthetic (true | false) "false"'>
+<!ENTITY % static 'static (true | false) "false"'>
+<!ENTITY % final 'final (true | false) "false"'>
+<!ENTITY % transient 'transient (true | false) "false"'>
+<!ENTITY % volatile 'volatile (true | false) "false"'>
+<!ENTITY % native 'native (true | false) "false"'>
+<!ENTITY % synchronized 'synchronized (true | false) "false"'>
+
+<!ENTITY % access 'access (private | package | protected | public) "package"'>
+<!ENTITY % class.access 'access (package | public) "package"'>
+
+<!ENTITY % extensibility 'extensibility (abstract | final | default) "default"'>
+
+
+<!-- =============================================================== -->
+<!-- Javadoc -->
+<!-- =============================================================== -->
+
+<!ELEMENT javadoc (package*, class*, interface*)>
+
+<!-- =============================================================== -->
+<!-- Package -->
+<!-- =============================================================== -->
+
+<!ELEMENT package (doc?, package*, class*, interface*)>
+<!ATTLIST package %name;>
+
+<!-- =============================================================== -->
+<!-- Class -->
+<!-- =============================================================== -->
+
+<!ELEMENT class (doc?,
+ extends_class?,
+ implements?,
+ field*,
+ constructor*,
+ method*,
+ innerclass*)>
+<!ATTLIST class
+ %name;
+ %extensibility;
+ %class.access;>
+
+<!ELEMENT extends_class (classref+)>
+
+<!ELEMENT innerclass (doc?,
+ extends?,
+ implements?,
+ field*,
+ constructor*,
+ method*)>
+<!ATTLIST innerclass
+ %name;
+ %access;
+ %abstract;
+ %anonymous;
+ %final;
+ %static;>
+
+<!-- =============================================================== -->
+<!-- Interface -->
+<!-- =============================================================== -->
+
+<!ELEMENT interface (doc?,
+ extends_interface?,
+ field*,
+ method*)>
+<!ATTLIST interface
+ %name;
+ %access;>
+
+<!ELEMENT extends_interface (interfaceref+)>
+
+<!-- =============================================================== -->
+<!-- Elements -->
+<!-- =============================================================== -->
+
+<!ELEMENT implements (interfaceref+)>
+
+<!ELEMENT throws (classref)+>
+
+<!ELEMENT classref EMPTY>
+<!ATTLIST classref %name;>
+
+<!ELEMENT interfaceref EMPTY>
+<!ATTLIST interfaceref %name;>
+
+<!ELEMENT methodref EMPTY>
+<!ATTLIST methodref %name;>
+
+<!ELEMENT packageref EMPTY>
+<!ATTLIST packageref %name;>
+
+<!ELEMENT primitive EMPTY>
+<!ATTLIST primitive
+ type (void | boolean | int | long | byte | short | double | float | char) #REQUIRED>
+
+<!ELEMENT field (doc?, (classref | interfaceref | primitive))>
+<!ATTLIST field
+ %name;
+ %access;
+ %dimension;
+ %synthetic;
+ %static;
+ %final;
+ %transient;
+ %volatile;>
+
+<!ELEMENT constructor (doc?, parameter*, throws*)>
+<!ATTLIST constructor
+ %name;
+ %access;
+ %synthetic;>
+
+<!ELEMENT method (doc?, returns, parameter*, throws*)>
+<!ATTLIST method
+ %name;
+ %access;
+ %extensibility;
+ %native;
+ %synthetic;
+ %static;
+ %synchronized;>
+
+<!ELEMENT returns (classref | interfaceref | primitive)>
+<!ATTLIST returns %dimension;>
+
+<!ELEMENT parameter (classref | interfaceref | primitive)>
+<!ATTLIST parameter
+ %name;
+ %final;
+ %dimension;>
+
+<!ELEMENT dimension (#PCDATA)>
+
+<!ELEMENT doc (#PCDATA |
+ linktag |
+ authortag |
+ versiontag |
+ paramtag |
+ returntag |
+ exceptiontag |
+ throwstag |
+ seetag |
+ sincetag |
+ deprecatedtag |
+ serialtag |
+ serialfieldtag |
+ serialdatatag)*>
+
+<!ELEMENT linktag (#PCDATA)>
+<!ATTLIST linktag
+ src CDATA #REQUIRED>
+
+<!ELEMENT authortag (#PCDATA | linktag)*>
+
+<!ELEMENT versiontag (#PCDATA | linktag)*>
+
+<!ELEMENT paramtag (#PCDATA | linktag)*>
+<!ATTLIST paramtag %name;>
+
+<!ELEMENT returntag (#PCDATA | linktag)*>
+
+<!ELEMENT exceptiontag (#PCDATA | classref | linktag)*>
+
+<!ELEMENT throwstag (#PCDATA | classref | linktag)*>
+
+<!ELEMENT seetag (#PCDATA | linktag)*>
+<!ATTLIST seetag
+ src CDATA #REQUIRED>
+
+<!ELEMENT sincetag (#PCDATA | linktag)*>
+
+<!ELEMENT deprecatedtag (#PCDATA | linktag)*>
+
+<!ELEMENT serialtag (#PCDATA | linktag)*>
+
+<!ELEMENT serialfieldtag (#PCDATA | linktag)*>
+<!ATTLIST serialfieldtag
+ fieldname CDATA #REQUIRED
+ fieldtype CDATA #REQUIRED>
+
+<!ELEMENT serialdatatag (#PCDATA | linktag)*>
+
+<!-- =============================================================== -->
+<!-- End of DTD -->
+<!-- =============================================================== -->
--- /dev/null
+<!-- ===================================================================
+
+ Apache Specification DTD (Version 1.1)
+
+PURPOSE:
+ This DTD was developed to create a simple yet powerful document
+ type for software specifications for use with the Apache projects.
+ It is an XML-compliant DTD and it's maintained by the Apache XML
+ project.
+
+TYPICAL INVOCATION:
+
+ <!DOCTYPE document PUBLIC
+ "-//APACHE//DTD Specification Vx.y//EN"
+ "specification-vxy.dtd">
+
+ where
+
+ x := major version
+ y := minor version
+
+NOTES:
+
+AUTHORS:
+ Stefano Mazzocchi <stefano@apache.org>
+
+FIXME:
+
+CHANGE HISTORY:
+[Version 1.0]
+ 19991129 Initial version. (SM)
+[Version 1.1]
+ 20011212 Used public identifiers for external entities (SM)
+
+COPYRIGHT:
+ Copyright (c) @year@ The Apache Software Foundation.
+
+ Permission to copy in any form is granted provided this notice is
+ included in all copies. Permission to redistribute is granted
+ provided this file is distributed untouched in all its parts and
+ included files.
+
+==================================================================== -->
+
+<!-- =============================================================== -->
+<!-- Include the Documentation DTD -->
+<!-- =============================================================== -->
+
+<!ENTITY % document PUBLIC
+ "-//APACHE//DTD Documentation V1.1//EN"
+ "document-v11.dtd">
+%document;
+
+
+<!-- =============================================================== -->
+<!-- Extend the Documentation DTD -->
+<!-- =============================================================== -->
+
+<!-- extend the local.xxx entities -->
+<!ENTITY % local.blocks "|bl">
+
+
+<!-- =============================================================== -->
+<!-- Document Type Definition -->
+<!-- =============================================================== -->
+
+<!ELEMENT specification (header?, body, appendices?, footer?)>
+<!ATTLIST specification %common.att;>
+
+ <!ELEMENT appendices (%sections;)+>
+ <!ATTLIST appendices %common.att;>
+
+<!-- =============================================================== -->
+<!-- Bibliography List -->
+<!-- =============================================================== -->
+
+ <!-- Bibliography list -->
+ <!ELEMENT bl (bi)+>
+ <!ATTLIST bl %common.att;>
+
+ <!-- Book item -->
+ <!ELEMENT bi EMPTY>
+ <!ATTLIST bi %common.att;
+ %name.att;
+ %title.att;
+ %link.att;
+ authors CDATA #REQUIRED
+ date CDATA #IMPLIED>
+
+<!-- =============================================================== -->
+<!-- End of DTD -->
+<!-- =============================================================== -->
--- /dev/null
+<!-- ===================================================================
+
+ Apache Todos DTD (Version 1.1)
+
+PURPOSE:
+ This DTD was developed to create a simple yet powerful document
+ type for software development todo lists for use with the Apache projects.
+ It is an XML-compliant DTD and it's maintained by the Apache XML
+ project.
+
+TYPICAL INVOCATION:
+
+ <!DOCTYPE document PUBLIC
+ "-//APACHE//DTD Todo Vx.y//EN"
+ "todo-vxy.dtd">
+
+ where
+
+ x := major version
+ y := minor version
+
+NOTES:
+ It is important, expecially in open developped software projects, to keep
+ track of software changes that need to be done, planned features, development
+ assignment, etc. in order to allow better work parallelization and create
+ an entry point for people that want to help. This DTD wants to provide
+ a solid foundation to provide such information and to allow it to be
+ published as well as distributed in a common format.
+
+AUTHORS:
+ Stefano Mazzocchi <stefano@apache.org>
+
+FIXME:
+ - do we need anymore working contexts? (SM)
+
+CHANGE HISTORY:
+[Version 1.0]
+ 19991129 Initial version. (SM)
+ 19991225 Added actions element for better structure (SM)
+[Version 1.1]
+ 20011212 Used public identifiers for external entities (SM)
+
+COPYRIGHT:
+ Copyright (c) @year@ The Apache Software Foundation.
+
+ Permission to copy in any form is granted provided this notice is
+ included in all copies. Permission to redistribute is granted
+ provided this file is distributed untouched in all its parts and
+ included files.
+
+==================================================================== -->
+
+<!-- =============================================================== -->
+<!-- Include the Documentation DTD -->
+<!-- =============================================================== -->
+
+<!ENTITY % document PUBLIC
+ "-//APACHE//DTD Documentation V1.1//EN"
+ "document-v11.dtd">
+%document;
+
+
+<!-- =============================================================== -->
+<!-- Common entities -->
+<!-- =============================================================== -->
+
+<!ENTITY % priorities "showstopper|high|medium|low|wish|dream">
+
+<!ENTITY % contexts "build|docs|code|admin|design">
+
+<!-- =============================================================== -->
+<!-- Document Type Definition -->
+<!-- =============================================================== -->
+
+<!ELEMENT todo (devs, actions*)>
+<!ATTLIST todo %common.att;
+ %title.att;>
+
+ <!ELEMENT devs (person+)>
+ <!ATTLIST devs %common.att;>
+
+ <!ELEMENT actions (action+)>
+ <!ATTLIST actions %common.att;
+ priority (%priorities;) #IMPLIED>
+
+ <!ELEMENT action (%content.mix;)*>
+ <!ATTLIST action %common.att;
+ assigned-to IDREF #IMPLIED
+ context (%contexts;) #REQUIRED>
+
+<!-- =============================================================== -->
+<!-- End of DTD -->
+<!-- =============================================================== -->
<td>jdepend</td>
<td>http://www.ibiblio.org/maven/jdepend/jars/</td>
</tr>
+ <tr>
+ <td>xalan</td>
+ <td>http://www.ibiblio.org/maven/xalan/jars/</td>
+ </tr>
</table>
<p>
Just pick the latest versions of these jars and place
<section><title>Purpose</title>
<p>
The POI project consists of APIs for manipulating various file formats
- based upon Microsoft's OLE 2 Compound Document format using pure Java.
+ based upon Microsoft's OLE 2 Compound Document format using pure Java. In short, you can
+ read and write MS Excel files using Java. Soon, you'll be able to read and write
+ Word files using Java. POI is your Java Excel solution as well as your Word Excel solution.
+ However, we have a complete API for porting other OLE 2 Compound Document formats and welcome
+ others to participate.
</p>
<p>
OLE 2 Compound Document Format based files include most Microsoft Office
- files such as XLS and DOC.
+ files such as XLS and DOC as well as MFC serialization API based file formats.
</p>
<p>
As a general policy we try to collaborate as much as possible with other projects to
we say that POIFS is the most complete and correct port of this file format to date!
</p>
<p>
- You'd use HSSF if you needed to read or write an XLS (Excel) file using Java. You can also read and modify
+ You'd use HSSF if you needed to read or write an Excel file using Java (XLS). You can also read and modify
spreadsheets using this API, although right now writing is more mature.
</p>
</section>
<title>History of Changes</title>
+ <release version="2.0-pre2" date="6 July 2003">
+ <action dev="POI-DEVELOPERS" type="fix">A nasty concurrency problem has been fixed. Any users working in a multithreaded environment should seriously consider upgrading to this release.</action>
+ <action dev="POI-DEVELOPERS" type="update">The EXTSST record has been implemented. This record is used by excel for optimized reading of strings.</action>
+ <action dev="POI-DEVELOPERS" type="update">When rows are shifted, the merged regions now move with them. If a row contains 2 merged cells, the resulting shifted row should have those cells merged as well.</action>
+ <action dev="POI-DEVELOPERS" type="fix">There were some issues when removing merged
+ regions (specifically, removing all of them and then adding some more) and have been resolved.</action>
+ <action dev="POI-DEVELOPERS" type="fix">When a sheet contained shared formulas (when a formula is
+ dragged across greater than 6 cells), the clone would fail. We now support cloning of
+ sheets that contain this Excel optimization. </action>
+ <action dev="POI-DEVELOPERS" type="add">Support added for reading formulas with UnaryPlus and UnaryMinus operators.</action>
+ </release>
+ <release version="2.0-pre1" date="17 May 2003">
+ <action dev="POI-DEVELOPERS" type="add">Patch applied for deep cloning of worksheets was provided</action>
+ <action dev="POI-DEVELOPERS" type="add">Patch applied to allow sheet reordering</action>
+ <action dev="POI-DEVELOPERS" type="add">Added additional print area setting methods using row/column numbers</action>
+ <action dev="POI-DEVELOPERS" type="fix">HDF: Negative Array size fix</action>
+ <action dev="POI-DEVELOPERS" type="update">Added argument pointers to support the IF formula</action>
+ <action dev="POI-DEVELOPERS" type="update">Formulas: Added special character support for string literals, specifically for SUMIF formula support and addresses a bug as well</action>
+ <action dev="POI-DEVELOPERS" type="fix">BlockingInputStream committed to help ensure reads</action>
+ <action dev="POI-DEVELOPERS" type="fix">Fixed problem with NaN values differing from the investigated value from file reads in FormulaRecords</action>
+ <action dev="POI-DEVELOPERS" type="fix">Patch for getColumnWidth in HSSF</action>
+ <action dev="POI-DEVELOPERS" type="add">Patch for dealing with mult-level numbered lists in HDF</action>
+ <action dev="POI-DEVELOPERS" type="fix">Due to named reference work, several named-ranged bugs were closed</action>
+ <action dev="POI-DEVELOPERS" type="fix">Patch applied to prevent sheet corruption after a template modification</action>
+ <action dev="POI-DEVELOPERS" type="update">Shared Formulas now Supported</action>
+ <action dev="POI-DEVELOPERS" type="update">Added GreaterEqual, LessEqual and NotEqual to Formula Parser</action>
+ <action dev="POI-DEVELOPERS" type="update">Added GreaterThan and LessThan functionality to formulas</action>
+ <action dev="POI-DEVELOPERS" type="fix">Patches for i10n</action>
+ <action dev="POI-DEVELOPERS" type="update">POI Build System Updated</action>
+ <action dev="POI-DEVELOPERS" type="fix">font names can now be null</action>
+ </release>
<release version="1.10-dev" date="19 Feb 2003">
<action dev="POI-DEVELOPERS" type="add">Support for zoom level</action>
<action dev="POI-DEVELOPERS" type="add">Freeze and split pane support</action>
</changes>
-</status>
\ No newline at end of file
+</status>
+++ /dev/null
-<!-- ===================================================================
-
- Apache Cocoon Documentation Book DTD (Version 1.0)
-
-PURPOSE:
-This DTD defines the */book.xml documentation configuration files.
-
-TYPICAL INVOCATION:
-
- <!DOCTYPE book PUBLIC
- "-//APACHE//DTD Cocoon Documentation Book Vx.yz//EN"
- "book-cocoon-vxyz.dtd">
-
- where
-
- x := major version
- y := minor version
- z := status identifier (optional)
-
-NOTES:
-We need to replace this DTD with the proper one.
-We are only using this DTD to enable validation during "build docs"
-because every XML instance must declare its ruleset.
-
-This initial minimal DTD has been reverse-engineered from the structure
-of the current documents, e.g.
- documentation/xdocs/book.xml
-
-AUTHORS:
- David Crossley <crossley@apache.org>
-
-FIXME:
- - find the proper DTD for book.xml
-
-CHANGE HISTORY:
- 20011031 Initial version. (DC)
-
-COPYRIGHT:
- Copyright (c) @year@ The Apache Software Foundation.
-
- Permission to copy in any form is granted provided this notice is
- included in all copies. Permission to redistribute is granted
- provided this file is distributed untouched in all its parts and
- included files.
-
-==================================================================== -->
-
-<!ELEMENT book (menu+)>
-<!ELEMENT menu (menu-item|external)*>
-<!ELEMENT menu-item EMPTY>
-<!ELEMENT external EMPTY>
-<!ATTLIST book software CDATA #REQUIRED
- title CDATA #REQUIRED
- copyright CDATA #REQUIRED
- xmlns:xlink CDATA #IMPLIED
->
-<!ATTLIST menu label CDATA #REQUIRED
->
-<!ATTLIST menu-item label CDATA #REQUIRED
- href CDATA #REQUIRED
- type (visible|hidden) "visible"
->
-<!ATTLIST external label CDATA #REQUIRED
- href CDATA #REQUIRED
- type (visible|hidden) "visible"
->
-
-<!-- =============================================================== -->
-<!-- End of DTD -->
-<!-- =============================================================== -->
+++ /dev/null
-<!-- ===================================================================
-
- Apache Changes DTD (Version 1.1)
-
-PURPOSE:
- This DTD was developed to create a simple yet powerful document
- type for software development changes for use with the Apache projects.
- It is an XML-compliant DTD and it's maintained by the Apache XML
- project.
-
-TYPICAL INVOCATION:
-
- <!DOCTYPE document PUBLIC
- "-//APACHE//DTD Changes Vx.y//EN"
- "changes-vxy.dtd">
-
- where
-
- x := major version
- y := minor version
-
-NOTES:
- It is important, expecially in open developped software projects, to keep
- track of software changes both to give users indications of bugs that might
- have been resolved, as well, and not less important, to provide credits
- for the support given to the project. It is considered vital to provide
- adequate payback using recognition and credits to let users and developers
- feel part of the community, thus increasing development power.
-
-AUTHORS:
- Stefano Mazzocchi <stefano@apache.org>
-
-FIXME:
-
-CHANGE HISTORY:
-[Version 1.0]
- 19991129 Initial version. (SM)
- 20000316 Added bugfixing attribute. (SM)
-[Version 1.1]
- 20011212 Used public identifiers for external entities (SM)
-
-COPYRIGHT:
- Copyright (c) @year@ The Apache Software Foundation.
-
- Permission to copy in any form is granted provided this notice is
- included in all copies. Permission to redistribute is granted
- provided this file is distributed untouched in all its parts and
- included files.
-
-==================================================================== -->
-
-<!-- =============================================================== -->
-<!-- Include the Documentation DTD -->
-<!-- =============================================================== -->
-
-<!ENTITY % document PUBLIC
- "-//APACHE//DTD Documentation V1.1//EN"
- "document-v11.dtd">
-%document;
-
-<!-- =============================================================== -->
-<!-- Common entities -->
-<!-- =============================================================== -->
-
-<!ENTITY % types "add|remove|update|fix">
-
-<!-- =============================================================== -->
-<!-- Document Type Definition -->
-<!-- =============================================================== -->
-
-<!ELEMENT changes (devs, release*)>
-<!ATTLIST changes %common.att;
- %title.att;>
-
- <!ELEMENT devs (person+)>
- <!ATTLIST devs %common.att;>
-
- <!ELEMENT release (action+)>
- <!ATTLIST release %common.att;
- version CDATA #REQUIRED
- date CDATA #REQUIRED>
-
- <!ELEMENT action (%content.mix;)*>
- <!ATTLIST action %common.att;
- dev IDREF #REQUIRED
- type (%types;) #IMPLIED
- due-to CDATA #IMPLIED
- due-to-email CDATA #IMPLIED
- fixes-bug CDATA #IMPLIED>
-
-<!-- =============================================================== -->
-<!-- End of DTD -->
-<!-- =============================================================== -->
+++ /dev/null
-<!-- ===================================================================
-
- Apache Documentation DTD (Version 1.1)
-
-PURPOSE:
- This DTD was developed to create a simple yet powerful document
- type for software documentation for use with the Apache projects.
- It is an XML-compliant DTD and it's maintained by the Apache XML
- project.
-
-TYPICAL INVOCATION:
-
- <!DOCTYPE document PUBLIC
- "-//APACHE//DTD Documentation Vx.y//EN"
- "document-vxy.dtd">
-
- where
-
- x := major version
- y := minor version
-
-NOTES:
- Many of the design patterns used in this DTD were take from the
- W3C XML Specification DTD edited by Eve Maler <elm@arbortext.com>.
-
- Where possible, great care has been used to reuse HTML tag
- names to reduce learning efforts and to allow HTML editors to be
- used for complex authorings like tables and lists.
-
-EXTENSIBILITY:
- This DTD includes several empty placeholders that can be used to
- extend it. These placeholders are implemented with empty entities. Here
- is the list of those empty entities and what they are used for:
-
- - local.inline: this entity should contain extended definitions of
- elements that can be used 'inline', or directly inside
- the content. An example for this entity could be
-
- <!ENTITY % local.inline "|citation">
-
- - local.blocks: this entity should contain extended definitions of
- elements that behave as 'blocks', thus can be visually
- rendered as areas on the canvas. An example for this
- entity could be:
-
- <!ENTITY % local.blocks "|poem">
-
- - local.sections: this entity should contain extended definitions of
- elements that behave as 'sections', thus can be considered
- containers of block-level elements. An example for
- this entity could be:
-
- <!ENTITY % local.sections "|chapter">
-
- - local.headers: this entity should contain extended definitions of
- elements that behave as parts of the document header.
- An example for this header could be:
-
- <!ENTITY % local.headers ", notes?">
-
- - local.footers: this entity should contain extended definitions of
- elements that behave as parts of the document footer.
- An example for this header could be:
-
- <!ENTITY % local.footers ", annotations*">
-
-
-AUTHORS:
- Stefano Mazzocchi <stefano@apache.org>
- Steven Noels <stevenn@outerthought.org>
-
-FIXME:
- - should "form" tags be included?
-
-CHANGE HISTORY:
-[Version 1.0]
- 19991121 Initial version. (SM)
- 19991123 Replaced "res" with more standard "strong" for emphasis. (SM)
- 19991124 Added "fork" element for window forking behavior. (SM)
- 19991124 Added "img-inline" element to separate from "img". (SM)
- 19991129 Removed "affiliation" from "author". (SM)
- 19991129 Made "author" empty and moved "name|email" as attributes. (SM)
- 19991215 Simplified table section. (SM)
- 19991215 Changed "img-block" in more friendly "figure". (SM)
- 20000125 Added the "icon" image. (SM)
- 20000126 Allowed "anchor" in all levels. (SM)
- 20000404 Removed the "role" attribute from common-xxx.att. (SM)
- 20000815 Allowed "code" inside "strong" and "em". (SM)
-[Version 1.1]
- 20011212 Used public identifiers for external entities. (SM)
- 20011212 Removed xlink attributes since not used. (SM)
- 20011212 Removed "connect" since not required at this level. (SM)
- 20011218 Added "warning" as a block level object. (SM)
- 20011218 Removed explicitly numbered sections ("s1|s2|s3|s4"). (SM)
- 20011218 Added "section" element. (SM)
- 20011218 Allowed "body" to have blocks without a section. (SM)
- 20011218 Removed "sl" since not really different from "ul". (SM)
- 20020214 Moved empty placeholder entity declarations up front (SNS)
- 20020214 Corrected content model of content.mix parameter entity (SNS)
-
-COPYRIGHT:
- Copyright (c) @year@ The Apache Software Foundation.
-
- Permission to copy in any form is granted provided this notice is
- included in all copies. Permission to redistribute is granted
- provided this file is distributed untouched in all its parts and
- included files.
-
-==================================================================== -->
-
-
-
-
-<!-- =============================================================== -->
-<!-- Common character entities (included from external file) -->
-<!-- =============================================================== -->
-
-<!ENTITY % ISOlat1 PUBLIC
- "ISO 8879:1986//ENTITIES Added Latin 1//EN//XML"
- "ISOlat1.pen">
-%ISOlat1;
-
-<!ENTITY % ISOpub PUBLIC
- "ISO 8879:1986//ENTITIES Publishing//EN//XML"
- "ISOpub.pen">
-%ISOpub;
-
-<!ENTITY % ISOtech PUBLIC
- "ISO 8879:1986//ENTITIES General Technical//EN//XML"
- "ISOtech.pen">
-%ISOtech;
-
-<!ENTITY % ISOnum PUBLIC
- "ISO 8879:1986//ENTITIES Numeric and Special Graphic//EN//XML"
- "ISOnum.pen">
-%ISOnum;
-
-<!ENTITY % ISOdia PUBLIC
- "ISO 8879:1986//ENTITIES Diacritical Marks//EN//XML"
- "ISOdia.pen">
-%ISOdia;
-
-<!-- =============================================================== -->
-<!-- Useful entities for increased DTD readability -->
-<!-- =============================================================== -->
-
-<!ENTITY % text "#PCDATA">
-
-<!-- Entities referred to later on are defined up front -->
-
-<!ENTITY % markup "strong|em|code|sub|sup">
-<!ENTITY % special-inline "br|img|icon">
-<!ENTITY % links "link|jump|fork">
-<!ENTITY % paragraphs "p|source|note|warning|fixme">
-<!ENTITY % tables "table">
-<!ENTITY % lists "ol|ul|dl">
-<!ENTITY % special-blocks "figure|anchor">
-
-
-<!-- =============================================================== -->
-<!-- Entities for general XML compliance -->
-<!-- =============================================================== -->
-
-<!-- Common attributes
- Every element has an ID attribute (sometimes required,
- but usually optional) for links. %common.att;
- is for common attributes where the ID is optional, and
- %common-idreq.att; is for common attributes where the
- ID is required.
--->
-<!ENTITY % common.att
- 'id ID #IMPLIED
- xml:lang NMTOKEN #IMPLIED'>
-<!ENTITY % common-idreq.att
- 'id ID #REQUIRED
- xml:lang NMTOKEN #IMPLIED'>
-
-
-<!-- xml:space attribute ===============================================
- Indicates that the element contains white space
- that the formatter or other application should retain,
- as appropriate to its function.
-==================================================================== -->
-<!ENTITY % xmlspace.att
- 'xml:space (default|preserve) #FIXED "preserve"'>
-
-
-<!-- def attribute =====================================================
- Points to the element where the relevant definition can be
- found, using the IDREF mechanism. %def.att; is for optional
- def attributes, and %def-req.att; is for required def
- attributes.
-==================================================================== -->
-<!ENTITY % def.att
- 'def IDREF #IMPLIED'>
-<!ENTITY % def-req.att
- 'def IDREF #REQUIRED'>
-
-
-<!-- ref attribute =====================================================
- Points to the element where more information can be found,
- using the IDREF mechanism. %ref.att; is for optional
- ref attributes, and %ref-req.att; is for required ref
- attributes.
-================================================================== -->
-<!ENTITY % ref.att
- 'ref IDREF #IMPLIED'>
-<!ENTITY % ref-req.att
- 'ref IDREF #REQUIRED'>
-
-
-<!-- =============================================================== -->
-<!-- Entities for general usage -->
-<!-- =============================================================== -->
-
-
-<!-- Key attribute =====================================================
- Optionally provides a sorting or indexing key, for cases when
- the element content is inappropriate for this purpose.
-==================================================================== -->
-<!ENTITY % key.att
- 'key CDATA #IMPLIED'>
-
-
-
-<!-- Title attributes ==================================================
- Indicates that the element requires to have a title attribute.
-==================================================================== -->
-<!ENTITY % title.att
- 'title CDATA #REQUIRED'>
-
-
-
-<!-- Name attributes ==================================================
- Indicates that the element requires to have a name attribute.
-==================================================================== -->
-<!ENTITY % name.att
- 'name CDATA #REQUIRED'>
-
-
-
-<!-- Email attributes ==================================================
- Indicates that the element requires to have an email attribute.
-==================================================================== -->
-<!ENTITY % email.att
- 'email CDATA #REQUIRED'>
-
-
-<!-- Link attributes ===================================================
- Indicates that the element requires to have hyperlink attributes.
-==================================================================== -->
-
-<!ENTITY % link.att
- 'href CDATA #IMPLIED
- role CDATA #IMPLIED
- title CDATA #IMPLIED '>
-
-
-
-<!-- =============================================================== -->
-<!-- General definitions -->
-<!-- =============================================================== -->
-
-<!-- A person is a general human entity -->
-<!ELEMENT person EMPTY>
-<!ATTLIST person %common.att;
- %name.att;
- %email.att;>
-
-
-
-<!-- =============================================================== -->
-<!-- Content definitions -->
-<!-- =============================================================== -->
-
-<!ENTITY % local.inline "">
-
-<!ENTITY % link-content.mix "%text;|%markup;|%special-inline; %local.inline;">
-
-<!ENTITY % content.mix "%link-content.mix;|%links;">
-
- <!-- ==================================================== -->
- <!-- Phrase Markup -->
- <!-- ==================================================== -->
-
- <!-- Strong (typically bold) -->
- <!ELEMENT strong (%text;|code)*>
- <!ATTLIST strong %common.att;>
-
- <!-- Emphasis (typically italic) -->
- <!ELEMENT em (%text;|code)*>
- <!ATTLIST em %common.att;>
-
- <!-- Code (typically monospaced) -->
- <!ELEMENT code (%text;)>
- <!ATTLIST code %common.att;>
-
- <!-- Superscript (typically smaller and higher) -->
- <!ELEMENT sup (%text;)>
- <!ATTLIST sup %common.att;>
-
- <!-- Subscript (typically smaller and lower) -->
- <!ELEMENT sub (%text;)>
- <!ATTLIST sub %common.att;>
-
- <!-- ==================================================== -->
- <!-- Hypertextual Links -->
- <!-- ==================================================== -->
-
- <!-- hyperlink (equivalent of <a ...>) -->
- <!ELEMENT link (%link-content.mix;)*>
- <!ATTLIST link %common.att;
- %link.att;>
-
- <!-- windows-replacing link (equivalent of <a ... target="_top">) -->
- <!ELEMENT jump (%link-content.mix;)*>
- <!ATTLIST jump %common.att;
- %link.att;>
-
- <!-- window-forking link (equivalent of <a ... target="_new">) -->
- <!ELEMENT fork (%link-content.mix;)*>
- <!ATTLIST fork %common.att;
- %link.att;>
-
- <!-- ==================================================== -->
- <!-- Specials -->
- <!-- ==================================================== -->
-
- <!-- Breakline Object (typically forces line break) -->
- <!ELEMENT br EMPTY>
- <!ATTLIST br %common.att;>
-
- <!-- Image Object (typically an inlined image) -->
- <!ELEMENT img EMPTY>
- <!ATTLIST img src CDATA #REQUIRED
- alt CDATA #REQUIRED
- height CDATA #IMPLIED
- width CDATA #IMPLIED
- usemap CDATA #IMPLIED
- ismap (ismap) #IMPLIED
- %common.att;>
-
- <!-- Image Icon (typically an inlined image placed as graphical item) -->
- <!ELEMENT icon EMPTY>
- <!ATTLIST icon src CDATA #REQUIRED
- alt CDATA #REQUIRED
- height CDATA #IMPLIED
- width CDATA #IMPLIED
- %common.att;>
-
-
-<!-- =============================================================== -->
-<!-- Blocks definitions -->
-<!-- =============================================================== -->
-
-<!ENTITY % local.blocks "">
-
-<!ENTITY % blocks "%paragraphs;|%tables;|%lists;|%special-blocks; %local.blocks;">
-
- <!-- ==================================================== -->
- <!-- Paragraphs -->
- <!-- ==================================================== -->
-
- <!-- Text Paragraph (normally vertically space delimited) -->
- <!ELEMENT p (%content.mix;)*>
- <!ATTLIST p %common.att;>
-
- <!-- Source Paragraph (normally space is preserved) -->
- <!ELEMENT source (%content.mix;)*>
- <!ATTLIST source %common.att;
- %xmlspace.att;>
-
- <!-- Note Paragraph (normally shown encapsulated) -->
- <!ELEMENT note (%content.mix;)*>
- <!ATTLIST note %common.att;>
-
- <!-- Warning Paragraph (normally shown with eye-catching colors) -->
- <!ELEMENT warning (%content.mix;)*>
- <!ATTLIST warning %common.att;>
-
- <!-- Fixme Paragraph (normally not shown) -->
- <!ELEMENT fixme (%content.mix;)*>
- <!ATTLIST fixme author CDATA #REQUIRED
- %common.att;>
-
- <!-- ==================================================== -->
- <!-- Tables -->
- <!-- ==================================================== -->
-
- <!-- Attributes that indicate the spanning of the table cell -->
- <!ENTITY % cell.span
- 'colspan CDATA "1"
- rowspan CDATA "1"'>
-
- <!-- Table element -->
- <!ELEMENT table (caption?, tr+)>
- <!ATTLIST table %common.att;>
-
- <!-- The table title -->
- <!ELEMENT caption (%content.mix;)*>
- <!ATTLIST caption %common.att;>
-
- <!-- The table row element -->
- <!ELEMENT tr (th|td)+>
- <!ATTLIST tr %common.att;>
-
- <!-- The table row header element -->
- <!ELEMENT th (%content.mix;)*>
- <!ATTLIST th %common.att;
- %cell.span;>
-
- <!-- The table row description element -->
- <!ELEMENT td (%content.mix;)*>
- <!ATTLIST td %common.att;
- %cell.span;>
-
- <!-- ==================================================== -->
- <!-- Lists -->
- <!-- ==================================================== -->
-
- <!-- List item -->
- <!ELEMENT li (%content.mix;|%lists;)*>
- <!ATTLIST li %common.att;>
-
- <!-- Unordered list (typically bulleted) -->
- <!ELEMENT ul (li|%lists;)+>
- <!-- spacing attribute:
- Use "normal" to get normal vertical spacing for items;
- use "compact" to get less spacing. The default is dependent
- on the stylesheet. -->
- <!ATTLIST ul
- %common.att;
- spacing (normal|compact) #IMPLIED>
-
- <!-- Ordered list (typically numbered) -->
- <!ELEMENT ol (li|%lists;)+>
- <!-- spacing attribute:
- Use "normal" to get normal vertical spacing for items;
- use "compact" to get less spacing. The default is dependent
- on the stylesheet. -->
- <!ATTLIST ol
- %common.att;
- spacing (normal|compact) #IMPLIED>
-
- <!-- Definition list (typically two-column) -->
- <!ELEMENT dl (dt,dd)+>
- <!ATTLIST dl %common.att;>
-
- <!-- Definition term -->
- <!ELEMENT dt (%content.mix;)*>
- <!ATTLIST dt %common.att;>
-
- <!-- Definition description -->
- <!ELEMENT dd (%content.mix;)*>
- <!ATTLIST dd %common.att;>
-
- <!-- ==================================================== -->
- <!-- Special Blocks -->
- <!-- ==================================================== -->
-
- <!-- Image Block (typically a separated and centered image) -->
- <!ELEMENT figure EMPTY>
- <!ATTLIST figure src CDATA #REQUIRED
- alt CDATA #REQUIRED
- height CDATA #IMPLIED
- width CDATA #IMPLIED
- usemap CDATA #IMPLIED
- ismap (ismap) #IMPLIED
- %common.att;>
-
- <!-- anchor point (equivalent of <a name="...">, typically not rendered) -->
- <!ELEMENT anchor EMPTY>
- <!ATTLIST anchor %common-idreq.att;>
-
-
-<!-- =============================================================== -->
-<!-- Document -->
-<!-- =============================================================== -->
-
-<!ELEMENT document (header?, body, footer?)>
-<!ATTLIST document %common.att;>
-
- <!-- ==================================================== -->
- <!-- Header -->
- <!-- ==================================================== -->
-
- <!ENTITY % local.headers "">
-
- <!ELEMENT header (title, subtitle?, version?, type?, authors,
- notice*, abstract? %local.headers;)>
- <!ATTLIST header %common.att;>
-
- <!ELEMENT title (%text;)>
- <!ATTLIST title %common.att;>
-
- <!ELEMENT subtitle (%text;)>
- <!ATTLIST subtitle %common.att;>
-
- <!ELEMENT version (%text;)>
- <!ATTLIST version %common.att;>
-
- <!ELEMENT type (%text;)>
- <!ATTLIST type %common.att;>
-
- <!ELEMENT authors (person+)>
- <!ATTLIST authors %common.att;>
-
- <!ELEMENT notice (%content.mix;)*>
- <!ATTLIST notice %common.att;>
-
- <!ELEMENT abstract (%content.mix;)*>
- <!ATTLIST abstract %common.att;>
-
- <!-- ==================================================== -->
- <!-- Body -->
- <!-- ==================================================== -->
-
- <!ENTITY % local.sections "">
-
- <!ENTITY % sections "section %local.sections;">
-
- <!ELEMENT body (%sections;|%blocks;)+>
- <!ATTLIST body %common.att;>
-
- <!ELEMENT section (%sections;|%blocks;)*>
- <!ATTLIST section %title.att; %common.att;>
-
- <!-- ==================================================== -->
- <!-- Footer -->
- <!-- ==================================================== -->
-
- <!ENTITY % local.footers "">
-
- <!ELEMENT footer (legal %local.footers;)>
-
- <!ELEMENT legal (%content.mix;)*>
- <!ATTLIST legal %common.att;>
-
-<!-- =============================================================== -->
-<!-- End of DTD -->
-<!-- =============================================================== -->
+++ /dev/null
-<!-- ===================================================================
-
- Apache FAQ DTD (Version 1.1)
-
-PURPOSE:
- This DTD was developed to create a simple yet powerful document
- type for software FAQ's for use with the Apache projects.
- It is an XML-compliant DTD and it's maintained by the Apache XML
- project.
-
-TYPICAL INVOCATION:
-
- <!DOCTYPE document PUBLIC
- "-//APACHE//DTD FAQ Vx.y//EN"
- "faq-vxy.dtd">
-
- where
-
- x := major version
- y := minor version
-
-NOTES:
- FAQs represent a powerful knowledge base and a very good way of solving
- common user problems reducing messages on mail lists and reducing the effort
- required for software installation and usage. Thid DTD want to be a common
- format for FAQ interchange to allow FAQ-O-Matic-type workgroup services to
- be published in other formats as well as enhancing data interchange.
-
-AUTHORS:
- Stefano Mazzocchi <stefano@apache.org>
-
-FIXME:
-
-CHANGE HISTORY:
- 19991129 Initial version. (SM)
- 20011212 Used public identifiers for external entities (SM)
-
-COPYRIGHT:
- Copyright (c) @year@ The Apache Software Foundation.
-
- Permission to copy in any form is granted provided this notice is
- included in all copies. Permission to redistribute is granted
- provided this file is distributed untouched in all its parts and
- included files.
-
-==================================================================== -->
-
-<!-- =============================================================== -->
-<!-- Include the Documentation DTD -->
-<!-- =============================================================== -->
-
-<!ENTITY % document PUBLIC
- "-//APACHE//DTD Documentation V1.1//EN"
- "document-v11.dtd">
-%document;
-
-<!-- =============================================================== -->
-<!-- Document Type Definition -->
-<!-- =============================================================== -->
-
-<!ELEMENT faqs (authors?, faq)+>
-<!ATTLIST faqs %common.att;
- %title.att;>
-
- <!ELEMENT faq (question, answer)>
- <!ATTLIST faq %common.att;>
-
- <!ELEMENT question (%content.mix;)*>
- <!ATTLIST question %common.att;>
-
- <!ELEMENT answer (%blocks;)*>
- <!ATTLIST answer author IDREF #IMPLIED>
-
-<!-- =============================================================== -->
-<!-- End of DTD -->
-<!-- =============================================================== -->
+++ /dev/null
-<!-- ===================================================================
-
- Apache JavaDoc DTD (version 0.4-draft)
-
-PURPOSE:
- This DTD is designed to capture the output of JavaDoc as an XML document
- through the use of the JavaDocXML Doclet. The hope is that by having the
- JavaDoc documentation in an XML format, it will be easier for application
- developers working with XML to treat their java source documentation in the
- same way they treat any other XML document within their publication framework.
-
- This DTD should reflect the information contained within the RootDoc object
- passed to the JavaDocXML Doclet by JavaDoc. The RootDoc object and the rest
- of the javaDoc Doclet API is specified at
-
- http://java.sun.com/products/jdk/1.2/docs/tooldocs/javadoc/doclet/index.html
-
- The only information that appears to be difficult to derive from this DTD
- that is easy to obtain from the RootDoc object is the information about
- serialization. However, this information should be derivable by manually
- looking for the correct serialization methods and other related structures.
-
-TYPICAL INVOCATION:
-
- <!DOCTYPE document PUBLIC
- "-//APACHE//DTD JavaDoc Vx.yz//EN"
- "javadoc-vxyz.dtd">
-
- where
-
- x := major version
- y := minor version
- z := status identifier (optional)
-
-NOTES:
- The authors would like to thank the Cocoon's mail list subscribers for
- providing such great support and feedback for this DTD.
-
-AUTHORS:
- Kenneth Murphy <murphyk@umsystem.edu>
-
-FIXME:
-
-CHANGE HISTORY:
- 199909?? Original idea of XML doclet. (KM)
- 199910?? Initial version of this DTD. (KM)
- 19991129 Cleaned up DTD. (SM)
-
-COPYRIGHT:
- Copyright (c) @year@ The Apache Software Foundation.
-
- Permission to copy in any form is granted provided this notice is
- included in all copies. Permission to redistribute is granted
- provided this file is distributed untouched in all its parts and
- included files.
-
-==================================================================== -->
-
-<!-- =============================================================== -->
-<!-- Common Attribute Entities -->
-<!-- =============================================================== -->
-
-<!ENTITY % name 'name CDATA #REQUIRED'>
-<!ENTITY % dimension 'dimension CDATA #REQUIRED'>
-
-<!ENTITY % abstract 'abstract (true | false) "false"'>
-<!ENTITY % anonymous 'anonymous (true | false) "false"'>
-<!ENTITY % synthetic 'synthetic (true | false) "false"'>
-<!ENTITY % static 'static (true | false) "false"'>
-<!ENTITY % final 'final (true | false) "false"'>
-<!ENTITY % transient 'transient (true | false) "false"'>
-<!ENTITY % volatile 'volatile (true | false) "false"'>
-<!ENTITY % native 'native (true | false) "false"'>
-<!ENTITY % synchronized 'synchronized (true | false) "false"'>
-
-<!ENTITY % access 'access (private | package | protected | public) "package"'>
-<!ENTITY % class.access 'access (package | public) "package"'>
-
-<!ENTITY % extensibility 'extensibility (abstract | final | default) "default"'>
-
-
-<!-- =============================================================== -->
-<!-- Javadoc -->
-<!-- =============================================================== -->
-
-<!ELEMENT javadoc (package*, class*, interface*)>
-
-<!-- =============================================================== -->
-<!-- Package -->
-<!-- =============================================================== -->
-
-<!ELEMENT package (doc?, package*, class*, interface*)>
-<!ATTLIST package %name;>
-
-<!-- =============================================================== -->
-<!-- Class -->
-<!-- =============================================================== -->
-
-<!ELEMENT class (doc?,
- extends_class?,
- implements?,
- field*,
- constructor*,
- method*,
- innerclass*)>
-<!ATTLIST class
- %name;
- %extensibility;
- %class.access;>
-
-<!ELEMENT extends_class (classref+)>
-
-<!ELEMENT innerclass (doc?,
- extends?,
- implements?,
- field*,
- constructor*,
- method*)>
-<!ATTLIST innerclass
- %name;
- %access;
- %abstract;
- %anonymous;
- %final;
- %static;>
-
-<!-- =============================================================== -->
-<!-- Interface -->
-<!-- =============================================================== -->
-
-<!ELEMENT interface (doc?,
- extends_interface?,
- field*,
- method*)>
-<!ATTLIST interface
- %name;
- %access;>
-
-<!ELEMENT extends_interface (interfaceref+)>
-
-<!-- =============================================================== -->
-<!-- Elements -->
-<!-- =============================================================== -->
-
-<!ELEMENT implements (interfaceref+)>
-
-<!ELEMENT throws (classref)+>
-
-<!ELEMENT classref EMPTY>
-<!ATTLIST classref %name;>
-
-<!ELEMENT interfaceref EMPTY>
-<!ATTLIST interfaceref %name;>
-
-<!ELEMENT methodref EMPTY>
-<!ATTLIST methodref %name;>
-
-<!ELEMENT packageref EMPTY>
-<!ATTLIST packageref %name;>
-
-<!ELEMENT primitive EMPTY>
-<!ATTLIST primitive
- type (void | boolean | int | long | byte | short | double | float | char) #REQUIRED>
-
-<!ELEMENT field (doc?, (classref | interfaceref | primitive))>
-<!ATTLIST field
- %name;
- %access;
- %dimension;
- %synthetic;
- %static;
- %final;
- %transient;
- %volatile;>
-
-<!ELEMENT constructor (doc?, parameter*, throws*)>
-<!ATTLIST constructor
- %name;
- %access;
- %synthetic;>
-
-<!ELEMENT method (doc?, returns, parameter*, throws*)>
-<!ATTLIST method
- %name;
- %access;
- %extensibility;
- %native;
- %synthetic;
- %static;
- %synchronized;>
-
-<!ELEMENT returns (classref | interfaceref | primitive)>
-<!ATTLIST returns %dimension;>
-
-<!ELEMENT parameter (classref | interfaceref | primitive)>
-<!ATTLIST parameter
- %name;
- %final;
- %dimension;>
-
-<!ELEMENT dimension (#PCDATA)>
-
-<!ELEMENT doc (#PCDATA |
- linktag |
- authortag |
- versiontag |
- paramtag |
- returntag |
- exceptiontag |
- throwstag |
- seetag |
- sincetag |
- deprecatedtag |
- serialtag |
- serialfieldtag |
- serialdatatag)*>
-
-<!ELEMENT linktag (#PCDATA)>
-<!ATTLIST linktag
- src CDATA #REQUIRED>
-
-<!ELEMENT authortag (#PCDATA | linktag)*>
-
-<!ELEMENT versiontag (#PCDATA | linktag)*>
-
-<!ELEMENT paramtag (#PCDATA | linktag)*>
-<!ATTLIST paramtag %name;>
-
-<!ELEMENT returntag (#PCDATA | linktag)*>
-
-<!ELEMENT exceptiontag (#PCDATA | classref | linktag)*>
-
-<!ELEMENT throwstag (#PCDATA | classref | linktag)*>
-
-<!ELEMENT seetag (#PCDATA | linktag)*>
-<!ATTLIST seetag
- src CDATA #REQUIRED>
-
-<!ELEMENT sincetag (#PCDATA | linktag)*>
-
-<!ELEMENT deprecatedtag (#PCDATA | linktag)*>
-
-<!ELEMENT serialtag (#PCDATA | linktag)*>
-
-<!ELEMENT serialfieldtag (#PCDATA | linktag)*>
-<!ATTLIST serialfieldtag
- fieldname CDATA #REQUIRED
- fieldtype CDATA #REQUIRED>
-
-<!ELEMENT serialdatatag (#PCDATA | linktag)*>
-
-<!-- =============================================================== -->
-<!-- End of DTD -->
-<!-- =============================================================== -->
+++ /dev/null
-<!-- ===================================================================
-
- Apache Specification DTD (Version 1.1)
-
-PURPOSE:
- This DTD was developed to create a simple yet powerful document
- type for software specifications for use with the Apache projects.
- It is an XML-compliant DTD and it's maintained by the Apache XML
- project.
-
-TYPICAL INVOCATION:
-
- <!DOCTYPE document PUBLIC
- "-//APACHE//DTD Specification Vx.y//EN"
- "specification-vxy.dtd">
-
- where
-
- x := major version
- y := minor version
-
-NOTES:
-
-AUTHORS:
- Stefano Mazzocchi <stefano@apache.org>
-
-FIXME:
-
-CHANGE HISTORY:
-[Version 1.0]
- 19991129 Initial version. (SM)
-[Version 1.1]
- 20011212 Used public identifiers for external entities (SM)
-
-COPYRIGHT:
- Copyright (c) @year@ The Apache Software Foundation.
-
- Permission to copy in any form is granted provided this notice is
- included in all copies. Permission to redistribute is granted
- provided this file is distributed untouched in all its parts and
- included files.
-
-==================================================================== -->
-
-<!-- =============================================================== -->
-<!-- Include the Documentation DTD -->
-<!-- =============================================================== -->
-
-<!ENTITY % document PUBLIC
- "-//APACHE//DTD Documentation V1.1//EN"
- "document-v11.dtd">
-%document;
-
-
-<!-- =============================================================== -->
-<!-- Extend the Documentation DTD -->
-<!-- =============================================================== -->
-
-<!-- extend the local.xxx entities -->
-<!ENTITY % local.blocks "|bl">
-
-
-<!-- =============================================================== -->
-<!-- Document Type Definition -->
-<!-- =============================================================== -->
-
-<!ELEMENT specification (header?, body, appendices?, footer?)>
-<!ATTLIST specification %common.att;>
-
- <!ELEMENT appendices (%sections;)+>
- <!ATTLIST appendices %common.att;>
-
-<!-- =============================================================== -->
-<!-- Bibliography List -->
-<!-- =============================================================== -->
-
- <!-- Bibliography list -->
- <!ELEMENT bl (bi)+>
- <!ATTLIST bl %common.att;>
-
- <!-- Book item -->
- <!ELEMENT bi EMPTY>
- <!ATTLIST bi %common.att;
- %name.att;
- %title.att;
- %link.att;
- authors CDATA #REQUIRED
- date CDATA #IMPLIED>
-
-<!-- =============================================================== -->
-<!-- End of DTD -->
-<!-- =============================================================== -->
+++ /dev/null
-<!-- ===================================================================
-
- Apache Todos DTD (Version 1.1)
-
-PURPOSE:
- This DTD was developed to create a simple yet powerful document
- type for software development todo lists for use with the Apache projects.
- It is an XML-compliant DTD and it's maintained by the Apache XML
- project.
-
-TYPICAL INVOCATION:
-
- <!DOCTYPE document PUBLIC
- "-//APACHE//DTD Todo Vx.y//EN"
- "todo-vxy.dtd">
-
- where
-
- x := major version
- y := minor version
-
-NOTES:
- It is important, expecially in open developped software projects, to keep
- track of software changes that need to be done, planned features, development
- assignment, etc. in order to allow better work parallelization and create
- an entry point for people that want to help. This DTD wants to provide
- a solid foundation to provide such information and to allow it to be
- published as well as distributed in a common format.
-
-AUTHORS:
- Stefano Mazzocchi <stefano@apache.org>
-
-FIXME:
- - do we need anymore working contexts? (SM)
-
-CHANGE HISTORY:
-[Version 1.0]
- 19991129 Initial version. (SM)
- 19991225 Added actions element for better structure (SM)
-[Version 1.1]
- 20011212 Used public identifiers for external entities (SM)
-
-COPYRIGHT:
- Copyright (c) @year@ The Apache Software Foundation.
-
- Permission to copy in any form is granted provided this notice is
- included in all copies. Permission to redistribute is granted
- provided this file is distributed untouched in all its parts and
- included files.
-
-==================================================================== -->
-
-<!-- =============================================================== -->
-<!-- Include the Documentation DTD -->
-<!-- =============================================================== -->
-
-<!ENTITY % document PUBLIC
- "-//APACHE//DTD Documentation V1.1//EN"
- "document-v11.dtd">
-%document;
-
-
-<!-- =============================================================== -->
-<!-- Common entities -->
-<!-- =============================================================== -->
-
-<!ENTITY % priorities "showstopper|high|medium|low|wish|dream">
-
-<!ENTITY % contexts "build|docs|code|admin|design">
-
-<!-- =============================================================== -->
-<!-- Document Type Definition -->
-<!-- =============================================================== -->
-
-<!ELEMENT todo (devs, actions*)>
-<!ATTLIST todo %common.att;
- %title.att;>
-
- <!ELEMENT devs (person+)>
- <!ATTLIST devs %common.att;>
-
- <!ELEMENT actions (action+)>
- <!ATTLIST actions %common.att;
- priority (%priorities;) #IMPLIED>
-
- <!ELEMENT action (%content.mix;)*>
- <!ATTLIST action %common.att;
- assigned-to IDREF #IMPLIED
- context (%contexts;) #REQUIRED>
-
-<!-- =============================================================== -->
-<!-- End of DTD -->
-<!-- =============================================================== -->
*/
package org.apache.poi.hpsf;
-import java.util.*;
import org.apache.poi.util.LittleEndian;
/**
* starts
* @param length The length of the variant including the variant
* type field
+ * @param type The variant type to read
* @return A Java object that corresponds best to the variant
* field. For example, a VT_I4 is returned as a {@link Long}, a
* VT_LPSTR as a {@link String}.
* @see Variant
*/
public static Object read(final byte[] src, int offset, int length,
- final int type)
+ final int type)
{
- /*
- * FIXME: Support reading more types and clean up this code!
- */
- Object value;
- length = length - LittleEndian.INT_SIZE;
+ /*
+ * FIXME: Support reading more types and clean up this code!
+ */
+ Object value;
+ length = length - LittleEndian.INT_SIZE;
switch (type)
- {
+ {
+ case Variant.VT_EMPTY:
+ {
+ /*
+ * FIXME: The value returned by this case relies on the
+ * assumption that the value VT_EMPTY denotes consists of zero
+ * bytes. I'd be glad if some could confirm or correct this.
+ */
+ value = null;
+ break;
+ }
case Variant.VT_I2:
{
/*
* Read a byte string. In Java it is represented as a
* String object. The 0x00 bytes at the end must be
* stripped.
- *
- * FIXME: Reading an 8-bit string should pay attention
- * to the codepage. Currently the byte making out the
- * property's value are interpreted according to the
- * platform's default character set.
+ *
+ * FIXME: Reading an 8-bit string should pay attention
+ * to the codepage. Currently the byte making out the
+ * property's value are interpreted according to the
+ * platform's default character set.
*/
final int first = offset + LittleEndian.INT_SIZE;
long last = first + LittleEndian.getUInt(src, offset) - 1;
while (src[(int) last] == 0 && first <= last)
last--;
value = new String(src, (int) first, (int) (last - first + 1));
- break;
+ break;
}
case Variant.VT_LPWSTR:
{
*/
final int first = offset + LittleEndian.INT_SIZE;
long last = first + LittleEndian.getUInt(src, offset) - 1;
- long l = last - first;
+ long l = last - first;
offset += LittleEndian.INT_SIZE;
- StringBuffer b = new StringBuffer((int) (last - first));
- for (int i = 0; i <= l; i++)
- {
- final int i1 = offset + (i * 2);
- final int i2 = i1 + 1;
- b.append((char) ((src[i2] << 8) + src[i1]));
- }
- /* Strip 0x00 characters from the end of the string: */
- while (b.charAt(b.length() - 1) == 0x00)
- b.setLength(b.length() - 1);
- value = b.toString();
- break;
+ StringBuffer b = new StringBuffer((int) (last - first));
+ for (int i = 0; i <= l; i++)
+ {
+ final int i1 = offset + (i * 2);
+ final int i2 = i1 + 1;
+ b.append((char) ((src[i2] << 8) + src[i1]));
+ }
+ /* Strip 0x00 characters from the end of the string: */
+ while (b.charAt(b.length() - 1) == 0x00)
+ b.setLength(b.length() - 1);
+ value = b.toString();
+ break;
}
case Variant.VT_CF:
{
final byte[] v = new byte[length];
for (int i = 0; i < length; i++)
v[i] = src[(int) (offset + i)];
- value = v;
+ value = v;
break;
}
case Variant.VT_BOOL:
* src[offset + 3] contain the DWord for VT_BOOL, so
* skip it, we don't need it.
*/
- final int first = offset + LittleEndian.INT_SIZE;
+ // final int first = offset + LittleEndian.INT_SIZE;
long bool = LittleEndian.getUInt(src, offset);
if (bool != 0)
value = new Boolean(true);
else
value = new Boolean(false);
- break;
+ break;
}
default:
{
final byte[] v = new byte[length];
for (int i = 0; i < length; i++)
v[i] = src[(int) (offset + i)];
- value = v;
+ value = v;
break;
}
}
- return value;
+ return value;
}
}
/**
* <p>[V][P] Nothing.</p>
*/
- public final static int VT_EMPTY = 0;
+ public static final int VT_EMPTY = 0;
/**
* <p>[V][P] SQL style Null.</p>
*/
- public final static int VT_NULL = 1;
+ public static final int VT_NULL = 1;
/**
* <p>[V][T][P][S] 2 byte signed int.</p>
*/
- public final static int VT_I2 = 2;
+ public static final int VT_I2 = 2;
/**
* <p>[V][T][P][S] 4 byte signed int.</p>
*/
- public final static int VT_I4 = 3;
+ public static final int VT_I4 = 3;
/**
* <p>[V][T][P][S] 4 byte real.</p>
*/
- public final static int VT_R4 = 4;
+ public static final int VT_R4 = 4;
/**
* <p>[V][T][P][S] 8 byte real.</p>
*/
- public final static int VT_R8 = 5;
+ public static final int VT_R8 = 5;
/**
* <p>[V][T][P][S] currency. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
- public final static int VT_CY = 6;
+ public static final int VT_CY = 6;
/**
* <p>[V][T][P][S] date. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
- public final static int VT_DATE = 7;
+ public static final int VT_DATE = 7;
/**
* <p>[V][T][P][S] OLE Automation string. <span
* style="background-color: #ffff00">How long is this? How is it
* to be interpreted?</span></p>
*/
- public final static int VT_BSTR = 8;
+ public static final int VT_BSTR = 8;
/**
* <p>[V][T][P][S] IDispatch *. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
- public final static int VT_DISPATCH = 9;
+ public static final int VT_DISPATCH = 9;
/**
* <p>[V][T][S] SCODE. <span style="background-color: #ffff00">How
* long is this? How is it to be interpreted?</span></p>
*/
- public final static int VT_ERROR = 10;
+ public static final int VT_ERROR = 10;
/**
* <p>[V][T][P][S] True=-1, False=0.</p>
*/
- public final static int VT_BOOL = 11;
+ public static final int VT_BOOL = 11;
/**
* <p>[V][T][P][S] VARIANT *. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
- public final static int VT_VARIANT = 12;
+ public static final int VT_VARIANT = 12;
/**
* <p>[V][T][S] IUnknown *. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
- public final static int VT_UNKNOWN = 13;
+ public static final int VT_UNKNOWN = 13;
/**
* <p>[V][T][S] 16 byte fixed point.</p>
*/
- public final static int VT_DECIMAL = 14;
+ public static final int VT_DECIMAL = 14;
/**
* <p>[T] signed char.</p>
*/
- public final static int VT_I1 = 16;
+ public static final int VT_I1 = 16;
/**
* <p>[V][T][P][S] unsigned char.</p>
*/
- public final static int VT_UI1 = 17;
+ public static final int VT_UI1 = 17;
/**
* <p>[T][P] unsigned short.</p>
*/
- public final static int VT_UI2 = 18;
+ public static final int VT_UI2 = 18;
/**
* <p>[T][P] unsigned int.</p>
*/
- public final static int VT_UI4 = 19;
+ public static final int VT_UI4 = 19;
/**
* <p>[T][P] signed 64-bit int.</p>
*/
- public final static int VT_I8 = 20;
+ public static final int VT_I8 = 20;
/**
* <p>[T][P] unsigned 64-bit int.</p>
*/
- public final static int VT_UI8 = 21;
+ public static final int VT_UI8 = 21;
/**
* <p>[T] signed machine int.</p>
*/
- public final static int VT_INT = 22;
+ public static final int VT_INT = 22;
/**
* <p>[T] unsigned machine int.</p>
*/
- public final static int VT_UINT = 23;
+ public static final int VT_UINT = 23;
/**
* <p>[T] C style void.</p>
*/
- public final static int VT_VOID = 24;
+ public static final int VT_VOID = 24;
/**
* <p>[T] Standard return type. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
- public final static int VT_HRESULT = 25;
+ public static final int VT_HRESULT = 25;
/**
* <p>[T] pointer type. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
- public final static int VT_PTR = 26;
+ public static final int VT_PTR = 26;
/**
* <p>[T] (use VT_ARRAY in VARIANT).</p>
*/
- public final static int VT_SAFEARRAY = 27;
+ public static final int VT_SAFEARRAY = 27;
/**
* <p>[T] C style array. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
- public final static int VT_CARRAY = 28;
+ public static final int VT_CARRAY = 28;
/**
* <p>[T] user defined type. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
- public final static int VT_USERDEFINED = 29;
+ public static final int VT_USERDEFINED = 29;
/**
* <p>[T][P] null terminated string.</p>
*/
- public final static int VT_LPSTR = 30;
+ public static final int VT_LPSTR = 30;
/**
* <p>[T][P] wide (Unicode) null terminated string.</p>
*/
- public final static int VT_LPWSTR = 31;
+ public static final int VT_LPWSTR = 31;
/**
* <p>[P] FILETIME. The FILETIME structure holds a date and time
* have passed since January 1, 1601. This 64-bit value is split
* into the two dwords stored in the structure.</p>
*/
- public final static int VT_FILETIME = 64;
+ public static final int VT_FILETIME = 64;
/**
* <p>[P] Length prefixed bytes.</p>
*/
- public final static int VT_BLOB = 65;
+ public static final int VT_BLOB = 65;
/**
* <p>[P] Name of the stream follows.</p>
*/
- public final static int VT_STREAM = 66;
+ public static final int VT_STREAM = 66;
/**
* <p>[P] Name of the storage follows.</p>
*/
- public final static int VT_STORAGE = 67;
+ public static final int VT_STORAGE = 67;
/**
* <p>[P] Stream contains an object. <span
* style="background-color: #ffff00"> How long is this? How is it
* to be interpreted?</span></p>
*/
- public final static int VT_STREAMED_OBJECT = 68;
+ public static final int VT_STREAMED_OBJECT = 68;
/**
* <p>[P] Storage contains an object. <span
* style="background-color: #ffff00"> How long is this? How is it
* to be interpreted?</span></p>
*/
- public final static int VT_STORED_OBJECT = 69;
+ public static final int VT_STORED_OBJECT = 69;
/**
* <p>[P] Blob contains an object. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
- public final static int VT_BLOB_OBJECT = 70;
+ public static final int VT_BLOB_OBJECT = 70;
/**
* <p>[P] Clipboard format. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
- public final static int VT_CF = 71;
+ public static final int VT_CF = 71;
/**
* <p>[P] A Class ID.</p>
* target="_blank">
* msdn.microsoft.com/library/en-us/com/stgrstrc_0uwk.asp</a>.</p>
*/
- public final static int VT_CLSID = 72;
+ public static final int VT_CLSID = 72;
/**
* <p>[P] simple counted array. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
- public final static int VT_VECTOR = 0x1000;
+ public static final int VT_VECTOR = 0x1000;
/**
* <p>[V] SAFEARRAY*. <span style="background-color: #ffff00">How
* long is this? How is it to be interpreted?</span></p>
*/
- public final static int VT_ARRAY = 0x2000;
+ public static final int VT_ARRAY = 0x2000;
/**
* <p>[V] void* for local use. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
- public final static int VT_BYREF = 0x4000;
+ public static final int VT_BYREF = 0x4000;
- public final static int VT_RESERVED = 0x8000;
+ /**
+ * <p>FIXME: Document this!</p>
+ */
+ public static final int VT_RESERVED = 0x8000;
- public final static int VT_ILLEGAL = 0xFFFF;
+ /**
+ * <p>FIXME: Document this!</p>
+ */
+ public static final int VT_ILLEGAL = 0xFFFF;
- public final static int VT_ILLEGALMASKED = 0xFFF;
+ /**
+ * <p>FIXME: Document this!</p>
+ */
+ public static final int VT_ILLEGALMASKED = 0xFFF;
- public final static int VT_TYPEMASK = 0xFFF;
+ /**
+ * <p>FIXME: Document this!</p>
+ */
+ public static final int VT_TYPEMASK = 0xFFF;
-}
+}
\ No newline at end of file
protected HeaderRecord header = null;
protected FooterRecord footer = null;
protected PrintGridlinesRecord printGridlines = null;
+ protected WindowTwoRecord windowTwo = null;
protected MergeCellsRecord merged = null;
+ protected Margin margins[] = null;
protected ArrayList mergedRecords = new ArrayList();
protected ArrayList mergedLocs = new ArrayList();
protected int numMergedRegions = 0;
{
retval.printGridlines = (PrintGridlinesRecord) rec;
}
- else if ( rec.getSid() == HeaderRecord.sid )
+ else if ( rec.getSid() == HeaderRecord.sid && bofEofNestingLevel == 1)
{
retval.header = (HeaderRecord) rec;
}
- else if ( rec.getSid() == FooterRecord.sid )
+ else if ( rec.getSid() == FooterRecord.sid && bofEofNestingLevel == 1)
{
retval.footer = (FooterRecord) rec;
}
- else if ( rec.getSid() == PrintSetupRecord.sid )
+ else if ( rec.getSid() == PrintSetupRecord.sid && bofEofNestingLevel == 1)
{
retval.printSetup = (PrintSetupRecord) rec;
}
+ else if ( rec.getSid() == LeftMarginRecord.sid)
+ {
+ retval.getMargins()[LeftMargin] = (LeftMarginRecord) rec;
+ }
+ else if ( rec.getSid() == RightMarginRecord.sid)
+ {
+ retval.getMargins()[RightMargin] = (RightMarginRecord) rec;
+ }
+ else if ( rec.getSid() == TopMarginRecord.sid)
+ {
+ retval.getMargins()[TopMargin] = (TopMarginRecord) rec;
+ }
+ else if ( rec.getSid() == BottomMarginRecord.sid)
+ {
+ retval.getMargins()[BottomMargin] = (BottomMarginRecord) rec;
+ }
else if ( rec.getSid() == SelectionRecord.sid )
{
retval.selection = (SelectionRecord) rec;
}
+ else if ( rec.getSid() == WindowTwoRecord.sid )
+ {
+ retval.windowTwo = (WindowTwoRecord) rec;
+ }
if (rec != null)
{
retval.dims = ( DimensionsRecord ) retval.createDimensions();
retval.dimsloc = 19;
records.add(retval.dims);
- records.add(retval.createWindowTwo());
+ records.add(retval.windowTwo = retval.createWindowTwo());
retval.setLoc(records.size() - 1);
retval.selection =
(SelectionRecord) retval.createSelection();
numMergedRegions--;
if (rec.getNumAreas() == 0)
{
- mergedRecords.remove(pos);
- if (merged == rec)
- merged = (MergeCellsRecord) mergedRecords.get(mergedRecords.size() - 1);
+ mergedRecords.remove(pos);
+ if (merged == rec) {
+ //pull up the LAST record for operations when we finally
+ //support continue records for mergedRegions
+ if (mergedRecords.size() > 0) {
+ merged = (MergeCellsRecord) mergedRecords.get(mergedRecords.size() - 1);
+ } else {
+ merged = null;
+ }
+ }
+
int removePos = ((Integer) mergedLocs.get(pos)).intValue();
records.remove(removePos);
mergedLocs.remove(pos);
+
}
}
* @return record containing a WindowTwoRecord
*/
- protected Record createWindowTwo()
+ protected WindowTwoRecord createWindowTwo()
{
WindowTwoRecord retval = new WindowTwoRecord();
* @param sel True to select the sheet, false otherwise.
*/
public void setSelected(boolean sel) {
- WindowTwoRecord windowTwo = (WindowTwoRecord) findFirstRecordBySid(WindowTwoRecord.sid);
windowTwo.setSelected(sel);
}
* @param margin which margin to get
* @return the size of the margin
*/
- public double getMargin(short margin) {
- Margin m;
- switch ( margin )
- {
- case LeftMargin:
- m = (Margin) findFirstRecordBySid( LeftMarginRecord.sid );
- if ( m == null )
- return .75;
- break;
- case RightMargin:
- m = (Margin) findFirstRecordBySid( RightMarginRecord.sid );
- if ( m == null )
- return .75;
- break;
- case TopMargin:
- m = (Margin) findFirstRecordBySid( TopMarginRecord.sid );
- if ( m == null )
- return 1.0;
- break;
- case BottomMargin:
- m = (Margin) findFirstRecordBySid( BottomMarginRecord.sid );
- if ( m == null )
- return 1.0;
- break;
- default :
- throw new RuntimeException( "Unknown margin constant: " + margin );
- }
- return m.getMargin();
- }
+ public double getMargin(short margin) {
+ if (getMargins()[margin] != null)
+ return margins[margin].getMargin();
+ else {
+ switch ( margin )
+ {
+ case LeftMargin:
+ return .75;
+ case RightMargin:
+ return .75;
+ case TopMargin:
+ return 1.0;
+ case BottomMargin:
+ return 1.0;
+ default :
+ throw new RuntimeException( "Unknown margin constant: " + margin );
+ }
+ }
+ }
/**
* Sets the size of the margin in inches.
* @param margin which margin to get
* @param size the size of the margin
*/
- public void setMargin(short margin, double size) {
- Margin m;
- switch ( margin )
- {
- case LeftMargin:
- m = (Margin) findFirstRecordBySid( LeftMarginRecord.sid );
- if ( m == null )
- {
- m = new LeftMarginRecord();
- records.add( getDimsLoc() + 1, m );
- }
- break;
- case RightMargin:
- m = (Margin) findFirstRecordBySid( RightMarginRecord.sid );
- if ( m == null )
- {
- m = new RightMarginRecord();
- records.add( getDimsLoc() + 1, m );
- }
- break;
- case TopMargin:
- m = (Margin) findFirstRecordBySid( TopMarginRecord.sid );
- if ( m == null )
- {
- m = new TopMarginRecord();
- records.add( getDimsLoc() + 1, m );
- }
- break;
- case BottomMargin:
- m = (Margin) findFirstRecordBySid( BottomMarginRecord.sid );
- if ( m == null )
- {
- m = new BottomMarginRecord();
- records.add( getDimsLoc() + 1, m );
- }
- break;
- default :
- throw new RuntimeException( "Unknown margin constant: " + margin );
- }
- m.setMargin( size );
- }
+ public void setMargin(short margin, double size) {
+ Margin m = getMargins()[margin];
+ if (m == null) {
+ switch ( margin )
+ {
+ case LeftMargin:
+ m = new LeftMarginRecord();
+ records.add( getDimsLoc() + 1, m );
+ break;
+ case RightMargin:
+ m = new RightMarginRecord();
+ records.add( getDimsLoc() + 1, m );
+ break;
+ case TopMargin:
+ m = new TopMarginRecord();
+ records.add( getDimsLoc() + 1, m );
+ break;
+ case BottomMargin:
+ m = new BottomMarginRecord();
+ records.add( getDimsLoc() + 1, m );
+ break;
+ default :
+ throw new RuntimeException( "Unknown margin constant: " + margin );
+ }
+ margins[margin] = m;
+ }
+ m.setMargin( size );
+ }
public int getEofLoc()
{
}
records.add(loc+1, pane);
- WindowTwoRecord windowRecord = (WindowTwoRecord) records.get(loc);
- windowRecord.setFreezePanes(true);
- windowRecord.setFreezePanesNoSplit(true);
+ windowTwo.setFreezePanes(true);
+ windowTwo.setFreezePanesNoSplit(true);
SelectionRecord sel = (SelectionRecord) findFirstRecordBySid(SelectionRecord.sid);
// SelectionRecord sel2 = (SelectionRecord) sel.clone();
r.setActivePane((short) activePane);
records.add(loc+1, r);
- WindowTwoRecord windowRecord = (WindowTwoRecord) records.get(loc);
- windowRecord.setFreezePanes(false);
- windowRecord.setFreezePanesNoSplit(false);
+ windowTwo.setFreezePanes(false);
+ windowTwo.setFreezePanesNoSplit(false);
SelectionRecord sel = (SelectionRecord) findFirstRecordBySid(SelectionRecord.sid);
// SelectionRecord sel2 = (SelectionRecord) sel.clone();
this.selection = selection;
}
+ /**
+ * Sets whether the gridlines are shown in a viewer.
+ * @param show whether to show gridlines or not
+ */
+ public void setDisplayGridlines(boolean show) {
+ windowTwo.setDisplayGridlines(show);
+ }
+
+ /**
+ * Returns if gridlines are displayed.
+ * @return whether gridlines are displayed
+ */
+ public boolean isDisplayGridlines() {
+ return windowTwo.getDisplayGridlines();
+ }
+
+ /**
+ * Sets whether the formulas are shown in a viewer.
+ * @param show whether to show formulas or not
+ */
+ public void setDisplayFormulas(boolean show) {
+ windowTwo.setDisplayFormulas(show);
+ }
+
+ /**
+ * Returns if formulas are displayed.
+ * @return whether formulas are displayed
+ */
+ public boolean isDisplayFormulas() {
+ return windowTwo.getDisplayFormulas();
+ }
+
+ /**
+ * Sets whether the RowColHeadings are shown in a viewer.
+ * @param show whether to show RowColHeadings or not
+ */
+ public void setDisplayRowColHeadings(boolean show) {
+ windowTwo.setDisplayRowColHeadings(show);
+ }
+
+ /**
+ * Returns if RowColHeadings are displayed.
+ * @return whether RowColHeadings are displayed
+ */
+ public boolean isDisplayRowColHeadings() {
+ return windowTwo.getDisplayRowColHeadings();
+ }
+
+ /**
+ * Returns the array of margins. If not created, will create.
+ *
+ * @return the array of marings.
+ */
+ protected Margin[] getMargins() {
+ if (margins == null)
+ margins = new Margin[4];
+ return margins;
+ }
}
for (int k = 0; k < boundsheets.size(); k++) {
String sheet = getSheetName(k);
- if (sheet.equals(name)) {
+ if (sheet.equalsIgnoreCase(name)) {
retval = k;
break;
}
*
* @return byte array containing the HSSF-only portions of the POIFS file.
*/
-
- public byte [] serialize() {
- log.log(DEBUG, "Serializing Workbook!");
- byte[] retval = null;
-
- // ArrayList bytes = new ArrayList(records.size());
- int arraysize = getSize();
- int pos = 0;
-
- // for (int k = 0; k < records.size(); k++)
- // {
- // bytes.add((( Record ) records.get(k)).serialize());
- // }
- // for (int k = 0; k < bytes.size(); k++)
- // {
- // arraysize += (( byte [] ) bytes.get(k)).length;
- // }
- retval = new byte[ arraysize ];
- for (int k = 0; k < records.size(); k++) {
-
- // byte[] rec = (( byte [] ) bytes.get(k));
- // System.arraycopy(rec, 0, retval, pos, rec.length);
- Record record = records.get(k);
- // Let's skip RECALCID records, as they are only use for optimization
- if(record.getSid() != RecalcIdRecord.sid || ((RecalcIdRecord)record).isNeeded()) {
- pos += record.serialize(pos, retval); // rec.length;
- }
- }
- log.log(DEBUG, "Exiting serialize workbook");
- return retval;
- }
+ // GJS: Not used so why keep it.
+// public byte [] serialize() {
+// log.log(DEBUG, "Serializing Workbook!");
+// byte[] retval = null;
+//
+//// ArrayList bytes = new ArrayList(records.size());
+// int arraysize = getSize();
+// int pos = 0;
+//
+// retval = new byte[ arraysize ];
+// for (int k = 0; k < records.size(); k++) {
+//
+// Record record = records.get(k);
+//// Let's skip RECALCID records, as they are only use for optimization
+// if(record.getSid() != RecalcIdRecord.sid || ((RecalcIdRecord)record).isNeeded()) {
+// pos += record.serialize(pos, retval); // rec.length;
+// }
+// }
+// log.log(DEBUG, "Exiting serialize workbook");
+// return retval;
+// }
/**
* Serializes all records int the worksheet section into a big byte array. Use
* @param data array of bytes to write this to
*/
- public int serialize(int offset, byte [] data) {
- log.log(DEBUG, "Serializing Workbook with offsets");
+ public int serialize( int offset, byte[] data )
+ {
+ log.log( DEBUG, "Serializing Workbook with offsets" );
- // ArrayList bytes = new ArrayList(records.size());
- // int arraysize = getSize(); // 0;
- int pos = 0;
+ int pos = 0;
- // for (int k = 0; k < records.size(); k++)
- // {
- // bytes.add((( Record ) records.get(k)).serialize());
- //
- // }
- // for (int k = 0; k < bytes.size(); k++)
- // {
- // arraysize += (( byte [] ) bytes.get(k)).length;
- // }
- for (int k = 0; k < records.size(); k++) {
+ SSTRecord sst = null;
+ int sstPos = 0;
+ for ( int k = 0; k < records.size(); k++ )
+ {
- // byte[] rec = (( byte [] ) bytes.get(k));
- // System.arraycopy(rec, 0, data, offset + pos, rec.length);
- Record record = records.get(k);
+ Record record = records.get( k );
// Let's skip RECALCID records, as they are only use for optimization
- if(record.getSid() != RecalcIdRecord.sid || ((RecalcIdRecord)record).isNeeded()) {
- pos += record.serialize(pos + offset, data); // rec.length;
+ if ( record.getSid() != RecalcIdRecord.sid || ( (RecalcIdRecord) record ).isNeeded() )
+ {
+ if (record instanceof SSTRecord)
+ {
+ sst = (SSTRecord)record;
+ sstPos = pos;
+ }
+ if (record.getSid() == ExtSSTRecord.sid && sst != null)
+ {
+ record = sst.createExtSSTRecord(sstPos + offset);
+ }
+ pos += record.serialize( pos + offset, data ); // rec.length;
}
}
- log.log(DEBUG, "Exiting serialize workbook");
+ log.log( DEBUG, "Exiting serialize workbook" );
return pos;
}
- public int getSize() {
+ public int getSize()
+ {
int retval = 0;
- for (int k = 0; k < records.size(); k++) {
- Record record = records.get(k);
+ SSTRecord sst = null;
+ for ( int k = 0; k < records.size(); k++ )
+ {
+ Record record = records.get( k );
// Let's skip RECALCID records, as they are only use for optimization
- if(record.getSid() != RecalcIdRecord.sid || ((RecalcIdRecord)record).isNeeded()) {
- retval += record.getRecordSize();
+ if ( record.getSid() != RecalcIdRecord.sid || ( (RecalcIdRecord) record ).isNeeded() )
+ {
+ if (record instanceof SSTRecord)
+ sst = (SSTRecord)record;
+ if (record.getSid() == ExtSSTRecord.sid && sst != null)
+ retval += sst.calcExtSSTRecordSize();
+ else
+ retval += record.getRecordSize();
}
}
return retval;
}
public SheetReferences getSheetReferences() {
- SheetReferences refs = new SheetReferences();
-
- if (externSheet != null) {
- for (int k = 0; k < externSheet.getNumOfREFStructures(); k++) {
- String sheetName = findSheetNameFromExternSheet((short)k);
- refs.addSheetReference(sheetName, k);
- }
- }
- return refs;
+ SheetReferences refs = new SheetReferences();
+
+ if (externSheet != null) {
+ for (int k = 0; k < externSheet.getNumOfREFStructures(); k++) {
+
+ String sheetName = findSheetNameFromExternSheet((short)k);
+ refs.addSheetReference(sheetName, k);
+
+ }
+ }
+ return refs;
}
/** finds the sheet name by his extern sheet index
* @return sheet name
*/
public String findSheetNameFromExternSheet(short num){
- String result;
+ String result="";
short indexToSheet = externSheet.getREFRecordAt(num).getIndexToFirstSupBook();
- result = getSheetName(indexToSheet);
+ if (indexToSheet>-1) { //error check, bail out gracefully!
+ result = getSheetName(indexToSheet);
+ }
return result;
}
-/* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" and * "Apache POI" must not be used to endorse or promote products * derived from this software without prior written permission. For * written permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * "Apache POI", nor may "Apache" appear in their name, without * prior written permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */package org.apache.poi.hssf.record;import org.apache.poi.util.*;/** * Record for the bottom margin. * NOTE: This source was automatically generated. * @author Shawn Laubach (slaubach at apache dot org) */public class BottomMarginRecord extends Record implements Margin{ public final static short sid = 0x29; private double field_1_margin; public BottomMarginRecord() { } /** * Constructs a BottomMargin record and sets its fields appropriately. * * @param id id must be 0x29 or an exception * will be throw upon validation * @param size size the size of the data area of the record * @param data data of the record (should not contain sid/len) */ public BottomMarginRecord(short id, short size, byte [] data) { super(id, size, data); } /** * Constructs a BottomMargin record and sets its fields appropriately. * * @param id id must be 0x29 or an exception * will be throw upon validation * @param size size the size of the data area of the record * @param data data of the record (should not contain sid/len) * @param offset of the record's data */ public BottomMarginRecord(short id, short size, byte [] data, int offset) { super(id, size, data, offset); } /** * Checks the sid matches the expected side for this record * * @param id the expected sid. */ protected void validateSid(short id) { if (id != sid) { throw new RecordFormatException("Not a BottomMargin record"); } } protected void fillFields(byte [] data, short size, int offset) { field_1_margin = LittleEndian.getDouble(data, 0x0 + offset); } public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("[BottomMargin]\n"); buffer.append(" .margin = ") .append(" (").append(getMargin()).append(" )\n"); buffer.append("[/BottomMargin]\n"); return buffer.toString(); } public int serialize(int offset, byte[] data) { LittleEndian.putShort(data, 0 + offset, sid); LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4)); LittleEndian.putDouble(data, 4 + offset, field_1_margin); return getRecordSize(); } /** * Size of record (exluding 4 byte header) */ public int getRecordSize() { return 4 + 8; } public short getSid() { return this.sid; } /** * Get the margin field for the BottomMargin record. */ public double getMargin() { return field_1_margin; } /** * Set the margin field for the BottomMargin record. */ public void setMargin(double field_1_margin) { this.field_1_margin = field_1_margin; } public Object clone() { BottomMarginRecord rec = new BottomMarginRecord(); rec.field_1_margin = this.field_1_margin; return rec; }} // END OF CLASS
\ No newline at end of file
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hssf.record;
+
+
+
+import org.apache.poi.util.*;
+
+/**
+ * Record for the bottom margin.
+ * NOTE: This source was automatically generated.
+ * @author Shawn Laubach (slaubach at apache dot org)
+ */
+public class BottomMarginRecord
+ extends Record implements Margin
+{
+ public final static short sid = 0x29;
+ private double field_1_margin;
+
+
+ public BottomMarginRecord()
+ {
+
+ }
+
+ /**
+ * Constructs a BottomMargin record and sets its fields appropriately.
+ *
+ * @param id id must be 0x29 or an exception
+ * will be throw upon validation
+ * @param size size the size of the data area of the record
+ * @param data data of the record (should not contain sid/len)
+ */
+
+ public BottomMarginRecord(short id, short size, byte [] data)
+ {
+ super(id, size, data);
+ }
+
+ /**
+ * Constructs a BottomMargin record and sets its fields appropriately.
+ *
+ * @param id id must be 0x29 or an exception
+ * will be throw upon validation
+ * @param size size the size of the data area of the record
+ * @param data data of the record (should not contain sid/len)
+ * @param offset of the record's data
+ */
+
+ public BottomMarginRecord(short id, short size, byte [] data, int offset)
+ {
+ super(id, size, data, offset);
+ }
+
+ /**
+ * Checks the sid matches the expected side for this record
+ *
+ * @param id the expected sid.
+ */
+ protected void validateSid(short id)
+ {
+ if (id != sid)
+ {
+ throw new RecordFormatException("Not a BottomMargin record");
+ }
+ }
+
+ protected void fillFields(byte [] data, short size, int offset)
+ {
+ field_1_margin = LittleEndian.getDouble(data, 0x0 + offset);
+
+ }
+
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+
+ buffer.append("[BottomMargin]\n");
+
+ buffer.append(" .margin = ")
+ .append(" (").append(getMargin()).append(" )\n");
+
+ buffer.append("[/BottomMargin]\n");
+ return buffer.toString();
+ }
+
+ public int serialize(int offset, byte[] data)
+ {
+ LittleEndian.putShort(data, 0 + offset, sid);
+ LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
+
+ LittleEndian.putDouble(data, 4 + offset, field_1_margin);
+
+ return getRecordSize();
+ }
+
+ /**
+ * Size of record (exluding 4 byte header)
+ */
+ public int getRecordSize()
+ {
+ return 4 + 8;
+ }
+
+ public short getSid()
+ {
+ return this.sid;
+ }
+
+
+ /**
+ * Get the margin field for the BottomMargin record.
+ */
+ public double getMargin()
+ {
+ return field_1_margin;
+ }
+
+ /**
+ * Set the margin field for the BottomMargin record.
+ */
+ public void setMargin(double field_1_margin)
+ {
+ this.field_1_margin = field_1_margin;
+ }
+
+ public Object clone() {
+ BottomMarginRecord rec = new BottomMarginRecord();
+ rec.field_1_margin = this.field_1_margin;
+ return rec;
+ }
+
+
+} // END OF CLASS
\ No newline at end of file
protected void fillFields(byte [] ignored_parm1, short ignored_parm2, int ignored_parm3)
{
}
+
+ /**
+ * Clone this record.
+ */
+ public Object clone() {
+ ContinueRecord clone = new ContinueRecord();
+ clone.setData(field_1_data);
+ return clone;
+ }
+
}
field_1_stream_pos = pos;
}
- public void setBucketSSTOffset(short offset)
+ public void setBucketRecordOffset(short offset)
{
field_2_bucket_sst_offset = offset;
}
public short getSid()
{
- return this.sid;
+ return sid;
}
}
private short field_1_strings_per_bucket;
private ArrayList field_2_sst_info;
+
public ExtSSTRecord()
{
field_2_sst_info = new ArrayList();
public int serialize(int offset, byte [] data)
{
LittleEndian.putShort(data, 0 + offset, sid);
-
-// LittleEndian.putShort(data,2,(short)(2 + (getNumInfoRecords() *8)));
- LittleEndian.putShort(data, 2 + offset, ( short ) (2 + (0x3fa - 2)));
- int pos = 4;
+ LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
+ LittleEndian.putShort(data, 4 + offset, field_1_strings_per_bucket);
+ int pos = 6;
for (int k = 0; k < getNumInfoRecords(); k++)
{
System.arraycopy(getInfoRecordAt(k).serialize(), 0, data,
pos + offset, 8);
+ pos += getInfoRecordAt(k).getRecordSize();
}
return getRecordSize();
}
public int getRecordSize()
{
- return 6 + 0x3fa - 2;
+ return 4 + 2 + field_2_sst_info.size() * 8;
}
public short getSid()
{
- return this.sid;
+ return sid;
+ }
+
+ public void setBucketOffsets( int[] bucketAbsoluteOffsets, int[] bucketRelativeOffsets )
+ {
+ this.field_2_sst_info = new ArrayList(bucketAbsoluteOffsets.length);
+ for ( int i = 0; i < bucketAbsoluteOffsets.length; i++ )
+ {
+ ExtSSTInfoSubRecord r = new ExtSSTInfoSubRecord();
+ r.setBucketRecordOffset((short)bucketRelativeOffsets[i]);
+ r.setStreamPos(bucketAbsoluteOffsets[i]);
+ field_2_sst_info.add(r);
+ }
}
+
}
-/* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" and * "Apache POI" must not be used to endorse or promote products * derived from this software without prior written permission. For * written permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * "Apache POI", nor may "Apache" appear in their name, without * prior written permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */package org.apache.poi.hssf.record;import org.apache.poi.util.LittleEndian;import java.util.ArrayList;/** * Title: Extern Sheet <P> * Description: A List of Inndexes to SupBook <P> * REFERENCE: <P> * @author Libin Roman (Vista Portal LDT. Developer) * @version 1.0-pre */public class ExternSheetRecord extends Record { public final static short sid = 0x17; private short field_1_number_of_REF_sturcutres; private ArrayList field_2_REF_structures; public ExternSheetRecord() { field_2_REF_structures = new ArrayList(); } /** * Constructs a Extern Sheet record and sets its fields appropriately. * * @param id id must be 0x16 or an exception will be throw upon validation * @param size the size of the data area of the record * @param data data of the record (should not contain sid/len) */ public ExternSheetRecord(short id, short size, byte[] data) { super(id, size, data); } /** * Constructs a Extern Sheet record and sets its fields appropriately. * * @param id id must be 0x16 or an exception will be throw upon validation * @param size the size of the data area of the record * @param data data of the record (should not contain sid/len) * @param offset of the record's data */ public ExternSheetRecord(short id, short size, byte[] data, int offset) { super(id, size, data, offset); } /** * called by constructor, should throw runtime exception in the event of a * record passed with a differing ID. * * @param id alleged id for this record */ protected void validateSid(short id) { if (id != sid) { throw new RecordFormatException("NOT An ExternSheet RECORD"); } } /** * called by the constructor, should set class level fields. Should throw * runtime exception for bad/icomplete data. * * @param data raw data * @param size size of data * @param offset of the record's data (provided a big array of the file) */ protected void fillFields(byte [] data, short size, int offset) { field_2_REF_structures = new ArrayList(); field_1_number_of_REF_sturcutres = LittleEndian.getShort(data, 0 + offset); int pos = 2 + offset; for (int i = 0 ; i < field_1_number_of_REF_sturcutres ; ++i) { ExternSheetSubRecord rec = new ExternSheetSubRecord((short)0, (short)6 , data , pos); pos += 6; field_2_REF_structures.add( rec); } } /** * sets the number of the REF structors , that is in Excel file * @param numStruct number of REF structs */ public void setNumOfREFStructures(short numStruct) { field_1_number_of_REF_sturcutres = numStruct; } /** * return the number of the REF structors , that is in Excel file * @return number of REF structs */ public short getNumOfREFStructures() { return field_1_number_of_REF_sturcutres; } /** * adds REF struct (ExternSheetSubRecord) * @param rec REF struct */ public void addREFRecord(ExternSheetSubRecord rec) { field_2_REF_structures.add(rec); } /** returns the number of REF Records, which is in model * @return number of REF records */ public int getNumOfREFRecords() { return field_2_REF_structures.size(); } /** returns the REF record (ExternSheetSubRecord) * @param elem index to place * @return REF record */ public ExternSheetSubRecord getREFRecordAt(int elem) { ExternSheetSubRecord result = ( ExternSheetSubRecord ) field_2_REF_structures.get(elem); return result; } public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("[EXTERNSHEET]\n"); buffer.append(" numOfRefs = ").append(getNumOfREFStructures()).append("\n"); for (int k=0; k < this.getNumOfREFRecords(); k++) { buffer.append("refrec #").append(k).append('\n'); buffer.append(getREFRecordAt(k).toString()); buffer.append("----refrec #").append(k).append('\n'); } buffer.append("[/EXTERNSHEET]\n"); return buffer.toString(); } /** * called by the class that is responsible for writing this sucker. * Subclasses should implement this so that their data is passed back in a * byte array. * * @param offset to begin writing at * @param data byte array containing instance data * @return number of bytes written */ public int serialize(int offset, byte [] data) { LittleEndian.putShort(data, 0 + offset, sid); LittleEndian.putShort(data, 2 + offset,(short)(2 + (getNumOfREFRecords() *6))); LittleEndian.putShort(data, 4 + offset, getNumOfREFStructures()); int pos = 6 ; for (int k = 0; k < getNumOfREFRecords(); k++) { ExternSheetSubRecord record = getREFRecordAt(k); System.arraycopy(record.serialize(), 0, data, pos + offset, 6); pos +=6; } return getRecordSize(); } public int getRecordSize() { return 4 + 2 + getNumOfREFRecords() * 6; } /** * return the non static version of the id for this record. */ public short getSid() { return this.sid; }}
\ No newline at end of file
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+package org.apache.poi.hssf.record;
+
+import org.apache.poi.util.LittleEndian;
+
+import java.util.ArrayList;
+
+/**
+ * Title: Extern Sheet <P>
+ * Description: A List of Inndexes to SupBook <P>
+ * REFERENCE: <P>
+ * @author Libin Roman (Vista Portal LDT. Developer)
+ * @version 1.0-pre
+ */
+
+public class ExternSheetRecord extends Record {
+ public final static short sid = 0x17;
+ private short field_1_number_of_REF_sturcutres;
+ private ArrayList field_2_REF_structures;
+
+ public ExternSheetRecord() {
+ field_2_REF_structures = new ArrayList();
+ }
+
+ /**
+ * Constructs a Extern Sheet record and sets its fields appropriately.
+ *
+ * @param id id must be 0x16 or an exception will be throw upon validation
+ * @param size the size of the data area of the record
+ * @param data data of the record (should not contain sid/len)
+ */
+
+ public ExternSheetRecord(short id, short size, byte[] data) {
+ super(id, size, data);
+ }
+
+ /**
+ * Constructs a Extern Sheet record and sets its fields appropriately.
+ *
+ * @param id id must be 0x16 or an exception will be throw upon validation
+ * @param size the size of the data area of the record
+ * @param data data of the record (should not contain sid/len)
+ * @param offset of the record's data
+ */
+ public ExternSheetRecord(short id, short size, byte[] data, int offset) {
+ super(id, size, data, offset);
+ }
+
+ /**
+ * called by constructor, should throw runtime exception in the event of a
+ * record passed with a differing ID.
+ *
+ * @param id alleged id for this record
+ */
+ protected void validateSid(short id) {
+ if (id != sid) {
+ throw new RecordFormatException("NOT An ExternSheet RECORD");
+ }
+ }
+
+ /**
+ * called by the constructor, should set class level fields. Should throw
+ * runtime exception for bad/icomplete data.
+ *
+ * @param data raw data
+ * @param size size of data
+ * @param offset of the record's data (provided a big array of the file)
+ */
+ protected void fillFields(byte [] data, short size, int offset) {
+ field_2_REF_structures = new ArrayList();
+
+ field_1_number_of_REF_sturcutres = LittleEndian.getShort(data, 0 + offset);
+
+ int pos = 2 + offset;
+ for (int i = 0 ; i < field_1_number_of_REF_sturcutres ; ++i) {
+ ExternSheetSubRecord rec = new ExternSheetSubRecord((short)0, (short)6 , data , pos);
+
+ pos += 6;
+
+ field_2_REF_structures.add( rec);
+ }
+ }
+
+ /**
+ * sets the number of the REF structors , that is in Excel file
+ * @param numStruct number of REF structs
+ */
+ public void setNumOfREFStructures(short numStruct) {
+ field_1_number_of_REF_sturcutres = numStruct;
+ }
+
+ /**
+ * return the number of the REF structors , that is in Excel file
+ * @return number of REF structs
+ */
+ public short getNumOfREFStructures() {
+ return field_1_number_of_REF_sturcutres;
+ }
+
+ /**
+ * adds REF struct (ExternSheetSubRecord)
+ * @param rec REF struct
+ */
+ public void addREFRecord(ExternSheetSubRecord rec) {
+ field_2_REF_structures.add(rec);
+ }
+
+ /** returns the number of REF Records, which is in model
+ * @return number of REF records
+ */
+ public int getNumOfREFRecords() {
+ return field_2_REF_structures.size();
+ }
+
+ /** returns the REF record (ExternSheetSubRecord)
+ * @param elem index to place
+ * @return REF record
+ */
+ public ExternSheetSubRecord getREFRecordAt(int elem) {
+ ExternSheetSubRecord result = ( ExternSheetSubRecord ) field_2_REF_structures.get(elem);
+
+ return result;
+ }
+
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+
+ buffer.append("[EXTERNSHEET]\n");
+ buffer.append(" numOfRefs = ").append(getNumOfREFStructures()).append("\n");
+ for (int k=0; k < this.getNumOfREFRecords(); k++) {
+ buffer.append("refrec #").append(k).append('\n');
+ buffer.append(getREFRecordAt(k).toString());
+ buffer.append("----refrec #").append(k).append('\n');
+ }
+ buffer.append("[/EXTERNSHEET]\n");
+
+
+ return buffer.toString();
+ }
+
+ /**
+ * called by the class that is responsible for writing this sucker.
+ * Subclasses should implement this so that their data is passed back in a
+ * byte array.
+ *
+ * @param offset to begin writing at
+ * @param data byte array containing instance data
+ * @return number of bytes written
+ */
+ public int serialize(int offset, byte [] data) {
+ LittleEndian.putShort(data, 0 + offset, sid);
+ LittleEndian.putShort(data, 2 + offset,(short)(2 + (getNumOfREFRecords() *6)));
+
+ LittleEndian.putShort(data, 4 + offset, getNumOfREFStructures());
+
+ int pos = 6 ;
+
+ for (int k = 0; k < getNumOfREFRecords(); k++) {
+ ExternSheetSubRecord record = getREFRecordAt(k);
+ System.arraycopy(record.serialize(), 0, data, pos + offset, 6);
+
+ pos +=6;
+ }
+ return getRecordSize();
+ }
+
+ public int getRecordSize() {
+ return 4 + 2 + getNumOfREFRecords() * 6;
+ }
+
+ /**
+ * return the non static version of the id for this record.
+ */
+ public short getSid() {
+ return this.sid;
+ }
+}
.append("\n");
buffer.append(" .xf = ")
.append(Integer.toHexString(getXFIndex())).append("\n");
- buffer.append(" .value = ").append(getValue())
- .append("\n");
+ if (Double.isNaN(this.getValue()) && value_data != null)
+ buffer.append(" .value (NaN) = ")
+ .append(org.apache.poi.util.HexDump.dump(value_data,0,0))
+ .append("\n");
+ else
+ buffer.append(" .value = ").append(getValue())
+ .append("\n");
buffer.append(" .options = ").append(getOptions())
.append("\n");
buffer.append(" .zero = ").append(field_6_zero)
if (field_8_parsed_expr != null)
size = field_8_parsed_expr.size();
for (int i=0; i< size; i++) {
- Ptg ptg = (Ptg)((Ptg)field_8_parsed_expr.get(i)).clone();
- rec.field_8_parsed_expr.set(i, ptg);
+ Ptg ptg = (Ptg)((Ptg)field_8_parsed_expr.get(i)).clone();
+ rec.field_8_parsed_expr.add(i, ptg);
}
+ rec.value_data = value_data;
rec.all_data = all_data;
return rec;
}
pos += ptg.getSize();
sizeCounter += ptg.getSize();
stack.push(ptg);
+ field_13_raw_name_definition=new byte[size];
+ System.arraycopy(data,offset,field_13_raw_name_definition,0,size);
}
} catch (java.lang.UnsupportedOperationException uoe) {
System.err.println("[WARNING] Unknown Ptg "
.append("\n");
buffer.append(" .unused = ").append( field_5_index_to_sheet )
.append("\n");
- buffer.append(" .( 0 = Global name, otherwise index to sheet (one-based) ) = ").append( field_6_equals_to_index_to_sheet )
+ buffer.append(" .index to sheet (1-based, 0=Global) = ").append( field_6_equals_to_index_to_sheet )
.append("\n");
buffer.append(" .Length of menu text (character count) = ").append( field_7_length_custom_menu )
.append("\n");
.append("\n");
buffer.append(" .Status bar text (Unicode string without length field) = ").append( field_17_status_bar_text )
.append("\n");
+ buffer.append(org.apache.poi.util.HexDump.dump(this.field_13_raw_name_definition,0,0));
buffer.append("[/NAME]\n");
return buffer.toString();
{
return this.sid;
}
+
+ /**
+ * Clone this record.
+ */
+ public Object clone() {
+ PasswordRecord clone = new PasswordRecord();
+ clone.setPassword(field_1_password);
+ return clone;
+ }
+
}
public abstract class Record
{
- /**
- * The static ID, subclasses should override this value with the id for the
- * record type they handle.
- */
-
- public short sid = 0;
- private short id = 0;
- private short size = 0;
- private byte[] data = null;
-
/**
* instantiates a blank record strictly for ID matching
*/
public Record(short id, short size, byte [] data)
{
- this.id = id;
- this.size = size;
- this.data = data;
validateSid(id);
fillFields(data, size);
}
public Record(short id, short size, byte [] data, int offset)
{
- this.id = id;
- this.size = size;
- this.data = data;
validateSid(id);
fillFields(data, size, offset);
}
recordOffset += amount;
available -= amount;
}
+
+ public int getRecordOffset()
+ {
+ return recordOffset;
+ }
}
import java.util.Iterator;
import java.util.List;
-import java.util.ArrayList;
/**
* Title: Static String Table Record
* @author Andrew C. Oliver (acoliver at apache dot org)
* @author Marc Johnson (mjohnson at apache dot org)
* @author Glen Stampoultzis (glens at apache.org)
- * @version 2.0-pre
+ *
* @see org.apache.poi.hssf.record.LabelSSTRecord
* @see org.apache.poi.hssf.record.ContinueRecord
*/
private List _record_lengths = null;
private SSTDeserializer deserializer;
+ /** Offsets from the beginning of the SST record (even across continuations) */
+ int[] bucketAbsoluteOffsets;
+ /** Offsets relative the start of the current SST or continue record */
+ int[] bucketRelativeOffsets;
+
/**
* default constructor
*/
-
public SSTRecord()
{
field_1_num_strings = 0;
field_1_num_strings++;
String str = ( string == null ) ? ""
: string;
- int rval = -1;
+ int rval;
UnicodeString ucs = new UnicodeString();
ucs.setString( str );
for ( int k = 0; k < field_3_strings.size(); k++ )
{
buffer.append( " .string_" + k + " = " )
- .append( ( (UnicodeString) field_3_strings
+ .append( ( field_3_strings
.get( new Integer( k ) ) ).toString() ).append( "\n" );
}
buffer.append( "[/SST]\n" );
* The data consists of sets of string data. This string data is
* arranged as follows:
* <P>
- * <CODE>
+ * <CODE><pre>
* short string_length; // length of string data
* byte string_flag; // flag specifying special string
* // handling
* // array is run_count)
* byte[] extension; // optional extension (length of array
* // is extend_length)
- * </CODE>
+ * </pre></CODE>
* <P>
* The string_flag is bit mapped as follows:
* <P>
* Subclasses should implement this so that their data is passed back in a
* byte array.
*
- * @return byte array containing instance data
+ * @return size
*/
public int serialize( int offset, byte[] data )
{
SSTSerializer serializer = new SSTSerializer(
_record_lengths, field_3_strings, getNumStrings(), getNumUniqueStrings() );
- return serializer.serialize( getRecordSize(), offset, data );
+ int bytes = serializer.serialize( getRecordSize(), offset, data );
+ bucketAbsoluteOffsets = serializer.getBucketAbsoluteOffsets();
+ bucketRelativeOffsets = serializer.getBucketRelativeOffsets();
+// for ( int i = 0; i < bucketAbsoluteOffsets.length; i++ )
+// {
+// System.out.println( "bucketAbsoluteOffset = " + bucketAbsoluteOffsets[i] );
+// System.out.println( "bucketRelativeOffset = " + bucketRelativeOffsets[i] );
+// }
+ return bytes;
}
{
deserializer.processContinueRecord( record );
}
+
+ /**
+ * Creates an extended string record based on the current contents of
+ * the current SST record. The offset within the stream to the SST record
+ * is required because the extended string record points directly to the
+ * strings in the SST record.
+ * <p>
+ * NOTE: THIS FUNCTION MUST ONLY BE CALLED AFTER THE SST RECORD HAS BEEN
+ * SERIALIZED.
+ *
+ * @param sstOffset The offset in the stream to the start of the
+ * SST record.
+ * @return The new SST record.
+ */
+ public ExtSSTRecord createExtSSTRecord(int sstOffset)
+ {
+ if (bucketAbsoluteOffsets == null || bucketAbsoluteOffsets == null)
+ throw new IllegalStateException("SST record has not yet been serialized.");
+
+ ExtSSTRecord extSST = new ExtSSTRecord();
+ extSST.setNumStringsPerBucket((short)8);
+ int[] absoluteOffsets = (int[]) bucketAbsoluteOffsets.clone();
+ int[] relativeOffsets = (int[]) bucketRelativeOffsets.clone();
+ for ( int i = 0; i < absoluteOffsets.length; i++ )
+ absoluteOffsets[i] += sstOffset;
+ extSST.setBucketOffsets(absoluteOffsets, relativeOffsets);
+ return extSST;
+ }
+
+ /**
+ * Calculates the size in bytes of the EXTSST record as it would be if the
+ * record was serialized.
+ *
+ * @return The size of the ExtSST record in bytes.
+ */
+ public int calcExtSSTRecordSize()
+ {
+ return 4 + 2 + ((field_3_strings.size() / SSTSerializer.DEFAULT_BUCKET_SIZE) + 1) * 8;
+ }
}
import java.util.Map;
/**
- * Used to calculate the record sizes for a particular record.
+ * Used to calculate the record sizes for a particular record. This kind of
+ * sucks because it's similar to the SST serialization code. In general
+ * the SST serialization code needs to be rewritten.
*
* @author Glen Stampoultzis (glens at apache.org)
*/
private int numUniqueStrings;
private SSTRecordHeader sstRecordHeader;
+ /** Offsets from the beginning of the SST record (even across continuations) */
+ int[] bucketAbsoluteOffsets;
+ /** Offsets relative the start of the current SST or continue record */
+ int[] bucketRelativeOffsets;
+ int startOfSST, startOfRecord;
+ /** The default bucket size (this is used for ExternSST) */
+ final static int DEFAULT_BUCKET_SIZE = 8;
+
public SSTSerializer( List recordLengths, BinaryTree strings, int numStrings, int numUniqueStrings )
{
this.recordLengths = recordLengths;
this.numStrings = numStrings;
this.numUniqueStrings = numUniqueStrings;
this.sstRecordHeader = new SSTRecordHeader( numStrings, numUniqueStrings );
+
+ this.bucketAbsoluteOffsets = new int[strings.size()/DEFAULT_BUCKET_SIZE+1];
+ this.bucketRelativeOffsets = new int[strings.size()/DEFAULT_BUCKET_SIZE+1];
}
/**
/**
* This case is chosen when an SST record does not span over to a continue record.
- *
*/
private void serializeSingleSSTRecord( byte[] data, int offset, int record_length_index )
{
for ( int k = 0; k < strings.size(); k++ )
{
+ if (k % DEFAULT_BUCKET_SIZE == 0)
+ {
+ bucketAbsoluteOffsets[k / DEFAULT_BUCKET_SIZE] = pos;
+ bucketRelativeOffsets[k / DEFAULT_BUCKET_SIZE] = pos;
+ }
System.arraycopy( getUnicodeString( k ).serialize(), 0, data, pos + offset, getUnicodeString( k ).getRecordSize() );
pos += getUnicodeString( k ).getRecordSize();
}
private void serializeLargeRecord( int record_size, int record_length_index, byte[] buffer, int offset )
{
+ startOfSST = offset;
+
byte[] stringReminant = null;
int stringIndex = 0;
boolean lastneedcontinue = false;
recordLength, numStrings, numUniqueStrings );
// write the appropriate header
+ startOfRecord = offset + totalWritten;
recordProcessor.writeRecordHeader( offset, totalWritten, recordLength, first_record );
first_record = false;
{
UnicodeString unistr = getUnicodeString( stringIndex );
+ if (stringIndex % DEFAULT_BUCKET_SIZE == 0)
+ {
+ bucketAbsoluteOffsets[stringIndex / DEFAULT_BUCKET_SIZE] = offset + totalWritten + recordProcessor.getRecordOffset() - startOfSST;
+ bucketRelativeOffsets[stringIndex / DEFAULT_BUCKET_SIZE] = offset + totalWritten + recordProcessor.getRecordOffset() - startOfRecord;
+ }
+
if ( unistr.getRecordSize() <= recordProcessor.getAvailable() )
{
recordProcessor.writeWholeString( unistr, offset, totalWritten );
{
return recordLengths;
}
+
+ public int[] getBucketAbsoluteOffsets()
+ {
+ return bucketAbsoluteOffsets;
+ }
+
+ public int[] getBucketRelativeOffsets()
+ {
+ return bucketRelativeOffsets;
+ }
}
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.StringUtil;
+import org.apache.poi.util.BitField;
/**
* Title: Style Record<P>
* Description: Describes a builtin to the gui or user defined style<P>
* REFERENCE: PG 390 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
* @author Andrew C. Oliver (acoliver at apache dot org)
+ * @author aviks : string fixes for UserDefined Style
* @version 2.0-pre
*/
private byte field_3_outline_style_level;
// only for user defined styles
- private byte field_2_name_length;
- private String field_3_name;
+ private short field_2_name_length; //OO doc says 16 bit length, so we believe
+ private byte field_3_string_options;
+ private BitField fHighByte;
+ private String field_4_name;
public StyleRecord()
{
protected void fillFields(byte [] data, short size, int offset)
{
+ fHighByte = new BitField(0x01); //have to init here, since we are being called
+ //from super, and class level init hasnt been done.
field_1_xf_index = LittleEndian.getShort(data, 0 + offset);
- if (getType() == 1)
+ if (getType() == STYLE_BUILT_IN)
{
field_2_builtin_style = data[ 2 + offset ];
field_3_outline_style_level = data[ 3 + offset ];
}
- else if (getType() == 0)
+ else if (getType() == STYLE_USER_DEFINED)
{
- field_2_name_length = data[ 2 + offset ];
- field_3_name = StringUtil.getFromCompressedUnicode(data, 3 + offset,
- LittleEndian.ubyteToInt(field_2_name_length));
+ field_2_name_length = LittleEndian.getShort(data, 2 + offset );
+ field_3_string_options = data[4+offset];
+
+ if (fHighByte.isSet(field_3_string_options)) {
+ field_4_name= StringUtil.getFromUnicode(data,offset+5,field_2_name_length);
+ }else {
+ field_4_name=StringUtil.getFromCompressedUnicode(data,offset+5,field_2_name_length);
+ }
}
// todo sanity check exception to make sure we're one or the other
public void setName(String name)
{
- field_3_name = name;
+ field_4_name = name;
+ //TODO set name length and string options
}
// end user defined
* @see #getName()
*/
- public byte getNameLength()
+ public short getNameLength()
{
return field_2_name_length;
}
public String getName()
{
- return field_3_name;
+ return field_4_name;
}
// end user defined
else
{
LittleEndian.putShort(data, 2 + offset,
- (( short ) (0x03 + getNameLength())));
+ (( short ) (getRecordSize()-4)));
}
LittleEndian.putShort(data, 4 + offset, getIndex());
if (getType() == STYLE_BUILT_IN)
}
else
{
- data[ 6 + offset ] = getNameLength();
- StringUtil.putCompressedUnicode(getName(), data, 7 + offset);
+ LittleEndian.putShort(data, 6 + offset , getNameLength());
+ data[8+offset]=this.field_3_string_options;
+ StringUtil.putCompressedUnicode(getName(), data, 9 + offset);
}
return getRecordSize();
}
}
else
{
- retval = 7 + getNameLength();
+ if (fHighByte.isSet(field_3_string_options)) {
+ retval= 9+2*getNameLength();
+ }else {
+ retval = 9 + getNameLength();
+ }
}
return retval;
}
* Company: SuperLink Software, Inc.<P>
* @author Andrew C. Oliver (acoliver at apache dot org)
* @author Jason Height (jheight at chariot dot net dot au)
- * @version 2.0-pre
+ * @author Glen Stampoultzis (glens at apache.org)
*/
public class UnknownRecord
extends Record
{
- private short sid = 0;
- private short size = 0;
- private byte[] thedata = null;
- int offset = 0;
+ private short sid = 0;
+ private byte[] thedata = null;
public UnknownRecord()
{
public UnknownRecord(short id, short size, byte [] data)
{
sid = id;
- size = size;
thedata = data;
}
protected void fillFields(byte [] data, short sid)
{
- sid = sid;
+ this.sid = sid;
thedata = data;
}
/** Unlike the other Record.clone methods this is a shallow clone*/
public Object clone() {
UnknownRecord rec = new UnknownRecord();
- rec.offset = offset;
rec.sid = sid;
- rec.size = size;
rec.thedata = thedata;
return rec;
}
this.stringRecord = stringRecord;
}
+ /**
+ * Used only in the clone
+ * @param formulaRecord
+ * @param stringRecord
+ * @param sharedRecord
+ */
+ public FormulaRecordAggregate( FormulaRecord formulaRecord, StringRecord stringRecord, SharedFormulaRecord sharedRecord)
+ {
+ this.formulaRecord = formulaRecord;
+ this.stringRecord = stringRecord;
+ this.sharedFormulaRecord = sharedRecord;
+ }
+
protected void validateSid( short id )
{
int pos = offset;
pos += formulaRecord.serialize(pos, data);
- if (stringRecord != null)
- {
- pos += stringRecord.serialize(pos, data);
- }
if (this.getSharedFormulaRecord() != null)
{
pos += getSharedFormulaRecord().serialize(pos, data);
}
+ if (stringRecord != null)
+ {
+ pos += stringRecord.serialize(pos, data);
+ }
return pos - offset;
}
* @see java.lang.Object#clone()
*/
public Object clone() {
- return new FormulaRecordAggregate((FormulaRecord) this.formulaRecord.clone(), (StringRecord) this.stringRecord.clone());
+ StringRecord clonedString = (stringRecord == null) ? null : (StringRecord)stringRecord.clone();
+ SharedFormulaRecord clonedShared = (sharedFormulaRecord == null) ? null : (SharedFormulaRecord)sharedFormulaRecord.clone();
+
+ return new FormulaRecordAggregate((FormulaRecord) this.formulaRecord.clone(), clonedString, clonedShared);
}
this.sharedFormulaRecord = sharedFormulaRecord;
}
+ /*
+ * Setting to true so that this value does not abort the whole ValueAggregation
+ * (non-Javadoc)
+ * @see org.apache.poi.hssf.record.Record#isInValueSection()
+ */
+ public boolean isInValueSection() {
+
+ return true;
+ }
+
}
ptg.field_3_last_row = field_3_last_row;
ptg.field_4_first_column = field_4_first_column;
ptg.field_5_last_column = field_5_last_column;
+ ptg.setClass(ptgClass);
return ptg;
}
ptg.field_2_last_row = field_2_last_row;
ptg.field_3_first_column = field_3_first_column;
ptg.field_4_last_column = field_4_last_column;
+ ptg.setClass(ptgClass);
return ptg;
}
public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;}
public Object clone() {
- throw new RuntimeException("NO IDEA SHARED FORMULA EXP PTG");
+ //can't clone one that doesnt have data can we??
+ if (this.existing == null) throw new RuntimeException("NO IDEA SHARED FORMULA EXP PTG");
+
+ return new ExpPtg(this.existing, 0);
}
}
FuncPtg ptg = new FuncPtg();
//ptg.field_1_num_args = field_1_num_args;
ptg.field_2_fnc_index = field_2_fnc_index;
- return ptg;
+ ptg.setClass(ptgClass);
+ return ptg;
}
public int getSize() {
FuncVarPtg ptg = new FuncVarPtg();
ptg.field_1_num_args = field_1_num_args;
ptg.field_2_fnc_index = field_2_fnc_index;
+ ptg.setClass(ptgClass);
return ptg;
}
extends Ptg
{
public final static short sid = 0x23;
- private final static int SIZE = 7;
- private short field_1_ixti; // unknown function
- private short field_2_label_index;
- private short field_3_zero; // reserved must be 0
+ private final static int SIZE = 5;
+ private short field_1_label_index;
+ private short field_2_zero; // reserved must be 0
+ boolean xtra=false;
private NamePtg() {
public NamePtg(byte [] data, int offset)
{
offset++;
- field_1_ixti = LittleEndian.getShort(data, offset);
- field_2_label_index = LittleEndian.getShort(data, offset + 2);
- field_3_zero = LittleEndian.getShort(data, offset + 4);
+ //field_1_ixti = LittleEndian.getShort(data, offset);
+ field_1_label_index = LittleEndian.getShort(data, offset );
+ field_2_zero = LittleEndian.getShort(data, offset + 2);
+ //if (data[offset+6]==0) xtra=true;
}
public void writeBytes(byte [] array, int offset)
{
+ array[offset+0]= (byte) (sid + ptgClass);
+ LittleEndian.putShort(array,offset+1,field_1_label_index);
+ LittleEndian.putShort(array,offset+3, field_2_zero);
}
public int getSize()
public String toFormulaString(SheetReferences refs)
{
- return "NO IDEA - NAME";
+ return "NAMED RANGE";
}
public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;}
public Object clone() {
NamePtg ptg = new NamePtg();
- ptg.field_1_ixti = field_1_ixti;
- ptg.field_2_label_index = field_2_label_index;
- ptg.field_3_zero = field_3_zero;
+ ptg.field_1_label_index = field_1_label_index;
+ ptg.field_2_zero = field_2_zero;
return ptg;
}
}
public void writeBytes(byte [] array, int offset)
{
- array[ offset + 0 ] = sid;
+ array[ offset + 0 ] = (byte)(sid + ptgClass);
LittleEndian.putShort(array, offset + 1, field_1_ixals);
LittleEndian.putShort(array,offset+3, field_2_ilbl);
LittleEndian.putShort(array, offset + 5, field_3_reserved);
ptg.field_1_ixals = field_1_ixals;
ptg.field_3_reserved = field_3_reserved;
ptg.field_2_ilbl = field_2_ilbl;
+ ptg.setClass(ptgClass);
return ptg;
}
}
case MissingArgPtg.sid:
retval = new MissingArgPtg(data,offset);
break;
+ case UnaryPlusPtg.sid:
+ retval=new UnaryPlusPtg(data,offset);
+ break;
+ case UnaryMinusPtg.sid:
+ retval=new UnaryMinusPtg(data,offset);
+ break;
default :
return retval;
}
+ /** Overridden toString method to ensure object hash is not printed.
+ * This helps get rid of gratuitous diffs when comparing two dumps
+ * Subclasses may output more relevant information by overriding this method
+ **/
+ public String toString(){
+ return this.getClass().toString();
+ }
+
public static final byte CLASS_REF = 0x00;
public static final byte CLASS_VALUE = 0x20;
public static final byte CLASS_ARRAY = 0x40;
public String toString() {
StringBuffer buffer = new StringBuffer();
- buffer.append("Ref3dPrg\n");
+ buffer.append("Ref3dPtg\n");
buffer.append("Index to Extern Sheet = " + getExternSheetIndex()).append("\n");
buffer.append("Row = " + getRow()).append("\n");
buffer.append("Col = " + getColumn()).append("\n");
ptg.field_1_index_extern_sheet = field_1_index_extern_sheet;
ptg.field_2_row = field_2_row;
ptg.field_3_column = field_3_column;
+ ptg.setClass(ptgClass);
return ptg;
}
ReferencePtg ptg = new ReferencePtg();
ptg.field_1_row = field_1_row;
ptg.field_2_col = field_2_col;
+ ptg.setClass(ptgClass);
return ptg;
}
}
package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.LittleEndian;
-
+import org.apache.poi.util.BitField;
import org.apache.poi.hssf.util.SheetReferences;
+import org.apache.poi.util.StringUtil;
/**
* Number
{
public final static int SIZE = 9;
public final static byte sid = 0x17;
- private String field_1_value;
+ //NOTE: OO doc says 16bit lenght, but BiffViewer says 8
+ // Book says something totally different, so dont look there!
+ byte field_1_length;
+ byte field_2_options;
+ BitField fHighByte = new BitField(0x01);
+ private String field_3_string;
private StringPtg() {
//Required for clone methods
/** Create a StringPtg from a byte array read from disk */
public StringPtg(byte [] data, int offset)
{
- setValue(new String(data, offset+3, data[offset+1] + 256*data[offset+2]));
+ offset++;
+ field_1_length = data[offset];
+ field_2_options = data[offset+1];
+ if (fHighByte.isSet(field_2_options)) {
+ field_3_string= StringUtil.getFromUnicode(data,offset+2,field_1_length);
+ }else {
+ field_3_string=StringUtil.getFromCompressedUnicode(data,offset+2,field_1_length);
+ }
+
+ //setValue(new String(data, offset+3, data[offset+1] + 256*data[offset+2]));
}
/** Create a StringPtg from a string representation of the number
* @param value : String representation of a floating point number
*/
public StringPtg(String value) {
- setValue(value);
+ if (value.length() >255) {
+ throw new IllegalArgumentException("String literals in formulas cant be bigger than 255 characters ASCII");
+ }
+ this.field_2_options=0;
+ this.fHighByte.setBoolean(field_2_options, false);
+ this.field_3_string=value;
+ this.field_1_length=(byte)value.length(); //for the moment, we support only ASCII strings in formulas we create
}
-
+ /*
public void setValue(String value)
{
field_1_value = value;
- }
+ }*/
public String getValue()
{
- return field_1_value;
+ return field_3_string;
}
public void writeBytes(byte [] array, int offset)
{
array[ offset + 0 ] = sid;
- array[ offset + 1 ] = (byte)(getValue().length() % 256);
- array[ offset + 2 ] = (byte)(getValue().length() / 256);
- System.arraycopy(getValue().getBytes(), 0, array, offset + 3, getValue().length());
+ array[ offset + 1 ] = field_1_length;
+ array[ offset + 2 ] = field_2_options;
+ if (fHighByte.isSet(field_2_options)) {
+ StringUtil.putUncompressedUnicode(getValue(),array,offset+3);
+ }else {
+ StringUtil.putCompressedUnicode(getValue(),array,offset+3);
+ }
}
public int getSize()
{
- return field_1_value.length() + 3;
+ if (fHighByte.isSet(field_2_options)) {
+ return 2*field_1_length+3;
+ }else {
+ return field_1_length+3;
+ }
}
public String toFormulaString(SheetReferences refs)
public Object clone() {
StringPtg ptg = new StringPtg();
- ptg.field_1_value = field_1_value;
+ ptg.field_1_length = field_1_length;
+ ptg.field_2_options=field_2_options;
+ ptg.field_3_string=field_3_string;
return ptg;
}
--- /dev/null
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+package org.apache.poi.hssf.record.formula;
+
+import java.util.List;
+
+import org.apache.poi.hssf.util.SheetReferences;
+
+/**
+ * Unary Plus operator
+ * does not have any effect on the operand
+ * @author Avik Sengupta
+ */
+
+public class UnaryMinusPtg extends OperationPtg
+{
+ public final static int SIZE = 1;
+ public final static byte sid = 0x13;
+
+ private final static String MINUS = "-";
+
+ /** Creates new AddPtg */
+
+ public UnaryMinusPtg()
+ {
+ }
+
+ public UnaryMinusPtg(byte[] data, int offset)
+ {
+
+ // doesn't need anything
+ }
+
+
+ public void writeBytes(byte [] array, int offset)
+ {
+ array[ offset + 0 ] = sid;
+ }
+
+ public int getSize()
+ {
+ return SIZE;
+ }
+
+ public int getType()
+ {
+ return this.TYPE_UNARY;
+ }
+
+ public int getNumberOfOperands()
+ {
+ return 1;
+ }
+
+ /** Implementation of method from Ptg */
+ public String toFormulaString(SheetReferences refs)
+ {
+ return "+";
+ }
+
+ /** implementation of method from OperationsPtg*/
+ public String toFormulaString(String[] operands) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(MINUS);
+ buffer.append(operands[ 0]);
+ return buffer.toString();
+ }
+
+ public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;}
+
+ public Object clone() {
+ return new UnaryPlusPtg();
+ }
+
+}
--- /dev/null
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+package org.apache.poi.hssf.record.formula;
+
+import java.util.List;
+
+import org.apache.poi.hssf.util.SheetReferences;
+
+/**
+ * Unary Plus operator
+ * does not have any effect on the operand
+ * @author Avik Sengupta
+ */
+
+public class UnaryPlusPtg extends OperationPtg
+{
+ public final static int SIZE = 1;
+ public final static byte sid = 0x12;
+
+ private final static String ADD = "+";
+
+ /** Creates new AddPtg */
+
+ public UnaryPlusPtg()
+ {
+ }
+
+ public UnaryPlusPtg(byte[] data, int offset)
+ {
+
+ // doesn't need anything
+ }
+
+
+ public void writeBytes(byte [] array, int offset)
+ {
+ array[ offset + 0 ] = sid;
+ }
+
+ public int getSize()
+ {
+ return SIZE;
+ }
+
+ public int getType()
+ {
+ return this.TYPE_UNARY;
+ }
+
+ public int getNumberOfOperands()
+ {
+ return 1;
+ }
+
+ /** Implementation of method from Ptg */
+ public String toFormulaString(SheetReferences refs)
+ {
+ return "+";
+ }
+
+ /** implementation of method from OperationsPtg*/
+ public String toFormulaString(String[] operands) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(ADD);
+ buffer.append(operands[ 0]);
+ return buffer.toString();
+ }
+
+ public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;}
+
+ public Object clone() {
+ return new UnaryPlusPtg();
+ }
+
+}
for (short i = (short) PaletteRecord.FIRST_COLOR_INDEX; b != null;
b = palette.getColor(++i))
{
- if (b[0] == red && b[1] == blue && b[2] == green)
+ if (b[0] == red && b[1] == green && b[2] == blue)
{
return new CustomColor(i, b);
}
*/
package org.apache.poi.hssf.usermodel;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.TreeMap;
+
import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.model.Workbook;
-import org.apache.poi.hssf.record.*;
+import org.apache.poi.hssf.record.CellValueRecordInterface;
+import org.apache.poi.hssf.record.HCenterRecord;
+import org.apache.poi.hssf.record.Record;
+import org.apache.poi.hssf.record.RowRecord;
+import org.apache.poi.hssf.record.SCLRecord;
+import org.apache.poi.hssf.record.VCenterRecord;
+import org.apache.poi.hssf.record.WSBoolRecord;
+import org.apache.poi.hssf.record.WindowTwoRecord;
import org.apache.poi.hssf.util.Region;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
-import java.util.Iterator;
-import java.util.TreeMap;
-import java.util.List;
-
/**
* High level representation of a worksheet.
* @author Andrew C. Oliver (acoliver at apache dot org)
getSheet().setSCLRecord(sclRecord);
}
+ /**
+ * Shifts the merged regions left or right depending on mode
+ * <p>
+ * TODO: MODE , this is only row specific
+ * @param startRow
+ * @param endRow
+ * @param n
+ * @param isRow
+ */
+ protected void shiftMerged(int startRow, int endRow, int n, boolean isRow) {
+ List shiftedRegions = new ArrayList();
+ //move merged regions completely if they fall within the new region boundaries when they are shifted
+ for (int i = 0; i < this.getNumMergedRegions(); i++) {
+ Region merged = this.getMergedRegionAt(i);
+
+ boolean inStart = (merged.getRowFrom() >= startRow || merged.getRowTo() >= startRow);
+ boolean inEnd = (merged.getRowTo() <= endRow || merged.getRowFrom() <= endRow);
+
+ //dont check if it's not within the shifted area
+ if (! (inStart && inEnd)) continue;
+
+ //only shift if the region outside the shifted rows is not merged too
+ if (!merged.contains(startRow-1, (short)0) && !merged.contains(endRow+1, (short)0)){
+ merged.setRowFrom(merged.getRowFrom()+n);
+ merged.setRowTo(merged.getRowTo()+n);
+ //have to remove/add it back
+ shiftedRegions.add(merged);
+ this.removeMergedRegion(i);
+ i = i -1; // we have to back up now since we removed one
+
+ }
+
+ }
+
+ //readd so it doesn't get shifted again
+ Iterator iterator = shiftedRegions.iterator();
+ while (iterator.hasNext()) {
+ Region region = (Region)iterator.next();
+
+ this.addMergedRegion(region);
+ }
+
+ }
+
/**
* Shifts rows between startRow and endRow n number of rows.
* If you use a negative number, it will shift rows up.
*
* Calls shiftRows(startRow, endRow, n, false, false);
*
+ * <p>
+ * Additionally shifts merged regions that are completely defined in these
+ * rows (ie. merged 2 cells on a row to be shifted).
* @param startRow the row to start shifting
* @param endRow the row to end shifting
* @param n the number of rows to shift
*/
public void shiftRows( int startRow, int endRow, int n ) {
- shiftRows(startRow, endRow, n, false, false);
+ shiftRows(startRow, endRow, n, false, false);
}
/**
* Shifts rows between startRow and endRow n number of rows.
* If you use a negative number, it will shift rows up.
* Code ensures that rows don't wrap around
- *
+ *
+ * <p>
+ * Additionally shifts merged regions that are completely defined in these
+ * rows (ie. merged 2 cells on a row to be shifted).
* @param startRow the row to start shifting
* @param endRow the row to end shifting
* @param n the number of rows to shift
e = startRow;
inc = -1;
}
+
+ shiftMerged(startRow, endRow, n, true);
+
for ( int rowNum = s; rowNum >= startRow && rowNum <= endRow && rowNum >= 0 && rowNum < 65536; rowNum += inc )
{
HSSFRow row = getRow( rowNum );
HSSFCell cell;
+
+
+
// Removes the cells before over writting them.
for ( short col = row2Replace.getFirstCellNum(); col <= row2Replace.getLastCellNum(); col++ )
{
getSheet().createSplitPane( xSplitPos, ySplitPos, topRow, leftmostColumn, activePane );
}
+ /**
+ * Sets whether the gridlines are shown in a viewer.
+ * @param show whether to show gridlines or not
+ */
+ public void setDisplayGridlines(boolean show) {
+ sheet.setDisplayGridlines(show);
+ }
+ /**
+ * Returns if gridlines are displayed.
+ * @return whether gridlines are displayed
+ */
+ public boolean isDisplayGridlines() {
+ return sheet.isDisplayGridlines();
+ }
+
+ /**
+ * Sets whether the formulas are shown in a viewer.
+ * @param show whether to show formulas or not
+ */
+ public void setDisplayFormulas(boolean show) {
+ sheet.setDisplayFormulas(show);
+ }
+
+ /**
+ * Returns if formulas are displayed.
+ * @return whether formulas are displayed
+ */
+ public boolean isDisplayFormulas() {
+ return sheet.isDisplayFormulas();
+ }
+
+ /**
+ * Sets whether the RowColHeadings are shown in a viewer.
+ * @param show whether to show RowColHeadings or not
+ */
+ public void setDisplayRowColHeadings(boolean show) {
+ sheet.setDisplayRowColHeadings(show);
+ }
+
+ /**
+ * Returns if RowColHeadings are displayed.
+ * @return whether RowColHeadings are displayed
+ */
+ public boolean isDisplayRowColHeadings() {
+ return sheet.isDisplayRowColHeadings();
+ }
}
* memory.
*/
private POIFSFileSystem poifs;
+
+ /**
+ * Used to keep track of the data formatter so that all
+ * createDataFormatter calls return the same one for a given
+ * book. This ensures that updates from one places is visible
+ * someplace else.
+ */
+ private HSSFDataFormat formatter;
private static POILogger log = POILogFactory.getLogger(HSSFWorkbook.class);
}
/**
- * Creates an instance of HSSFDataFormat.
+ * Returns the instance of HSSFDataFormat for this workbook.
* @return the HSSFDataFormat object
* @see org.apache.poi.hssf.record.FormatRecord
* @see org.apache.poi.hssf.record.Record
*/
public HSSFDataFormat createDataFormat() {
- return new HSSFDataFormat(workbook);
+ if (formatter == null)
+ formatter = new HSSFDataFormat(workbook);
+ return formatter;
}
/** remove the named range by his name
public class HexDump
{
+ public static final String EOL =
+ System.getProperty("line.separator");
+// private static final StringBuffer _lbuffer = new StringBuffer(8);
+// private static final StringBuffer _cbuffer = new StringBuffer(2);
+ private static final char _hexcodes[] =
+ {
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D',
+ 'E', 'F'
+ };
+ private static final int _shifts[] =
+ {
+ 28, 24, 20, 16, 12, 8, 4, 0
+ };
+
// all static methods, so no need for a public constructor
private HexDump()
throws IOException, ArrayIndexOutOfBoundsException,
IllegalArgumentException
{
- if ((index < 0) || (index >= data.length))
+ if ((index < 0) || (data.length != 0 && index >= data.length))
{
throw new ArrayIndexOutOfBoundsException(
"illegal index: " + index + " into array of length "
+ data.length);
}
+ if (data.length == 0)
+ return; // nothing more to do.
if (stream == null)
{
throw new IllegalArgumentException("cannot write to nullstream");
}
- public static final String EOL =
- System.getProperty("line.separator");
- private static final StringBuffer _lbuffer = new StringBuffer(8);
- private static final StringBuffer _cbuffer = new StringBuffer(2);
- private static final char _hexcodes[] =
- {
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D',
- 'E', 'F'
- };
- private static final int _shifts[] =
- {
- 28, 24, 20, 16, 12, 8, 4, 0
- };
-
private static String dump(final long value)
{
- _lbuffer.setLength(0);
+ StringBuffer buf = new StringBuffer();
+ buf.setLength(0);
for (int j = 0; j < 8; j++)
{
- _lbuffer
- .append(_hexcodes[ (( int ) (value >> _shifts[ j ])) & 15 ]);
+ buf.append( _hexcodes[ (( int ) (value >> _shifts[ j ])) & 15 ]);
}
- return _lbuffer.toString();
+ return buf.toString();
}
private static String dump(final byte value)
{
- _cbuffer.setLength(0);
+ StringBuffer buf = new StringBuffer();
+ buf.setLength(0);
for (int j = 0; j < 2; j++)
{
- _cbuffer.append(_hexcodes[ (value >> _shifts[ j + 6 ]) & 15 ]);
+ buf.append(_hexcodes[ (value >> _shifts[ j + 6 ]) & 15 ]);
}
- return _cbuffer.toString();
+ return buf.toString();
}
/**
retVal.append(']');
return retVal.toString();
}
+
/**
* Converts the parameter to a hex value.
*
}
return result.toString();
}
+
+ /**
+ * Dumps <code>bytesToDump</code> bytes to an output stream.
+ *
+ * @param in The stream to read from
+ * @param out The output stream
+ * @param start The index to use as the starting position for the left hand side label
+ * @param bytesToDump The number of bytes to output. Use -1 to read until the end of file.
+ */
+ public static void dump( InputStream in, PrintStream out, int start, int bytesToDump ) throws IOException
+ {
+ ByteArrayOutputStream buf = new ByteArrayOutputStream();
+ if (bytesToDump == -1)
+ {
+ int c = in.read();
+ while (c != -1)
+ {
+ buf.write(c);
+ c = in.read();
+ }
+ }
+ else
+ {
+ int bytesRemaining = bytesToDump;
+ while (bytesRemaining-- > 0)
+ {
+ int c = in.read();
+ if (c == -1)
+ break;
+ else
+ buf.write(c);
+ }
+ }
+
+ byte[] data = buf.toByteArray();
+ dump(data, 0, out, start, data.length);
+ }
}
-/* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" and * "Apache POI" must not be used to endorse or promote products * derived from this software without prior written permission. For * written permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * "Apache POI", nor may "Apache" appear in their name, without * prior written permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */package org.apache.poi.util;import java.io.IOException;import java.io.File;import java.io.FileInputStream;import java.io.InputStream;import java.util.List;import java.util.ArrayList;/** * Utilities to read hex from files. * * @author Marc Johnson * @author Glen Stampoultzis (glens at apache.org) */public class HexRead{ /** * This method reads hex data from a filename and returns a byte array. * The file may contain line comments that are preceeded with a # symbol. * * @param filename The filename to read * @return The bytes read from the file. * @throws IOException If there was a problem while reading the file. */ public static byte[] readData( String filename ) throws IOException { File file = new File( filename ); FileInputStream stream = new FileInputStream( file ); try { return readData(stream, -1); } finally { stream.close(); } } /** * Same as readData(String) except that this method allows you to specify sections within * a file. Sections are referenced using section headers in the form: * <pre> * [sectioname] * </pre> * * @see #readData(String) */ public static byte[] readData(String filename, String section) throws IOException { File file = new File( filename ); FileInputStream stream = new FileInputStream( file ); try { StringBuffer sectionText = new StringBuffer(); boolean inSection = false; int c = stream.read(); while (c != -1) { switch(c) { case '[': inSection = true; break; case '\n': case '\r': inSection = false; sectionText = new StringBuffer(); break; case ']': inSection = false; if (sectionText.toString().equals(section)) return readData(stream, '['); sectionText = new StringBuffer(); break; default: if (inSection) sectionText.append((char)c); } c = stream.read(); } } finally { stream.close(); } throw new IOException("Section '" + section + "' not found"); } static private byte[] readData( FileInputStream stream, int eofChar ) throws IOException { int characterCount = 0; byte b = (byte) 0; List bytes = new ArrayList(); boolean done = false; while ( !done ) { int count = stream.read(); char baseChar = 'a'; if ( count == eofChar) break; switch ( count ) { case '#': readToEOL(stream); break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': b <<= 4; b += (byte) ( count - '0' ); characterCount++; if ( characterCount == 2 ) { bytes.add( new Byte( b ) ); characterCount = 0; b = (byte) 0; } break; case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': baseChar = 'A'; case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': b <<= 4; b += (byte) ( count + 10 - baseChar ); characterCount++; if ( characterCount == 2 ) { bytes.add( new Byte( b ) ); characterCount = 0; b = (byte) 0; } break; case -1: done = true; break; default : break; } } Byte[] polished = (Byte[]) bytes.toArray( new Byte[0] ); byte[] rval = new byte[polished.length]; for ( int j = 0; j < polished.length; j++ ) { rval[j] = polished[j].byteValue(); } return rval; } static private void readToEOL( InputStream stream ) throws IOException { int c = stream.read(); while ( c != -1 && c != '\n' && c != '\r') { c = stream.read(); } }}
\ No newline at end of file
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+package org.apache.poi.util;
+
+import java.io.*;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Utilities to read hex from files.
+ *
+ * @author Marc Johnson
+ * @author Glen Stampoultzis (glens at apache.org) */
+public class HexRead
+{
+ /**
+ * This method reads hex data from a filename and returns a byte array.
+ * The file may contain line comments that are preceeded with a # symbol.
+ *
+ * @param filename The filename to read
+ * @return The bytes read from the file.
+ * @throws IOException If there was a problem while reading the file. */
+ public static byte[] readData( String filename ) throws IOException
+ {
+ File file = new File( filename );
+ FileInputStream stream = new FileInputStream( file );
+ try
+ {
+ return readData( stream, -1 );
+ }
+ finally
+ {
+ stream.close();
+ }
+ }
+
+ /**
+ * Same as readData(String) except that this method allows you to specify sections within
+ * a file. Sections are referenced using section headers in the form:
+ * <pre>
+ * [sectioname]
+ * </pre>
+ *
+ * @see #readData(String)
+ */
+ public static byte[] readData( String filename, String section ) throws IOException
+ {
+ File file = new File( filename );
+ FileInputStream stream = new FileInputStream( file );
+ try
+ {
+ StringBuffer sectionText = new StringBuffer();
+ boolean inSection = false;
+ int c = stream.read();
+ while ( c != -1 )
+ {
+ switch ( c )
+ {
+ case '[':
+ inSection = true;
+ break;
+ case '\n':
+ case '\r':
+ inSection = false;
+ sectionText = new StringBuffer();
+ break;
+ case ']':
+ inSection = false;
+ if ( sectionText.toString().equals( section ) ) return readData( stream, '[' );
+ sectionText = new StringBuffer();
+ break;
+ default:
+ if ( inSection ) sectionText.append( (char) c );
+ }
+ c = stream.read();
+ }
+ }
+ finally
+ {
+ stream.close();
+ }
+ throw new IOException( "Section '" + section + "' not found" );
+ }
+
+ static public byte[] readData( InputStream stream, int eofChar ) throws IOException
+ {
+ int characterCount = 0;
+ byte b = (byte) 0;
+ List bytes = new ArrayList();
+ boolean done = false;
+ while ( !done )
+ {
+ int count = stream.read();
+ char baseChar = 'a';
+ if ( count == eofChar ) break;
+ switch ( count )
+ {
+ case '#':
+ readToEOL( stream );
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ b <<= 4;
+ b += (byte) ( count - '0' );
+ characterCount++;
+ if ( characterCount == 2 )
+ {
+ bytes.add( new Byte( b ) );
+ characterCount = 0;
+ b = (byte) 0;
+ }
+ break;
+ case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ baseChar = 'A';
+ case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ b <<= 4;
+ b += (byte) ( count + 10 - baseChar );
+ characterCount++;
+ if ( characterCount == 2 )
+ {
+ bytes.add( new Byte( b ) );
+ characterCount = 0;
+ b = (byte) 0;
+ }
+ break;
+ case -1:
+ done = true;
+ break;
+ default :
+ break;
+ }
+ }
+ Byte[] polished = (Byte[]) bytes.toArray( new Byte[0] );
+ byte[] rval = new byte[polished.length];
+ for ( int j = 0; j < polished.length; j++ )
+ {
+ rval[j] = polished[j].byteValue();
+ }
+ return rval;
+ }
+
+ static public byte[] readFromString(String data) throws IOException
+ {
+ return readData(new ByteArrayInputStream( data.getBytes() ), -1);
+ }
+
+ static private void readToEOL( InputStream stream ) throws IOException
+ {
+ int c = stream.read();
+ while ( c != -1 && c != '\n' && c != '\r' )
+ {
+ c = stream.read();
+ }
+ }
+}
\ No newline at end of file
return getLong(readFromStream(stream, LONG_SIZE));
}
-
- private final static byte[] _short_buffer = new byte[SHORT_SIZE];
- private final static byte[] _int_buffer = new byte[INT_SIZE];
- private final static byte[] _long_buffer = new byte[LONG_SIZE];
-
-
/**
* Read the appropriate number of bytes from the stream and return them to
* the caller. <p>
*
- * It should be noted that, in an attempt to improve system performance and
- * to prevent a transient explosion of discarded byte arrays to be garbage
- * collected, static byte arrays are employed for the standard cases of
- * reading a short, an int, or a long. <p>
- *
- * <b>THIS INTRODUCES A RISK FOR THREADED OPERATIONS!</b> <p>
- *
* However, for the purposes of the POI project, this risk is deemed
* negligible. It is, however, so noted.
*
public static byte[] readFromStream(final InputStream stream,
final int size)
throws IOException, BufferUnderrunException {
- byte[] buffer = null;
-
- switch (size) {
-
- case SHORT_SIZE:
- buffer = _short_buffer;
- break;
- case INT_SIZE:
- buffer = _int_buffer;
- break;
- case LONG_SIZE:
- buffer = _long_buffer;
- break;
- default:
- buffer = new byte[size];
- break;
- }
+ byte[] buffer = new byte[size];
+
int count = stream.read(buffer);
if (count == -1) {
-/* * ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" and * "Apache POI" must not be used to endorse or promote products * derived from this software without prior written permission. For * written permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * "Apache POI", nor may "Apache" appear in their name, without * prior written permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */package org.apache.poi.util;import java.io.UnsupportedEncodingException;import java.text.NumberFormat;import java.text.FieldPosition;/** * Title: String Utility Description: Collection of string handling utilities * * Now it is quite confusing: the method pairs, in which * one of them write data and other read written data are: * putUncompressedUnicodeHigh and getFromUnicode * putUncompressedUnicode and getFromUnicodeHigh * *@author Andrew C. Oliver *@author Sergei Kozello (sergeikozello at mail.ru) *@created May 10, 2002 *@version 1.0 */public class StringUtil { private final static String ENCODING="ISO-8859-1"; /** * Constructor for the StringUtil object */ private StringUtil() { } /** * given a byte array of 16-bit unicode characters, compress to 8-bit and * return a string * * { 0x16, 0x00 } -> 0x16 * *@param string the byte array to be converted *@param offset the initial offset into the * byte array. it is assumed that string[ offset ] and string[ offset + * 1 ] contain the first 16-bit unicode character *@param len *@return the converted string *@exception ArrayIndexOutOfBoundsException if offset is out of bounds for * the byte array (i.e., is negative or is greater than or equal to * string.length) *@exception IllegalArgumentException if len is too large (i.e., * there is not enough data in string to create a String of that * length) *@len the length of the final string */ public static String getFromUnicodeHigh(final byte[] string, final int offset, final int len) throws ArrayIndexOutOfBoundsException, IllegalArgumentException { if ((offset < 0) || (offset >= string.length)) { throw new ArrayIndexOutOfBoundsException("Illegal offset"); } if ((len < 0) || (((string.length - offset) / 2) < len)) { throw new IllegalArgumentException("Illegal length"); } char[] chars = new char[ len ]; for ( int i = 0; i < chars.length; i++ ) { chars[i] = (char)( string[ offset + ( 2*i ) ] & 0xFF | ( string[ offset + ( 2*i+1 ) ] << 8 ) ); } return new String( chars ); } /** * given a byte array of 16-bit unicode characters, compress to 8-bit and * return a string * * { 0x16, 0x00 } -> 0x16 * *@param string the byte array to be converted *@return the converted string */ public static String getFromUnicodeHigh( final byte[] string ) { return getFromUnicodeHigh( string, 0, string.length / 2 ); } /** * given a byte array of 16-bit unicode characters, compress to 8-bit and * return a string * * { 0x00, 0x16 } -> 0x16 * *@param string the byte array to be converted *@param offset the initial offset into the * byte array. it is assumed that string[ offset ] and string[ offset + * 1 ] contain the first 16-bit unicode character *@param len *@return the converted string *@exception ArrayIndexOutOfBoundsException if offset is out of bounds for * the byte array (i.e., is negative or is greater than or equal to * string.length) *@exception IllegalArgumentException if len is too large (i.e., * there is not enough data in string to create a String of that * length) *@len the length of the final string */ public static String getFromUnicode(final byte[] string, final int offset, final int len) throws ArrayIndexOutOfBoundsException, IllegalArgumentException { if ((offset < 0) || (offset >= string.length)) { throw new ArrayIndexOutOfBoundsException("Illegal offset"); } if ((len < 0) || (((string.length - offset) / 2) < len)) { throw new IllegalArgumentException("Illegal length"); } char[] chars = new char[ len ]; for ( int i = 0; i < chars.length; i++ ) { chars[i] = (char)( ( string[ offset + ( 2*i ) ] << 8 ) + string[ offset + ( 2*i+1 ) ] ); } return new String( chars ); } /** * given a byte array of 16-bit unicode characters, compress to 8-bit and * return a string * * { 0x00, 0x16 } -> 0x16 * *@param string the byte array to be converted *@return the converted string */ public static String getFromUnicode(final byte[] string) { return getFromUnicode(string, 0, string.length / 2); } /** * read compressed unicode(8bit) * * @author Toshiaki Kamoshida(kamoshida.toshiaki at future dot co dot jp) * * @param string byte array to read * @param offset offset to read byte array * @param len length to read byte array * @return String generated String instance by reading byte array */ public static String getFromCompressedUnicode(final byte[] string, final int offset, final int len){ try{ return new String(string,offset,len,"ISO-8859-1"); } catch(UnsupportedEncodingException e){ throw new InternalError();/* unreachable */ } } /** * write compressed unicode * *@param input the String containing the data to be written *@param output the byte array to which the data is to be written *@param offset an offset into the byte arrat at which the data is start * when written */ public static void putCompressedUnicode(final String input, final byte[] output, final int offset) { int strlen = input.length(); for (int k = 0; k < strlen; k++) { output[offset + k] = (byte) input.charAt(k); } } /** * Write uncompressed unicode * *@param input the String containing the unicode data to be written *@param output the byte array to hold the uncompressed unicode *@param offset the offset to start writing into the byte array */ public static void putUncompressedUnicode(final String input, final byte[] output, final int offset) { int strlen = input.length(); for (int k = 0; k < strlen; k++) { char c = input.charAt(k); output[offset + (2 * k)] = (byte) c; output[offset + (2 * k) + 1] = (byte) (c >> 8); } } /** * Write uncompressed unicode * *@param input the String containing the unicode data to be written *@param output the byte array to hold the uncompressed unicode *@param offset the offset to start writing into the byte array */ public static void putUncompressedUnicodeHigh(final String input, final byte[] output, final int offset) { int strlen = input.length(); for (int k = 0; k < strlen; k++) { char c = input.charAt(k); output[offset + (2 * k)] = (byte) (c >> 8); output[offset + (2 * k)] = (byte) c; } } /** * Description of the Method * *@param message Description of the Parameter *@param params Description of the Parameter *@return Description of the Return Value */ public static String format(String message, Object[] params) { int currentParamNumber = 0; StringBuffer formattedMessage = new StringBuffer(); for (int i = 0; i < message.length(); i++) { if (message.charAt(i) == '%') { if (currentParamNumber >= params.length) { formattedMessage.append("?missing data?"); } else if ((params[currentParamNumber] instanceof Number) && (i + 1 < message.length())) { i += matchOptionalFormatting( (Number) params[currentParamNumber++], message.substring(i + 1), formattedMessage); } else { formattedMessage.append(params[currentParamNumber++].toString()); } } else { if ((message.charAt(i) == '\\') && (i + 1 < message.length()) && (message.charAt(i + 1) == '%')) { formattedMessage.append('%'); i++; } else { formattedMessage.append(message.charAt(i)); } } } return formattedMessage.toString(); } /** * Description of the Method * *@param number Description of the Parameter *@param formatting Description of the Parameter *@param outputTo Description of the Parameter *@return Description of the Return Value */ private static int matchOptionalFormatting(Number number, String formatting, StringBuffer outputTo) { NumberFormat numberFormat = NumberFormat.getInstance(); if ((0 < formatting.length()) && Character.isDigit(formatting.charAt(0))) { numberFormat.setMinimumIntegerDigits(Integer.parseInt(formatting.charAt(0) + "")); if ((2 < formatting.length()) && (formatting.charAt(1) == '.') && Character.isDigit(formatting.charAt(2))) { numberFormat.setMaximumFractionDigits(Integer.parseInt(formatting.charAt(2) + "")); numberFormat.format(number, outputTo, new FieldPosition(0)); return 3; } numberFormat.format(number, outputTo, new FieldPosition(0)); return 1; } else if ((0 < formatting.length()) && (formatting.charAt(0) == '.')) { if ((1 < formatting.length()) && Character.isDigit(formatting.charAt(1))) { numberFormat.setMaximumFractionDigits(Integer.parseInt(formatting.charAt(1) + "")); numberFormat.format(number, outputTo, new FieldPosition(0)); return 2; } } numberFormat.format(number, outputTo, new FieldPosition(0)); return 1; } /** * @return the encoding we want to use (ISO-8859-1) */ public static String getPreferredEncoding() { return ENCODING; }}
\ No newline at end of file
+/*
+ * ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+package org.apache.poi.util;
+
+import java.io.UnsupportedEncodingException;
+
+import java.text.NumberFormat;
+import java.text.FieldPosition;
+
+/**
+ * Title: String Utility Description: Collection of string handling utilities
+ *
+ * Now it is quite confusing: the method pairs, in which
+ * one of them write data and other read written data are:
+ * putUncompressedUnicodeHigh and getFromUnicode
+ * putUncompressedUnicode and getFromUnicodeHigh
+ *
+ *@author Andrew C. Oliver
+ *@author Sergei Kozello (sergeikozello at mail.ru)
+ *@created May 10, 2002
+ *@version 1.0
+ */
+
+public class StringUtil {
+
+ private final static String ENCODING="ISO-8859-1";
+ /**
+ * Constructor for the StringUtil object
+ */
+ private StringUtil() { }
+
+
+ /**
+ * given a byte array of 16-bit unicode characters, compress to 8-bit and
+ * return a string
+ *
+ * { 0x16, 0x00 } -> 0x16
+ *
+ *@param string the byte array to be converted
+ *@param offset the initial offset into the
+ * byte array. it is assumed that string[ offset ] and string[ offset +
+ * 1 ] contain the first 16-bit unicode character
+ *@param len
+ *@return the converted string
+ *@exception ArrayIndexOutOfBoundsException if offset is out of bounds for
+ * the byte array (i.e., is negative or is greater than or equal to
+ * string.length)
+ *@exception IllegalArgumentException if len is too large (i.e.,
+ * there is not enough data in string to create a String of that
+ * length)
+ *@len the length of the final string
+ */
+
+ public static String getFromUnicodeHigh(final byte[] string,
+ final int offset, final int len)
+ throws ArrayIndexOutOfBoundsException, IllegalArgumentException {
+
+ if ((offset < 0) || (offset >= string.length)) {
+ throw new ArrayIndexOutOfBoundsException("Illegal offset");
+ }
+ if ((len < 0) || (((string.length - offset) / 2) < len)) {
+ throw new IllegalArgumentException("Illegal length");
+ }
+
+ char[] chars = new char[ len ];
+ for ( int i = 0; i < chars.length; i++ ) {
+ chars[i] = (char)( string[ offset + ( 2*i ) ] & 0xFF |
+ ( string[ offset + ( 2*i+1 ) ] << 8 ) );
+ }
+
+ return new String( chars );
+ }
+
+
+ /**
+ * given a byte array of 16-bit unicode characters, compress to 8-bit and
+ * return a string
+ *
+ * { 0x16, 0x00 } -> 0x16
+ *
+ *@param string the byte array to be converted
+ *@return the converted string
+ */
+
+ public static String getFromUnicodeHigh( final byte[] string ) {
+ return getFromUnicodeHigh( string, 0, string.length / 2 );
+ }
+
+
+ /**
+ * given a byte array of 16-bit unicode characters, compress to 8-bit and
+ * return a string
+ *
+ * { 0x00, 0x16 } -> 0x16
+ *
+ *@param string the byte array to be converted
+ *@param offset the initial offset into the
+ * byte array. it is assumed that string[ offset ] and string[ offset +
+ * 1 ] contain the first 16-bit unicode character
+ *@param len
+ *@return the converted string
+ *@exception ArrayIndexOutOfBoundsException if offset is out of bounds for
+ * the byte array (i.e., is negative or is greater than or equal to
+ * string.length)
+ *@exception IllegalArgumentException if len is too large (i.e.,
+ * there is not enough data in string to create a String of that
+ * length)
+ *@len the length of the final string
+ */
+
+ public static String getFromUnicode(final byte[] string,
+ final int offset, final int len)
+ throws ArrayIndexOutOfBoundsException, IllegalArgumentException {
+ if ((offset < 0) || (offset >= string.length)) {
+ throw new ArrayIndexOutOfBoundsException("Illegal offset");
+ }
+ if ((len < 0) || (((string.length - offset) / 2) < len)) {
+ throw new IllegalArgumentException("Illegal length");
+ }
+
+
+ char[] chars = new char[ len ];
+ for ( int i = 0; i < chars.length; i++ ) {
+ chars[i] = (char)( ( string[ offset + ( 2*i ) ] << 8 ) +
+ string[ offset + ( 2*i+1 ) ] );
+ }
+
+ return new String( chars );
+ }
+
+
+ /**
+ * given a byte array of 16-bit unicode characters, compress to 8-bit and
+ * return a string
+ *
+ * { 0x00, 0x16 } -> 0x16
+ *
+ *@param string the byte array to be converted
+ *@return the converted string
+ */
+
+ public static String getFromUnicode(final byte[] string) {
+ return getFromUnicode(string, 0, string.length / 2);
+ }
+
+
+ /**
+ * read compressed unicode(8bit)
+ *
+ * @author Toshiaki Kamoshida(kamoshida.toshiaki at future dot co dot jp)
+ *
+ * @param string byte array to read
+ * @param offset offset to read byte array
+ * @param len length to read byte array
+ * @return String generated String instance by reading byte array
+ */
+ public static String getFromCompressedUnicode(final byte[] string,
+ final int offset, final int len){
+ try{
+ return new String(string,offset,len,"ISO-8859-1");
+ }
+ catch(UnsupportedEncodingException e){
+ throw new InternalError();/* unreachable */
+ }
+ }
+
+ /**
+ * write compressed unicode
+ *
+ *@param input the String containing the data to be written
+ *@param output the byte array to which the data is to be written
+ *@param offset an offset into the byte arrat at which the data is start
+ * when written
+ */
+
+ public static void putCompressedUnicode(final String input,
+ final byte[] output,
+ final int offset) {
+ int strlen = input.length();
+
+ for (int k = 0; k < strlen; k++) {
+ output[offset + k] = (byte) input.charAt(k);
+ }
+ }
+
+
+ /**
+ * Write uncompressed unicode
+ *
+ *@param input the String containing the unicode data to be written
+ *@param output the byte array to hold the uncompressed unicode
+ *@param offset the offset to start writing into the byte array
+ */
+
+ public static void putUncompressedUnicode(final String input,
+ final byte[] output,
+ final int offset) {
+ int strlen = input.length();
+
+ for (int k = 0; k < strlen; k++) {
+ char c = input.charAt(k);
+
+ output[offset + (2 * k)] = (byte) c;
+ output[offset + (2 * k) + 1] = (byte) (c >> 8);
+ }
+ }
+
+ /**
+ * Write uncompressed unicode
+ *
+ *@param input the String containing the unicode data to be written
+ *@param output the byte array to hold the uncompressed unicode
+ *@param offset the offset to start writing into the byte array
+ */
+
+ public static void putUncompressedUnicodeHigh(final String input,
+ final byte[] output,
+ final int offset) {
+ int strlen = input.length();
+
+ for (int k = 0; k < strlen; k++) {
+ char c = input.charAt(k);
+
+ output[offset + (2 * k)] = (byte) (c >> 8);
+ output[offset + (2 * k)] = (byte) c;
+ }
+ }
+
+
+
+
+ /**
+ * Description of the Method
+ *
+ *@param message Description of the Parameter
+ *@param params Description of the Parameter
+ *@return Description of the Return Value
+ */
+ public static String format(String message, Object[] params) {
+ int currentParamNumber = 0;
+ StringBuffer formattedMessage = new StringBuffer();
+
+ for (int i = 0; i < message.length(); i++) {
+ if (message.charAt(i) == '%') {
+ if (currentParamNumber >= params.length) {
+ formattedMessage.append("?missing data?");
+ } else if ((params[currentParamNumber] instanceof Number)
+ && (i + 1 < message.length())) {
+ i += matchOptionalFormatting(
+ (Number) params[currentParamNumber++],
+ message.substring(i + 1), formattedMessage);
+ } else {
+ formattedMessage.append(params[currentParamNumber++].toString());
+ }
+ } else {
+ if ((message.charAt(i) == '\\') && (i + 1 < message.length())
+ && (message.charAt(i + 1) == '%')) {
+ formattedMessage.append('%');
+ i++;
+ } else {
+ formattedMessage.append(message.charAt(i));
+ }
+ }
+ }
+ return formattedMessage.toString();
+ }
+
+
+ /**
+ * Description of the Method
+ *
+ *@param number Description of the Parameter
+ *@param formatting Description of the Parameter
+ *@param outputTo Description of the Parameter
+ *@return Description of the Return Value
+ */
+ private static int matchOptionalFormatting(Number number,
+ String formatting,
+ StringBuffer outputTo) {
+ NumberFormat numberFormat = NumberFormat.getInstance();
+
+ if ((0 < formatting.length())
+ && Character.isDigit(formatting.charAt(0))) {
+ numberFormat.setMinimumIntegerDigits(Integer.parseInt(formatting.charAt(0) + ""));
+ if ((2 < formatting.length()) && (formatting.charAt(1) == '.')
+ && Character.isDigit(formatting.charAt(2))) {
+ numberFormat.setMaximumFractionDigits(Integer.parseInt(formatting.charAt(2) + ""));
+ numberFormat.format(number, outputTo, new FieldPosition(0));
+ return 3;
+ }
+ numberFormat.format(number, outputTo, new FieldPosition(0));
+ return 1;
+ } else if ((0 < formatting.length()) && (formatting.charAt(0) == '.')) {
+ if ((1 < formatting.length())
+ && Character.isDigit(formatting.charAt(1))) {
+ numberFormat.setMaximumFractionDigits(Integer.parseInt(formatting.charAt(1) + ""));
+ numberFormat.format(number, outputTo, new FieldPosition(0));
+ return 2;
+ }
+ }
+ numberFormat.format(number, outputTo, new FieldPosition(0));
+ return 1;
+ }
+
+ /**
+ * @return the encoding we want to use (ISO-8859-1)
+ */
+ public static String getPreferredEncoding() {
+ return ENCODING;
+ }
+}
\ No newline at end of file
*/
package org.apache.poi.hpsf.basic;
-import org.apache.poi.poifs.filesystem.*;
+
+import org.apache.poi.poifs.filesystem.POIFSDocumentPath;
public void setName(final String name)
{
- this.name = name;
+ this.name = name;
}
public String getName()
{
- return name;
+ return name;
}
public void setPath(final POIFSDocumentPath path)
{
- this.path = path;
+ this.path = path;
}
public POIFSDocumentPath getPath()
{
- return path;
+ return path;
}
public void setBytes(final byte[] bytes)
{
- this.bytes = bytes;
+ this.bytes = bytes;
}
public byte[] getBytes()
{
- return bytes;
+ return bytes;
}
}
package org.apache.poi.hpsf.basic;
-import java.io.*;
-import java.util.*;
-import junit.framework.*;
-import org.apache.poi.hpsf.*;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.poi.hpsf.DocumentSummaryInformation;
+import org.apache.poi.hpsf.HPSFException;
+import org.apache.poi.hpsf.MarkUnsupportedException;
+import org.apache.poi.hpsf.NoPropertySetStreamException;
+import org.apache.poi.hpsf.PropertySet;
+import org.apache.poi.hpsf.PropertySetFactory;
+import org.apache.poi.hpsf.SummaryInformation;
+import org.apache.poi.hpsf.UnexpectedPropertySetTypeException;
public class TestBasic extends TestCase
{
- final static String POI_FS = "TestGermanWord90.doc";
- final static String[] POI_FILES = new String[]
- {
- "\005SummaryInformation",
- "\005DocumentSummaryInformation",
- "WordDocument",
- "\001CompObj",
- "1Table"
- };
- final static int BYTE_ORDER = 0xfffe;
- final static int FORMAT = 0x0000;
- final static int OS_VERSION = 0x00020A04;
- final static byte[] CLASS_ID =
- {
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00
- };
- final static int[] SECTION_COUNT =
+ static final String POI_FS = "TestGermanWord90.doc";
+ static final String[] POI_FILES = new String[]
+ {
+ "\005SummaryInformation",
+ "\005DocumentSummaryInformation",
+ "WordDocument",
+ "\001CompObj",
+ "1Table"
+ };
+ static final int BYTE_ORDER = 0xfffe;
+ static final int FORMAT = 0x0000;
+ static final int OS_VERSION = 0x00020A04;
+ static final byte[] CLASS_ID =
+ {
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00
+ };
+ static final int[] SECTION_COUNT =
{1, 2};
- final static boolean[] IS_SUMMARY_INFORMATION =
+ static final boolean[] IS_SUMMARY_INFORMATION =
{true, false};
- final static boolean[] IS_DOCUMENT_SUMMARY_INFORMATION =
- {false, true};
+ static final boolean[] IS_DOCUMENT_SUMMARY_INFORMATION =
+ {false, true};
POIFile[] poiFiles;
- public TestBasic(String name)
+ public TestBasic(final String name)
{
super(name);
}
*/
public void setUp() throws FileNotFoundException, IOException
{
- final File dataDir =
- new File(System.getProperty("HPSF.testdata.path"));
- final File data = new File(dataDir, POI_FS);
+ final File dataDir =
+ new File(System.getProperty("HPSF.testdata.path"));
+ final File data = new File(dataDir, POI_FS);
- poiFiles = Util.readPOIFiles(data);
+ poiFiles = Util.readPOIFiles(data);
}
*/
public void testReadFiles() throws IOException
{
- String[] expected = POI_FILES;
- for (int i = 0; i < expected.length; i++)
- Assert.assertEquals(poiFiles[i].getName(), expected[i]);
+ String[] expected = POI_FILES;
+ for (int i = 0; i < expected.length; i++)
+ Assert.assertEquals(poiFiles[i].getName(), expected[i]);
}
*/
public void testCreatePropertySets() throws IOException
{
- Class[] expected = new Class[]
- {
- SummaryInformation.class,
- DocumentSummaryInformation.class,
- NoPropertySetStreamException.class,
- NoPropertySetStreamException.class,
- NoPropertySetStreamException.class
- };
- for (int i = 0; i < expected.length; i++)
- {
- InputStream in = new ByteArrayInputStream(poiFiles[i].getBytes());
- Object o;
- try
- {
- o = PropertySetFactory.create(in);
- }
- catch (NoPropertySetStreamException ex)
- {
- o = ex;
- }
- catch (UnexpectedPropertySetTypeException ex)
- {
- o = ex;
- }
- catch (MarkUnsupportedException ex)
- {
- o = ex;
- }
- in.close();
- Assert.assertEquals(o.getClass(), expected[i]);
- }
+ Class[] expected = new Class[]
+ {
+ SummaryInformation.class,
+ DocumentSummaryInformation.class,
+ NoPropertySetStreamException.class,
+ NoPropertySetStreamException.class,
+ NoPropertySetStreamException.class
+ };
+ for (int i = 0; i < expected.length; i++)
+ {
+ InputStream in = new ByteArrayInputStream(poiFiles[i].getBytes());
+ Object o;
+ try
+ {
+ o = PropertySetFactory.create(in);
+ }
+ catch (NoPropertySetStreamException ex)
+ {
+ o = ex;
+ }
+ catch (UnexpectedPropertySetTypeException ex)
+ {
+ o = ex;
+ }
+ catch (MarkUnsupportedException ex)
+ {
+ o = ex;
+ }
+ in.close();
+ Assert.assertEquals(o.getClass(), expected[i]);
+ }
}
*/
public void testPropertySetMethods() throws IOException, HPSFException
{
- String[] expected = POI_FILES;
-
- /* Loop over the two property sets. */
- for (int i = 0; i < 2; i++)
- {
- byte[] b = poiFiles[i].getBytes();
- PropertySet ps =
- PropertySetFactory.create(new ByteArrayInputStream(b));
- Assert.assertEquals(ps.getByteOrder(), BYTE_ORDER);
- Assert.assertEquals(ps.getFormat(), FORMAT);
- Assert.assertEquals(ps.getOSVersion(), OS_VERSION);
- Assert.assertEquals(new String(ps.getClassID().getBytes()),
- new String(CLASS_ID));
- Assert.assertEquals(ps.getSectionCount(), SECTION_COUNT[i]);
- Assert.assertEquals(ps.isSummaryInformation(),
- IS_SUMMARY_INFORMATION[i]);
- Assert.assertEquals(ps.isDocumentSummaryInformation(),
- IS_DOCUMENT_SUMMARY_INFORMATION[i]);
- }
+
+ /* Loop over the two property sets. */
+ for (int i = 0; i < 2; i++)
+ {
+ byte[] b = poiFiles[i].getBytes();
+ PropertySet ps =
+ PropertySetFactory.create(new ByteArrayInputStream(b));
+ Assert.assertEquals(ps.getByteOrder(), BYTE_ORDER);
+ Assert.assertEquals(ps.getFormat(), FORMAT);
+ Assert.assertEquals(ps.getOSVersion(), OS_VERSION);
+ Assert.assertEquals(new String(ps.getClassID().getBytes()),
+ new String(CLASS_ID));
+ Assert.assertEquals(ps.getSectionCount(), SECTION_COUNT[i]);
+ Assert.assertEquals(ps.isSummaryInformation(),
+ IS_SUMMARY_INFORMATION[i]);
+ Assert.assertEquals(ps.isDocumentSummaryInformation(),
+ IS_DOCUMENT_SUMMARY_INFORMATION[i]);
+ }
}
/**
* <p>Runs the test cases stand-alone.</p>
*/
- public static void main(String[] args) throws Throwable
+ public static void main(final String[] args) throws Throwable
{
- System.setProperty("HPSF.testdata.path",
- "./src/testcases/org/apache/poi/hpsf/data");
- junit.textui.TestRunner.run(TestBasic.class);
+ System.setProperty("HPSF.testdata.path",
+ "./src/testcases/org/apache/poi/hpsf/data");
+ junit.textui.TestRunner.run(TestBasic.class);
}
}
--- /dev/null
+package org.apache.poi.hpsf.basic;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.poi.hpsf.HPSFException;
+import org.apache.poi.hpsf.MarkUnsupportedException;
+import org.apache.poi.hpsf.NoPropertySetStreamException;
+import org.apache.poi.hpsf.PropertySet;
+import org.apache.poi.hpsf.PropertySetFactory;
+import org.apache.poi.hpsf.SummaryInformation;
+import org.apache.poi.hpsf.UnexpectedPropertySetTypeException;
+
+/**
+ * <p>Test case for OLE2 files with empty properties. An empty property's type
+ * is {@link Variant.VT_EMPTY}.</p>
+ *
+ * @author Rainer Klute <a
+ * href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
+ * @since 2003-07-25
+ * @version $Id$
+ */
+public class TestEmptyProperties extends TestCase
+{
+
+ /**
+ * <p>This test file's summary information stream contains some empty
+ * properties.</p>
+ */
+ static final String POI_FS = "TestCorel.shw";
+
+ static final String[] POI_FILES = new String[]
+ {
+ "PerfectOffice_MAIN",
+ "\005SummaryInformation",
+ "Main"
+ };
+
+ POIFile[] poiFiles;
+
+
+
+ /**
+ * <p>Constructor</p>
+ *
+ * @param name The name of the test case
+ */
+ public TestEmptyProperties(final String name)
+ {
+ super(name);
+ }
+
+
+
+ /**
+ * <p>Read a the test file from the "data" directory.</p>
+ *
+ * @exception FileNotFoundException if the file containing the test data
+ * does not exist
+ * @exception IOException if an I/O exception occurs
+ */
+ public void setUp() throws FileNotFoundException, IOException
+ {
+ final File dataDir =
+ new File(System.getProperty("HPSF.testdata.path"));
+ final File data = new File(dataDir, POI_FS);
+
+ poiFiles = Util.readPOIFiles(data);
+ }
+
+
+
+ /**
+ * <p>Checks the names of the files in the POI filesystem. They
+ * are expected to be in a certain order.</p>
+ *
+ * @exception IOException if an I/O exception occurs
+ */
+ public void testReadFiles() throws IOException
+ {
+ String[] expected = POI_FILES;
+ for (int i = 0; i < expected.length; i++)
+ Assert.assertEquals(poiFiles[i].getName(), expected[i]);
+ }
+
+
+
+ /**
+ * <p>Tests whether property sets can be created from the POI
+ * files in the POI file system. This test case expects the first
+ * file to be a {@link SummaryInformation}, the second file to be
+ * a {@link DocumentSummaryInformation} and the rest to be no
+ * property sets. In the latter cases a {@link
+ * NoPropertySetStreamException} will be thrown when trying to
+ * create a {@link PropertySet}.</p>
+ *
+ * @exception IOException if an I/O exception occurs
+ */
+ public void testCreatePropertySets() throws IOException
+ {
+ Class[] expected = new Class[]
+ {
+ NoPropertySetStreamException.class,
+ SummaryInformation.class,
+ NoPropertySetStreamException.class
+ };
+ for (int i = 0; i < expected.length; i++)
+ {
+ InputStream in = new ByteArrayInputStream(poiFiles[i].getBytes());
+ Object o;
+ try
+ {
+ o = PropertySetFactory.create(in);
+ }
+ catch (NoPropertySetStreamException ex)
+ {
+ o = ex;
+ }
+ catch (UnexpectedPropertySetTypeException ex)
+ {
+ o = ex;
+ }
+ catch (MarkUnsupportedException ex)
+ {
+ o = ex;
+ }
+ in.close();
+ Assert.assertEquals(o.getClass(), expected[i]);
+ }
+ }
+
+
+
+ /**
+ * <p>Tests the {@link PropertySet} methods. The test file has two
+ * property sets: the first one is a {@link SummaryInformation},
+ * the second one is a {@link DocumentSummaryInformation}.</p>
+ *
+ * @exception IOException if an I/O exception occurs
+ * @exception HPSFException if an HPSF operation fails
+ */
+ public void testPropertySetMethods() throws IOException, HPSFException
+ {
+ byte[] b = poiFiles[1].getBytes();
+ PropertySet ps =
+ PropertySetFactory.create(new ByteArrayInputStream(b));
+ SummaryInformation s = (SummaryInformation) ps;
+ assertNull(s.getTitle());
+ assertNull(s.getSubject());
+ assertNotNull(s.getAuthor());
+ assertNull(s.getKeywords());
+ assertNull(s.getComments());
+ assertNotNull(s.getTemplate());
+ assertNotNull(s.getLastAuthor());
+ assertNotNull(s.getRevNumber());
+ assertNull(s.getEditTime());
+ assertNull(s.getLastPrinted());
+ assertNull(s.getCreateDateTime());
+ assertNull(s.getLastSaveDateTime());
+ assertEquals(s.getPageCount(), 0);
+ assertEquals(s.getWordCount(), 0);
+ assertEquals(s.getCharCount(), 0);
+ assertNull(s.getThumbnail());
+ assertNull(s.getApplicationName());
+ }
+
+
+
+ /**
+ * <p>Runs the test cases stand-alone.</p>
+ *
+ * @param args the command-line arguments (unused)
+ *
+ * @exception Throwable if any exception or error occurs
+ */
+ public static void main(final String[] args) throws Throwable
+ {
+ System.setProperty("HPSF.testdata.path",
+ "./src/testcases/org/apache/poi/hpsf/data");
+ junit.textui.TestRunner.run(TestBasic.class);
+ }
+
+}
package org.apache.poi.hpsf.basic;
-import java.io.*;
-import java.util.*;
-import junit.framework.*;
-import org.apache.poi.hpsf.*;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.poi.hpsf.HPSFException;
+import org.apache.poi.hpsf.PropertySet;
+import org.apache.poi.hpsf.PropertySetFactory;
+import org.apache.poi.hpsf.Section;
public class TestUnicode extends TestCase
{
- final static String POI_FS = "TestUnicode.xls";
- final static String[] POI_FILES = new String[]
- {
- "\005DocumentSummaryInformation",
- };
+ static final String POI_FS = "TestUnicode.xls";
+ static final String[] POI_FILES = new String[]
+ {
+ "\005DocumentSummaryInformation",
+ };
File data;
POIFile[] poiFiles;
- public TestUnicode(String name)
+ /**
+ * <p>Constructor</p>
+ *
+ * @param name the test case's name
+ */
+ public TestUnicode(final String name)
{
super(name);
}
/**
* <p>Read a the test file from the "data" directory.</p>
*/
- public void setUp() throws FileNotFoundException, IOException
+ protected void setUp() throws FileNotFoundException, IOException
{
- final File dataDir =
- new File(System.getProperty("HPSF.testdata.path"));
- data = new File(dataDir, POI_FS);
+ final File dataDir =
+ new File(System.getProperty("HPSF.testdata.path"));
+ data = new File(dataDir, POI_FS);
}
*/
public void testPropertySetMethods() throws IOException, HPSFException
{
- POIFile poiFile = Util.readPOIFiles(data, POI_FILES)[0];
- byte[] b = poiFile.getBytes();
- PropertySet ps =
- PropertySetFactory.create(new ByteArrayInputStream(b));
- Assert.assertTrue(ps.isDocumentSummaryInformation());
- Assert.assertEquals(ps.getSectionCount(), 2);
- Section s = (Section) ps.getSections().get(1);
- Assert.assertEquals(s.getProperty(1),
- new Integer(1200));
- Assert.assertEquals(s.getProperty(2),
- new Long(4198897018l));
- Assert.assertEquals(s.getProperty(3),
- "MCon_Info zu Office bei Schreiner");
- Assert.assertEquals(s.getProperty(4),
- "petrovitsch@schreiner-online.de");
- Assert.assertEquals(s.getProperty(5),
- "Petrovitsch, Wilhelm");
+ POIFile poiFile = Util.readPOIFiles(data, POI_FILES)[0];
+ byte[] b = poiFile.getBytes();
+ PropertySet ps =
+ PropertySetFactory.create(new ByteArrayInputStream(b));
+ Assert.assertTrue(ps.isDocumentSummaryInformation());
+ Assert.assertEquals(ps.getSectionCount(), 2);
+ Section s = (Section) ps.getSections().get(1);
+ Assert.assertEquals(s.getProperty(1),
+ new Integer(1200));
+ Assert.assertEquals(s.getProperty(2),
+ new Long(4198897018L));
+ Assert.assertEquals(s.getProperty(3),
+ "MCon_Info zu Office bei Schreiner");
+ Assert.assertEquals(s.getProperty(4),
+ "petrovitsch@schreiner-online.de");
+ Assert.assertEquals(s.getProperty(5),
+ "Petrovitsch, Wilhelm");
}
/**
* <p>Runs the test cases stand-alone.</p>
*/
- public static void main(String[] args)
+ public static void main(final String[] args)
{
- System.setProperty("HPSF.testdata.path",
- "./src/testcases/org/apache/poi/hpsf/data");
+ System.setProperty("HPSF.testdata.path",
+ "./src/testcases/org/apache/poi/hpsf/data");
junit.textui.TestRunner.run(TestUnicode.class);
}
package org.apache.poi.hpsf.basic;
-import java.io.*;
-import java.util.*;
-import org.apache.poi.poifs.eventfilesystem.*;
+import java.io.ByteArrayOutputStream;
+import java.io.EOFException;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.poi.poifs.eventfilesystem.POIFSReader;
+import org.apache.poi.poifs.eventfilesystem.POIFSReaderEvent;
+import org.apache.poi.poifs.eventfilesystem.POIFSReaderListener;
/**
* <p>Reads bytes from an input stream and writes them to an
* output stream until end of file is encountered.</p>
+ *
+ * @param in the input stream to read from
+ * @param out the output stream to write to
*/
public static void copy(final InputStream in, final OutputStream out)
throws IOException
read = in.read(b, 0, BUF_SIZE);
if (read > 0)
out.write(b, 0, read);
- else
- eof = true;
+ else
+ eof = true;
}
catch (EOFException ex)
{
* into memory and thus does not cope well with large POI
* filessystems.</p>
*
- * @param file The name of the POI filesystem as seen by the
+ * @param poiFs The name of the POI filesystem as seen by the
* operating system. (This is the "filename".)
*
* @return The POI files. The elements are ordered in the same way
* as the files in the POI filesystem.
*/
public static POIFile[] readPOIFiles(final File poiFs)
- throws FileNotFoundException, IOException
+ throws FileNotFoundException, IOException
{
- return readPOIFiles(poiFs, null);
+ return readPOIFiles(poiFs, null);
}
* files into memory and thus does not cope well with large POI
* filessystems.</p>
*
- * @param file The name of the POI filesystem as seen by the
+ * @param poiFs The name of the POI filesystem as seen by the
* operating system. (This is the "filename".)
*
* @param poiFiles The names of the POI files to be read.
* as the files in the POI filesystem.
*/
public static POIFile[] readPOIFiles(final File poiFs,
- final String[] poiFiles)
- throws FileNotFoundException, IOException
+ final String[] poiFiles)
+ throws FileNotFoundException, IOException
{
- final List files = new ArrayList();
- POIFSReader r = new POIFSReader();
- POIFSReaderListener pfl = new POIFSReaderListener()
- {
- public void processPOIFSReaderEvent(POIFSReaderEvent event)
- {
- try
- {
- POIFile f = new POIFile();
- f.setName(event.getName());
- f.setPath(event.getPath());
- InputStream in = event.getStream();
- ByteArrayOutputStream out =
- new ByteArrayOutputStream();
- Util.copy(in, out);
- out.close();
- f.setBytes(out.toByteArray());
- files.add(f);
- }
- catch (IOException ex)
- {
- ex.printStackTrace();
- throw new RuntimeException(ex.getMessage());
- }
- }
- };
- if (poiFiles == null)
- /* Register the listener for all POI files. */
- r.registerListener(pfl);
- else
- /* Register the listener for the specified POI files
- * only. */
- for (int i = 0; i < poiFiles.length; i++)
- r.registerListener(pfl, poiFiles[i]);
-
- /* Read the POI filesystem. */
- r.read(new FileInputStream(poiFs));
- POIFile[] result = new POIFile[files.size()];
- for (int i = 0; i < result.length; i++)
- result[i] = (POIFile) files.get(i);
- return result;
+ final List files = new ArrayList();
+ POIFSReader r = new POIFSReader();
+ POIFSReaderListener pfl = new POIFSReaderListener()
+ {
+ public void processPOIFSReaderEvent(final POIFSReaderEvent event)
+ {
+ try
+ {
+ POIFile f = new POIFile();
+ f.setName(event.getName());
+ f.setPath(event.getPath());
+ InputStream in = event.getStream();
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ Util.copy(in, out);
+ out.close();
+ f.setBytes(out.toByteArray());
+ files.add(f);
+ }
+ catch (IOException ex)
+ {
+ ex.printStackTrace();
+ throw new RuntimeException(ex.getMessage());
+ }
+ }
+ };
+ if (poiFiles == null)
+ /* Register the listener for all POI files. */
+ r.registerListener(pfl);
+ else
+ /* Register the listener for the specified POI files
+ * only. */
+ for (int i = 0; i < poiFiles.length; i++)
+ r.registerListener(pfl, poiFiles[i]);
+
+ /* Read the POI filesystem. */
+ r.read(new FileInputStream(poiFs));
+ POIFile[] result = new POIFile[files.size()];
+ for (int i = 0; i < result.length; i++)
+ result[i] = (POIFile) files.get(i);
+ return result;
}
*/
public static void printSystemProperties()
{
- Properties p = System.getProperties();
- List names = new LinkedList();
- for (Iterator i = p.keySet().iterator(); i.hasNext();)
- names.add(i.next());
- Collections.sort(names);
- for (Iterator i = names.iterator(); i.hasNext();)
+ final Properties p = System.getProperties();
+ final List names = new LinkedList();
+ for (Iterator i = p.keySet().iterator(); i.hasNext();)
+ names.add(i.next());
+ Collections.sort(names);
+ for (final Iterator i = names.iterator(); i.hasNext();)
{
- String name = (String) i.next();
- String value = (String) p.get(name);
- System.out.println(name + ": " + value);
- }
- System.out.println("Current directory: " +
- System.getProperty("user.dir"));
+ String name = (String) i.next();
+ String value = (String) p.get(name);
+ System.out.println(name + ": " + value);
+ }
+ System.out.println("Current directory: " +
+ System.getProperty("user.dir"));
}
}
--- /dev/null
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003, 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+package org.apache.poi.hssf.usermodel;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Date;
+
+import junit.framework.TestCase;
+
+
+
+/**
+ * @author Avik Sengupta
+ */
+
+public class TestBugs
+extends TestCase {
+ public TestBugs(String s) {
+ super(s);
+ }
+
+ public void test15228()
+ throws java.io.IOException
+ {
+ String readFilename = System.getProperty("HSSF.testdata.path");
+ FileInputStream in = new FileInputStream(readFilename+File.separator+"15228.xls");
+ HSSFWorkbook wb = new HSSFWorkbook(in);
+ HSSFSheet s = wb.getSheetAt(0);
+ HSSFRow r = s.createRow(0);
+ HSSFCell c = r.createCell((short)0);
+ c.setCellValue(10);
+ File file = File.createTempFile("test15228",".xls");
+ FileOutputStream out = new FileOutputStream(file);
+ wb.write(out);
+ assertTrue("No exception thrown", true);
+ assertTrue("File Should Exist", file.exists());
+
+ }
+
+}
+
+
+
--- /dev/null
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+package org.apache.poi.hssf.usermodel;
+
+import junit.framework.TestCase;
+import org.apache.poi.hssf.usermodel.HSSFHeader;
+import org.apache.poi.hssf.usermodel.HSSFFooter;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+
+/**
+ * Tests row shifting capabilities.
+ *
+ *
+ * @author Shawn Laubach (slaubach at apache dot com)
+ */
+
+public class TestHSSFHeaderFooter extends TestCase {
+
+ /**
+ * Constructor for TestHeaderFooter.
+ * @param arg0
+ */
+ public TestHSSFHeaderFooter(String arg0) {
+ super(arg0);
+ }
+
+ /**
+ * Tests that get header retreives the proper values.
+ *
+ * @author Shawn Laubach (slaubach at apache dot org)
+ */
+ public void testRetrieveCorrectHeader() throws Exception
+ {
+ // Read initial file in
+ String filename = System.getProperty( "HSSF.testdata.path" );
+ filename = filename + "/EmbeddedChartHeaderTest.xls";
+ FileInputStream fin = new FileInputStream( filename );
+ HSSFWorkbook wb = new HSSFWorkbook( fin );
+ fin.close();
+ HSSFSheet s = wb.getSheetAt( 0 );
+ HSSFHeader head = s.getHeader();
+
+ assertEquals("Top Left", head.getLeft());
+ assertEquals("Top Center", head.getCenter());
+ assertEquals("Top Right", head.getRight());
+ }
+
+ /**
+ * Tests that get header retreives the proper values.
+ *
+ * @author Shawn Laubach (slaubach at apache dot org)
+ */
+ public void testRetrieveCorrectFooter() throws Exception
+ {
+ // Read initial file in
+ String filename = System.getProperty( "HSSF.testdata.path" );
+ filename = filename + "/EmbeddedChartHeaderTest.xls";
+ FileInputStream fin = new FileInputStream( filename );
+ HSSFWorkbook wb = new HSSFWorkbook( fin );
+ fin.close();
+ HSSFSheet s = wb.getSheetAt( 0 );
+ HSSFFooter foot = s.getFooter();
+
+ assertEquals("Bottom Left", foot.getLeft());
+ assertEquals("Bottom Center", foot.getCenter());
+ assertEquals("Bottom Right", foot.getRight());
+ }
+}
+
package org.apache.poi.hssf.usermodel;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+
import junit.framework.TestCase;
+
import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.record.HCenterRecord;
+import org.apache.poi.hssf.record.SCLRecord;
import org.apache.poi.hssf.record.VCenterRecord;
import org.apache.poi.hssf.record.WSBoolRecord;
-import org.apache.poi.hssf.record.SCLRecord;
import org.apache.poi.hssf.record.WindowTwoRecord;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
+import org.apache.poi.hssf.util.Region;
/**
* Tests HSSFSheet. This test case is very incomplete at the moment.
assertTrue(sclLoc == window2Loc + 1);
}
+
+
+ /**
+ * When removing one merged region, it would break
+ *
+ */
+ public void testRemoveMerged() {
+ HSSFWorkbook wb = new HSSFWorkbook();
+ HSSFSheet sheet = wb.createSheet();
+ Region region = new Region(0, (short)0, 1, (short)1);
+ sheet.addMergedRegion(region);
+ region = new Region(1, (short)0, 2, (short)1);
+ sheet.addMergedRegion(region);
+
+ sheet.removeMergedRegion(0);
+
+ region = sheet.getMergedRegionAt(0);
+ assertEquals("Left over region should be starting at row 1", 1, region.getRowFrom());
+
+ sheet.removeMergedRegion(0);
+
+ assertEquals("there should be no merged regions left!", 0, sheet.getNumMergedRegions());
+
+ //an, add, remove, get(0) would null pointer
+ sheet.addMergedRegion(region);
+ assertEquals("there should now be one merged region!", 1, sheet.getNumMergedRegions());
+ sheet.removeMergedRegion(0);
+ assertEquals("there should now be zero merged regions!", 0, sheet.getNumMergedRegions());
+ //add it again!
+ region.setRowTo(4);
+
+ sheet.addMergedRegion(region);
+ assertEquals("there should now be one merged region!", 1, sheet.getNumMergedRegions());
+
+ //should exist now!
+ assertTrue("there isn't more than one merged region in there", 1 <= sheet.getNumMergedRegions());
+ region = sheet.getMergedRegionAt(0);
+ assertEquals("the merged row to doesnt match the one we put in ", 4, region.getRowTo());
+
+ }
+
+ public void testShiftMerged() {
+ HSSFWorkbook wb = new HSSFWorkbook();
+ HSSFSheet sheet = wb.createSheet();
+ HSSFRow row = sheet.createRow(0);
+ HSSFCell cell = row.createCell((short)0);
+ cell.setCellValue("first row, first cell");
+
+ row = sheet.createRow(1);
+ cell = row.createCell((short)1);
+ cell.setCellValue("second row, second cell");
+
+ Region region = new Region(1, (short)0, 1, (short)1);
+ sheet.addMergedRegion(region);
+
+ sheet.shiftRows(1, 1, 1);
+
+ region = sheet.getMergedRegionAt(0);
+ assertEquals("Merged region not moved over to row 2", 2, region.getRowFrom());
+
+ }
+
+ /**
+ * Tests the display of gridlines, formulas, and rowcolheadings.
+ * @author Shawn Laubach (slaubach at apache dot org)
+ */
+ public void testDisplayOptions() throws Exception {
+ HSSFWorkbook wb = new HSSFWorkbook();
+ HSSFSheet sheet = wb.createSheet();
+
+ File tempFile = File.createTempFile("display", "test.xls");
+ FileOutputStream stream = new FileOutputStream(tempFile);
+ wb.write(stream);
+ stream.close();
+
+ FileInputStream readStream = new FileInputStream(tempFile);
+ wb = new HSSFWorkbook(readStream);
+ sheet = wb.getSheetAt(0);
+ readStream.close();
+
+ assertEquals(sheet.isDisplayGridlines(), true);
+ assertEquals(sheet.isDisplayRowColHeadings(), true);
+ assertEquals(sheet.isDisplayFormulas(), false);
+
+ sheet.setDisplayGridlines(false);
+ sheet.setDisplayRowColHeadings(false);
+ sheet.setDisplayFormulas(true);
+
+ tempFile = File.createTempFile("display", "test.xls");
+ stream = new FileOutputStream(tempFile);
+ wb.write(stream);
+ stream.close();
+
+ readStream = new FileInputStream(tempFile);
+ wb = new HSSFWorkbook(readStream);
+ sheet = wb.getSheetAt(0);
+ readStream.close();
+
+
+ assertEquals(sheet.isDisplayGridlines(), false);
+ assertEquals(sheet.isDisplayRowColHeadings(), false);
+ assertEquals(sheet.isDisplayFormulas(), true);
+ }
+
+ public static void main(java.lang.String[] args) {
+ junit.textui.TestRunner.run(TestHSSFSheet.class);
+ }
}
assertEquals(1.25,cell.getNumericCellValue(), 1e-10);
assertEquals(format.getFormat(df), "0.0");
+
+ assertEquals(format, workbook.createDataFormat());
stream.close();
}
// as expected
}
+
+ // verify proper behaviour with a 0 length dump on 0 length dataset
+ HexDump.dump(new byte[0], 0, new ByteArrayOutputStream(), 0, 0);
}
public void testToHex()