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 me...@apache.org on 2012/06/26 14:31:58 UTC
svn commit: r1353992 [2/3] - in
/xmlgraphics/fop/branches/Temp_URI_Unification:
src/java/org/apache/fop/afp/util/ src/java/org/apache/fop/apps/io/
src/java/org/apache/fop/cli/ src/java/org/apache/fop/fonts/
src/java/org/apache/fop/fonts/autodetect/ src...
Modified: xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/PDFRendererConfig.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/PDFRendererConfig.java?rev=1353992&r1=1353991&r2=1353992&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/PDFRendererConfig.java (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/PDFRendererConfig.java Tue Jun 26 12:31:50 2012
@@ -19,8 +19,6 @@
package org.apache.fop.render.pdf;
-import java.net.URI;
-import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashMap;
@@ -35,35 +33,32 @@ import org.apache.commons.logging.LogFac
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.apps.io.InternalResourceResolver;
import org.apache.fop.fonts.DefaultFontConfig;
import org.apache.fop.fonts.DefaultFontConfig.DefaultFontConfigParser;
-import org.apache.fop.pdf.PDFAMode;
import org.apache.fop.pdf.PDFEncryptionParams;
import org.apache.fop.pdf.PDFFilterList;
-import org.apache.fop.pdf.PDFXMode;
-import org.apache.fop.pdf.Version;
import org.apache.fop.render.RendererConfig;
+import org.apache.fop.render.RendererConfigOption;
import org.apache.fop.util.LogUtil;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.DISABLE_SRGB_COLORSPACE;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.ENCRYPTION_LENGTH;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.ENCRYPTION_PARAMS;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.FILTER_LIST;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_ACCESSCONTENT;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_ANNOTATIONS;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_ASSEMBLEDOC;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_COPY_CONTENT;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_EDIT_CONTENT;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_FILLINFORMS;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_PRINT;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_PRINTHQ;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.OUTPUT_PROFILE;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.OWNER_PASSWORD;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.PDF_A_MODE;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.PDF_X_MODE;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.USER_PASSWORD;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.VERSION;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.ENCRYPTION_LENGTH;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.ENCRYPTION_PARAMS;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.NO_ACCESSCONTENT;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.NO_ANNOTATIONS;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.NO_ASSEMBLEDOC;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.NO_COPY_CONTENT;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.NO_EDIT_CONTENT;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.NO_FILLINFORMS;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.NO_PRINT;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.NO_PRINTHQ;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.OWNER_PASSWORD;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.USER_PASSWORD;
+import static org.apache.fop.render.pdf.PDFRendererOption.DISABLE_SRGB_COLORSPACE;
+import static org.apache.fop.render.pdf.PDFRendererOption.FILTER_LIST;
+import static org.apache.fop.render.pdf.PDFRendererOption.OUTPUT_PROFILE;
+import static org.apache.fop.render.pdf.PDFRendererOption.PDF_A_MODE;
+import static org.apache.fop.render.pdf.PDFRendererOption.PDF_X_MODE;
+import static org.apache.fop.render.pdf.PDFRendererOption.VERSION;
/**
* The PDF renderer configuration data object.
@@ -72,46 +67,21 @@ public final class PDFRendererConfig imp
private static final Log LOG = LogFactory.getLog(PDFRendererConfig.class);
- private final Map<PDFRendererConfigOption, Object> configOptions
- = new EnumMap<PDFRendererConfigOption, Object>(PDFRendererConfigOption.class);
+ private final PDFRendererOptionsConfig configOption;
private final DefaultFontConfig fontConfig;
- private PDFRendererConfig(DefaultFontConfig fontConfig) {
+ private PDFRendererConfig(DefaultFontConfig fontConfig, PDFRendererOptionsConfig config) {
this.fontConfig = fontConfig;
+ this.configOption = config;
}
- public DefaultFontConfig getFontInfoConfig() {
- return fontConfig;
- }
-
- public Map<String, List<String>> getFilterMap() {
- return (Map<String, List<String>>) configOptions.get(FILTER_LIST);
- }
-
- public PDFAMode getPDFAMode() {
- return (PDFAMode) configOptions.get(PDF_A_MODE);
- }
-
- public PDFXMode getPDFXMode() {
- return (PDFXMode) configOptions.get(PDF_X_MODE);
+ public PDFRendererOptionsConfig getConfigOptions() {
+ return configOption;
}
- public PDFEncryptionParams getEncryptionParameters() {
- return (PDFEncryptionParams) configOptions.get(ENCRYPTION_PARAMS);
- }
-
- public URI getOutputProfileURI() {
- return (URI) configOptions.get(OUTPUT_PROFILE);
- }
-
- public Boolean getDisableSRGBColorSpace() {
- return (Boolean) configOptions.get(DISABLE_SRGB_COLORSPACE);
- }
-
- public Version getPDFVersion() {
- String pdfVersion = (String) configOptions.get(VERSION);
- return pdfVersion == null ? null : Version.getValueOf(pdfVersion);
+ public DefaultFontConfig getFontInfoConfig() {
+ return fontConfig;
}
/**
@@ -131,61 +101,70 @@ public final class PDFRendererConfig imp
private static final class ParserHelper {
+ private final Map<PDFRendererOption, Object> configOptions
+ = new EnumMap<PDFRendererOption, Object>(PDFRendererOption.class);
+
+ private PDFEncryptionParams encryptionConfig;
+
private PDFRendererConfig pdfConfig;
private ParserHelper(Configuration cfg, FOUserAgent userAgent, boolean strict) throws FOPException {
- pdfConfig = new PDFRendererConfig(new DefaultFontConfigParser().parse(cfg, strict));
if (cfg != null) {
configure(cfg, userAgent, strict);
}
+ pdfConfig = new PDFRendererConfig(new DefaultFontConfigParser().parse(cfg, strict),
+ new PDFRendererOptionsConfig(configOptions, encryptionConfig));
+ }
+
+ private void parseAndPut(PDFRendererOption option, Configuration cfg) {
+ put(option, option.parse(parseConfig(cfg, option)));
}
- private void put(PDFRendererConfigOption option, Object value) {
+ private void put(PDFRendererOption option, Object value) {
if (value != null && !value.equals(option.getDefaultValue())) {
- pdfConfig.configOptions.put(option, value);
+ configOptions.put(option, value);
}
}
- private void configure(Configuration cfg, FOUserAgent userAgent, boolean strict)
- throws FOPException {
+ private void configure(Configuration cfg, FOUserAgent userAgent, boolean strict) throws FOPException {
try {
buildFilterMapFromConfiguration(cfg);
- put(PDF_A_MODE, PDFAMode.getValueOf(parseConfig(cfg, PDF_A_MODE)));
- put(PDF_X_MODE, PDFXMode.getValueOf(parseConfig(cfg, PDF_X_MODE)));
- Configuration encryptCfg = cfg.getChild(ENCRYPTION_PARAMS.getName(), false);
- if (encryptCfg != null) {
- PDFEncryptionParams encryptionConfig = new PDFEncryptionParams();
- encryptionConfig.setOwnerPassword(parseConfig(encryptCfg, OWNER_PASSWORD));
- encryptionConfig.setUserPassword(parseConfig(encryptCfg, USER_PASSWORD));
- encryptionConfig.setAllowPrint(!doesValueExist(encryptCfg, NO_PRINT));
- encryptionConfig.setAllowCopyContent(!doesValueExist(encryptCfg, NO_COPY_CONTENT));
- encryptionConfig.setAllowEditContent(!doesValueExist(encryptCfg, NO_EDIT_CONTENT));
- encryptionConfig.setAllowEditAnnotations(!doesValueExist(encryptCfg, NO_ANNOTATIONS));
- encryptionConfig.setAllowFillInForms(!doesValueExist(encryptCfg, NO_FILLINFORMS));
- encryptionConfig.setAllowAccessContent(!doesValueExist(encryptCfg, NO_ACCESSCONTENT));
- encryptionConfig.setAllowAssembleDocument(!doesValueExist(encryptCfg,
- NO_ASSEMBLEDOC));
- encryptionConfig.setAllowPrintHq(!doesValueExist(encryptCfg, NO_PRINTHQ));
- String encryptionLength = parseConfig(encryptCfg, ENCRYPTION_LENGTH);
- if (encryptionLength != null) {
- int validatedLength = checkEncryptionLength(Integer.parseInt(encryptionLength),
- userAgent);
- encryptionConfig.setEncryptionLengthInBits(validatedLength);
- }
- put(ENCRYPTION_PARAMS, encryptionConfig);
- }
- put(OUTPUT_PROFILE, InternalResourceResolver.cleanURI(parseConfig(cfg, OUTPUT_PROFILE)));
- put(DISABLE_SRGB_COLORSPACE, Boolean.valueOf(parseConfig(cfg, DISABLE_SRGB_COLORSPACE)));
- put(VERSION, getPDFDocVersion(cfg));
+ parseAndPut(PDF_A_MODE, cfg);
+ parseAndPut(PDF_X_MODE, cfg);
+ configureEncryptionParams(cfg, userAgent, strict);
+ parseAndPut(OUTPUT_PROFILE, cfg);
+ parseAndPut(DISABLE_SRGB_COLORSPACE, cfg);
+
+ parseAndPut(VERSION, cfg);
} catch (ConfigurationException e) {
LogUtil.handleException(LOG, e, strict);
- } catch (URISyntaxException use) {
- LogUtil.handleException(LOG, use, strict);
}
}
- private void buildFilterMapFromConfiguration(Configuration cfg)
- throws ConfigurationException, FOPException {
+ private void configureEncryptionParams(Configuration cfg, FOUserAgent userAgent, boolean strict) {
+ Configuration encryptCfg = cfg.getChild(ENCRYPTION_PARAMS, false);
+ if (encryptCfg != null) {
+ encryptionConfig = new PDFEncryptionParams();
+ encryptionConfig.setOwnerPassword(parseConfig(encryptCfg, OWNER_PASSWORD));
+ encryptionConfig.setUserPassword(parseConfig(encryptCfg, USER_PASSWORD));
+ encryptionConfig.setAllowPrint(!doesValueExist(encryptCfg, NO_PRINT));
+ encryptionConfig.setAllowCopyContent(!doesValueExist(encryptCfg, NO_COPY_CONTENT));
+ encryptionConfig.setAllowEditContent(!doesValueExist(encryptCfg, NO_EDIT_CONTENT));
+ encryptionConfig.setAllowEditAnnotations(!doesValueExist(encryptCfg, NO_ANNOTATIONS));
+ encryptionConfig.setAllowFillInForms(!doesValueExist(encryptCfg, NO_FILLINFORMS));
+ encryptionConfig.setAllowAccessContent(!doesValueExist(encryptCfg, NO_ACCESSCONTENT));
+ encryptionConfig.setAllowAssembleDocument(!doesValueExist(encryptCfg, NO_ASSEMBLEDOC));
+ encryptionConfig.setAllowPrintHq(!doesValueExist(encryptCfg, NO_PRINTHQ));
+ String encryptionLength = parseConfig(encryptCfg, ENCRYPTION_LENGTH);
+ if (encryptionLength != null) {
+ int validatedLength = checkEncryptionLength(Integer.parseInt(encryptionLength), userAgent);
+ encryptionConfig.setEncryptionLengthInBits(validatedLength);
+ }
+ }
+ }
+
+ private void buildFilterMapFromConfiguration(Configuration cfg) throws ConfigurationException,
+ FOPException {
Configuration[] filterLists = cfg.getChildren(FILTER_LIST.getName());
Map<String, List<String>> filterMap = new HashMap<String, List<String>>();
for (Configuration filters : filterLists) {
@@ -218,28 +197,15 @@ public final class PDFRendererConfig imp
put(FILTER_LIST, filterMap);
}
- private String parseConfig(Configuration cfg, PDFRendererConfigOption option) {
+ private String parseConfig(Configuration cfg, RendererConfigOption option) {
Configuration child = cfg.getChild(option.getName());
return child.getValue(null);
}
- private boolean doesValueExist(Configuration cfg, PDFRendererConfigOption option) {
+ private boolean doesValueExist(Configuration cfg, RendererConfigOption option) {
return cfg.getChild(option.getName(), false) != null;
}
- private String getPDFDocVersion(Configuration cfg) throws FOPException {
- Configuration pdfVersion = cfg.getChild(VERSION.getName(), false);
- if (pdfVersion != null) {
- String version = pdfVersion.getValue(null);
- if (version != null && version.length() != 0) {
- return version;
- } else {
- throw new FOPException("The PDF version has not been set.");
- }
- }
- return null;
- }
-
private int checkEncryptionLength(int encryptionLength, FOUserAgent userAgent) {
int correctEncryptionLength = encryptionLength;
if (encryptionLength < 40) {
Modified: xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java?rev=1353992&r1=1353991&r2=1353992&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java Tue Jun 26 12:31:50 2012
@@ -21,7 +21,6 @@ package org.apache.fop.render.pdf;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.pdf.PDFEncryptionParams;
import org.apache.fop.render.DefaultRendererConfigurator;
import org.apache.fop.render.RendererConfig.RendererConfigParser;
import org.apache.fop.render.intermediate.IFDocumentHandler;
@@ -40,52 +39,10 @@ public class PDFRendererConfigurator ext
super(userAgent, rendererConfigParser);
}
- // ---=== IFDocumentHandler configuration ===---
-
/** {@inheritDoc} */
public void configure(IFDocumentHandler documentHandler) throws FOPException {
- final PDFRendererConfig pdfConfig = (PDFRendererConfig) getRendererConfig(documentHandler);
- if (pdfConfig != null) {
- PDFDocumentHandler pdfDocumentHandler = (PDFDocumentHandler) documentHandler;
- PDFRenderingUtil pdfUtil = pdfDocumentHandler.getPDFUtil();
- if (pdfConfig.getFilterMap() != null) {
- pdfUtil.setFilterMap(pdfConfig.getFilterMap());
- }
- if (pdfConfig.getPDFAMode() != null) {
- pdfUtil.setAMode(pdfConfig.getPDFAMode());
- }
- if (pdfConfig.getPDFXMode() != null) {
- pdfUtil.setXMode(pdfConfig.getPDFXMode());
- }
- if (pdfConfig.getOutputProfileURI() != null) {
- pdfUtil.setOutputProfileURI(pdfConfig.getOutputProfileURI());
- }
- if (pdfConfig.getPDFVersion() != null) {
- pdfUtil.setPDFVersion(pdfConfig.getPDFVersion());
- }
- if (pdfConfig.getDisableSRGBColorSpace() != null) {
- pdfUtil.setDisableSRGBColorSpace(pdfConfig.getDisableSRGBColorSpace());
- }
-
- PDFEncryptionParams config = pdfConfig.getEncryptionParameters();
- if (config != null) {
- PDFEncryptionParams utilParams = pdfUtil.getEncryptionParams();
- if (config.getUserPassword() != null) {
- utilParams.setUserPassword(config.getUserPassword());
- }
- if (config.getOwnerPassword() != null) {
- utilParams.setOwnerPassword(config.getOwnerPassword());
- }
- utilParams.setAllowPrint(config.isAllowPrint());
- utilParams.setAllowCopyContent(config.isAllowCopyContent());
- utilParams.setAllowEditContent(config.isAllowEditContent());
- utilParams.setAllowAssembleDocument(config.isAllowAssembleDocument());
- utilParams.setAllowAccessContent(config.isAllowAccessContent());
- utilParams.setAllowFillInForms(config.isAllowFillInForms());
- utilParams.setAllowPrintHq(config.isAllowPrintHq());
- utilParams.setEncryptionLengthInBits(config.getEncryptionLengthInBits());
- }
- }
+ ((PDFDocumentHandler) documentHandler).mergeRendererOptionsConfig(
+ ((PDFRendererConfig) getRendererConfig(documentHandler)).getConfigOptions());
}
}
Added: xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/PDFRendererOption.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/PDFRendererOption.java?rev=1353992&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/PDFRendererOption.java (added)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/PDFRendererOption.java Tue Jun 26 12:31:50 2012
@@ -0,0 +1,112 @@
+/*
+ * 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.render.pdf;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.fop.apps.io.InternalResourceResolver;
+import org.apache.fop.pdf.PDFAMode;
+import org.apache.fop.pdf.PDFXMode;
+import org.apache.fop.pdf.Version;
+import org.apache.fop.render.RendererConfigOption;
+
+public enum PDFRendererOption implements RendererConfigOption {
+ FILTER_LIST("filterList", null) {
+ @Override
+ Object deserialize(String value) {
+ throw new UnsupportedOperationException();
+ }
+ },
+ /** Rendering Options key for the PDF/A mode, default: {@link PDFAMode#DISABLED} */
+ PDF_A_MODE("pdf-a-mode", PDFAMode.DISABLED){
+ @Override
+ PDFAMode deserialize(String value) {
+ return PDFAMode.getValueOf(value);
+ }
+ },
+ /** Rendering Options key for the PDF/X mode, default: {@link PDFXMode#DISABLED} */
+ PDF_X_MODE("pdf-x-mode", PDFXMode.DISABLED){
+ @Override
+ PDFXMode deserialize(String value) {
+ return PDFXMode.getValueOf(value);
+ }
+ },
+ /** PDF version entry: specify the version of the PDF document created, datatype: String */
+ VERSION("version") {
+ @Override
+ Version deserialize(String value) {
+ return Version.getValueOf(value);
+ }
+ },
+ /**
+ * Rendering Options key for disabling the sRGB color space (only possible if no PDF/A or
+ * PDF/X profile is active), default: false
+ */
+ DISABLE_SRGB_COLORSPACE("disable-srgb-colorspace", false) {
+ @Override
+ Boolean deserialize(String value) {
+ return Boolean.valueOf(value);
+ }
+ },
+ /** Rendering Options key for the ICC profile for the output intent. */
+ OUTPUT_PROFILE("output-profile") {
+ @Override
+ URI deserialize(String value) {
+ try {
+ return InternalResourceResolver.cleanURI(value);
+ } catch (URISyntaxException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ };
+
+ private final String name;
+
+ private final Object defaultValue;
+
+ private PDFRendererOption(String name, Object defaultValue) {
+ this.name = name;
+ this.defaultValue = defaultValue;
+ }
+
+ private PDFRendererOption(String name) {
+ this(name, null);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Object getDefaultValue() {
+ return defaultValue;
+ }
+
+ public Object parse(Object object) {
+ if (object instanceof String) {
+ return deserialize((String) object);
+ } else {
+ return object;
+ }
+ }
+
+ abstract Object deserialize(String value);
+
+}
Propchange: xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/PDFRendererOption.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/PDFRendererOptionsConfig.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/PDFRendererOptionsConfig.java?rev=1353992&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/PDFRendererOptionsConfig.java (added)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/PDFRendererOptionsConfig.java Tue Jun 26 12:31:50 2012
@@ -0,0 +1,123 @@
+/*
+ * 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.render.pdf;
+
+import java.net.URI;
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.fop.pdf.PDFAMode;
+import org.apache.fop.pdf.PDFEncryptionParams;
+import org.apache.fop.pdf.PDFXMode;
+import org.apache.fop.pdf.Version;
+
+import static org.apache.fop.render.pdf.PDFRendererOption.DISABLE_SRGB_COLORSPACE;
+import static org.apache.fop.render.pdf.PDFRendererOption.FILTER_LIST;
+import static org.apache.fop.render.pdf.PDFRendererOption.OUTPUT_PROFILE;
+import static org.apache.fop.render.pdf.PDFRendererOption.PDF_A_MODE;
+import static org.apache.fop.render.pdf.PDFRendererOption.PDF_X_MODE;
+import static org.apache.fop.render.pdf.PDFRendererOption.VERSION;
+
+/**
+ * The renderer options configuration data.
+ */
+public final class PDFRendererOptionsConfig {
+
+ static final PDFRendererOptionsConfig DEFAULT;
+
+ static {
+ final EnumMap<PDFRendererOption, Object> props
+ = new EnumMap<PDFRendererOption, Object>(PDFRendererOption.class);
+ for(PDFRendererOption option : PDFRendererOption.values()) {
+ props.put(option, option.getDefaultValue());
+ }
+ DEFAULT = new PDFRendererOptionsConfig(props, null);
+ }
+
+ private final Map<PDFRendererOption, Object> properties
+ = new EnumMap<PDFRendererOption, Object>(PDFRendererOption.class);
+
+ private final PDFEncryptionParams encryptionConfig;
+
+ PDFRendererOptionsConfig(Map<PDFRendererOption, Object> props,
+ PDFEncryptionParams encryptionParams) {
+ properties.putAll(props);
+ this.encryptionConfig = copyPDFEncryptionParams(encryptionParams);
+ }
+
+ private static PDFEncryptionParams copyPDFEncryptionParams(PDFEncryptionParams source) {
+ return source == null ? null : new PDFEncryptionParams(source);
+ }
+
+ PDFRendererOptionsConfig merge(PDFRendererOptionsConfig config) {
+ if (config == null) {
+ return this;
+ } else {
+ return new PDFRendererOptionsConfig(merge(this.properties, config.properties),
+ config.getEncryptionParameters() == null
+ ? copyPDFEncryptionParams(this.encryptionConfig)
+ : copyPDFEncryptionParams(config.getEncryptionParameters()));
+ }
+ }
+
+ private static Map<PDFRendererOption, Object> merge(
+ Map<PDFRendererOption, Object> first, Map<PDFRendererOption, Object> second) {
+ final EnumMap<PDFRendererOption, Object> merged
+ = new EnumMap<PDFRendererOption, Object>(PDFRendererOption.class);
+ for (PDFRendererOption option : PDFRendererOption.values()) {
+ Object value = second.get(option);
+ if (value != null) {
+ merged.put(option, value);
+ } else {
+ merged.put(option, first.get(option));
+ }
+ }
+ return merged;
+ }
+
+ public Map<String, List<String>> getFilterMap() {
+ return (Map<String, List<String>>) properties.get(FILTER_LIST);
+ }
+
+ public PDFAMode getPDFAMode() {
+ return (PDFAMode) properties.get(PDF_A_MODE);
+ }
+
+ public PDFXMode getPDFXMode() {
+ return (PDFXMode) properties.get(PDF_X_MODE);
+ }
+
+ public PDFEncryptionParams getEncryptionParameters() {
+ return encryptionConfig;
+ }
+
+ public URI getOutputProfileURI() {
+ return (URI) properties.get(OUTPUT_PROFILE);
+ }
+
+ public Boolean getDisableSRGBColorSpace() {
+ return (Boolean) properties.get(DISABLE_SRGB_COLORSPACE);
+ }
+
+ public Version getPDFVersion() {
+ return (Version) properties.get(VERSION);
+ }
+}
Propchange: xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/PDFRendererOptionsConfig.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java?rev=1353992&r1=1353991&r2=1353992&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java Tue Jun 26 12:31:50 2012
@@ -26,6 +26,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
+import java.util.EnumMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
@@ -66,21 +67,18 @@ import org.apache.fop.pdf.Version;
import org.apache.fop.pdf.VersionController;
import org.apache.fop.render.pdf.extensions.PDFEmbeddedFileExtensionAttachment;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.DISABLE_SRGB_COLORSPACE;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.ENCRYPTION_PARAMS;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_ACCESSCONTENT;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_ANNOTATIONS;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_ASSEMBLEDOC;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_COPY_CONTENT;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_EDIT_CONTENT;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_FILLINFORMS;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_PRINT;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_PRINTHQ;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.OUTPUT_PROFILE;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.OWNER_PASSWORD;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.PDF_A_MODE;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.PDF_X_MODE;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.USER_PASSWORD;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.ENCRYPTION_PARAMS;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.NO_ACCESSCONTENT;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.NO_ANNOTATIONS;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.NO_ASSEMBLEDOC;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.NO_COPY_CONTENT;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.NO_EDIT_CONTENT;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.NO_FILLINFORMS;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.NO_PRINT;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.NO_PRINTHQ;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.OWNER_PASSWORD;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.USER_PASSWORD;
+
/**
* Utility class which enables all sorts of features that are not directly connected to the
@@ -96,168 +94,40 @@ class PDFRenderingUtil {
/** the PDF Document being created */
private PDFDocument pdfDoc;
- /** the PDF/A mode (Default: disabled) */
- private PDFAMode pdfAMode = (PDFAMode) PDFRendererConfigOption.PDF_A_MODE.getDefaultValue();
-
- /** the PDF/X mode (Default: disabled) */
- private PDFXMode pdfXMode = (PDFXMode) PDFRendererConfigOption.PDF_X_MODE.getDefaultValue();
-
- /** the (optional) encryption parameters */
- private PDFEncryptionParams encryptionParams;
-
- /** Registry of PDF filters */
- private Map filterMap;
+ private PDFRendererOptionsConfig rendererConfig;
/** the ICC stream used as output profile by this document for PDF/A and PDF/X functionality. */
private PDFICCStream outputProfile;
+
/** the default sRGB color space. */
private PDFICCBasedColorSpace sRGBColorSpace;
- /** controls whether the sRGB color space should be installed */
- private boolean disableSRGBColorSpace = false;
-
- /** Optional URI to an output profile to be used. */
- private URI outputProfileURI;
-
- private Version maxPDFVersion;
-
PDFRenderingUtil(FOUserAgent userAgent) {
this.userAgent = userAgent;
initialize();
}
- private static boolean booleanValueOf(Object obj) {
- if (obj instanceof Boolean) {
- return ((Boolean)obj).booleanValue();
- } else if (obj instanceof String) {
- return Boolean.valueOf((String)obj).booleanValue();
- } else {
- throw new IllegalArgumentException("Boolean or \"true\" or \"false\" expected.");
- }
- }
-
private void initialize() {
- PDFEncryptionParams params
- = (PDFEncryptionParams) userAgent.getRendererOption(ENCRYPTION_PARAMS);
- if (params != null) {
- this.encryptionParams = params; //overwrite if available
- }
- String userPassword = (String) userAgent.getRendererOption(USER_PASSWORD);
- if (userPassword != null) {
- getEncryptionParams().setUserPassword(userPassword);
- }
- String ownerPassword = (String) userAgent.getRendererOption(OWNER_PASSWORD);
- if (ownerPassword != null) {
- getEncryptionParams().setOwnerPassword(ownerPassword);
- }
- Object noPrint = userAgent.getRendererOption(NO_PRINT);
- if (noPrint != null) {
- getEncryptionParams().setAllowPrint(!booleanValueOf(noPrint));
- }
- Object noCopyContent = userAgent.getRendererOption(NO_COPY_CONTENT);
- if (noCopyContent != null) {
- getEncryptionParams().setAllowCopyContent(!booleanValueOf(noCopyContent));
- }
- Object noEditContent = userAgent.getRendererOption(NO_EDIT_CONTENT);
- if (noEditContent != null) {
- getEncryptionParams().setAllowEditContent(!booleanValueOf(noEditContent));
- }
- Object noAnnotations = userAgent.getRendererOption(NO_ANNOTATIONS);
- if (noAnnotations != null) {
- getEncryptionParams().setAllowEditAnnotations(!booleanValueOf(noAnnotations));
- }
- Object noFillInForms = userAgent.getRendererOption(NO_FILLINFORMS);
- if (noFillInForms != null) {
- getEncryptionParams().setAllowFillInForms(!booleanValueOf(noFillInForms));
- }
- Object noAccessContent = userAgent.getRendererOption(NO_ACCESSCONTENT);
- if (noAccessContent != null) {
- getEncryptionParams().setAllowAccessContent(!booleanValueOf(noAccessContent));
- }
- Object noAssembleDoc = userAgent.getRendererOption(NO_ASSEMBLEDOC);
- if (noAssembleDoc != null) {
- getEncryptionParams().setAllowAssembleDocument(!booleanValueOf(noAssembleDoc));
- }
- Object noPrintHQ = userAgent.getRendererOption(NO_PRINTHQ);
- if (noPrintHQ != null) {
- getEncryptionParams().setAllowPrintHq(!booleanValueOf(noPrintHQ));
- }
- String s = (String) userAgent.getRendererOption(PDF_A_MODE);
- if (s != null) {
- this.pdfAMode = PDFAMode.getValueOf(s);
- }
- if (this.pdfAMode.isPDFA1LevelA()) {
+ rendererConfig = PDFRendererOptionsConfig.DEFAULT.merge(createFromUserAgent(userAgent));
+ if (rendererConfig.getPDFAMode().isPDFA1LevelA()) {
//Enable accessibility if PDF/A-1a is enabled because it requires tagged PDF.
userAgent.getRendererOptions().put(Accessibility.ACCESSIBILITY, Boolean.TRUE);
}
- s = (String) userAgent.getRendererOption(PDF_X_MODE);
- if (s != null) {
- this.pdfXMode = PDFXMode.getValueOf(s);
- }
- s = (String) userAgent.getRendererOption(OUTPUT_PROFILE);
- if (s != null) {
- this.outputProfileURI = URI.create(s);
- }
- Object disableSRGBColorSpace = userAgent.getRendererOption(DISABLE_SRGB_COLORSPACE);
- if (disableSRGBColorSpace != null) {
- this.disableSRGBColorSpace = booleanValueOf(disableSRGBColorSpace);
- }
}
- public FOUserAgent getUserAgent() {
- return this.userAgent;
- }
-
- /**
- * Sets the PDF/A mode for the PDF renderer.
- * @param mode the PDF/A mode
- */
- public void setAMode(PDFAMode mode) {
- this.pdfAMode = mode;
- }
-
- /**
- * Sets the PDF/X mode for the PDF renderer.
- * @param mode the PDF/X mode
- */
- public void setXMode(PDFXMode mode) {
- this.pdfXMode = mode;
- }
-
- /**
- * Sets the output color profile for the PDF renderer.
- * @param outputProfileURI the URI to the output color profile
- */
- public void setOutputProfileURI(URI outputProfileURI) {
- this.outputProfileURI = outputProfileURI;
- }
-
- /**
- * Enables or disables the default sRGB color space needed for the PDF document to preserve
- * the sRGB colors used in XSL-FO.
- * @param disable true to disable, false to enable
- */
- public void setDisableSRGBColorSpace(boolean disable) {
- this.disableSRGBColorSpace = disable;
- }
-
- /**
- * Sets the filter map to be used by the PDF renderer.
- * @param filterMap the filter map
- */
- public void setFilterMap(Map filterMap) {
- this.filterMap = filterMap;
+ private static PDFRendererOptionsConfig createFromUserAgent(FOUserAgent userAgent) {
+ Map<PDFRendererOption, Object> properties
+ = new EnumMap<PDFRendererOption, Object>(PDFRendererOption.class);
+ for (PDFRendererOption option : PDFRendererOption.values()) {
+ Object value = userAgent.getRendererOption(option);
+ properties.put(option, option.parse(value));
+ }
+ PDFEncryptionParams encryptionConfig = new EncryptionParamsBuilder().createParams(userAgent);
+ return new PDFRendererOptionsConfig(properties, encryptionConfig);
}
- /**
- * Gets the encryption parameters used by the PDF renderer.
- * @return encryptionParams the encryption parameters
- */
- PDFEncryptionParams getEncryptionParams() {
- if (this.encryptionParams == null) {
- this.encryptionParams = new PDFEncryptionParams();
- }
- return this.encryptionParams;
+ void mergeRendererOptionsConfig(PDFRendererOptionsConfig config) {
+ rendererConfig = rendererConfig.merge(config);
}
private void updateInfo() {
@@ -271,15 +141,15 @@ class PDFRenderingUtil {
}
private void updatePDFProfiles() {
- pdfDoc.getProfile().setPDFAMode(this.pdfAMode);
- pdfDoc.getProfile().setPDFXMode(this.pdfXMode);
+ pdfDoc.getProfile().setPDFAMode(rendererConfig.getPDFAMode());
+ pdfDoc.getProfile().setPDFXMode(rendererConfig.getPDFXMode());
}
private void addsRGBColorSpace() throws IOException {
- if (disableSRGBColorSpace) {
- if (this.pdfAMode != PDFAMode.DISABLED
- || this.pdfXMode != PDFXMode.DISABLED
- || this.outputProfileURI != null) {
+ if (rendererConfig.getDisableSRGBColorSpace()) {
+ if (rendererConfig.getPDFAMode() != PDFAMode.DISABLED
+ || rendererConfig.getPDFXMode() != PDFXMode.DISABLED
+ || rendererConfig.getOutputProfileURI() != null) {
throw new IllegalStateException("It is not possible to disable the sRGB color"
+ " space if PDF/A or PDF/X functionality is enabled or an"
+ " output profile is set!");
@@ -299,9 +169,10 @@ class PDFRenderingUtil {
}
ICC_Profile profile;
InputStream in = null;
- if (this.outputProfileURI != null) {
+ URI outputProfileUri = rendererConfig.getOutputProfileURI();
+ if (outputProfileUri != null) {
this.outputProfile = pdfDoc.getFactory().makePDFICCStream();
- in = getUserAgent().getResourceResolver().getResource(outputProfileURI);
+ in = userAgent.getResourceResolver().getResource(rendererConfig.getOutputProfileURI());
try {
profile = ColorProfileUtil.getICC_Profile(in);
} finally {
@@ -386,7 +257,7 @@ class PDFRenderingUtil {
}
String producer = userAgent.getProducer() != null ? userAgent.getProducer() : "";
-
+ final Version maxPDFVersion = rendererConfig.getPDFVersion();
if (maxPDFVersion == null) {
this.pdfDoc = new PDFDocument(producer);
} else {
@@ -396,22 +267,24 @@ class PDFRenderingUtil {
}
updateInfo();
updatePDFProfiles();
- pdfDoc.setFilterMap(filterMap);
+ pdfDoc.setFilterMap(rendererConfig.getFilterMap());
pdfDoc.outputHeader(out);
//Setup encryption if necessary
- PDFEncryptionManager.setupPDFEncryption(encryptionParams, pdfDoc);
+ PDFEncryptionManager.setupPDFEncryption(rendererConfig.getEncryptionParameters(), pdfDoc);
addsRGBColorSpace();
- if (this.outputProfileURI != null) {
+ if (rendererConfig.getOutputProfileURI() != null) {
addDefaultOutputProfile();
}
+ PDFXMode pdfXMode = rendererConfig.getPDFXMode();
if (pdfXMode != PDFXMode.DISABLED) {
log.debug(pdfXMode + " is active.");
log.warn("Note: " + pdfXMode
+ " support is work-in-progress and not fully implemented, yet!");
addPDFXOutputIntent();
}
+ PDFAMode pdfAMode = rendererConfig.getPDFAMode();
if (pdfAMode.isPDFA1LevelB()) {
log.debug("PDF/A is active. Conformance Level: " + pdfAMode);
addPDFA1OutputIntent();
@@ -467,7 +340,7 @@ class PDFRenderingUtil {
} catch (URISyntaxException use) {
throw new RuntimeException(use);
}
- InputStream in = getUserAgent().getResourceResolver().getResource(srcURI);
+ InputStream in = userAgent.getResourceResolver().getResource(srcURI);
if (in == null) {
throw new FileNotFoundException(embeddedFile.getSrc());
}
@@ -507,14 +380,72 @@ class PDFRenderingUtil {
nameArray.add(new PDFReference(fileSpec));
}
- /**
- * Sets the PDF version of the output document. See {@link Version} for the format of
- * <code>version</code>.
- * @param version the PDF version
- * @throws IllegalArgumentException if the format of version doesn't conform to that specified
- * by {@link Version}
- */
- public void setPDFVersion(Version version) {
- maxPDFVersion = version;
+ private static final class EncryptionParamsBuilder {
+ private PDFEncryptionParams params;
+
+ private EncryptionParamsBuilder() {
+ }
+
+ private PDFEncryptionParams createParams(FOUserAgent userAgent) {
+ params = (PDFEncryptionParams) userAgent.getRendererOptions().get(ENCRYPTION_PARAMS);
+ String userPassword = (String) userAgent.getRendererOption(USER_PASSWORD);
+ if (userPassword != null) {
+ getEncryptionParams().setUserPassword(userPassword);
+ }
+ String ownerPassword = (String) userAgent.getRendererOption(OWNER_PASSWORD);
+ if (ownerPassword != null) {
+ getEncryptionParams().setOwnerPassword(ownerPassword);
+ }
+ Object noPrint = userAgent.getRendererOption(NO_PRINT);
+ if (noPrint != null) {
+ getEncryptionParams().setAllowPrint(!booleanValueOf(noPrint));
+ }
+ Object noCopyContent = userAgent.getRendererOption(NO_COPY_CONTENT);
+ if (noCopyContent != null) {
+ getEncryptionParams().setAllowCopyContent(!booleanValueOf(noCopyContent));
+ }
+ Object noEditContent = userAgent.getRendererOption(NO_EDIT_CONTENT);
+ if (noEditContent != null) {
+ getEncryptionParams().setAllowEditContent(!booleanValueOf(noEditContent));
+ }
+ Object noAnnotations = userAgent.getRendererOption(NO_ANNOTATIONS);
+ if (noAnnotations != null) {
+ getEncryptionParams().setAllowEditAnnotations(!booleanValueOf(noAnnotations));
+ }
+ Object noFillInForms = userAgent.getRendererOption(NO_FILLINFORMS);
+ if (noFillInForms != null) {
+ getEncryptionParams().setAllowFillInForms(!booleanValueOf(noFillInForms));
+ }
+ Object noAccessContent = userAgent.getRendererOption(NO_ACCESSCONTENT);
+ if (noAccessContent != null) {
+ getEncryptionParams().setAllowAccessContent(!booleanValueOf(noAccessContent));
+ }
+ Object noAssembleDoc = userAgent.getRendererOption(NO_ASSEMBLEDOC);
+ if (noAssembleDoc != null) {
+ getEncryptionParams().setAllowAssembleDocument(!booleanValueOf(noAssembleDoc));
+ }
+ Object noPrintHQ = userAgent.getRendererOption(NO_PRINTHQ);
+ if (noPrintHQ != null) {
+ getEncryptionParams().setAllowPrintHq(!booleanValueOf(noPrintHQ));
+ }
+ return params;
+ }
+
+ private PDFEncryptionParams getEncryptionParams() {
+ if (params == null) {
+ params = new PDFEncryptionParams();
+ }
+ return params;
+ }
+
+ private static boolean booleanValueOf(Object obj) {
+ if (obj instanceof Boolean) {
+ return ((Boolean)obj).booleanValue();
+ } else if (obj instanceof String) {
+ return Boolean.valueOf((String)obj).booleanValue();
+ } else {
+ throw new IllegalArgumentException("Boolean or \"true\" or \"false\" expected.");
+ }
+ }
}
}
Modified: xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/PSRendererConfig.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/PSRendererConfig.java?rev=1353992&r1=1353991&r2=1353992&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/PSRendererConfig.java (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/PSRendererConfig.java Tue Jun 26 12:31:50 2012
@@ -35,20 +35,20 @@ import org.apache.fop.fonts.DefaultFontC
import org.apache.fop.render.RendererConfig;
import org.apache.fop.util.LogUtil;
-import static org.apache.fop.render.ps.PSRendererConfigurationOption.AUTO_ROTATE_LANDSCAPE;
-import static org.apache.fop.render.ps.PSRendererConfigurationOption.DSC_COMPLIANT;
-import static org.apache.fop.render.ps.PSRendererConfigurationOption.LANGUAGE_LEVEL;
-import static org.apache.fop.render.ps.PSRendererConfigurationOption.OPTIMIZE_RESOURCES;
-import static org.apache.fop.render.ps.PSRendererConfigurationOption.RENDERING_MODE;
-import static org.apache.fop.render.ps.PSRendererConfigurationOption.SAFE_SET_PAGE_DEVICE;
+import static org.apache.fop.render.ps.PSRendererOption.AUTO_ROTATE_LANDSCAPE;
+import static org.apache.fop.render.ps.PSRendererOption.DSC_COMPLIANT;
+import static org.apache.fop.render.ps.PSRendererOption.LANGUAGE_LEVEL;
+import static org.apache.fop.render.ps.PSRendererOption.OPTIMIZE_RESOURCES;
+import static org.apache.fop.render.ps.PSRendererOption.RENDERING_MODE;
+import static org.apache.fop.render.ps.PSRendererOption.SAFE_SET_PAGE_DEVICE;
/**
* The PostScript renderer configuration data object.
*/
public final class PSRendererConfig implements RendererConfig {
- private final EnumMap<PSRendererConfigurationOption, Object> params
- = new EnumMap<PSRendererConfigurationOption, Object>(PSRendererConfigurationOption.class);
+ private final EnumMap<PSRendererOption, Object> params
+ = new EnumMap<PSRendererOption, Object>(PSRendererOption.class);
private final DefaultFontConfig fontConfig;
@@ -132,12 +132,12 @@ public final class PSRendererConfig impl
}
}
- private void setConfigParameter(PSRendererConfigurationOption option,
+ private void setConfigParameter(PSRendererOption option,
Object value) {
config.params.put(option, value != null ? value : option.getDefaultValue());
}
- private void setBoolConfigParam(Configuration cfg, PSRendererConfigurationOption option) {
+ private void setBoolConfigParam(Configuration cfg, PSRendererOption option) {
setConfigParameter(option, cfg.getChild(
option.getName()).getValueAsBoolean((Boolean) option.getDefaultValue()));
}
Added: xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/PSRendererOption.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/PSRendererOption.java?rev=1353992&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/PSRendererOption.java (added)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/PSRendererOption.java Tue Jun 26 12:31:50 2012
@@ -0,0 +1,57 @@
+/*
+ * 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.render.ps;
+
+import org.apache.xmlgraphics.ps.PSGenerator;
+
+import org.apache.fop.render.RendererConfigOption;
+
+/**
+ * An enumeration of the PostScript renderer configuration options along with their default values.
+ */
+public enum PSRendererOption implements RendererConfigOption {
+ /** Indicates whether landscape pages should be rotated, default: false */
+ AUTO_ROTATE_LANDSCAPE("auto-rotate-landscape", false),
+ /** Sets the PostScript language leven, default: {@see PSGenerator#DEFAULT_LANGUAGE_LEVEL}*/
+ LANGUAGE_LEVEL("language-level", PSGenerator.DEFAULT_LANGUAGE_LEVEL),
+ /** Whether resources should be optimized in a post-processing run, default: false */
+ OPTIMIZE_RESOURCES("optimize-resources", false),
+ /** Indicates whether the "safe setpagedevice" mode is active, default: false */
+ SAFE_SET_PAGE_DEVICE("safe-set-page-device", false),
+ /** Indicates whether the PostScript output should be DSC compliant, default: true*/
+ DSC_COMPLIANT("dsc-compliant", true),
+ RENDERING_MODE("rendering", PSRenderingMode.QUALITY);
+
+ private final String name;
+ private final Object defaultValue;
+
+ private PSRendererOption(String name, Object defaultValue) {
+ this.name = name;
+ this.defaultValue = defaultValue;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Object getDefaultValue() {
+ return defaultValue;
+ }
+}
Propchange: xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/PSRendererOption.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/PSRenderingUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/PSRenderingUtil.java?rev=1353992&r1=1353991&r2=1353992&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/PSRenderingUtil.java (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/PSRenderingUtil.java Tue Jun 26 12:31:50 2012
@@ -33,9 +33,9 @@ import org.apache.fop.render.ps.extensio
import org.apache.fop.render.ps.extensions.PSExtensionAttachment;
import org.apache.fop.render.ps.extensions.PSSetupCode;
-import static org.apache.fop.render.ps.PSRendererConfigurationOption.AUTO_ROTATE_LANDSCAPE;
-import static org.apache.fop.render.ps.PSRendererConfigurationOption.LANGUAGE_LEVEL;
-import static org.apache.fop.render.ps.PSRendererConfigurationOption.OPTIMIZE_RESOURCES;
+import static org.apache.fop.render.ps.PSRendererOption.AUTO_ROTATE_LANDSCAPE;
+import static org.apache.fop.render.ps.PSRendererOption.LANGUAGE_LEVEL;
+import static org.apache.fop.render.ps.PSRendererOption.OPTIMIZE_RESOURCES;
/**
* Utility class which enables all sorts of features that are not directly connected to the
Modified: xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/PSTextPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/PSTextPainter.java?rev=1353992&r1=1353991&r2=1353992&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/PSTextPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/PSTextPainter.java Tue Jun 26 12:31:50 2012
@@ -52,7 +52,7 @@ import org.apache.fop.util.CharUtilities
import org.apache.fop.util.HexEncoder;
/**
- * Renders the attributed character iterator of a text node.
+ * Renders the attributed character iterator of a {@link org.apache.batik.gvt.TextNode TextNode}.
* This class draws the text directly using PostScript text operators so
* the text is not drawn using shapes which makes the PS files larger.
* <p>
Added: xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/fonts/PSTTFGenerator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/fonts/PSTTFGenerator.java?rev=1353992&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/fonts/PSTTFGenerator.java (added)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/fonts/PSTTFGenerator.java Tue Jun 26 12:31:50 2012
@@ -0,0 +1,101 @@
+/*
+ * 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.render.ps.fonts;
+
+import java.io.IOException;
+
+import org.apache.xmlgraphics.ps.PSGenerator;
+import org.apache.xmlgraphics.util.io.ASCIIHexOutputStream;
+
+/**
+ * This is a wrapper for {@link PSGenerator} that contains some members specific for streaming
+ * TrueType fonts to a PostScript document.
+ */
+public class PSTTFGenerator {
+ private PSGenerator gen;
+ private ASCIIHexOutputStream hexOut;
+
+ /**
+ * The buffer is used to store the font file in an array of hex-encoded strings. Strings are
+ * limited to 65535 characters, string will start with a newline, 2 characters are needed to
+ * hex-encode each byte.
+ */
+ public static final int MAX_BUFFER_SIZE = 32764;
+
+ /**
+ * Creates a new instance wrapping the given generator.
+ * @param gen the PSGenerator to wrap
+ */
+ public PSTTFGenerator(PSGenerator gen) {
+ this.gen = gen;
+ hexOut = new ASCIIHexOutputStream(gen.getOutputStream());
+ }
+
+ /**
+ * Writes the '<' character that starts a string.
+ */
+ public void startString() throws IOException {
+ // We need to reset the streamer so that it starts a new line in the PS document
+ hexOut = new ASCIIHexOutputStream(gen.getOutputStream());
+ gen.writeln("<");
+ }
+
+ /**
+ * Writes the given string to the output.
+ * @param cmd a string
+ */
+ public void write(String cmd) throws IOException {
+ gen.write(cmd);
+ }
+
+ /**
+ * Writes the given string to the output, followed by a newline.
+ * @param cmd a string
+ */
+ public void writeln(String cmd) throws IOException {
+ gen.writeln(cmd);
+ }
+
+ /**
+ * Writes bytes from the given byte array to the output.
+ *
+ * @param byteArray byte[] a byte array
+ * @param offset the position in the byte array where the streaming must start
+ * @param length the number of bytes to stream. This MUST be less than
+ * {@link #MAX_BUFFER_SIZE} - 1 since strings are suffixed by '00' (see Section 4.2 of
+ * Adobe Technical Note #5012, <em>The Type 42 Font Format Specification</em>.).
+ */
+ public void streamBytes(byte[] byteArray, int offset, int length) throws IOException {
+ if (length > MAX_BUFFER_SIZE) {
+ throw new UnsupportedOperationException("Attempting to write a string to a PostScript"
+ + " file that is greater than the buffer size.");
+ }
+ hexOut.write(byteArray, offset, length);
+ }
+
+ /**
+ * Finishes writing a string by appending '00' and '>' to the end.
+ */
+ public void endString() throws IOException {
+ /* Appends a '00' to the end of the string as specified in the spec */
+ gen.write("00\n> ");
+ }
+
+}
Propchange: xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/fonts/PSTTFGenerator.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/fonts/PSTTFGlyphOutputStream.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/fonts/PSTTFGlyphOutputStream.java?rev=1353992&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/fonts/PSTTFGlyphOutputStream.java (added)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/fonts/PSTTFGlyphOutputStream.java Tue Jun 26 12:31:50 2012
@@ -0,0 +1,75 @@
+/*
+ * 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.render.ps.fonts;
+
+import java.io.IOException;
+
+import org.apache.fop.fonts.truetype.TTFGlyphOutputStream;
+
+/**
+ * Streams glyphs in accordance with the constraints of the PostScript file format.
+ * Mainly, PostScript strings have a limited capacity and the font data may have to be
+ * broken down into several strings; however, this must occur at well-defined places like
+ * table or glyph boundaries. See also Adobe Technical Note #5012, <em>The Type 42 Font
+ * Format Specification</em>.
+ */
+public class PSTTFGlyphOutputStream implements TTFGlyphOutputStream {
+
+ /** Total number of bytes written so far. */
+ private int byteCounter;
+
+ private int lastStringBoundary;
+
+ private PSTTFGenerator ttfGen;
+
+ /**
+ * Constructor
+ * @param ttfGen PSTTFGenerator
+ */
+ public PSTTFGlyphOutputStream(PSTTFGenerator ttfGen) {
+ this.ttfGen = ttfGen;
+ }
+
+ public void startGlyphStream() throws IOException {
+ ttfGen.startString();
+ }
+
+ public void streamGlyph(byte[] glyphData, int offset, int size) throws IOException {
+ if (size > PSTTFGenerator.MAX_BUFFER_SIZE) {
+ throw new UnsupportedOperationException("The glyph is " + size
+ + " bytes. There may be an error in the font file.");
+ }
+
+ if (size + (byteCounter - lastStringBoundary) < PSTTFGenerator.MAX_BUFFER_SIZE) {
+ ttfGen.streamBytes(glyphData, offset, size);
+ } else {
+ ttfGen.endString();
+ lastStringBoundary = byteCounter;
+ ttfGen.startString();
+ ttfGen.streamBytes(glyphData, offset, size);
+ }
+ byteCounter += size;
+ }
+
+ public void endGlyphStream() throws IOException {
+ ttfGen.endString();
+ }
+
+}
Propchange: xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/fonts/PSTTFGlyphOutputStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/fonts/PSTTFOutputStream.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/fonts/PSTTFOutputStream.java?rev=1353992&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/fonts/PSTTFOutputStream.java (added)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/fonts/PSTTFOutputStream.java Tue Jun 26 12:31:50 2012
@@ -0,0 +1,62 @@
+/*
+ * 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.render.ps.fonts;
+
+import java.io.IOException;
+
+import org.apache.xmlgraphics.ps.PSGenerator;
+
+import org.apache.fop.fonts.truetype.TTFGlyphOutputStream;
+import org.apache.fop.fonts.truetype.TTFOutputStream;
+import org.apache.fop.fonts.truetype.TTFTableOutputStream;
+
+/**
+ * Streams a TrueType font according to the PostScript format.
+ */
+public class PSTTFOutputStream implements TTFOutputStream {
+
+ private final PSTTFGenerator ttfGen;
+
+ /**
+ * Creates a new instance wrapping the given generator.
+ *
+ * @param gen the generator to wrap
+ */
+ public PSTTFOutputStream(PSGenerator gen) {
+ this.ttfGen = new PSTTFGenerator(gen);
+ }
+
+ public void startFontStream() throws IOException {
+ ttfGen.write("/sfnts[");
+ }
+
+ public TTFTableOutputStream getTableOutputStream() {
+ return new PSTTFTableOutputStream(ttfGen);
+ }
+
+ public TTFGlyphOutputStream getGlyphOutputStream() {
+ return new PSTTFGlyphOutputStream(ttfGen);
+ }
+
+ public void endFontStream() throws IOException {
+ ttfGen.writeln("] def");
+ }
+
+}
Propchange: xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/fonts/PSTTFOutputStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/fonts/PSTTFTableOutputStream.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/fonts/PSTTFTableOutputStream.java?rev=1353992&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/fonts/PSTTFTableOutputStream.java (added)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/fonts/PSTTFTableOutputStream.java Tue Jun 26 12:31:50 2012
@@ -0,0 +1,59 @@
+/*
+ * 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.render.ps.fonts;
+
+import java.io.IOException;
+
+import org.apache.fop.fonts.truetype.TTFTableOutputStream;
+
+/**
+ * Streams a TrueType table according to the PostScript format.
+ */
+public class PSTTFTableOutputStream implements TTFTableOutputStream {
+
+ private PSTTFGenerator ttfGen;
+
+ /**
+ * Constructor.
+ * @param ttfGen the helper object to stream TrueType data
+ */
+ public PSTTFTableOutputStream(PSTTFGenerator ttfGen) {
+ this.ttfGen = ttfGen;
+ }
+
+ public void streamTable(byte[] ttfData, int offset, int size) throws IOException {
+ int offsetPosition = offset;
+ // Need to split the table into MAX_BUFFER_SIZE chunks
+ for (int i = 0; i < size / PSTTFGenerator.MAX_BUFFER_SIZE; i++) {
+ streamString(ttfData, offsetPosition, PSTTFGenerator.MAX_BUFFER_SIZE);
+ offsetPosition += PSTTFGenerator.MAX_BUFFER_SIZE;
+ }
+ if (size % PSTTFGenerator.MAX_BUFFER_SIZE > 0) {
+ streamString(ttfData, offsetPosition, size % PSTTFGenerator.MAX_BUFFER_SIZE);
+ }
+ }
+
+ private void streamString(byte[] byteArray, int offset, int length) throws IOException {
+ ttfGen.startString();
+ ttfGen.streamBytes(byteArray, offset, length);
+ ttfGen.endString();
+ }
+
+}
Propchange: xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/fonts/PSTTFTableOutputStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/txt/TxtRendererConfig.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/txt/TxtRendererConfig.java?rev=1353992&r1=1353991&r2=1353992&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/txt/TxtRendererConfig.java (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/txt/TxtRendererConfig.java Tue Jun 26 12:31:50 2012
@@ -36,13 +36,13 @@ import org.apache.fop.render.RendererCon
*/
public final class TxtRendererConfig implements RendererConfig {
- public enum TxtRendererConfigOption implements RendererConfigOption {
+ public enum TxtRendererOption implements RendererConfigOption {
ENCODING("encoding", "UTF-8");
private final String name;
private final Object defaultValue;
- private TxtRendererConfigOption(String name, Object defaultValue) {
+ private TxtRendererOption(String name, Object defaultValue) {
this.name = name;
this.defaultValue = defaultValue;
}
@@ -56,8 +56,8 @@ public final class TxtRendererConfig imp
}
}
- private final EnumMap<TxtRendererConfigOption, Object> params
- = new EnumMap<TxtRendererConfigOption, Object>(TxtRendererConfigOption.class);
+ private final EnumMap<TxtRendererOption, Object> params
+ = new EnumMap<TxtRendererOption, Object>(TxtRendererOption.class);
private final DefaultFontConfig fontConfig;
@@ -70,7 +70,7 @@ public final class TxtRendererConfig imp
}
public String getEncoding() {
- return (String) params.get(TxtRendererConfigOption.ENCODING);
+ return (String) params.get(TxtRendererOption.ENCODING);
}
/**
@@ -83,7 +83,7 @@ public final class TxtRendererConfig imp
TxtRendererConfig config = new TxtRendererConfig(new DefaultFontConfigParser().parse(cfg,
userAgent.validateStrictly()));
if (cfg != null) {
- TxtRendererConfigOption option = TxtRendererConfigOption.ENCODING;
+ TxtRendererOption option = TxtRendererOption.ENCODING;
String value = cfg.getChild(option.getName(), true).getValue(null);
config.params.put(option, value != null ? value : option.getDefaultValue());
}
Modified: xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java?rev=1353992&r1=1353991&r2=1353992&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java Tue Jun 26 12:31:50 2012
@@ -61,7 +61,7 @@ public class PDFDocumentGraphics2DConfig
try {
//Filter map
PDFRendererConfig pdfConfig = new PDFRendererConfigParser().build(null, cfg);
- pdfDoc.setFilterMap(pdfConfig.getFilterMap());
+ pdfDoc.setFilterMap(pdfConfig.getConfigOptions().getFilterMap());
} catch (FOPException e) {
throw new RuntimeException(e);
}
Modified: xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/afp/AFPTestSuite.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/afp/AFPTestSuite.java?rev=1353992&r1=1353991&r2=1353992&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/afp/AFPTestSuite.java (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/afp/AFPTestSuite.java Tue Jun 26 12:31:50 2012
@@ -31,7 +31,6 @@ import org.apache.fop.afp.modca.IncludeO
@RunWith(Suite.class)
@SuiteClasses({
IncludeObjectTestCase.class,
- AFPResourceUtilTestCase.class,
AFPObjectAreaInfoTestCase.class,
AFPPaintingStateTestCase.class
})
Modified: xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/apps/AFPRendererConfBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/apps/AFPRendererConfBuilder.java?rev=1353992&r1=1353991&r2=1353992&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/apps/AFPRendererConfBuilder.java (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/apps/AFPRendererConfBuilder.java Tue Jun 26 12:31:50 2012
@@ -25,25 +25,25 @@ import org.w3c.dom.Element;
import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder;
import org.apache.fop.render.afp.AFPRendererConfig;
-import org.apache.fop.render.afp.AFPRendererConfigOption;
+import org.apache.fop.render.afp.AFPRendererOption;
import org.apache.fop.render.afp.AFPShadingMode;
import static org.apache.fop.render.afp.AFPRendererConfig.ImagesModeOptions.MODE_GRAYSCALE;
-import static org.apache.fop.render.afp.AFPRendererConfigOption.DEFAULT_RESOURCE_LEVELS;
-import static org.apache.fop.render.afp.AFPRendererConfigOption.IMAGES;
-import static org.apache.fop.render.afp.AFPRendererConfigOption.IMAGES_DITHERING_QUALITY;
-import static org.apache.fop.render.afp.AFPRendererConfigOption.IMAGES_FS45;
-import static org.apache.fop.render.afp.AFPRendererConfigOption.IMAGES_JPEG;
-import static org.apache.fop.render.afp.AFPRendererConfigOption.IMAGES_MAPPING_OPTION;
-import static org.apache.fop.render.afp.AFPRendererConfigOption.IMAGES_MODE;
-import static org.apache.fop.render.afp.AFPRendererConfigOption.IMAGES_NATIVE;
-import static org.apache.fop.render.afp.AFPRendererConfigOption.IMAGES_WRAP_PSEG;
-import static org.apache.fop.render.afp.AFPRendererConfigOption.JPEG_ALLOW_JPEG_EMBEDDING;
-import static org.apache.fop.render.afp.AFPRendererConfigOption.JPEG_BITMAP_ENCODING_QUALITY;
-import static org.apache.fop.render.afp.AFPRendererConfigOption.LINE_WIDTH_CORRECTION;
-import static org.apache.fop.render.afp.AFPRendererConfigOption.RENDERER_RESOLUTION;
-import static org.apache.fop.render.afp.AFPRendererConfigOption.RESOURCE_GROUP_URI;
-import static org.apache.fop.render.afp.AFPRendererConfigOption.SHADING;
+import static org.apache.fop.render.afp.AFPRendererOption.DEFAULT_RESOURCE_LEVELS;
+import static org.apache.fop.render.afp.AFPRendererOption.IMAGES;
+import static org.apache.fop.render.afp.AFPRendererOption.IMAGES_DITHERING_QUALITY;
+import static org.apache.fop.render.afp.AFPRendererOption.IMAGES_FS45;
+import static org.apache.fop.render.afp.AFPRendererOption.IMAGES_JPEG;
+import static org.apache.fop.render.afp.AFPRendererOption.IMAGES_MAPPING_OPTION;
+import static org.apache.fop.render.afp.AFPRendererOption.IMAGES_MODE;
+import static org.apache.fop.render.afp.AFPRendererOption.IMAGES_NATIVE;
+import static org.apache.fop.render.afp.AFPRendererOption.IMAGES_WRAP_PSEG;
+import static org.apache.fop.render.afp.AFPRendererOption.JPEG_ALLOW_JPEG_EMBEDDING;
+import static org.apache.fop.render.afp.AFPRendererOption.JPEG_BITMAP_ENCODING_QUALITY;
+import static org.apache.fop.render.afp.AFPRendererOption.LINE_WIDTH_CORRECTION;
+import static org.apache.fop.render.afp.AFPRendererOption.RENDERER_RESOLUTION;
+import static org.apache.fop.render.afp.AFPRendererOption.RESOURCE_GROUP_URI;
+import static org.apache.fop.render.afp.AFPRendererOption.SHADING;
/**
* A config builder specific to a particular renderer for specific MIME type.
@@ -56,7 +56,7 @@ public final class AFPRendererConfBuilde
super(MimeConstants.MIME_AFP);
}
- private AFPRendererConfBuilder createTextElement(AFPRendererConfigOption option, String value) {
+ private AFPRendererConfBuilder createTextElement(AFPRendererOption option, String value) {
createTextElement(option.getName(), value);
return this;
}
@@ -153,7 +153,11 @@ public final class AFPRendererConfBuilde
return AFPRendererConfBuilder.this.endImages();
}
- private ImagesBuilder setAttribute(AFPRendererConfigOption options, Object value) {
+ private ImagesBuilder setAttribute(AFPRendererOption options, String value) {
+ return setAttribute(options.getName(), value);
+ }
+
+ private ImagesBuilder setAttribute(AFPRendererOption options, Object value) {
return setAttribute(options.getName(), value);
}
Modified: xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/apps/BitmapRendererConfBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/apps/BitmapRendererConfBuilder.java?rev=1353992&r1=1353991&r2=1353992&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/apps/BitmapRendererConfBuilder.java (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/apps/BitmapRendererConfBuilder.java Tue Jun 26 12:31:50 2012
@@ -21,11 +21,11 @@ package org.apache.fop.apps;
import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder;
-import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.ANTI_ALIASING;
-import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.BACKGROUND_COLOR;
-import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.COLOR_MODE;
-import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.JAVA2D_TRANSPARENT_PAGE_BACKGROUND;
-import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.RENDERING_QUALITY_ELEMENT;
+import static org.apache.fop.render.bitmap.BitmapRendererOption.ANTI_ALIASING;
+import static org.apache.fop.render.bitmap.BitmapRendererOption.BACKGROUND_COLOR;
+import static org.apache.fop.render.bitmap.BitmapRendererOption.COLOR_MODE;
+import static org.apache.fop.render.bitmap.BitmapRendererOption.JAVA2D_TRANSPARENT_PAGE_BACKGROUND;
+import static org.apache.fop.render.bitmap.BitmapRendererOption.RENDERING_QUALITY_ELEMENT;
public class BitmapRendererConfBuilder extends RendererConfBuilder {
Modified: xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/apps/PDFRendererConfBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/apps/PDFRendererConfBuilder.java?rev=1353992&r1=1353991&r2=1353992&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/apps/PDFRendererConfBuilder.java (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/apps/PDFRendererConfBuilder.java Tue Jun 26 12:31:50 2012
@@ -22,19 +22,21 @@ package org.apache.fop.apps;
import org.w3c.dom.Element;
import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder;
+import org.apache.fop.pdf.PDFEncryptionParams;
import org.apache.fop.render.RendererConfigOption;
-import org.apache.fop.render.pdf.PDFRendererConfigOption;
+import org.apache.fop.render.pdf.PDFEncryptionOption;
+import org.apache.fop.render.pdf.PDFRendererOption;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.DISABLE_SRGB_COLORSPACE;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.ENCRYPTION_LENGTH;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.ENCRYPTION_PARAMS;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.FILTER_LIST;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.OUTPUT_PROFILE;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.OWNER_PASSWORD;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.PDF_A_MODE;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.PDF_X_MODE;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.USER_PASSWORD;
-import static org.apache.fop.render.pdf.PDFRendererConfigOption.VERSION;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.ENCRYPTION_LENGTH;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.ENCRYPTION_PARAMS;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.OWNER_PASSWORD;
+import static org.apache.fop.render.pdf.PDFEncryptionOption.USER_PASSWORD;
+import static org.apache.fop.render.pdf.PDFRendererOption.DISABLE_SRGB_COLORSPACE;
+import static org.apache.fop.render.pdf.PDFRendererOption.FILTER_LIST;
+import static org.apache.fop.render.pdf.PDFRendererOption.OUTPUT_PROFILE;
+import static org.apache.fop.render.pdf.PDFRendererOption.PDF_A_MODE;
+import static org.apache.fop.render.pdf.PDFRendererOption.PDF_X_MODE;
+import static org.apache.fop.render.pdf.PDFRendererOption.VERSION;
/**
* A config builder specific to a particular renderer for specific MIME type.
@@ -97,7 +99,7 @@ public final class PDFRendererConfBuilde
private final Element el;
private EncryptionParamsBuilder() {
- el = createElement(ENCRYPTION_PARAMS.getName());
+ el = createElement(ENCRYPTION_PARAMS);
}
public EncryptionParamsBuilder setEncryptionLength(int length) {
@@ -115,7 +117,7 @@ public final class PDFRendererConfBuilde
return this;
}
- public EncryptionParamsBuilder setAllowParam(PDFRendererConfigOption option) {
+ public EncryptionParamsBuilder setAllowParam(PDFEncryptionOption option) {
el.appendChild(createElement(option.getName()));
return this;
}
Modified: xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/apps/PSRendererConfBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/apps/PSRendererConfBuilder.java?rev=1353992&r1=1353991&r2=1353992&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/apps/PSRendererConfBuilder.java (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/apps/PSRendererConfBuilder.java Tue Jun 26 12:31:50 2012
@@ -21,11 +21,11 @@ package org.apache.fop.apps;
import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder;
-import static org.apache.fop.render.ps.PSRendererConfigurationOption.AUTO_ROTATE_LANDSCAPE;
-import static org.apache.fop.render.ps.PSRendererConfigurationOption.DSC_COMPLIANT;
-import static org.apache.fop.render.ps.PSRendererConfigurationOption.LANGUAGE_LEVEL;
-import static org.apache.fop.render.ps.PSRendererConfigurationOption.OPTIMIZE_RESOURCES;
-import static org.apache.fop.render.ps.PSRendererConfigurationOption.SAFE_SET_PAGE_DEVICE;
+import static org.apache.fop.render.ps.PSRendererOption.AUTO_ROTATE_LANDSCAPE;
+import static org.apache.fop.render.ps.PSRendererOption.DSC_COMPLIANT;
+import static org.apache.fop.render.ps.PSRendererOption.LANGUAGE_LEVEL;
+import static org.apache.fop.render.ps.PSRendererOption.OPTIMIZE_RESOURCES;
+import static org.apache.fop.render.ps.PSRendererOption.SAFE_SET_PAGE_DEVICE;
/**
* A fop conf builder specific to a particular renderer for Postscript.
Modified: xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/apps/TIFFRendererConfBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/apps/TIFFRendererConfBuilder.java?rev=1353992&r1=1353991&r2=1353992&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/apps/TIFFRendererConfBuilder.java (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/apps/TIFFRendererConfBuilder.java Tue Jun 26 12:31:50 2012
@@ -19,7 +19,7 @@
package org.apache.fop.apps;
-import static org.apache.fop.render.bitmap.TIFFRendererConfig.TIFFRendererConfigOption.COMPRESSION;
+import static org.apache.fop.render.bitmap.TIFFRendererConfig.TIFFRendererOption.COMPRESSION;
public class TIFFRendererConfBuilder extends BitmapRendererConfBuilder {
Modified: xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/apps/TxtRendererConfBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/apps/TxtRendererConfBuilder.java?rev=1353992&r1=1353991&r2=1353992&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/apps/TxtRendererConfBuilder.java (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/apps/TxtRendererConfBuilder.java Tue Jun 26 12:31:50 2012
@@ -21,7 +21,7 @@ package org.apache.fop.apps;
import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder;
-import static org.apache.fop.render.txt.TxtRendererConfig.TxtRendererConfigOption.ENCODING;
+import static org.apache.fop.render.txt.TxtRendererConfig.TxtRendererOption.ENCODING;
public class TxtRendererConfBuilder extends RendererConfBuilder {
Modified: xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/bitmap/AbstractBitmapRendererConfigParserTester.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/bitmap/AbstractBitmapRendererConfigParserTester.java?rev=1353992&r1=1353991&r2=1353992&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/bitmap/AbstractBitmapRendererConfigParserTester.java (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/bitmap/AbstractBitmapRendererConfigParserTester.java Tue Jun 26 12:31:50 2012
@@ -28,14 +28,14 @@ import org.apache.fop.apps.AbstractRende
import org.apache.fop.apps.BitmapRendererConfBuilder;
import org.apache.fop.render.bitmap.BitmapRendererConfig.BitmapRendererConfigParser;
-import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.COLOR_MODE_BILEVEL;
-import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.COLOR_MODE_BINARY;
-import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.COLOR_MODE_GRAY;
-import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.COLOR_MODE_RGB;
-import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.COLOR_MODE_RGBA;
-import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.JAVA2D_TRANSPARENT_PAGE_BACKGROUND;
-import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.RENDERING_QUALITY;
-import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.RENDERING_SPEED;
+import static org.apache.fop.render.bitmap.BitmapRendererOption.COLOR_MODE_BILEVEL;
+import static org.apache.fop.render.bitmap.BitmapRendererOption.COLOR_MODE_BINARY;
+import static org.apache.fop.render.bitmap.BitmapRendererOption.COLOR_MODE_GRAY;
+import static org.apache.fop.render.bitmap.BitmapRendererOption.COLOR_MODE_RGB;
+import static org.apache.fop.render.bitmap.BitmapRendererOption.COLOR_MODE_RGBA;
+import static org.apache.fop.render.bitmap.BitmapRendererOption.JAVA2D_TRANSPARENT_PAGE_BACKGROUND;
+import static org.apache.fop.render.bitmap.BitmapRendererOption.RENDERING_QUALITY;
+import static org.apache.fop.render.bitmap.BitmapRendererOption.RENDERING_SPEED;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org