Kaynağa Gözat

1.) LM initialization logic for fo:table-body, fo:table-footer, and fo:table-header

moved out of AddLMVisitor.

2.) New LayoutManager subclass created for fo:external-graphic formatting object.

3.) ValidateChildNode(), endOfNode() implemented for fo:float.


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197866 13f79535-47bb-0310-9956-ffa450edef68
tags/Root_Temp_KnuthStylePageBreaking
Glen Mazza 20 yıl önce
ebeveyn
işleme
89db98aa88

+ 12
- 43
src/java/org/apache/fop/fo/flow/ExternalGraphic.java Dosyayı Görüntüle

@@ -27,18 +27,14 @@ import org.xml.sax.Attributes;
import org.xml.sax.Locator;
import org.xml.sax.SAXParseException;

// FOP
import org.apache.fop.area.inline.Image;
import org.apache.fop.area.inline.InlineArea;
import org.apache.fop.area.inline.Viewport;
import org.apache.fop.datatypes.Length;
import org.apache.fop.fo.properties.CommonBorderAndPadding;
import org.apache.fop.fo.properties.CommonBackground;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.image.FopImage;
import org.apache.fop.image.ImageFactory;
import org.apache.fop.layoutmgr.LeafNodeLayoutManager;
import org.apache.fop.layoutmgr.TraitSetter;
import org.apache.fop.layoutmgr.ExternalGraphicLayoutManager;

/**
* External graphic formatting object.
@@ -88,6 +84,7 @@ public class ExternalGraphic extends FObj {
/**
* Setup this image.
* This gets the sizes for the image and the dimensions and clipping.
* @todo move logic to LM class and/or addProperties() as appropriate
*/
private void setup() {
url = this.propertyList.get(PR_SRC).getString();
@@ -230,6 +227,7 @@ public class ExternalGraphic extends FObj {

/**
* @return the ViewHeight (in millipoints??)
* @todo check that each of these accessors are needed
*/
public int getViewHeight() {
return viewHeight;
@@ -251,52 +249,23 @@ public class ExternalGraphic extends FObj {
return placement;
}

public String getName() {
return "fo:external-graphic";
}

/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
setup();
InlineArea area = getExternalGraphicInlineArea();
if (area != null) {
LeafNodeLayoutManager lm = new LeafNodeLayoutManager(this);
lm.setCurrentArea(area);
lm.setAlignment(getProperty(PR_VERTICAL_ALIGN).getEnum());
lm.setLead(getViewHeight());
if (getURL() != null) {
ExternalGraphicLayoutManager lm = new ExternalGraphicLayoutManager(this);
list.add(lm);
}
}

/**
* Get the inline area for this external grpahic.
* This creates the image area and puts it inside a viewport.
*
* @return the viewport containing the image area
* @todo see if can move to LM classes.
*/
public InlineArea getExternalGraphicInlineArea() {
if (getURL() == null) {
return null;
}
Image imArea = new Image(getURL());
Viewport vp = new Viewport(imArea);
vp.setWidth(getViewWidth());
vp.setHeight(getViewHeight());
vp.setClip(getClip());
vp.setContentPosition(getPlacement());
vp.setOffset(0);

// Common Border, Padding, and Background Properties
CommonBorderAndPadding bap = getPropertyManager().getBorderAndPadding();
CommonBackground bProps = getPropertyManager().getBackgroundProps();
TraitSetter.addBorders(vp, bap);
TraitSetter.addBackground(vp, bProps);

return vp;
}
/**
* @see org.apache.fop.fo.FObj#getName()
*/
public String getName() {
return "fo:external-graphic";
}

/**
* @see org.apache.fop.fo.FObj#getNameId()

+ 27
- 4
src/java/org/apache/fop/fo/flow/Float.java Dosyayı Görüntüle

@@ -18,6 +18,11 @@

package org.apache.fop.fo.flow;

// XML
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
import org.xml.sax.SAXParseException;

// FOP
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.ToBeImplementedElement;
@@ -34,13 +39,31 @@ public class Float extends ToBeImplementedElement {
super(parent);
}

private void setup() {

// this.propertyList.get("float");
// this.propertyList.get("clear");
/**
* @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
* XSL Content Model: (%block;)+
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
throws SAXParseException {
if (!isBlockItem(nsURI, localName)) {
invalidChildError(loc, nsURI, localName);
}
}

/**
* Make sure content model satisfied, if so then tell the
* StructureRenderer that we are at the end of the flow.
* @see org.apache.fop.fo.FONode#end
*/
protected void endOfNode() throws SAXParseException {
if (childNodes == null) {
missingChildElementError("(%block;)+");
}
}

/**
* @see org.apache.fop.fo.FObj#getName()
*/
public String getName() {
return "fo:float";
}

+ 16
- 12
src/java/org/apache/fop/fo/flow/TableBody.java Dosyayı Görüntüle

@@ -18,6 +18,9 @@

package org.apache.fop.fo.flow;

// Java
import java.util.List;

// XML
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
@@ -27,14 +30,13 @@ import org.xml.sax.SAXParseException;
import org.apache.fop.datatypes.ColorType;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.layoutmgr.AddLMVisitor;
import org.apache.fop.fo.LMVisited;
import org.apache.fop.layoutmgr.table.Body;

/**
* Class modelling the fo:table-body object. See Sec. 6.7.8 of the XSL-FO
* Standard.
*/
public class TableBody extends FObj implements LMVisited {
public class TableBody extends FObj {

private int spaceBefore;
private int spaceAfter;
@@ -61,19 +63,21 @@ public class TableBody extends FObj implements LMVisited {
getFOInputHandler().startBody(this);
}

/**
* This is a hook for the AddLMVisitor class to be able to access
* this object.
* @param aLMV the AddLMVisitor object that can access this object.
*/
public void acceptVisitor(AddLMVisitor aLMV) {
aLMV.serveTableBody(this);
}

protected void endOfNode() throws SAXParseException {
getFOInputHandler().endBody(this);
}

/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
Body blm = new Body(this);
list.add(blm);
}

/**
* @see org.apache.fop.fo.FObj#getName()
*/
public String getName() {
return "fo:table-body";
}

+ 4
- 7
src/java/org/apache/fop/fo/flow/TableFooter.java Dosyayı Görüntüle

@@ -20,14 +20,12 @@ package org.apache.fop.fo.flow;

// FOP
import org.apache.fop.fo.FONode;
import org.apache.fop.layoutmgr.AddLMVisitor;
import org.apache.fop.fo.LMVisited;

/**
* Class modelling the fo:table-footer object. See Sec. 6.7.7 of the XSL-FO
* Standard.
*/
public class TableFooter extends TableBody implements LMVisited {
public class TableFooter extends TableBody {

/**
* @param parent FONode that is the parent of this object
@@ -36,10 +34,9 @@ public class TableFooter extends TableBody implements LMVisited {
super(parent);
}

public void acceptVisitor(AddLMVisitor aLMV) {
aLMV.serveTableFooter(this);
}

/**
* @see org.apache.fop.fo.FObj#getName()
*/
public String getName() {
return "fo:table-footer";
}

+ 4
- 7
src/java/org/apache/fop/fo/flow/TableHeader.java Dosyayı Görüntüle

@@ -20,14 +20,12 @@ package org.apache.fop.fo.flow;

// FOP
import org.apache.fop.fo.FONode;
import org.apache.fop.layoutmgr.AddLMVisitor;
import org.apache.fop.fo.LMVisited;

/**
* Class modelling the fo:table-header object. See Sec. 6.7.6 of the XSL-FO
* Standard.
*/
public class TableHeader extends TableBody implements LMVisited {
public class TableHeader extends TableBody {

/**
* @param parent FONode that is the parent of this object
@@ -36,10 +34,9 @@ public class TableHeader extends TableBody implements LMVisited {
super(parent);
}

public void acceptVisitor(AddLMVisitor aLMV) {
aLMV.serveTableHeader(this);
}

/**
* @see org.apache.fop.fo.FObj#getName()
*/
public String getName() {
return "fo:table-header";
}

+ 3
- 0
src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java Dosyayı Görüntüle

@@ -67,6 +67,9 @@ public abstract class AbstractLayoutManager implements LayoutManager, Constants
* @param fo the formatting object for this layout manager
*/
public AbstractLayoutManager(FObj fo) {
if (fo == null) {
throw new IllegalStateException("Null formatting object found.");
}
setFObj(fo);
}


+ 0
- 20
src/java/org/apache/fop/layoutmgr/AddLMVisitor.java Dosyayı Görüntüle

@@ -49,8 +49,6 @@ import org.apache.fop.fo.flow.TableAndCaption;
import org.apache.fop.fo.flow.TableBody;
import org.apache.fop.fo.flow.TableCell;
import org.apache.fop.fo.flow.TableColumn;
import org.apache.fop.fo.flow.TableFooter;
import org.apache.fop.fo.flow.TableHeader;
import org.apache.fop.fo.flow.TableRow;
import org.apache.fop.fo.flow.Wrapper;
import org.apache.fop.fo.pagination.Title;
@@ -434,26 +432,8 @@ public class AddLMVisitor {
return clm;
}

public void serveTableBody(TableBody node) {
currentLMList.add(getTableBodyLayoutManager(node));
}

public Body getTableBodyLayoutManager(TableBody node) {
Body blm = new Body(node);
return blm;
}

/**
* @param node TableFooter object to process
*/
public void serveTableFooter(TableFooter node) {
serveTableBody((TableBody)node);
}

/**
* @param node TableHeader object to process
*/
public void serveTableHeader(TableHeader node) {
serveTableBody((TableBody)node);
}
}

+ 74
- 0
src/java/org/apache/fop/layoutmgr/ExternalGraphicLayoutManager.java Dosyayı Görüntüle

@@ -0,0 +1,74 @@
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
* Licensed 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.layoutmgr;

import org.apache.fop.area.inline.Image;
import org.apache.fop.area.inline.InlineArea;
import org.apache.fop.area.inline.Viewport;
import org.apache.fop.fo.flow.ExternalGraphic;
import org.apache.fop.fo.properties.CommonBorderAndPadding;
import org.apache.fop.fo.properties.CommonBackground;

/**
* LayoutManager for the fo:external-graphic formatting object
*/
public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {

ExternalGraphic graphic = null;

/**
* Constructor
*
* @param node the fo:external-graphic formatting object that creates the area
*/
public ExternalGraphicLayoutManager(ExternalGraphic node) {
super(node);

graphic = node;
InlineArea area = getExternalGraphicInlineArea();
setCurrentArea(area);
setAlignment(graphic.getProperty(PR_VERTICAL_ALIGN).getEnum());
setLead(graphic.getViewHeight());
}

/**
* Get the inline area for this external grpahic.
* This creates the image area and puts it inside a viewport.
*
* @return the viewport containing the image area
*/
public InlineArea getExternalGraphicInlineArea() {
Image imArea = new Image(graphic.getURL());
Viewport vp = new Viewport(imArea);
vp.setWidth(graphic.getViewWidth());
vp.setHeight(graphic.getViewHeight());
vp.setClip(graphic.getClip());
vp.setContentPosition(graphic.getPlacement());
vp.setOffset(0);

// Common Border, Padding, and Background Properties
CommonBorderAndPadding bap = graphic.getPropertyManager().getBorderAndPadding();
CommonBackground bProps = graphic.getPropertyManager().getBackgroundProps();
TraitSetter.addBorders(vp, bap);
TraitSetter.addBackground(vp, bProps);

return vp;
}
}


+ 1
- 3
src/java/org/apache/fop/layoutmgr/PageNumberCitationLayoutManager.java Dosyayı Görüntüle

@@ -39,9 +39,7 @@ public class PageNumberCitationLayoutManager extends LeafNodeLayoutManager {
* Constructor
*
* @param node the formatting object that creates this area
* @todo better null checking of node, font
* @todo see if cleaner way to remove redundant pncNode variable (already
* being stored as an FObj in base class)
* @todo better null checking font
*/
public PageNumberCitationLayoutManager(PageNumberCitation node) {
super(node);

+ 1
- 1
src/java/org/apache/fop/layoutmgr/PageNumberLayoutManager.java Dosyayı Görüntüle

@@ -25,7 +25,7 @@ import org.apache.fop.area.Trait;
import org.apache.fop.fonts.Font;

/**
* LayoutManager for the fo:basic-link formatting object
* LayoutManager for the fo:page-number formatting object
*/
public class PageNumberLayoutManager extends LeafNodeLayoutManager {


Loading…
İptal
Kaydet