foray-commit Mailing List for FOray (Page 56)
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
(139) |
Apr
(98) |
May
(250) |
Jun
(394) |
Jul
(84) |
Aug
(13) |
Sep
(420) |
Oct
(186) |
Nov
(1) |
Dec
(3) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(108) |
Feb
(202) |
Mar
(291) |
Apr
(247) |
May
(374) |
Jun
(227) |
Jul
(231) |
Aug
(60) |
Sep
(31) |
Oct
(45) |
Nov
(18) |
Dec
|
| 2008 |
Jan
(38) |
Feb
(71) |
Mar
(142) |
Apr
|
May
(59) |
Jun
(6) |
Jul
(10) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2009 |
Jan
(12) |
Feb
(4) |
Mar
(88) |
Apr
(121) |
May
(17) |
Jun
(30) |
Jul
|
Aug
(5) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2010 |
Jan
(11) |
Feb
(76) |
Mar
(11) |
Apr
|
May
(11) |
Jun
|
Jul
|
Aug
(44) |
Sep
(14) |
Oct
(7) |
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(9) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(10) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(168) |
| 2017 |
Jan
(77) |
Feb
(11) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
(6) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
|
Feb
(88) |
Mar
(118) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(6) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(141) |
| 2021 |
Jan
(170) |
Feb
(20) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(62) |
Nov
(189) |
Dec
(162) |
| 2022 |
Jan
(201) |
Feb
(118) |
Mar
(8) |
Apr
|
May
(2) |
Jun
(47) |
Jul
(19) |
Aug
(14) |
Sep
(3) |
Oct
|
Nov
(28) |
Dec
(235) |
| 2023 |
Jan
(112) |
Feb
(23) |
Mar
(2) |
Apr
(2) |
May
|
Jun
(1) |
Jul
|
Aug
(70) |
Sep
(92) |
Oct
(20) |
Nov
(1) |
Dec
(1) |
| 2024 |
Jan
|
Feb
|
Mar
(1) |
Apr
(1) |
May
(14) |
Jun
(11) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2025 |
Jan
(10) |
Feb
(29) |
Mar
|
Apr
(162) |
May
(245) |
Jun
(83) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(3) |
Dec
|
|
From: <vic...@us...> - 2022-01-29 20:19:19
|
Revision: 12501
http://sourceforge.net/p/foray/code/12501
Author: victormote
Date: 2022-01-29 20:19:15 +0000 (Sat, 29 Jan 2022)
Log Message:
-----------
Move file structure classes to new package.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfDictionary.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/util/PdfReport.java
trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfDocumentTests.java
Added Paths:
-----------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/serial/
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/serial/PdfCrossRefEntry.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/serial/PdfCrossRefInfo.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/serial/PdfHeader.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/serial/PdfParser.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/serial/PdfSerializationConfig4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/serial/PdfTrailer.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/serial/package-info.java
trunk/foray/foray-pdf/src/test/java/org/foray/pdf/serial/
trunk/foray/foray-pdf/src/test/java/org/foray/pdf/serial/PdfParserTests.java
Removed Paths:
-------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfCrossRefEntry.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfCrossRefInfo.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfHeader.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfParser.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfSerializationConfig4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfTrailer.java
trunk/foray/foray-pdf/src/test/java/org/foray/pdf/PdfParserTests.java
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfCrossRefEntry.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfCrossRefEntry.java 2022-01-29 19:38:14 UTC (rev 12500)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfCrossRefEntry.java 2022-01-29 20:19:15 UTC (rev 12501)
@@ -1,230 +0,0 @@
-/*
- * Copyright 2020 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf;
-
-import org.foray.pdf.type.PdfObject;
-
-import org.axsl.utility.sequence.ByteSequencePlus;
-
-/**
- * An entry in the cross-reference table found near the end of a PDF.
- * Note that, like the entry in the physical file itself, the object number of the object referenced is not stored
- * in this class.
- * Instead, instances of this class are stored in an ordered collection (array or list, for example), and their position
- * in such ordered collection implies the object number.
- * @see "PDF Reference, Sixth Edition (PDF Version 1.7), Section 3.4.3."
- */
-public class PdfCrossRefEntry {
-
- /** The size, in bytes, of a PDF cross-reference entry when serialized. */
- public static final int TOTAL_BYTE_LENGTH = 20;
-
- /** The size, in bytes, of the offset portion of a PDF cross-reference entry when serialized. */
- public static final int OFFSET_BYTE_LENGTH = 10;
-
- /** The size, in bytes, of the generation portion of a PDF cross-reference entry when serialized. */
- public static final int GENERATION_BYTE_LENGTH = 5;
-
- /** Formatting string for writing the offset value. */
- private static final String OFFSET_FORMATTING_STRING = "%010d";
-
- /** Formatting string for writing the generation value. */
- private static final String GENERATION_FORMATTING_STRING = "%05d";
-
- /** The 0-based offset into the file content (bytes) to which this entry points. */
- private long offset;
- /* The capacity defined in the PDF reference is 10 decimal digits, a maximum of 9,999,999,999, one less than 10
- * billion, about 5 times as much as can be stored in an {@link Integer#TYPE}.
- * Therefore we use {@link Long#TYPE}. */
-
- /** The generation number of the object referenced by this entry. */
- private int generation;
- /* The capacity defined in the PDF reference is 5 decimal digits, a maximum of 99,999, one less than 10
- * billion, about 3 times as much as can be stored in an {@link Short#TYPE}, and about 1.5 times a much as can be
- * stored in a {@link Character#TYPE}.
- * Therefore we use {@link Integer#TYPE}. */
-
- /** Indicates whether this entry is "in-use" ("n" in the PDF), or "free" ("f" in the PDF). */
- private boolean inUse;
-
- /** The referenced object. This will be null if the document is being parsed and the parser has not yet parsed the
- * object at this offset. */
- private PdfObject object;
-
- /**
- * Constructor for the case where we wish to record that an object will be indirectly referenced, but we do not yet
- * know the offset for it in the serialized output.
- * This is useful mostly for cases where we are building a new document.
- * @param object The object being added to the cross-reference table.
- */
- public PdfCrossRefEntry(final PdfObject object) {
- this.offset = -1;
- this.generation = 0;
- this.inUse = true;
- this.object = object;
- }
-
- /**
- * Constructor that reads the instance values from a byte sequence.
- * This is useful mostly when parsing from an existing document.
- * @param sequence The byte sequence to be read.
- * @param entryOffset The 0-based offset into {@code sequence} at which the parsing of the entry should begin.
- * @throws IllegalArgumentException For invalid in-use indicator.
- */
- public PdfCrossRefEntry(final ByteSequencePlus sequence, final int entryOffset) {
- int start = entryOffset;
- int end = start + OFFSET_BYTE_LENGTH;
- final String offsetString = sequence.charSubSequence(start, end).toString();
- this.offset = Long.parseLong(offsetString);
-
- start = end + 1;
- end = start + GENERATION_BYTE_LENGTH;
- final String generationString = sequence.charSubSequence(start, end).toString();
- this.generation = Integer.parseInt(generationString);
-
- start = end + 1;
- final byte inUseChar = sequence.byteAt(start);
- if (inUseChar == 'n') {
- inUse = true;
- } else if (inUseChar == 'f') {
- inUse = false;
- } else {
- throw new IllegalArgumentException("In-use indicator must either \"n\" or \"f\". Actual: " + inUseChar);
- }
- }
-
- /**
- * Private constructor used by internal processes.
- */
- private PdfCrossRefEntry() { }
-
- /**
- * Creates the first entry for the cross-reference table, a kind of filler entry that fills the index-0 spot.
- * An entry with the same value will be parsed if the document is being parsed, but when creating a new document,
- * this must be created manually.
- * @return A new {@link PdfCrossRefEntry} with an offset of zero, a generation of 65535, and an in-use of false.
- */
- public static PdfCrossRefEntry createInitialEntry() {
- final PdfCrossRefEntry xref = new PdfCrossRefEntry();
- xref.setOffset(0);
- xref.setGeneration(PdfConstants.MAX_OBJECT_GENERATION);
- xref.setInUse(false);
- xref.setObject(null);
- return xref;
- }
-
- /**
- * Returns the String that should be written into the PDF for the offset value.
- * @return The offset value as a string to be written into the PDF.
- */
- public String getOffsetFormatted() {
- return String.format(OFFSET_FORMATTING_STRING, this.offset);
- }
-
- /**
- * Returns the String that should be written into the PDF for the generation value.
- * @return The generation value as a string to be written into the PDF.
- */
- public String getGenerationFormatted() {
- return String.format(GENERATION_FORMATTING_STRING, this.generation);
- }
-
- /**
- * Returns the char that should be written into the PDF for the in-use value.
- * @return The in-use value as a char to be written into the PDF.
- */
- public byte getInUseFormatted() {
- return this.inUse ? (byte) 'n' : (byte) 'f';
- }
-
- /**
- * Returns the value for the offset.
- * @return The value for the offset.
- */
- public long getOffset() {
- return offset;
- }
-
- /**
- * Sets the new value for the offset.
- * @param offset The new value for the offset.
- */
- public void setOffset(final long offset) {
- this.offset = offset;
- }
-
- /**
- * Returns the value for the generation.
- * @return The value for the generation.
- */
- public int getGeneration() {
- return generation;
- }
-
- /**
- * Sets the new value for the generation.
- * @param generation The new value for the generation.
- */
- public void setGeneration(final int generation) {
- this.generation = generation;
- }
-
- /**
- * Indicates whether this entry is "in-use".
- * @return True if and only if this entry is "in-use".
- */
- public boolean isInUse() {
- return inUse;
- }
-
- /**
- * Sets the "in-use" value.
- * @param inUse The new value for "in-use".
- */
- public void setInUse(final boolean inUse) {
- this.inUse = inUse;
- }
-
- /**
- * Returns the object referenced by this cross-reference entry.
- * @return The object referenced by this cross-reference entry.
- */
- public PdfObject getObject() {
- return object;
- }
-
- /**
- * Sets the object referenced by this cross-reference entry.
- * @param object The object referenced by this cross-reference entry.
- */
- public void setObject(final PdfObject object) {
- this.object = object;
- }
-
-}
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfCrossRefInfo.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfCrossRefInfo.java 2022-01-29 19:38:14 UTC (rev 12500)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfCrossRefInfo.java 2022-01-29 20:19:15 UTC (rev 12501)
@@ -1,146 +0,0 @@
-/*
- * Copyright 2020 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf;
-
-import org.foray.common.primitive.StringUtils;
-import org.foray.common.sequence.ByteArrayBuilder;
-import org.foray.common.sequence.IntArrayBuilder;
-import org.foray.pdf.type.PdfObject;
-
-import org.axsl.utility.sequence.IntPrimitiveIterator;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * The cross-reference information for a PDF document.
- * This can include a cross-reference table, a cross-reference stream, or both.
- * This current implementation supports only a cross-reference table.
- */
-public class PdfCrossRefInfo {
-
- /**
- * The list of the locations of each indirect object.
- * Parsed from and/or used to create the xref table at the end of a serialized PDF document.
- * The index into the list is equal to the indirect object's number.
- */
- private List<PdfCrossRefEntry> xrefTable = new ArrayList<PdfCrossRefEntry>();
-
- /** Stack of object IDs that should be written after all other objects have been written. */
- private IntArrayBuilder indirectWriteLast = new IntArrayBuilder();
-
- /**
- * Returns the size of the xref table.
- * @return The number of entries in the xref table.
- */
- public int getTableSize() {
- return this.xrefTable.size();
- }
-
- /**
- * Returns the xref entry for a given object ID.
- * @param objectId The object ID for which the cross-reference entry to be returned.
- * @return The xref entry for {@code objectId}.
- */
- public PdfCrossRefEntry getTableEntry(final int objectId) {
- return this.xrefTable.get(objectId);
- }
-
- /**
- * Adds an entry to the table.
- * @param xref The entry to be added.
- */
- public void addTableEntry(final PdfCrossRefEntry xref) {
- this.xrefTable.add(xref);
- }
-
- /**
- * Adds a deferred entry (an entry that should be written toward the end of serialization) to the table.
- * @param xref The entry to be added.
- */
- public void addDeferredTableEntry(final PdfCrossRefEntry xref) {
- this.xrefTable.add(xref);
- this.indirectWriteLast.append(xref.getObject().getIndirectReference().getNumber());
- }
-
- /**
- * Indicates whether a given object ID is part of the object IDs that should be written after all other objects.
- * @param objectId The object ID to be checked.
- * @return True if and only if {@code objectId} should be written with the last objects.
- */
- public boolean isDeferred(final int objectId) {
- return indirectWriteLast.contains(objectId);
- }
-
- /**
- * Creates and returns an iterator over the deferred indirect object IDs.
- * The deferred list is conceptually stack-like, so the iterator returns the object IDs in reverse order.
- * @return A new iterator over the deferred indirect object IDs.
- */
- public IntPrimitiveIterator iteratorForDeferred() {
- return this.indirectWriteLast.iteratorReverse();
- }
-
- /**
- * Write the xref table.
- * @param stream the OutputStream to which the xref table should be written.
- * @throws IOException For errors while writing to the output stream.
- */
- public void writeTable(final OutputStream stream) throws IOException {
-// int bytesWritten = 0;
-
- final ByteArrayBuilder builder = new ByteArrayBuilder();
- builder.append("xref");
- builder.append(PdfObject.EOL);
- builder.append("0 ");
- builder.append(this.xrefTable.size());
- builder.append(PdfObject.EOL);
-// bytesWritten += builder.length();
- builder.writeTo(stream);
-
- builder.clear();
- for (int i = 0; i < this.xrefTable.size(); i++) {
- final PdfCrossRefEntry xref = this.xrefTable.get(i);
- builder.append(xref.getOffsetFormatted());
- builder.append(StringUtils.SINGLE_SPACE);
- builder.append(xref.getGenerationFormatted());
- builder.append(StringUtils.SINGLE_SPACE);
- builder.append(xref.getInUseFormatted());
- builder.append(PdfObject.XREF_EOL);
-
-// bytesWritten += builder.length();
- builder.writeTo(stream);
- builder.clear();
- }
-
- }
-
-}
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfHeader.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfHeader.java 2022-01-29 19:38:14 UTC (rev 12500)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfHeader.java 2022-01-29 20:19:15 UTC (rev 12501)
@@ -1,113 +0,0 @@
-/*
- * Copyright 2020 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf;
-
-import org.foray.common.sequence.ByteArray;
-import org.foray.common.sequence.ByteArrayBuilder;
-import org.foray.pdf.type.PdfObject;
-
-import org.axsl.pdf.PdfVersion;
-
-/**
- * The header portion of a PDF document.
- * @see "PDF Reference, Sixth Edition (PDF version 1.7), Section 3.4.1"
- */
-public class PdfHeader {
-
- /** The default value for the PDF version. */
- private static final PdfVersion DEFAULT_PDF_VERSION = PdfVersion.VERSION_1_6;
-
- /** A default value for the binary comment as recommended by the PDF spec (3.4.1). */
- private static final ByteArray DEFAULT_BINARY_COMMENT = new ByteArray(
- (byte) 0xAA,
- (byte) 0xAB,
- (byte) 0xAC,
- (byte) 0xAD
- );
-
- /** The version of PDF for this document. */
- private PdfVersion pdfVersion;
-
- /** The binary comment, written immediately after the header line, indicating to parsing applications that this
- * document may contain binary data. */
- private ByteArray binaryComment;
-
- public PdfHeader() {
- this.pdfVersion = DEFAULT_PDF_VERSION;
- this.binaryComment = DEFAULT_BINARY_COMMENT;
- }
-
- public ByteArrayBuilder toPDF() {
- final ByteArrayBuilder builder = new ByteArrayBuilder();
- // The PDF identifier comment.
- builder.append(PdfConstants.DOCUMENT_BEGIN_MARKER);
- builder.append(this.pdfVersion.getVersionString());
- builder.append(PdfObject.EOL);
- builder.append(PdfConstants.OPEN_COMMENT);
- builder.append(this.binaryComment);
- builder.append(PdfObject.EOL);
- return builder;
- }
-
- /**
- * Returns the version of PDF for this document.
- * @return The PDF version.
- */
- public PdfVersion getPdfVersion() {
- return pdfVersion;
- }
-
- /**
- * Sets the PDF version for this document.
- * @param pdfVersion The new value for the PDF version.
- */
- public void setPdfVersion(final PdfVersion pdfVersion) {
- this.pdfVersion = pdfVersion;
- }
-
- /**
- * Returns the binary comment, written immediately after the header line, indicating to parsing applications that
- * this document may contain binary data.
- * @see "PDF Reference, Sixth Edition (PDF version 1.7), Section 3.4.1."
- * @return The binary comment.
- */
- public ByteArray getBinaryComment() {
- return binaryComment;
- }
-
- /**
- * Sets the binary comments.
- * @param binaryComment The new value for the binary comment.
- * @see #getBinaryComment()
- */
- public void setBinaryComment(final ByteArray binaryComment) {
- this.binaryComment = binaryComment;
- }
-
-}
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfParser.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfParser.java 2022-01-29 19:38:14 UTC (rev 12500)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfParser.java 2022-01-29 20:19:15 UTC (rev 12501)
@@ -1,524 +0,0 @@
-/*
- * Copyright 2020 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf;
-
-import org.foray.common.data.ByteSequenceTokenizer;
-import org.foray.common.data.ByteSequenceTokenizerConfig;
-import org.foray.common.sequence.ByteArray;
-import org.foray.common.sequence.ByteArrayBuilder;
-import org.foray.common.sequence.ByteSequenceSubset;
-import org.foray.pdf.object.PdfDocument4a;
-import org.foray.pdf.object.PdfGenericDictionary;
-import org.foray.pdf.object.PdfGenericStream;
-import org.foray.pdf.object.PdfObjectReference;
-import org.foray.pdf.object.PdfTrailer;
-import org.foray.pdf.structure.PdfTextString;
-import org.foray.pdf.type.PdfArray;
-import org.foray.pdf.type.PdfBoolean;
-import org.foray.pdf.type.PdfDictionary;
-import org.foray.pdf.type.PdfHexString;
-import org.foray.pdf.type.PdfInteger;
-import org.foray.pdf.type.PdfName;
-import org.foray.pdf.type.PdfObject;
-import org.foray.pdf.type.PdfReal;
-
-import org.axsl.pdf.PdfException;
-import org.axsl.pdf.PdfVersion;
-import org.axsl.utility.sequence.ByteSequence;
-import org.axsl.utility.sequence.ByteSequencePlus;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Stack;
-
-/**
- * <p>Parses a stream of bytes into a PDF document.
- * The PDF document is designed to be read incrementally, as needed.
- * Therefore, this parser parses as little of the document as possible, responding to client requests for more
- * information as needed.</p>
- */
-public class PdfParser {
-
- /** The standard tokenizer configuration for parsing a PDF. */
- public static final ByteSequenceTokenizerConfig STD_TOKENIZER_CONFIG =
- new ByteSequenceTokenizerConfig(PdfConstants.PDF_DELIMITERS, PdfConstants.PDF_WHITESPACE, null, null);
-
- /** Delimiters for parsing literal PDF strings. */
- public static final List<ByteArray> PDF_TEXT_DELIMITERS = Arrays.asList(
- PdfConstants.CLOSE_STRING_LITERAL
- );
-
- /** Delimiter balancers for parsing literal PDF strings. */
- public static final List<ByteArray> PDF_TEXT_DELIMITER_BALANCERS = Arrays.asList(
- PdfConstants.OPEN_STRING_LITERAL
- );
-
- /** Delimiters for parsing literal PDF streams. */
- public static final List<ByteArray> PDF_STREAM_DELIMITERS = Arrays.asList(
- PdfConstants.KEYWORD_END_STREAM
- );
-
- /** The tokenizer configuration for parsing PDF text. */
- public static final ByteSequenceTokenizerConfig TEXT_TOKENIZER_CONFIG = new ByteSequenceTokenizerConfig(
- PDF_TEXT_DELIMITERS, null, PdfConstants.TEXT_ESCAPE_CHARS, PDF_TEXT_DELIMITER_BALANCERS);
-
- /** The tokenizer configuration for parsing a PDF comment. Just looking for the end of the line. */
- public static final ByteSequenceTokenizerConfig COMMENT_TOKENIZER_CONFIG =
- new ByteSequenceTokenizerConfig(PdfConstants.PDF_END_OF_LINE_DELIMITERS, null, null, null);
-
- /** The tokenizer configuration for parsing a PDF stream. */
- public static final ByteSequenceTokenizerConfig STREAM_TOKENIZER_CONFIG =
- new ByteSequenceTokenizerConfig(PDF_STREAM_DELIMITERS, null, null, null);
-
- /** The raw document bytes. */
- private ByteSequencePlus source;
-
- /** The parsed PDF. */
- private PdfDocument4a pdf;
-
- /** The logger. */
- private Logger logger = LoggerFactory.getLogger(PdfParser.class);
-
- /**
- * Constructor for an input stream.
- * @param input The input stream to be parsed. This constructor will close the stream after reading it.
- * @throws IOException For errors reading the input stream.
- */
- public PdfParser(final InputStream input) throws IOException {
- this(new ByteArrayBuilder().append(input));
- }
-
- /**
- * Constructor for an already-constructed {@link ByteSequencePlus}.
- * This might be especially useful if someone wants to avoid reading an entire document file into memory, and writes
- * a {@link ByteSequencePlus} implementation that knows how to transparently expose the file content without doing
- * so.
- * @param input The byte sequence from which the document should be parsed.
- */
- public PdfParser(final ByteSequencePlus input) {
- this.source = input;
- }
-
- /**
- * No-args constructor.
- * Useful primarily for testing.
- */
- PdfParser() { }
-
- /**
- * Parses the content of the PDF document.
- * @return The parsed content of the PDF document.
- * @throws PdfException For errors during parsing.
- */
- public PdfDocument4a parse() throws PdfException {
- this.pdf = new PdfDocument4a(this);
- return this.pdf;
- }
-
- /**
- * Parses the header portion of the document.
- * @return The parsed {@link PdfVersion}.
- * @throws PdfException If the {@link PdfVersion} is not found.
- */
- public PdfVersion parseHeader() throws PdfException {
- final String headerLine = source.readCurrentLine(0).toString();
- if (! headerLine.startsWith(PdfConstants.DOCUMENT_BEGIN_MARKER.toString())) {
- throw new PdfException("PDF Header not found.");
- }
- final String versionString = headerLine.substring(PdfConstants.DOCUMENT_BEGIN_MARKER.length()).trim();
- final PdfVersion version = PdfVersion.fromString(versionString);
- if (version == null) {
- throw new PdfException("PDF Version not found: " + versionString);
- }
- return version;
- }
-
- /**
- * Parses the offset to the start of the cross-reference section from the end of the file.
- * @return The offset to the start of the cross-reference section.
- * @throws PdfException If unable to find the "%%EOF" marker or the "startxref" keyword.
- */
- private int getStartXrefOffset() throws PdfException {
- /* Find start of last "%%EOF" marker. */
- final int eofIndex = source.lastIndexOf(PdfConstants.DOCUMENT_END_MARKER.toString());
- if (eofIndex < 0) {
- throw new PdfException("Unable to find PDF end marker.");
- }
-
- /* Find start of first "startxref" before that. */
- final int startxrefIndex = source.lastIndexOf("startxref", eofIndex);
- if (startxrefIndex < 0) {
- throw new PdfException("Unable to find startxref.");
- }
- return source.readWord(startxrefIndex + "startxref".length()).parseInt();
- }
-
- /**
- * Parses the trailer portion of a PDF document and returns the results.
- * @return The results of parsing the trailer portion of the PDF document.
- * @throws PdfException For errors during parsing.
- */
- public PdfTrailer parseTrailer() throws PdfException {
- final int trailerIndex = source.lastIndexOf("trailer");
- final int trailerDictStart = source.indexOf(PdfConstants.OPEN_DICTIONARY, trailerIndex);
- final int trailerDictEnd = source.indexOf(PdfConstants.CLOSE_DICTIONARY, trailerDictStart) +
- PdfConstants.CLOSE_DICTIONARY.length();
- final ByteSequenceSubset parseArea =
- new ByteSequenceSubset(source, trailerDictStart, trailerDictEnd - trailerDictStart);
- final ByteSequenceTokenizer tokenizer = new ByteSequenceTokenizer(parseArea, STD_TOKENIZER_CONFIG);
- final PdfObject trailerObject = this.parseObject(tokenizer);
-
- if (trailerObject instanceof PdfGenericDictionary) {
- return ((PdfGenericDictionary) trailerObject).asPdfTrailer();
- } else {
- throw new PdfException("Unable to parse the trailer dictionary.");
- }
- }
-
- /**
- * Parses the indirect objects in the PDF.
- * @throws PdfException For errors during parsing.
- */
- public void parseIndirectObjects() throws PdfException {
- final PdfCrossRefInfo xrefs = getXrefs();
- ByteSequenceSubset parseArea;
- ByteSequenceTokenizer tokenizer;
- /* Parse each indirect object. */
- final PdfObject[] objects = new PdfObject[xrefs.getTableSize()];
- for (int objectId = 1; objectId < xrefs.getTableSize(); objectId ++) {
- final PdfCrossRefEntry entry = xrefs.getTableEntry(objectId);
- this.logger.debug(String.format("Parsing object %d, generation %d.", objectId, entry.getGeneration()));
-
- /* TODO: Need an array of byte arrays to handle bigger documents. */
- if (entry.getOffset() > Integer.MAX_VALUE) {
- throw new IllegalStateException("PDF Object ID exceeds internal limit of " + Integer.MAX_VALUE);
- }
- final int objectStart = (int) entry.getOffset();
-
- /* We only expect indirect objects here. */
- parseArea = new ByteSequenceSubset(source, objectStart, source.length() - objectStart);
- tokenizer = new ByteSequenceTokenizer(parseArea, STD_TOKENIZER_CONFIG);
- PdfObject parsedObject = null;
- try {
- parsedObject = parseObject(tokenizer);
- } catch (final PdfException e) {
- final String msg = String.format(
- "Error parsing object %d, generation %d", objectId, entry.getGeneration());
- this.logger.error(msg);
- this.logger.error(e.getMessage());
- throw new PdfException(msg, e);
- }
- if (parsedObject == null) {
- throw new PdfException("Unable to parse indirect object: " + objectId);
- } else {
-// parsedObject.registerIndirectReference(ref);
- objects[objectId] = parsedObject;
- }
- }
- }
-
- /**
- * Parses a PDF object from a tokenizer's output.
- * PDF's roots are in Postscript, which is a postfix language.
- * PDF's syntax is somewhat postfix-like.
- * The easiest way to parse it seems to be to first tokenize the object from start to finish, placing the tokens on
- * a stack, then parsing the tokens in reverse order, popping them off the stack until done.
- * Tokenization needs to be done in the forward direction, because some tokens change the context for the tokenizer
- * itself.
- * @param tokenizer The tokenizer.
- * @return The parsed PDF object.
- * @throws PdfException For errors in the PDF.
- */
- PdfObject parseObject(final ByteSequenceTokenizer tokenizer) throws PdfException {
- final Stack<ByteSequencePlus> tokenStack = new Stack<ByteSequencePlus>();
- final Stack<PdfObject> objectStack = new Stack<PdfObject>();
- parseObjectTokens(tokenizer, tokenStack);
- processTokenStack(tokenStack, objectStack);
- if (objectStack.size() == 1) {
- return objectStack.pop();
- } else {
- throw new PdfException("Object stack should have exactly one object, actual: " + objectStack.size());
- }
- }
-
- /**
- * Enumerator for the valid tokenizer modes.
- */
- private enum TokenizerMode {
- /** Tokenizer is in standard PDF mode. */
- STANDARD,
-
- /** Tokenizer is in PDF literal text mode. */
- LITERAL_TEXT,
-
- /** Tokenizer is in PDF comment mode. */
- COMMENT,
-
- /** Tokenizer is in PDF stream mode. */
- STREAM,
- }
-
- private void parseObjectTokens(final ByteSequenceTokenizer tokenizer, final Stack<ByteSequencePlus> tokenStack) {
- TokenizerMode mode = TokenizerMode.STANDARD;
- while (tokenizer.hasMoreTokens()) {
- final ByteSequencePlus token = tokenizer.nextToken();
- if (mode == TokenizerMode.STANDARD) {
- if (PdfConstants.OPEN_COMMENT.equals(token)) {
- mode = TokenizerMode.COMMENT;
- tokenizer.setConfig(COMMENT_TOKENIZER_CONFIG);
- } else if (PdfConstants.OPEN_STRING_LITERAL.equals(token)) {
- mode = TokenizerMode.LITERAL_TEXT;
- tokenizer.setConfig(TEXT_TOKENIZER_CONFIG);
- } else if (PdfConstants.KEYWORD_START_STREAM.equals(token)) {
- mode = TokenizerMode.STREAM;
- tokenizer.setConfig(STREAM_TOKENIZER_CONFIG);
- }
- } else if (mode == TokenizerMode.COMMENT) {
- if (PdfConstants.PDF_END_OF_LINE_DELIMITERS.contains(token)) {
- /* We are at the end of the line. Switch back to standard. */
- mode = TokenizerMode.STANDARD;
- tokenizer.setConfig(STD_TOKENIZER_CONFIG);
- } else {
- /* This is the comment text. Just let it go onto the token stack. */
- }
- } else if (mode == TokenizerMode.LITERAL_TEXT) {
- if (PDF_TEXT_DELIMITERS.contains(token)) {
- /* We are at the end of the string literal. Switch back to standard. */
- mode = TokenizerMode.STANDARD;
- tokenizer.setConfig(STD_TOKENIZER_CONFIG);
- }
- } else if (mode == TokenizerMode.STREAM) {
- if (PDF_STREAM_DELIMITERS.contains(token)) {
- /* We are at the end of the stream. Switch back to standard. */
- mode = TokenizerMode.STANDARD;
- tokenizer.setConfig(STD_TOKENIZER_CONFIG);
- }
- }
- tokenStack.push(token);
- if (PdfConstants.KEYWORD_END_OBJECT.equals(token)) {
- return;
- }
- }
- }
-
- private void processTokenStack(final Stack<ByteSequencePlus> tokenStack, final Stack<PdfObject> objectStack)
- throws PdfException {
- while (tokenStack.size() > 0) {
- processNextObject(tokenStack, objectStack);
- }
- }
-
- private void processNextObject(final Stack<ByteSequencePlus> tokenStack, final Stack<PdfObject> objectStack)
- throws PdfException {
- final ByteSequencePlus token = tokenStack.pop();
- if (token == null) {
- throw new PdfException("Unexpected End of Object.");
- } else if (PdfConstants.KEYWORD_REFERENCE_MARKER.equals(token)
- && (tokenStack.size() < 1
- || ! PdfConstants.NAME_PREFIX.equals(tokenStack.peek()))) {
- /* The token is "R". It also is NOT immediately preceded by token "/", which would indicate that it is the
- * PDF name "/R". */
- final int generation = tokenStack.pop().parseInt();
- final int objectId = tokenStack.pop().parseInt();
- objectStack.push(new PdfObjectReference(objectId, generation));
- } else if (PdfConstants.CLOSE_STRING_HEX.equals(token)) {
- /* Pop the hex string. */
- final ByteSequence hexString = tokenStack.pop();
- /* Pop the token for the start of the hex string. */
- tokenStack.pop();
- final ByteArray byteArray = ByteArray.fromHexByteSequence(hexString);
- objectStack.push(new PdfHexString(byteArray));
- } else if (PdfConstants.CLOSE_STRING_LITERAL.equals(token)) {
- /* Pop the next token. It is probably the text, but if the string is empty, it will be the token that marks
- * the start of the string. */
- final ByteSequence text = tokenStack.pop();
- if (PdfConstants.OPEN_STRING_LITERAL.equals(text)) {
- /* The string is probably an empty string. However, if the string content itself is the marker for the
- * start of the string, we would have tokens of (, (, and ).
- * To avoid this corner case, we will check the next token down.
- * If it is also the open string literal, then we have hit the corner case.
- * If not, the string is empty. */
- if (tokenStack.size() > 0
- && PdfConstants.OPEN_STRING_LITERAL.equals(tokenStack.peek())) {
- /* We have hit the corner case. Pop the marker that we just peeked. */
- objectStack.push(new PdfTextString(text));
- } else {
- /* The string is empty. We object we just popped is the start of text marker. */
- objectStack.push(new PdfTextString(ByteArray.EMPTY));
- }
-
- } else {
- /* Pop the token for the start of the string. */
- tokenStack.pop();
- objectStack.push(new PdfTextString(text));
- }
- } else if (PdfConstants.CLOSE_ARRAY.equals(token)) {
- /* Create the array object and push it onto the object stack. */
- final PdfArray array = new PdfArray();
- objectStack.push(array);
-
- /* Parse the array elements. */
- while (! PdfConstants.OPEN_ARRAY.equals(tokenStack.peek())) {
- /* This should push the array element on the stack. */
- processNextObject(tokenStack, objectStack);
- }
- /* We got down to the open array token. Pop it. */
- tokenStack.pop();
-
- /* Read through the array elements on the object stack, adding each to the array. */
- /* Check by object identity. The object we are looking for will always be exactly the same one we created
- * above. */
- while (objectStack.peek() != array) {
- final PdfObject element = objectStack.pop();
- array.addElement(element);
- }
- } else if (PdfConstants.CLOSE_DICTIONARY.equals(token)) {
- /* Create the dictionary object and push it onto the object stack. */
- final PdfGenericDictionary dict = new PdfGenericDictionary();
- objectStack.push(dict);
-
- /* Parse the dictionary keys and values. */
- while (! PdfConstants.OPEN_DICTIONARY.equals(tokenStack.peek())) {
- /* This should push the entry value on the stack. */
- processNextObject(tokenStack, objectStack);
- /* This should push the entry key on the stack. */
- processNextObject(tokenStack, objectStack);
- }
- /* We got down to the open dictionary token. Pop it. */
- tokenStack.pop();
-
- /* Read through the keys and values on the object stack, adding each pair to the dictionary. */
- PdfObject key = null;
- PdfObject value = null;
- /* Check by object identity. The object we are looking for will always be exactly the same one we created
- * above. */
- while (objectStack.peek() != dict) {
- key = objectStack.pop();
- if (! (key instanceof PdfName)) {
- throw new PdfException("Expected PDF name object for dictionary key.");
- }
- final String keyString = ((PdfName) key).getValue();
- value = objectStack.pop();
- dict.put(keyString, value);
- key = null;
- value = null;
- }
- if (key != null
- || value != null) {
- throw new PdfException("Unbalanced key/value while parsing PDF dictionary.");
- }
- } else if (PdfConstants.KEYWORD_END_OBJECT.equals(token)) {
- /* Push the indirect object on the stack. */
- processNextObject(tokenStack, objectStack);
- if (PdfConstants.KEYWORD_START_OBJECT.equals(tokenStack.peek())) {
- tokenStack.pop();
- } else {
- throw new PdfException("Expected token: \"obj\".");
- }
- final int generation = tokenStack.pop().parseInt();
- final int objectId = tokenStack.pop().parseInt();
- final PdfObjectReference ref = new PdfObjectReference(objectId, generation);
- objectStack.peek().registerIndirectReference(ref);
- } else if (PdfConstants.KEYWORD_END_STREAM.equals(token)) {
- final ByteSequence streamContent = tokenStack.pop();
- if (PdfConstants.KEYWORD_START_STREAM.equals(tokenStack.peek())) {
- tokenStack.pop();
- } else {
- throw new PdfException("Expected token: \"endstream\".");
- }
- /* Process the related dictionary and push it onto the stack. */
- processNextObject(tokenStack, objectStack);
- final PdfObject dictObject = objectStack.pop();
- if (! (dictObject instanceof PdfDictionary)) {
- throw new PdfException("Expected PDF Dictionary");
- }
- final PdfDictionary dictionary = (PdfDictionary) dictObject;
- objectStack.push(new PdfGenericStream(dictionary, streamContent));
- } else if (token.canParseInt()) {
- final int value = token.parseInt();
- objectStack.push(new PdfInteger(value));
- } else if (token.canParseDecimal()) {
- final BigDecimal value = token.parseDecimal();
- objectStack.push(new PdfReal(value));
- } else if (PdfBoolean.parse(token) != null) {
- objectStack.push(PdfBoolean.parse(token));
- } else {
- /* The token is arbitrary text. We need to see what is under it in the stack. */
- final ByteSequence subToken = tokenStack.pop();
- if (PdfConstants.NAME_PREFIX.equals(subToken)) {
- objectStack.push(new PdfName(token.toString()));
- } else if (PdfConstants.OPEN_COMMENT.equals(subToken)) {
- /* We don't have any use for the comment right now, but, if we did, it should be captured here. */
- }
- }
- }
-
- /**
- * Returns the PDF that was parsed.
- * Note that this request will result in the parsing of any unparsed portions of the document.
- * @return The PDF.
- * @throws PdfException For errors during parsing of the document.
- */
- public PdfDocument4a getParsedDocument() throws PdfException {
- /* For now, just make sure the Xrefs have been parsed. */
- getXrefs();
-
- return this.pdf;
- }
-
- /**
- * Parses the cross-reference table.
- * @return A new {@link PdfCrossRefInfo} instance containing the parsed cross-reference table.
- * @throws PdfException For errors finding or parsing the cross-reference table.
- */
- private PdfCrossRefInfo getXrefs() throws PdfException {
- final PdfCrossRefInfo xrefInfo = new PdfCrossRefInfo();
- final int startXrefOffset = getStartXrefOffset();
- /* The second word on the first line contains the count. */
- final ByteSequencePlus xrefLine = source.readCurrentLine(startXrefOffset);
- int offset = source.findStartOfLine(startXrefOffset + xrefLine.length());
- final ByteSequencePlus xrefCountLine = source.readCurrentLine(offset);
- final int qtyXrefs = xrefCountLine.readWord(0, 2).parseInt();
- offset = source.findStartOfLine(offset + xrefCountLine.length());
-
- while (xrefInfo.getTableSize() < qtyXrefs) {
- final PdfCrossRefEntry entry = new PdfCrossRefEntry(source, offset);
- xrefInfo.addTableEntry(entry);
- offset += PdfCrossRefEntry.TOTAL_BYTE_LENGTH;
- }
- return xrefInfo;
- }
-
-}
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfSerializationConfig4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfSerializationConfig4a.java 2022-01-29 19:38:14 UTC (rev 12500)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfSerializationConfig4a.java 2022-01-29 20:19:15 UTC (rev 12501)
@@ -1,67 +0,0 @@
-/*
- * Copyright 2021 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf;
-
-import org.axsl.pdf.PdfSerializationConfig;
-
-/**
- * Concrete implementaton of {@link PdfSerializationConfig}.
- */
-public class PdfSerializationConfig4a implements PdfSerializationConfig {
-
- /** The default line length of the output PDF document. */
- public static final int DEFAULT_CHARACTERS_PER_LINE = 80;
-
- /** The desired maximum length of lines in the serialized document. */
- private int maxLineLength;
-
- /**
- * Creates a configuration instance with reasonable defaults.
- * @return A default configuration instance.
- */
- public static PdfSerializationConfig4a createDefaultInstance() {
- final PdfSerializationConfig4a config = new PdfSerializationConfig4a();
- config.maxLineLength = DEFAULT_CHARACTERS_PER_LINE;
- return config;
- }
-
- @Override
- public int getMaxLineLength() {
- return this.maxLineLength;
- }
-
- /**
- * Sets the desired maximum length of lines in the serialized document.
- * @param maxLineLength The desired maximum length of lines in the serialized document.
- */
- public void setMaxLineLength(final int maxLineLength) {
- this.maxLineLength = maxLineLength;
- }
-
-}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java 2022-01-29 19:38:14 UTC (rev 12500)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java 2022-01-29 20:19:15 UTC (rev 12501)
@@ -39,12 +39,13 @@
import org.foray.common.ColorUtil;
import org.foray.common.sequence.ByteArrayBuilder;
import org.foray.pdf.PdfConstants;
-import org.foray.pdf.PdfCrossRefEntry;
-import org.foray.pdf.PdfCrossRefInfo;
-import org.foray.pdf.PdfHeader;
-import org.foray.pdf.PdfParser;
import org.foray.pdf.interact.PdfOutlineParent4a;
import org.foray.pdf.interact.PdfPageLabel;
+import org.foray.pdf.serial.PdfCrossRefEntry;
+import org.foray.pdf.serial.PdfCrossRefInfo;
+import org.foray.pdf.serial.PdfHeader;
+import org.foray.pdf.serial.PdfParser;
+import org.foray.pdf.serial.PdfTrailer;
import org.foray.pdf.type.PdfObject;
import org.axsl.font.Font;
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfTrailer.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfTrailer.java 2022-01-29 19:38:14 UTC (rev 12500)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfTrailer.java 2022-01-29 20:19:15 UTC (rev 12501)
@@ -1,152 +0,0 @@
-/*
- * Copyright 2020 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-import org.foray.common.sequence.ByteArray;
-import org.foray.pdf.PdfConstants;
-import org.foray.pdf.type.PdfArray;
-import org.foray.pdf.type.PdfDictionary;
-import org.foray.pdf.type.PdfHexString;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Random;
-
-public class PdfTrailer extends PdfDictionary {
-
- /** The default order when writing dictionaries of this class. */
- private static final List<String> DEFAULT_ORDER = Arrays.asList("Size", "Prev", "Root", "Encrypt", "Info", "ID");
-
- /**
- * No-args constructor.
- */
- public PdfTrailer() {
- super();
- }
-
- /**
- * Constructor allowing subclasses to remake themselves as a different subclass.
- * @param existing The existing {@link PdfDictionary} whose contents will be pushed into the new instance.
- */
- public PdfTrailer(final PdfDictionary existing) {
- super(existing);
- }
-
- @Override
- public List<String> getOutputOrder() {
- return DEFAULT_ORDER;
- }
-
- @Override
- public String getDictionaryType() {
- return null;
- }
-
- private ByteArray getStoredPermanentFileId() {
- final PdfArray idArray = this.getPdfArray("ID");
- if (idArray == null) {
- return null;
- }
- final PdfHexString hexString = idArray.getPdfHexString(0);
- return hexString == null ? null : hexString.getValue();
- }
-
- private ByteArray getStoredIncrementalFileId() {
- final PdfArray idArray = this.getPdfArray("ID");
- if (idArray == null) {
- return null;
- }
- final PdfHexString hexString = idArray.getPdfHexString(1);
- return hexString == null ? null : hexString.getValue();
- }
-
- /**
- * Returns the permanent document file ID.
- * @return The permanent file ID.
- * @see "PDFReference, Sixth Edition (PDF version 1.7), Section 10.3."
- */
- public ByteArray getPermanentFileID() {
- if (getStoredPermanentFileId() == null) {
- final byte[] fileIdBytes = new byte[PdfConstants.FILE_ID_SIZE];
- final Random random = new Random();
- random.nextBytes(fileIdBytes);
- setPermanentFileId(new ByteArray(fileIdBytes));
- }
- return getStoredPermanentFileId();
- }
-
- /**
- * Sets the permanent document file ID.
- * @param fileId The new value for the permanent document file ID.
- * The size of the array must be exactly 16.
- * @see "PDFReference, Sixth Edition (PDF version 1.7), Section 10.3."
- */
- public void setPermanentFileId(final ByteArray fileId) {
- if (fileId.length() != PdfConstants.FILE_ID_SIZE) {
- throw new IllegalArgumentException(
- String.format("Size of array must be exactly {0}, actual: {1}",
- PdfConstants.FILE_ID_SIZE, fileId.length()));
- }
- final PdfArray array = this.ensureArray("ID");
- array.ensureMinimumSize(2);
- array.set(0, new PdfHexString(fileId));
- }
-
- /**
- * Returns the incremental document file ID.
- * @return The incremental file ID.
- * @see "PDFReference, Sixth Edition (PDF version 1.7), Section 10.3."
- */
- public ByteArray getIncrementalFileID() {
- if (getStoredIncrementalFileId() == null) {
- /* If not explicitly set, we assume that this is a new file, and the incremental file ID should be the same
- * as the permanent one. */
- this.setIncrementalFileId(getPermanentFileID());
- }
- return getStoredIncrementalFileId();
- }
-
- /**
- * Sets the incremental document file ID.
- * @param fileId The new value for the incremental document file ID.
- * The size of the array must be exactly 16.
- * @see "PDFReference, Sixth Edition (PDF version 1.7), Section 10.3."
- */
- public void setIncrementalFileId(final ByteArray fileId) {
- if (fileId.length() != PdfConstants.FILE_ID_SIZE) {
- throw new IllegalArgumentException(
- String.format("Size of array must be exactly {0}, actual: {1}",
- PdfConstants.FILE_ID_SIZE, fileId.length()));
- }
- final PdfArray array = this.ensureArray("ID");
- array.ensureMinimumSize(2);
- array.set(1, new PdfHexString(fileId));
- }
-
-}
Copied: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/serial/PdfCrossRefEntry.java (from rev 12492, trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfCrossRefEntry.java)
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/serial/PdfCrossRefEntry.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/serial/PdfCrossRefEntry.java 2022-01-29 20:19:15 UTC (rev 12501)
@@ -0,0 +1,231 @@
+/*
+ * Copyright 2020 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf.serial;
+
+import org.foray.pdf.PdfConstants;
+import org.foray.pdf.type.PdfObject;
+
+import org.axsl.utility.sequence.ByteSequencePlus;
+
+/**
+ * An entry in the cross-reference table found near the end of a PDF.
+ * Note that, like the entry in the physical file itself, the object number of the object referenced is not stored
+ * in this class.
+ * Instead, instances of this class are stored in an ordered collection (array or list, for example), and their position
+ * in such ordered collection implies the object number.
+ * @see "PDF Reference, Sixth Edition (PDF Version 1.7), Section 3.4.3."
+ */
+public class PdfCrossRefEntry {
+
+ /** The size, in bytes, of a PDF cross-reference entry when serialized. */
+ public static final int TOTAL_BYTE_LENGTH = 20;
+
+ /** The size, in bytes, of the offset portion of a PDF cross-reference entry when serialized. */
+ public static final int OFFSET_BYTE_LENGTH = 10;
+
+ /** The size, in bytes, of the generation portion of a PDF cross-reference entry when serialized. */
+ public static final int GENERATION_BYTE_LENGTH = 5;
+
+ /** Formatting string for writing the offset value. */
+ private static final String OFFSET_FORMATTING_STRING = "%010d";
+
+ /** Formatting string for writing the generation value. */
+ private static final String GENERATION_FORMATTING_STRING = "%05d";
+
+ /** The 0-based offset into the file content (bytes) to which this entry points. */
+ private long offset;
+ /* The capacity defined in the PDF reference is 10 decimal digits, a maximum of 9,999,999,999, one less than 10
+ * billion, about 5 times as much as can be stored in an {@link Integer#TYPE}.
+ * Therefore we use {@link Long#TYPE}. */
+
+ /** The generation number of the object referenced by this entry. */
+ private int generation;
+ /* The capacity defined in the PDF reference is 5 decimal digits, a maximum of 99,999, one less than 10
+ * billion, about 3 times as much as can be stored in an {@link Short#TYPE}, and about 1.5 times a much as can be
+ * stored in a {@link Character#TYPE}.
+ * Therefore we use {@link Integer#TYPE}. */
+
+ /** Indicates whether this entry is "in-use" ("n" in the PDF), or "free" ("f" in the PDF). */
+ private boolean inUse;
+
+ /** The referenced object. This will be null if the document is being parsed and the parser has not yet parsed the
+ * object at this offset. */
+ private PdfObject object;
+
+ /**
+ * Constructor for the case where we wish to record that an object will be indirectly referenced, but we do not yet
+ * know the offset for it in the serialized output.
+ * This is useful mostly for cases where we are building a new document.
+ * @param object The object being added to the cross-reference table.
+ */
+ public PdfCrossRefEntry(final PdfObject object) {
+ this.offset = -1;
+ this.generation = 0;
+ this.inUse = true;
+ this.object = object;
+ }
+
+ /**
+ * Constructor that reads the instance values from a byte sequence.
+ * This is useful mostly when parsing from an existing document.
+ * @param sequence The byte sequence to be read.
+ * @param entryOffset The 0-based offset into {@code sequence} at which the parsing of the entry should begin.
+ * @throws IllegalArgumentException For invalid in-use indicator.
+ */
+ public PdfCrossRefEntry(final ByteSequencePlus sequence, final int entryOffset) {
+ int start = entryOffset;
+ int end = start + OFFSET_BYTE_LENGTH;
+ final String offsetString = sequence.charSubSequence(start, end).toString();
+ this.offset = Long.parseLong(offsetString);
+
+ start = end + 1;
+ end = start + GENERATION_BYTE_LENGTH;
+ final String generationString = sequence.charSubSequence(start, end).toString();
+ this.generation = Integer.parseInt(generationString);
+
+ start = end + 1;
+ final byte inUseChar = sequence.byteAt(start);
+ if (inUseChar == 'n') {
+ inUse = true;
+ } else if (inUseChar == 'f') {
+ inUse = false;
+ } else {
+ throw new IllegalArgumentException("In-use indicator must either \"n\" or \"f\". Actual: " + inUseChar);
+ }
+ }
+
+ /**
+ * Private constructor used by internal processes.
+ */
+ private PdfCrossRefEntry() { }
+
+ /**
+ * Creates the first...
[truncated message content] |
|
From: <vic...@us...> - 2022-01-29 19:38:16
|
Revision: 12500
http://sourceforge.net/p/foray/code/12500
Author: victormote
Date: 2022-01-29 19:38:14 +0000 (Sat, 29 Jan 2022)
Log Message:
-----------
Move action and annotation classes to new packages.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineItem4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/package-info.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAnnotList.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java
Added Paths:
-----------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfAction.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoTo.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoToRemote.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfUri.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/package-info.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfAnnotation.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfLink.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/package-info.java
Removed Paths:
-------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAction.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAnnotation.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoTo.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoToRemote.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfLink.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfUri.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineItem4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineItem4a.java 2022-01-29 19:26:18 UTC (rev 12499)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineItem4a.java 2022-01-29 19:38:14 UTC (rev 12500)
@@ -33,7 +33,7 @@
package org.foray.pdf.interact;
import org.foray.common.sequence.ByteArray;
-import org.foray.pdf.object.PdfAction;
+import org.foray.pdf.interact.action.PdfAction;
import org.foray.pdf.object.PdfColor4a;
import org.foray.pdf.object.PdfDocument4a;
import org.foray.pdf.structure.PdfTextString;
Copied: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfAction.java (from rev 12492, trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAction.java)
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfAction.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfAction.java 2022-01-29 19:38:14 UTC (rev 12500)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf.interact.action;
+
+import org.foray.pdf.object.PdfDocument4a;
+import org.foray.pdf.type.PdfObject;
+
+/**
+ * An action object.
+ */
+public abstract class PdfAction extends PdfObject {
+
+ /**
+ * represent the action to call
+ * this method should be implemented to return the action which gets
+ * called by the Link Object. This could be a reference to another object
+ * or the specific destination of the link
+ * @param doc The PDF Document.
+ *
+ * @return the action to place next to /A within a Link
+ */
+ public abstract String getAction(PdfDocument4a doc);
+
+}
Copied: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoTo.java (from rev 12499, trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoTo.java)
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoTo.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoTo.java 2022-01-29 19:38:14 UTC (rev 12500)
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf.interact.action;
+
+import org.foray.common.sequence.ByteArray;
+import org.foray.pdf.interact.PdfDestinationExplicit4a;
+import org.foray.pdf.object.PdfDocument4a;
+
+import org.axsl.utility.sequence.ByteSequencePlus;
+
+/**
+ * class representing a /GoTo object.
+ *
+ */
+public class PdfGoTo extends PdfAction {
+
+ /** The destination of this object. */
+ private PdfDestinationExplicit4a destination;
+
+ /**
+ * Create a /GoTo object.
+ * @param destination The PdfDestination that this object should "go to".
+ */
+ public PdfGoTo(final PdfDestinationExplicit4a destination) {
+ this.destination = destination;
+ }
+
+ @Override
+ public String getAction(final PdfDocument4a doc) {
+ return pdfReference(doc);
+ }
+
+
+ @Override
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ final StringBuilder buffer = new StringBuilder();
+ buffer.append(this.pdfID() + EOL);
+ buffer.append("<<" + EOL);
+ buffer.append("/S /GoTo" + EOL);
+ buffer.append("/D " + this.destination.serialize(doc) + ">>" + EOL);
+ buffer.append("endobj" + EOL);
+ return new ByteArray(buffer);
+ }
+
+ /*
+ * example
+ * 29 0 obj
+ * <<
+ * /S /GoTo
+ * /D [23 0 R /FitH 600]
+ * >>
+ * endobj
+ */
+}
Copied: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoToRemote.java (from rev 12498, trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoToRemote.java)
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoToRemote.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoToRemote.java 2022-01-29 19:38:14 UTC (rev 12500)
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf.interact.action;
+
+import org.foray.common.sequence.ByteArray;
+import org.foray.pdf.object.PdfDocument4a;
+import org.foray.pdf.object.PdfFileSpec;
+
+import org.axsl.utility.sequence.ByteSequencePlus;
+
+/**
+ * class representing a /GoToR object.
+ */
+public class PdfGoToRemote extends PdfAction {
+
+ /** The file specification. */
+ private PdfFileSpec pdfFileSpec;
+
+ /** The page number in the remote document to which this link points. */
+ private int pageReference = 0;
+
+ /** The remote destination for this object. */
+ private String destination = null;
+
+ /**
+ * Create a GoToR object.
+ * @param pdfFileSpec the fileSpec associated with the action
+ */
+ public PdfGoToRemote(final PdfFileSpec pdfFileSpec) {
+ /* generic creation of object */
+ this.pdfFileSpec = pdfFileSpec;
+ }
+
+ /**
+ * Create a GoToR object for a specific page in a remote document.
+ * @param pdfFileSpec The fileSpec associated with the action.
+ * @param page A page reference within the remote document.
+ */
+ public PdfGoToRemote(final PdfFileSpec pdfFileSpec, final int page) {
+ /* generic creation of object */
+ this.pdfFileSpec = pdfFileSpec;
+ this.pageReference = page;
+ }
+
+ /**
+ * Create a GoToR object for a named destination in a remote object.
+ * @param pdfFileSpec The fileSpec associated with the action.
+ * @param dest A named destination within the remote document.
+ */
+ public PdfGoToRemote(final PdfFileSpec pdfFileSpec, final String dest) {
+ /* generic creation of object */
+ this.pdfFileSpec = pdfFileSpec;
+ this.destination = dest;
+ }
+
+ @Override
+ public String getAction(final PdfDocument4a doc) {
+ return this.pdfReference(doc);
+ }
+
+ @Override
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ String p = new String(this.pdfID() + EOL
+ + "<<" + EOL + "/S /GoToR" + EOL + "/F "
+ + this.pdfFileSpec.pdfReference(doc) + "" + EOL);
+
+ if (this.destination != null) {
+ p += "/D (" + this.destination + ")";
+ } else {
+ p += "/D [ " + this.pageReference + " /XYZ null null null ]";
+ }
+
+ p += EOL + ">>" + EOL + "endobj" + EOL;
+
+ return new ByteArray(p);
+ }
+
+ /*
+ * example
+ * 28 0 obj
+ * <<
+ * /S /GoToR
+ * /F 29 0 R
+ * /D [ 0 /XYZ -6 797 null ]
+ * >>
+ * endobj
+ */
+}
Copied: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfUri.java (from rev 12498, trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfUri.java)
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfUri.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfUri.java 2022-01-29 19:38:14 UTC (rev 12500)
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf.interact.action;
+
+import org.foray.pdf.object.PdfDocument4a;
+
+import org.axsl.utility.sequence.ByteSequencePlus;
+
+/**
+ * A PDF Uri link.
+ */
+public class PdfUri extends PdfAction {
+
+ /** The encapsulated URI string. */
+ private String uri;
+
+ /**
+ * Create a Uri instance.
+ * @param uri The uri to which the link should point.
+ */
+ public PdfUri(final String uri) {
+ this.uri = uri;
+ }
+
+ /**
+ * Returns the action necessary for a uri.
+ * @param doc The PDF Document.
+ * @return the action to place next to /A within a Link
+ */
+ public String getAction(final PdfDocument4a doc) {
+ return "<< /URI (" + this.uri + ")" + EOL + "/S /URI >>";
+ }
+
+ /**
+ * There is nothing to return for the toPDF method, as it should not be
+ * called.
+ *
+ * @return an empty string
+ */
+ @Override
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ return null;
+ }
+
+}
Added: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/package-info.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/package-info.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/package-info.java 2022-01-29 19:38:14 UTC (rev 12500)
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2022 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+/**
+ * Classes for PDF actions.
+ * @see "PDF Reference, 6th Edition (PDF Version 1.7), Section 8.5."
+ */
+package org.foray.pdf.interact.action;
Property changes on: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/package-info.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Copied: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfAnnotation.java (from rev 12492, trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAnnotation.java)
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfAnnotation.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfAnnotation.java 2022-01-29 19:38:14 UTC (rev 12500)
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf.interact.annotation;
+
+import org.foray.pdf.type.PdfObject;
+
+import java.awt.geom.Rectangle2D;
+
+/**
+ * Abstract superclass for /Annot objects.
+ */
+public abstract class PdfAnnotation extends PdfObject {
+
+ /** The rectangle which outlines the link. */
+ private Rectangle2D rectangle;
+
+ /**
+ * Create objects associated with a link annotation (GoToR).
+ * @param r The rectangle which outlines the link.
+ */
+ public PdfAnnotation(final Rectangle2D r) {
+ this.rectangle = r;
+ }
+
+ /**
+ * Returns the rectange for this annotation.
+ * @return Returns the rectangle.
+ */
+ public Rectangle2D getRectangle() {
+ return this.rectangle;
+ }
+
+}
Copied: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfLink.java (from rev 12499, trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfLink.java)
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfLink.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfLink.java 2022-01-29 19:38:14 UTC (rev 12500)
@@ -0,0 +1,172 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf.interact.annotation;
+
+import org.foray.common.WellKnownConstants;
+import org.foray.common.sequence.ByteArray;
+import org.foray.pdf.interact.PdfDestinationExplicit4a;
+import org.foray.pdf.interact.action.PdfAction;
+import org.foray.pdf.object.PdfColor4a;
+import org.foray.pdf.object.PdfDocument4a;
+import org.foray.pdf.structure.PdfTextString;
+
+import org.axsl.utility.sequence.ByteSequencePlus;
+
+import java.awt.geom.Rectangle2D;
+
+/**
+ * A PDF /Annot object of /Subtype /Link.
+ */
+public class PdfLink extends PdfAnnotation implements org.axsl.pdf.PdfLink {
+
+ /** Should be null if either destination or action is not. */
+ private PdfTextString destinationName;
+
+ /** Should be null if either destinationName or action is not. */
+ private PdfDestinationExplicit4a destination;
+
+ /** Should be null if either destination or destinationName is not. */
+ private PdfAction action;
+
+ /** The color for this link. */
+ private PdfColor4a color = null;
+
+ /**
+ * Create a PdfLink object.
+ * @param rect The rectangle which outlines the link. All dimension in the
+ * rectangle should be expressed in 1/1000ths of a user space unit.
+ */
+ private PdfLink(final Rectangle2D rect) {
+ super(rect);
+ }
+
+ /**
+ * Constructor for a link to a named destination.
+ * @param rect The rectangle which outlines the link. All dimension in the
+ * rectangle should be expressed in 1/1000ths of a user space unit.
+ * @param destinationName The name of the destination to which this link
+ * points.
+ */
+ public PdfLink(final Rectangle2D rect, final String destinationName) {
+ this(rect);
+ this.destinationName = new PdfTextString(destinationName);
+ }
+
+ /**
+ * Constructor for a link to a named destination.
+ * @param rect The rectangle which outlines the link. All dimension in the
+ * rectangle should be expressed in 1/1000ths of a user space unit.
+ * @param destination The destination to which this link points.
+ */
+ public PdfLink(final Rectangle2D rect, final PdfDestinationExplicit4a destination) {
+ this(rect);
+ this.destination = destination;
+ }
+
+ /**
+ * Constructor for a link to an action.
+ * @param rect The rectangle which outlines the link. All dimension in the
+ * rectangle should be expressed in 1/1000ths of a user space unit.
+ * @param action The action to be activated by this link.
+ */
+ public PdfLink(final Rectangle2D rect, final PdfAction action) {
+ this(rect);
+ this.action = action;
+ }
+
+ /**
+ * Returns the color for this link.
+ * @return Returns the color.
+ */
+ public PdfColor4a getColor() {
+ return this.color;
+ }
+
+ /**
+ * Sets the color for this link.
+ * @param color The color to set.
+ */
+ public void setColor(final PdfColor4a color) {
+ this.color = color;
+ }
+
+ @Override
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ final StringBuilder buffer = new StringBuilder();
+ buffer.append(this.pdfID() + EOL);
+ buffer.append("<<" + EOL
+ + "/Type /Annot" + EOL
+ + "/Subtype /Link" + EOL
+ + "/Rect ["
+ + getRectangle().getX() / WellKnownConstants.MILLIPOINTS_PER_POINT
+ + " "
+ + getRectangle().getY() / WellKnownConstants.MILLIPOINTS_PER_POINT
+ + " "
+ + (getRectangle().getX() + getRectangle().getWidth())
+ / WellKnownConstants.MILLIPOINTS_PER_POINT
+ + " "
+ + (getRectangle().getY() - getRectangle().getHeight())
+ / WellKnownConstants.MILLIPOINTS_PER_POINT
+ + "]" + EOL);
+ buffer.append("/BS " + doc.getDefaultBorderStyle()
+ .pdfReference(doc) + EOL);
+ if (this.color != null && ! this.color.isBlack()) {
+ buffer.append("/C " + this.color.serialize(doc) + EOL);
+ }
+ if (this.destinationName != null
+ && this.destinationName.length() > 0) {
+ // If there is a named destination, use that ...
+ buffer.append("/Dest " + this.destinationName.serialize(doc)
+ + EOL);
+ } else if (this.destination != null) {
+ buffer.append("/Dest " + this.destination.serialize(doc));
+ } else if (this.action != null) {
+ // ... otherwise, use the Action.
+ buffer.append("/A " + this.action.getAction(doc) + EOL);
+ }
+ buffer.append(">>" + EOL + "endobj" + EOL);
+ return new ByteArray(buffer);
+ }
+
+ /*
+ * example
+ * 19 0 obj
+ * <<
+ * /Type /Annot
+ * /Subtype /Link
+ * /Rect [ 176.032 678.48412 228.73579 692.356 ]
+ * /C [ 0.86491 0.03421 0.02591 ]
+ * /Border [ 0 0 1 ]
+ * /A 28 0 R
+ * /H /I
+ * >>
+ * endobj
+ */
+
+}
Added: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/package-info.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/package-info.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/package-info.java 2022-01-29 19:38:14 UTC (rev 12500)
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2022 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+/**
+ * Classes for PDF annotations.
+ * @see "PDF Reference, 6th Edition (PDF Version 1.7), Section 8.4."
+ */
+package org.foray.pdf.interact.annotation;
Property changes on: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/package-info.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/package-info.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/package-info.java 2022-01-29 19:26:18 UTC (rev 12499)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/package-info.java 2022-01-29 19:38:14 UTC (rev 12500)
@@ -27,7 +27,7 @@
*/
/**
- * Classes representing the PDF interactive features.
+ * Classes for the PDF interactive features.
* @see "PDF Reference, 6th Edition (PDF Version 1.7), Section 8."
*/
package org.foray.pdf.interact;
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAction.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAction.java 2022-01-29 19:26:18 UTC (rev 12499)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAction.java 2022-01-29 19:38:14 UTC (rev 12500)
@@ -1,49 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-import org.foray.pdf.type.PdfObject;
-
-/**
- * An action object.
- */
-public abstract class PdfAction extends PdfObject {
-
- /**
- * represent the action to call
- * this method should be implemented to return the action which gets
- * called by the Link Object. This could be a reference to another object
- * or the specific destination of the link
- * @param doc The PDF Document.
- *
- * @return the action to place next to /A within a Link
- */
- public abstract String getAction(PdfDocument4a doc);
-
-}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAnnotList.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAnnotList.java 2022-01-29 19:26:18 UTC (rev 12499)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAnnotList.java 2022-01-29 19:38:14 UTC (rev 12500)
@@ -29,6 +29,7 @@
package org.foray.pdf.object;
import org.foray.common.sequence.ByteArray;
+import org.foray.pdf.interact.annotation.PdfAnnotation;
import org.foray.pdf.type.PdfObject;
import org.axsl.utility.sequence.ByteSequencePlus;
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAnnotation.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAnnotation.java 2022-01-29 19:26:18 UTC (rev 12499)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAnnotation.java 2022-01-29 19:38:14 UTC (rev 12500)
@@ -1,59 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-import org.foray.pdf.type.PdfObject;
-
-import java.awt.geom.Rectangle2D;
-
-/**
- * Abstract superclass for /Annot objects.
- */
-public abstract class PdfAnnotation extends PdfObject {
-
- /** The rectangle which outlines the link. */
- private Rectangle2D rectangle;
-
- /**
- * Create objects associated with a link annotation (GoToR).
- * @param r The rectangle which outlines the link.
- */
- public PdfAnnotation(final Rectangle2D r) {
- this.rectangle = r;
- }
-
- /**
- * Returns the rectange for this annotation.
- * @return Returns the rectangle.
- */
- public Rectangle2D getRectangle() {
- return this.rectangle;
- }
-
-}
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoTo.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoTo.java 2022-01-29 19:26:18 UTC (rev 12499)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoTo.java 2022-01-29 19:38:14 UTC (rev 12500)
@@ -1,79 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-import org.foray.common.sequence.ByteArray;
-import org.foray.pdf.interact.PdfDestinationExplicit4a;
-
-import org.axsl.utility.sequence.ByteSequencePlus;
-
-/**
- * class representing a /GoTo object.
- *
- */
-public class PdfGoTo extends PdfAction {
-
- /** The destination of this object. */
- private PdfDestinationExplicit4a destination;
-
- /**
- * Create a /GoTo object.
- * @param destination The PdfDestination that this object should "go to".
- */
- public PdfGoTo(final PdfDestinationExplicit4a destination) {
- this.destination = destination;
- }
-
- @Override
- public String getAction(final PdfDocument4a doc) {
- return pdfReference(doc);
- }
-
-
- @Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
- final StringBuilder buffer = new StringBuilder();
- buffer.append(this.pdfID() + EOL);
- buffer.append("<<" + EOL);
- buffer.append("/S /GoTo" + EOL);
- buffer.append("/D " + this.destination.serialize(doc) + ">>" + EOL);
- buffer.append("endobj" + EOL);
- return new ByteArray(buffer);
- }
-
- /*
- * example
- * 29 0 obj
- * <<
- * /S /GoTo
- * /D [23 0 R /FitH 600]
- * >>
- * endobj
- */
-}
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoToRemote.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoToRemote.java 2022-01-29 19:26:18 UTC (rev 12499)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoToRemote.java 2022-01-29 19:38:14 UTC (rev 12500)
@@ -1,112 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-import org.foray.common.sequence.ByteArray;
-
-import org.axsl.utility.sequence.ByteSequencePlus;
-
-/**
- * class representing a /GoToR object.
- */
-public class PdfGoToRemote extends PdfAction {
-
- /** The file specification. */
- private PdfFileSpec pdfFileSpec;
-
- /** The page number in the remote document to which this link points. */
- private int pageReference = 0;
-
- /** The remote destination for this object. */
- private String destination = null;
-
- /**
- * Create a GoToR object.
- * @param pdfFileSpec the fileSpec associated with the action
- */
- public PdfGoToRemote(final PdfFileSpec pdfFileSpec) {
- /* generic creation of object */
- this.pdfFileSpec = pdfFileSpec;
- }
-
- /**
- * Create a GoToR object for a specific page in a remote document.
- * @param pdfFileSpec The fileSpec associated with the action.
- * @param page A page reference within the remote document.
- */
- public PdfGoToRemote(final PdfFileSpec pdfFileSpec, final int page) {
- /* generic creation of object */
- this.pdfFileSpec = pdfFileSpec;
- this.pageReference = page;
- }
-
- /**
- * Create a GoToR object for a named destination in a remote object.
- * @param pdfFileSpec The fileSpec associated with the action.
- * @param dest A named destination within the remote document.
- */
- public PdfGoToRemote(final PdfFileSpec pdfFileSpec, final String dest) {
- /* generic creation of object */
- this.pdfFileSpec = pdfFileSpec;
- this.destination = dest;
- }
-
- @Override
- public String getAction(final PdfDocument4a doc) {
- return this.pdfReference(doc);
- }
-
- @Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
- String p = new String(this.pdfID() + EOL
- + "<<" + EOL + "/S /GoToR" + EOL + "/F "
- + this.pdfFileSpec.pdfReference(doc) + "" + EOL);
-
- if (this.destination != null) {
- p += "/D (" + this.destination + ")";
- } else {
- p += "/D [ " + this.pageReference + " /XYZ null null null ]";
- }
-
- p += EOL + ">>" + EOL + "endobj" + EOL;
-
- return new ByteArray(p);
- }
-
- /*
- * example
- * 28 0 obj
- * <<
- * /S /GoToR
- * /F 29 0 R
- * /D [ 0 /XYZ -6 797 null ]
- * >>
- * endobj
- */
-}
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfLink.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfLink.java 2022-01-29 19:26:18 UTC (rev 12499)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfLink.java 2022-01-29 19:38:14 UTC (rev 12500)
@@ -1,169 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-import org.foray.common.WellKnownConstants;
-import org.foray.common.sequence.ByteArray;
-import org.foray.pdf.interact.PdfDestinationExplicit4a;
-import org.foray.pdf.structure.PdfTextString;
-
-import org.axsl.utility.sequence.ByteSequencePlus;
-
-import java.awt.geom.Rectangle2D;
-
-/**
- * A PDF /Annot object of /Subtype /Link.
- */
-public class PdfLink extends PdfAnnotation implements org.axsl.pdf.PdfLink {
-
- /** Should be null if either destination or action is not. */
- private PdfTextString destinationName;
-
- /** Should be null if either destinationName or action is not. */
- private PdfDestinationExplicit4a destination;
-
- /** Should be null if either destination or destinationName is not. */
- private PdfAction action;
-
- /** The color for this link. */
- private PdfColor4a color = null;
-
- /**
- * Create a PdfLink object.
- * @param rect The rectangle which outlines the link. All dimension in the
- * rectangle should be expressed in 1/1000ths of a user space unit.
- */
- private PdfLink(final Rectangle2D rect) {
- super(rect);
- }
-
- /**
- * Constructor for a link to a named destination.
- * @param rect The rectangle which outlines the link. All dimension in the
- * rectangle should be expressed in 1/1000ths of a user space unit.
- * @param destinationName The name of the destination to which this link
- * points.
- */
- public PdfLink(final Rectangle2D rect, final String destinationName) {
- this(rect);
- this.destinationName = new PdfTextString(destinationName);
- }
-
- /**
- * Constructor for a link to a named destination.
- * @param rect The rectangle which outlines the link. All dimension in the
- * rectangle should be expressed in 1/1000ths of a user space unit.
- * @param destination The destination to which this link points.
- */
- public PdfLink(final Rectangle2D rect, final PdfDestinationExplicit4a destination) {
- this(rect);
- this.destination = destination;
- }
-
- /**
- * Constructor for a link to an action.
- * @param rect The rectangle which outlines the link. All dimension in the
- * rectangle should be expressed in 1/1000ths of a user space unit.
- * @param action The action to be activated by this link.
- */
- public PdfLink(final Rectangle2D rect, final PdfAction action) {
- this(rect);
- this.action = action;
- }
-
- /**
- * Returns the color for this link.
- * @return Returns the color.
- */
- public PdfColor4a getColor() {
- return this.color;
- }
-
- /**
- * Sets the color for this link.
- * @param color The color to set.
- */
- public void setColor(final PdfColor4a color) {
- this.color = color;
- }
-
- @Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
- final StringBuilder buffer = new StringBuilder();
- buffer.append(this.pdfID() + EOL);
- buffer.append("<<" + EOL
- + "/Type /Annot" + EOL
- + "/Subtype /Link" + EOL
- + "/Rect ["
- + getRectangle().getX() / WellKnownConstants.MILLIPOINTS_PER_POINT
- + " "
- + getRectangle().getY() / WellKnownConstants.MILLIPOINTS_PER_POINT
- + " "
- + (getRectangle().getX() + getRectangle().getWidth())
- / WellKnownConstants.MILLIPOINTS_PER_POINT
- + " "
- + (getRectangle().getY() - getRectangle().getHeight())
- / WellKnownConstants.MILLIPOINTS_PER_POINT
- + "]" + EOL);
- buffer.append("/BS " + doc.getDefaultBorderStyle()
- .pdfReference(doc) + EOL);
- if (this.color != null && ! this.color.isBlack()) {
- buffer.append("/C " + this.color.serialize(doc) + EOL);
- }
- if (this.destinationName != null
- && this.destinationName.length() > 0) {
- // If there is a named destination, use that ...
- buffer.append("/Dest " + this.destinationName.serialize(doc)
- + EOL);
- } else if (this.destination != null) {
- buffer.append("/Dest " + this.destination.serialize(doc));
- } else if (this.action != null) {
- // ... otherwise, use the Action.
- buffer.append("/A " + this.action.getAction(doc) + EOL);
- }
- buffer.append(">>" + EOL + "endobj" + EOL);
- return new ByteArray(buffer);
- }
-
- /*
- * example
- * 19 0 obj
- * <<
- * /Type /Annot
- * /Subtype /Link
- * /Rect [ 176.032 678.48412 228.73579 692.356 ]
- * /C [ 0.86491 0.03421 0.02591 ]
- * /Border [ 0 0 1 ]
- * /A 28 0 R
- * /H /I
- * >>
- * endobj
- */
-
-}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java 2022-01-29 19:26:18 UTC (rev 12499)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java 2022-01-29 19:38:14 UTC (rev 12500)
@@ -31,6 +31,10 @@
import org.foray.common.sequence.ByteArray;
import org.foray.pdf.interact.PdfDestinationExplicit4a;
import org.foray.pdf.interact.PdfDestinationNamed4a;
+import org.foray.pdf.interact.action.PdfAction;
+import org.foray.pdf.interact.action.PdfGoToRemote;
+import org.foray.pdf.interact.action.PdfUri;
+import org.foray.pdf.interact.annotation.PdfLink;
import org.foray.pdf.structure.PdfNameTree;
import org.foray.pdf.type.PdfObject;
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfUri.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfUri.java 2022-01-29 19:26:18 UTC (rev 12499)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfUri.java 2022-01-29 19:38:14 UTC (rev 12500)
@@ -1,69 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-import org.axsl.utility.sequence.ByteSequencePlus;
-
-/**
- * A PDF Uri link.
- */
-public class PdfUri extends PdfAction {
-
- /** The encapsulated URI string. */
- private String uri;
-
- /**
- * Create a Uri instance.
- * @param uri The uri to which the link should point.
- */
- public PdfUri(final String uri) {
- this.uri = uri;
- }
-
- /**
- * Returns the action necessary for a uri.
- * @param doc The PDF Document.
- * @return the action to place next to /A within a Link
- */
- public String getAction(final PdfDocument4a doc) {
- return "<< /URI (" + this.uri + ")" + EOL + "/S /URI >>";
- }
-
- /**
- * There is nothing to return for the toPDF method, as it should not be
- * called.
- *
- * @return an empty string
- */
- @Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
- return null;
- }
-
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-29 19:26:21
|
Revision: 12499
http://sourceforge.net/p/foray/code/12499
Author: victormote
Date: 2022-01-29 19:26:18 +0000 (Sat, 29 Jan 2022)
Log Message:
-----------
Move some classes for interactive features to new package.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfNamedDestinationsTree4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoTo.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfLink.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java
Added Paths:
-----------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationExplicit4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationNamed4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutline4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineItem4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineParent4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfPageLabel.java
Removed Paths:
-------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineParent4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPageLabel.java
Copied: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationExplicit4a.java (from rev 12498, trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java)
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationExplicit4a.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationExplicit4a.java 2022-01-29 19:26:18 UTC (rev 12499)
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+/*
+ * Known contributors:
+ * Stefan Wachter
+ * Lloyd McKenzie
+ */
+
+package org.foray.pdf.interact;
+
+import org.foray.common.sequence.ByteArray;
+import org.foray.pdf.object.PdfDocument4a;
+import org.foray.pdf.object.PdfPage4a;
+import org.foray.pdf.type.PdfObject;
+
+import org.axsl.pdf.PdfDestinationExplicit;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
+/**
+ * A PDF Explicit Destination, a destination that points to a specific page / location / view.
+ * An Explicit Destination is by definition an array object.
+ * @see "PDF Reference, 2nd Edition (PDF 1.3), Section 7.2.1."
+ * @see "PDF Reference, 6th Edition (PDF 1.7), Section 8.2.1."
+ */
+public class PdfDestinationExplicit4a extends PdfObject implements PdfDestinationExplicit {
+
+ /** The parent page to which this Destination belongs. */
+ private PdfPage4a page;
+
+ /** The position and zoom for this destination. */
+ private PdfDestinationExplicit.PositionAndZoom positionAndZoom;
+
+ /** The coordinates for this destination. */
+ private PdfDestinationExplicit.Coordinates coordinates;
+
+ /** The explicit zoom for this destination. */
+ private Float explicitZoom;
+
+ /**
+ * Constructor.
+ * @param page The page on which the destination exists.
+ * @param positionAndZoom The position and zoom for this destination.
+ * @param coordinates The coordinates for this destination.
+ * @param explicitZoom The explicit zoom for this destination.
+ */
+ public PdfDestinationExplicit4a(final PdfPage4a page, final PdfDestinationExplicit.PositionAndZoom positionAndZoom,
+ final PdfDestinationExplicit.Coordinates coordinates, final Float explicitZoom) {
+ this.page = page;
+ this.positionAndZoom = positionAndZoom;
+ this.coordinates = coordinates;
+ this.explicitZoom = explicitZoom;
+ }
+
+ @Override
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ final StringBuilder buffer = new StringBuilder();
+ buffer.append(this.pdfID());
+ buffer.append(EOL);
+ buffer.append("[");
+ buffer.append(this.page.pdfReference(doc));
+ buffer.append(" ");
+ buffer.append(this.positionAndZoom.getPdfName());
+ switch(this.positionAndZoom) {
+ case XYZ: {
+ buffer.append(" ");
+ buffer.append(this.coordinates.getLeft());
+ buffer.append(" ");
+ buffer.append(this.coordinates.getTop());
+ buffer.append(" ");
+ final String zoom = this.explicitZoom == null ? NULL_OBJECT_VALUE : Float.toString(this.explicitZoom);
+ buffer.append(zoom);
+ break;
+ }
+ case FIT:
+ break;
+ case FIT_H:
+ buffer.append(" ");
+ buffer.append(this.coordinates.getTop());
+ break;
+ case FIT_V:
+ buffer.append(" ");
+ buffer.append(this.coordinates.getLeft());
+ break;
+ case FIT_R:
+ buffer.append(" ");
+ buffer.append(this.coordinates.getLeft());
+ buffer.append(" ");
+ buffer.append(this.coordinates.getBottom());
+ buffer.append(" ");
+ buffer.append(this.coordinates.getRight());
+ buffer.append(" ");
+ buffer.append(this.coordinates.getTop());
+ break;
+ case FIT_B:
+ break;
+ case FIT_BH:
+ buffer.append(" ");
+ buffer.append(this.coordinates.getTop());
+ break;
+ case FIT_BV:
+ buffer.append(" ");
+ buffer.append(this.coordinates.getLeft());
+ break;
+ default:
+ throw new IllegalArgumentException("Unexpected PositionAndZoom");
+ }
+
+ buffer.append("]");
+ buffer.append(EOL);
+ buffer.append("endobj" + EOL);
+ return new ByteArray(buffer);
+ }
+
+}
Copied: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationNamed4a.java (from rev 12498, trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java)
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationNamed4a.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationNamed4a.java 2022-01-29 19:26:18 UTC (rev 12499)
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2022 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf.interact;
+
+import org.foray.pdf.object.PdfDocument4a;
+import org.foray.pdf.structure.PdfTextString;
+import org.foray.pdf.type.PdfObject;
+
+import org.axsl.pdf.PdfDestinationNamed;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
+public class PdfDestinationNamed4a extends PdfObject implements PdfDestinationNamed {
+
+ /** The registered name of this destination. */
+ private PdfTextString name;
+
+ /** The explicit destination to which this named destination is attached. */
+ private PdfDestinationExplicit4a explicitDestination;
+
+ public PdfDestinationNamed4a(final String name, final PdfDestinationExplicit4a explicitDestination) {
+ this.name = new PdfTextString(name);
+ this.explicitDestination = explicitDestination;
+ }
+
+ @Override
+ public String getName() {
+ return this.name.toString();
+ }
+
+ @Override
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ return this.name.serialize(doc);
+ }
+
+ /**
+ * Return the explicit destination to which this named destination is attached.
+ * @return The explicit destination.
+ */
+ public PdfDestinationExplicit4a getReferencedDestination() {
+ return this.explicitDestination;
+ }
+
+}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfNamedDestinationsTree4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfNamedDestinationsTree4a.java 2022-01-29 19:11:03 UTC (rev 12498)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfNamedDestinationsTree4a.java 2022-01-29 19:26:18 UTC (rev 12499)
@@ -28,7 +28,6 @@
package org.foray.pdf.interact;
-import org.foray.pdf.object.PdfDestinationNamed4a;
import org.foray.pdf.object.PdfDocument4a;
import org.foray.pdf.structure.PdfNameTree;
Copied: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutline4a.java (from rev 12498, trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline4a.java)
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutline4a.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutline4a.java 2022-01-29 19:26:18 UTC (rev 12499)
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf.interact;
+
+import org.foray.common.sequence.ByteArray;
+import org.foray.pdf.object.PdfDocument4a;
+
+import org.axsl.utility.sequence.ByteSequencePlus;
+
+/**
+ * An Outline dictionary in PDF.
+ * See PDF Reference 3rd Edition, Section 8.2.2.
+ */
+public class PdfOutline4a extends PdfOutlineParent4a {
+
+ /**
+ * Returns the total number of open items at all levels of the outline.
+ * @return The total number of open items at all levels of the outline.
+ * @see "PDF Reference, 3rd Edition, Table 8.3.3"
+ */
+ protected int count() {
+ // no count... we start with the outline completely closed for now
+ return 0;
+ }
+
+ @Override
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ if (getChildren().size() < 1) {
+ return ByteArray.EMPTY;
+ }
+ final StringBuilder result = new StringBuilder();
+ result.append(this.pdfID() + EOL);
+ result.append("<<" + EOL);
+ result.append(" /Type /Outlines" + EOL);
+ if (getFirst() != null && getLast() != null) {
+ result.append(" /First " + getFirst().pdfReference(doc) + EOL);
+ result.append(" /Last " + getLast().pdfReference(doc) + EOL);
+ }
+ if (count() > 0) {
+ result.append(" /Count " + count() + EOL);
+ }
+ result.append(">> endobj" + EOL);
+ return new ByteArray(result);
+ }
+
+}
Copied: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineItem4a.java (from rev 12498, trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java)
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineItem4a.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineItem4a.java 2022-01-29 19:26:18 UTC (rev 12499)
@@ -0,0 +1,222 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+/*
+ * Known Constributors:
+ * Kelly A. Campbell
+ */
+package org.foray.pdf.interact;
+
+import org.foray.common.sequence.ByteArray;
+import org.foray.pdf.object.PdfAction;
+import org.foray.pdf.object.PdfColor4a;
+import org.foray.pdf.object.PdfDocument4a;
+import org.foray.pdf.structure.PdfTextString;
+
+import org.axsl.pdf.PdfDestination;
+import org.axsl.pdf.PdfOutlineItem;
+import org.axsl.pdf.PdfOutlineTarget;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
+import java.awt.Color;
+import java.util.List;
+
+/**
+ * An Outline Item Dictionary in PDF.
+ */
+
+public class PdfOutlineItem4a extends PdfOutlineParent4a implements PdfOutlineItem {
+
+ /** The parent object. */
+ private PdfOutlineParent4a parent;
+
+ /** The title to display for the bookmark entry. */
+ private PdfTextString title;
+
+ /**
+ * Bit 1 of the flags entry.
+ * @see "PDF Reference, 3rd Edition, Table 8.5 and the discussion near it."
+ */
+ private boolean italic = false;
+
+ /**
+ * Bit 2 of the flags entry.
+ * @see "PDF Reference, 3rd Edition, Table 8.5 and the discussion near it."
+ */
+ private boolean bold = false;
+
+ /** The color for this outline item. */
+ private PdfColor4a color = null;
+
+ /** The target of this bookmark. */
+ private PdfOutlineTarget target;
+
+ /**
+ * Private constructor to be used only by the public constructors in this class.
+ * @param parent The parent outline item.
+ * @param title The title or text of the outline item.
+ * @param target The target of this outline item.
+ * @param color The color of the outline item.
+ * @param italic Indicates whether the outline item should be displayed
+ * in an italic font.
+ * @param bold Indciates whether the outline item should be displayed in a
+ * bold font.
+ */
+ public PdfOutlineItem4a(final PdfOutlineParent4a parent, final String title, final PdfOutlineTarget target,
+ final Color color, final boolean italic, final boolean bold) {
+ this.parent = parent;
+ this.title = new PdfTextString(title);
+ this.target = target;
+ if (color != null) {
+ this.color = new PdfColor4a(color);
+ }
+ this.italic = italic;
+ this.bold = bold;
+ }
+
+ /**
+ * Return the sibling outline items.
+ * @return The sibling outline items.
+ */
+ private List<PdfOutlineItem4a> getSiblings() {
+ if (this.parent instanceof PdfOutline4a) {
+ return ((PdfOutline4a) this.parent).getChildren();
+ }
+ if (this.parent instanceof PdfOutlineItem4a) {
+ return ((PdfOutlineItem4a) this.parent).getChildren();
+ }
+ return null;
+ }
+
+ /**
+ * Return the sibling outline item immediately before this one.
+ * @return The sibling outline item immediately before this one, or null if there is none.
+ */
+ private PdfOutlineItem4a getPrevious() {
+ final int myIndex = this.parent.getChildren().indexOf(this);
+ if (myIndex < 1) {
+ return null;
+ }
+ return this.parent.getChildren().get(myIndex - 1);
+ }
+
+ /**
+ * Return the sibling outline item immediately after this one.
+ * @return The sibling outline item immediately after this one, or null if there is none.
+ */
+ private PdfOutlineItem4a getNext() {
+ final int myIndex = this.parent.getChildren().indexOf(this);
+ if (myIndex >= getSiblings().size() - 1) {
+ return null;
+ }
+ return this.parent.getChildren().get(myIndex + 1);
+ }
+
+ @Override
+ protected int count() {
+ if (getChildren() == null) {
+ return 0;
+ }
+ int descendants = getChildren().size();
+ for (int i = 0; i < getChildren().size(); i++) {
+ final PdfOutlineItem4a child = getChildren().get(i);
+ descendants += child.count();
+ }
+ return descendants;
+ }
+
+ /**
+ * Computes the flags (unsigned 32-bit integer), as described in PDF
+ * Reference, 3rd Edition, near Table 8.5.
+ * @return The flags integer.
+ */
+ protected long flags() {
+ long flags = 0;
+ if (this.italic) {
+ /* BitUtils 1, 2^0. */
+ flags += 1;
+ }
+ if (this.bold) {
+ /* BitUtils 2, 2^1. */
+ flags += 2;
+ }
+ return flags;
+ }
+
+ @Override
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ final StringBuilder result = new StringBuilder();
+ result.append(this.pdfID() + EOL + "<<" + EOL);
+ final int countDescendants = this.count();
+ // subentry Outline object
+ result.append(" /Title " + this.title.serialize(doc) + EOL);
+ result.append(" /Parent " + this.parent.pdfReference(doc) + EOL);
+ if (getFirst() != null && getLast() != null) {
+ result.append(" /First " + getFirst().pdfReference(doc) + EOL);
+ result.append(" /Last " + getLast().pdfReference(doc) + EOL);
+ }
+ final PdfOutlineItem4a previous = getPrevious();
+ if (previous != null) {
+ result.append(" /Prev " + previous.pdfReference(doc) + EOL);
+ }
+ final PdfOutlineItem4a next = getNext();
+ if (next != null) {
+ result.append(" /Next " + next.pdfReference(doc) + EOL);
+ }
+ if (countDescendants > 0) {
+ result.append(" /Count -" + countDescendants + EOL);
+ }
+
+ if (this.target instanceof PdfDestination) {
+ result.append(" /Dest ");
+ if (this.target instanceof PdfDestinationNamed4a) {
+ final PdfDestinationNamed4a named = (PdfDestinationNamed4a) this.target;
+ result.append(named.serialize(doc));
+ } else if (this.target instanceof PdfDestinationExplicit4a) {
+ final PdfDestinationExplicit4a explicit = (PdfDestinationExplicit4a) this.target;
+ result.append(explicit.serialize(doc));
+ }
+ result.append(EOL);
+ } else if (this.target instanceof PdfAction) {
+ final PdfAction action = (PdfAction) this.target;
+ result.append(" /A " + action.serialize(doc));
+ }
+
+ if (this.color != null
+ && ! this.color.isBlack()) {
+ result.append(" /C " + this.color.serialize(doc) + EOL);
+ }
+ if (this.flags() != 0) {
+ result.append(" /F " + this.flags() + EOL);
+ }
+ result.append(">> endobj" + EOL);
+
+ return new ByteArray(result);
+ }
+
+}
Copied: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineParent4a.java (from rev 12492, trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineParent4a.java)
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineParent4a.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineParent4a.java 2022-01-29 19:26:18 UTC (rev 12499)
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf.interact;
+
+import org.foray.pdf.type.PdfObject;
+
+import org.axsl.pdf.PdfOutlineParent;
+import org.axsl.pdf.PdfOutlineTarget;
+
+import java.awt.Color;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Abstract superclass for PDFObjects that can be parents of a PdfOutlineItem4a
+ * object. This includes the classes PdfOutline and PdfOutlineItem4a.
+ */
+
+public abstract class PdfOutlineParent4a extends PdfObject implements PdfOutlineParent {
+
+ /** Collection of child PdfOutline objects. */
+ private List<PdfOutlineItem4a> children = new ArrayList<PdfOutlineItem4a>();
+
+ /**
+ * Return the children of this parent.
+ * @return The children of this parent.
+ */
+ public List<PdfOutlineItem4a> getChildren() {
+ return this.children;
+ }
+
+ /**
+ * Return the first child of this parent.
+ * @return The first child of this parent.
+ */
+ protected PdfOutlineItem4a getFirst() {
+ if (this.children == null
+ || this.children.size() < 1) {
+ return null;
+ }
+ return this.children.get(0);
+ }
+
+ /**
+ * Return the last child of this parent.
+ * @return The last child of this parent.
+ */
+ protected PdfOutlineItem4a getLast() {
+ if (this.children == null
+ || this.children.size() < 1) {
+ return null;
+ }
+ return this.children.get(this.children.size() - 1);
+ }
+
+ /**
+ * Return the total number of descendants.
+ * @return The total number of descendants.
+ */
+ protected abstract int count();
+
+ @Override
+ public PdfOutlineItem4a createPdfOutlineItem(final String titleText, final PdfOutlineTarget internalDestination,
+ final Color color, final boolean italic, final boolean bold) {
+ final PdfOutlineItem4a newItem =
+ new PdfOutlineItem4a(this, titleText, internalDestination, color, italic, bold);
+ this.children.add(newItem);
+ return newItem;
+ }
+
+}
Copied: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfPageLabel.java (from rev 12498, trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPageLabel.java)
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfPageLabel.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfPageLabel.java 2022-01-29 19:26:18 UTC (rev 12499)
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2007 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf.interact;
+
+import org.foray.common.sequence.ByteArray;
+import org.foray.pdf.object.PdfDocument4a;
+import org.foray.pdf.structure.PdfTextString;
+import org.foray.pdf.type.PdfObject;
+
+import org.axsl.pdf.PdfPageLabelStyle;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
+/**
+ * A PDF PageLabel Dictionary. See PDF Reference, 3rd Edition, Section 8.3.1.
+ */
+public class PdfPageLabel extends PdfObject {
+
+ /** The numbering style to be used for the numeric portion of each page
+ * label. A null value implies that the numeric portion of the page label
+ * will not be displayed. */
+ private PdfPageLabelStyle style;
+
+ /** The (optional) label prefix for page labels in this range. */
+ private PdfTextString labelPrefix;
+
+ /** The (optional) value of the numeric portion for the first page label in
+ * the range. Subsequent pages will be numbered sequentially from this
+ * value. */
+ private int startingNumber;
+
+ /**
+ * Create a PdfPageLabel object.
+ * @param doc The parent PDF document.
+ * @param style The numbering style to be used for the numeric portion of
+ * each page label. If null is passed, there will be no numeric portion in
+ * the page label.
+ * @param labelPrefix The (optional) label prefix for page labels in this
+ * range. If null is passed, there will be no label prefix in the page
+ * label.
+ * @param startingNumber The (optional) value of the numeric portion for the
+ * first page label in the range. Subsequent pages will be numbered
+ * sequentially from this value.
+ */
+ public PdfPageLabel(final PdfDocument4a doc, final PdfPageLabelStyle style,
+ final CharSequence labelPrefix, final int startingNumber) {
+ this.style = style;
+ if (labelPrefix != null
+ && ! (labelPrefix.equals(""))) {
+ this.labelPrefix = new PdfTextString(labelPrefix);
+ }
+ this.startingNumber = startingNumber;
+ doc.registerIndirectObject(this);
+ }
+
+ @Override
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ final StringBuilder buffer = new StringBuilder();
+ buffer.append(this.pdfID() + EOL);
+ buffer.append("<< /Type /PageLabel" + EOL);
+ if (this.style != null) {
+ buffer.append("/S /" + this.style.getPdfName() + EOL);
+ }
+ if (this.labelPrefix != null) {
+ buffer.append("/P " + this.labelPrefix.pdfReference(doc) + EOL);
+ }
+ if (this.startingNumber > 0) {
+ /* Ignore any entries with a value less than 1. */
+ buffer.append("/St " + this.startingNumber + EOL);
+ }
+ buffer.append(">>" + EOL + "endobj" + EOL);
+ return new ByteArray(buffer);
+ }
+
+}
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java 2022-01-29 19:11:03 UTC (rev 12498)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java 2022-01-29 19:26:18 UTC (rev 12499)
@@ -1,138 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-/*
- * Known contributors:
- * Stefan Wachter
- * Lloyd McKenzie
- */
-
-package org.foray.pdf.object;
-
-import org.foray.common.sequence.ByteArray;
-import org.foray.pdf.type.PdfObject;
-
-import org.axsl.pdf.PdfDestinationExplicit;
-import org.axsl.utility.sequence.ByteSequencePlus;
-
-/**
- * A PDF Explicit Destination, a destination that points to a specific page / location / view.
- * An Explicit Destination is by definition an array object.
- * @see "PDF Reference, 2nd Edition (PDF 1.3), Section 7.2.1."
- * @see "PDF Reference, 6th Edition (PDF 1.7), Section 8.2.1."
- */
-public class PdfDestinationExplicit4a extends PdfObject implements PdfDestinationExplicit {
-
- /** The parent page to which this Destination belongs. */
- private PdfPage4a page;
-
- /** The position and zoom for this destination. */
- private PdfDestinationExplicit.PositionAndZoom positionAndZoom;
-
- /** The coordinates for this destination. */
- private PdfDestinationExplicit.Coordinates coordinates;
-
- /** The explicit zoom for this destination. */
- private Float explicitZoom;
-
- /**
- * Constructor.
- * @param page The page on which the destination exists.
- * @param positionAndZoom The position and zoom for this destination.
- * @param coordinates The coordinates for this destination.
- * @param explicitZoom The explicit zoom for this destination.
- */
- public PdfDestinationExplicit4a(final PdfPage4a page, final PdfDestinationExplicit.PositionAndZoom positionAndZoom,
- final PdfDestinationExplicit.Coordinates coordinates, final Float explicitZoom) {
- this.page = page;
- this.positionAndZoom = positionAndZoom;
- this.coordinates = coordinates;
- this.explicitZoom = explicitZoom;
- }
-
- @Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
- final StringBuilder buffer = new StringBuilder();
- buffer.append(this.pdfID());
- buffer.append(EOL);
- buffer.append("[");
- buffer.append(this.page.pdfReference(doc));
- buffer.append(" ");
- buffer.append(this.positionAndZoom.getPdfName());
- switch(this.positionAndZoom) {
- case XYZ: {
- buffer.append(" ");
- buffer.append(this.coordinates.getLeft());
- buffer.append(" ");
- buffer.append(this.coordinates.getTop());
- buffer.append(" ");
- final String zoom = this.explicitZoom == null ? NULL_OBJECT_VALUE : Float.toString(this.explicitZoom);
- buffer.append(zoom);
- break;
- }
- case FIT:
- break;
- case FIT_H:
- buffer.append(" ");
- buffer.append(this.coordinates.getTop());
- break;
- case FIT_V:
- buffer.append(" ");
- buffer.append(this.coordinates.getLeft());
- break;
- case FIT_R:
- buffer.append(" ");
- buffer.append(this.coordinates.getLeft());
- buffer.append(" ");
- buffer.append(this.coordinates.getBottom());
- buffer.append(" ");
- buffer.append(this.coordinates.getRight());
- buffer.append(" ");
- buffer.append(this.coordinates.getTop());
- break;
- case FIT_B:
- break;
- case FIT_BH:
- buffer.append(" ");
- buffer.append(this.coordinates.getTop());
- break;
- case FIT_BV:
- buffer.append(" ");
- buffer.append(this.coordinates.getLeft());
- break;
- default:
- throw new IllegalArgumentException("Unexpected PositionAndZoom");
- }
-
- buffer.append("]");
- buffer.append(EOL);
- buffer.append("endobj" + EOL);
- return new ByteArray(buffer);
- }
-
-}
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java 2022-01-29 19:11:03 UTC (rev 12498)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java 2022-01-29 19:26:18 UTC (rev 12499)
@@ -1,68 +0,0 @@
-/*
- * Copyright 2022 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-import org.foray.pdf.structure.PdfTextString;
-import org.foray.pdf.type.PdfObject;
-
-import org.axsl.pdf.PdfDestinationNamed;
-import org.axsl.utility.sequence.ByteSequencePlus;
-
-public class PdfDestinationNamed4a extends PdfObject implements PdfDestinationNamed {
-
- /** The registered name of this destination. */
- private PdfTextString name;
-
- /** The explicit destination to which this named destination is attached. */
- private PdfDestinationExplicit4a explicitDestination;
-
- public PdfDestinationNamed4a(final String name, final PdfDestinationExplicit4a explicitDestination) {
- this.name = new PdfTextString(name);
- this.explicitDestination = explicitDestination;
- }
-
- @Override
- public String getName() {
- return this.name.toString();
- }
-
- @Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
- return this.name.serialize(doc);
- }
-
- /**
- * Return the explicit destination to which this named destination is attached.
- * @return The explicit destination.
- */
- public PdfDestinationExplicit4a getReferencedDestination() {
- return this.explicitDestination;
- }
-
-}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java 2022-01-29 19:11:03 UTC (rev 12498)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java 2022-01-29 19:26:18 UTC (rev 12499)
@@ -43,6 +43,8 @@
import org.foray.pdf.PdfCrossRefInfo;
import org.foray.pdf.PdfHeader;
import org.foray.pdf.PdfParser;
+import org.foray.pdf.interact.PdfOutlineParent4a;
+import org.foray.pdf.interact.PdfPageLabel;
import org.foray.pdf.type.PdfObject;
import org.axsl.font.Font;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoTo.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoTo.java 2022-01-29 19:11:03 UTC (rev 12498)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoTo.java 2022-01-29 19:26:18 UTC (rev 12499)
@@ -29,6 +29,7 @@
package org.foray.pdf.object;
import org.foray.common.sequence.ByteArray;
+import org.foray.pdf.interact.PdfDestinationExplicit4a;
import org.axsl.utility.sequence.ByteSequencePlus;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfLink.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfLink.java 2022-01-29 19:11:03 UTC (rev 12498)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfLink.java 2022-01-29 19:26:18 UTC (rev 12499)
@@ -30,6 +30,7 @@
import org.foray.common.WellKnownConstants;
import org.foray.common.sequence.ByteArray;
+import org.foray.pdf.interact.PdfDestinationExplicit4a;
import org.foray.pdf.structure.PdfTextString;
import org.axsl.utility.sequence.ByteSequencePlus;
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline4a.java 2022-01-29 19:11:03 UTC (rev 12498)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline4a.java 2022-01-29 19:26:18 UTC (rev 12499)
@@ -1,71 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-import org.foray.common.sequence.ByteArray;
-
-import org.axsl.utility.sequence.ByteSequencePlus;
-
-/**
- * An Outline dictionary in PDF.
- * See PDF Reference 3rd Edition, Section 8.2.2.
- */
-public class PdfOutline4a extends PdfOutlineParent4a {
-
- /**
- * Returns the total number of open items at all levels of the outline.
- * @return The total number of open items at all levels of the outline.
- * @see "PDF Reference, 3rd Edition, Table 8.3.3"
- */
- protected int count() {
- // no count... we start with the outline completely closed for now
- return 0;
- }
-
- @Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
- if (getChildren().size() < 1) {
- return ByteArray.EMPTY;
- }
- final StringBuilder result = new StringBuilder();
- result.append(this.pdfID() + EOL);
- result.append("<<" + EOL);
- result.append(" /Type /Outlines" + EOL);
- if (getFirst() != null && getLast() != null) {
- result.append(" /First " + getFirst().pdfReference(doc) + EOL);
- result.append(" /Last " + getLast().pdfReference(doc) + EOL);
- }
- if (count() > 0) {
- result.append(" /Count " + count() + EOL);
- }
- result.append(">> endobj" + EOL);
- return new ByteArray(result);
- }
-
-}
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java 2022-01-29 19:11:03 UTC (rev 12498)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java 2022-01-29 19:26:18 UTC (rev 12499)
@@ -1,219 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-/*
- * Known Constributors:
- * Kelly A. Campbell
- */
-package org.foray.pdf.object;
-
-import org.foray.common.sequence.ByteArray;
-import org.foray.pdf.structure.PdfTextString;
-
-import org.axsl.pdf.PdfDestination;
-import org.axsl.pdf.PdfOutlineItem;
-import org.axsl.pdf.PdfOutlineTarget;
-import org.axsl.utility.sequence.ByteSequencePlus;
-
-import java.awt.Color;
-import java.util.List;
-
-/**
- * An Outline Item Dictionary in PDF.
- */
-
-public class PdfOutlineItem4a extends PdfOutlineParent4a implements PdfOutlineItem {
-
- /** The parent object. */
- private PdfOutlineParent4a parent;
-
- /** The title to display for the bookmark entry. */
- private PdfTextString title;
-
- /**
- * Bit 1 of the flags entry.
- * @see "PDF Reference, 3rd Edition, Table 8.5 and the discussion near it."
- */
- private boolean italic = false;
-
- /**
- * Bit 2 of the flags entry.
- * @see "PDF Reference, 3rd Edition, Table 8.5 and the discussion near it."
- */
- private boolean bold = false;
-
- /** The color for this outline item. */
- private PdfColor4a color = null;
-
- /** The target of this bookmark. */
- private PdfOutlineTarget target;
-
- /**
- * Private constructor to be used only by the public constructors in this class.
- * @param parent The parent outline item.
- * @param title The title or text of the outline item.
- * @param target The target of this outline item.
- * @param color The color of the outline item.
- * @param italic Indicates whether the outline item should be displayed
- * in an italic font.
- * @param bold Indciates whether the outline item should be displayed in a
- * bold font.
- */
- public PdfOutlineItem4a(final PdfOutlineParent4a parent, final String title, final PdfOutlineTarget target,
- final Color color, final boolean italic, final boolean bold) {
- this.parent = parent;
- this.title = new PdfTextString(title);
- this.target = target;
- if (color != null) {
- this.color = new PdfColor4a(color);
- }
- this.italic = italic;
- this.bold = bold;
- }
-
- /**
- * Return the sibling outline items.
- * @return The sibling outline items.
- */
- private List<PdfOutlineItem4a> getSiblings() {
- if (this.parent instanceof PdfOutline4a) {
- return ((PdfOutline4a) this.parent).getChildren();
- }
- if (this.parent instanceof PdfOutlineItem4a) {
- return ((PdfOutlineItem4a) this.parent).getChildren();
- }
- return null;
- }
-
- /**
- * Return the sibling outline item immediately before this one.
- * @return The sibling outline item immediately before this one, or null if there is none.
- */
- private PdfOutlineItem4a getPrevious() {
- final int myIndex = this.parent.getChildren().indexOf(this);
- if (myIndex < 1) {
- return null;
- }
- return this.parent.getChildren().get(myIndex - 1);
- }
-
- /**
- * Return the sibling outline item immediately after this one.
- * @return The sibling outline item immediately after this one, or null if there is none.
- */
- private PdfOutlineItem4a getNext() {
- final int myIndex = this.parent.getChildren().indexOf(this);
- if (myIndex >= getSiblings().size() - 1) {
- return null;
- }
- return this.parent.getChildren().get(myIndex + 1);
- }
-
- @Override
- protected int count() {
- if (getChildren() == null) {
- return 0;
- }
- int descendants = getChildren().size();
- for (int i = 0; i < getChildren().size(); i++) {
- final PdfOutlineItem4a child = getChildren().get(i);
- descendants += child.count();
- }
- return descendants;
- }
-
- /**
- * Computes the flags (unsigned 32-bit integer), as described in PDF
- * Reference, 3rd Edition, near Table 8.5.
- * @return The flags integer.
- */
- protected long flags() {
- long flags = 0;
- if (this.italic) {
- /* BitUtils 1, 2^0. */
- flags += 1;
- }
- if (this.bold) {
- /* BitUtils 2, 2^1. */
- flags += 2;
- }
- return flags;
- }
-
- @Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
- final StringBuilder result = new StringBuilder();
- result.append(this.pdfID() + EOL + "<<" + EOL);
- final int countDescendants = this.count();
- // subentry Outline object
- result.append(" /Title " + this.title.serialize(doc) + EOL);
- result.append(" /Parent " + this.parent.pdfReference(doc) + EOL);
- if (getFirst() != null && getLast() != null) {
- result.append(" /First " + getFirst().pdfReference(doc) + EOL);
- result.append(" /Last " + getLast().pdfReference(doc) + EOL);
- }
- final PdfOutlineItem4a previous = getPrevious();
- if (previous != null) {
- result.append(" /Prev " + previous.pdfReference(doc) + EOL);
- }
- final PdfOutlineItem4a next = getNext();
- if (next != null) {
- result.append(" /Next " + next.pdfReference(doc) + EOL);
- }
- if (countDescendants > 0) {
- result.append(" /Count -" + countDescendants + EOL);
- }
-
- if (this.target instanceof PdfDestination) {
- result.append(" /Dest ");
- if (this.target instanceof PdfDestinationNamed4a) {
- final PdfDestinationNamed4a named = (PdfDestinationNamed4a) this.target;
- result.append(named.serialize(doc));
- } else if (this.target instanceof PdfDestinationExplicit4a) {
- final PdfDestinationExplicit4a explicit = (PdfDestinationExplicit4a) this.target;
- result.append(explicit.serialize(doc));
- }
- result.append(EOL);
- } else if (this.target instanceof PdfAction) {
- final PdfAction action = (PdfAction) this.target;
- result.append(" /A " + action.serialize(doc));
- }
-
- if (this.color != null
- && ! this.color.isBlack()) {
- result.append(" /C " + this.color.serialize(doc) + EOL);
- }
- if (this.flags() != 0) {
- result.append(" /F " + this.flags() + EOL);
- }
- result.append(">> endobj" + EOL);
-
- return new ByteArray(result);
- }
-
-}
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineParent4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineParent4a.java 2022-01-29 19:11:03 UTC (rev 12498)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineParent4a.java 2022-01-29 19:26:18 UTC (rev 12499)
@@ -1,97 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-import org.foray.pdf.type.PdfObject;
-
-import org.axsl.pdf.PdfOutlineParent;
-import org.axsl.pdf.PdfOutlineTarget;
-
-import java.awt.Color;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Abstract superclass for PDFObjects that can be parents of a PdfOutlineItem4a
- * object. This includes the classes PdfOutline and PdfOutlineItem4a.
- */
-
-public abstract class PdfOutlineParent4a extends PdfObject implements PdfOutlineParent {
-
- /** Collection of child PdfOutline objects. */
- private List<PdfOutlineItem4a> children = new ArrayList<PdfOutlineItem4a>();
-
- /**
- * Return the children of this parent.
- * @return The children of this parent.
- */
- public List<PdfOutlineItem4a> getChildren() {
- return this.children;
- }
-
- /**
- * Return the first child of this parent.
- * @return The first child of this parent.
- */
- protected PdfOutlineItem4a getFirst() {
- if (this.children == null
- || this.children.size() < 1) {
- return null;
- }
- return this.children.get(0);
- }
-
- /**
- * Return the last child of this parent.
- * @return The last child of this parent.
- */
- protected PdfOutlineItem4a getLast() {
- if (this.children == null
- || this.children.size() < 1) {
- return null;
- }
- return this.children.get(this.children.size() - 1);
- }
-
- /**
- * Return the total number of descendants.
- * @return The total number of descendants.
- */
- protected abstract int count();
-
- @Override
- public PdfOutlineItem4a createPdfOutlineItem(final String titleText, final PdfOutlineTarget internalDestination,
- final Color color, final boolean italic, final boolean bold) {
- final PdfOutlineItem4a newItem =
- new PdfOutlineItem4a(this, titleText, internalDestination, color, italic, bold);
- this.children.add(newItem);
- return newItem;
- }
-
-}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java 2022-01-29 19:11:03 UTC (rev 12498)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java 2022-01-29 19:26:18 UTC (rev 12499)
@@ -29,6 +29,8 @@
package org.foray.pdf.object;
import org.foray.common.sequence.ByteArray;
+import org.foray.pdf.interact.PdfDestinationExplicit4a;
+import org.foray.pdf.interact.PdfDestinationNamed4a;
import org.foray.pdf.structure.PdfNameTree;
import org.foray.pdf.type.PdfObject;
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPageLabel.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPageLabel.java 2022-01-29 19:11:03 UTC (rev 12498)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPageLabel.java 2022-01-29 19:26:18 UTC (rev 12499)
@@ -1,99 +0,0 @@
-/*
- * Copyright 2007 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-import org.foray.common.sequence.ByteArray;
-import org.foray.pdf.structure.PdfTextString;
-import org.foray.pdf.type.PdfObject;
-
-import org.axsl.pdf.PdfPageLabelStyle;
-import org.axsl.utility.sequence.ByteSequencePlus;
-
-/**
- * A PDF PageLabel Dictionary. See PDF Reference, 3rd Edition, Section 8.3.1.
- */
-public class PdfPageLabel extends PdfObject {
-
- /** The numbering style to be used for the numeric portion of each page
- * label. A null value implies that the numeric portion of the page label
- * will not be displayed. */
- private PdfPageLabelStyle style;
-
- /** The (optional) label prefix for page labels in this range. */
- private PdfTextString labelPrefix;
-
- /** The (optional) value of the numeric portion for the first page label in
- * the range. Subsequent pages will be numbered sequentially from this
- * value. */
- private int startingNumber;
-
- /**
- * Create a PdfPageLabel object.
- * @param doc The parent PDF document.
- * @param style The numbering style to be used for the numeric portion of
- * each page label. If null is passed, there will be no numeric portion in
- * the page label.
- * @param labelPrefix The (optional) label prefix for page labels in this
- * range. If null is passed, there will be no label prefix in the page
- * label.
- * @param startingNumber The (optional) value of the numeric portion for the
- * first page label in the range. Subsequent pages will be numbered
- * sequentially from this value.
- */
- public PdfPageLabel(final PdfDocument4a doc, final PdfPageLabelStyle style,
- final CharSequence labelPrefix, final int startingNumber) {
- this.style = style;
- if (labelPrefix != null
- && ! (labelPrefix.equals(""))) {
- this.labelPrefix = new PdfTextString(labelPrefix);
- }
- this.startingNumber = startingNumber;
- doc.registerIndirectObject(this);
- }
-
- @Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
- final StringBuilder buffer = new StringBuilder();
- buffer.append(this.pdfID() + EOL);
- buffer.append("<< /Type /PageLabel" + EOL);
- if (this.style != null) {
- buffer.append("/S /" + this.style.getPdfName() + EOL);
- }
- if (this.labelPrefix != null) {
- buffer.append("/P " + this.labelPrefix.pdfReference(doc) + EOL);
- }
- if (this.startingNumber > 0) {
- /* Ignore any entries with a value less than 1. */
- buffer.append("/St " + this.startingNumber + EOL);
- }
- buffer.append(">>" + EOL + "endobj" + EOL);
- return new ByteArray(buffer);
- }
-
-}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java 2022-01-29 19:11:03 UTC (rev 12498)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java 2022-01-29 19:26:18 UTC (rev 12499)
@@ -31,7 +31,10 @@
import org.foray.common.primitive.StringUtils;
import org.foray.common.sequence.ByteArray;
import org.foray.pdf.PdfConstants;
+import org.foray.pdf.interact.PdfDestinationNamed4a;
import org.foray.pdf.interact.PdfNamedDestinationsTree4a;
+import org.foray.pdf.interact.PdfOutline4a;
+import org.foray.pdf.interact.PdfPageLabel;
import org.foray.pdf.structure.PdfNameTree;
import org.foray.pdf.structure.PdfNumberTree;
import org.foray.pdf.type.PdfDictionary;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-29 19:11:06
|
Revision: 12498
http://sourceforge.net/p/foray/code/12498
Author: victormote
Date: 2022-01-29 19:11:03 +0000 (Sat, 29 Jan 2022)
Log Message:
-----------
Change PDF serialization scheme from being char-oriented to being byte-oriented.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAnnotList.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfBorderStyle.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCharProcs.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidFont.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidSystemInfo.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfColor4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEncoding.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEncryption4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFileSpec.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFont4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFontDescriptor.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFunction.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoTo.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoToRemote.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfLink.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfObjectReference.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPageLabel.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPages.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPattern.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfResources.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfShading.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfUri.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfDate.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNameTree.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNumberTree.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfTextString.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfArray.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfBoolean.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfDictionary.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfHexString.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfInteger.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfLiteralString.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfName.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfObject.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfReal.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java
trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfDocumentInfo4aTests.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAnnotList.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAnnotList.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAnnotList.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -28,8 +28,11 @@
package org.foray.pdf.object;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.type.PdfObject;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
import java.util.ArrayList;
import java.util.List;
@@ -69,7 +72,7 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
final StringBuilder p = new StringBuilder();
p.append(this.pdfID() + EOL);
p.append("[" + EOL);
@@ -78,7 +81,7 @@
p.append(child.pdfReference(doc) + EOL);
}
p.append("] endobj" + EOL);
- return p.toString();
+ return new ByteArray(p);
}
/*
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfBorderStyle.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfBorderStyle.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfBorderStyle.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -28,8 +28,11 @@
package org.foray.pdf.object;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.type.PdfObject;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
/**
* A PDF Border Style Dictionary. See PDF Reference, 3rd Edition, Section 8.4.3.
*/
@@ -102,7 +105,7 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
final StringBuilder buffer = new StringBuilder();
buffer.append(this.pdfID() + EOL);
buffer.append("<< /Type /Border" + EOL);
@@ -113,7 +116,7 @@
buffer.append("/S " + this.style.getPdfName() + EOL);
}
buffer.append(">>" + EOL + "endobj" + EOL);
- return buffer.toString();
+ return new ByteArray(buffer);
}
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCharProcs.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCharProcs.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCharProcs.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -28,9 +28,12 @@
package org.foray.pdf.object;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.type.PdfObject;
import org.foray.pdf.type.PdfStream;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
import java.util.HashMap;
import java.util.Map;
@@ -65,9 +68,9 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
// TODO: Implement this.
- return new String();
+ return ByteArray.EMPTY;
}
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidFont.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidFont.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidFont.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -33,11 +33,13 @@
package org.foray.pdf.object;
import org.foray.common.primitive.StringUtils;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.type.PdfObject;
import org.foray.pdf.type.PdfStream;
import org.axsl.font.Font;
import org.axsl.font.FontUse;
+import org.axsl.utility.sequence.ByteSequencePlus;
/**
* Class representing a "character identifier" font. See PDF Reference, Second
@@ -121,7 +123,7 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
final Font font = this.fsFont.getFont();
final StringBuilder p = new StringBuilder();
p.append(pdfID() + EOL);
@@ -159,7 +161,7 @@
* array. */
p.append(EOL + ">>" + EOL + "endobj" + EOL);
- return p.toString();
+ return new ByteArray(p);
}
/**
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidSystemInfo.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidSystemInfo.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidSystemInfo.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -33,8 +33,11 @@
package org.foray.pdf.object;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.type.PdfDictionary;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
import java.util.List;
/**
@@ -75,7 +78,7 @@
* the referencing object.
*/
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
final StringBuilder buffer = new StringBuilder();
buffer.setLength(0);
buffer.append("/CIDSystemInfo << /Registry (");
@@ -85,7 +88,7 @@
buffer.append(")/Supplement ");
buffer.append(this.supplement);
buffer.append(" >>");
- return buffer.toString();
+ return new ByteArray(buffer);
}
@Override
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfColor4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfColor4a.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfColor4a.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -29,7 +29,10 @@
package org.foray.pdf.object;
import org.foray.common.ps.PsColor;
+import org.foray.common.sequence.ByteArray;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
import java.awt.Color;
import java.awt.color.ColorSpace;
@@ -66,7 +69,7 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
final StringBuilder buffer = new StringBuilder();
buffer.append("[");
buffer.append(getRed() + " ");
@@ -73,7 +76,7 @@
buffer.append(getGreen() + " ");
buffer.append(getBlue());
buffer.append("]");
- return buffer.toString();
+ return new ByteArray(buffer);
}
@Override
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -34,9 +34,11 @@
package org.foray.pdf.object;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.type.PdfObject;
import org.axsl.pdf.PdfDestinationExplicit;
+import org.axsl.utility.sequence.ByteSequencePlus;
/**
* A PDF Explicit Destination, a destination that points to a specific page / location / view.
@@ -74,7 +76,7 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
final StringBuilder buffer = new StringBuilder();
buffer.append(this.pdfID());
buffer.append(EOL);
@@ -130,7 +132,7 @@
buffer.append("]");
buffer.append(EOL);
buffer.append("endobj" + EOL);
- return buffer.toString();
+ return new ByteArray(buffer);
}
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -32,6 +32,7 @@
import org.foray.pdf.type.PdfObject;
import org.axsl.pdf.PdfDestinationNamed;
+import org.axsl.utility.sequence.ByteSequencePlus;
public class PdfDestinationNamed4a extends PdfObject implements PdfDestinationNamed {
@@ -52,7 +53,7 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
return this.name.serialize(doc);
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEncoding.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEncoding.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEncoding.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -28,10 +28,12 @@
package org.foray.pdf.object;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.type.PdfObject;
import org.axsl.ps.Encoding;
import org.axsl.ps.PsEncoding;
+import org.axsl.utility.sequence.ByteSequencePlus;
/**
* Class representing an /Encoding object.
@@ -82,11 +84,11 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
if (this.encoding.isBuiltInPdf()) {
/* The predefined PDF encodings are present by name. They do not
* need to be written into the document. */
- return new String();
+ return ByteArray.EMPTY;
}
final StringBuilder p = new StringBuilder();
p.append(pdfID() + EOL);
@@ -96,7 +98,7 @@
p.append(">>" + EOL);
p.append("endobj" + EOL);
- return p.toString();
+ return new ByteArray(p);
}
/*
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEncryption4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEncryption4a.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEncryption4a.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -30,9 +30,11 @@
import org.foray.common.WellKnownConstants;
import org.foray.common.primitive.StringUtils;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.type.PdfDictionary;
import org.axsl.pdf.PdfException;
+import org.axsl.utility.sequence.ByteSequencePlus;
import java.io.FilterOutputStream;
import java.io.IOException;
@@ -397,12 +399,12 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
if (this.dictionary == null) {
throw new IllegalStateException("PDF Encryption has not been "
+ "initialized");
}
- return this.dictionary;
+ return new ByteArray(this.dictionary);
}
/**
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFileSpec.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFileSpec.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFileSpec.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -28,8 +28,11 @@
package org.foray.pdf.object;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.type.PdfObject;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
/**
* A File Specification Dictionary.
* @see "PDF Reference, 3rd Edition, Section 3.10.2"
@@ -61,7 +64,7 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
final StringBuilder builder = new StringBuilder();
builder.append(pdfID() + EOL
+ "<<" + EOL
@@ -78,7 +81,7 @@
}
builder.append(">>" + EOL);
builder.append("endobj" + EOL);
- return builder.toString();
+ return new ByteArray(builder);
}
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFont4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFont4a.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFont4a.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -29,6 +29,7 @@
package org.foray.pdf.object;
import org.foray.common.WellKnownConstants;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.structure.PdfRectangle;
import org.foray.pdf.type.PdfArray;
import org.foray.pdf.type.PdfObject;
@@ -40,6 +41,7 @@
import org.axsl.pdf.PdfFont;
import org.axsl.ps.Encoding;
import org.axsl.ps.PsEncoding;
+import org.axsl.utility.sequence.ByteSequencePlus;
/**
* A /Font object in PDF.
@@ -168,7 +170,7 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
final StringBuilder buffer = new StringBuilder();
buffer.append(this.pdfID() + EOL);
buffer.append("<<" + EOL);
@@ -187,7 +189,7 @@
writeDescendantFonts(buffer, doc);
buffer.append(">>" + EOL);
buffer.append("endobj" + EOL);
- return buffer.toString();
+ return new ByteArray(buffer);
}
/**
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFontDescriptor.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFontDescriptor.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFontDescriptor.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -29,11 +29,13 @@
package org.foray.pdf.object;
import org.foray.common.WellKnownConstants;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.structure.PdfRectangle;
import org.foray.pdf.type.PdfObject;
import org.axsl.font.Font;
import org.axsl.pdf.PdfException;
+import org.axsl.utility.sequence.ByteSequencePlus;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
@@ -134,7 +136,7 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
final Font font = this.pdfFont.getFont();
final StringBuilder p = new StringBuilder();
p.append(this.pdfID() + EOL);
@@ -200,7 +202,7 @@
fillInPDF(p, doc);
p.append(EOL + " >>" + EOL + "endobj" + EOL);
- return p.toString();
+ return new ByteArray(p);
}
/**
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFunction.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFunction.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFunction.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -29,8 +29,11 @@
package org.foray.pdf.object;
import org.foray.common.ps.PsUtil;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.type.PdfObject;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
import java.util.List;
/**
@@ -412,7 +415,7 @@
* @return the PDF string.
*/
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
int vectorSize = 0;
int numberOfFunctions = 0;
int tempInt = 0;
@@ -730,7 +733,7 @@
}
- return p.toString();
+ return new ByteArray(p);
}
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoTo.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoTo.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoTo.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -28,6 +28,10 @@
package org.foray.pdf.object;
+import org.foray.common.sequence.ByteArray;
+
+import org.axsl.utility.sequence.ByteSequencePlus;
+
/**
* class representing a /GoTo object.
*
@@ -52,7 +56,7 @@
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
final StringBuilder buffer = new StringBuilder();
buffer.append(this.pdfID() + EOL);
buffer.append("<<" + EOL);
@@ -59,7 +63,7 @@
buffer.append("/S /GoTo" + EOL);
buffer.append("/D " + this.destination.serialize(doc) + ">>" + EOL);
buffer.append("endobj" + EOL);
- return buffer.toString();
+ return new ByteArray(buffer);
}
/*
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoToRemote.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoToRemote.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoToRemote.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -28,6 +28,10 @@
package org.foray.pdf.object;
+import org.foray.common.sequence.ByteArray;
+
+import org.axsl.utility.sequence.ByteSequencePlus;
+
/**
* class representing a /GoToR object.
*/
@@ -79,7 +83,7 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
String p = new String(this.pdfID() + EOL
+ "<<" + EOL + "/S /GoToR" + EOL + "/F "
+ this.pdfFileSpec.pdfReference(doc) + "" + EOL);
@@ -92,7 +96,7 @@
p += EOL + ">>" + EOL + "endobj" + EOL;
- return p;
+ return new ByteArray(p);
}
/*
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfLink.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfLink.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfLink.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -29,8 +29,11 @@
package org.foray.pdf.object;
import org.foray.common.WellKnownConstants;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.structure.PdfTextString;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
import java.awt.geom.Rectangle2D;
/**
@@ -110,7 +113,7 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
final StringBuilder buffer = new StringBuilder();
buffer.append(this.pdfID() + EOL);
buffer.append("<<" + EOL
@@ -144,7 +147,7 @@
buffer.append("/A " + this.action.getAction(doc) + EOL);
}
buffer.append(">>" + EOL + "endobj" + EOL);
- return buffer.toString();
+ return new ByteArray(buffer);
}
/*
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfObjectReference.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfObjectReference.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfObjectReference.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -28,10 +28,12 @@
package org.foray.pdf.object;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.type.PdfInteger;
import org.foray.pdf.type.PdfObject;
import org.axsl.pdf.PdfException;
+import org.axsl.utility.sequence.ByteSequencePlus;
/**
* <p>A reference to an indirect object, also known as a labeled object.
@@ -65,9 +67,8 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
- // TODO Auto-generated method stub
- return null;
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ return ByteArray.EMPTY;
}
@Override
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline4a.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline4a.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -28,8 +28,10 @@
package org.foray.pdf.object;
-import org.foray.common.primitive.StringUtils;
+import org.foray.common.sequence.ByteArray;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
/**
* An Outline dictionary in PDF.
* See PDF Reference 3rd Edition, Section 8.2.2.
@@ -47,9 +49,9 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
if (getChildren().size() < 1) {
- return StringUtils.EMPTY_STRING;
+ return ByteArray.EMPTY;
}
final StringBuilder result = new StringBuilder();
result.append(this.pdfID() + EOL);
@@ -63,7 +65,7 @@
result.append(" /Count " + count() + EOL);
}
result.append(">> endobj" + EOL);
- return result.toString();
+ return new ByteArray(result);
}
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -32,11 +32,13 @@
*/
package org.foray.pdf.object;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.structure.PdfTextString;
import org.axsl.pdf.PdfDestination;
import org.axsl.pdf.PdfOutlineItem;
import org.axsl.pdf.PdfOutlineTarget;
+import org.axsl.utility.sequence.ByteSequencePlus;
import java.awt.Color;
import java.util.List;
@@ -164,7 +166,7 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
final StringBuilder result = new StringBuilder();
result.append(this.pdfID() + EOL + "<<" + EOL);
final int countDescendants = this.count();
@@ -211,7 +213,7 @@
}
result.append(">> endobj" + EOL);
- return result.toString();
+ return new ByteArray(result);
}
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -28,6 +28,7 @@
package org.foray.pdf.object;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.structure.PdfNameTree;
import org.foray.pdf.type.PdfObject;
@@ -35,6 +36,7 @@
import org.axsl.pdf.PdfDestinationExplicit.Coordinates;
import org.axsl.pdf.PdfDestinationExplicit.PositionAndZoom;
import org.axsl.pdf.PdfException;
+import org.axsl.utility.sequence.ByteSequencePlus;
import java.awt.geom.Rectangle2D;
@@ -121,7 +123,7 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
final StringBuilder sb = new StringBuilder();
sb.append(this.pdfID() + EOL
@@ -138,7 +140,7 @@
sb.append(">>" + EOL + "endobj" + EOL);
- return sb.toString();
+ return new ByteArray(sb);
}
/**
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPageLabel.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPageLabel.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPageLabel.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -28,10 +28,12 @@
package org.foray.pdf.object;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.structure.PdfTextString;
import org.foray.pdf.type.PdfObject;
import org.axsl.pdf.PdfPageLabelStyle;
+import org.axsl.utility.sequence.ByteSequencePlus;
/**
* A PDF PageLabel Dictionary. See PDF Reference, 3rd Edition, Section 8.3.1.
@@ -76,7 +78,7 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
final StringBuilder buffer = new StringBuilder();
buffer.append(this.pdfID() + EOL);
buffer.append("<< /Type /PageLabel" + EOL);
@@ -91,7 +93,7 @@
buffer.append("/St " + this.startingNumber + EOL);
}
buffer.append(">>" + EOL + "endobj" + EOL);
- return buffer.toString();
+ return new ByteArray(buffer);
}
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPages.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPages.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPages.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -28,9 +28,11 @@
package org.foray.pdf.object;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.type.PdfObject;
import org.axsl.pdf.PdfPage;
+import org.axsl.utility.sequence.ByteSequencePlus;
import java.util.ArrayList;
import java.util.Collections;
@@ -73,7 +75,7 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
/* TODO: Create a balanced tree here. See the PDF Reference. */
final StringBuilder p = new StringBuilder();
p.append(this.pdfID() + EOL);
@@ -87,7 +89,7 @@
}
p.append("] >>" + EOL + "endobj" + EOL);
- return p.toString();
+ return new ByteArray(p);
}
/**
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPattern.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPattern.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPattern.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -29,7 +29,10 @@
package org.foray.pdf.object;
import org.foray.common.ps.PsUtil;
+import org.foray.common.sequence.ByteArray;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
import java.util.List;
/**
@@ -185,7 +188,7 @@
* @return the PDF string.
*/
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
int vectorSize = 0;
int tempInt = 0;
final StringBuilder p = new StringBuilder();
@@ -283,7 +286,7 @@
p.append("endobj" + EOL);
- return p.toString();
+ return new ByteArray(p);
}
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfResources.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfResources.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfResources.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -28,8 +28,11 @@
package org.foray.pdf.object;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.type.PdfObject;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
import java.util.ArrayList;
import java.util.List;
@@ -86,7 +89,7 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
final StringBuilder p = new StringBuilder();
p.append(this.pdfID() + EOL);
p.append("<<" + EOL);
@@ -147,7 +150,7 @@
p.append(">>" + EOL);
p.append("endobj" + EOL);
- return p.toString();
+ return new ByteArray(p);
}
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -29,6 +29,7 @@
package org.foray.pdf.object;
import org.foray.common.primitive.StringUtils;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.PdfConstants;
import org.foray.pdf.interact.PdfNamedDestinationsTree4a;
import org.foray.pdf.structure.PdfNameTree;
@@ -35,6 +36,8 @@
import org.foray.pdf.structure.PdfNumberTree;
import org.foray.pdf.type.PdfDictionary;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
import java.util.List;
/**
@@ -146,7 +149,7 @@
* @param doc The PDF Document.
* @return The PDF string
*/
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
final StringBuilder p = new StringBuilder();
p.append(this.pdfID() + EOL);
p.append(PdfConstants.OPEN_DICTIONARY + EOL);
@@ -172,7 +175,7 @@
}
p.append(PdfConstants.CLOSE_DICTIONARY + EOL);
p.append("endobj" + EOL);
- return p.toString();
+ return new ByteArray(p);
}
/**
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfShading.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfShading.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfShading.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -29,8 +29,11 @@
package org.foray.pdf.object;
import org.foray.common.ps.PsUtil;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.type.PdfObject;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
import java.awt.color.ColorSpace;
import java.util.List;
@@ -366,7 +369,7 @@
* @return the PDF string.
*/
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
int vectorSize;
int tempInt;
final StringBuilder p = new StringBuilder();
@@ -559,7 +562,7 @@
p.append(">>" + EOL + "endobj" + EOL);
- return p.toString();
+ return new ByteArray(p);
}
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfUri.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfUri.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfUri.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -28,6 +28,8 @@
package org.foray.pdf.object;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
/**
* A PDF Uri link.
*/
@@ -60,7 +62,7 @@
* @return an empty string
*/
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
return null;
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfDate.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfDate.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfDate.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -28,9 +28,12 @@
package org.foray.pdf.structure;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.object.PdfDocument4a;
import org.foray.pdf.type.PdfObject;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -66,9 +69,9 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
if (this.date == null) {
- return new String();
+ return ByteArray.EMPTY;
}
final StringBuilder buffer = new StringBuilder();
buffer.append("(D:");
@@ -83,7 +86,7 @@
PdfDate.TIMEZONE_HOURS_SIZE + PdfDate.TIMEZONE_MINUTES_SIZE));
buffer.append("'");
buffer.append(")");
- return buffer.toString();
+ return new ByteArray(buffer);
}
/**
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNameTree.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNameTree.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNameTree.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -28,9 +28,12 @@
package org.foray.pdf.structure;
+import org.foray.common.sequence.ByteArrayBuilder;
import org.foray.pdf.object.PdfDocument4a;
import org.foray.pdf.type.PdfObject;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
import java.util.SortedMap;
import java.util.TreeMap;
@@ -47,10 +50,10 @@
private SortedMap<String, T> names = new TreeMap<String, T>();
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
/* TODO: This currently handles a tree with only one level. Add the capability here of writing a root node,
* intermediate nodes, and leaf nodes to properly balance the serialized version of the tree for performance. */
- final StringBuilder p = new StringBuilder();
+ final ByteArrayBuilder p = new ByteArrayBuilder();
p.append(this.pdfID() + EOL);
p.append("<<");
p.append(EOL);
@@ -76,7 +79,7 @@
p.append(EOL);
p.append("endobj");
p.append(EOL);
- return p.toString();
+ return p.asPlus();
}
/**
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNumberTree.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNumberTree.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNumberTree.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -28,9 +28,12 @@
package org.foray.pdf.structure;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.object.PdfDocument4a;
import org.foray.pdf.type.PdfObject;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
import java.util.Map;
import java.util.TreeMap;
@@ -46,7 +49,7 @@
private Map<Integer, T> nums = new TreeMap<Integer, T>();
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
final StringBuilder p = new StringBuilder();
p.append(this.pdfID() + EOL);
p.append("<<" + EOL);
@@ -58,7 +61,7 @@
p.append("]" + EOL);
p.append(">>" + EOL);
p.append("endobj" + EOL);
- return p.toString();
+ return new ByteArray(p);
}
/**
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfTextString.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfTextString.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfTextString.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -29,6 +29,7 @@
package org.foray.pdf.structure;
import org.foray.common.WellKnownConstants;
+import org.foray.common.sequence.ByteArray;
import org.foray.common.sequence.ByteSequenceChars;
import org.foray.pdf.object.PdfDocument4a;
import org.foray.pdf.type.PdfLiteralString;
@@ -35,6 +36,7 @@
import org.foray.pdf.type.PdfObject;
import org.axsl.utility.sequence.ByteSequence;
+import org.axsl.utility.sequence.ByteSequencePlus;
/**
* A PDF Text String.
@@ -88,9 +90,9 @@
* PDFDocEncoding).
*/
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
if (this.theSequence == null) {
- return new String();
+ return ByteArray.EMPTY;
}
final StringBuilder buffer = new StringBuilder();
buffer.append("(");
@@ -102,7 +104,7 @@
buffer.append(toPDFUnicode());
}
buffer.append(")");
- return buffer.toString();
+ return new ByteArray(buffer);
}
@Override
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfArray.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfArray.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfArray.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -28,6 +28,7 @@
package org.foray.pdf.type;
+import org.foray.common.sequence.ByteArray;
import org.foray.common.sequence.ByteArrayBuilder;
import org.foray.pdf.PdfConstants;
import org.foray.pdf.object.PdfDocument4a;
@@ -35,6 +36,8 @@
import org.foray.pdf.structure.PdfDate;
import org.foray.pdf.structure.PdfTextString;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
@@ -69,7 +72,7 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
final ByteArrayBuilder builder = new ByteArrayBuilder();
builder.append(PdfConstants.OPEN_ARRAY);
builder.append(PdfObject.EOL);
@@ -82,7 +85,7 @@
builder.append(PdfConstants.CLOSE_ARRAY);
// StringUtils.lineBreakStringBuffer(builder, EOL, getCharsPerLine());
- return builder.toString();
+ return new ByteArray(builder);
}
/**
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfBoolean.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfBoolean.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfBoolean.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -32,6 +32,7 @@
import org.foray.pdf.object.PdfDocument4a;
import org.axsl.utility.sequence.ByteSequence;
+import org.axsl.utility.sequence.ByteSequencePlus;
/**
* A PDF boolean.
@@ -62,8 +63,8 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
- return this.textValue.toString();
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ return new ByteArray(this.textValue);
}
/**
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfDictionary.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfDictionary.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfDictionary.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -29,6 +29,7 @@
package org.foray.pdf.type;
import org.foray.common.primitive.StringUtils;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.PdfConstants;
import org.foray.pdf.object.PdfDocument4a;
import org.foray.pdf.object.PdfObjectReference;
@@ -36,6 +37,8 @@
import org.foray.pdf.structure.PdfDate;
import org.foray.pdf.structure.PdfTextString;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
@@ -89,9 +92,9 @@
public abstract String getDictionaryType();
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
if (isEmpty()) {
- return StringUtils.EMPTY_STRING;
+ return ByteArray.EMPTY;
}
/* Compute the output order. */
@@ -122,8 +125,8 @@
final PdfObject object = get(key);
if (object != null) {
final PdfObjectReference indirectReference = object.getIndirectReference();
- final String asPdf = indirectReference == null ? object.serialize(doc) :
- indirectReference.pdfReference();
+ final ByteSequencePlus asPdf = indirectReference == null ? object.serialize(doc) :
+ new ByteArray(indirectReference.pdfReference());
if (asPdf != null
&& ! asPdf.isEmpty()) {
builder.append("/");
@@ -137,7 +140,7 @@
builder.append(PdfConstants.CLOSE_DICTIONARY.toString());
builder.append(EOL);
- return builder.toString();
+ return new ByteArray(builder);
}
private List<String> getRealOutputOrder() {
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfHexString.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfHexString.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfHexString.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -33,6 +33,8 @@
import org.foray.pdf.PdfConstants;
import org.foray.pdf.object.PdfDocument4a;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
/**
* A PDF Hex String.
* @see "PDF Reference, Sixth Edition (PDF version 1.7), Section 3.2.3."
@@ -47,12 +49,12 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
final ByteArrayBuilder builder = new ByteArrayBuilder();
builder.append(PdfConstants.OPEN_STRING_HEX);
builder.append(this.value.toHexByteSequence());
builder.append(PdfConstants.CLOSE_STRING_HEX);
- return builder.toString();
+ return new ByteArray(builder);
}
public ByteArray getValue() {
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfInteger.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfInteger.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfInteger.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -28,8 +28,11 @@
package org.foray.pdf.type;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.object.PdfDocument4a;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
/**
* A Pdf integer.
* @see "PDF Reference, Sixth Edition (PDF version 1.7), Section 3.2.2."
@@ -48,8 +51,8 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
- return Long.toString(this.value);
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ return new ByteArray(Long.toString(this.value));
}
@Override
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfLiteralString.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfLiteralString.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfLiteralString.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -28,6 +28,7 @@
package org.foray.pdf.type;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.object.PdfDocument4a;
import org.foray.pdf.structure.PdfTextString;
@@ -34,6 +35,7 @@
import org.axsl.font.FontContext;
import org.axsl.orthography.Orthography;
import org.axsl.pdf.PdfFont;
+import org.axsl.utility.sequence.ByteSequencePlus;
/**
* A PDF String Object, as defined in PDF Reference, 2nd edition, Section 3.2.3.
@@ -74,8 +76,8 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
- return this.font.textToPdf(this.theString, this.fontContext, this.orthography).toString();
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ return new ByteArray(this.font.textToPdf(this.theString, this.fontContext, this.orthography));
}
/**
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfName.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfName.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfName.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -32,8 +32,11 @@
*/
package org.foray.pdf.type;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.object.PdfDocument4a;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
public class PdfName extends PdfObject {
/** The value of this name. */
@@ -53,8 +56,8 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
- return "/" + this.value;
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ return new ByteArray("/" + this.value);
}
/**
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfObject.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfObject.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfObject.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -33,6 +33,7 @@
import org.foray.pdf.object.PdfObjectReference;
import org.axsl.pdf.PdfException;
+import org.axsl.utility.sequence.ByteSequencePlus;
import java.io.IOException;
import java.io.OutputStream;
@@ -61,17 +62,16 @@
* @throws PdfException For I/O errors during output.
*/
public int output(final OutputStream stream, final PdfDocument4a doc) throws PdfException {
- final String pdf = this.serialize(doc);
+ final ByteSequencePlus pdf = this.serialize(doc);
if (pdf == null) {
return 0;
}
- final byte[] bytes = PdfObject.stringToByteArray(pdf);
try {
- stream.write(bytes);
+ pdf.writeTo(stream);
} catch (final IOException e) {
throw new PdfException(e);
}
- return bytes.length;
+ return pdf.length();
}
public void registerIndirectReference(final PdfObjectReference reference) {
@@ -105,7 +105,7 @@
* @param doc The PDF document, which contains data needed by some objects in it.
* @return The PDF text necessary to represent the object.
*/
- public abstract String serialize(PdfDocument4a doc);
+ public abstract ByteSequencePlus serialize(PdfDocument4a doc);
public PdfObjectReference getIndirectReference() {
return this.reference;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfReal.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfReal.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfReal.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -28,8 +28,11 @@
package org.foray.pdf.type;
+import org.foray.common.sequence.ByteArray;
import org.foray.pdf.object.PdfDocument4a;
+import org.axsl.utility.sequence.ByteSequencePlus;
+
import java.math.BigDecimal;
/**
@@ -48,8 +51,8 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
- return this.value.toPlainString();
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ return new ByteArray(this.value.toPlainString());
}
public BigDecimal getValue() {
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -35,6 +35,7 @@
import org.axsl.ps.PsEncodeFilter;
import org.axsl.ps.PsFilterType;
import org.axsl.utility.sequence.ByteSequence;
+import org.axsl.utility.sequence.ByteSequencePlus;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -232,7 +233,7 @@
}
@Override
- public String serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize(final PdfDocument4a doc) {
throw new RuntimeException();
}
Modified: trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfDocumentInfo4aTests.java
===================================================================
--- trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfDocumentInfo4aTests.java 2022-01-29 18:45:15 UTC (rev 12497)
+++ trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfDocumentInfo4aTests.java 2022-01-29 19:11:03 UTC (rev 12498)
@@ -28,7 +28,10 @@
package org.foray.pdf.object;
+import org.foray.common.sequence.ByteArray;
+
import org.axsl.pdf.PdfDocumentTrapped;
+import org.axsl.utility.sequence.ByteSequencePlus;
import org.junit.Assert;
import org.junit.Before;
@@ -80,7 +83,7 @@
out.setAuthor("Sir Arthur Conan Doyle");
out.setTitle("The Hound of the Baskervilles");
- final String actual = out.serialize(null);
+ final ByteSequencePlus actual = out.serialize(null);
final String expected =
"<< /Type /Info\n" +
"/Title (The Hound of the Baskervilles)\n" +
@@ -94,7 +97,7 @@
"/Trapped (Unknown)\n" +
">>\n";
- Assert.assertEquals(expected, actual);
+ Assert.assertEquals(new ByteArray(expected), actual);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-29 18:45:18
|
Revision: 12497
http://sourceforge.net/p/foray/code/12497
Author: victormote
Date: 2022-01-29 18:45:15 +0000 (Sat, 29 Jan 2022)
Log Message:
-----------
Conform to aXSL change: Add isEmpty() method to the Plus version of each sequence.
Modified Paths:
--------------
trunk/foray/foray-common/src/main/java/org/foray/common/sequence/AbstractByteSequence.java
trunk/foray/foray-common/src/main/java/org/foray/common/sequence/AbstractCharSequence.java
trunk/foray/foray-common/src/main/java/org/foray/common/sequence/AbstractIntSequence.java
trunk/foray/foray-common/src/main/java/org/foray/common/sequence/AbstractLongSequence.java
trunk/foray/foray-common/src/main/java/org/foray/common/sequence/AbstractShortSequence.java
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/sequence/AbstractByteSequence.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/sequence/AbstractByteSequence.java 2022-01-29 17:17:38 UTC (rev 12496)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/sequence/AbstractByteSequence.java 2022-01-29 18:45:15 UTC (rev 12497)
@@ -678,4 +678,9 @@
return byteAt(length() - 1);
}
+ @Override
+ public boolean isEmpty() {
+ return this.length() < 1;
+ }
+
}
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/sequence/AbstractCharSequence.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/sequence/AbstractCharSequence.java 2022-01-29 17:17:38 UTC (rev 12496)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/sequence/AbstractCharSequence.java 2022-01-29 18:45:15 UTC (rev 12497)
@@ -101,4 +101,9 @@
return charAt(length() - 1);
}
+ @Override
+ public boolean isEmpty() {
+ return this.length() < 1;
+ }
+
}
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/sequence/AbstractIntSequence.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/sequence/AbstractIntSequence.java 2022-01-29 17:17:38 UTC (rev 12496)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/sequence/AbstractIntSequence.java 2022-01-29 18:45:15 UTC (rev 12497)
@@ -101,4 +101,9 @@
return intAt(length() - 1);
}
+ @Override
+ public boolean isEmpty() {
+ return this.length() < 1;
+ }
+
}
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/sequence/AbstractLongSequence.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/sequence/AbstractLongSequence.java 2022-01-29 17:17:38 UTC (rev 12496)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/sequence/AbstractLongSequence.java 2022-01-29 18:45:15 UTC (rev 12497)
@@ -101,4 +101,9 @@
return longAt(length() - 1);
}
+ @Override
+ public boolean isEmpty() {
+ return this.length() < 1;
+ }
+
}
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/sequence/AbstractShortSequence.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/sequence/AbstractShortSequence.java 2022-01-29 17:17:38 UTC (rev 12496)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/sequence/AbstractShortSequence.java 2022-01-29 18:45:15 UTC (rev 12497)
@@ -118,4 +118,9 @@
return shortAt(length() - 1);
}
+ @Override
+ public boolean isEmpty() {
+ return this.length() < 1;
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-29 17:17:41
|
Revision: 12496
http://sourceforge.net/p/foray/code/12496
Author: victormote
Date: 2022-01-29 17:17:38 +0000 (Sat, 29 Jan 2022)
Log Message:
-----------
Rename "toPDF" method to "serialize," for clarity.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAnnotList.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfBorderStyle.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCharProcs.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidFont.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidSystemInfo.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfColor4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEncoding.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEncryption4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFileSpec.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFont4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFontDescriptor.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFunction.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoTo.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoToRemote.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfLink.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfObjectReference.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPageLabel.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPages.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPattern.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfResources.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfShading.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfUri.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfDate.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNameTree.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNumberTree.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfTextString.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfArray.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfBoolean.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfDictionary.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfHexString.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfInteger.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfLiteralString.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfName.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfObject.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfReal.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java
trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfArrayTests.java
trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfDocumentInfo4aTests.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAnnotList.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAnnotList.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAnnotList.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -69,7 +69,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
final StringBuilder p = new StringBuilder();
p.append(this.pdfID() + EOL);
p.append("[" + EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfBorderStyle.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfBorderStyle.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfBorderStyle.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -102,7 +102,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
final StringBuilder buffer = new StringBuilder();
buffer.append(this.pdfID() + EOL);
buffer.append("<< /Type /Border" + EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCharProcs.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCharProcs.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCharProcs.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -65,7 +65,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
// TODO: Implement this.
return new String();
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidFont.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidFont.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidFont.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -121,7 +121,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
final Font font = this.fsFont.getFont();
final StringBuilder p = new StringBuilder();
p.append(pdfID() + EOL);
@@ -135,7 +135,7 @@
p.append(EOL + "/Subtype /");
p.append(this.subType.getPdfName());
p.append(EOL);
- p.append(this.systemInfo.toPDF(doc));
+ p.append(this.systemInfo.serialize(doc));
p.append(EOL + "/FontDescriptor ");
p.append(this.descriptor.pdfReference(doc));
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidSystemInfo.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidSystemInfo.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidSystemInfo.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -75,7 +75,7 @@
* the referencing object.
*/
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
final StringBuilder buffer = new StringBuilder();
buffer.setLength(0);
buffer.append("/CIDSystemInfo << /Registry (");
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfColor4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfColor4a.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfColor4a.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -66,7 +66,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
final StringBuilder buffer = new StringBuilder();
buffer.append("[");
buffer.append(getRed() + " ");
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -74,7 +74,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
final StringBuilder buffer = new StringBuilder();
buffer.append(this.pdfID());
buffer.append(EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -52,8 +52,8 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
- return this.name.toPDF(doc);
+ public String serialize(final PdfDocument4a doc) {
+ return this.name.serialize(doc);
}
/**
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -333,7 +333,7 @@
/* Write the trailer. */
final ByteArrayBuilder builder = new ByteArrayBuilder();
builder.append("trailer" + PdfObject.EOL);
- builder.append(getTrailer().toPDF(this));
+ builder.append(getTrailer().serialize(this));
builder.append("startxref");
builder.append(PdfObject.EOL);
builder.append(Long.toString(xrefPosition));
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEncoding.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEncoding.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEncoding.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -82,7 +82,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
if (this.encoding.isBuiltInPdf()) {
/* The predefined PDF encodings are present by name. They do not
* need to be written into the document. */
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEncryption4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEncryption4a.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEncryption4a.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -397,7 +397,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
if (this.dictionary == null) {
throw new IllegalStateException("PDF Encryption has not been "
+ "initialized");
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFileSpec.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFileSpec.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFileSpec.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -61,7 +61,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
final StringBuilder builder = new StringBuilder();
builder.append(pdfID() + EOL
+ "<<" + EOL
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFont4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFont4a.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFont4a.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -168,7 +168,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
final StringBuilder buffer = new StringBuilder();
buffer.append(this.pdfID() + EOL);
buffer.append("<<" + EOL);
@@ -254,7 +254,7 @@
widthArray.addElement(aShort);
}
buffer.append("/Widths ");
- buffer.append(widthArray.toPDF(doc));
+ buffer.append(widthArray.serialize(doc));
buffer.append(EOL);
}
@@ -324,7 +324,7 @@
final PdfArray fontMatrix = new PdfArray();
if (fontMatrix != null) {
buffer.append("/FontMatrix ");
- buffer.append(fontMatrix.toPDF(doc));
+ buffer.append(fontMatrix.serialize(doc));
buffer.append(EOL);
}
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFontDescriptor.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFontDescriptor.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFontDescriptor.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -134,7 +134,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
final Font font = this.pdfFont.getFont();
final StringBuilder p = new StringBuilder();
p.append(this.pdfID() + EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFunction.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFunction.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFunction.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -412,7 +412,7 @@
* @return the PDF string.
*/
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
int vectorSize = 0;
int numberOfFunctions = 0;
int tempInt = 0;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoTo.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoTo.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoTo.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -52,12 +52,12 @@
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
final StringBuilder buffer = new StringBuilder();
buffer.append(this.pdfID() + EOL);
buffer.append("<<" + EOL);
buffer.append("/S /GoTo" + EOL);
- buffer.append("/D " + this.destination.toPDF(doc) + ">>" + EOL);
+ buffer.append("/D " + this.destination.serialize(doc) + ">>" + EOL);
buffer.append("endobj" + EOL);
return buffer.toString();
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoToRemote.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoToRemote.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoToRemote.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -79,7 +79,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
String p = new String(this.pdfID() + EOL
+ "<<" + EOL + "/S /GoToR" + EOL + "/F "
+ this.pdfFileSpec.pdfReference(doc) + "" + EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfLink.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfLink.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfLink.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -110,7 +110,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
final StringBuilder buffer = new StringBuilder();
buffer.append(this.pdfID() + EOL);
buffer.append("<<" + EOL
@@ -130,15 +130,15 @@
buffer.append("/BS " + doc.getDefaultBorderStyle()
.pdfReference(doc) + EOL);
if (this.color != null && ! this.color.isBlack()) {
- buffer.append("/C " + this.color.toPDF(doc) + EOL);
+ buffer.append("/C " + this.color.serialize(doc) + EOL);
}
if (this.destinationName != null
&& this.destinationName.length() > 0) {
// If there is a named destination, use that ...
- buffer.append("/Dest " + this.destinationName.toPDF(doc)
+ buffer.append("/Dest " + this.destinationName.serialize(doc)
+ EOL);
} else if (this.destination != null) {
- buffer.append("/Dest " + this.destination.toPDF(doc));
+ buffer.append("/Dest " + this.destination.serialize(doc));
} else if (this.action != null) {
// ... otherwise, use the Action.
buffer.append("/A " + this.action.getAction(doc) + EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfObjectReference.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfObjectReference.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfObjectReference.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -65,7 +65,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
// TODO Auto-generated method stub
return null;
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline4a.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline4a.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -47,7 +47,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
if (getChildren().size() < 1) {
return StringUtils.EMPTY_STRING;
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -164,12 +164,12 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
final StringBuilder result = new StringBuilder();
result.append(this.pdfID() + EOL + "<<" + EOL);
final int countDescendants = this.count();
// subentry Outline object
- result.append(" /Title " + this.title.toPDF(doc) + EOL);
+ result.append(" /Title " + this.title.serialize(doc) + EOL);
result.append(" /Parent " + this.parent.pdfReference(doc) + EOL);
if (getFirst() != null && getLast() != null) {
result.append(" /First " + getFirst().pdfReference(doc) + EOL);
@@ -191,20 +191,20 @@
result.append(" /Dest ");
if (this.target instanceof PdfDestinationNamed4a) {
final PdfDestinationNamed4a named = (PdfDestinationNamed4a) this.target;
- result.append(named.toPDF(doc));
+ result.append(named.serialize(doc));
} else if (this.target instanceof PdfDestinationExplicit4a) {
final PdfDestinationExplicit4a explicit = (PdfDestinationExplicit4a) this.target;
- result.append(explicit.toPDF(doc));
+ result.append(explicit.serialize(doc));
}
result.append(EOL);
} else if (this.target instanceof PdfAction) {
final PdfAction action = (PdfAction) this.target;
- result.append(" /A " + action.toPDF(doc));
+ result.append(" /A " + action.serialize(doc));
}
if (this.color != null
&& ! this.color.isBlack()) {
- result.append(" /C " + this.color.toPDF(doc) + EOL);
+ result.append(" /C " + this.color.serialize(doc) + EOL);
}
if (this.flags() != 0) {
result.append(" /F " + this.flags() + EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -121,7 +121,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
final StringBuilder sb = new StringBuilder();
sb.append(this.pdfID() + EOL
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPageLabel.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPageLabel.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPageLabel.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -76,7 +76,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
final StringBuilder buffer = new StringBuilder();
buffer.append(this.pdfID() + EOL);
buffer.append("<< /Type /PageLabel" + EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPages.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPages.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPages.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -73,7 +73,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
/* TODO: Create a balanced tree here. See the PDF Reference. */
final StringBuilder p = new StringBuilder();
p.append(this.pdfID() + EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPattern.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPattern.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPattern.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -185,7 +185,7 @@
* @return the PDF string.
*/
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
int vectorSize = 0;
int tempInt = 0;
final StringBuilder p = new StringBuilder();
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfResources.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfResources.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfResources.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -86,7 +86,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
final StringBuilder p = new StringBuilder();
p.append(this.pdfID() + EOL);
p.append("<<" + EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -146,7 +146,7 @@
* @param doc The PDF Document.
* @return The PDF string
*/
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
final StringBuilder p = new StringBuilder();
p.append(this.pdfID() + EOL);
p.append(PdfConstants.OPEN_DICTIONARY + EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfShading.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfShading.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfShading.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -366,7 +366,7 @@
* @return the PDF string.
*/
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
int vectorSize;
int tempInt;
final StringBuilder p = new StringBuilder();
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfUri.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfUri.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfUri.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -60,7 +60,7 @@
* @return an empty string
*/
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
return null;
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfDate.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfDate.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfDate.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -66,7 +66,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
if (this.date == null) {
return new String();
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNameTree.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNameTree.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNameTree.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -47,7 +47,7 @@
private SortedMap<String, T> names = new TreeMap<String, T>();
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
/* TODO: This currently handles a tree with only one level. Add the capability here of writing a root node,
* intermediate nodes, and leaf nodes to properly balance the serialized version of the tree for performance. */
final StringBuilder p = new StringBuilder();
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNumberTree.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNumberTree.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNumberTree.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -46,7 +46,7 @@
private Map<Integer, T> nums = new TreeMap<Integer, T>();
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
final StringBuilder p = new StringBuilder();
p.append(this.pdfID() + EOL);
p.append("<<" + EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfTextString.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfTextString.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfTextString.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -88,7 +88,7 @@
* PDFDocEncoding).
*/
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
if (this.theSequence == null) {
return new String();
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfArray.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfArray.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfArray.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -69,7 +69,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
final ByteArrayBuilder builder = new ByteArrayBuilder();
builder.append(PdfConstants.OPEN_ARRAY);
builder.append(PdfObject.EOL);
@@ -76,7 +76,7 @@
for (int index = 0; index < this.arrayContents.size(); index ++) {
final PdfObject pdfObject = this.arrayContents.get(index);
- builder.append(pdfObject.toPDF(doc));
+ builder.append(pdfObject.serialize(doc));
builder.append(PdfObject.EOL);
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfBoolean.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfBoolean.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfBoolean.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -62,7 +62,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
return this.textValue.toString();
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfDictionary.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfDictionary.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfDictionary.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -89,7 +89,7 @@
public abstract String getDictionaryType();
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
if (isEmpty()) {
return StringUtils.EMPTY_STRING;
}
@@ -122,7 +122,8 @@
final PdfObject object = get(key);
if (object != null) {
final PdfObjectReference indirectReference = object.getIndirectReference();
- final String asPdf = indirectReference == null ? object.toPDF(doc) : indirectReference.pdfReference();
+ final String asPdf = indirectReference == null ? object.serialize(doc) :
+ indirectReference.pdfReference();
if (asPdf != null
&& ! asPdf.isEmpty()) {
builder.append("/");
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfHexString.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfHexString.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfHexString.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -47,7 +47,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
final ByteArrayBuilder builder = new ByteArrayBuilder();
builder.append(PdfConstants.OPEN_STRING_HEX);
builder.append(this.value.toHexByteSequence());
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfInteger.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfInteger.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfInteger.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -48,7 +48,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
return Long.toString(this.value);
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfLiteralString.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfLiteralString.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfLiteralString.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -74,7 +74,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
return this.font.textToPdf(this.theString, this.fontContext, this.orthography).toString();
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfName.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfName.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfName.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -53,7 +53,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
return "/" + this.value;
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfObject.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfObject.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfObject.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -61,7 +61,7 @@
* @throws PdfException For I/O errors during output.
*/
public int output(final OutputStream stream, final PdfDocument4a doc) throws PdfException {
- final String pdf = this.toPDF(doc);
+ final String pdf = this.serialize(doc);
if (pdf == null) {
return 0;
}
@@ -101,11 +101,11 @@
}
/**
- * Generates the PDF text necessary to represent the object, returning it as a String.
- * @param doc The PDF document, which contains data needed by som objects in it.
+ * Returns this object in its serialized form, i.e. the content that should be written to a PDF file.
+ * @param doc The PDF document, which contains data needed by some objects in it.
* @return The PDF text necessary to represent the object.
*/
- public abstract String toPDF(PdfDocument4a doc);
+ public abstract String serialize(PdfDocument4a doc);
public PdfObjectReference getIndirectReference() {
return this.reference;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfReal.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfReal.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfReal.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -48,7 +48,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
return this.value.toPlainString();
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -232,7 +232,7 @@
}
@Override
- public String toPDF(final PdfDocument4a doc) {
+ public String serialize(final PdfDocument4a doc) {
throw new RuntimeException();
}
Modified: trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfArrayTests.java
===================================================================
--- trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfArrayTests.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfArrayTests.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -56,7 +56,7 @@
out.addElement(new PdfTextString("Ralph"));
out.addElement(new PdfName("SomeName"));
- final ByteArray actual = new ByteArray(out.toPDF(null));
+ final ByteArray actual = new ByteArray(out.serialize(null));
final ByteArray expected = new ByteArray("[\n549\n3.14\nfalse\n(Ralph)\n/SomeName\n]");
Assert.assertEquals(expected, actual);
Modified: trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfDocumentInfo4aTests.java
===================================================================
--- trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfDocumentInfo4aTests.java 2022-01-29 16:34:40 UTC (rev 12495)
+++ trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfDocumentInfo4aTests.java 2022-01-29 17:17:38 UTC (rev 12496)
@@ -80,7 +80,7 @@
out.setAuthor("Sir Arthur Conan Doyle");
out.setTitle("The Hound of the Baskervilles");
- final String actual = out.toPDF(null);
+ final String actual = out.serialize(null);
final String expected =
"<< /Type /Info\n" +
"/Title (The Hound of the Baskervilles)\n" +
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-29 16:34:44
|
Revision: 12495
http://sourceforge.net/p/foray/code/12495
Author: victormote
Date: 2022-01-29 16:34:40 +0000 (Sat, 29 Jan 2022)
Log Message:
-----------
Fix output of name trees. Add subclass specific to named destinations.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEmbeddedFileStream.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNameTree.java
Added Paths:
-----------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfNamedDestinationsTree4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/package-info.java
Added: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfNamedDestinationsTree4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfNamedDestinationsTree4a.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfNamedDestinationsTree4a.java 2022-01-29 16:34:40 UTC (rev 12495)
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2022 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf.interact;
+
+import org.foray.pdf.object.PdfDestinationNamed4a;
+import org.foray.pdf.object.PdfDocument4a;
+import org.foray.pdf.structure.PdfNameTree;
+
+public class PdfNamedDestinationsTree4a extends PdfNameTree<PdfDestinationNamed4a> {
+
+ protected String valueToPDF(final PdfDestinationNamed4a value, final PdfDocument4a doc) {
+ return value.getReferencedDestination().pdfReference(doc);
+ }
+
+}
Property changes on: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfNamedDestinationsTree4a.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/package-info.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/package-info.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/package-info.java 2022-01-29 16:34:40 UTC (rev 12495)
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2022 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+/**
+ * Classes representing the PDF interactive features.
+ * @see "PDF Reference, 6th Edition (PDF Version 1.7), Section 8."
+ */
+package org.foray.pdf.interact;
Property changes on: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/package-info.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEmbeddedFileStream.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEmbeddedFileStream.java 2022-01-29 14:29:35 UTC (rev 12494)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEmbeddedFileStream.java 2022-01-29 16:34:40 UTC (rev 12495)
@@ -48,7 +48,7 @@
*/
public PdfEmbeddedFileStream(final PdfDocument4a doc, final String name) {
this.name = name;
- doc.getRoot().getEmbeddedFiles().add(name, this);
+ doc.getRoot().getEmbeddedFiles().put(name, this);
}
/**
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java 2022-01-29 14:29:35 UTC (rev 12494)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java 2022-01-29 16:34:40 UTC (rev 12495)
@@ -212,7 +212,7 @@
if (name != null) {
final PdfDestinationNamed4a namedDestination = new PdfDestinationNamed4a(name, explicitDestination);
- namedDestinations.add(name, namedDestination);
+ namedDestinations.put(name, namedDestination);
return namedDestination;
} else {
return explicitDestination;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java 2022-01-29 14:29:35 UTC (rev 12494)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java 2022-01-29 16:34:40 UTC (rev 12495)
@@ -30,6 +30,7 @@
import org.foray.common.primitive.StringUtils;
import org.foray.pdf.PdfConstants;
+import org.foray.pdf.interact.PdfNamedDestinationsTree4a;
import org.foray.pdf.structure.PdfNameTree;
import org.foray.pdf.structure.PdfNumberTree;
import org.foray.pdf.type.PdfDictionary;
@@ -55,7 +56,7 @@
private PdfOutline4a outline;
/** Collection of named destinations. */
- private PdfNameTree<PdfDestinationNamed4a> destinations;
+ private PdfNamedDestinationsTree4a namedDestinations;
/** The embedded files. */
private PdfNameTree<PdfEmbeddedFileStream> embeddedFiles;
@@ -110,10 +111,11 @@
* @return The destinations in this document.
*/
public PdfNameTree<PdfDestinationNamed4a> getNamedDestinations() {
- if (this.destinations == null) {
- this.destinations = new PdfNameTree<PdfDestinationNamed4a>();
+ if (this.namedDestinations == null) {
+ this.namedDestinations = new PdfNamedDestinationsTree4a();
+ this.document.registerIndirectObjectLast(this.namedDestinations);
}
- return this.destinations;
+ return this.namedDestinations;
}
/**
@@ -160,8 +162,8 @@
if (this.hasNameDictionary()) {
p.append(" /Names" + EOL);
p.append(StringUtils.SINGLE_SPACE + PdfConstants.OPEN_DICTIONARY + EOL);
- if (this.destinations != null) {
- p.append(" /Dests " + this.destinations.pdfReference(doc) + EOL);
+ if (this.namedDestinations != null) {
+ p.append(" /Dests " + this.namedDestinations.pdfReference(doc) + EOL);
}
if (this.embeddedFiles != null) {
p.append(" /EmbeddedFiles " + this.embeddedFiles.pdfReference(doc) + EOL);
@@ -178,7 +180,7 @@
* @return True if there is any data requiring a name dictionary.
*/
private boolean hasNameDictionary() {
- if (this.destinations != null) {
+ if (this.namedDestinations != null) {
return true;
}
if (this.embeddedFiles != null) {
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNameTree.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNameTree.java 2022-01-29 14:29:35 UTC (rev 12494)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNameTree.java 2022-01-29 16:34:40 UTC (rev 12495)
@@ -31,34 +31,51 @@
import org.foray.pdf.object.PdfDocument4a;
import org.foray.pdf.type.PdfObject;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
/**
* A PDF Name Tree.
+ * A serialized PDF document might store this tree as a root node, intermediate nodes, and leaf nodes.
+ * Internally, this class stores the tree in the flattened form of a {@link SortedMap}.
* @param <T> The type of value mapped in this name tree.
* @see "PDF Reference, Sixth Edition, (PDF version 1.7) Section 3.8.5."
*/
public class PdfNameTree<T extends PdfObject> extends PdfObject {
- /* TODO: This currently handles a tree with only one level. */
- /** This name tree's map. */
- private Map<String, T> names = new HashMap<String, T>();
+ /** This name tree's internal map. */
+ private SortedMap<String, T> names = new TreeMap<String, T>();
@Override
public String toPDF(final PdfDocument4a doc) {
+ /* TODO: This currently handles a tree with only one level. Add the capability here of writing a root node,
+ * intermediate nodes, and leaf nodes to properly balance the serialized version of the tree for performance. */
final StringBuilder p = new StringBuilder();
p.append(this.pdfID() + EOL);
- p.append("<<" + EOL);
- p.append("/Names [" + EOL);
- for (Map.Entry<String, T> entry : this.names.entrySet()) {
- final PdfObject pdfObject = entry.getValue();
- p.append("(" + entry.getKey() + ") " + pdfObject.pdfReference(doc)
- + EOL);
+ p.append("<<");
+ p.append(EOL);
+ p.append("/Limits [(");
+ p.append(this.names.firstKey());
+ p.append(") (");
+ p.append(this.names.lastKey());
+ p.append(")]");
+ p.append(EOL);
+ p.append("/Names [");
+ p.append(EOL);
+ for (SortedMap.Entry<String, T> entry : this.names.entrySet()) {
+ final T value = entry.getValue();
+ p.append("(");
+ p.append(entry.getKey());
+ p.append(") ");
+ p.append(valueToPDF(value, doc));
+ p.append(EOL);
}
- p.append("]" + EOL);
- p.append(">>" + EOL);
- p.append("endobj" + EOL);
+ p.append("]");
+ p.append(EOL);
+ p.append(">>");
+ p.append(EOL);
+ p.append("endobj");
+ p.append(EOL);
return p.toString();
}
@@ -67,7 +84,7 @@
* @param key The key to be added.
* @param value The value to be added.
*/
- public void add(final String key, final T value) {
+ public void put(final String key, final T value) {
this.names.put(key, value);
}
@@ -80,4 +97,14 @@
return this.names.get(key);
}
+ /**
+ * Provides the PDF content that should be used as the "value" for a given map entry.
+ * @param value The raw value from the internal map.
+ * @param doc The PDF document.
+ * @return The content to be written to the PDF for {@code value}.
+ */
+ protected String valueToPDF(final T value, final PdfDocument4a doc) {
+ return value.pdfReference(doc);
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-29 14:29:38
|
Revision: 12494
http://sourceforge.net/p/foray/code/12494
Author: victormote
Date: 2022-01-29 14:29:35 +0000 (Sat, 29 Jan 2022)
Log Message:
-----------
Move PDF common structures to new package.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfParser.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFont4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFontDescriptor.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfLink.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPageLabel.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfArray.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfDictionary.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfLiteralString.java
trunk/foray/foray-pdf/src/test/java/org/foray/pdf/PdfParserTests.java
trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfArrayTests.java
Added Paths:
-----------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfDate.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNameTree.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNumberTree.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfRectangle.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfTextString.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/package-info.java
Removed Paths:
-------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDate.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfNameTree.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfNumberTree.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRectangle.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfTextString.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfParser.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfParser.java 2022-01-29 13:13:23 UTC (rev 12493)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfParser.java 2022-01-29 14:29:35 UTC (rev 12494)
@@ -37,8 +37,8 @@
import org.foray.pdf.object.PdfGenericDictionary;
import org.foray.pdf.object.PdfGenericStream;
import org.foray.pdf.object.PdfObjectReference;
-import org.foray.pdf.object.PdfTextString;
import org.foray.pdf.object.PdfTrailer;
+import org.foray.pdf.structure.PdfTextString;
import org.foray.pdf.type.PdfArray;
import org.foray.pdf.type.PdfBoolean;
import org.foray.pdf.type.PdfDictionary;
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDate.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDate.java 2022-01-29 13:13:23 UTC (rev 12493)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDate.java 2022-01-29 14:29:35 UTC (rev 12494)
@@ -1,96 +0,0 @@
-/*
- * Copyright 2005 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-import org.foray.pdf.type.PdfObject;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Represents a Date object in PDF. Date is listed as a PDF Data Type in PDF
- * Reference, 3rd Edition, Table 3.22. The Date data type is discussed at
- * Section 3.8.2.
- *
- * <p>Dates are technically PDF strings, probably actually PDF text strings,
- * so it is tempting to make this class a subclass of PdfTextString. However,
- * since the output will always be ASCII characters (as far as we know), there
- * is currently no benefit to doing so.</p>
- */
-public class PdfDate extends PdfObject {
-
- /** The number of chars used to represent the time zone hours in a Java
- * Date. */
- private static final int TIMEZONE_HOURS_SIZE = 3;
-
- /** The number of chars used to represent the time zone minutes in a Java
- * Date. */
- private static final int TIMEZONE_MINUTES_SIZE = 2;
-
- /** The encapsulated Date instance. */
- private Date date;
-
- /**
- * Create a PdfDate instance.
- * @param date The Date to be encapsulated.
- */
- public PdfDate(final Date date) {
- this.date = date;
- }
-
- @Override
- public String toPDF(final PdfDocument4a doc) {
- if (this.date == null) {
- return new String();
- }
- final StringBuilder buffer = new StringBuilder();
- buffer.append("(D:");
- final SimpleDateFormat formatter = new SimpleDateFormat(
- "yyyyMMddHHmmss");
- buffer.append(formatter.format(this.date));
- formatter.applyPattern("Z");
- final String tzOffset = formatter.format(this.date);
- buffer.append(tzOffset.substring(0, PdfDate.TIMEZONE_HOURS_SIZE));
- buffer.append("'");
- buffer.append(tzOffset.substring(PdfDate.TIMEZONE_HOURS_SIZE,
- PdfDate.TIMEZONE_HOURS_SIZE + PdfDate.TIMEZONE_MINUTES_SIZE));
- buffer.append("'");
- buffer.append(")");
- return buffer.toString();
- }
-
- /**
- * Returns the wrapped Date instance.
- * @return The wrapped Date instance.
- */
- public Date getValue() {
- return this.date;
- }
-
-}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java 2022-01-29 13:13:23 UTC (rev 12493)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java 2022-01-29 14:29:35 UTC (rev 12494)
@@ -28,6 +28,7 @@
package org.foray.pdf.object;
+import org.foray.pdf.structure.PdfTextString;
import org.foray.pdf.type.PdfObject;
import org.axsl.pdf.PdfDestinationNamed;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFont4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFont4a.java 2022-01-29 13:13:23 UTC (rev 12493)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFont4a.java 2022-01-29 14:29:35 UTC (rev 12494)
@@ -29,6 +29,7 @@
package org.foray.pdf.object;
import org.foray.common.WellKnownConstants;
+import org.foray.pdf.structure.PdfRectangle;
import org.foray.pdf.type.PdfArray;
import org.foray.pdf.type.PdfObject;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFontDescriptor.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFontDescriptor.java 2022-01-29 13:13:23 UTC (rev 12493)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFontDescriptor.java 2022-01-29 14:29:35 UTC (rev 12494)
@@ -29,6 +29,7 @@
package org.foray.pdf.object;
import org.foray.common.WellKnownConstants;
+import org.foray.pdf.structure.PdfRectangle;
import org.foray.pdf.type.PdfObject;
import org.axsl.font.Font;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfLink.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfLink.java 2022-01-29 13:13:23 UTC (rev 12493)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfLink.java 2022-01-29 14:29:35 UTC (rev 12494)
@@ -29,6 +29,7 @@
package org.foray.pdf.object;
import org.foray.common.WellKnownConstants;
+import org.foray.pdf.structure.PdfTextString;
import java.awt.geom.Rectangle2D;
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfNameTree.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfNameTree.java 2022-01-29 13:13:23 UTC (rev 12493)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfNameTree.java 2022-01-29 14:29:35 UTC (rev 12494)
@@ -1,82 +0,0 @@
-/*
- * Copyright 2006 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-import org.foray.pdf.type.PdfObject;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * A PDF Name Tree.
- * @param <T> The type of value mapped in this name tree.
- * @see "PDF Reference, Sixth Edition, (PDF version 1.7) Section 3.8.5."
- */
-public class PdfNameTree<T extends PdfObject> extends PdfObject {
- /* TODO: This currently handles a tree with only one level. */
-
- /** This name tree's map. */
- private Map<String, T> names = new HashMap<String, T>();
-
- @Override
- public String toPDF(final PdfDocument4a doc) {
- final StringBuilder p = new StringBuilder();
- p.append(this.pdfID() + EOL);
- p.append("<<" + EOL);
- p.append("/Names [" + EOL);
- for (Map.Entry<String, T> entry : this.names.entrySet()) {
- final PdfObject pdfObject = entry.getValue();
- p.append("(" + entry.getKey() + ") " + pdfObject.pdfReference(doc)
- + EOL);
- }
- p.append("]" + EOL);
- p.append(">>" + EOL);
- p.append("endobj" + EOL);
- return p.toString();
- }
-
- /**
- * Add a mapping to this name tree.
- * @param key The key to be added.
- * @param value The value to be added.
- */
- public void add(final String key, final T value) {
- this.names.put(key, value);
- }
-
- /**
- * Returns a mapped item from its key.
- * @param key The key.
- * @return The mapped item, or null if the key does not exist in this tree.
- */
- public T get(final String key) {
- return this.names.get(key);
- }
-
-}
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfNumberTree.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfNumberTree.java 2022-01-29 13:13:23 UTC (rev 12493)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfNumberTree.java 2022-01-29 14:29:35 UTC (rev 12494)
@@ -1,81 +0,0 @@
-/*
- * Copyright 2006 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-import org.foray.pdf.type.PdfObject;
-
-import java.util.Map;
-import java.util.TreeMap;
-
-/**
- * A PDF Number Tree.
- * @param <T> The type of value mapped in this number tree.
- * @see "PDF Reference, Sixth Edition (PDF version 1.7), Section 3.8.6."
- */
-public class PdfNumberTree<T extends PdfObject> extends PdfObject {
- /* TODO: This currently handles a tree with only one level. */
-
- /** This number tree's map. */
- private Map<Integer, T> nums = new TreeMap<Integer, T>();
-
- @Override
- public String toPDF(final PdfDocument4a doc) {
- final StringBuilder p = new StringBuilder();
- p.append(this.pdfID() + EOL);
- p.append("<<" + EOL);
- p.append("/Nums [" + EOL);
- for (Map.Entry<Integer, T> entry : this.nums.entrySet()) {
- final PdfObject pdfObject = entry.getValue();
- p.append(entry.getKey() + " " + pdfObject.pdfReference(doc) + EOL);
- }
- p.append("]" + EOL);
- p.append(">>" + EOL);
- p.append("endobj" + EOL);
- return p.toString();
- }
-
- /**
- * Add a mapping to this number tree.
- * @param key The key to be added.
- * @param value The value to be added.
- */
- public void add(final Integer key, final T value) {
- this.nums.put(key, value);
- }
-
- /**
- * Returns a mapped item from its key.
- * @param key The key.
- * @return The mapped item, or null if the key does not exist in this tree.
- */
- public T get(final Integer key) {
- return this.nums.get(key);
- }
-
-}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java 2022-01-29 13:13:23 UTC (rev 12493)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java 2022-01-29 14:29:35 UTC (rev 12494)
@@ -32,6 +32,8 @@
*/
package org.foray.pdf.object;
+import org.foray.pdf.structure.PdfTextString;
+
import org.axsl.pdf.PdfDestination;
import org.axsl.pdf.PdfOutlineItem;
import org.axsl.pdf.PdfOutlineTarget;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java 2022-01-29 13:13:23 UTC (rev 12493)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java 2022-01-29 14:29:35 UTC (rev 12494)
@@ -28,6 +28,7 @@
package org.foray.pdf.object;
+import org.foray.pdf.structure.PdfNameTree;
import org.foray.pdf.type.PdfObject;
import org.axsl.pdf.PdfDestination;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPageLabel.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPageLabel.java 2022-01-29 13:13:23 UTC (rev 12493)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPageLabel.java 2022-01-29 14:29:35 UTC (rev 12494)
@@ -28,6 +28,7 @@
package org.foray.pdf.object;
+import org.foray.pdf.structure.PdfTextString;
import org.foray.pdf.type.PdfObject;
import org.axsl.pdf.PdfPageLabelStyle;
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRectangle.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRectangle.java 2022-01-29 13:13:23 UTC (rev 12493)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRectangle.java 2022-01-29 14:29:35 UTC (rev 12494)
@@ -1,116 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-import org.axsl.ps.BoundingBox;
-
-import java.io.UnsupportedEncodingException;
-
-/**
- * A PDF rectangle.
- * @see "PDF Reference, 6th Edition (PDF Version 1.7), Section 3.8.4."
- */
-public class PdfRectangle {
-
- /** Lower left x coordinate. */
- private int llx;
-
- /** Lower left y coordinate. */
- private int lly;
-
- /** Upper right x coordinate. */
- private int urx;
-
- /** Upper right y coordinate. */
- private int ury;
-
- /**
- * Create a rectangle from its coordinates.
- * @param llx Lower left x coordinate.
- * @param lly Lower left y coordinate.
- * @param urx Upper right x coordinate.
- * @param ury Upper right y coordinate.
- */
- public PdfRectangle(final int llx, final int lly, final int urx,
- final int ury) {
- this.llx = llx;
- this.lly = lly;
- this.urx = urx;
- this.ury = ury;
- }
-
- /**
- * Create a rectangle from an array of four values.
- * @param array values in the order llx, lly, urx, ury
- */
- public PdfRectangle(final int[] array) {
- int index = 0;
- this.llx = array[index];
- index ++;
- this.lly = array[index];
- index ++;
- this.urx = array[index];
- index ++;
- this.ury = array[index];
- }
-
- /**
- * Create a rectangle from a bounding box.
- * @param bBox A bounding box.
- */
- public PdfRectangle(final BoundingBox bBox) {
- this.llx = bBox.getCoordinateAsInt(BoundingBox.LOWER_LEFT_X_INDEX);
- this.lly = bBox.getCoordinateAsInt(BoundingBox.LOWER_LEFT_Y_INDEX);
- this.urx = bBox.getCoordinateAsInt(BoundingBox.UPPER_RIGHT_X_INDEX);
- this.ury = bBox.getCoordinateAsInt(BoundingBox.UPPER_RIGHT_Y_INDEX);
- }
-
- /**
- * Produce the PDF representation for the object.
- * @return the PDF
- */
- public byte[] toPDF() {
- try {
- return toPDFString().getBytes(PdfDocument4a.ENCODING);
- } catch (final UnsupportedEncodingException ue) {
- return toPDFString().getBytes();
- }
- }
-
- /**
- * Returns the description of the rectangle suitable for embedding in the
- * PDF document.
- * @return The rectangle description, for PDF.
- */
- public String toPDFString() {
- return new String(" [" + this.llx + " " + this.lly + " "
- + this.urx + " " + this.ury + "] ");
- }
-
-}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java 2022-01-29 13:13:23 UTC (rev 12493)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java 2022-01-29 14:29:35 UTC (rev 12494)
@@ -30,6 +30,8 @@
import org.foray.common.primitive.StringUtils;
import org.foray.pdf.PdfConstants;
+import org.foray.pdf.structure.PdfNameTree;
+import org.foray.pdf.structure.PdfNumberTree;
import org.foray.pdf.type.PdfDictionary;
import java.util.List;
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfTextString.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfTextString.java 2022-01-29 13:13:23 UTC (rev 12493)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfTextString.java 2022-01-29 14:29:35 UTC (rev 12494)
@@ -1,208 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-import org.foray.common.WellKnownConstants;
-import org.foray.common.sequence.ByteSequenceChars;
-import org.foray.pdf.type.PdfLiteralString;
-import org.foray.pdf.type.PdfObject;
-
-import org.axsl.utility.sequence.ByteSequence;
-
-/**
- * A PDF Text String.
- * Text-strings are used in such PDF concepts as bookmarks, text annotations, etc., which do not have (or need) control
- * over fonts, layout, etc.
- * For string objects used in PDF content streams, see {@link PdfLiteralString}.
- * @see PdfLiteralString
- * @see "PDF Reference, 2nd Edition (PDF Version 1.3), Section 3.8.1."
- * @see "PDF Reference, 6th Edition (PDF Version 1.7), Section 3.8.1."
- */
-public class PdfTextString extends PdfObject {
-
- /** This char is returned when a Unicode character cannot be encoded using
- * the PDFDocEncoding. */
- public static final char INVALID_PDF_DOC_ENCODING = 0xffff;
-
- /** Constant used to mask the hi-order bits in a multibyte character. */
- private static final int HI_MASK = WellKnownConstants.MAX_8_BIT_UNSIGNED_INT
- << WellKnownConstants.SHIFT_1_BYTE;
-
- /** The encapsulated String. */
- private ByteSequence theSequence;
-
- /**
- * Constructor.
- * @param string The encapsulated String.
- */
- public PdfTextString(final ByteSequence string) {
- this.theSequence = string;
- }
-
- /**
- * Constructor.
- * @param sequence The encapsulated character sequence.
- * @throws NullPointerException If {@code sequence} is null.
- */
- public PdfTextString(final CharSequence sequence) {
- if (sequence == null) {
- throw new NullPointerException("The CharSequence cannot be null.");
- }
- this.theSequence = new ByteSequenceChars(sequence);
- }
-
- /**
- * {@inheritDoc}
- * Convert this.theString to valid content for a PDF String Object.
- * See PDF Reference, 2nd edition, Section 3.2.3 for general information
- * on String objects, including how to add non-ASCII characters.
- * See Section 3.8.1 for information on the Unicode byte markers that must
- * be present for Text Strings that are encoded in Unicode (as opposed to
- * PDFDocEncoding).
- */
- @Override
- public String toPDF(final PdfDocument4a doc) {
- if (this.theSequence == null) {
- return new String();
- }
- final StringBuilder buffer = new StringBuilder();
- buffer.append("(");
- // Since it is more readable, try to use the PDFDocEncoding.
- final String pdfDoc = unicodeToPDFDocEncoding(this.theSequence);
- if (pdfDoc != null) {
- buffer.append(pdfDoc);
- } else {
- buffer.append(toPDFUnicode());
- }
- buffer.append(")");
- return buffer.toString();
- }
-
- @Override
- public String toString() {
- return this.theSequence.toString();
- }
-
- /**
- * Converts the encapsulated String to its PDF Unicode equivalent.
- * @return The PDF Unicode representation of the encapsulated String.
- */
- private String toPDFUnicode() {
- final StringBuilder result = new StringBuilder();
- // byte order marker (0xfeff)
- result.append("\\376\\377");
-
- /* @TODO: Handle different ByteSequence types better. */
- final String theString = this.theSequence.toString();
- for (int i = 0; i < theString.length(); i++) {
- final char ch = theString.charAt(i);
- final int high = (ch & PdfTextString.HI_MASK)
- >>> WellKnownConstants.SHIFT_1_BYTE;
- final int low = ch & WellKnownConstants.MAX_8_BIT_UNSIGNED_INT;
- result.append("\\");
- result.append(Integer.toOctalString(high));
- result.append("\\");
- result.append(Integer.toOctalString(low));
- }
- return result.toString();
- }
-
- /**
- * Converts a String from Unicode to PDFDocEncoding, if possible.
- * @param unicodeSequence The {@link String} to be converted.
- * @return The converted String, or null if unicodeString contains one or
- * more chars that cannot be converted to PDFDocEncoding.
- */
- public static String unicodeToPDFDocEncoding(final ByteSequence unicodeSequence) {
- /* @TODO: Handle different types of ByteSequences better. */
- final String unicodeString = unicodeSequence.toString();
- final StringBuilder pdfDocString = new StringBuilder(unicodeString);
- for (int i = 0; i < unicodeString.length(); i++) {
- final char unicodeChar = unicodeString.charAt(i);
- final char pdfDocChar = unicodeToPDFDocEncoding(unicodeChar);
- if (pdfDocChar == PdfTextString.INVALID_PDF_DOC_ENCODING) {
- return null;
- }
- if (unicodeChar != pdfDocChar) {
- pdfDocString.setCharAt(i, pdfDocChar);
- }
- }
- return pdfDocString.toString();
- }
-
- /**
- * Converts a Unicode character to its PDFDocEncoding equivalent, if
- * possible.
- * @param unicodeChar The Unicode character to be converted.
- * @return The PDFDocEncoding equivalent of #unicodeChar if possible,
- * or #INVALID_PDF_DOC_ENCODING if it cannot be converted.
- */
- public static char unicodeToPDFDocEncoding(final char unicodeChar) {
- /*
- * This may not be right, but I am pretty sure that the ASCII chars
- * are the same.
- */
- if (unicodeChar >= ' '
- && unicodeChar <= WellKnownConstants.MAX_8_BIT_UNSIGNED_INT) {
- return unicodeChar;
- }
- /*
- * TODO: The remaining items are not complete.
- */
- switch (unicodeChar) {
- case '\u00C1': return '\u00C1'; //Aacute
- case '\u00C6': return '\u00C6'; //AE
- }
- return PdfTextString.INVALID_PDF_DOC_ENCODING;
- }
-
- /**
- * Indicates whether this String has any content.
- * @return True if and only if this String has no content.
- */
- public boolean isEmpty() {
- if (this.theSequence == null) {
- return true;
- }
- return this.theSequence.length() < 1;
- }
-
- /**
- * Returns the length of this string.
- * @return The number of bytes in this sequence.
- */
- public int length() {
- return this.theSequence.length();
- }
-
- public ByteSequence getValue() {
- return this.theSequence;
- }
-
-}
Copied: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfDate.java (from rev 12492, trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDate.java)
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfDate.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfDate.java 2022-01-29 14:29:35 UTC (rev 12494)
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2005 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf.structure;
+
+import org.foray.pdf.object.PdfDocument4a;
+import org.foray.pdf.type.PdfObject;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Represents a Date object in PDF. Date is listed as a PDF Data Type in PDF
+ * Reference, 3rd Edition, Table 3.22. The Date data type is discussed at
+ * Section 3.8.2.
+ *
+ * <p>Dates are technically PDF strings, probably actually PDF text strings,
+ * so it is tempting to make this class a subclass of PdfTextString. However,
+ * since the output will always be ASCII characters (as far as we know), there
+ * is currently no benefit to doing so.</p>
+ */
+public class PdfDate extends PdfObject {
+
+ /** The number of chars used to represent the time zone hours in a Java
+ * Date. */
+ private static final int TIMEZONE_HOURS_SIZE = 3;
+
+ /** The number of chars used to represent the time zone minutes in a Java
+ * Date. */
+ private static final int TIMEZONE_MINUTES_SIZE = 2;
+
+ /** The encapsulated Date instance. */
+ private Date date;
+
+ /**
+ * Create a PdfDate instance.
+ * @param date The Date to be encapsulated.
+ */
+ public PdfDate(final Date date) {
+ this.date = date;
+ }
+
+ @Override
+ public String toPDF(final PdfDocument4a doc) {
+ if (this.date == null) {
+ return new String();
+ }
+ final StringBuilder buffer = new StringBuilder();
+ buffer.append("(D:");
+ final SimpleDateFormat formatter = new SimpleDateFormat(
+ "yyyyMMddHHmmss");
+ buffer.append(formatter.format(this.date));
+ formatter.applyPattern("Z");
+ final String tzOffset = formatter.format(this.date);
+ buffer.append(tzOffset.substring(0, PdfDate.TIMEZONE_HOURS_SIZE));
+ buffer.append("'");
+ buffer.append(tzOffset.substring(PdfDate.TIMEZONE_HOURS_SIZE,
+ PdfDate.TIMEZONE_HOURS_SIZE + PdfDate.TIMEZONE_MINUTES_SIZE));
+ buffer.append("'");
+ buffer.append(")");
+ return buffer.toString();
+ }
+
+ /**
+ * Returns the wrapped Date instance.
+ * @return The wrapped Date instance.
+ */
+ public Date getValue() {
+ return this.date;
+ }
+
+}
Copied: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNameTree.java (from rev 12492, trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfNameTree.java)
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNameTree.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNameTree.java 2022-01-29 14:29:35 UTC (rev 12494)
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2006 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf.structure;
+
+import org.foray.pdf.object.PdfDocument4a;
+import org.foray.pdf.type.PdfObject;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A PDF Name Tree.
+ * @param <T> The type of value mapped in this name tree.
+ * @see "PDF Reference, Sixth Edition, (PDF version 1.7) Section 3.8.5."
+ */
+public class PdfNameTree<T extends PdfObject> extends PdfObject {
+ /* TODO: This currently handles a tree with only one level. */
+
+ /** This name tree's map. */
+ private Map<String, T> names = new HashMap<String, T>();
+
+ @Override
+ public String toPDF(final PdfDocument4a doc) {
+ final StringBuilder p = new StringBuilder();
+ p.append(this.pdfID() + EOL);
+ p.append("<<" + EOL);
+ p.append("/Names [" + EOL);
+ for (Map.Entry<String, T> entry : this.names.entrySet()) {
+ final PdfObject pdfObject = entry.getValue();
+ p.append("(" + entry.getKey() + ") " + pdfObject.pdfReference(doc)
+ + EOL);
+ }
+ p.append("]" + EOL);
+ p.append(">>" + EOL);
+ p.append("endobj" + EOL);
+ return p.toString();
+ }
+
+ /**
+ * Add a mapping to this name tree.
+ * @param key The key to be added.
+ * @param value The value to be added.
+ */
+ public void add(final String key, final T value) {
+ this.names.put(key, value);
+ }
+
+ /**
+ * Returns a mapped item from its key.
+ * @param key The key.
+ * @return The mapped item, or null if the key does not exist in this tree.
+ */
+ public T get(final String key) {
+ return this.names.get(key);
+ }
+
+}
Copied: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNumberTree.java (from rev 12492, trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfNumberTree.java)
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNumberTree.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNumberTree.java 2022-01-29 14:29:35 UTC (rev 12494)
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2006 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf.structure;
+
+import org.foray.pdf.object.PdfDocument4a;
+import org.foray.pdf.type.PdfObject;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * A PDF Number Tree.
+ * @param <T> The type of value mapped in this number tree.
+ * @see "PDF Reference, Sixth Edition (PDF version 1.7), Section 3.8.6."
+ */
+public class PdfNumberTree<T extends PdfObject> extends PdfObject {
+ /* TODO: This currently handles a tree with only one level. */
+
+ /** This number tree's map. */
+ private Map<Integer, T> nums = new TreeMap<Integer, T>();
+
+ @Override
+ public String toPDF(final PdfDocument4a doc) {
+ final StringBuilder p = new StringBuilder();
+ p.append(this.pdfID() + EOL);
+ p.append("<<" + EOL);
+ p.append("/Nums [" + EOL);
+ for (Map.Entry<Integer, T> entry : this.nums.entrySet()) {
+ final PdfObject pdfObject = entry.getValue();
+ p.append(entry.getKey() + " " + pdfObject.pdfReference(doc) + EOL);
+ }
+ p.append("]" + EOL);
+ p.append(">>" + EOL);
+ p.append("endobj" + EOL);
+ return p.toString();
+ }
+
+ /**
+ * Add a mapping to this number tree.
+ * @param key The key to be added.
+ * @param value The value to be added.
+ */
+ public void add(final Integer key, final T value) {
+ this.nums.put(key, value);
+ }
+
+ /**
+ * Returns a mapped item from its key.
+ * @param key The key.
+ * @return The mapped item, or null if the key does not exist in this tree.
+ */
+ public T get(final Integer key) {
+ return this.nums.get(key);
+ }
+
+}
Copied: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfRectangle.java (from rev 12487, trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRectangle.java)
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfRectangle.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfRectangle.java 2022-01-29 14:29:35 UTC (rev 12494)
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf.structure;
+
+import org.foray.pdf.object.PdfDocument4a;
+
+import org.axsl.ps.BoundingBox;
+
+import java.io.UnsupportedEncodingException;
+
+/**
+ * A PDF rectangle.
+ * @see "PDF Reference, 6th Edition (PDF Version 1.7), Section 3.8.4."
+ */
+public class PdfRectangle {
+
+ /** Lower left x coordinate. */
+ private int llx;
+
+ /** Lower left y coordinate. */
+ private int lly;
+
+ /** Upper right x coordinate. */
+ private int urx;
+
+ /** Upper right y coordinate. */
+ private int ury;
+
+ /**
+ * Create a rectangle from its coordinates.
+ * @param llx Lower left x coordinate.
+ * @param lly Lower left y coordinate.
+ * @param urx Upper right x coordinate.
+ * @param ury Upper right y coordinate.
+ */
+ public PdfRectangle(final int llx, final int lly, final int urx,
+ final int ury) {
+ this.llx = llx;
+ this.lly = lly;
+ this.urx = urx;
+ this.ury = ury;
+ }
+
+ /**
+ * Create a rectangle from an array of four values.
+ * @param array values in the order llx, lly, urx, ury
+ */
+ public PdfRectangle(final int[] array) {
+ int index = 0;
+ this.llx = array[index];
+ index ++;
+ this.lly = array[index];
+ index ++;
+ this.urx = array[index];
+ index ++;
+ this.ury = array[index];
+ }
+
+ /**
+ * Create a rectangle from a bounding box.
+ * @param bBox A bounding box.
+ */
+ public PdfRectangle(final BoundingBox bBox) {
+ this.llx = bBox.getCoordinateAsInt(BoundingBox.LOWER_LEFT_X_INDEX);
+ this.lly = bBox.getCoordinateAsInt(BoundingBox.LOWER_LEFT_Y_INDEX);
+ this.urx = bBox.getCoordinateAsInt(BoundingBox.UPPER_RIGHT_X_INDEX);
+ this.ury = bBox.getCoordinateAsInt(BoundingBox.UPPER_RIGHT_Y_INDEX);
+ }
+
+ /**
+ * Produce the PDF representation for the object.
+ * @return the PDF
+ */
+ public byte[] toPDF() {
+ try {
+ return toPDFString().getBytes(PdfDocument4a.ENCODING);
+ } catch (final UnsupportedEncodingException ue) {
+ return toPDFString().getBytes();
+ }
+ }
+
+ /**
+ * Returns the description of the rectangle suitable for embedding in the
+ * PDF document.
+ * @return The rectangle description, for PDF.
+ */
+ public String toPDFString() {
+ return new String(" [" + this.llx + " " + this.lly + " "
+ + this.urx + " " + this.ury + "] ");
+ }
+
+}
Copied: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfTextString.java (from rev 12493, trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfTextString.java)
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfTextString.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfTextString.java 2022-01-29 14:29:35 UTC (rev 12494)
@@ -0,0 +1,209 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf.structure;
+
+import org.foray.common.WellKnownConstants;
+import org.foray.common.sequence.ByteSequenceChars;
+import org.foray.pdf.object.PdfDocument4a;
+import org.foray.pdf.type.PdfLiteralString;
+import org.foray.pdf.type.PdfObject;
+
+import org.axsl.utility.sequence.ByteSequence;
+
+/**
+ * A PDF Text String.
+ * Text-strings are used in such PDF concepts as bookmarks, text annotations, etc., which do not have (or need) control
+ * over fonts, layout, etc.
+ * For string objects used in PDF content streams, see {@link PdfLiteralString}.
+ * @see PdfLiteralString
+ * @see "PDF Reference, 2nd Edition (PDF Version 1.3), Section 3.8.1."
+ * @see "PDF Reference, 6th Edition (PDF Version 1.7), Section 3.8.1."
+ */
+public class PdfTextString extends PdfObject {
+
+ /** This char is returned when a Unicode character cannot be encoded using
+ * the PDFDocEncoding. */
+ public static final char INVALID_PDF_DOC_ENCODING = 0xffff;
+
+ /** Constant used to mask the hi-order bits in a multibyte character. */
+ private static final int HI_MASK = WellKnownConstants.MAX_8_BIT_UNSIGNED_INT
+ << WellKnownConstants.SHIFT_1_BYTE;
+
+ /** The encapsulated String. */
+ private ByteSequence theSequence;
+
+ /**
+ * Constructor.
+ * @param string The encapsulated String.
+ */
+ public PdfTextString(final ByteSequence string) {
+ this.theSequence = string;
+ }
+
+ /**
+ * Constructor.
+ * @param sequence The encapsulated character sequence.
+ * @throws NullPointerException If {@code sequence} is null.
+ */
+ public PdfTextString(final CharSequence sequence) {
+ if (sequence == null) {
+ throw new NullPointerException("The CharSequence cannot be null.");
+ }
+ this.theSequence = new ByteSequenceChars(sequence);
+ }
+
+ /**
+ * {@inheritDoc}
+ * Convert this.theString to valid content for a PDF String Object.
+ * See PDF Reference, 2nd edition, Section 3.2.3 for general information
+ * on String objects, including how to add non-ASCII characters.
+ * See Section 3.8.1 for information on the Unicode byte markers that must
+ * be present for Text Strings that are encoded in Unicode (as opposed to
+ * PDFDocEncoding).
+ */
+ @Override
+ public String toPDF(final PdfDocument4a doc) {
+ if (this.theSequence == null) {
+ return new String();
+ }
+ final StringBuilder buffer = new StringBuilder();
+ buffer.append("(");
+ // Since it is more readable, try to use the PDFDocEncoding.
+ final String pdfDoc = unicodeToPDFDocEncoding(this.theSequence);
+ if (pdfDoc != null) {
+ buffer.append(pdfDoc);
+ } else {
+ buffer.append(toPDFUnicode());
+ }
+ buffer.append(")");
+ return buffer.toString();
+ }
+
+ @Override
+ public String toString() {
+ return this.theSequence.toString();
+ }
+
+ /**
+ * Converts the encapsulated String to its PDF Unicode equivalent.
+ * @return The PDF Unicode representation of the encapsulated String.
+ */
+ private String toPDFUnicode() {
+ final StringBuilder result = new StringBuilder();
+ // byte order marker (0xfeff)
+ result.append("\\376\\377");
+
+ /* @TODO: Handle different ByteSequence types better. */
+ final String theString = this.theSequence.toString();
+ for (int i = 0; i < theString.length(); i++) {
+ final char ch = theString.charAt(i);
+ final int high = (ch & PdfTextString.HI_MASK)
+ >>> WellKnownConstants.SHIFT_1_BYTE;
+ final int low = ch & WellKnownConstants.MAX_8_BIT_UNSIGNED_INT;
+ result.append("\\");
+ result.append(Integer.toOctalString(high));
+ result.append("\\");
+ result.append(Integer.toOctalString(low));
+ }
+ return result.toString();
+ }
+
+ /**
+ * Converts a String from Unicode to PDFDocEncoding, if possible.
+ * @param unicodeSequence The {@link String} to be converted.
+ * @return The converted String, or null if unicodeString contains one or
+ * more chars that cannot be converted to PDFDocEncoding.
+ */
+ public static String unicodeToPDFDocEncoding(final ByteSequence unicodeSequence) {
+ /* @TODO: Handle different types of ByteSequences better. */
+ final String unicodeString = unicodeSequence.toString();
+ final StringBuilder pdfDocString = new StringBuilder(unicodeString);
+ for (int i = 0; i < unicodeString.length(); i++) {
+ final char unicodeChar = unicodeString.charAt(i);
+ final char pdfDocChar = unicodeToPDFDocEncoding(unicodeChar);
+ if (pdfDocChar == PdfTextString.INVALID_PDF_DOC_ENCODING) {
+ return null;
+ }
+ if (unicodeChar != pdfDocChar) {
+ pdfDocString.setCharAt(i, pdfDocChar);
+ }
+ }
+ return pdfDocString.toString();
+ }
+
+ /**
+ * Converts a Unicode character to its PDFDocEncoding equivalent, if
+ * possible.
+ * @param unicodeChar The Unicode character to be converted.
+ * @return The PDFDocEncoding equivalent of #unicodeChar if possible,
+ * or #INVALID_PDF_DOC_ENCODING if it cannot be converted.
+ */
+ public static char unicodeToPDFDocEncoding(final char unicodeChar) {
+ /*
+ * This may not be right, but I am pretty sure that the ASCII chars
+ * are the same.
+ */
+ if (unicodeChar >= ' '
+ && unicodeChar <= WellKnownConstants.MAX_8_BIT_UNSIGNED_INT) {
+ return unicodeChar;
+ }
+ /*
+ * TODO: The remaining items are not complete.
+ */
+ switch (unicodeChar) {
+ case '\u00C1': return '\u00C1'; //Aacute
+ case '\u00C6': return '\u00C6'; //AE
+ }
+ return PdfTextString.INVALID_PDF_DOC_ENCODING;
+ }
+
+ /**
+ * Indicates whether this String has any content.
+ * @return True if and only if this String has no content.
+ */
+ public boolean isEmpty() {
+ if (this.theSequence == null) {
+ return true;
+ }
+ return this.theSequence.length() < 1;
+ }
+
+ /**
+ * Returns the length of this string.
+ * @return The number of bytes in this sequence.
+ */
+ public int length() {
+ return this.theSequence.length();
+ }
+
+ public ByteSequence getValue() {
+ return this.theSequence;
+ }
+
+}
Added: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/package-info.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/package-info.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/package-info.java 2022-01-29 14:29:35 UTC (rev 12494)
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2022 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+/**
+ * Classes representing the PDF common data structures.
+ * @see "PDF Reference, 6th Edition (PDF Version 1.7), Section 3.8."
+ */
+package org.foray.pdf.structure;
Property changes on: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/package-info.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfArray.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfArray.java 2022-01-29 13:13:23 UTC (rev 12493)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfArray.java 2022-01-29 14:29:35 UTC (rev 12494)
@@ -30,10 +30,10 @@
import org.foray.common.sequence.ByteArrayBuilder;
import org.foray.pdf.PdfConstants;
-import org.foray.pdf.object.PdfDate;
import org.foray.pdf.object.PdfDocument4a;
import org.foray.pdf.object.PdfObjectReference;
-import org.foray.pdf.object.PdfTextString;
+import org.foray.pdf.structure.PdfDate;
+import org.foray.pdf.structure.PdfTextString;
import java.math.BigDecimal;
import java.util.ArrayList;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfDictionary.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfDictionary.java 2022-01-29 13:13:23 UTC (rev 12493)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfDictionary.java 2022-01-29 14:29:35 UTC (rev 12494)
@@ -30,11 +30,11 @@
import org.foray.common.primitive.StringUtils;
import org.foray.pdf.PdfConstants;
-import org.foray.pdf.object.PdfDate;
import org.foray.pdf.object.PdfDocument4a;
import org.foray.pdf.object.PdfObjectReference;
-import org.foray.pdf.object.PdfTextString;
import org.foray.pdf.object.PdfTrailer;
+import org.foray.pdf.structure.PdfDate;
+import org.foray.pdf.structure.PdfTextString;
import java.math.BigDecimal;
import java.util.ArrayList;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfLiteralString.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfLiteralString.java 2022-01-29 13:13:23 UTC (rev 12493)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfLiteralString.java 2022-01-29 14:29:35 UTC (rev 12494)
@@ -29,7 +29,7 @@
package org.foray.pdf.type;
import org.foray.pdf.object.PdfDocument4a;
-import org.foray.pdf.object.PdfTextString;
+import org.foray.pdf.structure.PdfTextString;
import org.axsl.font.FontContext;
import org.axsl.orthography.Orthography;
Modified: trunk/foray/foray-pdf/src/test/java/org/foray/pdf/PdfParserTests.java
===================================================================
--- trunk/foray/foray-pdf/src/test/java/org/foray/pdf/PdfParserTests.java 2022-01-29 13:13:23 UTC (rev 12493)
+++ trunk/foray/foray-pdf/src/test/java/org/foray/pdf/PdfParserTests.java 2022-01-29 14:29:35 UTC (rev 12494)
@@ -31,7 +31,7 @@
import org.foray.common.data.ByteSequenceTokenizer;
import org.foray.common.sequence.ByteArray;
import org.foray.pdf.object.PdfObjectReference;
-import org.foray.pdf.object.PdfTextString;
+import org.foray.pdf.structure.PdfTextString;
import org.foray.pdf.type.PdfArray;
import org.foray.pdf.type.PdfDictionary;
import org.foray.pdf.type.PdfHexString;
Modified: trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfArrayTests.java
===================================================================
--- trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfArrayTests.java 2022-01-29 13:13:23 UTC (rev 12493)
+++ trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfArrayTests.java 2022-01-29 14:29:35 UTC (rev 12494)
@@ -29,6 +29,7 @@
package org.foray.pdf.object;
import org.foray.common.sequence.ByteArray;
+import org.foray.pdf.structure.PdfTextString;
import org.foray.pdf.type.PdfArray;
import org.foray.pdf.type.PdfBoolean;
import org.foray.pdf.type.PdfName;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-29 13:13:25
|
Revision: 12493
http://sourceforge.net/p/foray/code/12493
Author: victormote
Date: 2022-01-29 13:13:23 +0000 (Sat, 29 Jan 2022)
Log Message:
-----------
Move and rename the string literal class.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfTextString.java
Added Paths:
-----------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfLiteralString.java
Removed Paths:
-------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfString.java
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfString.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfString.java 2022-01-29 12:40:21 UTC (rev 12492)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfString.java 2022-01-29 13:13:23 UTC (rev 12493)
@@ -1,94 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-import org.foray.pdf.type.PdfObject;
-
-import org.axsl.font.FontContext;
-import org.axsl.orthography.Orthography;
-import org.axsl.pdf.PdfFont;
-
-/**
- * A PDF String Object, as defined in PDF Reference, 2nd edition, Section 3.2.3.
- * PDF string objects are used in content streams, and are specifically
- * distinguished from PDF text strings, which are used for such things as
- * bookmark titles, annotations, etc.
- * @see PdfTextString
- */
-public class PdfString extends PdfObject {
-
- /** The encapsulated String. */
- private String theString;
-
- /** The Font that should be used to render this String. */
- private PdfFont font;
-
- /** The font options, such as ligatures and small-caps that should be used when computing the glyphs for this
- * word. */
- private FontContext fontContext;
-
- /** The orthography that should be used when applying font features like subsitutions. */
- private Orthography orthography;
-
- /**
- * Constructor.
- * @param string The String being encapsulated.
- * @param font The font in which this String should be written.
- * @param fontContext The font options, such as ligatures and small-caps that should be used when computing the
- * glyphs for this word.
- * @param orthography The orthography that should be used when applying font features like subsitutions.
- */
- public PdfString(final String string, final PdfFont font, final FontContext fontContext,
- final Orthography orthography) {
- this.theString = string;
- this.font = font;
- this.fontContext = fontContext;
- this.orthography = orthography;
- }
-
- @Override
- public String toPDF(final PdfDocument4a doc) {
- return this.font.textToPdf(this.theString, this.fontContext, this.orthography).toString();
- }
-
- /**
- * Indicates whether this string has any content or not.
- * @return True if and only if this string has no content.
- */
- public boolean isEmpty() {
- if (this.theString == null) {
- return true;
- }
- if (this.theString.equals("")) {
- return true;
- }
- return false;
- }
-
-}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfTextString.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfTextString.java 2022-01-29 12:40:21 UTC (rev 12492)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfTextString.java 2022-01-29 13:13:23 UTC (rev 12493)
@@ -30,6 +30,7 @@
import org.foray.common.WellKnownConstants;
import org.foray.common.sequence.ByteSequenceChars;
+import org.foray.pdf.type.PdfLiteralString;
import org.foray.pdf.type.PdfObject;
import org.axsl.utility.sequence.ByteSequence;
@@ -38,8 +39,8 @@
* A PDF Text String.
* Text-strings are used in such PDF concepts as bookmarks, text annotations, etc., which do not have (or need) control
* over fonts, layout, etc.
- * For string objects used in PDF content streams, see {@link PdfString}.
- * @see PdfString
+ * For string objects used in PDF content streams, see {@link PdfLiteralString}.
+ * @see PdfLiteralString
* @see "PDF Reference, 2nd Edition (PDF Version 1.3), Section 3.8.1."
* @see "PDF Reference, 6th Edition (PDF Version 1.7), Section 3.8.1."
*/
Copied: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfLiteralString.java (from rev 12492, trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfString.java)
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfLiteralString.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfLiteralString.java 2022-01-29 13:13:23 UTC (rev 12493)
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf.type;
+
+import org.foray.pdf.object.PdfDocument4a;
+import org.foray.pdf.object.PdfTextString;
+
+import org.axsl.font.FontContext;
+import org.axsl.orthography.Orthography;
+import org.axsl.pdf.PdfFont;
+
+/**
+ * A PDF String Object, as defined in PDF Reference, 2nd edition, Section 3.2.3.
+ * PDF string objects are used in content streams, and are specifically
+ * distinguished from PDF text strings, which are used for such things as
+ * bookmark titles, annotations, etc.
+ * @see PdfTextString
+ */
+public class PdfLiteralString extends PdfObject {
+
+ /** The encapsulated String. */
+ private String theString;
+
+ /** The Font that should be used to render this String. */
+ private PdfFont font;
+
+ /** The font options, such as ligatures and small-caps that should be used when computing the glyphs for this
+ * word. */
+ private FontContext fontContext;
+
+ /** The orthography that should be used when applying font features like subsitutions. */
+ private Orthography orthography;
+
+ /**
+ * Constructor.
+ * @param string The String being encapsulated.
+ * @param font The font in which this String should be written.
+ * @param fontContext The font options, such as ligatures and small-caps that should be used when computing the
+ * glyphs for this word.
+ * @param orthography The orthography that should be used when applying font features like subsitutions.
+ */
+ public PdfLiteralString(final String string, final PdfFont font, final FontContext fontContext,
+ final Orthography orthography) {
+ this.theString = string;
+ this.font = font;
+ this.fontContext = fontContext;
+ this.orthography = orthography;
+ }
+
+ @Override
+ public String toPDF(final PdfDocument4a doc) {
+ return this.font.textToPdf(this.theString, this.fontContext, this.orthography).toString();
+ }
+
+ /**
+ * Indicates whether this string has any content or not.
+ * @return True if and only if this string has no content.
+ */
+ public boolean isEmpty() {
+ if (this.theString == null) {
+ return true;
+ }
+ if (this.theString.equals("")) {
+ return true;
+ }
+ return false;
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-29 12:40:24
|
Revision: 12492
http://sourceforge.net/p/foray/code/12492
Author: victormote
Date: 2022-01-29 12:40:21 +0000 (Sat, 29 Jan 2022)
Log Message:
-----------
Move classes for basic object types to new package.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfCrossRefEntry.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfCrossRefInfo.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfHeader.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfParser.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAction.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAnnotList.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAnnotation.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfBorderStyle.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCharProcs.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidFont.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidFontDescriptor.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidSystemInfo.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCmap.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfContentStream4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDate.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocumentInfo4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEmbeddedFileStream.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEncoding.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEncryption4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFileSpec.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFont4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFontDescriptor.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFontFileStream.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFunction.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGenericDictionary.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGenericStream.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfIccStream.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfNameTree.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfNumberTree.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfObjectReference.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineParent4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPageLabel.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPages.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPathPaint.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfResources.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfShading.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfString.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfTextString.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfTrailer.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfXobject4a.java
trunk/foray/foray-pdf/src/test/java/org/foray/pdf/PdfParserTests.java
trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfArrayTests.java
Added Paths:
-----------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfArray.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfBoolean.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfDictionary.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfHexString.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfInteger.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfName.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfNumeric.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfObject.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfReal.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/package-info.java
Removed Paths:
-------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfArray.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfBoolean.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDictionary.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfHexString.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfInteger.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfName.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfNumeric.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfObject.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfReal.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfStream.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfCrossRefEntry.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfCrossRefEntry.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfCrossRefEntry.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -28,7 +28,7 @@
package org.foray.pdf;
-import org.foray.pdf.object.PdfObject;
+import org.foray.pdf.type.PdfObject;
import org.axsl.utility.sequence.ByteSequencePlus;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfCrossRefInfo.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfCrossRefInfo.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfCrossRefInfo.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -31,7 +31,7 @@
import org.foray.common.primitive.StringUtils;
import org.foray.common.sequence.ByteArrayBuilder;
import org.foray.common.sequence.IntArrayBuilder;
-import org.foray.pdf.object.PdfObject;
+import org.foray.pdf.type.PdfObject;
import org.axsl.utility.sequence.IntPrimitiveIterator;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfHeader.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfHeader.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfHeader.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -30,7 +30,7 @@
import org.foray.common.sequence.ByteArray;
import org.foray.common.sequence.ByteArrayBuilder;
-import org.foray.pdf.object.PdfObject;
+import org.foray.pdf.type.PdfObject;
import org.axsl.pdf.PdfVersion;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfParser.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfParser.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfParser.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -33,20 +33,20 @@
import org.foray.common.sequence.ByteArray;
import org.foray.common.sequence.ByteArrayBuilder;
import org.foray.common.sequence.ByteSequenceSubset;
-import org.foray.pdf.object.PdfArray;
-import org.foray.pdf.object.PdfBoolean;
-import org.foray.pdf.object.PdfDictionary;
import org.foray.pdf.object.PdfDocument4a;
import org.foray.pdf.object.PdfGenericDictionary;
import org.foray.pdf.object.PdfGenericStream;
-import org.foray.pdf.object.PdfHexString;
-import org.foray.pdf.object.PdfInteger;
-import org.foray.pdf.object.PdfName;
-import org.foray.pdf.object.PdfObject;
import org.foray.pdf.object.PdfObjectReference;
-import org.foray.pdf.object.PdfReal;
import org.foray.pdf.object.PdfTextString;
import org.foray.pdf.object.PdfTrailer;
+import org.foray.pdf.type.PdfArray;
+import org.foray.pdf.type.PdfBoolean;
+import org.foray.pdf.type.PdfDictionary;
+import org.foray.pdf.type.PdfHexString;
+import org.foray.pdf.type.PdfInteger;
+import org.foray.pdf.type.PdfName;
+import org.foray.pdf.type.PdfObject;
+import org.foray.pdf.type.PdfReal;
import org.axsl.pdf.PdfException;
import org.axsl.pdf.PdfVersion;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAction.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAction.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAction.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -28,6 +28,8 @@
package org.foray.pdf.object;
+import org.foray.pdf.type.PdfObject;
+
/**
* An action object.
*/
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAnnotList.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAnnotList.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAnnotList.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -28,6 +28,8 @@
package org.foray.pdf.object;
+import org.foray.pdf.type.PdfObject;
+
import java.util.ArrayList;
import java.util.List;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAnnotation.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAnnotation.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAnnotation.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -28,6 +28,8 @@
package org.foray.pdf.object;
+import org.foray.pdf.type.PdfObject;
+
import java.awt.geom.Rectangle2D;
/**
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfArray.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfArray.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfArray.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -1,233 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-import org.foray.common.sequence.ByteArrayBuilder;
-import org.foray.pdf.PdfConstants;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-/**
- * A PDF array object.
- */
-public class PdfArray extends PdfObject {
-
- /** The contents of the array. */
- private List<PdfObject> arrayContents = new ArrayList<PdfObject>();
-
- public void addElement(final PdfObject newElement) {
- this.arrayContents.add(newElement);
- }
-
- public void addElement(final int anInteger) {
- final PdfInteger newElement = new PdfInteger(anInteger);
- addElement(newElement);
- }
-
- public void addElement(final BigDecimal aReal) {
- final PdfReal newElement = new PdfReal(aReal);
- addElement(newElement);
- }
-
- public void ensureMinimumSize(final int minimumSize) {
- while (this.arrayContents.size() < minimumSize) {
- addElement((PdfObject) null);
- }
- }
-
- @Override
- public String toPDF(final PdfDocument4a doc) {
- final ByteArrayBuilder builder = new ByteArrayBuilder();
- builder.append(PdfConstants.OPEN_ARRAY);
- builder.append(PdfObject.EOL);
-
- for (int index = 0; index < this.arrayContents.size(); index ++) {
- final PdfObject pdfObject = this.arrayContents.get(index);
- builder.append(pdfObject.toPDF(doc));
- builder.append(PdfObject.EOL);
- }
-
- builder.append(PdfConstants.CLOSE_ARRAY);
-// StringUtils.lineBreakStringBuffer(builder, EOL, getCharsPerLine());
- return builder.toString();
- }
-
- /**
- * Returns the number of elements in this array.
- * @return The number of elements.
- */
- public int size() {
- return this.arrayContents.size();
- }
-
- /**
- * Sets the value of a specific element in this array.
- * @param index The index to the element to be set.
- * @param object The object to be placed at {@code index}.
- */
- public void set(final int index, final PdfObject object) {
- this.arrayContents.set(index, object);
- }
-
- public PdfObject get(final int index) {
- return this.arrayContents.get(index);
- }
-
- public PdfTextString getPdfTextString(final int index) {
- final PdfObject value = get(index);
- if (value == null) {
- return null;
- }
- if (value instanceof PdfTextString) {
- return (PdfTextString) value;
- }
- throw new IllegalArgumentException(String.format(
- "Element for key \"{0}\" is of type {1}", index, value.getClass().getName()));
- }
-
- public String getString(final int index) {
- final PdfTextString value = getPdfTextString(index);
- return value == null ? null : value.toString();
- }
-
- public PdfHexString getPdfHexString(final int index) {
- final PdfObject value = get(index);
- if (value == null) {
- return null;
- }
- if (value instanceof PdfHexString) {
- return (PdfHexString) value;
- }
- throw new IllegalArgumentException(String.format(
- "Element for key \"{0}\" is of type {1}", index, value.getClass().getName()));
- }
-
- public PdfInteger getPdfInteger(final int index) {
- final PdfObject value = get(index);
- if (value == null) {
- return null;
- }
- if (value instanceof PdfInteger) {
- return (PdfInteger) value;
- }
- throw new IllegalArgumentException(String.format(
- "Element for key \"{0}\" is of type {1}", index, value.getClass().getName()));
- }
-
- public int getInteger(final int index) {
- final PdfInteger value = getPdfInteger(index);
- return value == null ? null : value.getValue();
- }
-
- public PdfReal getPdfReal(final int index) {
- final PdfObject value = get(index);
- if (value == null) {
- return null;
- }
- if (value instanceof PdfReal) {
- return (PdfReal) value;
- }
- throw new IllegalArgumentException(String.format(
- "Element for key \"{0}\" is of type {1}", index, value.getClass().getName()));
- }
-
- public BigDecimal getBigDecimal(final int index) {
- final PdfReal value = getPdfReal(index);
- return value == null ? null : value.getValue();
- }
-
- public PdfDate getPdfDate(final int index) {
- final PdfObject value = get(index);
- if (value == null) {
- return null;
- }
- if (value instanceof PdfDate) {
- return (PdfDate) value;
- }
- throw new IllegalArgumentException(String.format(
- "Element for key \"{0}\" is of type {1}", index, value.getClass().getName()));
- }
-
- public Date getDate(final int index) {
- final PdfDate value = getPdfDate(index);
- return value == null ? null : value.getValue();
- }
-
- public PdfDictionary getPdfDictionary(final int index) {
- final PdfObject value = get(index);
- if (value == null) {
- return null;
- }
- if (value instanceof PdfDictionary) {
- return (PdfDictionary) value;
- }
- throw new IllegalArgumentException(String.format(
- "Element for key \"{0}\" is of type {1}", index, value.getClass().getName()));
- }
-
- public PdfName getPdfName(final int index) {
- final PdfObject value = get(index);
- if (value == null) {
- return null;
- }
- if (value instanceof PdfName) {
- return (PdfName) value;
- }
- throw new IllegalArgumentException(String.format(
- "Element for key \"{0}\" is of type {1}", index, value.getClass().getName()));
- }
-
- public PdfObjectReference getPdfObjectReference(final int index) {
- final PdfObject value = get(index);
- if (value == null) {
- return null;
- }
- if (value instanceof PdfObjectReference) {
- return (PdfObjectReference) value;
- }
- throw new IllegalArgumentException(String.format(
- "Element for key \"{0}\" is of type {1}", index, value.getClass().getName()));
- }
-
- public PdfArray getPdfArray(final int index) {
- final PdfObject value = get(index);
- if (value == null) {
- return null;
- }
- if (value instanceof PdfArray) {
- return (PdfArray) value;
- }
- throw new IllegalArgumentException(String.format(
- "Element for key \"{0}\" is of type {1}", index, value.getClass().getName()));
- }
-
-}
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfBoolean.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfBoolean.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfBoolean.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -1,91 +0,0 @@
-/*
- * Copyright 2020 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-import org.foray.common.sequence.ByteArray;
-
-import org.axsl.utility.sequence.ByteSequence;
-
-/**
- * A PDF boolean.
- * @see "PDF Reference, Sixth Edition (PDF version 1.7), Section 3.2.1."
- */
-public final class PdfBoolean extends PdfObject {
-
- /** Instance representing the boolean "true". */
- public static final PdfBoolean TRUE = new PdfBoolean(true, new ByteArray("true"));
-
- /** Instance representing the boolean "false". */
- public static final PdfBoolean FALSE = new PdfBoolean(false, new ByteArray("false"));
-
- /** The boolean value for this instance. */
- private boolean value;
-
- /** The text value for this instance. */
- private ByteArray textValue;
-
- /**
- * Private constructor. Use static variables to obtain an instance.
- * @param value The boolean value.
- * @param textValue The text value.
- */
- private PdfBoolean(final boolean value, final ByteArray textValue) {
- this.value = value;
- this.textValue = textValue;
- }
-
- @Override
- public String toPDF(final PdfDocument4a doc) {
- return this.textValue.toString();
- }
-
- /**
- * Returns the instance whose text value matches a given token.
- * @param token The value to be matched.
- * @return The instance of the enumeration matching {@code token}, or null if none is found.
- */
- public static PdfBoolean parse(final ByteSequence token) {
- if (PdfBoolean.TRUE.textValue.equals(token)) {
- return PdfBoolean.TRUE;
- }
- if (PdfBoolean.FALSE.textValue.equals(token)) {
- return PdfBoolean.FALSE;
- }
- return null;
- }
-
- public boolean getValue() {
- return this.value;
- }
-
- public ByteArray getTextValue() {
- return this.textValue;
- }
-
-}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfBorderStyle.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfBorderStyle.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfBorderStyle.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -28,6 +28,8 @@
package org.foray.pdf.object;
+import org.foray.pdf.type.PdfObject;
+
/**
* A PDF Border Style Dictionary. See PDF Reference, 3rd Edition, Section 8.4.3.
*/
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCharProcs.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCharProcs.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCharProcs.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -28,6 +28,9 @@
package org.foray.pdf.object;
+import org.foray.pdf.type.PdfObject;
+import org.foray.pdf.type.PdfStream;
+
import java.util.HashMap;
import java.util.Map;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidFont.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidFont.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidFont.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -33,6 +33,8 @@
package org.foray.pdf.object;
import org.foray.common.primitive.StringUtils;
+import org.foray.pdf.type.PdfObject;
+import org.foray.pdf.type.PdfStream;
import org.axsl.font.Font;
import org.axsl.font.FontUse;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidFontDescriptor.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidFontDescriptor.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidFontDescriptor.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -28,6 +28,8 @@
package org.foray.pdf.object;
+import org.foray.pdf.type.PdfStream;
+
// based on work by Takayuki Takeuchi
/**
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidSystemInfo.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidSystemInfo.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCidSystemInfo.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -33,6 +33,8 @@
package org.foray.pdf.object;
+import org.foray.pdf.type.PdfDictionary;
+
import java.util.List;
/**
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCmap.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCmap.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfCmap.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -29,6 +29,7 @@
package org.foray.pdf.object;
import org.foray.common.WellKnownConstants;
+import org.foray.pdf.type.PdfStream;
import org.axsl.pdf.PdfException;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfContentStream4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfContentStream4a.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfContentStream4a.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -30,6 +30,7 @@
import org.foray.common.WellKnownConstants;
import org.foray.pdf.PdfGraphicsState4a;
+import org.foray.pdf.type.PdfStream;
import org.axsl.font.FontConsumer;
import org.axsl.font.FontContext;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDate.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDate.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDate.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -28,6 +28,8 @@
package org.foray.pdf.object;
+import org.foray.pdf.type.PdfObject;
+
import java.text.SimpleDateFormat;
import java.util.Date;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -34,6 +34,8 @@
package org.foray.pdf.object;
+import org.foray.pdf.type.PdfObject;
+
import org.axsl.pdf.PdfDestinationExplicit;
/**
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -28,6 +28,8 @@
package org.foray.pdf.object;
+import org.foray.pdf.type.PdfObject;
+
import org.axsl.pdf.PdfDestinationNamed;
public class PdfDestinationNamed4a extends PdfObject implements PdfDestinationNamed {
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDictionary.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDictionary.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDictionary.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -1,344 +0,0 @@
-/*
- * Copyright 2020 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-import org.foray.common.primitive.StringUtils;
-import org.foray.pdf.PdfConstants;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-public abstract class PdfDictionary extends PdfObject {
-
- /** Internal map of the dictionary. */
- private Map<String, PdfObject> entries = new HashMap<String, PdfObject>();
- /* TODO: The key to this map should technically be a PdfName. However, this seems unimportant at the
- * moment. Find out whether that is necessary, and either document that it is not, or change the type. */
-
- /**
- * The specified output order for entries in this dictionary.
- * If not null, this list will be used.
- * Otherwise, the list in {@link #getOutputOrder()} will be used.
- */
- private List<String> outputOrder;
-
- /**
- * Public no-args constructor.
- */
- public PdfDictionary() { }
-
- /**
- * Constructor allowing subclasses to remake themselves as a different subclass.
- * @param existing The existing {@link PdfDictionary} whose contents will be pushed into the new instance.
- */
- protected PdfDictionary(final PdfDictionary existing) {
- this.entries = existing.entries;
- this.outputOrder = existing.outputOrder;
- }
-
- /**
- * Returns the keys to this dictionary in the order in which they should be output when the PDF is serialized.
- * If null, the output order is undefined.
- * The entries in a PDF Dictionary are inherently unordered.
- * However, some downstream uses, such as testing, may benefit from specifying an order.
- * Also, in some cases, there is an aesthetic benefit to ordered output.
- * @return The keys to this dictionary, in output order.
- */
- public abstract List<String> getOutputOrder();
-
- /**
- * Returns the /Type of this dictionary.
- * @return The type of this dictionary.
- */
- public abstract String getDictionaryType();
-
- @Override
- public String toPDF(final PdfDocument4a doc) {
- if (isEmpty()) {
- return StringUtils.EMPTY_STRING;
- }
-
- /* Compute the output order. */
- final Set<String> keys = this.entries.keySet();
- final List<String> specifiedOutputOrder = getRealOutputOrder();
- final List<String> actualOutputOrder;
- if (specifiedOutputOrder == null) {
- actualOutputOrder = new ArrayList<String>(keys);
- } else {
- actualOutputOrder = new ArrayList<String>(specifiedOutputOrder);
- for (String key : keys) {
- if (! actualOutputOrder.contains(key)) {
- actualOutputOrder.add(key);
- }
- }
- }
-
- final StringBuilder builder = new StringBuilder();
- builder.append(PdfConstants.OPEN_DICTIONARY.toString());
- if (getDictionaryType() != null
- && getDictionaryType().length() > 0) {
- builder.append(" /Type /");
- builder.append(getDictionaryType());
- }
- builder.append(EOL);
-
- for (String key : actualOutputOrder) {
- final PdfObject object = get(key);
- if (object != null) {
- final PdfObjectReference indirectReference = object.getIndirectReference();
- final String asPdf = indirectReference == null ? object.toPDF(doc) : indirectReference.pdfReference();
- if (asPdf != null
- && ! asPdf.isEmpty()) {
- builder.append("/");
- builder.append(key);
- builder.append(StringUtils.SINGLE_SPACE);
- builder.append(asPdf);
- builder.append(EOL);
- }
- }
- }
-
- builder.append(PdfConstants.CLOSE_DICTIONARY.toString());
- builder.append(EOL);
- return builder.toString();
- }
-
- private List<String> getRealOutputOrder() {
- return this.outputOrder == null ? getOutputOrder() : this.outputOrder;
- }
-
- boolean isEmpty() {
- return this.entries.isEmpty();
- }
-
- public void put(final String key, final PdfObject value) {
- this.entries.put(key, value);
- }
-
- /**
- * Puts a "string" entry in the dictionary.
- * @param key The key.
- * @param value The "string" value.
- * @throws NullPointerException If {@code value} is null.
- */
- public void put(final String key, final String value) {
- if (value == null) {
- throw new NullPointerException("The value cannot be null.");
- }
- final PdfTextString textString = new PdfTextString(value);
- put(key, textString);
- }
-
- public void put(final String key, final int value) {
- final PdfInteger integer = new PdfInteger(value);
- put(key, integer);
- }
-
- public void put(final String key, final BigDecimal value) {
- final PdfReal integer = new PdfReal(value);
- put(key, integer);
- }
-
- public void put(final String key, final Date value) {
- final PdfDate date = new PdfDate(value);
- put(key, date);
- }
-
- /**
- * Returns the number of key/value entries in this dictionary.
- * @return The number of entries.
- */
- public int size() {
- return this.entries.size();
- }
-
- public PdfObject get(final String key) {
- return this.entries.get(key);
- }
-
- public PdfTextString getPdfTextString(final String key) {
- final PdfObject value = get(key);
- if (value == null) {
- return null;
- }
- if (value instanceof PdfTextString) {
- return (PdfTextString) value;
- }
- throw new IllegalArgumentException(String.format(
- "Element for key \"{0}\" is of type {1}", key, value.getClass().getName()));
- }
-
- public String getString(final String key) {
- final PdfTextString value = getPdfTextString(key);
- return value == null ? null : value.toString();
- }
-
- public PdfHexString getPdfHexString(final String key) {
- final PdfObject value = get(key);
- if (value == null) {
- return null;
- }
- if (value instanceof PdfHexString) {
- return (PdfHexString) value;
- }
- throw new IllegalArgumentException(String.format(
- "Element for key \"{0}\" is of type {1}", key, value.getClass().getName()));
- }
-
- public PdfInteger getPdfInteger(final String key) {
- final PdfObject value = get(key);
- if (value == null) {
- return null;
- }
- if (value instanceof PdfInteger) {
- return (PdfInteger) value;
- }
- throw new IllegalArgumentException(String.format(
- "Element for key \"{0}\" is of type {1}", key, value.getClass().getName()));
- }
-
- public int getInteger(final String key) {
- final PdfInteger value = getPdfInteger(key);
- return value == null ? null : value.getValue();
- }
-
- public PdfReal getPdfReal(final String key) {
- final PdfObject value = get(key);
- if (value == null) {
- return null;
- }
- if (value instanceof PdfReal) {
- return (PdfReal) value;
- }
- throw new IllegalArgumentException(String.format(
- "Element for key \"{0}\" is of type {1}", key, value.getClass().getName()));
- }
-
- public BigDecimal getBigDecimal(final String key) {
- final PdfReal value = getPdfReal(key);
- return value == null ? null : value.getValue();
- }
-
- public PdfDate getPdfDate(final String key) {
- final PdfObject value = get(key);
- if (value == null) {
- return null;
- }
- if (value instanceof PdfDate) {
- return (PdfDate) value;
- }
- throw new IllegalArgumentException(String.format(
- "Element for key \"{0}\" is of type {1}", key, value.getClass().getName()));
- }
-
- public Date getDate(final String key) {
- final PdfDate value = getPdfDate(key);
- return value == null ? null : value.getValue();
- }
-
- public PdfDictionary getPdfDictionary(final String key) {
- final PdfObject value = get(key);
- if (value == null) {
- return null;
- }
- if (value instanceof PdfDictionary) {
- return (PdfDictionary) value;
- }
- throw new IllegalArgumentException(String.format(
- "Element for key \"{0}\" is of type {1}", key, value.getClass().getName()));
- }
-
- public PdfName getPdfName(final String key) {
- final PdfObject value = get(key);
- if (value == null) {
- return null;
- }
- if (value instanceof PdfName) {
- return (PdfName) value;
- }
- throw new IllegalArgumentException(String.format(
- "Element for key \"{0}\" is of type {1}", key, value.getClass().getName()));
- }
-
- public PdfObjectReference getPdfObjectReference(final String key) {
- final PdfObject value = get(key);
- if (value == null) {
- return null;
- }
- if (value instanceof PdfObjectReference) {
- return (PdfObjectReference) value;
- }
- throw new IllegalArgumentException(String.format(
- "Element for key \"{0}\" is of type {1}", key, value.getClass().getName()));
- }
-
- public PdfArray getPdfArray(final String key) {
- final PdfObject value = get(key);
- if (value == null) {
- return null;
- }
- if (value instanceof PdfArray) {
- return (PdfArray) value;
- }
- throw new IllegalArgumentException(String.format(
- "Element for key \"{0}\" is of type {1}", key, value.getClass().getName()));
- }
-
- /**
- * Ensures that there is a PdfArray as the value for a given key, creating it if necessary.
- * @param key The key for which an array is needed.
- * @return The array.
- */
- public PdfArray ensureArray(final String key) {
- PdfArray value = getPdfArray(key);
- if (value == null) {
- value = new PdfArray();
- this.put(key, value);
- }
- return value;
- }
-
- /**
- * Converts this to an instance of {@link PdfTrailer}.
- * @return If this is an instance of PdfTrailer, returns this, otherwise a new instance of PdfTrailer with this's
- * instance variables.
- */
- public PdfTrailer asPdfTrailer() {
- if (this instanceof PdfTrailer) {
- return (PdfTrailer) this;
- }
- return new PdfTrailer(this);
- }
-
-}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -43,6 +43,7 @@
import org.foray.pdf.PdfCrossRefInfo;
import org.foray.pdf.PdfHeader;
import org.foray.pdf.PdfParser;
+import org.foray.pdf.type.PdfObject;
import org.axsl.font.Font;
import org.axsl.font.FontConsumer;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocumentInfo4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocumentInfo4a.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocumentInfo4a.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -28,6 +28,8 @@
package org.foray.pdf.object;
+import org.foray.pdf.type.PdfDictionary;
+
import org.axsl.pdf.PdfDocumentInfo;
import org.axsl.pdf.PdfDocumentTrapped;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEmbeddedFileStream.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEmbeddedFileStream.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEmbeddedFileStream.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -28,6 +28,7 @@
package org.foray.pdf.object;
+import org.foray.pdf.type.PdfStream;
/**
* Container for a PDF Embedded File Stream. See PDF Reference, 3rd Edition,
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEncoding.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEncoding.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEncoding.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -28,6 +28,8 @@
package org.foray.pdf.object;
+import org.foray.pdf.type.PdfObject;
+
import org.axsl.ps.Encoding;
import org.axsl.ps.PsEncoding;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEncryption4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEncryption4a.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfEncryption4a.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -30,6 +30,7 @@
import org.foray.common.WellKnownConstants;
import org.foray.common.primitive.StringUtils;
+import org.foray.pdf.type.PdfDictionary;
import org.axsl.pdf.PdfException;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFileSpec.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFileSpec.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFileSpec.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -28,6 +28,8 @@
package org.foray.pdf.object;
+import org.foray.pdf.type.PdfObject;
+
/**
* A File Specification Dictionary.
* @see "PDF Reference, 3rd Edition, Section 3.10.2"
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFont4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFont4a.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFont4a.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -29,6 +29,8 @@
package org.foray.pdf.object;
import org.foray.common.WellKnownConstants;
+import org.foray.pdf.type.PdfArray;
+import org.foray.pdf.type.PdfObject;
import org.axsl.font.Font;
import org.axsl.font.FontContext;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFontDescriptor.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFontDescriptor.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFontDescriptor.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -29,6 +29,7 @@
package org.foray.pdf.object;
import org.foray.common.WellKnownConstants;
+import org.foray.pdf.type.PdfObject;
import org.axsl.font.Font;
import org.axsl.pdf.PdfException;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFontFileStream.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFontFileStream.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFontFileStream.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -28,6 +28,8 @@
package org.foray.pdf.object;
+import org.foray.pdf.type.PdfStream;
+
import org.axsl.font.FontUse;
import org.axsl.pdf.PdfException;
import org.axsl.utility.sequence.ByteSequence;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFunction.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFunction.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfFunction.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -29,6 +29,7 @@
package org.foray.pdf.object;
import org.foray.common.ps.PsUtil;
+import org.foray.pdf.type.PdfObject;
import java.util.List;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGenericDictionary.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGenericDictionary.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGenericDictionary.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -29,6 +29,7 @@
package org.foray.pdf.object;
import org.foray.common.primitive.StringUtils;
+import org.foray.pdf.type.PdfDictionary;
import java.util.Collections;
import java.util.List;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGenericStream.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGenericStream.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGenericStream.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -28,6 +28,9 @@
package org.foray.pdf.object;
+import org.foray.pdf.type.PdfDictionary;
+import org.foray.pdf.type.PdfStream;
+
import org.axsl.pdf.PdfException;
import org.axsl.utility.sequence.ByteSequence;
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfHexString.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfHexString.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfHexString.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -1,61 +0,0 @@
-/*
- * Copyright 2020 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-import org.foray.common.sequence.ByteArray;
-import org.foray.common.sequence.ByteArrayBuilder;
-import org.foray.pdf.PdfConstants;
-
-/**
- * A PDF Hex String.
- * @see "PDF Reference, Sixth Edition (PDF version 1.7), Section 3.2.3."
- */
-public class PdfHexString extends PdfObject {
-
- /** The parsed hex string bytes. */
- private ByteArray value;
-
- public PdfHexString(final ByteArray value) {
- this.value = value;
- }
-
- @Override
- public String toPDF(final PdfDocument4a doc) {
- final ByteArrayBuilder builder = new ByteArrayBuilder();
- builder.append(PdfConstants.OPEN_STRING_HEX);
- builder.append(this.value.toHexByteSequence());
- builder.append(PdfConstants.CLOSE_STRING_HEX);
- return builder.toString();
- }
-
- public ByteArray getValue() {
- return this.value;
- }
-
-}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfIccStream.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfIccStream.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfIccStream.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -28,6 +28,8 @@
package org.foray.pdf.object;
+import org.foray.pdf.type.PdfStream;
+
import org.axsl.pdf.PdfException;
import java.awt.color.ICC_ColorSpace;
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfInteger.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfInteger.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfInteger.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -1,58 +0,0 @@
-/*
- * Copyright 2020 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-/**
- * A Pdf integer.
- * @see "PDF Reference, Sixth Edition (PDF version 1.7), Section 3.2.2."
- */
-public class PdfInteger extends PdfNumeric {
-
- /** The integer value. */
- private int value;
-
- public PdfInteger(final int value) {
- this.value = value;
- }
-
- public int getValue() {
- return this.value;
- }
-
- @Override
- public String toPDF(final PdfDocument4a doc) {
- return Long.toString(this.value);
- }
-
- @Override
- public String toString() {
- return Long.toString(this.value);
- }
-
-}
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfName.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfName.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfName.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -1,66 +0,0 @@
-/*
- * Copyright 2020 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-/**
- * A PDF "Name" object.
- * @see "PDF Reference, Sixth Edition (PDF version 1.7), Section 3.2.4."
- */
-package org.foray.pdf.object;
-
-public class PdfName extends PdfObject {
-
- /** The value of this name. */
- private String value;
-
- /**
- * Constructor.
- * @param value The value of this name.
- */
- public PdfName(final String value) {
- this.value = value;
- }
-
- @Override
- public String toString() {
- return "/" + this.value;
- }
-
- @Override
- public String toPDF(final PdfDocument4a doc) {
- return "/" + this.value;
- }
-
- /**
- * Returns the value of this name.
- * @return The value of this name.
- */
- public String getValue() {
- return this.value;
- }
-
-}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfNameTree.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfNameTree.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfNameTree.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -28,6 +28,8 @@
package org.foray.pdf.object;
+import org.foray.pdf.type.PdfObject;
+
import java.util.HashMap;
import java.util.Map;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfNumberTree.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfNumberTree.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfNumberTree.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -28,6 +28,8 @@
package org.foray.pdf.object;
+import org.foray.pdf.type.PdfObject;
+
import java.util.Map;
import java.util.TreeMap;
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfNumeric.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfNumeric.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfNumeric.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -1,33 +0,0 @@
-/*
- * Copyright 2020 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-public abstract class PdfNumeric extends PdfObject {
-
-}
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfObject.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfObject.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfObject.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -1,112 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-import org.foray.pdf.PdfItem;
-
-import org.axsl.pdf.PdfException;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * generic PDF object.
- *
- * A PDF Document is essentially a collection of these objects. A PDF
- * Object has a number and a generation (although the generation will always
- * be 0 in new documents).
- */
-public abstract class PdfObject extends PdfItem {
-
- /** String representation of the Null Object.
- * @see "PDF Reference, 6th Edition (PDF Version 1.7), Section 3.2.8 for discussion of the Null Object." */
- public static final String NULL_OBJECT_VALUE = "null";
-
- /** If not null, this object is an indirectly referenced object. */
- private PdfObjectReference reference;
-
- /**
- * Write the PDF represention of this object to a given output stream.
- * @param stream The stream to which the PDF content is being written.
- * @param doc The PDF document being written.
- * @return The number of bytes written.
- * @throws PdfException For I/O errors during output.
- */
- protected int output(final OutputStream stream, final PdfDocument4a doc) throws PdfException {
- final String pdf = this.toPDF(doc);
- if (pdf == null) {
- return 0;
- }
- final byte[] bytes = PdfObject.stringToByteArray(pdf);
- try {
- stream.write(bytes);
- } catch (final IOException e) {
- throw new PdfException(e);
- }
- return bytes.length;
- }
-
- public void registerIndirectReference(final PdfObjectReference reference) {
- if (this.reference != null) {
- throw new IllegalStateException("Indirect reference already set.");
- }
- this.reference = reference;
- }
-
- /**
- * The String used to reference this object within the PDF.
- * @param doc The PDF Document.
- * @return The String used to reference this object within the PDF.
- */
- public String pdfReference(final PdfDocument4a doc) {
- doc.registerIndirectObject(this);
- return this.reference.pdfReference();
- }
-
- /**
- * The String used to identify this object as it is written in the PDF.
- * @return The String used to identify this object as it is written in the
- * PDF.
- */
- protected String pdfID() {
- return this.reference.pdfID();
- }
-
- /**
- * Generates the PDF text necessary to represent the object, returning it as a String.
- * @param doc The PDF document, which contains data needed by som objects in it.
- * @return The PDF text necessary to represent the object.
- */
- public abstract String toPDF(PdfDocument4a doc);
-
- public PdfObjectReference getIndirectReference() {
- return this.reference;
- }
-
-}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfObjectReference.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfObjectReference.java 2022-01-29 12:08:13 UTC (rev 12491)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfObjectReference.java 2022-01-29 12:40:21 UTC (rev 12492)
@@ -28,6 +28,9 @@
package org.f...
[truncated message content] |
|
From: <vic...@us...> - 2022-01-29 12:08:16
|
Revision: 12491
http://sourceforge.net/p/foray/code/12491
Author: victormote
Date: 2022-01-29 12:08:13 +0000 (Sat, 29 Jan 2022)
Log Message:
-----------
Improvements to PDF parsing timing.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfParser.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java
trunk/foray/foray-pdf/src/test/java/org/foray/pdf/PdfParserTests.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfParser.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfParser.java 2022-01-28 17:18:28 UTC (rev 12490)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfParser.java 2022-01-29 12:08:13 UTC (rev 12491)
@@ -115,9 +115,8 @@
* Constructor for an input stream.
* @param input The input stream to be parsed. This constructor will close the stream after reading it.
* @throws IOException For errors reading the input stream.
- * @throws PdfException For errors parsing the PDF document.
*/
- public PdfParser(final InputStream input) throws IOException, PdfException {
+ public PdfParser(final InputStream input) throws IOException {
this(new ByteArrayBuilder().append(input));
}
@@ -127,15 +126,9 @@
* a {@link ByteSequencePlus} implementation that knows how to transparently expose the file content without doing
* so.
* @param input The byte sequence from which the document should be parsed.
- * @throws PdfException For errors parsing the PDF document.
*/
- public PdfParser(final ByteSequencePlus input) throws PdfException {
+ public PdfParser(final ByteSequencePlus input) {
this.source = input;
- this.pdf = new PdfDocument4a(this);
-
- parseHeader();
- parseTrailer();
- parseIndirectObjects();
}
/**
@@ -144,7 +137,22 @@
*/
PdfParser() { }
- private void parseHeader() throws PdfException {
+ /**
+ * Parses the content of the PDF document.
+ * @return The parsed content of the PDF document.
+ * @throws PdfException For errors during parsing.
+ */
+ public PdfDocument4a parse() throws PdfException {
+ this.pdf = new PdfDocument4a(this);
+ return this.pdf;
+ }
+
+ /**
+ * Parses the header portion of the document.
+ * @return The parsed {@link PdfVersion}.
+ * @throws PdfException If the {@link PdfVersion} is not found.
+ */
+ public PdfVersion parseHeader() throws PdfException {
final String headerLine = source.readCurrentLine(0).toString();
if (! headerLine.startsWith(PdfConstants.DOCUMENT_BEGIN_MARKER.toString())) {
throw new PdfException("PDF Header not found.");
@@ -154,8 +162,7 @@
if (version == null) {
throw new PdfException("PDF Version not found: " + versionString);
}
-
- this.pdf.setVersion(version);
+ return version;
}
/**
@@ -178,6 +185,11 @@
return source.readWord(startxrefIndex + "startxref".length()).parseInt();
}
+ /**
+ * Parses the trailer portion of a PDF document and returns the results.
+ * @return The results of parsing the trailer portion of the PDF document.
+ * @throws PdfException For errors during parsing.
+ */
public PdfTrailer parseTrailer() throws PdfException {
final int trailerIndex = source.lastIndexOf("trailer");
final int trailerDictStart = source.indexOf(PdfConstants.OPEN_DICTIONARY, trailerIndex);
@@ -195,7 +207,11 @@
}
}
- private void parseIndirectObjects() throws PdfException {
+ /**
+ * Parses the indirect objects in the PDF.
+ * @throws PdfException For errors during parsing.
+ */
+ public void parseIndirectObjects() throws PdfException {
final PdfCrossRefInfo xrefs = getXrefs();
ByteSequenceSubset parseArea;
ByteSequenceTokenizer tokenizer;
@@ -482,22 +498,25 @@
return this.pdf;
}
+ /**
+ * Parses the cross-reference table.
+ * @return A new {@link PdfCrossRefInfo} instance containing the parsed cross-reference table.
+ * @throws PdfException For errors finding or parsing the cross-reference table.
+ */
private PdfCrossRefInfo getXrefs() throws PdfException {
- final PdfCrossRefInfo xrefInfo = this.pdf.getCrossRefInfo();
- if (xrefInfo.getTableSize() < 1) {
- final int startXrefOffset = getStartXrefOffset();
- /* The second word on the first line contains the count. */
- final ByteSequencePlus xrefLine = source.readCurrentLine(startXrefOffset);
- int offset = source.findStartOfLine(startXrefOffset + xrefLine.length());
- final ByteSequencePlus xrefCountLine = source.readCurrentLine(offset);
- final int qtyXrefs = xrefCountLine.readWord(0, 2).parseInt();
- offset = source.findStartOfLine(offset + xrefCountLine.length());
+ final PdfCrossRefInfo xrefInfo = new PdfCrossRefInfo();
+ final int startXrefOffset = getStartXrefOffset();
+ /* The second word on the first line contains the count. */
+ final ByteSequencePlus xrefLine = source.readCurrentLine(startXrefOffset);
+ int offset = source.findStartOfLine(startXrefOffset + xrefLine.length());
+ final ByteSequencePlus xrefCountLine = source.readCurrentLine(offset);
+ final int qtyXrefs = xrefCountLine.readWord(0, 2).parseInt();
+ offset = source.findStartOfLine(offset + xrefCountLine.length());
- while (xrefInfo.getTableSize() < qtyXrefs) {
- final PdfCrossRefEntry entry = new PdfCrossRefEntry(source, offset);
- xrefInfo.addTableEntry(entry);
- offset += PdfCrossRefEntry.TOTAL_BYTE_LENGTH;
- }
+ while (xrefInfo.getTableSize() < qtyXrefs) {
+ final PdfCrossRefEntry entry = new PdfCrossRefEntry(source, offset);
+ xrefInfo.addTableEntry(entry);
+ offset += PdfCrossRefEntry.TOTAL_BYTE_LENGTH;
}
return xrefInfo;
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java 2022-01-28 17:18:28 UTC (rev 12490)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java 2022-01-29 12:08:13 UTC (rev 12491)
@@ -189,10 +189,6 @@
* created. */
private PdfTrailer lazyTrailer;
- /** The parser, if any, that is being used to create this document. If this is null, the document is being created
- * manually instead of by parsing. */
- private PdfParser parser;
-
/**
* Constructor which creates an empty PDF document.
* The constructor creates a /Root and /Pages object to track the document
@@ -216,11 +212,15 @@
}
/**
- * Creates an empty PDF document, usually with the expectation of parsing from input.
+ * Creates a PDF document from a parser.
* @param parser The parser to be used to create this document.
+ * @throws PdfException For errors parsing the document.
*/
- public PdfDocument4a(final PdfParser parser) {
- this.parser = parser;
+ public PdfDocument4a(final PdfParser parser) throws PdfException {
+ final PdfVersion pdfVersion = parser.parseHeader();
+ this.lazyTrailer = parser.parseTrailer();
+ parser.parseIndirectObjects();
+ setVersion(pdfVersion);
}
@Override
@@ -784,13 +784,13 @@
throw new UnsupportedOperationException();
}
- public PdfTrailer getTrailer() throws PdfException {
+ /**
+ * Returns the file trailer, creating it if necessary.
+ * @return the file trailer object.
+ */
+ public PdfTrailer getTrailer() {
if (this.lazyTrailer == null) {
- if (this.parser == null) {
- this.lazyTrailer = new PdfTrailer();
- } else {
- this.lazyTrailer = this.parser.parseTrailer();
- }
+ this.lazyTrailer = new PdfTrailer();
}
return this.lazyTrailer;
}
Modified: trunk/foray/foray-pdf/src/test/java/org/foray/pdf/PdfParserTests.java
===================================================================
--- trunk/foray/foray-pdf/src/test/java/org/foray/pdf/PdfParserTests.java 2022-01-28 17:18:28 UTC (rev 12490)
+++ trunk/foray/foray-pdf/src/test/java/org/foray/pdf/PdfParserTests.java 2022-01-29 12:08:13 UTC (rev 12491)
@@ -271,7 +271,7 @@
final String baselineFile = "./src/test/resources/example/002-hello-world.pdf";
final PdfParser out = new PdfParser(new FileInputStream(baselineFile));
- final PdfDictionary trailer = out.getParsedDocument().getTrailer();
+ final PdfDictionary trailer = out.parseTrailer();
Assert.assertEquals(3, trailer.size());
Assert.assertEquals(7, trailer.getInteger("Size"));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-28 17:18:31
|
Revision: 12490
http://sourceforge.net/p/foray/code/12490
Author: victormote
Date: 2022-01-28 17:18:28 +0000 (Fri, 28 Jan 2022)
Log Message:
-----------
Improvements to PDF Outlines and Destinations.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfTextString.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java 2022-01-28 16:16:09 UTC (rev 12489)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java 2022-01-28 17:18:28 UTC (rev 12490)
@@ -33,24 +33,24 @@
public class PdfDestinationNamed4a extends PdfObject implements PdfDestinationNamed {
/** The registered name of this destination. */
- private String name;
+ private PdfTextString name;
/** The explicit destination to which this named destination is attached. */
private PdfDestinationExplicit4a explicitDestination;
public PdfDestinationNamed4a(final String name, final PdfDestinationExplicit4a explicitDestination) {
- this.name = name;
+ this.name = new PdfTextString(name);
this.explicitDestination = explicitDestination;
}
@Override
public String getName() {
- return this.name;
+ return this.name.toString();
}
@Override
public String toPDF(final PdfDocument4a doc) {
- return this.name;
+ return this.name.toPDF(doc);
}
/**
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java 2022-01-28 16:16:09 UTC (rev 12489)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java 2022-01-28 17:18:28 UTC (rev 12490)
@@ -189,7 +189,7 @@
result.append(" /Dest ");
if (this.target instanceof PdfDestinationNamed4a) {
final PdfDestinationNamed4a named = (PdfDestinationNamed4a) this.target;
- result.append(named.getName());
+ result.append(named.toPDF(doc));
} else if (this.target instanceof PdfDestinationExplicit4a) {
final PdfDestinationExplicit4a explicit = (PdfDestinationExplicit4a) this.target;
result.append(explicit.toPDF(doc));
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfTextString.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfTextString.java 2022-01-28 16:16:09 UTC (rev 12489)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfTextString.java 2022-01-28 17:18:28 UTC (rev 12490)
@@ -34,11 +34,13 @@
import org.axsl.utility.sequence.ByteSequence;
/**
- * A PDF Text String, as defined in PDF Reference, 2nd Edition, Section 3.8.1.
- * Text-strings are used in such PDF concepts as bookmarks, text annotations,
- * etc., which do not have control over fonts, layout, etc.
+ * A PDF Text String.
+ * Text-strings are used in such PDF concepts as bookmarks, text annotations, etc., which do not have (or need) control
+ * over fonts, layout, etc.
* For string objects used in PDF content streams, see {@link PdfString}.
* @see PdfString
+ * @see "PDF Reference, 2nd Edition (PDF Version 1.3), Section 3.8.1."
+ * @see "PDF Reference, 6th Edition (PDF Version 1.7), Section 3.8.1."
*/
public class PdfTextString extends PdfObject {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-28 16:16:12
|
Revision: 12489
http://sourceforge.net/p/foray/code/12489
Author: victormote
Date: 2022-01-28 16:16:09 +0000 (Fri, 28 Jan 2022)
Log Message:
-----------
Conform to aXSL changes: Improvements to Destinations and Outlines.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineParent4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java
trunk/foray/foray-render/src/main/java/org/foray/render/Renderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfDestinationCoordinates4a.java
trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java
Added Paths:
-----------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java
Added: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java 2022-01-28 16:16:09 UTC (rev 12489)
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2022 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf.object;
+
+import org.axsl.pdf.PdfDestinationNamed;
+
+public class PdfDestinationNamed4a extends PdfObject implements PdfDestinationNamed {
+
+ /** The registered name of this destination. */
+ private String name;
+
+ /** The explicit destination to which this named destination is attached. */
+ private PdfDestinationExplicit4a explicitDestination;
+
+ public PdfDestinationNamed4a(final String name, final PdfDestinationExplicit4a explicitDestination) {
+ this.name = name;
+ this.explicitDestination = explicitDestination;
+ }
+
+ @Override
+ public String getName() {
+ return this.name;
+ }
+
+ @Override
+ public String toPDF(final PdfDocument4a doc) {
+ return this.name;
+ }
+
+ /**
+ * Return the explicit destination to which this named destination is attached.
+ * @return The explicit destination.
+ */
+ public PdfDestinationExplicit4a getReferencedDestination() {
+ return this.explicitDestination;
+ }
+
+}
Property changes on: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationNamed4a.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java 2022-01-28 13:34:26 UTC (rev 12488)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java 2022-01-28 16:16:09 UTC (rev 12489)
@@ -51,6 +51,7 @@
import org.axsl.graphic.GraphicException;
import org.axsl.graphic.output.GraphicOutputContext;
import org.axsl.orthography.Orthography;
+import org.axsl.pdf.PdfDestinationNamed;
import org.axsl.pdf.PdfDocument;
import org.axsl.pdf.PdfException;
import org.axsl.pdf.PdfPage;
@@ -822,4 +823,9 @@
this.root.getPages().reorderPages(comparator);
}
+ @Override
+ public PdfDestinationNamed getNamedDestination(final String name) {
+ return this.root.getNamedDestinations().get(name);
+ }
+
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java 2022-01-28 13:34:26 UTC (rev 12488)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java 2022-01-28 16:16:09 UTC (rev 12489)
@@ -32,7 +32,9 @@
*/
package org.foray.pdf.object;
+import org.axsl.pdf.PdfDestination;
import org.axsl.pdf.PdfOutlineItem;
+import org.axsl.pdf.PdfOutlineTarget;
import java.awt.Color;
import java.util.List;
@@ -64,30 +66,14 @@
/** The color for this outline item. */
private PdfColor4a color = null;
- /**
- * Used to access a PDFNamedDestination. If not null, destinationString will
- * be used as the value for the /Dest key. (Either /Dest or /A may be used,
- * but not both).
- */
- private PdfTextString destinationString;
+ /** The target of this bookmark. */
+ private PdfOutlineTarget target;
/**
- * Used to access a PdfDestination. If not null, destination will be used
- * as the value for the /Dest key. (Either /Dest or /A may be used, but not
- * both).
- */
- private PdfDestinationExplicit4a destination;
-
- /**
- * Used to access a PdfAction. If not null, action will be used as the
- * value for the /A key. (Either /Dest or /A may be used, but not both).
- */
- private PdfAction action;
-
- /**
* Private constructor to be used only by the public constructors in this class.
* @param parent The parent outline item.
* @param title The title or text of the outline item.
+ * @param target The target of this outline item.
* @param color The color of the outline item.
* @param italic Indicates whether the outline item should be displayed
* in an italic font.
@@ -94,10 +80,11 @@
* @param bold Indciates whether the outline item should be displayed in a
* bold font.
*/
- private PdfOutlineItem4a(final PdfOutlineParent4a parent, final String title, final Color color,
- final boolean italic, final boolean bold) {
+ public PdfOutlineItem4a(final PdfOutlineParent4a parent, final String title, final PdfOutlineTarget target,
+ final Color color, final boolean italic, final boolean bold) {
this.parent = parent;
this.title = new PdfTextString(title);
+ this.target = target;
if (color != null) {
this.color = new PdfColor4a(color);
}
@@ -106,51 +93,6 @@
}
/**
- * Constructor to access a named destination.
- * @param parent The parent outline item.
- * @param title The title or text of the outline item.
- * @param destinationString The name of the named destination that should be accessed by this Outline Item.
- * @param color The color of the outline item.
- * @param italic Indicates whether the outline item should be displayed in an italic font.
- * @param bold Indciates whether the outline item should be displayed in a bold font.
- */
- public PdfOutlineItem4a(final PdfOutlineParent4a parent, final String title, final String destinationString,
- final Color color, final boolean italic, final boolean bold) {
- this(parent, title, color, italic, bold);
- this.destinationString = new PdfTextString(destinationString);
- }
-
- /**
- * Constructor to access a named destination.
- * @param parent The parent outline item.
- * @param title The title or text of the outline item.
- * @param destination The PdfDestination instance that should be accessed by this Outline Item.
- * @param color The color of the outline item.
- * @param italic Indicates whether the outline item should be displayed in an italic font.
- * @param bold Indciates whether the outline item should be displayed in a bold font.
- */
- public PdfOutlineItem4a(final PdfOutlineParent4a parent, final String title,
- final PdfDestinationExplicit4a destination, final Color color, final boolean italic, final boolean bold) {
- this(parent, title, color, italic, bold);
- this.destination = destination;
- }
-
- /**
- * Constructor to access an action.
- * @param parent The parent outline item.
- * @param title The title or text of the outline item.
- * @param action The PdfAction instance that should be accessed by this Outline Item.
- * @param color The color of the outline item.
- * @param italic Indicates whether the outline item should be displayed in an italic font.
- * @param bold Indciates whether the outline item should be displayed in a bold font.
- */
- public PdfOutlineItem4a(final PdfOutlineParent4a parent, final String title, final PdfAction action,
- final Color color, final boolean italic, final boolean bold) {
- this(parent, title, color, italic, bold);
- this.action = action;
- }
-
- /**
* Return the sibling outline items.
* @return The sibling outline items.
*/
@@ -242,14 +184,22 @@
if (countDescendants > 0) {
result.append(" /Count -" + countDescendants + EOL);
}
- if (this.destinationString != null) {
- result.append(" /Dest " + this.destinationString.toPDF(doc)
- + EOL);
- } else if (this.destination != null) {
- result.append(" /Dest " + this.destination.toPDF(doc));
- } else if (this.action != null) {
- result.append(" /A " + this.action.toPDF(doc));
+
+ if (this.target instanceof PdfDestination) {
+ result.append(" /Dest ");
+ if (this.target instanceof PdfDestinationNamed4a) {
+ final PdfDestinationNamed4a named = (PdfDestinationNamed4a) this.target;
+ result.append(named.getName());
+ } else if (this.target instanceof PdfDestinationExplicit4a) {
+ final PdfDestinationExplicit4a explicit = (PdfDestinationExplicit4a) this.target;
+ result.append(explicit.toPDF(doc));
+ }
+ result.append(EOL);
+ } else if (this.target instanceof PdfAction) {
+ final PdfAction action = (PdfAction) this.target;
+ result.append(" /A " + action.toPDF(doc));
}
+
if (this.color != null
&& ! this.color.isBlack()) {
result.append(" /C " + this.color.toPDF(doc) + EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineParent4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineParent4a.java 2022-01-28 13:34:26 UTC (rev 12488)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineParent4a.java 2022-01-28 16:16:09 UTC (rev 12489)
@@ -29,6 +29,7 @@
package org.foray.pdf.object;
import org.axsl.pdf.PdfOutlineParent;
+import org.axsl.pdf.PdfOutlineTarget;
import java.awt.Color;
import java.util.ArrayList;
@@ -83,7 +84,7 @@
protected abstract int count();
@Override
- public PdfOutlineItem4a createPdfOutlineItem(final String titleText, final String internalDestination,
+ public PdfOutlineItem4a createPdfOutlineItem(final String titleText, final PdfOutlineTarget internalDestination,
final Color color, final boolean italic, final boolean bold) {
final PdfOutlineItem4a newItem =
new PdfOutlineItem4a(this, titleText, internalDestination, color, italic, bold);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java 2022-01-28 13:34:26 UTC (rev 12488)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java 2022-01-28 16:16:09 UTC (rev 12489)
@@ -28,7 +28,7 @@
package org.foray.pdf.object;
-import org.axsl.pdf.PdfDestinationExplicit;
+import org.axsl.pdf.PdfDestination;
import org.axsl.pdf.PdfDestinationExplicit.Coordinates;
import org.axsl.pdf.PdfDestinationExplicit.PositionAndZoom;
import org.axsl.pdf.PdfException;
@@ -192,24 +192,28 @@
}
@Override
- public PdfDestinationExplicit createDestination(final PositionAndZoom positionAndZoom,
+ public PdfDestination createDestination(final PositionAndZoom positionAndZoom,
final Coordinates coordinates, final Float explicitZoom, final String name) throws PdfException {
- final PdfDestinationExplicit4a destination =
- new PdfDestinationExplicit4a(this, positionAndZoom, coordinates, explicitZoom);
+ /* Has the name already been registered as a named destination? */
final PdfDocument4a document = this.parent.getRoot().getDocument();
- document.registerIndirectObjectLast(destination);
-
+ final PdfNameTree<PdfDestinationNamed4a> namedDestinations = document.getRoot().getNamedDestinations();
if (name != null) {
- final PdfNameTree<PdfDestinationExplicit4a> destinations = document.getRoot().getDestinations();
- final PdfDestinationExplicit4a existingDestination = destinations.get(name);
- if (existingDestination == null) {
- destinations.add(name, destination);
- } else {
+ final PdfDestinationNamed4a existingDestination = namedDestinations.get(name);
+ if (existingDestination != null) {
throw new PdfException("Named destination already exists: " + name);
}
}
+ final PdfDestinationExplicit4a explicitDestination =
+ new PdfDestinationExplicit4a(this, positionAndZoom, coordinates, explicitZoom);
+ document.registerIndirectObjectLast(explicitDestination);
- return destination;
+ if (name != null) {
+ final PdfDestinationNamed4a namedDestination = new PdfDestinationNamed4a(name, explicitDestination);
+ namedDestinations.add(name, namedDestination);
+ return namedDestination;
+ } else {
+ return explicitDestination;
+ }
}
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java 2022-01-28 13:34:26 UTC (rev 12488)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java 2022-01-28 16:16:09 UTC (rev 12489)
@@ -51,8 +51,8 @@
/** The root outline object. Lazily created, to avoid unnecessary objects. */
private PdfOutline4a outline;
- /** Collection of destinations. */
- private PdfNameTree<PdfDestinationExplicit4a> destinations;
+ /** Collection of named destinations. */
+ private PdfNameTree<PdfDestinationNamed4a> destinations;
/** The embedded files. */
private PdfNameTree<PdfEmbeddedFileStream> embeddedFiles;
@@ -106,9 +106,9 @@
* Returns the destinations in this document.
* @return The destinations in this document.
*/
- public PdfNameTree<PdfDestinationExplicit4a> getDestinations() {
+ public PdfNameTree<PdfDestinationNamed4a> getNamedDestinations() {
if (this.destinations == null) {
- this.destinations = new PdfNameTree<PdfDestinationExplicit4a>();
+ this.destinations = new PdfNameTree<PdfDestinationNamed4a>();
}
return this.destinations;
}
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/Renderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/Renderer.java 2022-01-28 13:34:26 UTC (rev 12488)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/Renderer.java 2022-01-28 16:16:09 UTC (rev 12489)
@@ -481,8 +481,9 @@
/**
* Render the bookmark tree for this document.
* @param bookmarkTree The bookmark tree to be rendered.
+ * @throws GalleyVisitorException For invalid bookmark target.
*/
- public abstract void render(BookmarkTreeG5 bookmarkTree);
+ public abstract void render(BookmarkTreeG5 bookmarkTree) throws GalleyVisitorException;
@Override
public Void visit(final InlineAreaG5 area) throws GalleyVisitorException {
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfDestinationCoordinates4a.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfDestinationCoordinates4a.java 2022-01-28 13:34:26 UTC (rev 12488)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfDestinationCoordinates4a.java 2022-01-28 16:16:09 UTC (rev 12489)
@@ -35,6 +35,9 @@
*/
public class PdfDestinationCoordinates4a implements PdfDestinationExplicit.Coordinates {
+ /** The format string for {@link #toString()}. */
+ private static final String TO_STRING_FORMAT = "{left = %s, bottom = %s, right = %s, top = %s}";
+
/** String representation of the Null Object. */
private static final String NULL_OBJECT_VALUE = "null";
@@ -85,4 +88,9 @@
return this.top == null ? NULL_OBJECT_VALUE : Float.toString(this.top);
}
+ @Override
+ public String toString() {
+ return String.format(TO_STRING_FORMAT, this.left, this.bottom, this.right, this.top);
+ }
+
}
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java 2022-01-28 13:34:26 UTC (rev 12488)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java 2022-01-28 16:16:09 UTC (rev 12489)
@@ -65,6 +65,7 @@
import org.axsl.pdf.PdfColor;
import org.axsl.pdf.PdfContentStream;
import org.axsl.pdf.PdfDestinationExplicit;
+import org.axsl.pdf.PdfDestinationNamed;
import org.axsl.pdf.PdfDocument;
import org.axsl.pdf.PdfDocumentInfo;
import org.axsl.pdf.PdfEncryption;
@@ -613,9 +614,11 @@
if (destinationName != null) {
/* We don't really know what the position-and-zoom should be. The FIT_H seems like the best default. */
final PdfDestinationExplicit.PositionAndZoom positionAndZoom = PdfDestinationExplicit.PositionAndZoom.FIT_H;
- /* For FIT_H, all we care about is the top coordinate. */
+ /* For FIT_H, all we care about is the top coordinate. Convert from area tree millipoint dimensions to PDF
+ * point dimensions. */
+ final float topPoints = ((float) area.crOriginY()) / WellKnownConstants.MILLIPOINTS_PER_POINT;
final PdfDestinationExplicit.Coordinates coordinates =
- new PdfDestinationCoordinates4a(0f, 0f, 0f, (float) area.crOriginY());
+ new PdfDestinationCoordinates4a(0f, 0f, 0f, topPoints);
final float explicitZoom = 0;
try {
this.currentPage.createDestination(positionAndZoom, coordinates, explicitZoom, destinationName);
@@ -652,7 +655,7 @@
}
@Override
- public void render(final BookmarkTreeG5 bookmarkTree) {
+ public void render(final BookmarkTreeG5 bookmarkTree) throws GalleyVisitorException {
for (int i = 0; i < bookmarkTree.qtyAreaNodeChildren(); i++) {
final BookmarkG5 bookmark = bookmarkTree.areaNodeChildAt(i);
renderBookmark(bookmark, this.pdfDoc.getOutlineRoot());
@@ -663,8 +666,9 @@
* Render a bookmark, using recursion to render child bookmarks as well.
* @param bookmark The bookmark area to be rendered.
* @param parent The PDF outline object to which the rendered bookmarks should be added.
+ * @throws GalleyVisitorException For an invalid named destination.
*/
- public void renderBookmark(final BookmarkG5 bookmark, final PdfOutlineParent parent) {
+ public void renderBookmark(final BookmarkG5 bookmark, final PdfOutlineParent parent) throws GalleyVisitorException {
if (bookmark == null || parent == null) {
return;
}
@@ -677,9 +681,12 @@
if (bookmark.traitFontWeight().getNumericWeight() >= Font.Weight.BOLD.getNumericWeight()) {
bold = true;
}
+ final PdfDestinationNamed namedDestination = this.pdfDoc.getNamedDestination(bookmark.getInternalDestination());
+ if (namedDestination == null) {
+ throw new GalleyVisitorException("Named destination not found: " + bookmark.getInternalDestination());
+ }
PdfOutlineItem pdfOutline = null;
- pdfOutline = parent.createPdfOutlineItem(bookmark.getTitleText(), bookmark.getInternalDestination(), color,
- italic, bold);
+ pdfOutline = parent.createPdfOutlineItem(bookmark.getTitleText(), namedDestination, color, italic, bold);
// Recursively handle child bookmarks
for (int i = 0; i < bookmark.qtyAreaNodeChildren(); i++) {
final BookmarkG5 child = bookmark.areaNodeChildAt(i);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-28 13:34:29
|
Revision: 12488
http://sourceforge.net/p/foray/code/12488
Author: victormote
Date: 2022-01-28 13:34:26 +0000 (Fri, 28 Jan 2022)
Log Message:
-----------
Conform to aXSL change: Rename interface for clarity, and in preparation for reuse of the pre-existing name.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java
trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfDestinationCoordinates4a.java
trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java 2022-01-28 12:55:50 UTC (rev 12487)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java 2022-01-28 13:34:26 UTC (rev 12488)
@@ -34,7 +34,7 @@
package org.foray.pdf.object;
-import org.axsl.pdf.PdfDestination;
+import org.axsl.pdf.PdfDestinationExplicit;
/**
* A PDF Explicit Destination, a destination that points to a specific page / location / view.
@@ -42,16 +42,16 @@
* @see "PDF Reference, 2nd Edition (PDF 1.3), Section 7.2.1."
* @see "PDF Reference, 6th Edition (PDF 1.7), Section 8.2.1."
*/
-public class PdfDestinationExplicit4a extends PdfObject implements PdfDestination {
+public class PdfDestinationExplicit4a extends PdfObject implements PdfDestinationExplicit {
/** The parent page to which this Destination belongs. */
private PdfPage4a page;
/** The position and zoom for this destination. */
- private PdfDestination.PositionAndZoom positionAndZoom;
+ private PdfDestinationExplicit.PositionAndZoom positionAndZoom;
/** The coordinates for this destination. */
- private PdfDestination.Coordinates coordinates;
+ private PdfDestinationExplicit.Coordinates coordinates;
/** The explicit zoom for this destination. */
private Float explicitZoom;
@@ -63,8 +63,8 @@
* @param coordinates The coordinates for this destination.
* @param explicitZoom The explicit zoom for this destination.
*/
- public PdfDestinationExplicit4a(final PdfPage4a page, final PdfDestination.PositionAndZoom positionAndZoom,
- final PdfDestination.Coordinates coordinates, final Float explicitZoom) {
+ public PdfDestinationExplicit4a(final PdfPage4a page, final PdfDestinationExplicit.PositionAndZoom positionAndZoom,
+ final PdfDestinationExplicit.Coordinates coordinates, final Float explicitZoom) {
this.page = page;
this.positionAndZoom = positionAndZoom;
this.coordinates = coordinates;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java 2022-01-28 12:55:50 UTC (rev 12487)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java 2022-01-28 13:34:26 UTC (rev 12488)
@@ -28,9 +28,9 @@
package org.foray.pdf.object;
-import org.axsl.pdf.PdfDestination;
-import org.axsl.pdf.PdfDestination.Coordinates;
-import org.axsl.pdf.PdfDestination.PositionAndZoom;
+import org.axsl.pdf.PdfDestinationExplicit;
+import org.axsl.pdf.PdfDestinationExplicit.Coordinates;
+import org.axsl.pdf.PdfDestinationExplicit.PositionAndZoom;
import org.axsl.pdf.PdfException;
import java.awt.geom.Rectangle2D;
@@ -192,8 +192,8 @@
}
@Override
- public PdfDestination createDestination(final PositionAndZoom positionAndZoom, final Coordinates coordinates,
- final Float explicitZoom, final String name) throws PdfException {
+ public PdfDestinationExplicit createDestination(final PositionAndZoom positionAndZoom,
+ final Coordinates coordinates, final Float explicitZoom, final String name) throws PdfException {
final PdfDestinationExplicit4a destination =
new PdfDestinationExplicit4a(this, positionAndZoom, coordinates, explicitZoom);
final PdfDocument4a document = this.parent.getRoot().getDocument();
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfDestinationCoordinates4a.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfDestinationCoordinates4a.java 2022-01-28 12:55:50 UTC (rev 12487)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfDestinationCoordinates4a.java 2022-01-28 13:34:26 UTC (rev 12488)
@@ -28,12 +28,12 @@
package org.foray.render.pdf;
-import org.axsl.pdf.PdfDestination;
+import org.axsl.pdf.PdfDestinationExplicit;
/**
- * FOray implementation of {@link PdfDestination.Coordinates}.
+ * FOray implementation of {@link PdfDestinationExplicit.Coordinates}.
*/
-public class PdfDestinationCoordinates4a implements PdfDestination.Coordinates {
+public class PdfDestinationCoordinates4a implements PdfDestinationExplicit.Coordinates {
/** String representation of the Null Object. */
private static final String NULL_OBJECT_VALUE = "null";
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java 2022-01-28 12:55:50 UTC (rev 12487)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java 2022-01-28 13:34:26 UTC (rev 12488)
@@ -64,7 +64,7 @@
import org.axsl.output.OutputException;
import org.axsl.pdf.PdfColor;
import org.axsl.pdf.PdfContentStream;
-import org.axsl.pdf.PdfDestination;
+import org.axsl.pdf.PdfDestinationExplicit;
import org.axsl.pdf.PdfDocument;
import org.axsl.pdf.PdfDocumentInfo;
import org.axsl.pdf.PdfEncryption;
@@ -612,9 +612,9 @@
final String destinationName = area.destinationName();
if (destinationName != null) {
/* We don't really know what the position-and-zoom should be. The FIT_H seems like the best default. */
- final PdfDestination.PositionAndZoom positionAndZoom = PdfDestination.PositionAndZoom.FIT_H;
+ final PdfDestinationExplicit.PositionAndZoom positionAndZoom = PdfDestinationExplicit.PositionAndZoom.FIT_H;
/* For FIT_H, all we care about is the top coordinate. */
- final PdfDestination.Coordinates coordinates =
+ final PdfDestinationExplicit.Coordinates coordinates =
new PdfDestinationCoordinates4a(0f, 0f, 0f, (float) area.crOriginY());
final float explicitZoom = 0;
try {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-28 12:55:53
|
Revision: 12487
http://sourceforge.net/p/foray/code/12487
Author: victormote
Date: 2022-01-28 12:55:50 +0000 (Fri, 28 Jan 2022)
Log Message:
-----------
Conform to aXSL changes: Handle all types of explicit PDF destinations.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfObject.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRectangle.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfStream.java
trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java
Added Paths:
-----------
trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfDestinationCoordinates4a.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java 2022-01-27 21:08:48 UTC (rev 12486)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java 2022-01-28 12:55:50 UTC (rev 12487)
@@ -44,48 +44,91 @@
*/
public class PdfDestinationExplicit4a extends PdfObject implements PdfDestination {
- /** The page to which this Destination goes. */
+ /** The parent page to which this Destination belongs. */
private PdfPage4a page;
- /** The x axis location of the destination. */
- private float leftPosition = 0;
+ /** The position and zoom for this destination. */
+ private PdfDestination.PositionAndZoom positionAndZoom;
- /** The y axis location of the destination. */
- private float topPosition = 0;
+ /** The coordinates for this destination. */
+ private PdfDestination.Coordinates coordinates;
- /** The name, if any, that has been assigned to this destination. If not null, this is a "named destination". */
- private String name;
+ /** The explicit zoom for this destination. */
+ private Float explicitZoom;
/**
* Constructor.
* @param page The page on which the destination exists.
- * @param xPosition The x axis location of the destination on the page.
- * @param yPosition The y axis location of the destination on the page.
- * @param name The name for this destination. If not null, this is a named destination.
- * Client code is responsible to register this name with the document itself.
+ * @param positionAndZoom The position and zoom for this destination.
+ * @param coordinates The coordinates for this destination.
+ * @param explicitZoom The explicit zoom for this destination.
*/
- public PdfDestinationExplicit4a(final PdfPage4a page,
- final float xPosition, final float yPosition, final String name) {
+ public PdfDestinationExplicit4a(final PdfPage4a page, final PdfDestination.PositionAndZoom positionAndZoom,
+ final PdfDestination.Coordinates coordinates, final Float explicitZoom) {
this.page = page;
- this.leftPosition = xPosition;
- this.topPosition = yPosition;
- this.name = name;
+ this.positionAndZoom = positionAndZoom;
+ this.coordinates = coordinates;
+ this.explicitZoom = explicitZoom;
}
@Override
public String toPDF(final PdfDocument4a doc) {
final StringBuilder buffer = new StringBuilder();
- buffer.append(this.pdfID() + EOL);
- buffer.append("[" + this.page.pdfReference(doc) + " /XYZ "
- + this.leftPosition
- + " " + this.topPosition + " null]" + EOL);
+ buffer.append(this.pdfID());
+ buffer.append(EOL);
+ buffer.append("[");
+ buffer.append(this.page.pdfReference(doc));
+ buffer.append(" ");
+ buffer.append(this.positionAndZoom.getPdfName());
+ switch(this.positionAndZoom) {
+ case XYZ: {
+ buffer.append(" ");
+ buffer.append(this.coordinates.getLeft());
+ buffer.append(" ");
+ buffer.append(this.coordinates.getTop());
+ buffer.append(" ");
+ final String zoom = this.explicitZoom == null ? NULL_OBJECT_VALUE : Float.toString(this.explicitZoom);
+ buffer.append(zoom);
+ break;
+ }
+ case FIT:
+ break;
+ case FIT_H:
+ buffer.append(" ");
+ buffer.append(this.coordinates.getTop());
+ break;
+ case FIT_V:
+ buffer.append(" ");
+ buffer.append(this.coordinates.getLeft());
+ break;
+ case FIT_R:
+ buffer.append(" ");
+ buffer.append(this.coordinates.getLeft());
+ buffer.append(" ");
+ buffer.append(this.coordinates.getBottom());
+ buffer.append(" ");
+ buffer.append(this.coordinates.getRight());
+ buffer.append(" ");
+ buffer.append(this.coordinates.getTop());
+ break;
+ case FIT_B:
+ break;
+ case FIT_BH:
+ buffer.append(" ");
+ buffer.append(this.coordinates.getTop());
+ break;
+ case FIT_BV:
+ buffer.append(" ");
+ buffer.append(this.coordinates.getLeft());
+ break;
+ default:
+ throw new IllegalArgumentException("Unexpected PositionAndZoom");
+ }
+
+ buffer.append("]");
+ buffer.append(EOL);
buffer.append("endobj" + EOL);
return buffer.toString();
}
- @Override
- public String getName() {
- return this.name;
- }
-
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfObject.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfObject.java 2022-01-27 21:08:48 UTC (rev 12486)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfObject.java 2022-01-28 12:55:50 UTC (rev 12487)
@@ -44,6 +44,10 @@
*/
public abstract class PdfObject extends PdfItem {
+ /** String representation of the Null Object.
+ * @see "PDF Reference, 6th Edition (PDF Version 1.7), Section 3.2.8 for discussion of the Null Object." */
+ public static final String NULL_OBJECT_VALUE = "null";
+
/** If not null, this object is an indirectly referenced object. */
private PdfObjectReference reference;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java 2022-01-27 21:08:48 UTC (rev 12486)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java 2022-01-28 12:55:50 UTC (rev 12487)
@@ -28,6 +28,9 @@
package org.foray.pdf.object;
+import org.axsl.pdf.PdfDestination;
+import org.axsl.pdf.PdfDestination.Coordinates;
+import org.axsl.pdf.PdfDestination.PositionAndZoom;
import org.axsl.pdf.PdfException;
import java.awt.geom.Rectangle2D;
@@ -189,14 +192,14 @@
}
@Override
- public PdfDestinationExplicit4a createDestination(final float xPosition, final float yPosition, final String name)
- throws PdfException {
- final PdfDestinationExplicit4a destination = new PdfDestinationExplicit4a(this, xPosition, yPosition, name);
+ public PdfDestination createDestination(final PositionAndZoom positionAndZoom, final Coordinates coordinates,
+ final Float explicitZoom, final String name) throws PdfException {
+ final PdfDestinationExplicit4a destination =
+ new PdfDestinationExplicit4a(this, positionAndZoom, coordinates, explicitZoom);
final PdfDocument4a document = this.parent.getRoot().getDocument();
document.registerIndirectObjectLast(destination);
if (name != null) {
- /* Register the destination with the PDF document. */
final PdfNameTree<PdfDestinationExplicit4a> destinations = document.getRoot().getDestinations();
final PdfDestinationExplicit4a existingDestination = destinations.get(name);
if (existingDestination == null) {
@@ -205,6 +208,7 @@
throw new PdfException("Named destination already exists: " + name);
}
}
+
return destination;
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRectangle.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRectangle.java 2022-01-27 21:08:48 UTC (rev 12486)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRectangle.java 2022-01-28 12:55:50 UTC (rev 12487)
@@ -34,7 +34,7 @@
/**
* A PDF rectangle.
- * Rectangles are specified on page 183 of the PDF 1.3 spec.
+ * @see "PDF Reference, 6th Edition (PDF Version 1.7), Section 3.8.4."
*/
public class PdfRectangle {
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfStream.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfStream.java 2022-01-27 21:08:48 UTC (rev 12486)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfStream.java 2022-01-28 12:55:50 UTC (rev 12487)
@@ -388,7 +388,7 @@
sb.append(s);
needParmsEntry = true;
} else {
- sb.append("null");
+ sb.append(PdfObject.NULL_OBJECT_VALUE);
}
sb.append(" ");
}
Added: trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfDestinationCoordinates4a.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfDestinationCoordinates4a.java (rev 0)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfDestinationCoordinates4a.java 2022-01-28 12:55:50 UTC (rev 12487)
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2022 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.render.pdf;
+
+import org.axsl.pdf.PdfDestination;
+
+/**
+ * FOray implementation of {@link PdfDestination.Coordinates}.
+ */
+public class PdfDestinationCoordinates4a implements PdfDestination.Coordinates {
+
+ /** String representation of the Null Object. */
+ private static final String NULL_OBJECT_VALUE = "null";
+
+ /** The left coordinate. */
+ private Float left;
+
+ /** The bottom coordinate. */
+ private Float bottom;
+
+ /** The right coordinate. */
+ private Float right;
+
+ /** The top coordinate. */
+ private Float top;
+
+ /**
+ * Constructor.
+ * @param left The left coordinate.
+ * @param bottom The bottom coordinate.
+ * @param right The right coordinate.
+ * @param top The top coordinate.
+ */
+ public PdfDestinationCoordinates4a(final Float left, final Float bottom, final Float right, final Float top) {
+ this.left = left;
+ this.bottom = bottom;
+ this.right = right;
+ this.top = top;
+ }
+
+
+ @Override
+ public String getLeft() {
+ return this.left == null ? NULL_OBJECT_VALUE : Float.toString(this.left);
+ }
+
+ @Override
+ public String getBottom() {
+ return this.bottom == null ? NULL_OBJECT_VALUE : Float.toString(this.bottom);
+ }
+
+ @Override
+ public String getRight() {
+ return this.right == null ? NULL_OBJECT_VALUE : Float.toString(this.right);
+ }
+
+ @Override
+ public String getTop() {
+ return this.top == null ? NULL_OBJECT_VALUE : Float.toString(this.top);
+ }
+
+}
Property changes on: trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfDestinationCoordinates4a.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java 2022-01-27 21:08:48 UTC (rev 12486)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java 2022-01-28 12:55:50 UTC (rev 12487)
@@ -64,6 +64,7 @@
import org.axsl.output.OutputException;
import org.axsl.pdf.PdfColor;
import org.axsl.pdf.PdfContentStream;
+import org.axsl.pdf.PdfDestination;
import org.axsl.pdf.PdfDocument;
import org.axsl.pdf.PdfDocumentInfo;
import org.axsl.pdf.PdfEncryption;
@@ -602,23 +603,27 @@
}
/**
- * Using recursion, traverses the entire tree-fragment that is under this
- * area, looking for Area instances that should trigger destinations in
- * the output, and creating them.
- * @param area The root of the AreaTree fragment in which destinations
- * should be sought.
+ * Using recursion, traverses the entire tree-fragment rooted at a given node, looking for Area instances that
+ * should trigger <em>named</em> destinations in the output, and creating them.
+ * @param area The root of the AreaTree fragment in which destinations should be sought.
* @throws GalleyVisitorException If a destination already exists.
*/
private void renderDestinations(final AreaG5 area) throws GalleyVisitorException {
final String destinationName = area.destinationName();
if (destinationName != null) {
+ /* We don't really know what the position-and-zoom should be. The FIT_H seems like the best default. */
+ final PdfDestination.PositionAndZoom positionAndZoom = PdfDestination.PositionAndZoom.FIT_H;
+ /* For FIT_H, all we care about is the top coordinate. */
+ final PdfDestination.Coordinates coordinates =
+ new PdfDestinationCoordinates4a(0f, 0f, 0f, (float) area.crOriginY());
+ final float explicitZoom = 0;
try {
- this.currentPage.createDestination(toPoints(area.crOriginX()), toPoints(area.crOriginY()),
- destinationName);
+ this.currentPage.createDestination(positionAndZoom, coordinates, explicitZoom, destinationName);
} catch (final PdfException e) {
throw new GalleyVisitorException(e);
}
}
+
if (area.isLinkRoot()) {
createBasicLink(area);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-27 21:08:50
|
Revision: 12486
http://sourceforge.net/p/foray/code/12486
Author: victormote
Date: 2022-01-27 21:08:48 +0000 (Thu, 27 Jan 2022)
Log Message:
-----------
Rename class for clarity.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAction.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoTo.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfLink.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java
Added Paths:
-----------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java
Removed Paths:
-------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestination4a.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAction.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAction.java 2022-01-27 16:52:18 UTC (rev 12485)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfAction.java 2022-01-27 21:08:48 UTC (rev 12486)
@@ -29,7 +29,7 @@
package org.foray.pdf.object;
/**
- * class representing an action object.
+ * An action object.
*/
public abstract class PdfAction extends PdfObject {
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestination4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestination4a.java 2022-01-27 16:52:18 UTC (rev 12485)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestination4a.java 2022-01-27 21:08:48 UTC (rev 12486)
@@ -1,91 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-/*
- * Known contributors:
- * Stefan Wachter
- * Lloyd McKenzie
- */
-
-package org.foray.pdf.object;
-
-import org.axsl.pdf.PdfDestination;
-
-/**
- * A PDF Explicit Destination, a destination that points to a specific page /
- * location / view. An Explicit Destination is by definition an array object.
- * See PDF Reference, 2nd Edition, Section 7.2.1 for more information about
- * PDF Destinations in general, and Explicit Destinations in particular.
- */
-public class PdfDestination4a extends PdfObject implements PdfDestination {
-
- /** The page to which this Destination goes. */
- private PdfPage4a page;
-
- /** The x axis location of the destination. */
- private float leftPosition = 0;
-
- /** The y axis location of the destination. */
- private float topPosition = 0;
-
- /** The name, if any, that has been assigned to this destination. If not null, this is a "named destination". */
- private String name;
-
- /**
- * Constructor.
- * @param page The page on which the destination exists.
- * @param xPosition The x axis location of the destination on the page.
- * @param yPosition The y axis location of the destination on the page.
- * @param name The name for this destination. If not null, this is a named destination.
- * Client code is responsible to register this name with the document itself.
- */
- public PdfDestination4a(final PdfPage4a page,
- final float xPosition, final float yPosition, final String name) {
- this.page = page;
- this.leftPosition = xPosition;
- this.topPosition = yPosition;
- this.name = name;
- }
-
- @Override
- public String toPDF(final PdfDocument4a doc) {
- final StringBuilder buffer = new StringBuilder();
- buffer.append(this.pdfID() + EOL);
- buffer.append("[" + this.page.pdfReference(doc) + " /XYZ "
- + this.leftPosition
- + " " + this.topPosition + " null]" + EOL);
- buffer.append("endobj" + EOL);
- return buffer.toString();
- }
-
- @Override
- public String getName() {
- return this.name;
- }
-
-}
Copied: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java (from rev 12482, trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestination4a.java)
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDestinationExplicit4a.java 2022-01-27 21:08:48 UTC (rev 12486)
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+/*
+ * Known contributors:
+ * Stefan Wachter
+ * Lloyd McKenzie
+ */
+
+package org.foray.pdf.object;
+
+import org.axsl.pdf.PdfDestination;
+
+/**
+ * A PDF Explicit Destination, a destination that points to a specific page / location / view.
+ * An Explicit Destination is by definition an array object.
+ * @see "PDF Reference, 2nd Edition (PDF 1.3), Section 7.2.1."
+ * @see "PDF Reference, 6th Edition (PDF 1.7), Section 8.2.1."
+ */
+public class PdfDestinationExplicit4a extends PdfObject implements PdfDestination {
+
+ /** The page to which this Destination goes. */
+ private PdfPage4a page;
+
+ /** The x axis location of the destination. */
+ private float leftPosition = 0;
+
+ /** The y axis location of the destination. */
+ private float topPosition = 0;
+
+ /** The name, if any, that has been assigned to this destination. If not null, this is a "named destination". */
+ private String name;
+
+ /**
+ * Constructor.
+ * @param page The page on which the destination exists.
+ * @param xPosition The x axis location of the destination on the page.
+ * @param yPosition The y axis location of the destination on the page.
+ * @param name The name for this destination. If not null, this is a named destination.
+ * Client code is responsible to register this name with the document itself.
+ */
+ public PdfDestinationExplicit4a(final PdfPage4a page,
+ final float xPosition, final float yPosition, final String name) {
+ this.page = page;
+ this.leftPosition = xPosition;
+ this.topPosition = yPosition;
+ this.name = name;
+ }
+
+ @Override
+ public String toPDF(final PdfDocument4a doc) {
+ final StringBuilder buffer = new StringBuilder();
+ buffer.append(this.pdfID() + EOL);
+ buffer.append("[" + this.page.pdfReference(doc) + " /XYZ "
+ + this.leftPosition
+ + " " + this.topPosition + " null]" + EOL);
+ buffer.append("endobj" + EOL);
+ return buffer.toString();
+ }
+
+ @Override
+ public String getName() {
+ return this.name;
+ }
+
+}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoTo.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoTo.java 2022-01-27 16:52:18 UTC (rev 12485)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfGoTo.java 2022-01-27 21:08:48 UTC (rev 12486)
@@ -35,13 +35,13 @@
public class PdfGoTo extends PdfAction {
/** The destination of this object. */
- private PdfDestination4a destination;
+ private PdfDestinationExplicit4a destination;
/**
* Create a /GoTo object.
* @param destination The PdfDestination that this object should "go to".
*/
- public PdfGoTo(final PdfDestination4a destination) {
+ public PdfGoTo(final PdfDestinationExplicit4a destination) {
this.destination = destination;
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfLink.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfLink.java 2022-01-27 16:52:18 UTC (rev 12485)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfLink.java 2022-01-27 21:08:48 UTC (rev 12486)
@@ -41,7 +41,7 @@
private PdfTextString destinationName;
/** Should be null if either destinationName or action is not. */
- private PdfDestination4a destination;
+ private PdfDestinationExplicit4a destination;
/** Should be null if either destination or destinationName is not. */
private PdfAction action;
@@ -76,7 +76,7 @@
* rectangle should be expressed in 1/1000ths of a user space unit.
* @param destination The destination to which this link points.
*/
- public PdfLink(final Rectangle2D rect, final PdfDestination4a destination) {
+ public PdfLink(final Rectangle2D rect, final PdfDestinationExplicit4a destination) {
this(rect);
this.destination = destination;
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java 2022-01-27 16:52:18 UTC (rev 12485)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java 2022-01-27 21:08:48 UTC (rev 12486)
@@ -76,7 +76,7 @@
* as the value for the /Dest key. (Either /Dest or /A may be used, but not
* both).
*/
- private PdfDestination4a destination;
+ private PdfDestinationExplicit4a destination;
/**
* Used to access a PdfAction. If not null, action will be used as the
@@ -129,8 +129,8 @@
* @param italic Indicates whether the outline item should be displayed in an italic font.
* @param bold Indciates whether the outline item should be displayed in a bold font.
*/
- public PdfOutlineItem4a(final PdfOutlineParent4a parent, final String title, final PdfDestination4a destination,
- final Color color, final boolean italic, final boolean bold) {
+ public PdfOutlineItem4a(final PdfOutlineParent4a parent, final String title,
+ final PdfDestinationExplicit4a destination, final Color color, final boolean italic, final boolean bold) {
this(parent, title, color, italic, bold);
this.destination = destination;
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java 2022-01-27 16:52:18 UTC (rev 12485)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java 2022-01-27 21:08:48 UTC (rev 12486)
@@ -189,16 +189,16 @@
}
@Override
- public PdfDestination4a createDestination(final float xPosition, final float yPosition, final String name)
+ public PdfDestinationExplicit4a createDestination(final float xPosition, final float yPosition, final String name)
throws PdfException {
- final PdfDestination4a destination = new PdfDestination4a(this, xPosition, yPosition, name);
+ final PdfDestinationExplicit4a destination = new PdfDestinationExplicit4a(this, xPosition, yPosition, name);
final PdfDocument4a document = this.parent.getRoot().getDocument();
document.registerIndirectObjectLast(destination);
if (name != null) {
/* Register the destination with the PDF document. */
- final PdfNameTree<PdfDestination4a> destinations = document.getRoot().getDestinations();
- final PdfDestination4a existingDestination = destinations.get(name);
+ final PdfNameTree<PdfDestinationExplicit4a> destinations = document.getRoot().getDestinations();
+ final PdfDestinationExplicit4a existingDestination = destinations.get(name);
if (existingDestination == null) {
destinations.add(name, destination);
} else {
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java 2022-01-27 16:52:18 UTC (rev 12485)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java 2022-01-27 21:08:48 UTC (rev 12486)
@@ -52,7 +52,7 @@
private PdfOutline4a outline;
/** Collection of destinations. */
- private PdfNameTree<PdfDestination4a> destinations;
+ private PdfNameTree<PdfDestinationExplicit4a> destinations;
/** The embedded files. */
private PdfNameTree<PdfEmbeddedFileStream> embeddedFiles;
@@ -106,9 +106,9 @@
* Returns the destinations in this document.
* @return The destinations in this document.
*/
- public PdfNameTree<PdfDestination4a> getDestinations() {
+ public PdfNameTree<PdfDestinationExplicit4a> getDestinations() {
if (this.destinations == null) {
- this.destinations = new PdfNameTree<PdfDestination4a>();
+ this.destinations = new PdfNameTree<PdfDestinationExplicit4a>();
}
return this.destinations;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-27 16:52:21
|
Revision: 12485
http://sourceforge.net/p/foray/code/12485
Author: victormote
Date: 2022-01-27 16:52:18 +0000 (Thu, 27 Jan 2022)
Log Message:
-----------
Improvements to rendering of bookmarks in PDF.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfItem.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineParent4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java
trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfItem.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfItem.java 2022-01-27 13:22:30 UTC (rev 12484)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfItem.java 2022-01-27 16:52:18 UTC (rev 12485)
@@ -45,20 +45,16 @@
* etc.
*/
public abstract class PdfItem {
+
/** The String that should be used to end a line in the PDF document.
- * Note that this always uses the Unix-style line ending, as it is more
- * compact, and as the PDF generated should be identical, regardless of
- * the platform from which it is generated. */
+ * Note that this always uses the Unix-style line ending, as it is more compact, and as the PDF generated should be
+ * identical, regardless of the platform from which it is generated. */
public static final String EOL = StringUtils.EMPTY_STRING + Basic_Latin_Block.CONTROL_LINE_FEED;
- /**
- * The String that should be used to end a cross-reference line in the
- * PDF document.
- * According to the PDF Reference, 3rd Edition, Section 3.4.3, each
- * cross-reference entry must be exactly 20 bytes long, including the
- * end-of-line character(s).
- * If a 1-character eol is used (such as a newline), then an extra character
- * must be padded.
+ /** The String that should be used to end a cross-reference line in the PDF document.
+ * According to the PDF Reference, 3rd Edition, Section 3.4.3, each cross-reference entry must be exactly 20 bytes
+ * long, including the end-of-line character(s).
+ * If a 1-character eol is used (such as a newline), then an extra character must be padded.
* According to the Reference, that character must be a space. */
public static final String XREF_EOL = StringUtils.SINGLE_SPACE + Basic_Latin_Block.CONTROL_LINE_FEED;
@@ -66,12 +62,6 @@
public static final String MSG_EOL = System.getProperty("line.separator");
/**
- * No-parameter constructor.
- */
- public PdfItem() {
- }
-
- /**
* Converts a StringBuilder buffer to an array of bytes.
* @param buffer The input StringBuilder.
* @return A properly-encoded array of bytes.
@@ -99,8 +89,7 @@
* @param bytes The array to be written.
* @throws PdfException For IO errors during output.
*/
- protected void byteArrayToStream(final byte[] bytes,
- final OutputStream stream) throws PdfException {
+ protected void byteArrayToStream(final byte[] bytes, final OutputStream stream) throws PdfException {
try {
stream.write(bytes);
} catch (final IOException e) {
@@ -108,5 +97,4 @@
}
}
-
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline4a.java 2022-01-27 13:22:30 UTC (rev 12484)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline4a.java 2022-01-27 16:52:18 UTC (rev 12485)
@@ -48,7 +48,7 @@
@Override
public String toPDF(final PdfDocument4a doc) {
- if (this.getChildren().size() < 1) {
+ if (getChildren().size() < 1) {
return StringUtils.EMPTY_STRING;
}
final StringBuilder result = new StringBuilder();
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java 2022-01-27 13:22:30 UTC (rev 12484)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java 2022-01-27 16:52:18 UTC (rev 12485)
@@ -32,6 +32,8 @@
*/
package org.foray.pdf.object;
+import org.axsl.pdf.PdfOutlineItem;
+
import java.awt.Color;
import java.util.List;
@@ -39,8 +41,7 @@
* An Outline Item Dictionary in PDF.
*/
-public class PdfOutlineItem4a extends PdfOutlineParent4a
- implements org.axsl.pdf.PdfOutlineItem {
+public class PdfOutlineItem4a extends PdfOutlineParent4a implements PdfOutlineItem {
/** The parent object. */
private PdfOutlineParent4a parent;
@@ -49,14 +50,14 @@
private PdfTextString title;
/**
- * BitUtils 1 of the flags entry. See PDF Reference, 3rd Edition, Table 8.5 and
- * the discussion near it for the meaning.
+ * Bit 1 of the flags entry.
+ * @see "PDF Reference, 3rd Edition, Table 8.5 and the discussion near it."
*/
private boolean italic = false;
/**
- * BitUtils 2 of the flags entry. See PDF Reference, 3rd Edition, Table 8.5 and
- * the discussion near it for the meaning.
+ * Bit 2 of the flags entry.
+ * @see "PDF Reference, 3rd Edition, Table 8.5 and the discussion near it."
*/
private boolean bold = false;
@@ -84,8 +85,7 @@
private PdfAction action;
/**
- * Private constructor to be used only by the public constructors in this
- * class.
+ * Private constructor to be used only by the public constructors in this class.
* @param parent The parent outline item.
* @param title The title or text of the outline item.
* @param color The color of the outline item.
@@ -94,11 +94,9 @@
* @param bold Indciates whether the outline item should be displayed in a
* bold font.
*/
- private PdfOutlineItem4a(final PdfOutlineParent4a parent,
- final String title, final Color color, final boolean italic,
- final boolean bold) {
+ private PdfOutlineItem4a(final PdfOutlineParent4a parent, final String title, final Color color,
+ final boolean italic, final boolean bold) {
this.parent = parent;
- parent.addChild(this);
this.title = new PdfTextString(title);
if (color != null) {
this.color = new PdfColor4a(color);
@@ -111,16 +109,12 @@
* Constructor to access a named destination.
* @param parent The parent outline item.
* @param title The title or text of the outline item.
- * @param destinationString The name of the named destination that should
- * be accessed by this Outline Item.
+ * @param destinationString The name of the named destination that should be accessed by this Outline Item.
* @param color The color of the outline item.
- * @param italic Indicates whether the outline item should be displayed
- * in an italic font.
- * @param bold Indciates whether the outline item should be displayed in a
- * bold font.
+ * @param italic Indicates whether the outline item should be displayed in an italic font.
+ * @param bold Indciates whether the outline item should be displayed in a bold font.
*/
- public PdfOutlineItem4a(final PdfOutlineParent4a parent,
- final String title, final String destinationString,
+ public PdfOutlineItem4a(final PdfOutlineParent4a parent, final String title, final String destinationString,
final Color color, final boolean italic, final boolean bold) {
this(parent, title, color, italic, bold);
this.destinationString = new PdfTextString(destinationString);
@@ -130,16 +124,12 @@
* Constructor to access a named destination.
* @param parent The parent outline item.
* @param title The title or text of the outline item.
- * @param destination The PdfDestination instance that should be accessed
- * by this Outline Item.
+ * @param destination The PdfDestination instance that should be accessed by this Outline Item.
* @param color The color of the outline item.
- * @param italic Indicates whether the outline item should be displayed
- * in an italic font.
- * @param bold Indciates whether the outline item should be displayed in a
- * bold font.
+ * @param italic Indicates whether the outline item should be displayed in an italic font.
+ * @param bold Indciates whether the outline item should be displayed in a bold font.
*/
- public PdfOutlineItem4a(final PdfOutlineParent4a parent,
- final String title, final PdfDestination4a destination,
+ public PdfOutlineItem4a(final PdfOutlineParent4a parent, final String title, final PdfDestination4a destination,
final Color color, final boolean italic, final boolean bold) {
this(parent, title, color, italic, bold);
this.destination = destination;
@@ -149,17 +139,13 @@
* Constructor to access an action.
* @param parent The parent outline item.
* @param title The title or text of the outline item.
- * @param action The PdfAction instance that should be accessed
- * by this Outline Item.
+ * @param action The PdfAction instance that should be accessed by this Outline Item.
* @param color The color of the outline item.
- * @param italic Indicates whether the outline item should be displayed
- * in an italic font.
- * @param bold Indciates whether the outline item should be displayed in a
- * bold font.
+ * @param italic Indicates whether the outline item should be displayed in an italic font.
+ * @param bold Indciates whether the outline item should be displayed in a bold font.
*/
- public PdfOutlineItem4a(final PdfOutlineParent4a parent,
- final String title, final PdfAction action, final Color color,
- final boolean italic, final boolean bold) {
+ public PdfOutlineItem4a(final PdfOutlineParent4a parent, final String title, final PdfAction action,
+ final Color color, final boolean italic, final boolean bold) {
this(parent, title, color, italic, bold);
this.action = action;
}
@@ -180,35 +166,26 @@
/**
* Return the sibling outline item immediately before this one.
- * @return The sibling outline item immediately before this one, or null if
- * there is none.
+ * @return The sibling outline item immediately before this one, or null if there is none.
*/
private PdfOutlineItem4a getPrevious() {
- if (this.parent == null) {
+ final int myIndex = this.parent.getChildren().indexOf(this);
+ if (myIndex < 1) {
return null;
}
- final int siblingIndex = getSiblings().indexOf(this);
- if (siblingIndex < 1 || siblingIndex >= getSiblings().size()) {
- return null;
- }
- return getSiblings().get(siblingIndex - 1);
+ return this.parent.getChildren().get(myIndex - 1);
}
/**
* Return the sibling outline item immediately after this one.
- * @return The sibling outline item immediately after this one, or null if
- * there is none.
+ * @return The sibling outline item immediately after this one, or null if there is none.
*/
private PdfOutlineItem4a getNext() {
- if (this.parent == null) {
+ final int myIndex = this.parent.getChildren().indexOf(this);
+ if (myIndex >= getSiblings().size() - 1) {
return null;
}
- final int siblingIndex = getSiblings().indexOf(this);
- if (siblingIndex < 0
- || siblingIndex >= getSiblings().size() - 1) {
- return null;
- }
- return getSiblings().get(siblingIndex + 1);
+ return this.parent.getChildren().get(myIndex + 1);
}
@Override
@@ -254,11 +231,13 @@
result.append(" /First " + getFirst().pdfReference(doc) + EOL);
result.append(" /Last " + getLast().pdfReference(doc) + EOL);
}
- if (getPrevious() != null) {
- result.append(" /Prev " + getPrevious().pdfReference(doc) + EOL);
+ final PdfOutlineItem4a previous = getPrevious();
+ if (previous != null) {
+ result.append(" /Prev " + previous.pdfReference(doc) + EOL);
}
- if (getNext() != null) {
- result.append(" /Next " + getNext().pdfReference(doc) + EOL);
+ final PdfOutlineItem4a next = getNext();
+ if (next != null) {
+ result.append(" /Next " + next.pdfReference(doc) + EOL);
}
if (countDescendants > 0) {
result.append(" /Count -" + countDescendants + EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineParent4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineParent4a.java 2022-01-27 13:22:30 UTC (rev 12484)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineParent4a.java 2022-01-27 16:52:18 UTC (rev 12485)
@@ -28,6 +28,8 @@
package org.foray.pdf.object;
+import org.axsl.pdf.PdfOutlineParent;
+
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
@@ -37,21 +39,12 @@
* object. This includes the classes PdfOutline and PdfOutlineItem4a.
*/
-public abstract class PdfOutlineParent4a extends PdfObject
- implements org.axsl.pdf.PdfOutlineParent {
+public abstract class PdfOutlineParent4a extends PdfObject implements PdfOutlineParent {
/** Collection of child PdfOutline objects. */
private List<PdfOutlineItem4a> children = new ArrayList<PdfOutlineItem4a>();
/**
- * Add a child to this parent.
- * @param child The child to be added.
- */
- public void addChild(final PdfOutlineItem4a child) {
- this.children.add(child);
- }
-
- /**
* Return the children of this parent.
* @return The children of this parent.
*/
@@ -90,10 +83,12 @@
protected abstract int count();
@Override
- public PdfOutlineItem4a createPdfOutlineItem(
- final String titleText, final String internalDestination,
+ public PdfOutlineItem4a createPdfOutlineItem(final String titleText, final String internalDestination,
final Color color, final boolean italic, final boolean bold) {
- return new PdfOutlineItem4a(this, titleText, internalDestination, color, italic, bold);
+ final PdfOutlineItem4a newItem =
+ new PdfOutlineItem4a(this, titleText, internalDestination, color, italic, bold);
+ this.children.add(newItem);
+ return newItem;
}
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java 2022-01-27 13:22:30 UTC (rev 12484)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java 2022-01-27 16:52:18 UTC (rev 12485)
@@ -131,6 +131,7 @@
public PdfOutline4a getOutlineRoot() {
if (this.outline == null) {
this.outline = new PdfOutline4a();
+ this.document.registerIndirectObject(this.outline);
}
return this.outline;
}
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java 2022-01-27 13:22:30 UTC (rev 12484)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java 2022-01-27 16:52:18 UTC (rev 12485)
@@ -647,39 +647,37 @@
}
@Override
- public void render(final BookmarkTreeG5 area) {
- for (int i = 0; i < area.qtyAreaNodeChildren(); i++) {
- final BookmarkG5 child = area.areaNodeChildAt(i);
- renderBookmark(child, this.pdfDoc.getOutlineRoot());
+ public void render(final BookmarkTreeG5 bookmarkTree) {
+ for (int i = 0; i < bookmarkTree.qtyAreaNodeChildren(); i++) {
+ final BookmarkG5 bookmark = bookmarkTree.areaNodeChildAt(i);
+ renderBookmark(bookmark, this.pdfDoc.getOutlineRoot());
}
}
/**
* Render a bookmark, using recursion to render child bookmarks as well.
- * @param area The bookmark area to be rendered.
- * @param parent The PDF outline object to which the rendered bookmarks
- * should be added.
+ * @param bookmark The bookmark area to be rendered.
+ * @param parent The PDF outline object to which the rendered bookmarks should be added.
*/
- public void renderBookmark(final BookmarkG5 area, final PdfOutlineParent parent) {
- if (area == null || parent == null) {
+ public void renderBookmark(final BookmarkG5 bookmark, final PdfOutlineParent parent) {
+ if (bookmark == null || parent == null) {
return;
}
- final Color color = area.traitColor();
+ final Color color = bookmark.traitColor();
boolean italic = false;
- if (area.traitFontStyle() == Font.Style.ITALIC) {
+ if (bookmark.traitFontStyle() == Font.Style.ITALIC) {
italic = true;
}
boolean bold = false;
- if (area.traitFontWeight().getNumericWeight()
- >= Font.Weight.BOLD.getNumericWeight()) {
+ if (bookmark.traitFontWeight().getNumericWeight() >= Font.Weight.BOLD.getNumericWeight()) {
bold = true;
}
PdfOutlineItem pdfOutline = null;
- pdfOutline = parent.createPdfOutlineItem(area.getTitleText(),
- area.getInternalDestination(), color, italic, bold);
+ pdfOutline = parent.createPdfOutlineItem(bookmark.getTitleText(), bookmark.getInternalDestination(), color,
+ italic, bold);
// Recursively handle child bookmarks
- for (int i = 0; i < area.qtyAreaNodeChildren(); i++) {
- final BookmarkG5 child = area.areaNodeChildAt(i);
+ for (int i = 0; i < bookmark.qtyAreaNodeChildren(); i++) {
+ final BookmarkG5 child = bookmark.areaNodeChildAt(i);
renderBookmark(child, pdfOutline);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-27 13:22:36
|
Revision: 12484
http://sourceforge.net/p/foray/code/12484
Author: victormote
Date: 2022-01-27 13:22:30 +0000 (Thu, 27 Jan 2022)
Log Message:
-----------
Remove build dependency on lombok. Interesting idea, worked well, but we don't intend to use it more than we are, which doesn't justify the dependency.
Modified Paths:
--------------
trunk/foray/build.gradle
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfCrossRefEntry.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfGraphicsState4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfHeader.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfSerializationConfig4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfTextState.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDashPattern.java
trunk/foray/foray-unicode/src/main/java/org/foray/unicode/Block.java
trunk/foray/foray-unicode/src/main/java/org/foray/unicode/CodePoint.java
Modified: trunk/foray/build.gradle
===================================================================
--- trunk/foray/build.gradle 2022-01-27 12:17:01 UTC (rev 12483)
+++ trunk/foray/build.gradle 2022-01-27 13:22:30 UTC (rev 12484)
@@ -18,11 +18,6 @@
Runs all tests from all projects.
*/
-
-plugins {
- id 'io.freefair.lombok' version '5.3.0' apply false
-}
-
def buildDate = new Date().format("yyyy-MM-dd 'at' HH:mm 'GMT'", TimeZone.getTimeZone("GMT"))
allprojects {
@@ -103,7 +98,6 @@
apply plugin: 'java-library'
apply plugin: 'checkstyle'
apply plugin: 'maven-publish'
- apply plugin: 'io.freefair.lombok'
java {
sourceCompatibility = javaSourceCompatibility
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfCrossRefEntry.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfCrossRefEntry.java 2022-01-27 12:17:01 UTC (rev 12483)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfCrossRefEntry.java 2022-01-27 13:22:30 UTC (rev 12484)
@@ -32,9 +32,6 @@
import org.axsl.utility.sequence.ByteSequencePlus;
-import lombok.Getter;
-import lombok.Setter;
-
/**
* An entry in the cross-reference table found near the end of a PDF.
* Note that, like the entry in the physical file itself, the object number of the object referenced is not stored
@@ -60,25 +57,13 @@
/** Formatting string for writing the generation value. */
private static final String GENERATION_FORMATTING_STRING = "%05d";
- /**
- * The 0-based offset into the file content (bytes) to which this entry points.
- * @param offset The new value for the offset.
- * @return The value for the offset.
- */
- @Getter
- @Setter
+ /** The 0-based offset into the file content (bytes) to which this entry points. */
private long offset;
/* The capacity defined in the PDF reference is 10 decimal digits, a maximum of 9,999,999,999, one less than 10
* billion, about 5 times as much as can be stored in an {@link Integer#TYPE}.
* Therefore we use {@link Long#TYPE}. */
- /**
- * The generation number of the object referenced by this entry.
- * @param generation The new value for the generation.
- * @return The value for the generation.
- */
- @Getter
- @Setter
+ /** The generation number of the object referenced by this entry. */
private int generation;
/* The capacity defined in the PDF reference is 5 decimal digits, a maximum of 99,999, one less than 10
* billion, about 3 times as much as can be stored in an {@link Short#TYPE}, and about 1.5 times a much as can be
@@ -85,23 +70,11 @@
* stored in a {@link Character#TYPE}.
* Therefore we use {@link Integer#TYPE}. */
- /**
- * Indicates whether this entry is "in-use" ("n" in the PDF), or "free" ("f" in the PDF).
- * @param inUse The new value for "in-use".
- * @return True if and only if this entry is "in-use".
- */
- @Getter
- @Setter
+ /** Indicates whether this entry is "in-use" ("n" in the PDF), or "free" ("f" in the PDF). */
private boolean inUse;
- /**
- * The referenced object.
- * This will be null if the document is being parsed and the parser has not yet parsed the object at this offset.
- * @param object The object referenced by this cross-reference entry.
- * @return The object referenced by this cross-reference entry.
- */
- @Getter
- @Setter
+ /** The referenced object. This will be null if the document is being parsed and the parser has not yet parsed the
+ * object at this offset. */
private PdfObject object;
/**
@@ -190,4 +163,68 @@
return this.inUse ? (byte) 'n' : (byte) 'f';
}
+ /**
+ * Returns the value for the offset.
+ * @return The value for the offset.
+ */
+ public long getOffset() {
+ return offset;
+ }
+
+ /**
+ * Sets the new value for the offset.
+ * @param offset The new value for the offset.
+ */
+ public void setOffset(final long offset) {
+ this.offset = offset;
+ }
+
+ /**
+ * Returns the value for the generation.
+ * @return The value for the generation.
+ */
+ public int getGeneration() {
+ return generation;
+ }
+
+ /**
+ * Sets the new value for the generation.
+ * @param generation The new value for the generation.
+ */
+ public void setGeneration(final int generation) {
+ this.generation = generation;
+ }
+
+ /**
+ * Indicates whether this entry is "in-use".
+ * @return True if and only if this entry is "in-use".
+ */
+ public boolean isInUse() {
+ return inUse;
+ }
+
+ /**
+ * Sets the "in-use" value.
+ * @param inUse The new value for "in-use".
+ */
+ public void setInUse(final boolean inUse) {
+ this.inUse = inUse;
+ }
+
+ /**
+ * Returns the object referenced by this cross-reference entry.
+ * @return The object referenced by this cross-reference entry.
+ */
+ public PdfObject getObject() {
+ return object;
+ }
+
+ /**
+ * Sets the object referenced by this cross-reference entry.
+ * @param object The object referenced by this cross-reference entry.
+ */
+ public void setObject(final PdfObject object) {
+ this.object = object;
+ }
+
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfGraphicsState4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfGraphicsState4a.java 2022-01-27 12:17:01 UTC (rev 12483)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfGraphicsState4a.java 2022-01-27 13:22:30 UTC (rev 12484)
@@ -34,8 +34,6 @@
import org.axsl.pdf.PdfColor;
import org.axsl.pdf.PdfLineCapStyle;
-import lombok.Getter;
-
/**
* The PDF graphics state.
* Tracks the current state of various properties used to render content, such as colors and fonts.
@@ -47,41 +45,19 @@
*/
public class PdfGraphicsState4a {
- /**
- * The stroke color.
- * @return The stroke color.
- */
- @Getter
+ /** The stroke color. */
private PdfColor strokeColor;
- /**
- * The "non-stroke" or "other" color.
- * @return The non-stroke or other color.
- */
- @Getter
+ /** The "non-stroke" or "other" color. */
private PdfColor fillColor;
- /**
- * The text state.
- * @return The text state.
- */
- @Getter
+ /** The text state. */
private PdfTextState textState = new PdfTextState();
- /**
- * The line cap style.
- * @return The line cap style.
- * @see "PDF Reference, Sixth Edition (PDF Version 1.7), Section 4.3.2."
- */
- @Getter
+ /** The line cap style. */
private PdfLineCapStyle lineCapStyle;
- /**
- * The dash pattern.
- * @return The dash pattern.
- * @see "PDF Reference, Sixth Edition (PDF Version 1.7), Section 4.3.2."
- */
- @Getter
+ /** The dash pattern. */
private PdfDashPattern dashPattern;
/**
@@ -118,6 +94,14 @@
}
/**
+ * Returns the stroke color.
+ * @return The stroke color.
+ */
+ public PdfColor getStrokeColor() {
+ return strokeColor;
+ }
+
+ /**
* Sets the stroke color.
* @param newStrokeColor The new stroke color.
* @return True if and only if the Graphics State was changed by this operation.
@@ -136,6 +120,14 @@
}
/**
+ * Returns the non-stroke or "other" color.
+ * @return The non-stroke or other color.
+ */
+ public PdfColor getFillColor() {
+ return fillColor;
+ }
+
+ /**
* Sets the "non-stroke" or "other" or "fill" color.
* @param newFillColor The new non-stroke color.
* @return True if and only if the Graphics State was changed by this operation.
@@ -154,6 +146,23 @@
}
/**
+ * Returns the text state.
+ * @return The text state.
+ */
+ public PdfTextState getTextState() {
+ return textState;
+ }
+
+ /**
+ * Returns the line cap style.
+ * @return The line cap style.
+ * @see "PDF Reference, Sixth Edition (PDF Version 1.7), Section 4.3.2."
+ */
+ public PdfLineCapStyle getLineCapStyle() {
+ return lineCapStyle;
+ }
+
+ /**
* Sets the line cap style.
* @param newLineCapStyle The new line cap style.
* @return True if and only if the Graphics State was changed by this operation.
@@ -169,6 +178,15 @@
}
/**
+ * Returns the dash pattern.
+ * @return The dash pattern.
+ * @see "PDF Reference, Sixth Edition (PDF Version 1.7), Section 4.3.2."
+ */
+ public PdfDashPattern getDashPattern() {
+ return dashPattern;
+ }
+
+ /**
* Sets the line dash pattern.
* @param newDashPattern The new dash pattern.
* @return True if and only if the Graphics State was changed by this operation.
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfHeader.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfHeader.java 2022-01-27 12:17:01 UTC (rev 12483)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfHeader.java 2022-01-27 13:22:30 UTC (rev 12484)
@@ -34,9 +34,6 @@
import org.axsl.pdf.PdfVersion;
-import lombok.Getter;
-import lombok.Setter;
-
/**
* The header portion of a PDF document.
* @see "PDF Reference, Sixth Edition (PDF version 1.7), Section 3.4.1"
@@ -54,27 +51,13 @@
(byte) 0xAD
);
- /**
- * The version of PDF for this document.
- * @param pdfVersion The new value for the PDF version.
- * @return The PDF version.
- */
- @Getter
- @Setter
+ /** The version of PDF for this document. */
private PdfVersion pdfVersion;
- /**
- * The binary comment, written immediately after the header line, indicating to parsing applications that this
- * document may contain binary data.
- * @see "PDF Reference, Sixth Edition (PDF version 1.7), Section 3.4.1."
- * @param binaryComment The new value for the binary comment.
- * @return The binary comment.
- */
- @Getter
- @Setter
+ /** The binary comment, written immediately after the header line, indicating to parsing applications that this
+ * document may contain binary data. */
private ByteArray binaryComment;
-
public PdfHeader() {
this.pdfVersion = DEFAULT_PDF_VERSION;
this.binaryComment = DEFAULT_BINARY_COMMENT;
@@ -92,4 +75,39 @@
return builder;
}
+ /**
+ * Returns the version of PDF for this document.
+ * @return The PDF version.
+ */
+ public PdfVersion getPdfVersion() {
+ return pdfVersion;
+ }
+
+ /**
+ * Sets the PDF version for this document.
+ * @param pdfVersion The new value for the PDF version.
+ */
+ public void setPdfVersion(final PdfVersion pdfVersion) {
+ this.pdfVersion = pdfVersion;
+ }
+
+ /**
+ * Returns the binary comment, written immediately after the header line, indicating to parsing applications that
+ * this document may contain binary data.
+ * @see "PDF Reference, Sixth Edition (PDF version 1.7), Section 3.4.1."
+ * @return The binary comment.
+ */
+ public ByteArray getBinaryComment() {
+ return binaryComment;
+ }
+
+ /**
+ * Sets the binary comments.
+ * @param binaryComment The new value for the binary comment.
+ * @see #getBinaryComment()
+ */
+ public void setBinaryComment(final ByteArray binaryComment) {
+ this.binaryComment = binaryComment;
+ }
+
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfSerializationConfig4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfSerializationConfig4a.java 2022-01-27 12:17:01 UTC (rev 12483)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfSerializationConfig4a.java 2022-01-27 13:22:30 UTC (rev 12484)
@@ -30,8 +30,6 @@
import org.axsl.pdf.PdfSerializationConfig;
-import lombok.Setter;
-
/**
* Concrete implementaton of {@link PdfSerializationConfig}.
*/
@@ -40,11 +38,7 @@
/** The default line length of the output PDF document. */
public static final int DEFAULT_CHARACTERS_PER_LINE = 80;
- /**
- * The desired maximum length of lines in the serialized document.
- * @param maxLineLength The desired maximum length of lines in the serialized document.
- */
- @Setter
+ /** The desired maximum length of lines in the serialized document. */
private int maxLineLength;
/**
@@ -62,4 +56,12 @@
return this.maxLineLength;
}
+ /**
+ * Sets the desired maximum length of lines in the serialized document.
+ * @param maxLineLength The desired maximum length of lines in the serialized document.
+ */
+ public void setMaxLineLength(final int maxLineLength) {
+ this.maxLineLength = maxLineLength;
+ }
+
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfTextState.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfTextState.java 2022-01-27 12:17:01 UTC (rev 12483)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfTextState.java 2022-01-27 13:22:30 UTC (rev 12484)
@@ -31,8 +31,6 @@
import org.axsl.pdf.PdfFont;
import org.axsl.pdf.PdfTextRenderingMode;
-import lombok.Getter;
-
/**
* The text state for the PDF graphics state.
* @see "PDF Reference, Sixth Edition (PDF Version 1.7), Section 5.2."
@@ -42,74 +40,31 @@
/** Constant for the initial horizontal scaling percentage, that is 100%. */
public static final float INITIAL_HORIZONTAL_SCALING = 100;
- /**
- * The character spacing, expressed in unscaled text space units.
- * @see "PDF Reference, Sixth Edition (PDF Version 1.7), Section 5.2.1."
- * @return The character spacing.
- */
- @Getter
+ /** The character spacing, expressed in unscaled text space units. */
private float characterSpacing;
- /**
- * The word spacing, expressed in unscaled text space units.
- * @see "PDF Reference, Sixth Edition (PDF Version 1.7), Section 5.2.2."
- * @return The word spacing.
- */
- @Getter
+ /** The word spacing, expressed in unscaled text space units. */
private float wordSpacing;
- /**
- * The horizontal scaling, a percentage.
- * @see "PDF Reference, Sixth Edition (PDF Version 1.7), Section 5.2.3."
- * @return The horizontal scaling.
- */
- @Getter
+ /** The horizontal scaling, a percentage. */
private float horizontalScaling;
- /**
- * The text leading, expressed in unscaled text units.
- * @see "PDF Reference, Sixth Edition (PDF Version 1.7), Section 5.2.4."
- * @return The text leading.
- */
- @Getter
+ /** The text leading, expressed in unscaled text units. */
private float leading;
- /**
- * The font.
- * @return The font.
- */
- @Getter
+ /** The font. */
private PdfFont font;
- /**
- * The font size.
- * @return The font size.
- */
- @Getter
+ /** The font size. */
private float fontSize;
- /**
- * The text rendering mode.
- * @see "PDF Reference, Sixth Edition (PDF Version 1.7), Section 5.2.5."
- * @return The text rendering mode.
- */
- @Getter
+ /** The text rendering mode. */
private PdfTextRenderingMode textRenderingMode;
- /**
- * The text rise, expressed in unscaled text space units.
- * @see "PDF Reference, Sixth Edition (PDF Version 1.7), Section 5.2.6."
- * @return The text rise.
- */
- @Getter
+ /** The text rise, expressed in unscaled text space units. */
private float textRise;
- /**
- * The text knockout flag.
- * @see "PDF Reference, Sixth Edition (PDF Version 1.7), Section 5.2.7."
- * @return The text knockout.
- */
- @Getter
+ /** The text knockout flag. */
private boolean textKnockout;
/**
@@ -290,4 +245,83 @@
return anyChange;
}
+ /**
+ * Returns the character spacing.
+ * @return The character spacing, expressed in unscaled text space units.
+ * @see "PDF Reference, Sixth Edition (PDF Version 1.7), Section 5.2.1."
+ */
+ public float getCharacterSpacing() {
+ return characterSpacing;
+ }
+
+ /**
+ * Returns the word spacing.
+ * @return The word spacing, expressed in unscaled text space units.
+ * @see "PDF Reference, Sixth Edition (PDF Version 1.7), Section 5.2.2."
+ */
+ public float getWordSpacing() {
+ return wordSpacing;
+ }
+
+ /**
+ * Returns the horizontal scaling.
+ * @return The horizontal scaling, a percentage.
+ * @see "PDF Reference, Sixth Edition (PDF Version 1.7), Section 5.2.3."
+ */
+ public float getHorizontalScaling() {
+ return horizontalScaling;
+ }
+
+ /**
+ * Returns the text leading.
+ * @return The text leading, expressed in unscaled text units.
+ * @see "PDF Reference, Sixth Edition (PDF Version 1.7), Section 5.2.4."
+ */
+ public float getLeading() {
+ return leading;
+ }
+
+ /**
+ * Returns the font.
+ * @return The font.
+ */
+ public PdfFont getFont() {
+ return font;
+ }
+
+ /**
+ * Returns the font size.
+ * @return The font size.
+ */
+ public float getFontSize() {
+ return fontSize;
+ }
+
+ /**
+ * Returns the text rendering mode.
+ * @return The text rendering mode.
+ * @see "PDF Reference, Sixth Edition (PDF Version 1.7), Section 5.2.5."
+ */
+ public PdfTextRenderingMode getTextRenderingMode() {
+ return textRenderingMode;
+ }
+
+ /**
+ * Returns the text rise.
+ * @return The text rise, expressed in unscaled text space units.
+ * @see "PDF Reference, Sixth Edition (PDF Version 1.7), Section 5.2.6."
+ */
+ public float getTextRise() {
+ return textRise;
+ }
+
+ /**
+ * Returns the text knockout flag.
+ * @return The text knockout flag.
+ * @see "PDF Reference, Sixth Edition (PDF Version 1.7), Section 5.2.7."
+ */
+ public boolean isTextKnockout() {
+ return textKnockout;
+ }
+
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDashPattern.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDashPattern.java 2022-01-27 12:17:01 UTC (rev 12483)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDashPattern.java 2022-01-27 13:22:30 UTC (rev 12484)
@@ -28,8 +28,6 @@
package org.foray.pdf.object;
-import lombok.Getter;
-
/**
* A PDF Line Dash Pattern.
* Instances of this class are immutable.
@@ -46,18 +44,10 @@
/** Constant used to designate a "dashed" dash pattern. */
public static final PdfDashPattern DASHED = new PdfDashPattern(new float[] {3, 3}, 0);
- /**
- * The dash array.
- * @return The dash array.
- */
- @Getter
+ /** The dash array. */
private float[] dashArray;
- /**
- * The dash phase.
- * @return The dash phase.
- */
- @Getter
+ /** The dash phase. */
private float dashPhase;
public PdfDashPattern(final float[] dashArray, final float dashPhase) {
@@ -66,6 +56,22 @@
this.dashPhase = dashPhase;
}
+ /**
+ * Returns the dash array.
+ * @return The dash array.
+ */
+ public float[] getDashArray() {
+ return this.dashArray;
+ }
+
+ /**
+ * Returns the dash phase.
+ * @return The dash phase.
+ */
+ public float getDashPhase() {
+ return this.dashPhase;
+ }
+
@Override
public boolean equals(final Object other) {
if (other == null) {
Modified: trunk/foray/foray-unicode/src/main/java/org/foray/unicode/Block.java
===================================================================
--- trunk/foray/foray-unicode/src/main/java/org/foray/unicode/Block.java 2022-01-27 12:17:01 UTC (rev 12483)
+++ trunk/foray/foray-unicode/src/main/java/org/foray/unicode/Block.java 2022-01-27 13:22:30 UTC (rev 12484)
@@ -32,39 +32,21 @@
import java.util.Collections;
import java.util.List;
-import lombok.Getter;
-
/**
* The Unicode code blocks.
*/
public class Block {
- /**
- * The name of the code block.
- * @return The name of the code block.
- */
- @Getter
+ /** The name of the code block. */
private String name;
- /**
- * The first code point int the block.
- * @return The first code point int the block.
- */
- @Getter
+ /** The first code point in the block. */
private int start;
- /**
- * The last code point in the block.
- * @return The last code point in the block.
- */
- @Getter
+ /** The last code point in the block. */
private int end;
- /**
- * The list of known code points for this block, sorted by code point value.
- * @return The list of known code points for this block, sorted by code point value.
- */
- @Getter
+ /** The list of known code points for this block, sorted by code point value. */
private List<CodePoint> codePoints = new ArrayList<CodePoint>();
/**
@@ -80,6 +62,38 @@
}
/**
+ * Returns the name of the code block.
+ * @return The name of the code block.
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Returns the first code point in the block.
+ * @return The first code point in the block.
+ */
+ public int getStart() {
+ return this.start;
+ }
+
+ /**
+ * Returns the last code point in the block.
+ * @return The last code point in the block.
+ */
+ public int getEnd() {
+ return this.end;
+ }
+
+ /**
+ * Returns the list of known code points for this block, sorted by code point value.
+ * @return The list of known code points for this block, sorted by code point value.
+ */
+ public List<CodePoint> getCodePoints() {
+ return this.codePoints;
+ }
+
+ /**
* Returns a normalizes version of this block's name.
* @return The normalized block name.
* @see #normalizeName(String)
Modified: trunk/foray/foray-unicode/src/main/java/org/foray/unicode/CodePoint.java
===================================================================
--- trunk/foray/foray-unicode/src/main/java/org/foray/unicode/CodePoint.java 2022-01-27 12:17:01 UTC (rev 12483)
+++ trunk/foray/foray-unicode/src/main/java/org/foray/unicode/CodePoint.java 2022-01-27 13:22:30 UTC (rev 12484)
@@ -30,8 +30,6 @@
import java.util.Locale;
-import lombok.Getter;
-
/**
* A Unicode code point.
* @see "http://www.unicode.org/L2/L1999/UnicodeData.html"
@@ -86,25 +84,13 @@
/** Radix used to parse Base 16 integers, which is {@value}. */
private static final int BASE_16_RADIX = 16;
- /**
- * The numeric value assigned to this code point.
- * @return The numeric value assigned to this code point.
- */
- @Getter
+ /** The numeric value assigned to this code point. */
private int value;
- /**
- * The name of this code point.
- * @return The name of this code point.
- */
- @Getter
+ /** The name of this code point. */
private String name;
- /**
- * The Unicode 1.0 name.
- * @return The Unicode 1.0 name.
- */
- @Getter
+ /** The Unicode 1.0 name. */
private String unicode10Name;
/**
@@ -164,6 +150,30 @@
this.unicode10Name = unicode10Name;
}
+ /**
+ * Returns the numeric value assigned to this code point.
+ * @return The numeric value assigned to this code point.
+ */
+ public int getValue() {
+ return this.value;
+ }
+
+ /**
+ * Returns the name of this code point.
+ * @return The name of this code point.
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Returns the Unicode 1.0 name.
+ * @return The Unicode 1.0 name.
+ */
+ public String getUnicode10Name() {
+ return this.unicode10Name;
+ }
+
@Override
public int compareTo(final CodePoint o) {
return this.value - o.value;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-27 12:17:03
|
Revision: 12483
http://sourceforge.net/p/foray/code/12483
Author: victormote
Date: 2022-01-27 12:17:01 +0000 (Thu, 27 Jan 2022)
Log Message:
-----------
In an attempt to suppress the creation of unnecessary jar files during the build, move text-fixture gradle code from the general build to the only module that uses it.
Modified Paths:
--------------
trunk/foray/build.gradle
trunk/foray/foray-font/build.gradle
Modified: trunk/foray/build.gradle
===================================================================
--- trunk/foray/build.gradle 2022-01-27 01:30:42 UTC (rev 12482)
+++ trunk/foray/build.gradle 2022-01-27 12:17:01 UTC (rev 12483)
@@ -101,8 +101,6 @@
subprojects {
apply plugin: 'java-library'
- /* Allow creation of test fixtures. */
- apply plugin: 'java-test-fixtures'
apply plugin: 'checkstyle'
apply plugin: 'maven-publish'
apply plugin: 'io.freefair.lombok'
Modified: trunk/foray/foray-font/build.gradle
===================================================================
--- trunk/foray/foray-font/build.gradle 2022-01-27 01:30:42 UTC (rev 12482)
+++ trunk/foray/foray-font/build.gradle 2022-01-27 12:17:01 UTC (rev 12483)
@@ -1,5 +1,8 @@
description = 'foray-font'
+/* Allow creation of test fixtures. */
+apply plugin: 'java-test-fixtures'
+
dependencies {
api group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
api group: 'commons-io', name: 'commons-io', version: commonsIoVersion
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-27 01:30:44
|
Revision: 12482
http://sourceforge.net/p/foray/code/12482
Author: victormote
Date: 2022-01-27 01:30:42 +0000 (Thu, 27 Jan 2022)
Log Message:
-----------
Remove now-empty directory.
Removed Paths:
-------------
trunk/foray/foray-common/src/main/resources/resources/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-27 01:19:15
|
Revision: 12481
http://sourceforge.net/p/foray/code/12481
Author: victormote
Date: 2022-01-27 01:19:14 +0000 (Thu, 27 Jan 2022)
Log Message:
-----------
Remove externals link to DTDs in master. The link is outdated, but we shouldn't need this anymore anyway.
Property Changed:
----------------
trunk/foray/foray-common/src/main/resources/resources/org/foray/
Index: trunk/foray/foray-common/src/main/resources/resources/org/foray
===================================================================
--- trunk/foray/foray-common/src/main/resources/resources/org/foray 2022-01-27 00:48:46 UTC (rev 12480)
+++ trunk/foray/foray-common/src/main/resources/resources/org/foray 2022-01-27 01:19:14 UTC (rev 12481)
Property changes on: trunk/foray/foray-common/src/main/resources/resources/org/foray
___________________________________________________________________
Deleted: svn:externals
## -1 +0,0 ##
-https://svn.code.sf.net/p/foray/code/trunk/foray/master/doc/web/dtds dtds
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-27 00:48:50
|
Revision: 12480
http://sourceforge.net/p/foray/code/12480
Author: victormote
Date: 2022-01-27 00:48:46 +0000 (Thu, 27 Jan 2022)
Log Message:
-----------
Move and rename bookmark-related area tree types for clarity
Modified Paths:
--------------
trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaTree4a.java
Added Paths:
-----------
trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/
trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/BookmarkNode4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/BookmarkParentNode4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/BookmarkTitleArea4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/BookmarkTreeNode4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/DocumentMetadata4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/package-info.java
Removed Paths:
-------------
trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkParentArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkTitleArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkTreeArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/DocumentMetadata4a.java
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaTree4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaTree4a.java 2022-01-27 00:30:11 UTC (rev 12479)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaTree4a.java 2022-01-27 00:48:46 UTC (rev 12480)
@@ -31,6 +31,8 @@
import org.foray.area.link.Link;
import org.foray.area.link.LinkFactory;
import org.foray.area.link.NormalLink;
+import org.foray.area.metadata.BookmarkTreeNode4a;
+import org.foray.area.metadata.DocumentMetadata4a;
import org.axsl.area.AreaTree;
import org.axsl.area.AreaTreeException;
@@ -74,7 +76,7 @@
private List<PageCollection4a> children = new ArrayList<PageCollection4a>();
/** The bookmark tree for this document. */
- private BookmarkTreeArea bookmarkTreeArea;
+ private BookmarkTreeNode4a bookmarkTreeArea;
/** The metadata for this document. */
private DocumentMetadataG5 documentMetadata;
@@ -238,7 +240,7 @@
if (bookmarkTree == null) {
return;
}
- this.bookmarkTreeArea = BookmarkTreeArea.makeBookmarkTreeArea(
+ this.bookmarkTreeArea = BookmarkTreeNode4a.makeBookmarkTreeArea(
bookmarkTree, this);
for (int i = 0; i < bookmarkTree.qtyFormattingObjectChildren(); i++) {
final Bookmark bookmark = (Bookmark)
@@ -399,11 +401,10 @@
* @return The FoLinkage for {@code node}, or null if there is none.
*/
@SuppressWarnings("unchecked")
- protected <T extends Fo> Link<T> getFONodeLinkage(final T node) {
+ public <T extends Fo> Link<T> getFONodeLinkage(final T node) {
final int index = node.getSequentialIndex();
if (index < 0) {
- throw new IndexOutOfBoundsException("FONode has a negative "
- + "sequential Index.");
+ throw new IndexOutOfBoundsException("FONode has a negative sequential Index.");
}
if (index >= this.linkageMap.size()) {
return null;
@@ -431,7 +432,7 @@
}
@Override
- public BookmarkTreeArea getBookmarkTree() {
+ public BookmarkTreeNode4a getBookmarkTree() {
return this.bookmarkTreeArea;
}
Deleted: trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkArea.java 2022-01-27 00:30:11 UTC (rev 12479)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkArea.java 2022-01-27 00:48:46 UTC (rev 12480)
@@ -1,191 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.area;
-
-import org.foray.area.link.Link;
-
-import org.axsl.area.AreaTreeException;
-import org.axsl.font.Font;
-import org.axsl.fotree.Fo;
-import org.axsl.fotree.fo.Bookmark;
-import org.axsl.fotree.fo.BookmarkTitle;
-import org.axsl.galley.metadata.BookmarkG5;
-import org.axsl.galley.render.GalleyVisitor;
-import org.axsl.galley.render.GalleyVisitorException;
-import org.axsl.value.StartingState;
-
-import java.awt.Color;
-import java.net.URI;
-
-/**
- * The AreaTree representation of an fo:bookmark object.
- */
-public final class BookmarkArea extends BookmarkParentArea implements BookmarkG5 {
-
- /** The link to the FO tree. */
- private Bookmark foLink;
-
- /** The parent of this node. */
- private BookmarkParentArea parent;
-
- /** The title area for this bookmark. */
- private BookmarkTitleArea titleArea;
-
- /**
- * Private Constructor.
- * @param parentArea The parent area.
- */
- private BookmarkArea(final BookmarkParentArea parentArea) {
- this.parent = parentArea;
- }
-
- /**
- * Package-visible factory method.
- * @param generatedBy The FO node generating this area.
- * @param parentArea The parent area.
- * @return The new instance.
- */
- static BookmarkArea makeBookmarkArea(final Bookmark generatedBy,
- final BookmarkParentArea parentArea) {
- final BookmarkArea newBookmarkArea = new BookmarkArea(parentArea);
- newBookmarkArea.foLink = generatedBy;
- return newBookmarkArea;
- }
-
- /**
- * Returns the parent of this bookmark.
- * @return The parent of this bookmark.
- */
- public BookmarkParentArea getParent() {
- return this.parent;
- }
-
- /**
- * Return the bookmark title for this bookmark.
- * @return The bookmark title for this bookmark.
- */
- public BookmarkTitleArea getBookmarkTitle() {
- return this.titleArea;
- }
-
- /**
- * Lays out a bookmark title.
- * @param bookmarkTitle The bookmark title to be laid out.
- */
- protected void layoutBookmarkTitle(final BookmarkTitle bookmarkTitle) {
- final BookmarkTitleArea newTitleArea
- = BookmarkTitleArea.makeBookmarkTitleArea(bookmarkTitle,
- this);
- this.titleArea = newTitleArea;
- }
-
- /**
- * Creates the child areas for this bookmark area.
- * @param bookmark The "generated-by" Bookmark.
- */
- public void makeChildren(final Bookmark bookmark) {
- for (int i = 0; i < bookmark.qtyFormattingObjectChildren(); i++) {
- final Fo child = bookmark.formattingObjectChildAt(i);
- if (child instanceof Bookmark) {
- this.makeBookmarkArea((Bookmark) child);
- } else if (child instanceof BookmarkTitle) {
- this.layoutBookmarkTitle((BookmarkTitle) child);
- }
- }
- }
-
- /**
- * Returns the FO Tree bookmark node that created this.
- * @return The FO Tree bookmark.
- */
- public Bookmark traitGeneratedBy() {
- return this.foLink;
- }
-
- @Override
- public URI getExternalDestination() {
- return traitGeneratedBy().traitExternalDestination();
- }
-
- @Override
- public String getInternalDestination() {
- return traitGeneratedBy().traitInternalDestination();
- }
-
- @Override
- public String getTitleText() {
- return this.getBookmarkTitle().getTitleText();
- }
-
- @Override
- public Color traitColor() {
- return this.getBookmarkTitle().traitGeneratedBy().traitColor(null);
- }
-
- @Override
- public Font.Weight traitFontWeight() {
- return this.getBookmarkTitle().traitGeneratedBy().traitFontWeight(null);
- }
-
- @Override
- public Font.Style traitFontStyle() {
- return this.getBookmarkTitle().traitGeneratedBy().traitFontStyle(null);
- }
-
- @Override
- public StartingState traitStartingState() {
- return traitGeneratedBy().traitStartingState(this);
- }
-
- @Override
- public String getAreaName() {
- return "bookmark";
- }
-
- @Override
- public <T> T acceptVisitor(final GalleyVisitor<T> visitor) throws GalleyVisitorException {
- return visitor.visit(this);
- }
-
- @Override
- public void setParent(final AreaNode4a node) throws AreaTreeException {
- this.parent = (BookmarkParentArea) node;
- }
-
- @Override
- public Link<? extends Fo> getFoLink() {
- return getAreaTree().getFONodeLinkage(this.foLink);
- }
-
- @Override
- protected boolean optimize() {
- return false;
- }
-
-}
Deleted: trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkParentArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkParentArea.java 2022-01-27 00:30:11 UTC (rev 12479)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkParentArea.java 2022-01-27 00:48:46 UTC (rev 12480)
@@ -1,74 +0,0 @@
-/*
- * Copyright 2007 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.area;
-
-import org.axsl.fotree.fo.Bookmark;
-import org.axsl.galley.metadata.BookmarkParentG5;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Superclass for classes that can be parents of {@link BookmarkArea}s.
- */
-public abstract class BookmarkParentArea extends AreaNode4a implements BookmarkParentG5 {
-
- /** The children of this node. */
- private List<BookmarkArea> children = new ArrayList<BookmarkArea>();
-
- @Override
- public BookmarkArea areaNodeChildAt(final int childIndex) {
- return this.children.get(childIndex);
- }
-
- @Override
- public List<BookmarkArea> getChildren() {
- return this.children;
- }
-
- /**
- * Recursively lays out a bookmark.
- * @param bookmark The bookmark being laid out.
- */
- public void makeBookmarkArea(final Bookmark bookmark) {
- final BookmarkArea bookmarkArea = BookmarkArea.makeBookmarkArea(
- bookmark, this);
- this.addBookmarkAreaChild(bookmarkArea);
- bookmarkArea.makeChildren(bookmark);
- }
-
- /**
- * Adds a bookmark area as a child.
- * @param bookmarkArea The bookmark area to be added.
- */
- protected void addBookmarkAreaChild(final BookmarkArea bookmarkArea) {
- this.children.add(bookmarkArea);
- }
-
-}
Deleted: trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkTitleArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkTitleArea.java 2022-01-27 00:30:11 UTC (rev 12479)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkTitleArea.java 2022-01-27 00:48:46 UTC (rev 12480)
@@ -1,119 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.area;
-
-import org.axsl.font.Font;
-import org.axsl.fotree.fo.BookmarkTitle;
-
-import java.awt.Color;
-
-/**
- * The AreaTree representation of an fo:bookmark-title object.
- */
-public final class BookmarkTitleArea {
-
- /** The link to the FO tree. */
- private BookmarkTitle foLink;
-
- /** The parent of this node. */
- private BookmarkArea parent;
-
- /**
- * Private Constructor.
- * @param parentArea The parent area.
- */
- private BookmarkTitleArea(final BookmarkArea parentArea) {
- this.parent = parentArea;
- }
-
- /**
- * Constructor.
- * @param generatedBy The FO node generating this area.
- * @param parentArea The parent area.
- * @return The new instance.
- */
- static BookmarkTitleArea makeBookmarkTitleArea(
- final BookmarkTitle generatedBy, final BookmarkArea parentArea) {
- final BookmarkTitleArea newTitleArea = new BookmarkTitleArea(
- parentArea);
- newTitleArea.foLink = generatedBy;
- return newTitleArea;
- }
-
- /**
- * Return the text for this bookmark title.
- * @return The text for this bookmark title.
- */
- public String getTitleText() {
- final BookmarkTitle generatedBy = traitGeneratedBy();
- return generatedBy.getText();
- }
-
- /**
- * Returns the parent bookmark area.
- * @return The parent bookmark area.
- */
- public BookmarkArea getParent() {
- return this.parent;
- }
-
- /**
- * Returns the FO Tree bookmark-title object that generated this.
- * @return The FO Tree bookmark-title object that generated this.
- */
- public BookmarkTitle traitGeneratedBy() {
- return this.foLink;
- }
-
- /**
- * Returns the color of this node.
- * @return The color of this node.
- */
- public Color traitColor() {
- return traitGeneratedBy().traitColor(null);
- }
-
- /**
- * Returns the relative boldness of the font-family typeface that should be
- * used.
- * @return The font weight constant for this area.
- */
- public Font.Weight traitFontWeight() {
- return traitGeneratedBy().traitFontWeight(null);
- }
-
- /**
- * Returns the font style (normal, italic, etc.) for this area.
- * @return The font style.
- */
- public Font.Style traitFontStyle() {
- return traitGeneratedBy().traitFontStyle(null);
- }
-
-}
Deleted: trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkTreeArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkTreeArea.java 2022-01-27 00:30:11 UTC (rev 12479)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkTreeArea.java 2022-01-27 00:48:46 UTC (rev 12480)
@@ -1,116 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.area;
-
-import org.foray.area.link.Link;
-
-import org.axsl.area.AreaTreeException;
-import org.axsl.fotree.Fo;
-import org.axsl.fotree.fo.BookmarkTree;
-import org.axsl.galley.metadata.BookmarkTreeG5;
-import org.axsl.galley.render.GalleyVisitor;
-import org.axsl.galley.render.GalleyVisitorException;
-
-/**
- * A NonArea class for items generated by fo:bookmark-tree.
- */
-public final class BookmarkTreeArea extends BookmarkParentArea implements BookmarkTreeG5 {
-
- /** The link to the FO tree. */
- private BookmarkTree foLink;
-
- /** The parent of this node. */
- private AreaTree4a parent;
-
- /**
- * Private Constructor.
- * @param parentArea The parent area.
- */
- private BookmarkTreeArea(final AreaTree4a parentArea) {
- this.parent = parentArea;
- }
-
- /**
- * Package-visible factory method.
- * @param generatedBy The FO node generating this area.
- * @param parentArea The parent area.
- * @return The new instance.
- */
- static BookmarkTreeArea makeBookmarkTreeArea(final BookmarkTree generatedBy,
- final AreaTree4a parentArea) {
- final BookmarkTreeArea newBookmarkTreeArea = new BookmarkTreeArea(
- parentArea);
- newBookmarkTreeArea.foLink = generatedBy;
- return newBookmarkTreeArea;
- }
-
- @Override
- public AreaTree4a getParent() {
- return this.parent;
- }
-
- /**
- * Returns the FO Tree node that generated this bookmark tree.
- * @return The FO Tree node that generated this bookmark tree.
- */
- public BookmarkTree getGeneratedBy() {
- return this.foLink;
- }
-
- @Override
- public String getAreaName() {
- return "bookmark-tree";
- }
-
- @Override
- public <T> T acceptVisitor(final GalleyVisitor<T> visitor) throws GalleyVisitorException {
- return visitor.visit(this);
- }
-
- @Override
- public void setParent(final AreaNode4a node) throws AreaTreeException {
- this.parent = (AreaTree4a) node;
- }
-
- @Override
- public Fo traitGeneratedBy() {
- return this.foLink;
- }
-
- @Override
- public Link<? extends Fo> getFoLink() {
- return getAreaTree().getFONodeLinkage(this.foLink);
- }
-
- @Override
- protected boolean optimize() {
- return false;
- }
-
-}
Deleted: trunk/foray/foray-areatree/src/main/java/org/foray/area/DocumentMetadata4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/DocumentMetadata4a.java 2022-01-27 00:30:11 UTC (rev 12479)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/DocumentMetadata4a.java 2022-01-27 00:48:46 UTC (rev 12480)
@@ -1,117 +0,0 @@
-/*
- * Copyright 2022 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.area;
-
-import org.foray.area.link.Link;
-import org.foray.common.MarkedIndexOutOfBoundsException;
-
-import org.axsl.area.AreaTreeException;
-import org.axsl.fotree.Fo;
-import org.axsl.galley.metadata.DocumentMetadataG5;
-import org.axsl.galley.render.GalleyVisitor;
-import org.axsl.galley.render.GalleyVisitorException;
-
-import java.util.Collections;
-import java.util.List;
-
-public class DocumentMetadata4a extends AreaNode4a implements DocumentMetadataG5 {
-
- /** The parent area tree. */
- private AreaTree4a parent;
-
- public DocumentMetadata4a(final AreaTree4a parent) {
- this.parent = parent;
- }
-
- @Override
- public AreaTree4a getParent() {
- return this.parent;
- }
-
- @Override
- public String getAreaName() {
- return "document-metadata";
- }
-
- @Override
- public <T> T acceptVisitor(final GalleyVisitor<T> visitor) throws GalleyVisitorException {
- return visitor.visit(this);
- }
-
- @Override
- public void setParent(final AreaNode4a node) throws AreaTreeException {
- this.parent = (AreaTree4a) node;
- }
-
- @Override
- public List<? extends AreaNode4a> getChildren() {
- return Collections.emptyList();
- }
-
- @Override
- public AreaNode4a areaNodeChildAt(final int childIndex) {
- throw new MarkedIndexOutOfBoundsException(childIndex, 0);
- }
-
- @Override
- public Fo traitGeneratedBy() {
- return this.traitGeneratedBy();
- }
-
- @Override
- public Link<? extends Fo> getFoLink() {
- return null;
- }
-
- @Override
- protected boolean optimize() {
- return false;
- }
-
- @Override
- public String getTitle() {
- return this.parent.traitGeneratedBy().getTitle();
- }
-
- @Override
- public String getAuthor() {
- return this.parent.traitGeneratedBy().getAuthor();
- }
-
- @Override
- public String getSubject() {
- return this.parent.traitGeneratedBy().getSubject();
- }
-
- @Override
- public String getKeywords() {
- return this.parent.traitGeneratedBy().getKeywords();
- }
-
-}
Copied: trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/BookmarkNode4a.java (from rev 12479, trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkArea.java)
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/BookmarkNode4a.java (rev 0)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/BookmarkNode4a.java 2022-01-27 00:48:46 UTC (rev 12480)
@@ -0,0 +1,192 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.area.metadata;
+
+import org.foray.area.AreaNode4a;
+import org.foray.area.link.Link;
+
+import org.axsl.area.AreaTreeException;
+import org.axsl.font.Font;
+import org.axsl.fotree.Fo;
+import org.axsl.fotree.fo.Bookmark;
+import org.axsl.fotree.fo.BookmarkTitle;
+import org.axsl.galley.metadata.BookmarkG5;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
+import org.axsl.value.StartingState;
+
+import java.awt.Color;
+import java.net.URI;
+
+/**
+ * The AreaTree representation of an fo:bookmark object.
+ */
+public final class BookmarkNode4a extends BookmarkParentNode4a implements BookmarkG5 {
+
+ /** The link to the FO tree. */
+ private Bookmark foLink;
+
+ /** The parent of this node. */
+ private BookmarkParentNode4a parent;
+
+ /** The title area for this bookmark. */
+ private BookmarkTitleArea4a titleArea;
+
+ /**
+ * Private Constructor.
+ * @param parentArea The parent area.
+ */
+ private BookmarkNode4a(final BookmarkParentNode4a parentArea) {
+ this.parent = parentArea;
+ }
+
+ /**
+ * Package-visible factory method.
+ * @param generatedBy The FO node generating this area.
+ * @param parentArea The parent area.
+ * @return The new instance.
+ */
+ static BookmarkNode4a makeBookmarkArea(final Bookmark generatedBy,
+ final BookmarkParentNode4a parentArea) {
+ final BookmarkNode4a newBookmarkArea = new BookmarkNode4a(parentArea);
+ newBookmarkArea.foLink = generatedBy;
+ return newBookmarkArea;
+ }
+
+ /**
+ * Returns the parent of this bookmark.
+ * @return The parent of this bookmark.
+ */
+ public BookmarkParentNode4a getParent() {
+ return this.parent;
+ }
+
+ /**
+ * Return the bookmark title for this bookmark.
+ * @return The bookmark title for this bookmark.
+ */
+ public BookmarkTitleArea4a getBookmarkTitle() {
+ return this.titleArea;
+ }
+
+ /**
+ * Lays out a bookmark title.
+ * @param bookmarkTitle The bookmark title to be laid out.
+ */
+ protected void layoutBookmarkTitle(final BookmarkTitle bookmarkTitle) {
+ final BookmarkTitleArea4a newTitleArea
+ = BookmarkTitleArea4a.makeBookmarkTitleArea(bookmarkTitle,
+ this);
+ this.titleArea = newTitleArea;
+ }
+
+ /**
+ * Creates the child areas for this bookmark area.
+ * @param bookmark The "generated-by" Bookmark.
+ */
+ public void makeChildren(final Bookmark bookmark) {
+ for (int i = 0; i < bookmark.qtyFormattingObjectChildren(); i++) {
+ final Fo child = bookmark.formattingObjectChildAt(i);
+ if (child instanceof Bookmark) {
+ this.makeBookmarkArea((Bookmark) child);
+ } else if (child instanceof BookmarkTitle) {
+ this.layoutBookmarkTitle((BookmarkTitle) child);
+ }
+ }
+ }
+
+ /**
+ * Returns the FO Tree bookmark node that created this.
+ * @return The FO Tree bookmark.
+ */
+ public Bookmark traitGeneratedBy() {
+ return this.foLink;
+ }
+
+ @Override
+ public URI getExternalDestination() {
+ return traitGeneratedBy().traitExternalDestination();
+ }
+
+ @Override
+ public String getInternalDestination() {
+ return traitGeneratedBy().traitInternalDestination();
+ }
+
+ @Override
+ public String getTitleText() {
+ return this.getBookmarkTitle().getTitleText();
+ }
+
+ @Override
+ public Color traitColor() {
+ return this.getBookmarkTitle().traitGeneratedBy().traitColor(null);
+ }
+
+ @Override
+ public Font.Weight traitFontWeight() {
+ return this.getBookmarkTitle().traitGeneratedBy().traitFontWeight(null);
+ }
+
+ @Override
+ public Font.Style traitFontStyle() {
+ return this.getBookmarkTitle().traitGeneratedBy().traitFontStyle(null);
+ }
+
+ @Override
+ public StartingState traitStartingState() {
+ return traitGeneratedBy().traitStartingState(this);
+ }
+
+ @Override
+ public String getAreaName() {
+ return "bookmark";
+ }
+
+ @Override
+ public <T> T acceptVisitor(final GalleyVisitor<T> visitor) throws GalleyVisitorException {
+ return visitor.visit(this);
+ }
+
+ @Override
+ public void setParent(final AreaNode4a node) throws AreaTreeException {
+ this.parent = (BookmarkParentNode4a) node;
+ }
+
+ @Override
+ public Link<? extends Fo> getFoLink() {
+ return getAreaTree().getFONodeLinkage(this.foLink);
+ }
+
+ @Override
+ protected boolean optimize() {
+ return false;
+ }
+
+}
Copied: trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/BookmarkParentNode4a.java (from rev 12476, trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkParentArea.java)
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/BookmarkParentNode4a.java (rev 0)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/BookmarkParentNode4a.java 2022-01-27 00:48:46 UTC (rev 12480)
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2007 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.area.metadata;
+
+import org.foray.area.AreaNode4a;
+
+import org.axsl.fotree.fo.Bookmark;
+import org.axsl.galley.metadata.BookmarkParentG5;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Superclass for classes that can be parents of {@link BookmarkNode4a}s.
+ */
+public abstract class BookmarkParentNode4a extends AreaNode4a implements BookmarkParentG5 {
+
+ /** The children of this node. */
+ private List<BookmarkNode4a> children = new ArrayList<BookmarkNode4a>();
+
+ @Override
+ public BookmarkNode4a areaNodeChildAt(final int childIndex) {
+ return this.children.get(childIndex);
+ }
+
+ @Override
+ public List<BookmarkNode4a> getChildren() {
+ return this.children;
+ }
+
+ /**
+ * Recursively lays out a bookmark.
+ * @param bookmark The bookmark being laid out.
+ */
+ public void makeBookmarkArea(final Bookmark bookmark) {
+ final BookmarkNode4a bookmarkArea = BookmarkNode4a.makeBookmarkArea(
+ bookmark, this);
+ this.addBookmarkAreaChild(bookmarkArea);
+ bookmarkArea.makeChildren(bookmark);
+ }
+
+ /**
+ * Adds a bookmark area as a child.
+ * @param bookmarkArea The bookmark area to be added.
+ */
+ protected void addBookmarkAreaChild(final BookmarkNode4a bookmarkArea) {
+ this.children.add(bookmarkArea);
+ }
+
+}
Copied: trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/BookmarkTitleArea4a.java (from rev 12426, trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkTitleArea.java)
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/BookmarkTitleArea4a.java (rev 0)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/BookmarkTitleArea4a.java 2022-01-27 00:48:46 UTC (rev 12480)
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.area.metadata;
+
+import org.axsl.font.Font;
+import org.axsl.fotree.fo.BookmarkTitle;
+
+import java.awt.Color;
+
+/**
+ * The AreaTree representation of an fo:bookmark-title object.
+ */
+public final class BookmarkTitleArea4a {
+
+ /** The link to the FO tree. */
+ private BookmarkTitle foLink;
+
+ /** The parent of this node. */
+ private BookmarkNode4a parent;
+
+ /**
+ * Private Constructor.
+ * @param parentArea The parent area.
+ */
+ private BookmarkTitleArea4a(final BookmarkNode4a parentArea) {
+ this.parent = parentArea;
+ }
+
+ /**
+ * Constructor.
+ * @param generatedBy The FO node generating this area.
+ * @param parentArea The parent area.
+ * @return The new instance.
+ */
+ static BookmarkTitleArea4a makeBookmarkTitleArea(
+ final BookmarkTitle generatedBy, final BookmarkNode4a parentArea) {
+ final BookmarkTitleArea4a newTitleArea = new BookmarkTitleArea4a(
+ parentArea);
+ newTitleArea.foLink = generatedBy;
+ return newTitleArea;
+ }
+
+ /**
+ * Return the text for this bookmark title.
+ * @return The text for this bookmark title.
+ */
+ public String getTitleText() {
+ final BookmarkTitle generatedBy = traitGeneratedBy();
+ return generatedBy.getText();
+ }
+
+ /**
+ * Returns the parent bookmark area.
+ * @return The parent bookmark area.
+ */
+ public BookmarkNode4a getParent() {
+ return this.parent;
+ }
+
+ /**
+ * Returns the FO Tree bookmark-title object that generated this.
+ * @return The FO Tree bookmark-title object that generated this.
+ */
+ public BookmarkTitle traitGeneratedBy() {
+ return this.foLink;
+ }
+
+ /**
+ * Returns the color of this node.
+ * @return The color of this node.
+ */
+ public Color traitColor() {
+ return traitGeneratedBy().traitColor(null);
+ }
+
+ /**
+ * Returns the relative boldness of the font-family typeface that should be
+ * used.
+ * @return The font weight constant for this area.
+ */
+ public Font.Weight traitFontWeight() {
+ return traitGeneratedBy().traitFontWeight(null);
+ }
+
+ /**
+ * Returns the font style (normal, italic, etc.) for this area.
+ * @return The font style.
+ */
+ public Font.Style traitFontStyle() {
+ return traitGeneratedBy().traitFontStyle(null);
+ }
+
+}
Copied: trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/BookmarkTreeNode4a.java (from rev 12477, trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkTreeArea.java)
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/BookmarkTreeNode4a.java (rev 0)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/BookmarkTreeNode4a.java 2022-01-27 00:48:46 UTC (rev 12480)
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.area.metadata;
+
+import org.foray.area.AreaNode4a;
+import org.foray.area.AreaTree4a;
+import org.foray.area.link.Link;
+
+import org.axsl.area.AreaTreeException;
+import org.axsl.fotree.Fo;
+import org.axsl.fotree.fo.BookmarkTree;
+import org.axsl.galley.metadata.BookmarkTreeG5;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
+
+/**
+ * A NonArea class for items generated by fo:bookmark-tree.
+ */
+public final class BookmarkTreeNode4a extends BookmarkParentNode4a implements BookmarkTreeG5 {
+
+ /** The link to the FO tree. */
+ private BookmarkTree foLink;
+
+ /** The parent of this node. */
+ private AreaTree4a parent;
+
+ /**
+ * Private Constructor.
+ * @param parentArea The parent area.
+ */
+ private BookmarkTreeNode4a(final AreaTree4a parentArea) {
+ this.parent = parentArea;
+ }
+
+ /**
+ * Package-visible factory method.
+ * @param generatedBy The FO node generating this area.
+ * @param parentArea The parent area.
+ * @return The new instance.
+ */
+ public static BookmarkTreeNode4a makeBookmarkTreeArea(final BookmarkTree generatedBy,
+ final AreaTree4a parentArea) {
+ final BookmarkTreeNode4a newBookmarkTreeArea = new BookmarkTreeNode4a(
+ parentArea);
+ newBookmarkTreeArea.foLink = generatedBy;
+ return newBookmarkTreeArea;
+ }
+
+ @Override
+ public AreaTree4a getParent() {
+ return this.parent;
+ }
+
+ /**
+ * Returns the FO Tree node that generated this bookmark tree.
+ * @return The FO Tree node that generated this bookmark tree.
+ */
+ public BookmarkTree getGeneratedBy() {
+ return this.foLink;
+ }
+
+ @Override
+ public String getAreaName() {
+ return "bookmark-tree";
+ }
+
+ @Override
+ public <T> T acceptVisitor(final GalleyVisitor<T> visitor) throws GalleyVisitorException {
+ return visitor.visit(this);
+ }
+
+ @Override
+ public void setParent(final AreaNode4a node) throws AreaTreeException {
+ this.parent = (AreaTree4a) node;
+ }
+
+ @Override
+ public Fo traitGeneratedBy() {
+ return this.foLink;
+ }
+
+ @Override
+ public Link<? extends Fo> getFoLink() {
+ return getAreaTree().getFONodeLinkage(this.foLink);
+ }
+
+ @Override
+ protected boolean optimize() {
+ return false;
+ }
+
+}
Copied: trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/DocumentMetadata4a.java (from rev 12477, trunk/foray/foray-areatree/src/main/java/org/foray/area/DocumentMetadata4a.java)
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/DocumentMetadata4a.java (rev 0)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/DocumentMetadata4a.java 2022-01-27 00:48:46 UTC (rev 12480)
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2022 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.area.metadata;
+
+import org.foray.area.AreaNode4a;
+import org.foray.area.AreaTree4a;
+import org.foray.area.link.Link;
+import org.foray.common.MarkedIndexOutOfBoundsException;
+
+import org.axsl.area.AreaTreeException;
+import org.axsl.fotree.Fo;
+import org.axsl.galley.metadata.DocumentMetadataG5;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
+
+import java.util.Collections;
+import java.util.List;
+
+public class DocumentMetadata4a extends AreaNode4a implements DocumentMetadataG5 {
+
+ /** The parent area tree. */
+ private AreaTree4a parent;
+
+ public DocumentMetadata4a(final AreaTree4a parent) {
+ this.parent = parent;
+ }
+
+ @Override
+ public AreaTree4a getParent() {
+ return this.parent;
+ }
+
+ @Override
+ public String getAreaName() {
+ return "document-metadata";
+ }
+
+ @Override
+ public <T> T acceptVisitor(final GalleyVisitor<T> visitor) throws GalleyVisitorException {
+ return visitor.visit(this);
+ }
+
+ @Override
+ public void setParent(final AreaNode4a node) throws AreaTreeException {
+ this.parent = (AreaTree4a) node;
+ }
+
+ @Override
+ public List<? extends AreaNode4a> getChildren() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public AreaNode4a areaNodeChildAt(final int childIndex) {
+ throw new MarkedIndexOutOfBoundsException(childIndex, 0);
+ }
+
+ @Override
+ public Fo traitGeneratedBy() {
+ return this.traitGeneratedBy();
+ }
+
+ @Override
+ public Link<? extends Fo> getFoLink() {
+ return null;
+ }
+
+ @Override
+ protected boolean optimize() {
+ return false;
+ }
+
+ @Override
+ public String getTitle() {
+ return this.parent.traitGeneratedBy().getTitle();
+ }
+
+ @Override
+ public String getAuthor() {
+ return this.parent.traitGeneratedBy().getAuthor();
+ }
+
+ @Override
+ public String getSubject() {
+ return this.parent.traitGeneratedBy().getSubject();
+ }
+
+ @Override
+ public String getKeywords() {
+ return this.parent.traitGeneratedBy().getKeywords();
+ }
+
+}
Added: trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/package-info.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/package-info.java (rev 0)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/package-info.java 2022-01-27 00:48:46 UTC (rev 12480)
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2022 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+/**
+ * FOray implementations of aXSL Galley bookmark- and metadata-related interfaces.
+ */
+package org.foray.area.metadata;
Property changes on: trunk/foray/foray-areatree/src/main/java/org/foray/area/metadata/package-info.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-27 00:30:13
|
Revision: 12479
http://sourceforge.net/p/foray/code/12479
Author: victormote
Date: 2022-01-27 00:30:11 +0000 (Thu, 27 Jan 2022)
Log Message:
-----------
Conform to aXSL change: Add method to return the starting state for the bookmark.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkArea.java
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkArea.java 2022-01-27 00:23:27 UTC (rev 12478)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkArea.java 2022-01-27 00:30:11 UTC (rev 12479)
@@ -38,6 +38,7 @@
import org.axsl.galley.metadata.BookmarkG5;
import org.axsl.galley.render.GalleyVisitor;
import org.axsl.galley.render.GalleyVisitorException;
+import org.axsl.value.StartingState;
import java.awt.Color;
import java.net.URI;
@@ -158,6 +159,11 @@
}
@Override
+ public StartingState traitStartingState() {
+ return traitGeneratedBy().traitStartingState(this);
+ }
+
+ @Override
public String getAreaName() {
return "bookmark";
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-27 00:23:29
|
Revision: 12478
http://sourceforge.net/p/foray/code/12478
Author: victormote
Date: 2022-01-27 00:23:27 +0000 (Thu, 27 Jan 2022)
Log Message:
-----------
Partially activate pushing fo:bookmark instances into PDF.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java
Added Paths:
-----------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineParent4a.java
Removed Paths:
-------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineParent.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java 2022-01-26 23:42:01 UTC (rev 12477)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfDocument4a.java 2022-01-27 00:23:27 UTC (rev 12478)
@@ -260,7 +260,7 @@
}
@Override
- public PdfOutlineParent getOutlineRoot() {
+ public PdfOutlineParent4a getOutlineRoot() {
return this.root.getOutlineRoot();
}
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline.java 2022-01-26 23:42:01 UTC (rev 12477)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline.java 2022-01-27 00:23:27 UTC (rev 12478)
@@ -1,64 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-/**
- * An Outline dictionary in PDF.
- * See PDF Reference 3rd Edition, Section 8.2.2.
- */
-public class PdfOutline extends PdfOutlineParent {
-
- /**
- * Returns the total number of open items at all levels of the outline.
- * @return The total number of open items at all levels of the outline.
- * @see "PDF Reference, 3rd Edition, Table 8.3.3"
- */
- protected int count() {
- // no count... we start with the outline completely closed for now
- return 0;
- }
-
- @Override
- public String toPDF(final PdfDocument4a doc) {
- final StringBuilder result = new StringBuilder();
- result.append(this.pdfID() + EOL);
- result.append("<<" + EOL);
- result.append(" /Type /Outlines" + EOL);
- if (getFirst() != null && getLast() != null) {
- result.append(" /First " + getFirst().pdfReference(doc) + EOL);
- result.append(" /Last " + getLast().pdfReference(doc) + EOL);
- }
- if (count() > 0) {
- result.append(" /Count " + count() + EOL);
- }
- result.append(">> endobj" + EOL);
- return result.toString();
- }
-
-}
Copied: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline4a.java (from rev 12426, trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline.java)
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline4a.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutline4a.java 2022-01-27 00:23:27 UTC (rev 12478)
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf.object;
+
+import org.foray.common.primitive.StringUtils;
+
+/**
+ * An Outline dictionary in PDF.
+ * See PDF Reference 3rd Edition, Section 8.2.2.
+ */
+public class PdfOutline4a extends PdfOutlineParent4a {
+
+ /**
+ * Returns the total number of open items at all levels of the outline.
+ * @return The total number of open items at all levels of the outline.
+ * @see "PDF Reference, 3rd Edition, Table 8.3.3"
+ */
+ protected int count() {
+ // no count... we start with the outline completely closed for now
+ return 0;
+ }
+
+ @Override
+ public String toPDF(final PdfDocument4a doc) {
+ if (this.getChildren().size() < 1) {
+ return StringUtils.EMPTY_STRING;
+ }
+ final StringBuilder result = new StringBuilder();
+ result.append(this.pdfID() + EOL);
+ result.append("<<" + EOL);
+ result.append(" /Type /Outlines" + EOL);
+ if (getFirst() != null && getLast() != null) {
+ result.append(" /First " + getFirst().pdfReference(doc) + EOL);
+ result.append(" /Last " + getLast().pdfReference(doc) + EOL);
+ }
+ if (count() > 0) {
+ result.append(" /Count " + count() + EOL);
+ }
+ result.append(">> endobj" + EOL);
+ return result.toString();
+ }
+
+}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java 2022-01-26 23:42:01 UTC (rev 12477)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineItem4a.java 2022-01-27 00:23:27 UTC (rev 12478)
@@ -39,11 +39,11 @@
* An Outline Item Dictionary in PDF.
*/
-public class PdfOutlineItem4a extends PdfOutlineParent
+public class PdfOutlineItem4a extends PdfOutlineParent4a
implements org.axsl.pdf.PdfOutlineItem {
/** The parent object. */
- private PdfOutlineParent parent;
+ private PdfOutlineParent4a parent;
/** The title to display for the bookmark entry. */
private PdfTextString title;
@@ -94,7 +94,7 @@
* @param bold Indciates whether the outline item should be displayed in a
* bold font.
*/
- private PdfOutlineItem4a(final PdfOutlineParent parent,
+ private PdfOutlineItem4a(final PdfOutlineParent4a parent,
final String title, final Color color, final boolean italic,
final boolean bold) {
this.parent = parent;
@@ -119,7 +119,7 @@
* @param bold Indciates whether the outline item should be displayed in a
* bold font.
*/
- public PdfOutlineItem4a(final PdfOutlineParent parent,
+ public PdfOutlineItem4a(final PdfOutlineParent4a parent,
final String title, final String destinationString,
final Color color, final boolean italic, final boolean bold) {
this(parent, title, color, italic, bold);
@@ -138,7 +138,7 @@
* @param bold Indciates whether the outline item should be displayed in a
* bold font.
*/
- public PdfOutlineItem4a(final PdfOutlineParent parent,
+ public PdfOutlineItem4a(final PdfOutlineParent4a parent,
final String title, final PdfDestination4a destination,
final Color color, final boolean italic, final boolean bold) {
this(parent, title, color, italic, bold);
@@ -157,7 +157,7 @@
* @param bold Indciates whether the outline item should be displayed in a
* bold font.
*/
- public PdfOutlineItem4a(final PdfOutlineParent parent,
+ public PdfOutlineItem4a(final PdfOutlineParent4a parent,
final String title, final PdfAction action, final Color color,
final boolean italic, final boolean bold) {
this(parent, title, color, italic, bold);
@@ -169,8 +169,8 @@
* @return The sibling outline items.
*/
private List<PdfOutlineItem4a> getSiblings() {
- if (this.parent instanceof PdfOutline) {
- return ((PdfOutline) this.parent).getChildren();
+ if (this.parent instanceof PdfOutline4a) {
+ return ((PdfOutline4a) this.parent).getChildren();
}
if (this.parent instanceof PdfOutlineItem4a) {
return ((PdfOutlineItem4a) this.parent).getChildren();
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineParent.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineParent.java 2022-01-26 23:42:01 UTC (rev 12477)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineParent.java 2022-01-27 00:23:27 UTC (rev 12478)
@@ -1,99 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf.object;
-
-import java.awt.Color;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Abstract superclass for PDFObjects that can be parents of a PdfOutlineItem4a
- * object. This includes the classes PdfOutline and PdfOutlineItem4a.
- */
-
-public abstract class PdfOutlineParent extends PdfObject
- implements org.axsl.pdf.PdfOutlineParent {
-
- /** Collection of child PdfOutline objects. */
- private List<PdfOutlineItem4a> children = new ArrayList<PdfOutlineItem4a>();
-
- /**
- * Add a child to this parent.
- * @param child The child to be added.
- */
- public void addChild(final PdfOutlineItem4a child) {
- this.children.add(child);
- }
-
- /**
- * Return the children of this parent.
- * @return The children of this parent.
- */
- public List<PdfOutlineItem4a> getChildren() {
- return this.children;
- }
-
- /**
- * Return the first child of this parent.
- * @return The first child of this parent.
- */
- protected PdfOutlineItem4a getFirst() {
- if (this.children == null
- || this.children.size() < 1) {
- return null;
- }
- return this.children.get(0);
- }
-
- /**
- * Return the last child of this parent.
- * @return The last child of this parent.
- */
- protected PdfOutlineItem4a getLast() {
- if (this.children == null
- || this.children.size() < 1) {
- return null;
- }
- return this.children.get(this.children.size() - 1);
- }
-
- /**
- * Return the total number of descendants.
- * @return The total number of descendants.
- */
- protected abstract int count();
-
- @Override
- public PdfOutlineItem4a createPdfOutlineItem(
- final String titleText, final String internalDestination,
- final Color color, final boolean italic, final boolean bold) {
- return new PdfOutlineItem4a(this, titleText, internalDestination, color, italic, bold);
- }
-
-}
Copied: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineParent4a.java (from rev 12426, trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineParent.java)
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineParent4a.java (rev 0)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfOutlineParent4a.java 2022-01-27 00:23:27 UTC (rev 12478)
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf.object;
+
+import java.awt.Color;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Abstract superclass for PDFObjects that can be parents of a PdfOutlineItem4a
+ * object. This includes the classes PdfOutline and PdfOutlineItem4a.
+ */
+
+public abstract class PdfOutlineParent4a extends PdfObject
+ implements org.axsl.pdf.PdfOutlineParent {
+
+ /** Collection of child PdfOutline objects. */
+ private List<PdfOutlineItem4a> children = new ArrayList<PdfOutlineItem4a>();
+
+ /**
+ * Add a child to this parent.
+ * @param child The child to be added.
+ */
+ public void addChild(final PdfOutlineItem4a child) {
+ this.children.add(child);
+ }
+
+ /**
+ * Return the children of this parent.
+ * @return The children of this parent.
+ */
+ public List<PdfOutlineItem4a> getChildren() {
+ return this.children;
+ }
+
+ /**
+ * Return the first child of this parent.
+ * @return The first child of this parent.
+ */
+ protected PdfOutlineItem4a getFirst() {
+ if (this.children == null
+ || this.children.size() < 1) {
+ return null;
+ }
+ return this.children.get(0);
+ }
+
+ /**
+ * Return the last child of this parent.
+ * @return The last child of this parent.
+ */
+ protected PdfOutlineItem4a getLast() {
+ if (this.children == null
+ || this.children.size() < 1) {
+ return null;
+ }
+ return this.children.get(this.children.size() - 1);
+ }
+
+ /**
+ * Return the total number of descendants.
+ * @return The total number of descendants.
+ */
+ protected abstract int count();
+
+ @Override
+ public PdfOutlineItem4a createPdfOutlineItem(
+ final String titleText, final String internalDestination,
+ final Color color, final boolean italic, final boolean bold) {
+ return new PdfOutlineItem4a(this, titleText, internalDestination, color, italic, bold);
+ }
+
+}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java 2022-01-26 23:42:01 UTC (rev 12477)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java 2022-01-27 00:23:27 UTC (rev 12478)
@@ -48,8 +48,8 @@
* document. */
private PdfNumberTree<PdfPageLabel> pageLabels;
- /** The root outline object. */
- private PdfOutline outline;
+ /** The root outline object. Lazily created, to avoid unnecessary objects. */
+ private PdfOutline4a outline;
/** Collection of destinations. */
private PdfNameTree<PdfDestination4a> destinations;
@@ -125,10 +125,13 @@
}
/**
- * Returns the root Outlines object.
+ * Returns the root Outlines object, creating it if necessary.
* @return The root Outlines object.
*/
- public PdfOutline getOutlineRoot() {
+ public PdfOutline4a getOutlineRoot() {
+ if (this.outline == null) {
+ this.outline = new PdfOutline4a();
+ }
return this.outline;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-26 23:42:04
|
Revision: 12477
http://sourceforge.net/p/foray/code/12477
Author: victormote
Date: 2022-01-26 23:42:01 +0000 (Wed, 26 Jan 2022)
Log Message:
-----------
Conform to aXSL changes: Move metadata- and rendering-related types to new packages.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/main/java/org/foray/area/AbstractListItemContent.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaTree4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/BasicLinkArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/BeforeFloatRa4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/BidiOverrideArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/BlockContainerRa.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkTreeArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/DocumentMetadata4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/ExternalGraphicArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/FootnoteRa4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/ForeignObjectArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/IndexPageCitationListArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/InlineArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/InlineContainerArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/LeaderArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/ListBlockArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/ListItemArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/MainRa4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/NormalBlockArea4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/NormalFlowRa4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/PageCollection4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/PageNumberArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/PageNumberCitationArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/PageNumberCitationLastArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/PageRa4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/RegionBodyRa4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/RegionOuterRa4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/RetrieveMarkerNode4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/RetrieveTableMarkerNode4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/ScalingValueCitationArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/SpanRa4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/TableBodyContainer4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/TableCellRa.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/TableFooterContainer4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/TableHeaderContainer4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/TableRa.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/TableRowContainer4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/TextArea.java
trunk/foray/foray-core/src/main/java/org/foray/core/ForayTarget.java
trunk/foray/foray-render/src/main/java/org/foray/render/PrintRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/Renderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtPrintRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/awt/viewer/PreviewDialog.java
trunk/foray/foray-render/src/main/java/org/foray/render/pcl/PclRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/svg/SvgRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/txt/TxtRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/xml/XmlRenderer.java
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/AbstractListItemContent.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/AbstractListItemContent.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/AbstractListItemContent.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -37,8 +37,8 @@
import org.axsl.fotree.fo.Marker;
import org.axsl.fotree.fo.RetrieveMarker;
import org.axsl.fotree.fo.Table;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaTree4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaTree4a.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaTree4a.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -45,10 +45,10 @@
import org.axsl.fotree.fo.Marker;
import org.axsl.fotree.fo.PageSequence;
import org.axsl.fotree.fo.Root;
-import org.axsl.galley.DocumentMetadataG5;
import org.axsl.galley.Galley;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.metadata.DocumentMetadataG5;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.linebreak.LineBreaker;
import org.axsl.linebreak.LineBreakerFactory;
import org.axsl.text.TextServer;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/BasicLinkArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/BasicLinkArea.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/BasicLinkArea.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -32,9 +32,9 @@
import org.axsl.area.AreaTreeException;
import org.axsl.fotree.fo.BasicLink;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.GeneralInlineAreaG5;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.value.BorderStyle;
import java.awt.Color;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/BeforeFloatRa4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/BeforeFloatRa4a.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/BeforeFloatRa4a.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -34,8 +34,8 @@
import org.axsl.area.BeforeFloatRa;
import org.axsl.fotree.Fo;
import org.axsl.fotree.fo.RegionBody;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.value.RelativeAxis;
import java.util.ArrayList;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/BidiOverrideArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/BidiOverrideArea.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/BidiOverrideArea.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -32,9 +32,9 @@
import org.axsl.area.AreaTreeException;
import org.axsl.fotree.fo.BidiOverride;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.GeneralInlineAreaG5;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import java.awt.Color;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/BlockContainerRa.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/BlockContainerRa.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/BlockContainerRa.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -41,8 +41,8 @@
import org.axsl.fotree.fo.Table;
import org.axsl.fotree.fo.prop.CommonPositionPa;
import org.axsl.galley.BlockContainerAreaG5;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.graphic.Graphic;
import org.axsl.value.AbsolutePosition;
import org.axsl.value.BackgroundRepeat;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkArea.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkArea.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -35,9 +35,9 @@
import org.axsl.fotree.Fo;
import org.axsl.fotree.fo.Bookmark;
import org.axsl.fotree.fo.BookmarkTitle;
-import org.axsl.galley.BookmarkG5;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.metadata.BookmarkG5;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import java.awt.Color;
import java.net.URI;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkTreeArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkTreeArea.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/BookmarkTreeArea.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -33,9 +33,9 @@
import org.axsl.area.AreaTreeException;
import org.axsl.fotree.Fo;
import org.axsl.fotree.fo.BookmarkTree;
-import org.axsl.galley.BookmarkTreeG5;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.metadata.BookmarkTreeG5;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
/**
* A NonArea class for items generated by fo:bookmark-tree.
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/DocumentMetadata4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/DocumentMetadata4a.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/DocumentMetadata4a.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -33,9 +33,9 @@
import org.axsl.area.AreaTreeException;
import org.axsl.fotree.Fo;
-import org.axsl.galley.DocumentMetadataG5;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.metadata.DocumentMetadataG5;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import java.util.Collections;
import java.util.List;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/ExternalGraphicArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/ExternalGraphicArea.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/ExternalGraphicArea.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -33,8 +33,8 @@
import org.axsl.area.AreaTreeException;
import org.axsl.fotree.fo.ExternalGraphic;
import org.axsl.galley.ExternalGraphicAreaG5;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.graphic.Graphic;
import java.awt.Color;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/FootnoteRa4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/FootnoteRa4a.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/FootnoteRa4a.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -34,8 +34,8 @@
import org.axsl.area.FootnoteRa;
import org.axsl.fotree.Fo;
import org.axsl.fotree.fo.RegionBody;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.value.RelativeAxis;
import java.util.ArrayList;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/ForeignObjectArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/ForeignObjectArea.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/ForeignObjectArea.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -37,8 +37,8 @@
import org.axsl.fotree.foreign.SvgElement;
import org.axsl.galley.ForeignContentG5;
import org.axsl.galley.ForeignObjectAreaG5;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import java.awt.Color;
import java.util.Collections;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/IndexPageCitationListArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/IndexPageCitationListArea.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/IndexPageCitationListArea.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -32,9 +32,9 @@
import org.axsl.area.AreaTreeException;
import org.axsl.fotree.fo.IndexPageCitationList;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.GeneralInlineAreaG5;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import java.awt.Color;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/InlineArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/InlineArea.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/InlineArea.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -32,9 +32,9 @@
import org.axsl.area.AreaTreeException;
import org.axsl.fotree.fo.Inline;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.InlineAreaG5;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.graphic.Graphic;
import org.axsl.value.BackgroundRepeat;
import org.axsl.value.BorderStyle;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/InlineContainerArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/InlineContainerArea.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/InlineContainerArea.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -40,8 +40,8 @@
import org.axsl.fotree.fo.Marker;
import org.axsl.fotree.fo.RetrieveMarker;
import org.axsl.fotree.fo.Table;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import java.awt.Color;
import java.util.ArrayList;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/LeaderArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/LeaderArea.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/LeaderArea.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -36,9 +36,9 @@
import org.axsl.fotree.fo.prop.LeaderAlignmentPa;
import org.axsl.fotree.fo.prop.LeaderPatternPa;
import org.axsl.fotree.fo.prop.LeaderPatternWidthPa;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.LeaderAreaG5;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.value.LeaderAlignment;
import org.axsl.value.LeaderPattern;
import org.axsl.value.RuleStyle;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -55,9 +55,9 @@
import org.axsl.fotree.fo.RetrieveMarker;
import org.axsl.fotree.fo.ScalingValueCitation;
import org.axsl.fotree.text.FoTokenFlow;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.GlyphAreaSequenceG5;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.kpModel.ParaBranch;
import org.axsl.kpModel.ParaLeaf;
import org.axsl.value.Conditionality;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/ListBlockArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/ListBlockArea.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/ListBlockArea.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -33,9 +33,9 @@
import org.axsl.area.AreaTreeException;
import org.axsl.fotree.fo.ListBlock;
import org.axsl.fotree.fo.ListItem;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.ListBlockAreaG5;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.value.RelativeAxis;
import java.util.ArrayList;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/ListItemArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/ListItemArea.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/ListItemArea.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -35,8 +35,8 @@
import org.axsl.fotree.fo.ListItem;
import org.axsl.fotree.fo.ListItemBody;
import org.axsl.fotree.fo.ListItemLabel;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.value.RelativeAxis;
import java.util.ArrayList;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/MainRa4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/MainRa4a.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/MainRa4a.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -36,8 +36,8 @@
import org.axsl.fotree.fo.Block;
import org.axsl.fotree.fo.BlockContainer;
import org.axsl.fotree.fo.RegionBody;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.value.RelativeAxis;
import org.axsl.value.Span;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/NormalBlockArea4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/NormalBlockArea4a.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/NormalBlockArea4a.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -43,8 +43,8 @@
import org.axsl.fotree.fo.Marker;
import org.axsl.fotree.fo.RetrieveMarker;
import org.axsl.fotree.fo.Table;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.graphic.Graphic;
import org.axsl.kpModel.ParaContext;
import org.axsl.kpModel.ParaPenalty;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/NormalFlowRa4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/NormalFlowRa4a.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/NormalFlowRa4a.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -41,8 +41,8 @@
import org.axsl.fotree.fo.RegionBody;
import org.axsl.fotree.fo.RetrieveMarker;
import org.axsl.fotree.fo.Table;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.value.RelativeAxis;
import java.util.ArrayList;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/PageCollection4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/PageCollection4a.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/PageCollection4a.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -41,8 +41,8 @@
import org.axsl.fotree.fo.PageMasterResolver;
import org.axsl.fotree.fo.PageSequence;
import org.axsl.fotree.fo.SimplePageMaster;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.i18n.Country;
import org.axsl.i18n.Language;
import org.axsl.value.ForcePageCount;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/PageNumberArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/PageNumberArea.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/PageNumberArea.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -33,9 +33,9 @@
import org.axsl.area.AreaTreeException;
import org.axsl.font.FontUse;
import org.axsl.fotree.fo.PageNumber;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.GlyphAreaSequenceG5;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import java.awt.Color;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/PageNumberCitationArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/PageNumberCitationArea.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/PageNumberCitationArea.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -33,9 +33,9 @@
import org.axsl.area.AreaTreeException;
import org.axsl.font.FontUse;
import org.axsl.fotree.fo.PageNumberCitation;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.GlyphAreaSequenceG5;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import java.awt.Color;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/PageNumberCitationLastArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/PageNumberCitationLastArea.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/PageNumberCitationLastArea.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -33,9 +33,9 @@
import org.axsl.area.AreaTreeException;
import org.axsl.font.FontUse;
import org.axsl.fotree.fo.PageNumberCitationLast;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.GlyphAreaSequenceG5;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import java.awt.Color;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/PageRa4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/PageRa4a.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/PageRa4a.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -45,8 +45,8 @@
import org.axsl.fotree.fo.RegionStart;
import org.axsl.fotree.fo.RetrieveMarker;
import org.axsl.fotree.fo.SimplePageMaster;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.value.AbsoluteAxis;
import org.axsl.value.AbsoluteDirection;
import org.axsl.value.Compass;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/RegionBodyRa4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/RegionBodyRa4a.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/RegionBodyRa4a.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -34,8 +34,8 @@
import org.axsl.area.RegionBodyRa;
import org.axsl.fotree.fo.RegionBody;
import org.axsl.fotree.fo.SimplePageMaster;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.graphic.Graphic;
import org.axsl.value.AbsoluteDirection;
import org.axsl.value.BackgroundRepeat;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/RegionOuterRa4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/RegionOuterRa4a.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/RegionOuterRa4a.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -44,8 +44,8 @@
import org.axsl.fotree.fo.RegionStart;
import org.axsl.fotree.fo.RetrieveMarker;
import org.axsl.fotree.fo.Table;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.graphic.Graphic;
import org.axsl.value.BackgroundRepeat;
import org.axsl.value.RelativeAxis;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/RetrieveMarkerNode4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/RetrieveMarkerNode4a.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/RetrieveMarkerNode4a.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -34,8 +34,8 @@
import org.axsl.area.RetrieveMarkerNode;
import org.axsl.fotree.fo.Marker;
import org.axsl.fotree.fo.RetrieveMarker;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/RetrieveTableMarkerNode4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/RetrieveTableMarkerNode4a.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/RetrieveTableMarkerNode4a.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -34,8 +34,8 @@
import org.axsl.area.RetrieveTableMarkerNode;
import org.axsl.fotree.fo.Marker;
import org.axsl.fotree.fo.RetrieveTableMarker;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/ScalingValueCitationArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/ScalingValueCitationArea.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/ScalingValueCitationArea.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -35,9 +35,9 @@
import org.axsl.font.FontContext;
import org.axsl.font.FontUse;
import org.axsl.fotree.fo.ScalingValueCitation;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.GlyphAreaSequenceG5;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import java.awt.Color;
import java.util.Collections;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/SpanRa4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/SpanRa4a.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/SpanRa4a.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -34,8 +34,8 @@
import org.axsl.area.SpanRa;
import org.axsl.fotree.fo.RegionBody;
import org.axsl.fotree.fo.prop.SpanPa;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.value.RelativeAxis;
import org.axsl.value.Span;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/TableBodyContainer4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/TableBodyContainer4a.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/TableBodyContainer4a.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -34,8 +34,8 @@
import org.axsl.area.TableBodyContainer;
import org.axsl.fotree.fo.GraftingPoint;
import org.axsl.fotree.fo.TableBody;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.graphic.Graphic;
import org.axsl.value.BackgroundRepeat;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/TableCellRa.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/TableCellRa.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/TableCellRa.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -40,8 +40,8 @@
import org.axsl.fotree.fo.RetrieveMarker;
import org.axsl.fotree.fo.Table;
import org.axsl.fotree.fo.TableCell;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.graphic.Graphic;
import org.axsl.value.BackgroundRepeat;
import org.axsl.value.BorderModel;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/TableFooterContainer4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/TableFooterContainer4a.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/TableFooterContainer4a.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -37,8 +37,8 @@
import org.axsl.fotree.fo.Marker;
import org.axsl.fotree.fo.RetrieveTableMarker;
import org.axsl.fotree.fo.TableFooter;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.graphic.Graphic;
import org.axsl.value.BackgroundRepeat;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/TableHeaderContainer4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/TableHeaderContainer4a.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/TableHeaderContainer4a.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -37,8 +37,8 @@
import org.axsl.fotree.fo.Marker;
import org.axsl.fotree.fo.RetrieveTableMarker;
import org.axsl.fotree.fo.TableHeader;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.graphic.Graphic;
import org.axsl.value.BackgroundRepeat;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/TableRa.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/TableRa.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/TableRa.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -42,8 +42,8 @@
import org.axsl.fotree.fo.TableFooter;
import org.axsl.fotree.fo.TableHeader;
import org.axsl.galley.BackgroundAreaG5;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.graphic.Graphic;
import org.axsl.value.BackgroundRepeat;
import org.axsl.value.BorderModel;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/TableRowContainer4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/TableRowContainer4a.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/TableRowContainer4a.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -35,8 +35,8 @@
import org.axsl.fotree.fo.GraftingPoint;
import org.axsl.fotree.fo.TableCell;
import org.axsl.fotree.fo.TableRow;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.graphic.Graphic;
import org.axsl.value.BackgroundRepeat;
import org.axsl.value.FoPropertyConstants;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/TextArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/TextArea.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/TextArea.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -38,9 +38,9 @@
import org.axsl.fotree.fo.Block;
import org.axsl.fotree.fo.FoText;
import org.axsl.fotree.fo.FoTextCharacters;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.GlyphAreaSequenceG5;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.unicode.block.Basic_Latin_Block;
import org.axsl.value.WhiteSpaceTreatment;
Modified: trunk/foray/foray-core/src/main/java/org/foray/core/ForayTarget.java
===================================================================
--- trunk/foray/foray-core/src/main/java/org/foray/core/ForayTarget.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-core/src/main/java/org/foray/core/ForayTarget.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -42,8 +42,8 @@
import org.axsl.fotree.FoTreeException;
import org.axsl.fotree.FoTreeListener;
import org.axsl.fotree.fo.PageSequence;
-import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.PageG5;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.layout.Layout;
import org.axsl.layout.LayoutException;
import org.axsl.layout.LayoutFactory;
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/PrintRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/PrintRenderer.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/PrintRenderer.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -33,9 +33,9 @@
import org.axsl.font.Font;
import org.axsl.font.FontSelectionConstraints;
import org.axsl.galley.BorderPaddingAreaG5;
-import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.GlyphAreaSequenceG5;
import org.axsl.galley.LeaderAreaG5;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.output.DocumentConfiguration;
import org.axsl.value.LeaderPattern;
import org.axsl.value.RuleStyle;
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/Renderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/Renderer.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/Renderer.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -41,7 +41,6 @@
import org.axsl.galley.AreaNodeG5;
import org.axsl.galley.BackgroundAreaG5;
import org.axsl.galley.BlockContainerAreaG5;
-import org.axsl.galley.BookmarkTreeG5;
import org.axsl.galley.BorderPaddingAreaG5;
import org.axsl.galley.ExternalGraphicAreaG5;
import org.axsl.galley.ForeignContentG5;
@@ -49,8 +48,6 @@
import org.axsl.galley.ForeignContentSvgG5;
import org.axsl.galley.ForeignObjectAreaG5;
import org.axsl.galley.Galley;
-import org.axsl.galley.GalleyVisitor;
-import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.GlyphAreaSequenceG5;
import org.axsl.galley.GraphicAreaG5;
import org.axsl.galley.InlineAreaG5;
@@ -61,6 +58,9 @@
import org.axsl.galley.RegionAreaG5;
import org.axsl.galley.TableAreaG5;
import org.axsl.galley.TableCellAreaG5;
+import org.axsl.galley.metadata.BookmarkTreeG5;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
import org.axsl.value.RuleStyle;
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtPrintRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtPrintRenderer.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtPrintRenderer.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -28,8 +28,8 @@
package org.foray.render.awt;
-import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.PageG5;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.output.OutputConfiguration;
import org.axsl.output.OutputException;
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtRenderer.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtRenderer.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -47,17 +47,17 @@
import org.axsl.font.FontSelectionConstraints;
import org.axsl.font.FontUse;
-import org.axsl.galley.BookmarkTreeG5;
import org.axsl.galley.BorderPaddingAreaG5;
import org.axsl.galley.ExternalGraphicAreaG5;
import org.axsl.galley.ForeignContentMathG5;
import org.axsl.galley.ForeignContentSvgG5;
import org.axsl.galley.ForeignObjectAreaG5;
-import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.GlyphAreaSequenceG5;
import org.axsl.galley.GraphicAreaG5;
import org.axsl.galley.LeaderAreaG5;
import org.axsl.galley.PageG5;
+import org.axsl.galley.metadata.BookmarkTreeG5;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
import org.axsl.graphic.SvgGraphic;
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/awt/viewer/PreviewDialog.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/awt/viewer/PreviewDialog.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/awt/viewer/PreviewDialog.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -45,7 +45,7 @@
import org.foray.common.WellKnownConstants;
import org.foray.render.awt.AwtRenderer;
-import org.axsl.galley.GalleyVisitorException;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.output.OutputException;
import java.awt.BorderLayout;
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/pcl/PclRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/pcl/PclRenderer.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/pcl/PclRenderer.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -41,14 +41,14 @@
import org.foray.render.Renderer;
import org.axsl.font.Font;
-import org.axsl.galley.BookmarkTreeG5;
import org.axsl.galley.ExternalGraphicAreaG5;
import org.axsl.galley.ForeignContentMathG5;
import org.axsl.galley.ForeignContentSvgG5;
-import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.GlyphAreaSequenceG5;
import org.axsl.galley.GraphicAreaG5;
import org.axsl.galley.PageG5;
+import org.axsl.galley.metadata.BookmarkTreeG5;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
import org.axsl.output.DocumentConfiguration;
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -43,18 +43,18 @@
import org.axsl.font.FontUse;
import org.axsl.galley.AreaG5;
import org.axsl.galley.AreaNodeG5;
-import org.axsl.galley.BookmarkG5;
-import org.axsl.galley.BookmarkTreeG5;
-import org.axsl.galley.DocumentMetadataG5;
import org.axsl.galley.ForeignContentMathG5;
import org.axsl.galley.ForeignContentSvgG5;
import org.axsl.galley.ForeignObjectAreaG5;
import org.axsl.galley.Galley;
-import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.GlyphAreaSequenceG5;
import org.axsl.galley.GraphicAreaG5;
import org.axsl.galley.PageCollectionG5;
import org.axsl.galley.PageG5;
+import org.axsl.galley.metadata.BookmarkG5;
+import org.axsl.galley.metadata.BookmarkTreeG5;
+import org.axsl.galley.metadata.DocumentMetadataG5;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicLink;
import org.axsl.graphic.MathGraphic;
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -45,16 +45,16 @@
import org.axsl.font.Font;
import org.axsl.font.FontUse;
import org.axsl.galley.AreaG5;
-import org.axsl.galley.BookmarkTreeG5;
import org.axsl.galley.BorderPaddingAreaG5;
import org.axsl.galley.ForeignContentMathG5;
import org.axsl.galley.ForeignContentSvgG5;
import org.axsl.galley.ForeignObjectAreaG5;
-import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.GlyphAreaSequenceG5;
import org.axsl.galley.GraphicAreaG5;
import org.axsl.galley.LeaderAreaG5;
import org.axsl.galley.PageG5;
+import org.axsl.galley.metadata.BookmarkTreeG5;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.graphic.EpsGraphic;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/svg/SvgRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/svg/SvgRenderer.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/svg/SvgRenderer.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -36,17 +36,17 @@
import org.axsl.font.FontSelectionConstraints;
import org.axsl.galley.AreaG5;
-import org.axsl.galley.BookmarkTreeG5;
import org.axsl.galley.BorderPaddingAreaG5;
import org.axsl.galley.ExternalGraphicAreaG5;
import org.axsl.galley.ForeignContentMathG5;
import org.axsl.galley.ForeignContentSvgG5;
import org.axsl.galley.ForeignObjectAreaG5;
-import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.GlyphAreaSequenceG5;
import org.axsl.galley.GraphicAreaG5;
import org.axsl.galley.LeaderAreaG5;
import org.axsl.galley.PageG5;
+import org.axsl.galley.metadata.BookmarkTreeG5;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
import org.axsl.graphic.GraphicServer;
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/txt/TxtRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/txt/TxtRenderer.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/txt/TxtRenderer.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -32,14 +32,14 @@
import org.foray.render.PrintRenderer;
import org.foray.render.Renderer;
-import org.axsl.galley.BookmarkTreeG5;
import org.axsl.galley.ExternalGraphicAreaG5;
import org.axsl.galley.ForeignContentMathG5;
import org.axsl.galley.ForeignContentSvgG5;
-import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.GlyphAreaSequenceG5;
import org.axsl.galley.GraphicAreaG5;
import org.axsl.galley.PageG5;
+import org.axsl.galley.metadata.BookmarkTreeG5;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
import org.axsl.output.DocumentConfiguration;
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/xml/XmlRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/xml/XmlRenderer.java 2022-01-26 23:24:40 UTC (rev 12476)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/xml/XmlRenderer.java 2022-01-26 23:42:01 UTC (rev 12477)
@@ -44,13 +44,11 @@
import org.axsl.galley.AreaNodeG5;
import org.axsl.galley.BackgroundAreaG5;
import org.axsl.galley.BlockContainerAreaG5;
-import org.axsl.galley.BookmarkTreeG5;
import org.axsl.galley.BorderPaddingAreaG5;
import org.axsl.galley.ExternalGraphicAreaG5;
import org.axsl.galley.ForeignContentMathG5;
import org.axsl.galley.ForeignContentSvgG5;
import org.axsl.galley.ForeignObjectAreaG5;
-import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.GeneralInlineAreaG5;
import org.axsl.galley.GlyphAreaSequenceG5;
import org.axsl.galley.GraphicAreaG5;
@@ -62,6 +60,8 @@
import org.axsl.galley.RegionAreaG5;
import org.axsl.galley.TableAreaG5;
import org.axsl.galley.TableCellAreaG5;
+import org.axsl.galley.metadata.BookmarkTreeG5;
+import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.graphic.Graphic;
import org.axsl.output.DocumentAreaConfiguration;
import org.axsl.value.RuleStyle;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|