aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop
diff options
context:
space:
mode:
authorKeiron Liddle <keiron@apache.org>2001-08-30 10:09:03 +0000
committerKeiron Liddle <keiron@apache.org>2001-08-30 10:09:03 +0000
commit348228dd57dbce827a48bfdafb4fa700b2ea5a8c (patch)
treeddb5b86cf36fa92d5e3d5cd17eb7dc77ee099618 /src/org/apache/fop
parente0f188c784787183e904380600233cb46b8277ff (diff)
downloadxmlgraphics-fop-348228dd57dbce827a48bfdafb4fa700b2ea5a8c.tar.gz
xmlgraphics-fop-348228dd57dbce827a48bfdafb4fa700b2ea5a8c.zip
handles viewbox and no svg size better
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194446 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop')
-rw-r--r--src/org/apache/fop/layout/inline/ForeignObjectArea.java8
-rw-r--r--src/org/apache/fop/render/pdf/PDFRenderer.java12
-rw-r--r--src/org/apache/fop/svg/SVGElement.java41
3 files changed, 54 insertions, 7 deletions
diff --git a/src/org/apache/fop/layout/inline/ForeignObjectArea.java b/src/org/apache/fop/layout/inline/ForeignObjectArea.java
index 72fb91dc0..535743499 100644
--- a/src/org/apache/fop/layout/inline/ForeignObjectArea.java
+++ b/src/org/apache/fop/layout/inline/ForeignObjectArea.java
@@ -92,6 +92,14 @@ public class ForeignObjectArea extends InlineArea {
chauto = ha;
}
+ public boolean isContentWidthAuto() {
+ return cwauto;
+ }
+
+ public boolean isContentHeightAuto() {
+ return chauto;
+ }
+
public void setAlign(int align) {
this.align = align;
}
diff --git a/src/org/apache/fop/render/pdf/PDFRenderer.java b/src/org/apache/fop/render/pdf/PDFRenderer.java
index 6cec91dd0..e4ae8f056 100644
--- a/src/org/apache/fop/render/pdf/PDFRenderer.java
+++ b/src/org/apache/fop/render/pdf/PDFRenderer.java
@@ -387,6 +387,7 @@ public class PDFRenderer extends PrintRenderer {
SVGSVGElement svg = ((SVGDocument)doc).getRootElement();
int w = (int)(svg.getWidth().getBaseVal().getValue() * 1000);
int h = (int)(svg.getHeight().getBaseVal().getValue() * 1000);
+
float sx = 1, sy = -1;
int xOffset = x, yOffset = y;
@@ -412,6 +413,17 @@ public class PDFRenderer extends PrintRenderer {
currentStream.add(sx + " 0 0 " + sy + " " + xOffset / 1000f + " "
+ yOffset / 1000f + " cm\n");
+ AffineTransform at = ViewBox.getPreserveAspectRatioTransform(svg, w / 1000f, h / 1000f);
+ if(!at.isIdentity()) {
+ double[] vals = new double[6];
+ at.getMatrix(vals);
+ currentStream.add(PDFNumber.doubleOut(vals[0]) + " "
+ + PDFNumber.doubleOut(vals[1]) + " "
+ + PDFNumber.doubleOut(vals[2]) + " "
+ + PDFNumber.doubleOut(vals[3]) + " "
+ + PDFNumber.doubleOut(vals[4]) + " "
+ + PDFNumber.doubleOut(vals[5]) + " cm\n");
+ }
UserAgent userAgent = new MUserAgent(new AffineTransform());
diff --git a/src/org/apache/fop/svg/SVGElement.java b/src/org/apache/fop/svg/SVGElement.java
index 91ef47bb0..b4f3dd811 100644
--- a/src/org/apache/fop/svg/SVGElement.java
+++ b/src/org/apache/fop/svg/SVGElement.java
@@ -26,6 +26,8 @@ import org.apache.batik.dom.svg.SVGDOMImplementation;
import java.io.File;
import java.net.URL;
+import java.util.List;
+import java.util.ArrayList;
/**
* class representing svg:svg pseudo flow object.
@@ -80,7 +82,7 @@ public class SVGElement extends Svg {
*
* @return the status of the layout
*/
- public Status layout(Area area) throws FOPException {
+ public Status layout(final Area area) throws FOPException {
if (!(area instanceof ForeignObjectArea)) {
// this is an error
@@ -100,7 +102,7 @@ public class SVGElement extends Svg {
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
Document doc = impl.createDocument(svgNS, "svg", null);
- Element svgRoot = doc.getDocumentElement();
+ final Element svgRoot = doc.getDocumentElement();
try {
String baseDir = Configuration.getStringValue("baseDir");
@@ -109,18 +111,33 @@ public class SVGElement extends Svg {
DefaultSVGContext dc = new DefaultSVGContext() {
public float getPixelToMM() {
- return 0.264583333333333333333f;
// 72 dpi
+ return 0.35277777777777777778f;
}
- public float getViewportWidth() {
- return 100;
+ public float getViewportWidth(Element e) throws IllegalStateException {
+ if(e == svgRoot) {
+ ForeignObjectArea foa = (ForeignObjectArea)area;
+ if(!foa.isContentWidthAuto()) {
+ return foa.getContentWidth();
+ }
+ }
+ return super.getViewportWidth(e);
}
- public float getViewportHeight() {
- return 100;
+ public float getViewportHeight(Element e) throws IllegalStateException {
+ if(e == svgRoot) {
+ ForeignObjectArea foa = (ForeignObjectArea)area;
+ if(!foa.isContentHeightAuto()) {
+ return foa.getContentHeight();
+ }
+ }
+ return super.getViewportHeight(e);
}
+ public List getDefaultFontFamilyValue() {
+ return FONT_FAMILY;
+ }
};
((SVGOMDocument)doc).setSVGContext(dc);
buildTopLevel(doc, svgRoot);
@@ -145,4 +162,14 @@ public class SVGElement extends Svg {
return new Status(Status.OK);
}
+ public final static List FONT_FAMILY;
+ static {
+ FONT_FAMILY = new ArrayList();
+ FONT_FAMILY.add("Helvetica");
+ FONT_FAMILY.add("Times");
+ FONT_FAMILY.add("Courier");
+ FONT_FAMILY.add("sans-serif");
+ FONT_FAMILY.add("serif");
+ }
+
}