Kumar Puppala wrote:
> Victor,
> Thanks for your input. I changed the code to provide
> background-color for fo:inline but this is not completely
> accurate. I have added 'layout' method to Inline.java, which
> is very similar to its parent but the only difference being
> that its sets the background color property. This is not the
> cleanest way since it does provide color for that entire area
> (like the one applied on fo:block) but atleast it provides
> something. I have provided the code changes below. Let me
> know incase you see any gaping holes with these changes. The
> code changes are:
>
> fop/fop-0.20.5/src/org/apache/fop/fo/flow/Inline.java:
> 53 // FOP
> 54 import org.apache.fop.fo.*;
> 55 import org.apache.fop.fo.properties.*;
> 56 import org.apache.fop.layout.*;
> 57 import org.apache.fop.apps.FOPException;
>
>
> 119 // Overriding the base class implementation for layout.
> 120 public int layout(Area area) throws FOPException {
> 121
> 122 if (this.properties != null) {
> 123 Property prop = this.properties.get("id");
> 124 if (prop != null) {
> 125 String id = prop.getString();
> 126
> 127 if (this.marker == START) {
> 128 if (area.getIDReferences() != null) {
> 129 try {
> 130
> area.getIDReferences().createID(id);
> 131 }
> 132 catch(FOPException e) {
> 133 if (!e.isLocationSet()) {
> 134 e.setLocation(systemId, line,
> column);
> 135 }
> 136 throw e;
> 137 }
> 138 }
> 139 this.marker = 0;
> 140 }
> 141
> 142 if (marker == 0 &&
> area.getIDReferences() != null) {
> 143
> area.getIDReferences().configureID(id, area);
> 144 }
> 145 }
> 146 }
> 147
> 148 area.setBackground(propMgr.getBackgroundProps());
^^^^
OK. Here is what you are complaining about. You are setting the background
properties on the *parent* area, which is probably a block-area. Normally,
what should happen here is a *new* Area is created and that is then used
below for the layout of each of the child FOs. Those children are probably
other inline areas or text nodes, which are getting laid out eventually in
LineArea. What is needed is an Area that is smaller than the BlockArea, but
larger than the WordArea. LineArea doesn't work because it doesn't
correspond to any FO. InlineArea is an abstraction of the more atomic inline
areas, and does not correspond to an actual area. To get what you want, I
think you'll have to either:
1) Create a new Area class to hold the areas generated by the child FOs.
This will be complicated because you need to deal with line breaks that come
in the middle, and maintaining state as lines and pages are created.
2) Assign the attribute to each of the child Areas that is created. I don't
see a straightforward way to do this, and then you still have to figure out
a way to get the Renderer to deal with spaces between them.
Either way it is not pretty. You can probably see why all of this is being
rewritten :-). Perhaps one of the other developers will see some alternative
that I do not.
> 149
> 150 int numChildren = this.children.size();
> 151 for (int i = this.marker; i < numChildren; i++) {
> 152 FONode fo = (FONode)children.get(i);
> 153 int status = fo.layout(area);
> 154 if (Status.isIncomplete(status)) {
> 155 this.marker = i;
> 156 return status;
> 157 }
> 158 }
> 159 return Status.OK;
> 160 }
Victor Mote