You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2011/01/18 09:54:26 UTC
svn commit: r1060241 [14/21] - in /xmlgraphics/fop/branches/Temp_Color: ./
examples/plan/src/org/apache/fop/plan/ lib/ lib/build/
src/codegen/java/org/apache/fop/tools/ src/codegen/unicode/data/
src/codegen/unicode/java/org/apache/fop/hyphenation/ src/...
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java Tue Jan 18 08:54:08 2011
@@ -81,15 +81,10 @@ public class TextLayoutManager extends L
private boolean breakOppAfter;
private final Font font;
- AreaInfo(final int startIndex,
- final int breakIndex,
- final int wordSpaceCount,
- final int letterSpaceCount,
- final MinOptMax areaIPD,
- final boolean isHyphenated,
- final boolean isSpace,
- final boolean breakOppAfter,
- final Font font) {
+ AreaInfo( // CSOK: ParameterNumber
+ int startIndex, int breakIndex, int wordSpaceCount, int letterSpaceCount,
+ MinOptMax areaIPD, boolean isHyphenated, boolean isSpace, boolean breakOppAfter,
+ Font font) {
assert startIndex <= breakIndex;
this.startIndex = startIndex;
this.breakIndex = breakIndex;
@@ -170,7 +165,8 @@ public class TextLayoutManager extends L
private int hyphIPD;
private boolean hasChanged = false;
- private int returnedIndex = 0;
+ private int[] returnedIndices = {0, 0};
+ private int changeOffset = 0;
private int thisStart = 0;
private int tempStart = 0;
private List changeList = new LinkedList();
@@ -709,7 +705,7 @@ public class TextLayoutManager extends L
if (inWord) {
processWord(alignment, sequence, prevAreaInfo, ch, false, false);
} else if (inWhitespace) {
- processWhitespace(alignment, sequence, true);
+ processWhitespace(alignment, sequence, !keepTogether);
} else if (areaInfo != null) {
processLeftoverAreaInfo(alignment, sequence, areaInfo,
ch == CharUtilities.ZERO_WIDTH_SPACE);
@@ -774,10 +770,8 @@ public class TextLayoutManager extends L
while (lastIndex > 0 && foText.charAt(lastIndex - 1) == CharUtilities.SOFT_HYPHEN) {
lastIndex--;
}
- final boolean endsWithHyphen = checkEndsWithHyphen
- && foText.charAt(lastIndex) == CharUtilities.SOFT_HYPHEN;
- Font font = FontSelector.selectFontForCharactersInText(foText, thisStart, lastIndex, foText, this);
- int wordLength = lastIndex - thisStart;
+ Font font = FontSelector
+ .selectFontForCharactersInText(foText, thisStart, lastIndex, foText, this);
boolean kerning = font.hasKerning();
MinOptMax wordIPD = MinOptMax.ZERO;
for (int i = thisStart; i < lastIndex; i++) {
@@ -793,7 +787,8 @@ public class TextLayoutManager extends L
if (i > thisStart) {
char previousChar = foText.charAt(i - 1);
kern = font.getKernValue(previousChar, currentChar);
- } else if (prevAreaInfo != null && !prevAreaInfo.isSpace && prevAreaInfo.breakIndex > 0) {
+ } else if (prevAreaInfo != null
+ && !prevAreaInfo.isSpace && prevAreaInfo.breakIndex > 0) {
char previousChar = foText.charAt(prevAreaInfo.breakIndex - 1);
kern = font.getKernValue(previousChar, currentChar);
}
@@ -803,30 +798,38 @@ public class TextLayoutManager extends L
}
}
}
+ boolean endsWithHyphen = checkEndsWithHyphen
+ && foText.charAt(lastIndex) == CharUtilities.SOFT_HYPHEN;
if (kerning
&& breakOpportunity
&& !TextLayoutManager.isSpace(ch)
&& lastIndex > 0
&& endsWithHyphen) {
- final int kern = font.getKernValue(foText.charAt(lastIndex - 1), ch);
+ int kern = font.getKernValue(foText.charAt(lastIndex - 1), ch);
if (kern != 0) {
addToLetterAdjust(lastIndex, kern);
//TODO: add kern to wordIPD?
}
}
- int iLetterSpaces = wordLength - 1;
- // if there is a break opportunity and the next one
- // is not a space, it could be used as a line end;
- // add one more letter space, in case other text follows
- if (breakOpportunity && !TextLayoutManager.isSpace(ch)) {
- iLetterSpaces++;
+ // shy+chars at start of word: wordLength == 0 && breakOpportunity
+ // shy only characters in word: wordLength == 0 && !breakOpportunity
+ int wordLength = lastIndex - thisStart;
+ int letterSpaces = 0;
+ if (wordLength != 0) {
+ letterSpaces = wordLength - 1;
+ // if there is a break opportunity and the next one
+ // is not a space, it could be used as a line end;
+ // add one more letter space, in case other text follows
+ if (breakOpportunity && !TextLayoutManager.isSpace(ch)) {
+ letterSpaces++;
+ }
}
- assert iLetterSpaces >= 0;
- wordIPD = wordIPD.plus(letterSpaceIPD.mult(iLetterSpaces));
+ assert letterSpaces >= 0;
+ wordIPD = wordIPD.plus(letterSpaceIPD.mult(letterSpaces));
// create the AreaInfo object
AreaInfo areaInfo = new AreaInfo(thisStart, lastIndex, 0,
- iLetterSpaces, wordIPD,
+ letterSpaces, wordIPD,
endsWithHyphen,
false, breakOpportunity, font);
prevAreaInfo = areaInfo;
@@ -841,14 +844,20 @@ public class TextLayoutManager extends L
}
/** {@inheritDoc} */
- public List addALetterSpaceTo(final List oldList) {
+ public List addALetterSpaceTo(List oldList) {
+ return addALetterSpaceTo(oldList, 0);
+ }
+
+ /** {@inheritDoc} */
+ public List addALetterSpaceTo(final List oldList, int depth) {
// old list contains only a box, or the sequence: box penalty glue box;
// look at the Position stored in the first element in oldList
// which is always a box
ListIterator oldListIterator = oldList.listIterator();
KnuthElement knuthElement = (KnuthElement) oldListIterator.next();
- LeafPosition pos = (LeafPosition) ((KnuthBox) knuthElement).getPosition();
- int index = pos.getLeafPos();
+ Position pos = knuthElement.getPosition();
+ LeafPosition leafPos = (LeafPosition) pos.getPosition(depth);
+ int index = leafPos.getLeafPos();
//element could refer to '-1' position, for non-collapsed spaces (?)
if (index > -1) {
AreaInfo areaInfo = getAreaInfo(index);
@@ -863,6 +872,7 @@ public class TextLayoutManager extends L
oldListIterator.add(new KnuthGlue(letterSpaceIPD, auxiliaryPosition, false));
} else if (letterSpaceIPD.isStiff()) {
// constant letter space: replace the box
+ // give it the unwrapped position of the replaced element
oldListIterator.set(new KnuthInlineBox(areaInfo.areaIPD.getOpt(),
alignmentContext, pos, false));
} else {
@@ -876,41 +886,9 @@ public class TextLayoutManager extends L
return oldList;
}
- /**
- * Removes the <code>AreaInfo</code> object represented by the given elements, so that it won't
- * generate any element when <code>getChangedKnuthElements</code> is called.
- *
- * @param oldList the elements representing the word space
- */
- public void removeWordSpace(final List oldList) {
- // find the element storing the Position whose value
- // points to the AreaInfo object
- final ListIterator oldListIterator = oldList.listIterator();
- if (((KnuthElement) ((LinkedList) oldList).getFirst()).isPenalty()) {
- // non breaking space: oldList starts with a penalty
- oldListIterator.next();
- }
- if (oldList.size() > 2) {
- // alignment is either center, start or end:
- // the first two elements does not store the needed Position
- oldListIterator.next();
- oldListIterator.next();
- }
- KnuthElement knuthElement = (KnuthElement) oldListIterator.next();
- int leafValue = ((LeafPosition) knuthElement.getPosition()).getLeafPos();
- // only the last word space can be a trailing space!
- if (leafValue == areaInfos.size() - 1) {
- areaInfos.remove(leafValue);
- } else {
- TextLayoutManager.LOG.error("trying to remove a non-trailing word space");
- }
- }
-
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void hyphenate(Position pos, HyphContext hyphContext) {
- AreaInfo areaInfo = getAreaInfo(((LeafPosition) pos).getLeafPos());
+ AreaInfo areaInfo = getAreaInfo(((LeafPosition) pos).getLeafPos() + changeOffset);
int startIndex = areaInfo.startIndex;
int stopIndex;
boolean nothingChanged = true;
@@ -953,7 +931,9 @@ public class TextLayoutManager extends L
}
// add letter spaces
- boolean isWordEnd = stopIndex == areaInfo.breakIndex && areaInfo.letterSpaceCount < areaInfo.getCharLength();
+ boolean isWordEnd
+ = stopIndex == areaInfo.breakIndex
+ && areaInfo.letterSpaceCount < areaInfo.getCharLength();
int letterSpaceCount = isWordEnd ? stopIndex - startIndex - 1 : stopIndex - startIndex;
assert letterSpaceCount >= 0;
@@ -963,7 +943,7 @@ public class TextLayoutManager extends L
// the new AreaInfo object is not equal to the old one
changeList.add(new PendingChange(new AreaInfo(startIndex, stopIndex, 0,
letterSpaceCount, newIPD, hyphenFollows, false, false, font),
- ((LeafPosition) pos).getLeafPos()));
+ ((LeafPosition) pos).getLeafPos() + changeOffset));
nothingChanged = false;
}
startIndex = stopIndex;
@@ -973,11 +953,48 @@ public class TextLayoutManager extends L
/** {@inheritDoc} */
public boolean applyChanges(final List oldList) {
+ return applyChanges(oldList, 0);
+ }
+
+ /** {@inheritDoc} */
+ public boolean applyChanges(final List oldList, int depth) {
+
+ // make sure the LM appears unfinished in between this call
+ // and the next call to getChangedKnuthElements()
setFinished(false);
+ if (oldList.isEmpty()) {
+ return false;
+ }
+
+ // Find the first and last positions in oldList that point to an AreaInfo
+ // (i.e. getLeafPos() != -1)
+ LeafPosition startPos = null, endPos = null;
+ ListIterator oldListIter;
+ for (oldListIter = oldList.listIterator(); oldListIter.hasNext();) {
+ Position pos = ((KnuthElement) oldListIter.next()).getPosition();
+ startPos = (LeafPosition) pos.getPosition(depth);
+ if (startPos != null && startPos.getLeafPos() != -1) {
+ break;
+ }
+ }
+ for (oldListIter = oldList.listIterator(oldList.size()); oldListIter.hasPrevious();) {
+ Position pos = ((KnuthElement) oldListIter.previous()).getPosition();
+ endPos = (LeafPosition) pos.getPosition(depth);
+ if (endPos != null && endPos.getLeafPos() != -1) {
+ break;
+ }
+ }
+
+ // set start/end index, taking into account any offset due to
+ // changes applied to previous paragraphs
+ returnedIndices[0] = (startPos != null ? startPos.getLeafPos() : -1) + changeOffset;
+ returnedIndices[1] = (endPos != null ? endPos.getLeafPos() : -1) + changeOffset;
+
+ int areaInfosAdded = 0;
+ int areaInfosRemoved = 0;
+
if (!changeList.isEmpty()) {
- int areaInfosAdded = 0;
- int areaInfosRemoved = 0;
int oldIndex = -1, changeIndex;
PendingChange currChange;
ListIterator changeListIterator = changeList.listIterator();
@@ -998,7 +1015,11 @@ public class TextLayoutManager extends L
changeList.clear();
}
- returnedIndex = 0;
+ // increase the end index for getChangedKnuthElements()
+ returnedIndices[1] += (areaInfosAdded - areaInfosRemoved);
+ // increase offset to use for subsequent paragraphs
+ changeOffset += (areaInfosAdded - areaInfosRemoved);
+
return hasChanged;
}
@@ -1010,27 +1031,24 @@ public class TextLayoutManager extends L
final LinkedList returnList = new LinkedList();
- while (returnedIndex < areaInfos.size()) {
- AreaInfo areaInfo = getAreaInfo(returnedIndex);
+ for (; returnedIndices[0] <= returnedIndices[1]; returnedIndices[0]++) {
+ AreaInfo areaInfo = getAreaInfo(returnedIndices[0]);
if (areaInfo.wordSpaceCount == 0) {
// areaInfo refers either to a word or a word fragment
- addElementsForAWordFragment(returnList, alignment, areaInfo, returnedIndex);
+ addElementsForAWordFragment(returnList, alignment, areaInfo, returnedIndices[0]);
} else {
// areaInfo refers to a space
- addElementsForASpace(returnList, alignment, areaInfo, returnedIndex);
+ addElementsForASpace(returnList, alignment, areaInfo, returnedIndices[0]);
}
- returnedIndex++;
}
- setFinished(true);
+ setFinished(returnedIndices[0] == areaInfos.size() - 1);
//ElementListObserver.observe(returnList, "text-changed", null);
return returnList;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public String getWordChars(Position pos) {
- int leafValue = ((LeafPosition) pos).getLeafPos();
+ int leafValue = ((LeafPosition) pos).getLeafPos() + changeOffset;
if (leafValue != -1) {
AreaInfo areaInfo = getAreaInfo(leafValue);
StringBuffer buffer = new StringBuffer(areaInfo.getCharLength());
@@ -1065,11 +1083,13 @@ public class TextLayoutManager extends L
if (foText.charAt(areaInfo.startIndex) != CharUtilities.SPACE
|| foText.getWhitespaceTreatment() == Constants.EN_PRESERVE) {
// a breaking space that needs to be preserved
- baseList.addAll(getElementsForBreakingSpace(alignment, areaInfo, auxiliaryPosition, 0,
+ baseList
+ .addAll(getElementsForBreakingSpace(alignment, areaInfo, auxiliaryPosition, 0,
mainPosition, areaInfo.areaIPD.getOpt(), true));
} else {
// a (possible block) of breaking spaces
- baseList.addAll(getElementsForBreakingSpace(alignment, areaInfo, mainPosition,
+ baseList
+ .addAll(getElementsForBreakingSpace(alignment, areaInfo, mainPosition,
areaInfo.areaIPD.getOpt(), auxiliaryPosition, 0, false));
}
}
@@ -1103,17 +1123,31 @@ public class TextLayoutManager extends L
// if the second element is chosen as a line break these elements
// add a constant amount of stretch at the end of a line, otherwise
// they don't add any stretch
+ KnuthGlue g;
if (skipZeroCheck || lineStartBAP != 0 || lineEndBAP != 0) {
- elements.add(new KnuthGlue(lineEndBAP, 3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0, auxiliaryPosition, false));
+ g = new KnuthGlue
+ (lineEndBAP,
+ 3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0, auxiliaryPosition, false);
+ elements.add(g);
elements.add(makeZeroWidthPenalty(0));
- elements.add(new KnuthGlue(p2WidthOffset - (lineStartBAP + lineEndBAP), -3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0, pos2, false));
+ g = new KnuthGlue
+ (p2WidthOffset - (lineStartBAP + lineEndBAP),
+ -3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0, pos2, false);
+ elements.add(g);
elements.add(makeAuxiliaryZeroWidthBox());
elements.add(makeZeroWidthPenalty(KnuthElement.INFINITE));
- elements.add(new KnuthGlue(lineStartBAP + p3WidthOffset, 0, 0, pos3, false));
+ g = new KnuthGlue(lineStartBAP + p3WidthOffset, 0, 0, pos3, false);
+ elements.add(g);
} else {
- elements.add(new KnuthGlue(0, 3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0, auxiliaryPosition, false));
+ g = new KnuthGlue
+ (0,
+ 3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0, auxiliaryPosition, false);
+ elements.add(g);
elements.add(makeZeroWidthPenalty(0));
- elements.add(new KnuthGlue(areaInfo.areaIPD.getOpt(), -3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0, pos2, false));
+ g = new KnuthGlue
+ (areaInfo.areaIPD.getOpt(),
+ -3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0, pos2, false);
+ elements.add(g);
}
break;
@@ -1133,9 +1167,10 @@ public class TextLayoutManager extends L
return elements;
}
- private List getElementsForJustifiedText(AreaInfo areaInfo, Position pos2, int p2WidthOffset,
- Position pos3, int p3WidthOffset, boolean skipZeroCheck,
- int shrinkability) {
+ private List getElementsForJustifiedText
+ (AreaInfo areaInfo, Position pos2, int p2WidthOffset,
+ Position pos3, int p3WidthOffset, boolean skipZeroCheck,
+ int shrinkability) {
int stretchability = areaInfo.areaIPD.getStretch();
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/CellPart.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/CellPart.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/CellPart.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/CellPart.java Tue Jan 18 08:54:08 2011
@@ -61,7 +61,8 @@ class CellPart {
* @param bpAfterLast width of (possibly optional) border- and padding-after if this
* part will be the last one on the page
*/
- protected CellPart(PrimaryGridUnit pgu, int start, int end, boolean last,
+ protected CellPart( // CSOK: ParameterNumber
+ PrimaryGridUnit pgu, int start, int end, boolean last,
int condBeforeContentLength, int length, int condAfterContentLength,
int bpBeforeNormal, int bpBeforeFirst,
int bpAfterNormal, int bpAfterLast) {
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java Tue Jan 18 08:54:08 2011
@@ -196,7 +196,7 @@ public abstract class CollapsingBorderMo
* @param border1 a border specification
* @param border2 another border specification
* @return the winning border, null if the two borders are equivalent
- * @see determineWinner
+ * @see #determineWinner(BorderSpecification,BorderSpecification,boolean)
*/
public abstract BorderSpecification determineWinner(BorderSpecification border1,
BorderSpecification border2);
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java Tue Jan 18 08:54:08 2011
@@ -33,7 +33,7 @@ import org.apache.fop.layoutmgr.Position
* The caption contains blocks that are positioned next to the
* table on the caption side.
* The caption blocks have an implicit keep with the table.
- * @todo Implement getNextKnuthElements()
+ * TODO Implement getNextKnuthElements()
*/
public class TableAndCaptionLayoutManager extends BlockStackingLayoutManager {
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java Tue Jan 18 08:54:08 2011
@@ -31,7 +31,7 @@ import org.apache.fop.layoutmgr.Position
* LayoutManager for a table-caption FO.
* The table caption contains blocks that are placed beside the
* table.
- * @todo Implement getNextKnuthElements()
+ * TODO Implement getNextKnuthElements()
*/
public class TableCaptionLayoutManager extends BlockStackingLayoutManager {
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java Tue Jan 18 08:54:08 2011
@@ -277,17 +277,10 @@ public class TableCellLayoutManager exte
* this row is placed on a previous page). Used to calculate the placement of the
* row's background image if any
*/
- public void addAreas(PositionIterator parentIter,
- LayoutContext layoutContext,
- int[] spannedGridRowHeights,
- int startRow,
- int endRow,
- int borderBeforeWhich,
- int borderAfterWhich,
- boolean firstOnPage,
- boolean lastOnPage,
- RowPainter painter,
- int firstRowHeight) {
+ public void addAreas( // CSOK: ParameterNumber
+ PositionIterator parentIter, LayoutContext layoutContext, int[] spannedGridRowHeights,
+ int startRow, int endRow, int borderBeforeWhich, int borderAfterWhich,
+ boolean firstOnPage, boolean lastOnPage, RowPainter painter, int firstRowHeight) {
getParentArea(null);
addId();
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java Tue Jan 18 08:54:08 2011
@@ -55,7 +55,7 @@ import org.apache.fop.util.BreakUtil;
public class TableContentLayoutManager implements PercentBaseContext {
/** Logger **/
- private static Log log = LogFactory.getLog(TableContentLayoutManager.class);
+ private static final Log LOG = LogFactory.getLog(TableContentLayoutManager.class);
private TableLayoutManager tableLM;
private TableRowIterator bodyIter;
@@ -127,10 +127,18 @@ public class TableContentLayoutManager i
return this.footerList;
}
- /** {@inheritDoc} */
- public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
- if (log.isDebugEnabled()) {
- log.debug("==> Columns: " + getTableLM().getColumns());
+ /**
+ * Get a sequence of KnuthElements representing the content
+ * of the node assigned to the LM.
+ *
+ * @param context the LayoutContext used to store layout information
+ * @param alignment the desired text alignment
+ * @return the list of KnuthElements
+ * @see org.apache.fop.layoutmgr.LayoutManager#getNextKnuthElements(LayoutContext, int)
+ */
+ public List getNextKnuthElements(LayoutContext context, int alignment) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("==> Columns: " + getTableLM().getColumns());
}
KnuthBox headerAsFirst = null;
KnuthBox headerAsSecondToLast = null;
@@ -140,8 +148,8 @@ public class TableContentLayoutManager i
headerIter, context, alignment, TableRowIterator.HEADER);
this.headerNetHeight
= ElementListUtils.calcContentLength(this.headerList);
- if (log.isDebugEnabled()) {
- log.debug("==> Header: "
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("==> Header: "
+ headerNetHeight + " - " + this.headerList);
}
TableHeaderFooterPosition pos = new TableHeaderFooterPosition(
@@ -160,8 +168,8 @@ public class TableContentLayoutManager i
footerIter, context, alignment, TableRowIterator.FOOTER);
this.footerNetHeight
= ElementListUtils.calcContentLength(this.footerList);
- if (log.isDebugEnabled()) {
- log.debug("==> Footer: "
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("==> Footer: "
+ footerNetHeight + " - " + this.footerList);
}
//We can simply add the table footer at the end of the whole list
@@ -369,14 +377,14 @@ public class TableContentLayoutManager i
} else if (pos instanceof TableContentPosition) {
tablePositions.add(pos);
} else {
- if (log.isDebugEnabled()) {
- log.debug("Ignoring position: " + pos);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Ignoring position: " + pos);
}
}
}
if (lastPos instanceof TableHFPenaltyPosition) {
TableHFPenaltyPosition penaltyPos = (TableHFPenaltyPosition)lastPos;
- log.debug("Break at penalty!");
+ LOG.debug("Break at penalty!");
if (penaltyPos.headerElements != null) {
//Header positions for the penalty position are in the last element and need to
//be handled first before all other TableContentPositions
@@ -402,7 +410,7 @@ public class TableContentLayoutManager i
if (tablePositions.isEmpty()) {
// TODO make sure this actually never happens
- log.error("tablePositions empty."
+ LOG.error("tablePositions empty."
+ " Please send your FO file to fop-users@xmlgraphics.apache.org");
} else {
// Here we are sure that posIter iterates only over TableContentPosition instances
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java Tue Jan 18 08:54:08 2011
@@ -240,7 +240,7 @@ public class TableLayoutManager extends
// Elements for the table-header/footer/body
- LinkedList contentKnuthElements;
+ List contentKnuthElements;
contentLM = new TableContentLayoutManager(this);
LayoutContext childLC = new LayoutContext(0);
/*
@@ -552,4 +552,11 @@ public class TableLayoutManager extends
}
}
+ /** {@inheritDoc} */
+ public void reset() {
+ super.reset();
+ curBlockArea = null;
+ tableUnit = 0.0;
+ }
+
}
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java Tue Jan 18 08:54:08 2011
@@ -28,8 +28,6 @@ import org.apache.fop.fo.FONode.FONodeIt
import org.apache.fop.fo.flow.table.EffRow;
import org.apache.fop.fo.flow.table.Table;
import org.apache.fop.fo.flow.table.TableBody;
-import org.apache.fop.fo.flow.table.TablePart;
-
/**
* Iterator that lets the table layout manager step over all the rows of a part of the
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/AbstractPDFStream.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/AbstractPDFStream.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/AbstractPDFStream.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/AbstractPDFStream.java Tue Jan 18 08:54:08 2011
@@ -191,7 +191,7 @@ public abstract class AbstractPDFStream
StreamCache encodedStream = null;
PDFNumber refLength = null;
final Object lengthEntry;
- if (getDocument().isEncodingOnTheFly()) {
+ if (isEncodingOnTheFly()) {
refLength = new PDFNumber();
getDocumentSafely().registerObject(refLength);
lengthEntry = refLength;
@@ -218,6 +218,15 @@ public abstract class AbstractPDFStream
}
/**
+ * Indicates whether encoding may happen without buffering the encoded data. If this method
+ * returns true, the /Length entry will be an indirect object, a direct object otherwise.
+ * @return true if encoding should happen "on the fly"
+ */
+ protected boolean isEncodingOnTheFly() {
+ return getDocument().isEncodingOnTheFly();
+ }
+
+ /**
* Populates the dictionary with all necessary entries for the stream.
* Override this method if you need additional entries.
* @param lengthEntry value for the /Length entry
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/AlphaRasterImage.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/AlphaRasterImage.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/AlphaRasterImage.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/AlphaRasterImage.java Tue Jan 18 08:54:08 2011
@@ -116,7 +116,7 @@ public class AlphaRasterImage implements
return null;
}
- /** {@inheritDoc} */
+ /** @return null (unless overridden) */
public String getSoftMask() {
return null;
}
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/CMapBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/CMapBuilder.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/CMapBuilder.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/CMapBuilder.java Tue Jan 18 08:54:08 2011
@@ -22,11 +22,19 @@ package org.apache.fop.pdf;
import java.io.IOException;
import java.io.Writer;
+/** A cmap builder. */
public class CMapBuilder {
+ /** name */
protected String name;
+ /** writer */
protected Writer writer;
+ /**
+ * Construct cmap builder.
+ * @param writer a writer
+ * @param name a name
+ */
public CMapBuilder(Writer writer, String name) {
this.writer = writer;
this.name = name;
@@ -52,12 +60,14 @@ public class CMapBuilder {
writeUseCMap();
}
+ /** @throws IOException if i/o exception */
protected void writePreStream() throws IOException {
// writer.write("/Type /CMap\n");
// writer.write(sysInfo.toPDFString());
// writer.write("/CMapName /" + name + EOL);
}
+ /** @throws IOException if i/o exception */
protected void writeStreamComments() throws IOException {
writer.write("%!PS-Adobe-3.0 Resource-CMap\n");
writer.write("%%DocumentNeededResources: ProcSet (CIDInit)\n");
@@ -66,12 +76,19 @@ public class CMapBuilder {
writer.write("%%EndComments\n");
}
+ /** @throws IOException if i/o exception */
protected void writeCIDInit() throws IOException {
writer.write("/CIDInit /ProcSet findresource begin\n");
writer.write("12 dict begin\n");
writer.write("begincmap\n");
}
+ /**
+ * @param registry string
+ * @param ordering string
+ * @param supplement string
+ * @throws IOException if i/o exception
+ */
protected void writeCIDSystemInfo(String registry, String ordering, int supplement)
throws IOException {
writer.write("/CIDSystemInfo 3 dict dup begin\n");
@@ -87,32 +104,50 @@ public class CMapBuilder {
writer.write("end def\n");
}
+ /** @throws IOException if i/o exception */
protected void writeCIDSystemInfo() throws IOException {
writeCIDSystemInfo("Adobe", "Identity", 0);
}
+ /**
+ * @param version a version
+ * @throws IOException if i/o exception
+ */
protected void writeVersion(String version) throws IOException {
writer.write("/CMapVersion ");
writer.write(version);
writer.write(" def\n");
}
+ /**
+ * @param type a type
+ * @throws IOException if i/o exception
+ */
protected void writeType(String type) throws IOException {
writer.write("/CMapType ");
writer.write(type);
writer.write(" def\n");
}
+ /**
+ * @param name a name
+ * @throws IOException if i/o exception
+ */
protected void writeName(String name) throws IOException {
writer.write("/CMapName /");
writer.write(name);
writer.write(" def\n");
}
+ /** @throws IOException if i/o exception */
protected void writeCodeSpaceRange() throws IOException {
writeCodeSpaceRange(false);
}
+ /**
+ * @param singleByte true if single byte range
+ * @throws IOException if i/o exception
+ */
protected void writeCodeSpaceRange(boolean singleByte) throws IOException {
writer.write("1 begincodespacerange\n");
if (singleByte) {
@@ -123,18 +158,21 @@ public class CMapBuilder {
writer.write("endcodespacerange\n");
}
+ /** @throws IOException if i/o exception */
protected void writeCIDRange() throws IOException {
writer.write("1 begincidrange\n");
writer.write("<0000> <FFFF> 0\n");
writer.write("endcidrange\n");
}
+ /** @throws IOException if i/o exception */
protected void writeBFEntries() throws IOException {
// writer.write("1 beginbfrange\n");
// writer.write("<0020> <0100> <0000>\n");
// writer.write("endbfrange\n");
}
+ /** @throws IOException if i/o exception */
protected void writeWrapUp() throws IOException {
writer.write("endcmap\n");
writer.write("CMapName currentdict /CMap defineresource pop\n");
@@ -142,11 +180,13 @@ public class CMapBuilder {
writer.write("end\n");
}
+ /** @throws IOException if i/o exception */
protected void writeStreamAfterComments() throws IOException {
writer.write("%%EndResource\n");
writer.write("%%EOF\n");
}
+ /** does nothing */
protected void writeUseCMap() {
/*
* writer.write(" /Type /CMap");
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/DestinationComparator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/DestinationComparator.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/DestinationComparator.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/DestinationComparator.java Tue Jan 18 08:54:08 2011
@@ -30,6 +30,7 @@ public class DestinationComparator imple
return dest1.getIDRef().compareTo(dest2.getIDRef());
}*/
+ /** {@inheritDoc} */
public int compare (Object obj1, Object obj2) {
if (obj1 instanceof PDFDestination && obj2 instanceof PDFDestination) {
PDFDestination dest1 = (PDFDestination)obj1;
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFArray.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFArray.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFArray.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFArray.java Tue Jan 18 08:54:08 2011
@@ -172,6 +172,13 @@ public class PDFArray extends PDFObject
this.values.add(new Double(value));
}
+ /**
+ * Clears the PDF array.
+ */
+ public void clear() {
+ this.values.clear();
+ }
+
/** {@inheritDoc} */
protected int output(OutputStream stream) throws IOException {
CountingOutputStream cout = new CountingOutputStream(stream);
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFCIDFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFCIDFont.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFCIDFont.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFCIDFont.java Tue Jan 18 08:54:08 2011
@@ -56,9 +56,10 @@ public class PDFCIDFont extends PDFObjec
* @param supplement Supplement number
* @param descriptor CID font descriptor
*/
- public PDFCIDFont(String basefont, CIDFontType cidtype, int dw,
- int[] w, String registry, String ordering,
- int supplement, PDFCIDFontDescriptor descriptor) {
+ public PDFCIDFont( // CSOK: ParameterNumber
+ String basefont, CIDFontType cidtype, int dw,
+ int[] w, String registry, String ordering,
+ int supplement, PDFCIDFontDescriptor descriptor) {
this(basefont, cidtype, dw,
new PDFWArray(w),
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFDocument.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFDocument.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFDocument.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFDocument.java Tue Jan 18 08:54:08 2011
@@ -91,7 +91,7 @@ public class PDFDocument {
private long xref;
/** the character position of each object */
- private List location = new ArrayList();
+ private List<Long> location = new ArrayList<Long>();
/** List of objects to write in the trailer */
private List trailerObjects = new ArrayList();
@@ -124,8 +124,8 @@ public class PDFDocument {
private PDFEncryption encryption;
/** the colorspace (0=RGB, 1=CMYK) */
- private PDFDeviceColorSpace colorspace =
- new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
+ private PDFDeviceColorSpace colorspace
+ = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
/** the counter for Pattern name numbering (e.g. 'Pattern1') */
private int patternCount = 0;
@@ -747,6 +747,7 @@ public class PDFDocument {
* @return the image or PDFXObject for the key if found
* @deprecated Use getXObject instead (so forms are treated in the same way)
*/
+ @Deprecated
public PDFImageXObject getImage(String key) {
return (PDFImageXObject)this.xObjectsMap.get(key);
}
@@ -915,7 +916,7 @@ public class PDFDocument {
while (this.location.size() <= objidx) {
this.location.add(LOCATION_PLACEHOLDER);
}
- this.location.set(objidx, new Long(position));
+ this.location.set(objidx, position);
}
/**
@@ -1017,9 +1018,7 @@ public class PDFDocument {
output(stream);
for (int count = 0; count < this.trailerObjects.size(); count++) {
PDFObject o = (PDFObject)this.trailerObjects.get(count);
- this.location.set(
- o.getObjectNumber() - 1,
- new Long(this.position));
+ setLocation(o.getObjectNumber() - 1, this.position);
this.position += o.output(stream);
}
/* output the xref table and increment the character position
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java Tue Jan 18 08:54:08 2011
@@ -21,7 +21,6 @@ package org.apache.fop.pdf;
// Java
import java.io.IOException;
-import java.io.InputStream;
import java.io.OutputStream;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
@@ -80,26 +79,6 @@ public class PDFEncryptionJCE extends PD
}
/**
- * Encode the given data with the filter
- * @param data The data to be encrypted
- * @return The encrypted data
- */
- public byte[] encode(byte[] data) {
- return encryption.encryptData(data, number, generation);
- }
-
- /**
- * {@inheritDoc}
- */
- public void encode(InputStream in, OutputStream out, int length)
- throws IOException {
- byte[] buffer = new byte[length];
- in.read(buffer);
- buffer = encode(buffer);
- out.write(buffer);
- }
-
- /**
* {@inheritDoc}
*/
public OutputStream applyFilter(OutputStream out) throws IOException {
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFEncryptionManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFEncryptionManager.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFEncryptionManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFEncryptionManager.java Tue Jan 18 08:54:08 2011
@@ -31,10 +31,13 @@ import org.apache.commons.logging.LogFac
* This class acts as a factory for PDF encryption support. It enables the
* feature to be optional to FOP depending on the availability of JCE.
*/
-public class PDFEncryptionManager {
+public final class PDFEncryptionManager {
+
+ private PDFEncryptionManager() {
+ }
/** logging instance */
- protected static Log log = LogFactory.getLog(PDFEncryptionManager.class);
+ private static final Log LOG = LogFactory.getLog(PDFEncryptionManager.class);
/**
* Indicates whether JCE is available.
@@ -60,12 +63,12 @@ public class PDFEncryptionManager {
Provider[] providers;
providers = Security.getProviders("Cipher.RC4");
if (providers == null) {
- log.warn("Cipher provider for RC4 not available.");
+ LOG.warn("Cipher provider for RC4 not available.");
return false;
}
providers = Security.getProviders("MessageDigest.MD5");
if (providers == null) {
- log.warn("MessageDigest provider for MD5 not available.");
+ LOG.warn("MessageDigest provider for MD5 not available.");
return false;
}
return true;
@@ -88,13 +91,13 @@ public class PDFEncryptionManager {
if (params != null) {
if (!checkAvailableAlgorithms()) {
if (isJCEAvailable()) {
- log.warn("PDF encryption has been requested, JCE is "
+ LOG.warn("PDF encryption has been requested, JCE is "
+ "available but there's no "
+ "JCE provider available that provides the "
+ "necessary algorithms. The PDF won't be "
+ "encrypted.");
} else {
- log.warn("PDF encryption has been requested but JCE is "
+ LOG.warn("PDF encryption has been requested but JCE is "
+ "unavailable! The PDF won't be encrypted.");
}
}
@@ -119,19 +122,19 @@ public class PDFEncryptionManager {
return (PDFEncryption)obj;
} catch (ClassNotFoundException e) {
if (checkAvailableAlgorithms()) {
- log.warn("JCE and algorithms available, but the "
+ LOG.warn("JCE and algorithms available, but the "
+ "implementation class unavailable. Please do a full "
+ "rebuild.");
}
return null;
} catch (NoSuchMethodException e) {
- log.error(e);
+ LOG.error(e);
return null;
} catch (IllegalAccessException e) {
- log.error(e);
+ LOG.error(e);
return null;
} catch (InvocationTargetException e) {
- log.error(e);
+ LOG.error(e);
return null;
}
}
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFFactory.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFFactory.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFFactory.java Tue Jan 18 08:54:08 2011
@@ -69,6 +69,9 @@ import org.apache.fop.fonts.type1.PFBPar
*/
public class PDFFactory {
+ /** Resolution of the User Space coordinate system (72dpi). */
+ public static final int DEFAULT_PDF_RESOLUTION = 72;
+
private PDFDocument document;
private Log log = LogFactory.getLog(PDFFactory.class);
@@ -293,12 +296,13 @@ public class PDFFactory {
* It should be 0 as this is the constructor for sampled functions.
* @return the PDF function that was created
*/
- public PDFFunction makeFunction(int theFunctionType, List theDomain,
- List theRange, List theSize,
- int theBitsPerSample, int theOrder,
- List theEncode, List theDecode,
- StringBuffer theFunctionDataStream,
- List theFilter) {
+ public PDFFunction makeFunction( // CSOK: ParameterNumber
+ int theFunctionType, List theDomain,
+ List theRange, List theSize,
+ int theBitsPerSample, int theOrder,
+ List theEncode, List theDecode,
+ StringBuffer theFunctionDataStream,
+ List theFilter) {
// Type 0 function
PDFFunction function = new PDFFunction(theFunctionType, theDomain,
theRange, theSize,
@@ -466,12 +470,13 @@ public class PDFFactory {
* @param theFunction The PDF Function that maps an (x,y) location to a color
* @return the PDF shading that was created
*/
- public PDFShading makeShading(PDFResourceContext res, int theShadingType,
- PDFDeviceColorSpace theColorSpace,
- List theBackground, List theBBox,
- boolean theAntiAlias, List theDomain,
- List theMatrix,
- PDFFunction theFunction) {
+ public PDFShading makeShading( // CSOK: ParameterNumber
+ PDFResourceContext res, int theShadingType,
+ PDFDeviceColorSpace theColorSpace,
+ List theBackground, List theBBox,
+ boolean theAntiAlias, List theDomain,
+ List theMatrix,
+ PDFFunction theFunction) {
// make Shading of Type 1
PDFShading shading = new PDFShading(theShadingType,
theColorSpace, theBackground,
@@ -518,12 +523,13 @@ public class PDFFactory {
* The default is [false, false]
* @return the PDF shading that was created
*/
- public PDFShading makeShading(PDFResourceContext res, int theShadingType,
- PDFDeviceColorSpace theColorSpace,
- List theBackground, List theBBox,
- boolean theAntiAlias, List theCoords,
- List theDomain, PDFFunction theFunction,
- List theExtend) {
+ public PDFShading makeShading( // CSOK: ParameterNumber
+ PDFResourceContext res, int theShadingType,
+ PDFDeviceColorSpace theColorSpace,
+ List theBackground, List theBBox,
+ boolean theAntiAlias, List theCoords,
+ List theDomain, PDFFunction theFunction,
+ List theExtend) {
// make Shading of Type 2 or 3
PDFShading shading = new PDFShading(theShadingType,
theColorSpace, theBackground,
@@ -571,14 +577,15 @@ public class PDFFactory {
* @param theFunction the PDFFunction
* @return the PDF shading that was created
*/
- public PDFShading makeShading(PDFResourceContext res, int theShadingType,
- PDFDeviceColorSpace theColorSpace,
- List theBackground, List theBBox,
- boolean theAntiAlias,
- int theBitsPerCoordinate,
- int theBitsPerComponent,
- int theBitsPerFlag, List theDecode,
- PDFFunction theFunction) {
+ public PDFShading makeShading( // CSOK: ParameterNumber
+ PDFResourceContext res, int theShadingType,
+ PDFDeviceColorSpace theColorSpace,
+ List theBackground, List theBBox,
+ boolean theAntiAlias,
+ int theBitsPerCoordinate,
+ int theBitsPerComponent,
+ int theBitsPerFlag, List theDecode,
+ PDFFunction theFunction) {
// make Shading of type 4,6 or 7
PDFShading shading = new PDFShading(theShadingType,
theColorSpace, theBackground,
@@ -626,14 +633,15 @@ public class PDFFactory {
* @param theFunction The PDFFunction that's mapped on to this shape
* @return the PDF shading that was created
*/
- public PDFShading makeShading(PDFResourceContext res, int theShadingType,
- PDFDeviceColorSpace theColorSpace,
- List theBackground, List theBBox,
- boolean theAntiAlias,
- int theBitsPerCoordinate,
- int theBitsPerComponent, List theDecode,
- int theVerticesPerRow,
- PDFFunction theFunction) {
+ public PDFShading makeShading( // CSOK: ParameterNumber
+ PDFResourceContext res, int theShadingType,
+ PDFDeviceColorSpace theColorSpace,
+ List theBackground, List theBBox,
+ boolean theAntiAlias,
+ int theBitsPerCoordinate,
+ int theBitsPerComponent, List theDecode,
+ int theVerticesPerRow,
+ PDFFunction theFunction) {
// make shading of Type 5
PDFShading shading = new PDFShading(theShadingType,
theColorSpace, theBackground,
@@ -676,11 +684,12 @@ public class PDFFactory {
* @param thePatternDataStream The stream of pattern data to be tiled.
* @return the PDF pattern that was created
*/
- public PDFPattern makePattern(PDFResourceContext res, int thePatternType, // 1
- PDFResources theResources, int thePaintType, int theTilingType,
- List theBBox, double theXStep,
- double theYStep, List theMatrix,
- List theXUID, StringBuffer thePatternDataStream) {
+ public PDFPattern makePattern( // CSOK: ParameterNumber
+ PDFResourceContext res, int thePatternType, // 1
+ PDFResources theResources, int thePaintType, int theTilingType,
+ List theBBox, double theXStep,
+ double theYStep, List theMatrix,
+ List theXUID, StringBuffer thePatternDataStream) {
// PDFResources theResources
PDFPattern pattern = new PDFPattern(theResources, 1,
thePaintType, theTilingType,
@@ -884,7 +893,8 @@ public class PDFFactory {
*/
public PDFNames makeNames() {
PDFNames names = new PDFNames();
- getDocument().registerObject(names);
+ getDocument().assignObjectNumber(names);
+ getDocument().addTrailerObject(names);
return names;
}
@@ -1057,6 +1067,8 @@ public class PDFFactory {
return link;
}
+ private static final String EMBEDDED_FILE = "embedded-file:";
+
/**
* Create/find and return the appropriate external PDFAction according to the target
*
@@ -1069,32 +1081,88 @@ public class PDFFactory {
public PDFAction getExternalAction(String target, boolean newWindow) {
int index;
String targetLo = target.toLowerCase();
- // HTTP URL?
- if (targetLo.startsWith("http://")) {
+ if (target.startsWith(EMBEDDED_FILE)) {
+ // File Attachments (Embedded Files)
+ String filename = target.substring(EMBEDDED_FILE.length());
+ return getActionForEmbeddedFile(filename, newWindow);
+ } else if (targetLo.startsWith("http://")) {
+ // HTTP URL?
return new PDFUri(target);
- // Non PDF files. Try to /Launch them.
} else if (targetLo.startsWith("file://")) {
+ // Non PDF files. Try to /Launch them.
target = target.substring("file://".length());
return getLaunchAction(target);
- // Bare PDF file name?
} else if (targetLo.endsWith(".pdf")) {
+ // Bare PDF file name?
return getGoToPDFAction(target, null, -1, newWindow);
- // PDF file + page?
- } else if ((index = targetLo.indexOf(".pdf#page=")) > 0) {
+ } else if ((index = targetLo.indexOf(".pdf#page=")) > 0) { // CSOK: InnerAssignment
+ // PDF file + page?
String filename = target.substring(0, index + 4);
int page = Integer.parseInt(target.substring(index + 10));
return getGoToPDFAction(filename, null, page, newWindow);
- // PDF file + destination?
- } else if ((index = targetLo.indexOf(".pdf#dest=")) > 0) {
+ } else if ((index = targetLo.indexOf(".pdf#dest=")) > 0) { // CSOK: InnerAssignment
+ // PDF file + destination?
String filename = target.substring(0, index + 4);
String dest = target.substring(index + 10);
return getGoToPDFAction(filename, dest, -1, newWindow);
- // None of the above? Default to URI:
} else {
+ // None of the above? Default to URI:
return new PDFUri(target);
}
}
+ private PDFAction getActionForEmbeddedFile(String filename, boolean newWindow) {
+ PDFNames names = getDocument().getRoot().getNames();
+ if (names == null) {
+ throw new IllegalStateException(
+ "No Names dictionary present."
+ + " Cannot create Launch Action for embedded file: " + filename);
+ }
+ PDFNameTreeNode embeddedFiles = names.getEmbeddedFiles();
+ if (embeddedFiles == null) {
+ throw new IllegalStateException(
+ "No /EmbeddedFiles name tree present."
+ + " Cannot create Launch Action for embedded file: " + filename);
+ }
+
+ //Find filespec reference for the embedded file
+ filename = PDFText.toPDFString(filename, '_');
+ PDFArray files = embeddedFiles.getNames();
+ PDFReference embeddedFileRef = null;
+ int i = 0;
+ while (i < files.length()) {
+ String name = (String)files.get(i);
+ i++;
+ PDFReference ref = (PDFReference)files.get(i);
+ if (name.equals(filename)) {
+ embeddedFileRef = ref;
+ break;
+ }
+ i++;
+ }
+ if (embeddedFileRef == null) {
+ throw new IllegalStateException(
+ "No embedded file with name " + filename + " present.");
+ }
+
+ //Finally create the action
+ //PDFLaunch action = new PDFLaunch(embeddedFileRef);
+ //This works with Acrobat 8 but not with Acrobat 9
+
+ //The following two options didn't seem to have any effect.
+ //PDFGoToEmbedded action = new PDFGoToEmbedded(embeddedFileRef, 0, newWindow);
+ //PDFGoToRemote action = new PDFGoToRemote(embeddedFileRef, 0, newWindow);
+
+ //This finally seems to work:
+ StringBuffer scriptBuffer = new StringBuffer();
+ scriptBuffer.append("this.exportDataObject({cName:\"");
+ scriptBuffer.append(filename);
+ scriptBuffer.append("\", nLaunch:2});");
+
+ PDFJavaScriptLaunchAction action = new PDFJavaScriptLaunchAction(scriptBuffer.toString());
+ return action;
+ }
+
/**
* Create or find a PDF GoTo with the given page reference string and Y offset,
* and return its PDF object reference
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFFileSpec.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFFileSpec.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFFileSpec.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFFileSpec.java Tue Jan 18 08:54:08 2011
@@ -20,15 +20,9 @@
package org.apache.fop.pdf;
/**
- * class representing a /FileSpec object.
- *
+ * Class representing a /FileSpec object.
*/
-public class PDFFileSpec extends PDFObject {
-
- /**
- * the filename
- */
- protected String filename;
+public class PDFFileSpec extends PDFDictionary {
/**
* create a /FileSpec object.
@@ -39,29 +33,30 @@ public class PDFFileSpec extends PDFObje
/* generic creation of object */
super();
+ put("Type", new PDFName("Filespec"));
+ put("F", filename);
+ }
- this.filename = filename;
+ private String getFilename() {
+ return (String)get("F");
}
/**
- * {@inheritDoc}
+ * Associates an dictionary with pointers to embedded file streams with this file spec.
+ * @param embeddedFileDict the dictionary with pointers to embedded file streams
*/
- public String toPDFString() {
- return getObjectID()
- + "<<\n/Type /FileSpec\n"
- + "/F (" + this.filename + ")\n"
- + ">>\nendobj\n";
+ public void setEmbeddedFile(PDFDictionary embeddedFileDict) {
+ put("EF", embeddedFileDict);
}
- /*
- * example
- * 29 0 obj
- * <<
- * /Type /FileSpec
- * /F (table1.pdf)
- * >>
- * endobj
+ /**
+ * Sets a description for the file spec.
+ * @param description the description
+ * @since PDF 1.6
*/
+ public void setDescription(String description) {
+ put("Desc", description);
+ }
/** {@inheritDoc} */
protected boolean contentEquals(PDFObject obj) {
@@ -75,7 +70,7 @@ public class PDFFileSpec extends PDFObje
PDFFileSpec spec = (PDFFileSpec)obj;
- if (!spec.filename.equals(filename)) {
+ if (!spec.getFilename().equals(getFilename())) {
return false;
}
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFFontDescriptor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFFontDescriptor.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFFontDescriptor.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFFontDescriptor.java Tue Jan 18 08:54:08 2011
@@ -40,10 +40,11 @@ public class PDFFontDescriptor extends P
* @param italicAngle the angle of the vertical dominant strokes
* @param stemV the width of the dominant vertical stems of glyphs
*/
- public PDFFontDescriptor(String basefont, int ascent,
- int descent, int capHeight, int flags,
- PDFRectangle fontBBox, int italicAngle,
- int stemV) {
+ public PDFFontDescriptor( // CSOK: ParameterNumber
+ String basefont, int ascent,
+ int descent, int capHeight, int flags,
+ PDFRectangle fontBBox, int italicAngle,
+ int stemV) {
super();
put("Type", new PDFName("FontDescriptor"));
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFFunction.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFFunction.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFFunction.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFFunction.java Tue Jan 18 08:54:08 2011
@@ -211,10 +211,11 @@ public class PDFFunction extends PDFObje
* @param theFunctionType This is the type of function (0,2,3, or 4).
* It should be 0 as this is the constructor for sampled functions.
*/
- public PDFFunction(int theFunctionType, List theDomain,
- List theRange, List theSize, int theBitsPerSample,
- int theOrder, List theEncode, List theDecode,
- StringBuffer theFunctionDataStream, List theFilter) {
+ public PDFFunction( // CSOK: ParameterNumber
+ int theFunctionType, List theDomain,
+ List theRange, List theSize, int theBitsPerSample,
+ int theOrder, List theEncode, List theDecode,
+ StringBuffer theFunctionDataStream, List theFilter) {
super();
this.functionType = 0; // dang well better be 0;
@@ -374,7 +375,7 @@ public class PDFFunction extends PDFObje
*
* @return the PDF string.
*/
- public byte[] toPDF() {
+ public byte[] toPDF() { // CSOK: MethodLength
int vectorSize = 0;
int numberOfFunctions = 0;
int tempInt = 0;
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFGoTo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFGoTo.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFGoTo.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFGoTo.java Tue Jan 18 08:54:08 2011
@@ -42,10 +42,8 @@ public class PDFGoTo extends PDFAction {
* @param pageReference the pageReference represented by this object
*/
public PDFGoTo(String pageReference) {
- /* generic creation of object */
super();
-
- this.pageReference = pageReference;
+ setPageReference(pageReference);
}
/**
@@ -56,9 +54,7 @@ public class PDFGoTo extends PDFAction {
*/
public PDFGoTo(String pageReference, Point2D position) {
/* generic creation of object */
- super();
-
- this.pageReference = pageReference;
+ this(pageReference);
setPosition(position);
}
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFGoToRemote.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFGoToRemote.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFGoToRemote.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFGoToRemote.java Tue Jan 18 08:54:08 2011
@@ -27,7 +27,7 @@ public class PDFGoToRemote extends PDFAc
/**
* the file specification
*/
- private PDFFileSpec pdfFileSpec;
+ private PDFReference pdfFileSpec;
private int pageReference = 0;
private String destination = null;
private boolean newWindow = false;
@@ -43,12 +43,12 @@ public class PDFGoToRemote extends PDFAc
/* generic creation of object */
super();
- this.pdfFileSpec = pdfFileSpec;
+ this.pdfFileSpec = pdfFileSpec.makeReference();
this.newWindow = newWindow;
}
/**
- * create an GoToR object.
+ * Create an GoToR object.
*
* @param pdfFileSpec the fileSpec associated with the action
* @param page a page reference within the remote document
@@ -56,7 +56,18 @@ public class PDFGoToRemote extends PDFAc
* displayed in a new window
*/
public PDFGoToRemote(PDFFileSpec pdfFileSpec, int page, boolean newWindow) {
- /* generic creation of object */
+ this(pdfFileSpec.makeReference(), page, newWindow);
+ }
+
+ /**
+ * Create an GoToR object.
+ *
+ * @param pdfFileSpec the fileSpec associated with the action
+ * @param page a page reference within the remote document
+ * @param newWindow boolean indicating whether the target should be
+ * displayed in a new window
+ */
+ public PDFGoToRemote(PDFReference pdfFileSpec, int page, boolean newWindow) {
super();
this.pdfFileSpec = pdfFileSpec;
@@ -76,7 +87,7 @@ public class PDFGoToRemote extends PDFAc
/* generic creation of object */
super();
- this.pdfFileSpec = pdfFileSpec;
+ this.pdfFileSpec = pdfFileSpec.makeReference();
this.destination = dest;
this.newWindow = newWindow;
}
@@ -97,7 +108,7 @@ public class PDFGoToRemote extends PDFAc
StringBuffer sb = new StringBuffer(64);
sb.append(getObjectID());
sb.append("<<\n/S /GoToR\n/F ");
- sb.append(pdfFileSpec.referencePDF());
+ sb.append(pdfFileSpec.toString());
sb.append("\n");
if (destination != null) {
@@ -139,7 +150,7 @@ public class PDFGoToRemote extends PDFAc
PDFGoToRemote remote = (PDFGoToRemote)obj;
- if (!remote.pdfFileSpec.referencePDF().equals(pdfFileSpec.referencePDF())) {
+ if (!remote.pdfFileSpec.toString().equals(pdfFileSpec.toString())) {
return false;
}
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFLaunch.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFLaunch.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFLaunch.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFLaunch.java Tue Jan 18 08:54:08 2011
@@ -5,7 +5,7 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
-
+ *
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@@ -14,7 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
/* $Id$ */
+
package org.apache.fop.pdf;
/**
@@ -22,21 +24,39 @@ package org.apache.fop.pdf;
*/
public class PDFLaunch extends PDFAction {
- private PDFFileSpec externalFileSpec;
+ private PDFReference externalFileSpec;
+ /**
+ * Creates a new /Launch action.
+ * @param fileSpec the file specification to launch
+ */
public PDFLaunch(PDFFileSpec fileSpec) {
+ this(fileSpec.makeReference());
+ }
+
+ /**
+ * Creates a new /Launch action.
+ * @param fileSpec a reference to the file specification
+ */
+ public PDFLaunch(PDFReference fileSpec) {
+ PDFObject fs = fileSpec.getObject();
+ if (fs != null) {
+ assert fs instanceof PDFFileSpec;
+ }
this.externalFileSpec = fileSpec;
}
+ /** {@inheritDoc} */
public String getAction() {
return this.referencePDF();
}
+ /** {@inheritDoc} */
public String toPDFString() {
StringBuffer sb = new StringBuffer(64);
sb.append(getObjectID());
sb.append("<<\n/S /Launch\n/F ");
- sb.append(externalFileSpec.referencePDF());
+ sb.append(externalFileSpec.toString());
sb.append(" \n>>\nendobj\n");
return sb.toString();
@@ -54,7 +74,7 @@ public class PDFLaunch extends PDFAction
PDFLaunch launch = (PDFLaunch) obj;
- if (!launch.externalFileSpec.referencePDF().equals(externalFileSpec.referencePDF())) {
+ if (!launch.externalFileSpec.toString().equals(externalFileSpec.toString())) {
return false;
}
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFMetadata.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFMetadata.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFMetadata.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFMetadata.java Tue Jan 18 08:54:08 2011
@@ -47,7 +47,11 @@ public class PDFMetadata extends PDFStre
private Metadata xmpMetadata;
private boolean readOnly = true;
- /** @see org.apache.fop.pdf.PDFObject#PDFObject() */
+ /**
+ * @param xmp xmp metadata
+ * @param readOnly true if read only
+ * @see org.apache.fop.pdf.PDFObject#PDFObject()
+ */
public PDFMetadata(Metadata xmp, boolean readOnly) {
super();
if (xmp == null) {
@@ -147,6 +151,9 @@ public class PDFMetadata extends PDFStre
}
dc.addDate(info.getCreationDate());
+ //Somewhat redundant but some PDF/A checkers issue a warning without this.
+ dc.setFormat("application/pdf");
+
//PDF/A identification
PDFAMode pdfaMode = pdfDoc.getProfile().getPDFAMode();
if (pdfaMode.isPDFA1LevelB()) {
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFName.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFName.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFName.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFName.java Tue Jan 18 08:54:08 2011
@@ -41,6 +41,7 @@ public class PDFName extends PDFObject {
this.name = escapeName(name);
}
+ private static final String ESCAPED_NAME_CHARS = "/()<>[]%#";
/**
* Escapes a PDF name. It adds the leading slash and escapes characters as necessary.
@@ -56,7 +57,8 @@ public class PDFName extends PDFObject {
}
for (int i = (skipFirst ? 1 : 0), c = name.length(); i < c; i++) {
char ch = name.charAt(i);
- if (ch < 33 || ch > 126 || ch == 0x2F) {
+
+ if (ch < 33 || ch > 126 || ESCAPED_NAME_CHARS.indexOf(ch) >= 0) {
sb.append('#');
toHex(ch, sb);
} else {
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFNameTreeNode.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFNameTreeNode.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFNameTreeNode.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFNameTreeNode.java Tue Jan 18 08:54:08 2011
@@ -19,6 +19,7 @@
package org.apache.fop.pdf;
+
/**
* Class representing a PDF name tree node.
*/
@@ -104,7 +105,6 @@ public class PDFNameTreeNode extends PDF
return (String)limits.get(1);
}
-
private PDFArray prepareLimitsArray() {
PDFArray limits = (PDFArray)get(LIMITS);
if (limits == null) {
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFNames.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFNames.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFNames.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFNames.java Tue Jan 18 08:54:08 2011
@@ -24,6 +24,9 @@ package org.apache.fop.pdf;
*/
public class PDFNames extends PDFDictionary {
+ private static final String DESTS = "Dests";
+ private static final String EMBEDDED_FILES = "EmbeddedFiles";
+
/**
* Create the Names object
*/
@@ -37,7 +40,7 @@ public class PDFNames extends PDFDiction
* @return the Dests object, or null if it's not used
*/
public PDFDests getDests() {
- return (PDFDests)get("Dests");
+ return (PDFDests)get(DESTS);
}
/**
@@ -45,7 +48,23 @@ public class PDFNames extends PDFDiction
* @param dests the Dests object
*/
public void setDests(PDFDests dests) {
- put("Dests", dests);
+ put(DESTS, dests);
+ }
+
+ /**
+ * Returns the EmbeddedFiles object
+ * @return the EmbeddedFiles object, or null if it's not used
+ */
+ public PDFEmbeddedFiles getEmbeddedFiles() {
+ return (PDFEmbeddedFiles)get(EMBEDDED_FILES);
+ }
+
+ /**
+ * Set the EmbeddedFiles object
+ * @param embeddedFiles the EmbeddedFiles object
+ */
+ public void setEmbeddedFiles(PDFEmbeddedFiles embeddedFiles) {
+ put(EMBEDDED_FILES, embeddedFiles);
}
}
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFNull.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFNull.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFNull.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFNull.java Tue Jan 18 08:54:08 2011
@@ -33,7 +33,6 @@ public final class PDFNull implements PD
/**
* Creates a new PDF name object.
- * @param name the name value
*/
private PDFNull() {
}
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFObject.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFObject.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFObject.java Tue Jan 18 08:54:08 2011
@@ -42,7 +42,7 @@ import org.apache.commons.logging.LogFac
public abstract class PDFObject implements PDFWritable {
/** logger for all PDFObjects (and descendants) */
- protected static Log log = LogFactory.getLog(PDFObject.class.getName());
+ protected static final Log log = LogFactory.getLog(PDFObject.class.getName());
/**
* the object's number
@@ -401,7 +401,7 @@ public abstract class PDFObject implemen
* identical, this method is not required to check everything. In the case
* of PDFObjects, this means that the overriding function does not have to
* check for {@link #getObjectID()}.
- *
+ *
* @param o
* object to compare to.
* @return true if the other object has the same content.
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFPattern.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFPattern.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFPattern.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFPattern.java Tue Jan 18 08:54:08 2011
@@ -117,11 +117,12 @@ public class PDFPattern extends PDFPathP
* @param theXUID Optional vector of Integers that uniquely identify the pattern
* @param thePatternDataStream The stream of pattern data to be tiled.
*/
- public PDFPattern(PDFResources theResources, int thePatternType, // 1
- int thePaintType, int theTilingType, List theBBox,
- double theXStep, double theYStep,
- List theMatrix, List theXUID,
- StringBuffer thePatternDataStream) {
+ public PDFPattern( // CSOK: ParameterNumber
+ PDFResources theResources, int thePatternType, // 1
+ int thePaintType, int theTilingType, List theBBox,
+ double theXStep, double theYStep,
+ List theMatrix, List theXUID,
+ StringBuffer thePatternDataStream) {
super();
this.resources = theResources;
// This next parameter is implicit to all constructors, and is
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFProfile.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFProfile.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFProfile.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFProfile.java Tue Jan 18 08:54:08 2011
@@ -265,4 +265,16 @@ public class PDFProfile {
}
}
+ /** Checks if embedded files are allowed. */
+ public void verifyEmbeddedFilesAllowed() {
+ final String err = "{0} does not allow embedded files.";
+ if (isPDFAActive()) {
+ throw new PDFConformanceException(format(err, getPDFAMode()));
+ }
+ if (isPDFXActive()) {
+ //Implicit since file specs are forbidden
+ throw new PDFConformanceException(format(err, getPDFXMode()));
+ }
+ }
+
}
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFResources.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFResources.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFResources.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/pdf/PDFResources.java Tue Jan 18 08:54:08 2011
@@ -100,11 +100,9 @@ public class PDFResources extends PDFDic
* @param fontInfo font info object to get font information from
*/
public void addFonts(PDFDocument doc, FontInfo fontInfo) {
- Map usedFonts = fontInfo.getUsedFonts();
- Iterator e = usedFonts.keySet().iterator();
- while (e.hasNext()) {
- String f = (String)e.next();
- Typeface font = (Typeface)usedFonts.get(f);
+ Map<String, Typeface> usedFonts = fontInfo.getUsedFonts();
+ for (String f : usedFonts.keySet()) {
+ Typeface font = usedFonts.get(f);
//Check if the font actually had any mapping operations. If not, it is an indication
//that it has never actually been used and therefore doesn't have to be embedded.
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org