From 49fbe4eb34b96d8e835420c7011b4e6dfc8ee62c Mon Sep 17 00:00:00 2001 From: Keiron Liddle Date: Mon, 30 Jul 2001 07:44:59 +0000 Subject: [PATCH] started support to read all relevant properties mostly commented git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194377 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/fo/ColorProfile.java | 4 + src/org/apache/fop/fo/PropertyManager.java | 26 ++++++ src/org/apache/fop/fo/flow/Character.java | 57 ++----------- .../fop/fo/pagination/PageSequence.java | 5 ++ .../apache/fop/fo/pagination/RegionAfter.java | 16 +++- .../fop/fo/pagination/RegionBefore.java | 18 +++- .../apache/fop/fo/pagination/RegionBody.java | 84 ++++++------------- .../apache/fop/fo/pagination/RegionEnd.java | 16 +++- .../apache/fop/fo/pagination/RegionStart.java | 16 +++- src/org/apache/fop/fo/pagination/Root.java | 2 + .../fop/fo/pagination/SimplePageMaster.java | 18 ++-- .../apache/fop/layout/BackgroundProps.java | 17 ++++ src/org/apache/fop/layout/MarginProps.java | 25 ++++++ 13 files changed, 181 insertions(+), 123 deletions(-) create mode 100644 src/org/apache/fop/layout/BackgroundProps.java create mode 100644 src/org/apache/fop/layout/MarginProps.java diff --git a/src/org/apache/fop/fo/ColorProfile.java b/src/org/apache/fop/fo/ColorProfile.java index 2b2a35db5..16494c96c 100644 --- a/src/org/apache/fop/fo/ColorProfile.java +++ b/src/org/apache/fop/fo/ColorProfile.java @@ -35,6 +35,10 @@ public class ColorProfile extends ToBeImplementedElement { PropertyList propertyList) throws FOPException { super(parent, propertyList); this.name = "fo:color-profile"; + + //this.properties.get("src"); + //this.properties.get("color-profile-name"); + //this.properties.get("rendering-intent"); } } diff --git a/src/org/apache/fop/fo/PropertyManager.java b/src/org/apache/fop/fo/PropertyManager.java index 55dbe2717..f8fb0ab9a 100644 --- a/src/org/apache/fop/fo/PropertyManager.java +++ b/src/org/apache/fop/fo/PropertyManager.java @@ -9,6 +9,8 @@ package org.apache.fop.fo; import org.apache.fop.layout.FontState; import org.apache.fop.layout.FontInfo; import org.apache.fop.layout.BorderAndPadding; +import org.apache.fop.layout.MarginProps; +import org.apache.fop.layout.BackgroundProps; import org.apache.fop.fo.properties.BreakAfter; import org.apache.fop.fo.properties.BreakBefore; import org.apache.fop.fo.properties.Constants; @@ -185,4 +187,28 @@ public class PropertyManager { } } +public MarginProps getMarginProps() +{ +MarginProps props = new MarginProps(); + +// Common Margin Properties-Block + props.marginTop = this.properties.get("margin-top").getLength().mvalue(); + props.marginBottom = this.properties.get("margin-bottom").getLength().mvalue(); + props.marginLeft = this.properties.get("margin-left").getLength().mvalue(); + props.marginRight = this.properties.get("margin-right").getLength().mvalue(); +/* +// need to get opt, min and max + props.spaceBefore = this.properties.get("space-before").getLength().mvalue(); + props.spaceAfter = this.properties.get("space-after").getLength().mvalue(); + props.startIndent = this.properties.get("start-indent").getLength().mvalue(); + props.endIndent = this.properties.get("end-indent").getLength().mvalue(); +*/ +return props; +} + +public BackgroundProps getBackgroundProps() { +BackgroundProps bp = new BackgroundProps(); +return bp; +} + } diff --git a/src/org/apache/fop/fo/flow/Character.java b/src/org/apache/fop/fo/flow/Character.java index d8b4a6377..7dd566884 100644 --- a/src/org/apache/fop/fo/flow/Character.java +++ b/src/org/apache/fop/fo/flow/Character.java @@ -1,52 +1,7 @@ -/* - - ============================================================================ - The Apache Software License, Version 1.1 - ============================================================================ - - Copyright (C) 1999 The Apache Software Foundation. All rights reserved. - - Redistribution and use in source and binary forms, with or without modifica- - tion, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. The end-user documentation included with the redistribution, if any, must - include the following acknowledgment: "This product includes software - developed by the Apache Software Foundation (http://www.apache.org/)." - Alternately, this acknowledgment may appear in the software itself, if - and wherever such third-party acknowledgments normally appear. - - 4. The names "FOP" and "Apache Software Foundation" must not be used to - endorse or promote products derived from this software without prior - written permission. For written permission, please contact - apache@apache.org. - - 5. Products derived from this software may not be called "Apache", nor may - "Apache" appear in their name, without prior written permission of the - Apache Software Foundation. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- - DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This software consists of voluntary contributions made by many individuals - on behalf of the Apache Software Foundation and was originally created by - James Tauber . For more information on the Apache - Software Foundation, please see . - +/* $Id$ + * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * For details on use and redistribution please refer to the + * LICENSE file included with these sources. */ package org.apache.fop.fo.flow; @@ -56,7 +11,7 @@ import org.apache.fop.fo.*; import org.apache.fop.fo.properties.*; import org.apache.fop.datatypes.ColorType; import org.apache.fop.layout.BlockArea; -import org.apache.fop.layout.Area; +import org.apache.fop.layout.*; import org.apache.fop.layout.inline.InlineArea; import org.apache.fop.fo.FObj; import org.apache.fop.layout.FontState; @@ -101,7 +56,7 @@ public class Character extends FObj { public Status layout(Area area) throws FOPException { - BlockArea blockArea; + AreaContainer blockArea; blockArea = (BlockArea) area; boolean textDecoration; diff --git a/src/org/apache/fop/fo/pagination/PageSequence.java b/src/org/apache/fop/fo/pagination/PageSequence.java index de8e731be..5faba0b27 100644 --- a/src/org/apache/fop/fo/pagination/PageSequence.java +++ b/src/org/apache/fop/fo/pagination/PageSequence.java @@ -157,9 +157,14 @@ public class PageSequence extends FObj { this.properties.get("grouping-separator").getCharacter(), this.properties.get("grouping-size").getNumber().intValue(), this.properties.get("letter-value").getEnum() + ); this.forcePageCount = this.properties.get("force-page-count").getEnum(); + + //this.properties.get("country"); + //this.properties.get("language"); + //this.properties.get("id"); } public void addFlow(Flow flow) throws FOPException { diff --git a/src/org/apache/fop/fo/pagination/RegionAfter.java b/src/org/apache/fop/fo/pagination/RegionAfter.java index 614319ada..c5d4c9e0c 100644 --- a/src/org/apache/fop/fo/pagination/RegionAfter.java +++ b/src/org/apache/fop/fo/pagination/RegionAfter.java @@ -11,6 +11,8 @@ import org.apache.fop.fo.*; import org.apache.fop.fo.properties.*; import org.apache.fop.apps.FOPException; import org.apache.fop.layout.RegionArea; +import org.apache.fop.layout.BorderAndPadding; +import org.apache.fop.layout.BackgroundProps; public class RegionAfter extends Region { @@ -39,7 +41,19 @@ public class RegionAfter extends Region { int allocationRectangleYPosition, int allocationRectangleWidth, int allocationRectangleHeight) { - int extent = this.properties.get("extent").getLength().mvalue(); + +// Common Border, Padding, and Background Properties +BorderAndPadding bap = propMgr.getBorderAndPadding(); +BackgroundProps bProps = propMgr.getBackgroundProps(); + + //this.properties.get("clip"); + //this.properties.get("display-align"); + int extent = this.properties.get("extent").getLength().mvalue(); + //this.properties.get("overflow"); + //this.properties.get("precedence"); + //this.properties.get("region-name"); + //this.properties.get("reference-orientation"); + //this.properties.get("writing-mode"); return new RegionArea(allocationRectangleXPosition, allocationRectangleYPosition - diff --git a/src/org/apache/fop/fo/pagination/RegionBefore.java b/src/org/apache/fop/fo/pagination/RegionBefore.java index dcc60aaa6..491110d07 100644 --- a/src/org/apache/fop/fo/pagination/RegionBefore.java +++ b/src/org/apache/fop/fo/pagination/RegionBefore.java @@ -2,7 +2,7 @@ * * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. * For details on use and redistribution please refer to the - * LICENSE file included with these sources." + * LICENSE file included with these sources. */ package org.apache.fop.fo.pagination; @@ -10,6 +10,8 @@ package org.apache.fop.fo.pagination; import org.apache.fop.fo.*; import org.apache.fop.fo.properties.*; import org.apache.fop.layout.RegionArea; +import org.apache.fop.layout.BorderAndPadding; +import org.apache.fop.layout.BackgroundProps; import org.apache.fop.apps.FOPException; public class RegionBefore extends Region { @@ -40,7 +42,19 @@ public class RegionBefore extends Region { int allocationRectangleYPosition, int allocationRectangleWidth, int allocationRectangleHeight) { - int extent = this.properties.get("extent").getLength().mvalue(); + +// Common Border, Padding, and Background Properties +BorderAndPadding bap = propMgr.getBorderAndPadding(); +BackgroundProps bProps = propMgr.getBackgroundProps(); + + //this.properties.get("clip"); + //this.properties.get("display-align"); + int extent = this.properties.get("extent").getLength().mvalue(); + //this.properties.get("overflow"); + //this.properties.get("precedence"); + //this.properties.get("region-name"); + //this.properties.get("reference-orientation"); + //this.properties.get("writing-mode"); return new RegionArea(allocationRectangleXPosition, allocationRectangleYPosition, diff --git a/src/org/apache/fop/fo/pagination/RegionBody.java b/src/org/apache/fop/fo/pagination/RegionBody.java index 754e6e020..187a5957c 100644 --- a/src/org/apache/fop/fo/pagination/RegionBody.java +++ b/src/org/apache/fop/fo/pagination/RegionBody.java @@ -1,53 +1,9 @@ -/*-- $Id$ -- - - ============================================================================ - The Apache Software License, Version 1.1 - ============================================================================ - - Copyright (C) 1999 The Apache Software Foundation. All rights reserved. - - Redistribution and use in source and binary forms, with or without modifica- - tion, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. The end-user documentation included with the redistribution, if any, must - include the following acknowledgment: "This product includes software - developed by the Apache Software Foundation (http://www.apache.org/)." - Alternately, this acknowledgment may appear in the software itself, if - and wherever such third-party acknowledgments normally appear. - - 4. The names "Fop" and "Apache Software Foundation" must not be used to - endorse or promote products derived from this software without prior - written permission. For written permission, please contact - apache@apache.org. - - 5. Products derived from this software may not be called "Apache", nor may - "Apache" appear in their name, without prior written permission of the - Apache Software Foundation. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- - DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This software consists of voluntary contributions made by many individuals - on behalf of the Apache Software Foundation and was originally created by - James Tauber . For more information on the Apache - Software Foundation, please see . - +/* $Id$ + * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * For details on use and redistribution please refer to the + * LICENSE file included with these sources. */ + package org.apache.fop.fo.pagination; // FOP @@ -58,6 +14,9 @@ import org.apache.fop.datatypes.ColorType; import org.apache.fop.apps.FOPException; import org.apache.fop.layout.RegionArea; import org.apache.fop.layout.BodyRegionArea; +import org.apache.fop.layout.BorderAndPadding; +import org.apache.fop.layout.BackgroundProps; +import org.apache.fop.layout.MarginProps; import org.apache.fop.messaging.MessageHandler; public class RegionBody extends Region { @@ -87,19 +46,28 @@ public class RegionBody extends Region { int allocationRectangleYPosition, int allocationRectangleWidth, int allocationRectangleHeight) { - int marginTop = this.properties.get("margin-top").getLength().mvalue(); - int marginBottom = this.properties.get("margin-bottom").getLength().mvalue(); - int marginLeft = this.properties.get("margin-left").getLength().mvalue(); - int marginRight = this.properties.get("margin-right").getLength().mvalue(); + +// Common Border, Padding, and Background Properties +BorderAndPadding bap = propMgr.getBorderAndPadding(); +BackgroundProps bProps = propMgr.getBackgroundProps(); + +// Common Margin Properties-Block +MarginProps mProps = propMgr.getMarginProps(); + + //this.properties.get("clip"); + //this.properties.get("display-align"); + //this.properties.get("region-name"); + //this.properties.get("reference-orientation"); + //this.properties.get("writing-mode"); this.backgroundColor = this.properties.get( "background-color").getColorType(); - BodyRegionArea body = new BodyRegionArea(allocationRectangleXPosition + marginLeft, - allocationRectangleYPosition - marginTop, - allocationRectangleWidth - marginLeft - - marginRight, allocationRectangleHeight - - marginTop - marginBottom); + BodyRegionArea body = new BodyRegionArea(allocationRectangleXPosition + mProps.marginLeft, + allocationRectangleYPosition - mProps.marginTop, + allocationRectangleWidth - mProps.marginLeft - + mProps.marginRight, allocationRectangleHeight - + mProps.marginTop - mProps.marginBottom); int overflow = this.properties.get("overflow").getEnum(); String columnCountAsString = this.properties.get("column-count").getString(); diff --git a/src/org/apache/fop/fo/pagination/RegionEnd.java b/src/org/apache/fop/fo/pagination/RegionEnd.java index b6ca9b834..110389df4 100644 --- a/src/org/apache/fop/fo/pagination/RegionEnd.java +++ b/src/org/apache/fop/fo/pagination/RegionEnd.java @@ -11,6 +11,8 @@ package org.apache.fop.fo.pagination; import org.apache.fop.fo.*; import org.apache.fop.fo.properties.*; import org.apache.fop.layout.RegionArea; +import org.apache.fop.layout.BorderAndPadding; +import org.apache.fop.layout.BackgroundProps; import org.apache.fop.apps.FOPException; public class RegionEnd extends Region { @@ -61,7 +63,19 @@ public class RegionEnd extends Region { int allocationRectangleYPosition, int allocationRectangleWidth, int allocationRectangleHeight) { - int extent = this.properties.get("extent").getLength().mvalue(); + +// Common Border, Padding, and Background Properties +BorderAndPadding bap = propMgr.getBorderAndPadding(); +BackgroundProps bProps = propMgr.getBackgroundProps(); + + //this.properties.get("clip"); + //this.properties.get("display-align"); + int extent = this.properties.get("extent").getLength().mvalue(); + //this.properties.get("overflow"); + //this.properties.get("region-name"); + //this.properties.get("reference-orientation"); + //this.properties.get("writing-mode"); + return makeRegionArea(allocationRectangleXPosition, allocationRectangleYPosition, allocationRectangleWidth, extent, false, false, 0, 0); diff --git a/src/org/apache/fop/fo/pagination/RegionStart.java b/src/org/apache/fop/fo/pagination/RegionStart.java index 57b320027..a039f6684 100644 --- a/src/org/apache/fop/fo/pagination/RegionStart.java +++ b/src/org/apache/fop/fo/pagination/RegionStart.java @@ -10,6 +10,8 @@ package org.apache.fop.fo.pagination; import org.apache.fop.fo.*; import org.apache.fop.fo.properties.*; import org.apache.fop.layout.RegionArea; +import org.apache.fop.layout.BorderAndPadding; +import org.apache.fop.layout.BackgroundProps; import org.apache.fop.apps.FOPException; public class RegionStart extends Region { @@ -59,7 +61,19 @@ public class RegionStart extends Region { int allocationRectangleYPosition, int allocationRectangleWidth, int allocationRectangleHeight) { - int extent = this.properties.get("extent").getLength().mvalue(); + +// Common Border, Padding, and Background Properties +BorderAndPadding bap = propMgr.getBorderAndPadding(); +BackgroundProps bProps = propMgr.getBackgroundProps(); + + //this.properties.get("clip"); + //this.properties.get("display-align"); + int extent = this.properties.get("extent").getLength().mvalue(); + //this.properties.get("overflow"); + //this.properties.get("region-name"); + //this.properties.get("reference-orientation"); + //this.properties.get("writing-mode"); + return makeRegionArea(allocationRectangleXPosition, allocationRectangleYPosition, allocationRectangleWidth, extent, false, false, 0, 0); diff --git a/src/org/apache/fop/fo/pagination/Root.java b/src/org/apache/fop/fo/pagination/Root.java index 14192eed1..9daa6da89 100644 --- a/src/org/apache/fop/fo/pagination/Root.java +++ b/src/org/apache/fop/fo/pagination/Root.java @@ -47,6 +47,8 @@ public class Root extends FObj { super(parent, propertyList); this.name = "fo:root"; + //this.properties.get("media-usage"); + pageSequences = new Vector(); if (parent != null) { diff --git a/src/org/apache/fop/fo/pagination/SimplePageMaster.java b/src/org/apache/fop/fo/pagination/SimplePageMaster.java index b87664a3a..2a5642d90 100644 --- a/src/org/apache/fop/fo/pagination/SimplePageMaster.java +++ b/src/org/apache/fop/fo/pagination/SimplePageMaster.java @@ -1,5 +1,4 @@ /*-- $Id$ -- - * * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. * For details on use and redistribution please refer to the * LICENSE file included with these sources." @@ -14,6 +13,7 @@ import org.apache.fop.fo.properties.*; import org.apache.fop.layout.PageMaster; import org.apache.fop.layout.RegionArea; import org.apache.fop.layout.BodyRegionArea; +import org.apache.fop.layout.MarginProps; import org.apache.fop.apps.FOPException; import java.util.*; @@ -71,16 +71,16 @@ public class SimplePageMaster extends FObj { protected void end() { int pageWidth = this.properties.get("page-width").getLength().mvalue(); int pageHeight = this.properties.get("page-height").getLength().mvalue(); + //this.properties.get("reference-orientation"); + //this.properties.get("writing-mode"); - int marginTop = this.properties.get("margin-top").getLength().mvalue(); - int marginBottom = this.properties.get("margin-bottom").getLength().mvalue(); - int marginLeft = this.properties.get("margin-left").getLength().mvalue(); - int marginRight = this.properties.get("margin-right").getLength().mvalue(); +// Common Margin Properties-Block +MarginProps mProps = propMgr.getMarginProps(); - int contentRectangleXPosition = marginLeft; - int contentRectangleYPosition = pageHeight - marginTop; - int contentRectangleWidth = pageWidth - marginLeft - marginRight; - int contentRectangleHeight = pageHeight - marginTop - marginBottom; + int contentRectangleXPosition = mProps.marginLeft; + int contentRectangleYPosition = pageHeight - mProps.marginTop; + int contentRectangleWidth = pageWidth - mProps.marginLeft - mProps.marginRight; + int contentRectangleHeight = pageHeight - mProps.marginTop - mProps.marginBottom; this.pageMaster = new PageMaster(pageWidth, pageHeight); if (getRegion(RegionBody.REGION_CLASS) != null) { diff --git a/src/org/apache/fop/layout/BackgroundProps.java b/src/org/apache/fop/layout/BackgroundProps.java new file mode 100644 index 000000000..c7a4ec4ee --- /dev/null +++ b/src/org/apache/fop/layout/BackgroundProps.java @@ -0,0 +1,17 @@ +/* $Id$ + * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * For details on use and redistribution please refer to the + * LICENSE file included with these sources. + */ + +package org.apache.fop.layout; + +/** + * Store all hyphenation related properties on an FO. + * Public "structure" allows direct member access. + */ +public class BackgroundProps { + + public BackgroundProps() { + } +} diff --git a/src/org/apache/fop/layout/MarginProps.java b/src/org/apache/fop/layout/MarginProps.java new file mode 100644 index 000000000..4b31be890 --- /dev/null +++ b/src/org/apache/fop/layout/MarginProps.java @@ -0,0 +1,25 @@ +/* $Id$ + * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * For details on use and redistribution please refer to the + * LICENSE file included with these sources. + */ + +package org.apache.fop.layout; + +/** + * Store all hyphenation related properties on an FO. + * Public "structure" allows direct member access. + */ +public class MarginProps { + public int marginTop; + public int marginBottom; + public int marginLeft; + public int marginRight; + public int spaceBefore; + public int spaceAfter; + public int startIndent; + public int endIndent; + + public MarginProps() { + } +} -- 2.39.5