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 2010/11/15 14:58:42 UTC
svn commit: r1035278 [2/3] - in
/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript: ./
src/documentation/content/xdocs/ src/documentation/content/xdocs/dev/
src/documentation/content/xdocs/trunk/ src/java/org/apache/fop/afp/
src/java/org/apache/fop/af...
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/Hyphenator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/Hyphenator.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/Hyphenator.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/Hyphenator.java Mon Nov 15 13:58:40 2010
@@ -24,6 +24,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
+import java.util.Map;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
@@ -39,32 +40,20 @@ import org.xml.sax.InputSource;
*
* @author Carlos Villegas <ca...@uniscope.co.jp>
*/
-public class Hyphenator {
+public final class Hyphenator {
/** logging instance */
protected static Log log = LogFactory.getLog(Hyphenator.class);
private static HyphenationTreeCache hTreeCache = null;
- private HyphenationTree hyphenTree = null;
- private int remainCharCount = 2;
- private int pushCharCount = 2;
/** Enables a dump of statistics. Note: If activated content is sent to System.out! */
private static boolean statisticsDump = false;
/**
* Creates a new hyphenator.
- * @param lang the language
- * @param country the country (may be null or "none")
- * @param leftMin the minimum number of characters before the hyphenation point
- * @param rightMin the minimum number of characters after the hyphenation point
*/
- public Hyphenator(String lang, String country, int leftMin,
- int rightMin) {
- hyphenTree = getHyphenationTree(lang, country);
- remainCharCount = leftMin;
- pushCharCount = rightMin;
- }
+ private Hyphenator() { }
/** @return the default (static) hyphenation tree cache */
public static synchronized HyphenationTreeCache getHyphenationTreeCache() {
@@ -75,35 +64,76 @@ public class Hyphenator {
}
/**
- * Returns a hyphenation tree for a given language and country. The hyphenation trees are
- * cached.
+ * Returns a hyphenation tree for a given language and country,
+ * with fallback from (lang,country) to (lang).
+ * The hyphenation trees are cached.
* @param lang the language
* @param country the country (may be null or "none")
+ * @param resolver resolver to find the hyphenation files
+ * @param hyphPatNames the map with user-configured hyphenation pattern file names
* @return the hyphenation tree
*/
public static HyphenationTree getHyphenationTree(String lang,
- String country) {
- return getHyphenationTree(lang, country, null);
+ String country, HyphenationTreeResolver resolver, Map hyphPatNames) {
+ String llccKey = HyphenationTreeCache.constructLlccKey(lang, country);
+ HyphenationTreeCache cache = getHyphenationTreeCache();
+
+ // If this hyphenation tree has been registered as missing, return immediately
+ if (cache.isMissing(llccKey)) {
+ return null;
+ }
+
+ HyphenationTree hTree = getHyphenationTree2(lang, country, resolver, hyphPatNames);
+
+ // fallback to lang only
+ if (hTree == null && country != null && !country.equals("none")) {
+ String llKey = HyphenationTreeCache.constructLlccKey(lang, null);
+ if (!cache.isMissing(llKey)) {
+ hTree = getHyphenationTree2(lang, null, resolver, hyphPatNames);
+ if (hTree != null && log.isDebugEnabled()) {
+ log.debug("Couldn't find hyphenation pattern "
+ + "for lang=\"" + lang + "\",country=\"" + country + "\"."
+ + " Using general language pattern "
+ + "for lang=\"" + lang + "\" instead.");
+ }
+ if (hTree == null) {
+ // no fallback; register as missing
+ cache.noteMissing(llKey);
+ } else {
+ // also register for (lang,country)
+ cache.cache(llccKey, hTree);
+ }
+ }
+ }
+
+ if (hTree == null) {
+ // (lang,country) and (lang) tried; register as missing
+ cache.noteMissing(llccKey);
+ log.error("Couldn't find hyphenation pattern "
+ + "for lang=\"" + lang + "\""
+ + (country != null && !country.equals("none")
+ ? ",country=\"" + country + "\""
+ : "")
+ + ".");
+ }
+
+ return hTree;
}
/**
- * Returns a hyphenation tree for a given language and country. The hyphenation trees are
- * cached.
+ * Returns a hyphenation tree for a given language and country
+ * The hyphenation trees are cached.
* @param lang the language
* @param country the country (may be null or "none")
* @param resolver resolver to find the hyphenation files
+ * @param hyphPatNames the map with user-configured hyphenation pattern file names
* @return the hyphenation tree
*/
- public static HyphenationTree getHyphenationTree(String lang,
- String country, HyphenationTreeResolver resolver) {
- String key = HyphenationTreeCache.constructKey(lang, country);
+ private static HyphenationTree getHyphenationTree2(String lang,
+ String country, HyphenationTreeResolver resolver, Map hyphPatNames) {
+ String llccKey = HyphenationTreeCache.constructLlccKey(lang, country);
HyphenationTreeCache cache = getHyphenationTreeCache();
- // See if there was an error finding this hyphenation tree before
- if (cache.isMissing(key)) {
- return null;
- }
-
HyphenationTree hTree;
// first try to find it in the cache
hTree = getHyphenationTreeCache().getHyphenationTree(lang, country);
@@ -111,6 +141,11 @@ public class Hyphenator {
return hTree;
}
+ String key = HyphenationTreeCache.constructUserKey(lang, country, hyphPatNames);
+ if (key == null) {
+ key = llccKey;
+ }
+
if (resolver != null) {
hTree = getUserHyphenationTree(key, resolver);
}
@@ -120,11 +155,9 @@ public class Hyphenator {
// put it into the pattern cache
if (hTree != null) {
- cache.cache(key, hTree);
- } else {
- log.error("Couldn't find hyphenation pattern " + key);
- cache.noteMissing(key);
+ cache.cache(llccKey, hTree);
}
+
return hTree;
}
@@ -179,31 +212,11 @@ public class Hyphenator {
try {
is = getResourceStream(key);
if (is == null) {
- if (key.length() == 5) {
- String lang = key.substring(0, 2);
- is = getResourceStream(lang);
- if (is != null) {
- if (log.isDebugEnabled()) {
- log.debug("Couldn't find hyphenation pattern '"
- + key
- + "'. Using general language pattern '"
- + lang
- + "' instead.");
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Couldn't find precompiled hyphenation pattern "
- + lang + " in resources.");
- }
- return null;
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Couldn't find precompiled hyphenation pattern "
- + key + " in resources");
- }
- return null;
+ if (log.isDebugEnabled()) {
+ log.debug("Couldn't find precompiled hyphenation pattern "
+ + key + " in resources");
}
+ return null;
}
hTree = readHyphenationTree(is);
} finally {
@@ -335,6 +348,7 @@ public class Hyphenator {
* @param lang the language
* @param country the optional country code (may be null or "none")
* @param resolver resolver to find the hyphenation files
+ * @param hyphPatNames the map with user-configured hyphenation pattern file names
* @param word the word to hyphenate
* @param leftMin the minimum number of characters before the hyphenation point
* @param rightMin the minimum number of characters after the hyphenation point
@@ -342,121 +356,14 @@ public class Hyphenator {
*/
public static Hyphenation hyphenate(String lang, String country,
HyphenationTreeResolver resolver,
+ Map hyphPatNames,
String word,
int leftMin, int rightMin) {
- HyphenationTree hTree = getHyphenationTree(lang, country, resolver);
+ HyphenationTree hTree = getHyphenationTree(lang, country, resolver, hyphPatNames);
if (hTree == null) {
return null;
}
return hTree.hyphenate(word, leftMin, rightMin);
}
- /**
- * Hyphenates a word.
- * @param lang the language
- * @param country the optional country code (may be null or "none")
- * @param word the word to hyphenate
- * @param leftMin the minimum number of characters before the hyphenation point
- * @param rightMin the minimum number of characters after the hyphenation point
- * @return the hyphenation result
- */
- public static Hyphenation hyphenate(String lang, String country,
- String word,
- int leftMin, int rightMin) {
- return hyphenate(lang, country, null, word, leftMin, rightMin);
- }
-
- /**
- * Hyphenates a word.
- * @param lang the language
- * @param country the optional country code (may be null or "none")
- * @param resolver resolver to find the hyphenation files
- * @param word the word to hyphenate
- * @param offset the offset of the first character in the "word" character array
- * @param len the length of the word
- * @param leftMin the minimum number of characters before the hyphenation point
- * @param rightMin the minimum number of characters after the hyphenation point
- * @return the hyphenation result
- */
- public static Hyphenation hyphenate(String lang, // CSOK: ParameterNumber
- String country,
- HyphenationTreeResolver resolver,
- char[] word, int offset, int len,
- int leftMin, int rightMin) {
- HyphenationTree hTree = getHyphenationTree(lang, country, resolver);
- if (hTree == null) {
- return null;
- }
- return hTree.hyphenate(word, offset, len, leftMin, rightMin);
- }
-
- /**
- * Hyphenates a word.
- * @param lang the language
- * @param country the optional country code (may be null or "none")
- * @param word the word to hyphenate
- * @param offset the offset of the first character in the "word" character array
- * @param len the length of the word
- * @param leftMin the minimum number of characters before the hyphenation point
- * @param rightMin the minimum number of characters after the hyphenation point
- * @return the hyphenation result
- */
- public static Hyphenation hyphenate(String lang, String country,
- char[] word, int offset, int len,
- int leftMin, int rightMin) {
- return hyphenate(lang, country, null, word, offset, len, leftMin, rightMin);
- }
-
- /**
- * Sets the minimum number of characters before the hyphenation point
- * @param min the number of characters
- */
- public void setMinRemainCharCount(int min) {
- remainCharCount = min;
- }
-
- /**
- * Sets the minimum number of characters after the hyphenation point
- * @param min the number of characters
- */
- public void setMinPushCharCount(int min) {
- pushCharCount = min;
- }
-
- /**
- * Sets the language and country for the hyphenation process.
- * @param lang the language
- * @param country the country (may be null or "none")
- */
- public void setLanguage(String lang, String country) {
- hyphenTree = getHyphenationTree(lang, country);
- }
-
- /**
- * Hyphenates a word.
- * @param word the word to hyphenate
- * @param offset the offset of the first character in the "word" character array
- * @param len the length of the word
- * @return the hyphenation result
- */
- public Hyphenation hyphenate(char[] word, int offset, int len) {
- if (hyphenTree == null) {
- return null;
- }
- return hyphenTree.hyphenate(word, offset, len, remainCharCount,
- pushCharCount);
- }
-
- /**
- * Hyphenates a word.
- * @param word the word to hyphenate
- * @return the hyphenation result
- */
- public Hyphenation hyphenate(String word) {
- if (hyphenTree == null) {
- return null;
- }
- return hyphenTree.hyphenate(word, remainCharCount, pushCharCount);
- }
-
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/Page.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/Page.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/Page.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/Page.java Mon Nov 15 13:58:40 2010
@@ -41,10 +41,12 @@ public class Page {
* @param pageNumber the page number (as an int)
* @param pageNumberStr the page number (as a String)
* @param blank true if this is a blank page
+ * @param spanAll true if the first span area spans all columns
*/
- public Page(SimplePageMaster spm, int pageNumber, String pageNumberStr, boolean blank) {
+ public Page(SimplePageMaster spm, int pageNumber, String pageNumberStr,
+ boolean blank, boolean spanAll) {
this.spm = spm;
- this.pageViewport = new PageViewport(spm, pageNumber, pageNumberStr, blank);
+ this.pageViewport = new PageViewport(spm, pageNumber, pageNumberStr, blank, spanAll);
}
/**
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PageBreaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PageBreaker.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PageBreaker.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PageBreaker.java Mon Nov 15 13:58:40 2010
@@ -45,6 +45,7 @@ public class PageBreaker extends Abstrac
private boolean needColumnBalancing;
private PageProvider pageProvider;
private Block separatorArea;
+ private boolean spanAllActive;
/**
* The FlowLayoutManager object, which processes
@@ -148,8 +149,9 @@ public class PageBreaker extends Abstrac
}
firstPart = false;
pageBreakHandled = true;
+
pageProvider.setStartOfNextElementList(pslm.getCurrentPageNum(),
- pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex());
+ pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex(), this.spanAllActive);
return super.getNextBlockList(childLC, nextSequenceStartsOn, positionAtIPDChange,
restartLM, firstElements);
}
@@ -342,8 +344,9 @@ public class PageBreaker extends Abstrac
pageBreakHandled = true;
//Update so the available BPD is reported correctly
int currentPageNum = pslm.getCurrentPageNum();
+
pageProvider.setStartOfNextElementList(currentPageNum,
- pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex());
+ pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex(), this.spanAllActive);
//Make sure we only add the areas we haven't added already
effectiveList.ignoreAtStart = newStartPos;
@@ -387,7 +390,7 @@ public class PageBreaker extends Abstrac
boolean fitsOnePage
= optimalPageCount <= pslm.getCurrentPV()
- .getBodyRegion().getMainReference().getCurrentSpan().getColumnCount();
+ .getBodyRegion().getMainReference().getCurrentSpan().getColumnCount();
if (needColumnBalancing) {
if (!fitsOnePage) {
@@ -435,7 +438,8 @@ public class PageBreaker extends Abstrac
handleBreakTrait(breakClass);
}
pageProvider.setStartOfNextElementList(pslm.getCurrentPageNum(),
- pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex());
+ pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex(),
+ this.spanAllActive);
}
pageBreakHandled = false;
// add static areas and resolve any new id areas
@@ -503,9 +507,11 @@ public class PageBreaker extends Abstrac
case Constants.EN_ALL:
//break due to span change in multi-column layout
curPage.getPageViewport().createSpan(true);
+ this.spanAllActive = true;
return;
case Constants.EN_NONE:
curPage.getPageViewport().createSpan(false);
+ this.spanAllActive = false;
return;
case Constants.EN_COLUMN:
case Constants.EN_AUTO:
@@ -554,7 +560,7 @@ public class PageBreaker extends Abstrac
*/
private boolean needBlankPageBeforeNew(int breakVal) {
if (breakVal == Constants.EN_PAGE
- || (pslm.getCurrentPage().getPageViewport().getPage().isEmpty())) {
+ || (pslm.getCurrentPage().getPageViewport().getPage().isEmpty())) {
// any page is OK or we already have an empty page
return false;
} else {
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PageProvider.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PageProvider.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PageProvider.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PageProvider.java Mon Nov 15 13:58:40 2010
@@ -51,6 +51,7 @@ public class PageProvider implements Con
private int startPageOfPageSequence;
private int startPageOfCurrentElementList;
private int startColumnOfCurrentElementList;
+ private boolean spanAllForCurrentElementList;
private List cachedPages = new java.util.ArrayList();
private int lastPageIndex = -1;
@@ -88,12 +89,17 @@ public class PageProvider implements Con
* on so it can later retrieve PageViewports relative to this first page.
* @param startPage the number of the first page for the element list.
* @param startColumn the starting column number for the element list.
+ * @param spanAll true if the current element list is for a column-spanning section
*/
- public void setStartOfNextElementList(int startPage, int startColumn) {
- log.debug("start of the next element list is:"
- + " page=" + startPage + " col=" + startColumn);
+ public void setStartOfNextElementList(int startPage, int startColumn, boolean spanAll) {
+ if (log.isDebugEnabled()) {
+ log.debug("start of the next element list is:"
+ + " page=" + startPage + " col=" + startColumn
+ + (spanAll ? ", column-spanning" : ""));
+ }
this.startPageOfCurrentElementList = startPage - startPageOfPageSequence + 1;
this.startColumnOfCurrentElementList = startColumn;
+ this.spanAllForCurrentElementList = spanAll;
//Reset Cache
this.lastRequestedIndex = -1;
this.lastReportedBPD = -1;
@@ -290,7 +296,7 @@ public class PageProvider implements Con
if (log.isTraceEnabled()) {
log.trace("Caching " + index);
}
- cacheNextPage(index, isBlank, isLastPage);
+ cacheNextPage(index, isBlank, isLastPage, this.spanAllForCurrentElementList);
}
Page page = (Page)cachedPages.get(intIndex);
boolean replace = false;
@@ -306,7 +312,7 @@ public class PageProvider implements Con
}
if (replace) {
discardCacheStartingWith(intIndex);
- page = cacheNextPage(index, isBlank, isLastPage);
+ page = cacheNextPage(index, isBlank, isLastPage, this.spanAllForCurrentElementList);
}
return page;
}
@@ -320,7 +326,7 @@ public class PageProvider implements Con
}
}
- private Page cacheNextPage(int index, boolean isBlank, boolean isLastPage) {
+ private Page cacheNextPage(int index, boolean isBlank, boolean isLastPage, boolean spanAll) {
String pageNumberString = pageSeq.makeFormattedPageNumber(index);
boolean isFirstPage = (startPageOfPageSequence == index);
SimplePageMaster spm = pageSeq.getNextSimplePageMaster(
@@ -335,7 +341,7 @@ public class PageProvider implements Con
eventProducer.flowNotMappingToRegionBody(this,
pageSeq.getMainFlow().getFlowName(), spm.getMasterName(), spm.getLocator());
}
- Page page = new Page(spm, index, pageNumberString, isBlank);
+ Page page = new Page(spm, index, pageNumberString, isBlank, spanAll);
//Set unique key obtained from the AreaTreeHandler
page.getPageViewport().setKey(areaTreeHandler.generatePageViewportKey());
page.getPageViewport().setForeignAttributes(spm.getForeignAttributes());
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java Mon Nov 15 13:58:40 2010
@@ -1415,6 +1415,7 @@ public class LineLayoutManager extends I
= Hyphenator.hyphenate(hyphenationProperties.language.getString(),
hyphenationProperties.country.getString(),
getFObj().getUserAgent().getFactory().getHyphenationTreeResolver(),
+ getFObj().getUserAgent().getFactory().getHyphPatNames(),
sbChars.toString(),
hyphenationProperties.hyphenationRemainCharacterCount.getValue(),
hyphenationProperties.hyphenationPushCharacterCount.getValue());
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java Mon Nov 15 13:58:40 2010
@@ -552,4 +552,11 @@ public class TableLayoutManager extends
}
}
+ /** {@inheritDoc} */
+ public void reset() {
+ super.reset();
+ curBlockArea = null;
+ tableUnit = 0.0;
+ }
+
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFMetadata.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFMetadata.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFMetadata.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFMetadata.java Mon Nov 15 13:58:40 2010
@@ -151,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_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFName.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFName.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFName.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFName.java Mon Nov 15 13:58:40 2010
@@ -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_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java Mon Nov 15 13:58:40 2010
@@ -47,6 +47,7 @@ import org.apache.fop.render.afp.extensi
import org.apache.fop.render.afp.extensions.AFPIncludeFormMap;
import org.apache.fop.render.afp.extensions.AFPInvokeMediumMap;
import org.apache.fop.render.afp.extensions.AFPPageOverlay;
+import org.apache.fop.render.afp.extensions.AFPPageSegmentElement;
import org.apache.fop.render.afp.extensions.AFPPageSetup;
import org.apache.fop.render.intermediate.AbstractBinaryWritingIFDocumentHandler;
import org.apache.fop.render.intermediate.IFDocumentHandler;
@@ -76,8 +77,8 @@ public class AFPDocumentHandler extends
private DataStream dataStream;
/** the map of page segments */
- private Map/*<String,String>*/pageSegmentMap
- = new java.util.HashMap/*<String,String>*/();
+ private Map/*<String,PageSegmentDescriptor>*/pageSegmentMap
+ = new java.util.HashMap/*<String,PageSegmentDescriptor>*/();
/** Medium Map referenced on previous page **/
private String lastMediumMap;
@@ -213,7 +214,6 @@ public class AFPDocumentHandler extends
throws IFException {
this.location = LOC_ELSEWHERE;
paintingState.clear();
- pageSegmentMap.clear();
AffineTransform baseTransform = getBaseTransform();
paintingState.concatenate(baseTransform);
@@ -288,9 +288,12 @@ public class AFPDocumentHandler extends
null);
}
if (AFPElementMapping.INCLUDE_PAGE_SEGMENT.equals(element)) {
- String name = aps.getName();
- String source = aps.getValue();
- pageSegmentMap.put(source, name);
+ AFPPageSegmentElement.AFPPageSegmentSetup apse
+ = (AFPPageSegmentElement.AFPPageSegmentSetup)aps;
+ String name = apse.getName();
+ String source = apse.getValue();
+ String uri = apse.getResourceSrc();
+ pageSegmentMap.put(source, new PageSegmentDescriptor(name, uri));
} else if (AFPElementMapping.NO_OPERATION.equals(element)) {
String content = aps.getContent();
if (content != null) {
@@ -392,13 +395,13 @@ public class AFPDocumentHandler extends
}
/**
- * Returns the page segment name for a given URI if it actually represents a page segment.
+ * Returns the page segment descriptor for a given URI if it actually represents a page segment.
* Otherwise, it just returns null.
* @param uri the URI that identifies the page segment
- * @return the page segment name or null if there's no page segment for the given URI
+ * @return the page segment descriptor or null if there's no page segment for the given URI
*/
- String getPageSegmentNameFor(String uri) {
- return (String)pageSegmentMap.get(uri);
+ PageSegmentDescriptor getPageSegmentNameFor(String uri) {
+ return (PageSegmentDescriptor)pageSegmentMap.get(uri);
}
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPPainter.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPPainter.java Mon Nov 15 13:58:40 2010
@@ -26,6 +26,8 @@ import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.Map;
import org.w3c.dom.Document;
@@ -48,6 +50,8 @@ import org.apache.fop.afp.modca.Abstract
import org.apache.fop.afp.modca.PresentationTextObject;
import org.apache.fop.afp.ptoca.PtocaBuilder;
import org.apache.fop.afp.ptoca.PtocaProducer;
+import org.apache.fop.afp.util.DefaultFOPResourceAccessor;
+import org.apache.fop.afp.util.ResourceAccessor;
import org.apache.fop.fonts.Font;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontTriplet;
@@ -183,14 +187,34 @@ public class AFPPainter extends Abstract
/** {@inheritDoc} */
public void drawImage(String uri, Rectangle rect) throws IFException {
- String name = documentHandler.getPageSegmentNameFor(uri);
- if (name != null) {
+ PageSegmentDescriptor pageSegment = documentHandler.getPageSegmentNameFor(uri);
+
+ if (pageSegment != null) {
float[] srcPts = {rect.x, rect.y};
int[] coords = unitConv.mpts2units(srcPts);
int width = Math.round(unitConv.mpt2units(rect.width));
int height = Math.round(unitConv.mpt2units(rect.height));
- getDataStream().createIncludePageSegment(name, coords[X], coords[Y], width, height);
+ getDataStream().createIncludePageSegment(pageSegment.getName(),
+ coords[X], coords[Y], width, height);
+
+ //Do we need to embed an external page segment?
+ if (pageSegment.getURI() != null) {
+ ResourceAccessor accessor = new DefaultFOPResourceAccessor (
+ documentHandler.getUserAgent(), null, null);
+ try {
+ URI resourceUri = new URI(pageSegment.getURI());
+ documentHandler.getResourceManager().createIncludedResourceFromExternal(
+ pageSegment.getName(), resourceUri, accessor);
+
+ } catch (URISyntaxException urie) {
+ throw new IFException("Could not handle resource url"
+ + pageSegment.getURI(), urie);
+ } catch (IOException ioe) {
+ throw new IFException("Could not handle resource" + pageSegment.getURI(), ioe);
+ }
+ }
+
} else {
drawImageUsingURI(uri, rect);
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java Mon Nov 15 13:58:40 2010
@@ -103,7 +103,7 @@ public class AFPElementMapping extends E
static class AFPIncludePageSegmentMaker extends ElementMapping.Maker {
public FONode make(FONode parent) {
- return new AFPPageSetupElement(parent, INCLUDE_PAGE_SEGMENT);
+ return new AFPPageSegmentElement(parent, INCLUDE_PAGE_SEGMENT);
}
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java Mon Nov 15 13:58:40 2010
@@ -24,11 +24,13 @@ import java.net.URISyntaxException;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.helpers.DefaultHandler;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.fop.render.afp.extensions.AFPPageSegmentElement.AFPPageSegmentSetup;
import org.apache.fop.util.ContentHandlerFactory;
import org.apache.fop.util.ContentHandlerFactory.ObjectBuiltListener;
@@ -52,7 +54,7 @@ public class AFPExtensionHandler extends
throws SAXException {
boolean handled = false;
if (AFPExtensionAttachment.CATEGORY.equals(uri)) {
- lastAttributes = attributes;
+ lastAttributes = new AttributesImpl(attributes);
handled = true;
if (localName.equals(AFPElementMapping.NO_OPERATION)
|| localName.equals(AFPElementMapping.TAG_LOGICAL_ELEMENT)
@@ -96,6 +98,30 @@ public class AFPExtensionHandler extends
if (name != null) {
returnedObject.setName(name);
}
+ } else if (AFPElementMapping.INCLUDE_PAGE_SEGMENT.equals(localName)) {
+ AFPPageSegmentSetup pageSetupExtn = null;
+
+ pageSetupExtn = new AFPPageSegmentSetup(localName);
+ this.returnedObject = pageSetupExtn;
+
+ String name = lastAttributes.getValue("name");
+ if (name != null) {
+ returnedObject.setName(name);
+ }
+ String value = lastAttributes.getValue("value");
+ if (value != null && pageSetupExtn != null) {
+ pageSetupExtn.setValue(value);
+ }
+
+ String resourceSrc = lastAttributes.getValue("resource-file");
+ if (resourceSrc != null && pageSetupExtn != null) {
+ pageSetupExtn.setResourceSrc(resourceSrc);
+ }
+
+ if (content.length() > 0 && pageSetupExtn != null) {
+ pageSetupExtn.setContent(content.toString());
+ content.setLength(0); //Reset text buffer (see characters())
+ }
} else {
AFPPageSetup pageSetupExtn = null;
if (AFPElementMapping.INVOKE_MEDIUM_MAP.equals(localName)) {
@@ -117,6 +143,7 @@ public class AFPExtensionHandler extends
content.setLength(0); //Reset text buffer (see characters())
}
}
+
}
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/intermediate/util/IFConcatenator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/intermediate/util/IFConcatenator.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/intermediate/util/IFConcatenator.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/intermediate/util/IFConcatenator.java Mon Nov 15 13:58:40 2010
@@ -19,7 +19,6 @@
package org.apache.fop.render.intermediate.util;
-
import java.awt.Dimension;
import javax.xml.transform.Source;
@@ -39,12 +38,17 @@ import org.apache.fop.render.intermediat
* <p>
* Note: This class will filter/ignore any document navigation events. Support for this may be
* added later.
+ * <p>
+ * Note: document-level extensions will only be transferred from the first document passed in.
+ * If you need to merge extensions from all the concatenated documents, you may have to merge
+ * these manually on the XML level, for example using XSLT.
*/
public class IFConcatenator {
private IFDocumentHandler targetHandler;
private int nextPageIndex = 0;
+ private boolean inFirstDocument = true;
/**
* Creates a new IF concatenator.
@@ -163,14 +167,17 @@ public class IFConcatenator {
/** {@inheritDoc} */
public void endDocument() throws IFException {
//ignore
+ inFirstDocument = false;
}
/** {@inheritDoc} */
public void handleExtensionObject(Object extension) throws IFException {
- if (inPageSequence) {
+ if (inPageSequence || inFirstDocument) {
//Only pass through when inside page-sequence
+ //or for the first document (for document-level extensions).
super.handleExtensionObject(extension);
}
+ //Note:Extensions from non-first documents are ignored!
}
/** {@inheritDoc} */
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java Mon Nov 15 13:58:40 2010
@@ -38,6 +38,7 @@ import org.apache.xmlgraphics.image.load
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.image.loader.batik.BatikImageFlavors;
+import org.apache.fop.image.loader.batik.BatikUtil;
import org.apache.fop.render.ImageHandler;
import org.apache.fop.render.RenderingContext;
import org.apache.fop.render.pdf.PDFLogicalStructureHandler.MarkedContentInfo;
@@ -46,6 +47,7 @@ import org.apache.fop.svg.PDFBridgeConte
import org.apache.fop.svg.PDFGraphics2D;
import org.apache.fop.svg.SVGEventProducer;
import org.apache.fop.svg.SVGUserAgent;
+import org.w3c.dom.Document;
/**
* Image Handler implementation which handles SVG images.
@@ -82,10 +84,14 @@ public class PDFImageHandlerSVG implemen
userAgent.getFactory().getImageManager(),
userAgent.getImageSessionContext(),
new AffineTransform());
+
+ //Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine)
+ //to it.
+ Document clonedDoc = BatikUtil.cloneSVGDocument(imageSVG.getDocument());
GraphicsNode root;
try {
- root = builder.build(ctx, imageSVG.getDocument());
+ root = builder.build(ctx, clonedDoc);
builder = null;
} catch (Exception e) {
SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/pdf/extensions/PDFExtensionHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/pdf/extensions/PDFExtensionHandler.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/pdf/extensions/PDFExtensionHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/pdf/extensions/PDFExtensionHandler.java Mon Nov 15 13:58:40 2010
@@ -21,6 +21,7 @@ package org.apache.fop.render.pdf.extens
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.helpers.DefaultHandler;
import org.apache.commons.logging.Log;
@@ -48,7 +49,7 @@ public class PDFExtensionHandler extends
throws SAXException {
boolean handled = false;
if (PDFExtensionAttachment.CATEGORY.equals(uri)) {
- lastAttributes = attributes;
+ lastAttributes = new AttributesImpl(attributes);
handled = false;
if (localName.equals(PDFEmbeddedFileExtensionAttachment.ELEMENT)) {
//handled in endElement
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java Mon Nov 15 13:58:40 2010
@@ -23,6 +23,8 @@ import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
import java.io.IOException;
+import org.w3c.dom.Document;
+
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.GVTBuilder;
import org.apache.batik.gvt.GraphicsNode;
@@ -34,6 +36,7 @@ import org.apache.xmlgraphics.java2d.ps.
import org.apache.xmlgraphics.ps.PSGenerator;
import org.apache.fop.image.loader.batik.BatikImageFlavors;
+import org.apache.fop.image.loader.batik.BatikUtil;
import org.apache.fop.render.ImageHandler;
import org.apache.fop.render.RenderingContext;
import org.apache.fop.svg.SVGEventProducer;
@@ -70,10 +73,14 @@ public class PSImageHandlerSVG implement
context.getUserAgent().getFactory().getImageManager(),
context.getUserAgent().getImageSessionContext());
+ //Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine)
+ //to it.
+ Document clonedDoc = BatikUtil.cloneSVGDocument(imageSVG.getDocument());
+
GraphicsNode root;
try {
GVTBuilder builder = new GVTBuilder();
- root = builder.build(ctx, imageSVG.getDocument());
+ root = builder.build(ctx, clonedDoc);
} catch (Exception e) {
SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
context.getUserAgent().getEventBroadcaster());
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java Mon Nov 15 13:58:40 2010
@@ -21,6 +21,7 @@ package org.apache.fop.render.ps.extensi
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.helpers.DefaultHandler;
import org.apache.commons.logging.Log;
@@ -49,7 +50,7 @@ public class PSExtensionHandler extends
throws SAXException {
boolean handled = false;
if (PSExtensionAttachment.CATEGORY.equals(uri)) {
- lastAttributes = attributes;
+ lastAttributes = new AttributesImpl(attributes);
handled = false;
if (localName.equals(PSSetupCode.ELEMENT)
|| localName.equals(PSSetPageDevice.ELEMENT)
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/rtf/RTFHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/rtf/RTFHandler.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/rtf/RTFHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/rtf/RTFHandler.java Mon Nov 15 13:58:40 2010
@@ -80,11 +80,11 @@ import org.apache.fop.fo.flow.PageNumber
import org.apache.fop.fo.flow.PageNumberCitation;
import org.apache.fop.fo.flow.table.Table;
import org.apache.fop.fo.flow.table.TableBody;
-import org.apache.fop.fo.flow.table.TableFooter;
-import org.apache.fop.fo.flow.table.TablePart;
import org.apache.fop.fo.flow.table.TableCell;
import org.apache.fop.fo.flow.table.TableColumn;
+import org.apache.fop.fo.flow.table.TableFooter;
import org.apache.fop.fo.flow.table.TableHeader;
+import org.apache.fop.fo.flow.table.TablePart;
import org.apache.fop.fo.flow.table.TableRow;
import org.apache.fop.fo.pagination.Flow;
import org.apache.fop.fo.pagination.PageSequence;
@@ -436,7 +436,8 @@ public class RTFHandler extends FOEventH
RtfTextrun textrun = container.getTextrun();
textrun.addParagraphBreak();
- textrun.popBlockAttributes();
+ int breakValue = toRtfBreakValue(bl.getBreakAfter());
+ textrun.popBlockAttributes(breakValue);
} catch (IOException ioe) {
handleIOTrouble(ioe);
@@ -488,7 +489,8 @@ public class RTFHandler extends FOEventH
RtfTextrun textrun = container.getTextrun();
textrun.addParagraphBreak();
- textrun.popBlockAttributes();
+ int breakValue = toRtfBreakValue(bl.getBreakAfter());
+ textrun.popBlockAttributes(breakValue);
} catch (IOException ioe) {
handleIOTrouble(ioe);
@@ -498,6 +500,21 @@ public class RTFHandler extends FOEventH
}
}
+ private int toRtfBreakValue(int foBreakValue) {
+ switch (foBreakValue) {
+ case Constants.EN_PAGE:
+ return RtfTextrun.BREAK_PAGE;
+ case Constants.EN_EVEN_PAGE:
+ return RtfTextrun.BREAK_EVEN_PAGE;
+ case Constants.EN_ODD_PAGE:
+ return RtfTextrun.BREAK_ODD_PAGE;
+ case Constants.EN_COLUMN:
+ return RtfTextrun.BREAK_COLUMN;
+ default:
+ return RtfTextrun.BREAK_NONE;
+ }
+ }
+
/** {@inheritDoc} */
public void startTable(Table tbl) {
if (bDefer) {
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java Mon Nov 15 13:58:40 2010
@@ -35,6 +35,7 @@ import org.apache.fop.fo.flow.BlockConta
import org.apache.fop.fo.flow.Inline;
import org.apache.fop.fo.flow.Leader;
import org.apache.fop.fo.flow.PageNumber;
+import org.apache.fop.fo.flow.table.TableCell;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.fo.properties.CommonFont;
import org.apache.fop.fo.properties.CommonMarginBlock;
@@ -80,10 +81,48 @@ final class TextAttributesConverter {
attrBlockMargin(fobj.getCommonMarginBlock(), attrib);
attrBlockTextAlign(fobj.getTextAlign(), attrib);
attrBorder(fobj.getCommonBorderPaddingBackground(), attrib, fobj);
+ attrBreak(fobj, attrib);
return attrib;
}
+ private static void attrBreak(Block fobj, FOPRtfAttributes attrib) {
+ int breakValue = fobj.getBreakBefore();
+ if (breakValue != Constants.EN_AUTO) {
+ //"sect" Creates a new section and a page break,
+ //a simple page break with control word "page" caused
+ //some problems
+ boolean bHasTableCellParent = false;
+ FONode f = fobj;
+ while (f.getParent() != null) {
+ f = f.getParent();
+ if (f instanceof TableCell) {
+ bHasTableCellParent = true;
+ break;
+ }
+ }
+ if (!bHasTableCellParent) {
+ attrib.set("sect");
+ switch (breakValue) {
+ case Constants.EN_EVEN_PAGE:
+ attrib.set("sbkeven");
+ break;
+ case Constants.EN_ODD_PAGE:
+ attrib.set("sbkodd");
+ break;
+ case Constants.EN_COLUMN:
+ attrib.set("sbkcol");
+ break;
+ default:
+ attrib.set("sbkpage");
+ }
+ } else {
+ log.warn("Cannot create break-before for a block inside a table.");
+ }
+ }
+ //Break after is handled in RtfCloseGroupMark
+ }
+
/**
* Converts all known text FO properties to RtfAttributes
* @param fobj FObj whose properties are to be converted
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java Mon Nov 15 13:58:40 2010
@@ -25,9 +25,10 @@ import java.io.Writer;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
+import java.util.Stack;
-// FOP
-import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfExternalGraphic;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* Class which contains a linear text run. It has methods to add attributes,
@@ -35,9 +36,26 @@ import org.apache.fop.render.rtf.rtflib.
* @author Peter Herweg, pherweg@web.de
*/
public class RtfTextrun extends RtfContainer {
+
+ /** Constant for no page break */
+ public static final int BREAK_NONE = 0;
+ /** Constant for a normal page break */
+ public static final int BREAK_PAGE = 1;
+ /** Constant for a column break */
+ public static final int BREAK_COLUMN = 2;
+ /** Constant for a even page break */
+ public static final int BREAK_EVEN_PAGE = 3;
+ /** Constant for a odd page break */
+ public static final int BREAK_ODD_PAGE = 4;
+
private boolean bSuppressLastPar = false;
private RtfListItem rtfListItem;
+ /**
+ * logging instance
+ */
+ protected static Log log = LogFactory.getLog(RtfTextrun.class);
+
/** Manager for handling space-* property. */
private RtfSpaceManager rtfSpaceManager = new RtfSpaceManager();
@@ -68,10 +86,12 @@ public class RtfTextrun extends RtfConta
/** Class which represents the closing of a RTF group mark.*/
private class RtfCloseGroupMark extends RtfElement {
+ private int breakType = BREAK_NONE;
- RtfCloseGroupMark(RtfContainer parent, Writer w)
- throws IOException {
+ RtfCloseGroupMark(RtfContainer parent, Writer w, int breakType)
+ throws IOException {
super(parent, w);
+ this.breakType = breakType;
}
/**
@@ -82,11 +102,44 @@ public class RtfTextrun extends RtfConta
}
/**
- * write RTF code of all our children
+ * Returns the break type.
+ * @return the break type (BREAK_* constants)
+ */
+ public int getBreakType() {
+ return breakType;
+ }
+
+ /**
+ * Write RTF code of all our children.
* @throws IOException for I/O problems
*/
protected void writeRtfContent() throws IOException {
writeGroupMark(false);
+ boolean bHasTableCellParent = this.getParentOfClass(RtfTableCell.class) != null;
+
+ //Unknown behavior when a table starts a new section,
+ //Word may crash
+ if (breakType != BREAK_NONE) {
+ if (!bHasTableCellParent) {
+ writeControlWord("sect");
+ /* The following modifiers don't seem to appear in the right place */
+ switch (breakType) {
+ case BREAK_EVEN_PAGE:
+ writeControlWord("sbkeven");
+ break;
+ case BREAK_ODD_PAGE:
+ writeControlWord("sbkodd");
+ break;
+ case BREAK_COLUMN:
+ writeControlWord("sbkcol");
+ break;
+ default:
+ writeControlWord("sbkpage");
+ }
+ } else {
+ log.warn("Cannot create break-after for a paragraph inside a table.");
+ }
+ }
}
}
@@ -135,8 +188,18 @@ public class RtfTextrun extends RtfConta
*
* @throws IOException for I/O problems
*/
+ private void addCloseGroupMark(int breakType) throws IOException {
+ RtfCloseGroupMark r = new RtfCloseGroupMark(this, writer, breakType);
+ }
+
+ /**
+ * Adds instance of <code>CloseGroupMark</code> as a child, but without a break option.
+ * Inline attributes do not need that for example
+ *
+ * @throws IOException for I/O problems
+ */
private void addCloseGroupMark() throws IOException {
- RtfCloseGroupMark r = new RtfCloseGroupMark(this, writer);
+ RtfCloseGroupMark r = new RtfCloseGroupMark(this, writer, BREAK_NONE);
}
/**
@@ -155,14 +218,14 @@ public class RtfTextrun extends RtfConta
/**
* Pops block attributes, notifies all opened blocks about pushing block
* attributes, adds <code>CloseGroupMark</code> as a child.
- *
+ * @param breakType the break type
* @throws IOException for I/O problems
*/
- public void popBlockAttributes() throws IOException {
- rtfSpaceManager.popRtfSpaceSplitter();
- rtfSpaceManager.stopUpdatingSpaceBefore();
- addCloseGroupMark();
- }
+ public void popBlockAttributes(int breakType) throws IOException {
+ rtfSpaceManager.popRtfSpaceSplitter();
+ rtfSpaceManager.stopUpdatingSpaceBefore();
+ addCloseGroupMark(breakType);
+ }
/**
* Pushes inline attributes.
@@ -228,28 +291,30 @@ public class RtfTextrun extends RtfConta
* @throws IOException for I/O problems
*/
public void addParagraphBreak() throws IOException {
- // get copy of children list
- List children = getChildren();
-
- // delete all previous CloseGroupMark
- int deletedCloseGroupCount = 0;
-
- ListIterator lit = children.listIterator(children.size());
- while (lit.hasPrevious()
- && (lit.previous() instanceof RtfCloseGroupMark)) {
- lit.remove();
- deletedCloseGroupCount++;
- }
-
- if (children.size() != 0) {
- // add paragraph break and restore all deleted close group marks
- setChildren(children);
- new RtfParagraphBreak(this, writer);
- for (int i = 0; i < deletedCloseGroupCount; i++) {
- addCloseGroupMark();
- }
- }
- }
+ // get copy of children list
+ List children = getChildren();
+ Stack tmp = new Stack();
+
+ // delete all previous CloseGroupMark
+ int deletedCloseGroupCount = 0;
+
+ ListIterator lit = children.listIterator(children.size());
+ while (lit.hasPrevious()
+ && (lit.previous() instanceof RtfCloseGroupMark)) {
+ tmp.push(new Integer(((RtfCloseGroupMark)lit.next()).getBreakType()));
+ lit.remove();
+ deletedCloseGroupCount++;
+ }
+
+ if (children.size() != 0) {
+ // add paragraph break and restore all deleted close group marks
+ setChildren(children);
+ new RtfParagraphBreak(this, writer);
+ for (int i = 0; i < deletedCloseGroupCount; i++) {
+ addCloseGroupMark(((Integer)tmp.pop()).intValue());
+ }
+ }
+ }
/**
* Inserts a leader.
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/svg/AbstractFOPTranscoder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/svg/AbstractFOPTranscoder.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/svg/AbstractFOPTranscoder.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/svg/AbstractFOPTranscoder.java Mon Nov 15 13:58:40 2010
@@ -29,6 +29,7 @@ import org.w3c.dom.DOMImplementation;
import org.xml.sax.EntityResolver;
+import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.configuration.DefaultConfiguration;
@@ -55,7 +56,7 @@ import org.apache.xmlgraphics.image.load
/**
* This is the common base class of all of FOP's transcoders.
*/
-public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder {
+public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder implements Configurable {
/**
* The key is used to specify the resolution for on-the-fly images generated
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/svg/NativeTextPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/svg/NativeTextPainter.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/svg/NativeTextPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/svg/NativeTextPainter.java Mon Nov 15 13:58:40 2010
@@ -111,9 +111,9 @@ public abstract class NativeTextPainter
String style = ((posture != null) && (posture.floatValue() > 0.0))
? Font.STYLE_ITALIC : Font.STYLE_NORMAL;
- int weight = ((taWeight != null)
- && (taWeight.floatValue() > 1.0)) ? Font.WEIGHT_BOLD
- : Font.WEIGHT_NORMAL;
+ int weight = toCSSWeight(taWeight != null
+ ? taWeight.floatValue()
+ : TextAttribute.WEIGHT_REGULAR.floatValue());
String firstFontFamily = null;
@@ -176,6 +176,28 @@ public abstract class NativeTextPainter
return (Font[])fonts.toArray(new Font[fonts.size()]);
}
+ private int toCSSWeight(float weight) {
+ if (weight <= TextAttribute.WEIGHT_EXTRA_LIGHT.floatValue()) {
+ return 100;
+ } else if (weight <= TextAttribute.WEIGHT_LIGHT.floatValue()) {
+ return 200;
+ } else if (weight <= TextAttribute.WEIGHT_DEMILIGHT.floatValue()) {
+ return 300;
+ } else if (weight <= TextAttribute.WEIGHT_REGULAR.floatValue()) {
+ return 400;
+ } else if (weight <= TextAttribute.WEIGHT_SEMIBOLD.floatValue()) {
+ return 500;
+ } else if (weight <= TextAttribute.WEIGHT_BOLD.floatValue()) {
+ return 600;
+ } else if (weight <= TextAttribute.WEIGHT_HEAVY.floatValue()) {
+ return 700;
+ } else if (weight <= TextAttribute.WEIGHT_EXTRABOLD.floatValue()) {
+ return 800;
+ } else {
+ return 900;
+ }
+ }
+
/**
* Collects all characters from an {@link AttributedCharacterIterator}.
* @param runaci the character iterator
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java Mon Nov 15 13:58:40 2010
@@ -256,6 +256,7 @@ public class PDFDocumentGraphics2D exten
if (!pdfContext.isPagePending()) {
return; //ignore
}
+ currentStream.write("Q\n");
//Finish page
PDFStream pdfStream = this.pdfDoc.getFactory().makeStream(
PDFFilterList.CONTENT_FILTER, false);
@@ -321,6 +322,7 @@ public class PDFDocumentGraphics2D exten
pdfContext.setCurrentPage(page);
pageRef = page.referencePDF();
+ currentStream.write("q\n");
AffineTransform at = new AffineTransform(1.0, 0.0, 0.0, -1.0,
0.0, height);
currentStream.write("1 0 0 -1 0 " + height + " cm\n");
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java Mon Nov 15 13:58:40 2010
@@ -25,12 +25,15 @@ import org.apache.avalon.framework.confi
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.fop.apps.FOPException;
+import org.apache.fop.fonts.CustomFontCollection;
+import org.apache.fop.fonts.FontCollection;
import org.apache.fop.fonts.FontEventListener;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontInfoConfigurator;
import org.apache.fop.fonts.FontManager;
+import org.apache.fop.fonts.FontManagerConfigurator;
import org.apache.fop.fonts.FontResolver;
-import org.apache.fop.fonts.FontSetup;
+import org.apache.fop.fonts.base14.Base14FontCollection;
import org.apache.fop.pdf.PDFDocument;
import org.apache.fop.render.pdf.PDFRendererConfigurator;
@@ -70,29 +73,30 @@ public class PDFDocumentGraphics2DConfig
*/
public static FontInfo createFontInfo(Configuration cfg) throws FOPException {
FontInfo fontInfo = new FontInfo();
+ final boolean strict = false;
+ FontResolver fontResolver = FontManager.createMinimalFontResolver();
+ //TODO The following could be optimized by retaining the FontManager somewhere
+ FontManager fontManager = new FontManager();
if (cfg != null) {
- FontResolver fontResolver = FontManager.createMinimalFontResolver();
- //TODO The following could be optimized by retaining the FontManager somewhere
- FontManager fontManager = new FontManager();
+ FontManagerConfigurator fmConfigurator = new FontManagerConfigurator(cfg);
+ fmConfigurator.configure(fontManager, strict);
+ }
- //TODO Make use of fontBaseURL, font substitution and referencing configuration
- //Requires a change to the expected configuration layout
+ List fontCollections = new java.util.ArrayList();
+ fontCollections.add(new Base14FontCollection(fontManager.isBase14KerningEnabled()));
+ if (cfg != null) {
//TODO Wire in the FontEventListener
- final FontEventListener listener = null;
- final boolean strict = false;
+ FontEventListener listener = null; //new FontEventAdapter(eventBroadcaster);
FontInfoConfigurator fontInfoConfigurator
= new FontInfoConfigurator(cfg, fontManager, fontResolver, listener, strict);
List/*<EmbedFontInfo>*/ fontInfoList = new java.util.ArrayList/*<EmbedFontInfo>*/();
fontInfoConfigurator.configure(fontInfoList);
-
- if (fontManager.useCache()) {
- fontManager.getFontCache().save();
- }
- FontSetup.setup(fontInfo, fontInfoList, fontResolver);
- } else {
- FontSetup.setup(fontInfo);
+ fontCollections.add(new CustomFontCollection(fontResolver, fontInfoList));
}
+ fontManager.setup(fontInfo,
+ (FontCollection[])fontCollections.toArray(
+ new FontCollection[fontCollections.size()]));
return fontInfo;
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/svg/PDFTranscoder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/svg/PDFTranscoder.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/svg/PDFTranscoder.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/svg/PDFTranscoder.java Mon Nov 15 13:58:40 2010
@@ -27,7 +27,6 @@ import java.io.OutputStream;
import org.w3c.dom.Document;
import org.w3c.dom.svg.SVGLength;
-import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.UnitProcessor;
@@ -73,8 +72,7 @@ import org.apache.fop.fonts.FontInfo;
* @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a>
* @version $Id$
*/
-public class PDFTranscoder extends AbstractFOPTranscoder
- implements Configurable {
+public class PDFTranscoder extends AbstractFOPTranscoder {
/** Graphics2D instance that is used to paint to */
protected PDFDocumentGraphics2D graphics = null;
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/tools/anttasks/Fop.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/tools/anttasks/Fop.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/tools/anttasks/Fop.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/tools/anttasks/Fop.java Mon Nov 15 13:58:40 2010
@@ -20,14 +20,6 @@
package org.apache.fop.tools.anttasks;
// Ant
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.DirectoryScanner;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.types.FileSet;
-import org.apache.tools.ant.util.GlobPatternMapper;
-
-// Java
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.IOException;
@@ -36,17 +28,23 @@ import java.net.MalformedURLException;
import java.util.List;
import java.util.Vector;
-// FOP
+import org.xml.sax.SAXException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.impl.SimpleLog;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.util.GlobPatternMapper;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.cli.InputHandler;
-import org.apache.commons.logging.impl.SimpleLog;
-import org.apache.commons.logging.Log;
-import org.xml.sax.SAXException;
-
/**
* Wrapper for FOP which allows it to be accessed from within an Ant task.
* Accepts the inputs:
@@ -156,7 +154,7 @@ public class Fop extends Task {
}
/**
- * Sets the XSLT parameters
+ * Sets the XSLT parameters
* @param xsltParams the XSLT parameters
*/
public void setXsltParams(String xsltParams) {
@@ -267,7 +265,7 @@ public class Fop extends Task {
/**
* Set whether exceptions are thrown.
* default is false.
- * @param throwExceptions true if should be thrown
+ * @param throwExceptions true if exceptions should be thrown
*/
public void setThrowexceptions(boolean throwExceptions) {
this.throwExceptions = throwExceptions;
@@ -553,7 +551,7 @@ class FOPTaskStarter {
// OR output file doesn't exist OR
// output file is older than input file
if (task.getForce() || !outf.exists()
- || (task.getXmlFile().lastModified() > outf.lastModified()
+ || (task.getXmlFile().lastModified() > outf.lastModified()
|| task.getXsltFile().lastModified() > outf.lastModified())) {
render(task.getXmlFile(), task.getXsltFile(), outf, outputFormat);
actioncount++;
@@ -639,8 +637,8 @@ class FOPTaskStarter {
}
}
- private void renderInputHandler
- (InputHandler inputHandler, File outFile, String outputFormat) throws Exception {
+ private void renderInputHandler(InputHandler inputHandler, File outFile, String outputFormat)
+ throws Exception {
OutputStream out = null;
try {
out = new java.io.FileOutputStream(outFile);
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/traits/MinOptMax.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/traits/MinOptMax.java?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/traits/MinOptMax.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/traits/MinOptMax.java Mon Nov 15 13:58:40 2010
@@ -56,8 +56,7 @@ public final class MinOptMax implements
* @return the corresponding instance
* @throws IllegalArgumentException if <code>min > opt || max < opt</code>.
*/
- public static MinOptMax getInstance(int min, int opt, int max)
- throws IllegalArgumentException {
+ public static MinOptMax getInstance(int min, int opt, int max) throws IllegalArgumentException {
if (min > opt) {
throw new IllegalArgumentException("min (" + min + ") > opt (" + opt + ")");
}
@@ -168,8 +167,7 @@ public final class MinOptMax implements
* @throws ArithmeticException if this instance has strictly less shrink or stretch
* than the operand
*/
- public MinOptMax minus(MinOptMax operand)
- throws ArithmeticException {
+ public MinOptMax minus(MinOptMax operand) throws ArithmeticException {
checkCompatibility(getShrink(), operand.getShrink(), "shrink");
checkCompatibility(getStretch(), operand.getStretch(), "stretch");
return new MinOptMax(min - operand.min, opt - operand.opt, max - operand.max);
@@ -194,58 +192,54 @@ public final class MinOptMax implements
}
/**
- * Returns an instance with the given value added to the minimal value.
+ * Do not use, backwards compatibility only. Returns an instance with the
+ * given value added to the minimal value.
*
* @param minOperand the minimal value to be added.
* @return an instance with the given value added to the minimal value.
- * @throws IllegalArgumentException if <code>min + minOperand > opt || max < opt</code>.
+ * @throws IllegalArgumentException if
+ * <code>min + minOperand > opt || max < opt</code>.
*/
- // [GA] remove deprecation - no alternative specified
- // @deprecated Do not use! It's only for backwards compatibility.
- public MinOptMax plusMin(int minOperand)
- throws IllegalArgumentException {
+ public MinOptMax plusMin(int minOperand) throws IllegalArgumentException {
return getInstance(min + minOperand, opt, max);
}
/**
- * Returns an instance with the given value subtracted to the minimal value.
+ * Do not use, backwards compatibility only. Returns an instance with the
+ * given value subtracted to the minimal value.
*
* @param minOperand the minimal value to be subtracted.
* @return an instance with the given value subtracted to the minimal value.
- * @throws IllegalArgumentException if <code>min - minOperand > opt || max < opt</code>.
+ * @throws IllegalArgumentException if
+ * <code>min - minOperand > opt || max < opt</code>.
*/
- // [GA] remove deprecation - no alternative specified
- // @deprecated Do not use! It's only for backwards compatibility.
- public MinOptMax minusMin(int minOperand)
- throws IllegalArgumentException {
+ public MinOptMax minusMin(int minOperand) throws IllegalArgumentException {
return getInstance(min - minOperand, opt, max);
}
/**
- * Returns an instance with the given value added to the maximal value.
+ * Do not use, backwards compatibility only. Returns an instance with the
+ * given value added to the maximal value.
*
* @param maxOperand the maximal value to be added.
* @return an instance with the given value added to the maximal value.
- * @throws IllegalArgumentException if <code>min > opt || max < opt + maxOperand</code>.
+ * @throws IllegalArgumentException if
+ * <code>min > opt || max < opt + maxOperand</code>.
*/
- // [GA] remove deprecation - no alternative specified
- // @deprecated Do not use! It's only for backwards compatibility.
- public MinOptMax plusMax(int maxOperand)
- throws IllegalArgumentException {
+ public MinOptMax plusMax(int maxOperand) throws IllegalArgumentException {
return getInstance(min, opt, max + maxOperand);
}
/**
- * Returns an instance with the given value subtracted to the maximal value.
+ * Do not use, backwards compatibility only. Returns an instance with the
+ * given value subtracted to the maximal value.
*
* @param maxOperand the maximal value to be subtracted.
* @return an instance with the given value subtracted to the maximal value.
- * @throws IllegalArgumentException if <code>min > opt || max < opt - maxOperand</code>.
+ * @throws IllegalArgumentException if
+ * <code>min > opt || max < opt - maxOperand</code>.
*/
- // [GA] remove deprecation - no alternative specified
- // @deprecated Do not use! It's only for backwards compatibility.
- public MinOptMax minusMax(int maxOperand)
- throws IllegalArgumentException {
+ public MinOptMax minusMax(int maxOperand) throws IllegalArgumentException {
return getInstance(min, opt, max - maxOperand);
}
@@ -256,8 +250,7 @@ public final class MinOptMax implements
* @return the product of this <code>MinOptMax</code> and the given factor
* @throws IllegalArgumentException if the factor is negative
*/
- public MinOptMax mult(int factor)
- throws IllegalArgumentException {
+ public MinOptMax mult(int factor) throws IllegalArgumentException {
if (factor < 0) {
throw new IllegalArgumentException("factor < 0; was: " + factor);
} else if (factor == 1) {
Propchange: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/util/ColorExt.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Nov 15 13:58:40 2010
@@ -2,3 +2,4 @@
/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/util/ColorExt.java:745924-830281
/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/ColorExt.java:603620-746655
/xmlgraphics/fop/branches/fop-0_95/src/java/org/apache/fop/util/ColorExt.java:684572,688085,688696
+/xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ColorExt.java:959946-1035276
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/status.xml?rev=1035278&r1=1035277&r2=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/status.xml (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/status.xml Mon Nov 15 13:58:40 2010
@@ -58,6 +58,18 @@
documents. Example: the fix of marks layering will be such a case when it's done.
-->
<release version="FOP Trunk" date="TBD">
+ <action context="Renderers" dev="JM" type="add" fixes-bug="42600" due-to="Maximilian Aster">
+ Added some support for break-before/-after for RTF output.
+ </action>
+ <action context="Renderers" dev="JM" type="add" fixes-bug="49379" due-to="Peter Hancock">
+ Added ability to embed an external AFP page segment resource file (AFP output only).
+ </action>
+ <action context="Renderers" dev="JM" type="fix" fixes-bug="46360" due-to="Alexis Giotis">
+ Fixed a multi-threading issue when rendering SVG.
+ </action>
+ <action context="Layout" dev="JM" type="fix" fixes-bug="49885">
+ Fixed retrieval of available BPD for cases spanning columns and multiple pages with differing page masters.
+ </action>
<action context="Renderers" dev="VH" type="remove">
Removed old Renderer implementations for those output formats that have a version based on
the new DocumentHandler architecture available (AFP, PCL, PDF, PS).
@@ -395,6 +407,9 @@
Fixed a problem where the BPD or a block area could be wrong if there is a nested,
absolutely positioned area (for example a block-container).
</action>
+ <action context="Code" dev="VH" type="fix" fixes-bug="45971" due-to="Tow Browder">
+ Improved the behaviour of the command line interface.
+ </action>
<action context="Layout" dev="AD" type="fix" fixes-bug="40798">
Bugzilla 40798: A conditional-page-master-reference with page-position="last" qualifies
for a first page, if it is also the last. Additionally: also added support for
Copied: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/test/java/org/apache/fop/fonts/EncodingModeTest.java (from r1035273, xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EncodingModeTest.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/test/java/org/apache/fop/fonts/EncodingModeTest.java?p2=xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/test/java/org/apache/fop/fonts/EncodingModeTest.java&p1=xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EncodingModeTest.java&r1=1035273&r2=1035278&rev=1035278&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EncodingModeTest.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/test/java/org/apache/fop/fonts/EncodingModeTest.java Mon Nov 15 13:58:40 2010
@@ -1,17 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
package org.apache.fop.fonts;
import junit.framework.TestCase;
public class EncodingModeTest extends TestCase {
- public void testGetName() {
- assertEquals("auto", EncodingMode.AUTO.getName());
- assertEquals("single-byte", EncodingMode.SINGLE_BYTE.getName());
- assertEquals("cid", EncodingMode.CID.getName());
- }
-
- public void testGetValue() {
- assertEquals(EncodingMode.AUTO, EncodingMode.getEncodingMode("auto"));
- assertEquals(EncodingMode.SINGLE_BYTE, EncodingMode.getEncodingMode("single-byte"));
- assertEquals(EncodingMode.CID, EncodingMode.getEncodingMode("cid"));
- }
+ public void testGetName() {
+ assertEquals("auto", EncodingMode.AUTO.getName());
+ assertEquals("single-byte", EncodingMode.SINGLE_BYTE.getName());
+ assertEquals("cid", EncodingMode.CID.getName());
+ }
+
+ public void testGetValue() {
+ assertEquals(EncodingMode.AUTO, EncodingMode.getEncodingMode("auto"));
+ assertEquals(EncodingMode.SINGLE_BYTE, EncodingMode.getEncodingMode("single-byte"));
+ assertEquals(EncodingMode.CID, EncodingMode.getEncodingMode("cid"));
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org