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, 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:

53      // FOP
54      import*;
55      import*;
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 {
122             if ( != null) {
123                 Property prop ="id");
124                 if (prop != null) {
125                     String id = prop.getString();
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,
135                                 }
136                                 throw e;
137                             }
138                         }
139                         this.marker = 0;
140                     }
142                     if (marker == 0 && area.getIDReferences() != null) {
143                         area.getIDReferences().configureID(id, area);
144                     }
145                 }  
146             }
148             area.setBackground(propMgr.getBackgroundProps());
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         }

Kumar Puppala

-----Original Message-----
From: Victor Mote [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 31, 2005 10:40 AM
Subject: RE: background-color for fo:inline

Kumar Puppala wrote:

>    The 0.20.5 does not support background-color for fo:inline 
> element. Does anyone know what I need to change in order to 
> add this functionality to
> 0.20.5 FOP. This feature is essential for our application and 
> I am planning to add this functionality. Any help in this 
> direction is greatly appreciated.

I suppose the reason this has not been done is because it is quite difficult
to do with the 0.20.5 architecture. I've probably worked with this stuff
more recently than others, and still may not be able to help, but I'll try.
There are two things that need to be done: 1) get an Area created that has
the background-color attribute set as you want it to be, 2) get that Area

For #1, look at the class layout.LineArea. You will probably need to add an
instance variable and setter for a background color (there are color
components there, but I think they are for the foreground color, i.e. the
text). LineArea's processing is stateful, so it needs to have all of these
variables set externally. You will either need to write a layout method for
the fo.flow.Inline class or update the one in fo.FObjMixed to use the
background-color setter that you created above. If there is non-text
content, you will probably need to modify the layout methods for those
classes as well (the FOP area model pushes traits to the AreaTree rather
than having them pulled by the AreaTree from the FOTree). You will need to
dig around to see where and how layout.inline.InlineArea instances are
created. I can't remember how they interact with layout.inline.WordArea
instances. In one or the other of those, perhaps both, you will need to
store the background-color and push that color to it.

For #2, it gets more fun. Getting the background-color painted on an area
for which you know the dimensions is not difficult. If an InlineArea is
actually created, or if you can get that done, your job will be easier. If
only WordAreas are created, you will need to figure out how to get the
background-color painted in the spaces between words. I don't see a method
for rendering an InlineArea, but I think that may be the kind of concept you
need to keep the WordAreas tied together. It may be useful to know that the
Renderer is also stateful, i.e. it has a conceptual cursor, and paints
things on the page where the cursor is, computing dimensions and locations
as it goes.

I think anything you do here will be a kludge. I would rather see you invest
your time in one of the three redesign efforts, but I realize that sometimes
you just need to get the job done. Good luck.

Victor Mote

Reply via email to