*/
package org.apache.fop.fo.flow;
+// XML
+import org.xml.sax.Attributes;
+
// FOP
import org.apache.fop.apps.FOPException;
import org.apache.fop.datatypes.ColorType;
fotv.serveListBlock(this);
}
+ /**
+ * @see org.apache.fop.fo.FObj#handleAttrs
+ */
+ public void handleAttrs(Attributes attlist) throws FOPException {
+ super.handleAttrs(attlist);
+
+ getFOTreeControl().getFOInputHandler().startList(this);
+ }
+
+ protected void end() {
+ super.end();
+
+ getFOTreeControl().getFOInputHandler().endList(this);
+ }
}
*/
package org.apache.fop.fo.flow;
+// XML
+import org.xml.sax.Attributes;
+
+// FOP
+import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FOTreeVisitor;
import org.apache.fop.fo.FObj;
fotv.serveListItem(this);
}
+ /**
+ * @see org.apache.fop.fo.FObj#handleAttrs
+ */
+ public void handleAttrs(Attributes attlist) throws FOPException {
+ super.handleAttrs(attlist);
+
+ getFOTreeControl().getFOInputHandler().startListItem(this);
+ }
+
+ protected void end() {
+ super.end();
+
+ getFOTreeControl().getFOInputHandler().endListItem(this);
+ }
}
*/
package org.apache.fop.fo.flow;
+// XML
+import org.xml.sax.Attributes;
+
// FOP
+import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.FOTreeVisitor;
fotv.serveListItemLabel(this);
}
+ /**
+ * @see org.apache.fop.fo.FObj#handleAttrs
+ */
+ public void handleAttrs(Attributes attlist) throws FOPException {
+ super.handleAttrs(attlist);
+
+ getFOTreeControl().getFOInputHandler().startListLabel();
+ }
+
+ protected void end() {
+ super.end();
+
+ getFOTreeControl().getFOInputHandler().endListLabel();
+ }
}
--- /dev/null
+/*
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 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 <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
+package org.apache.fop.render.rtf;
+
+//FOP
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.fo.Property;
+import org.apache.fop.fo.LengthProperty;
+import org.apache.fop.fo.PropertyList;
+
+//RTF
+import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes;
+import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListTable;
+import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfText;
+
+ /**
+ * @autor bdelacretaz, bdelacretaz@codeconsult.ch
+ * @autor Christopher Scott, scottc@westinghouse.com
+ * Portions created by Christopher Scott are Coypright (C) 2001
+ * Westinghouse Electric Company. All Rights Reserved.
+ * @autor Peter Herweg, pherweg@web.de
+ */
+
+/**
+ * Provides methods to convert list attributes to RtfAttributes.
+ */
+public class ListAttributesConverter {
+
+
+ static RtfAttributes convertAttributes(PropertyList properties)
+ throws FOPException{
+
+ RtfAttributes attrib = new RtfAttributes();
+
+ Property prop=null;
+ int iStartIndentInTwips=0;
+
+ //start-indent
+ if ((prop = properties.get("start-indent")) != null) {
+ LengthProperty lengthprop = (LengthProperty)prop;
+
+ Float f = new Float(lengthprop.getLength().getValue() / 1000f);
+ String sValue = f.toString() + "pt";
+
+ iStartIndentInTwips = (int) FoUnitsConverter.getInstance().convertToTwips(sValue);
+ } else {
+ //set default
+ iStartIndentInTwips = 360;
+ }
+ attrib.set(RtfListTable.LIST_INDENT, iStartIndentInTwips);
+
+ //end-indent
+ if ((prop = properties.get("end-indent")) != null) {
+ LengthProperty lengthprop = (LengthProperty)prop;
+
+ Float f = new Float(lengthprop.getLength().getValue() / 1000f);
+ String sValue = f.toString() + "pt";
+
+ attrib.set(RtfText.LEFT_INDENT_BODY,
+ (int) FoUnitsConverter.getInstance().convertToTwips(sValue));
+ } else {
+ if(iStartIndentInTwips >= 360) {
+ //if the start indent is greater than default, set to the start indent
+ attrib.set(RtfText.LEFT_INDENT_BODY, iStartIndentInTwips);
+ } else {
+ //else set to default
+ attrib.set(RtfText.LEFT_INDENT_BODY, 360);
+ }
+ }
+
+ /*
+ * set list table defaults
+ */
+
+ //set a simple list type
+ attrib.set(RtfListTable.LIST, "simple");
+ //set following char as tab
+ attrib.set(RtfListTable.LIST_FOLLOWING_CHAR, 0);
+
+ return attrib;
+ }
+}
\ No newline at end of file
import org.apache.fop.render.rtf.rtflib.rtfdoc.ITableAttributes;
import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfAfterContainer;
import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfBeforeContainer;
+import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfListContainer;
import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfTextrunContainer;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAfter;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfExternalGraphic;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfFile;
+import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfList;
+import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListItem;
+import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListItem.RtfListItemLabel;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTextrun;
* @see org.apache.fop.fo.FOInputHandler#startList(ListBlock)
*/
public void startList(ListBlock lb) {
+ try {
+ // create an RtfList in the current list container
+ final IRtfListContainer c = (IRtfListContainer)builderContext.getContainer(IRtfListContainer.class,true,this);
+ final RtfList newList = c.newList(ListAttributesConverter.convertAttributes(lb.properties));
+ builderContext.pushContainer(newList);
+ } catch (IOException ioe) {
+ log.error("startList: " + ioe.getMessage());
+ throw new Error(ioe.getMessage());
+ } catch (FOPException fe) {
+ log.error("startList: " + fe.getMessage());
+ throw new Error(fe.getMessage());
+ } catch (Exception e) {
+ log.error("startList: " + e.getMessage());
+ throw new Error(e.getMessage());
+ }
}
/**
* @see org.apache.fop.fo.FOInputHandler#endList(ListBlock)
*/
public void endList(ListBlock lb) {
+ builderContext.popContainer();
}
/**
* @see org.apache.fop.fo.FOInputHandler#startListItem(ListItem)
*/
public void startListItem(ListItem li) {
+ // create an RtfListItem in the current RtfList
+ try {
+ final RtfList list = (RtfList)builderContext.getContainer(RtfList.class,true,this);
+ builderContext.pushContainer(list.newListItem());
+ } catch (IOException ioe) {
+ log.error("startList: " + ioe.getMessage());
+ throw new Error(ioe.getMessage());
+ } catch (FOPException fe) {
+ log.error("startList: " + fe.getMessage());
+ throw new Error(fe.getMessage());
+ } catch (Exception e) {
+ log.error("startList: " + e.getMessage());
+ throw new Error(e.getMessage());
+ }
}
/**
* @see org.apache.fop.fo.FOInputHandler#endListItem(ListItem)
*/
public void endListItem(ListItem li) {
+ builderContext.popContainer();
}
/**
* @see org.apache.fop.fo.FOInputHandler#startListLabel()
*/
public void startListLabel() {
+ try {
+ RtfListItem item
+ = (RtfListItem)builderContext.getContainer(RtfListItem.class, true, this);
+
+ RtfListItemLabel label=item.new RtfListItemLabel(item);
+ builderContext.pushContainer(label);
+ } catch (IOException ioe) {
+ log.error("startPageNumber:" + ioe.getMessage());
+ throw new Error(ioe.getMessage());
+ } catch (Exception e) {
+ log.error("startPageNumber: " + e.getMessage());
+ throw new Error(e.getMessage());
+ }
}
/**
* @see org.apache.fop.fo.FOInputHandler#endListLabel()
*/
public void endListLabel() {
+ builderContext.popContainer();
}
/**
public RtfListTable startListTable(RtfAttributes attr)
throws IOException {
listNum++;
+ if(listTable != null) {
+ return listTable;
+ } else {
listTable = new RtfListTable(this, writer, new Integer(listNum), attr);
listTableContainer.addChild(listTable);
+ }
+
+ return listTable;
+ }
+
+ /**
+ * Get the list table.
+ * @return the RtfListTable
+ */
+ public RtfListTable getListTable() {
return listTable;
}
import java.io.Writer;
import java.io.IOException;
+import java.util.Date;
+import java.util.Random;
/**
* Model of an RTF list, which can contain RTF list items
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
* @author Christopher Scott, scottc@westinghouse.com
+ * @author Peter Herweg, pherweg@web.de
*/
public class RtfList extends RtfContainer {
private RtfListItem item;
private RtfListTable listTable;
private final boolean hasTableParent;
-
- /** list numbering style.
- * Could add more variables, for now we simply differentiate between bullets and numbering
- */
- private NumberingStyle numberingStyle;
-
- /**
- * Inner static class to handle numbering styles.
- */
- public static class NumberingStyle {
- private boolean isBulletedList = true;
-
- /**
- * accessor for isBulletedList
- * @return isBulletedList
- */
- public boolean getIsBulletedList() {
- return isBulletedList;
- }
-
- /**
- * set isBulletedList
- * @param isBL boolean value to set
- */
- public void setIsBulletedList(boolean isBL) {
- isBulletedList = isBL;
- }
- }
+ private RtfListStyle defaultListStyle;
+ private Integer listTemplateId = null;
+ private Integer listId = null;
/** Create an RTF list as a child of given container with given attributes */
RtfList(RtfContainer parent, Writer w, RtfAttributes attr) throws IOException {
super((RtfContainer)parent, w, attr);
- numberingStyle = new NumberingStyle();
+
+ //random number generator for ids
+ Date runTime = new Date();
+ Random listIdGenerator = new Random(runTime.getTime());
+ listId = new Integer(listIdGenerator.nextInt());
+ listTemplateId = new Integer(listIdGenerator.nextInt());
+
//create a new list table entry for the list
- listTable = (getRtfFile()).startListTable(attr);
- listTable.setParentList(this);
+ listTable = getRtfFile().startListTable(attr);
+ listTable.addList(this);
// find out if we are nested in a table
hasTableParent = this.getParentOfClass(RtfTable.class) != null;
}
- /**
- * Change numbering style
- * @param ns NumberingSytle to set
- */
- public void setNumberingStyle(NumberingStyle ns) {
- numberingStyle = ns;
- }
-
- /**
- * Overridden to setup the list: start a group with appropriate attributes
- * @throws IOException for I/O problems
- */
- protected void writeRtfPrefix() throws IOException {
- // pard causes word97 (and sometimes 2000 too) to crash if the list is nested in a table
- if (!hasTableParent) {
- writeControlWord("pard");
- }
-
- writeOneAttribute(RtfText.LEFT_INDENT_FIRST, attrib.getValue(RtfListTable.LIST_INDENT));
- writeOneAttribute(RtfText.LEFT_INDENT_BODY, attrib.getValue(RtfText.LEFT_INDENT_BODY));
-
- // put the whole list in a group
- writeGroupMark(true);
-
- // group for list setup info
- writeGroupMark(true);
-
- writeStarControlWord("pn");
- //Modified by Chris Scott
- //fixes second line indentation
-
- if (numberingStyle.isBulletedList) {
- // bulleted list
- writeControlWord("pnlvlblt");
- writeControlWord("ilvl0");
- writeOneAttribute(RtfListTable.LIST_NUMBER,
- (listTable.getListNumber()).toString());
- writeOneAttribute("pnindent",
- attrib.getValue(RtfListTable.LIST_INDENT));
- writeControlWord("pnf1");
- writeGroupMark(true);
- writeControlWord("pndec");
- writeOneAttribute(RtfListTable.LIST_FONT_TYPE, "2");
- writeControlWord("pntxtb");
- writeControlWord("'b7");
- writeGroupMark(false);
- } else {
- // numbered list
- writeControlWord("pnlvlbody");
- writeControlWord("ilvl0");
- writeOneAttribute(RtfListTable.LIST_NUMBER,
- (numberingStyle.isBulletedList) ? "2" : "0");
- writeControlWord("pndec");
- writeOneAttribute("pnstart",
- attrib.getValue(RtfListTable.LIST_START_AT));
- writeOneAttribute("pnindent",
- attrib.getValue(RtfListTable.LIST_INDENT));
- writeControlWord("pntxta.");
- }
-
- writeGroupMark(false);
- writeOneAttribute(RtfListTable.LIST_NUMBER,
- (listTable.getListNumber()).toString());
- }
-
- /**
- * End the list group
- * @throws IOException for I/O problems
- */
- protected void writeRtfSuffix() throws IOException {
- // close group that encloses the whole list
- writeGroupMark(false);
-
- /* reset paragraph defaults to make sure list ends
- * but pard causes word97 (and sometimes 2000 too) to crash if the list
- * is nested in a table
- */
- if (!hasTableParent) {
- writeControlWord("pard");
- }
- }
-
/**
* Close current list item and start a new one
* @return new RtfListItem
return item;
}
+ public Integer getListId() {
+ return listId;
+ }
+
+ public Integer getListTemplateId() {
+ return listTemplateId;
+ }
+
+ /**
+ * Change list style
+ * @param ls ListStyle to set
+ */
+ public void setRtfListStyle(RtfListStyle ls) {
+ defaultListStyle = ls;
+ }
+
/**
- * @return true if this is a bulleted list (as opposed to numbered list)
+ * Get list style
+ * @return ListSytle of the List
*/
- public boolean isBulletedList() {
- return numberingStyle.isBulletedList;
+ public RtfListStyle getRtfListStyle() {
+ return defaultListStyle;
+ }
+
+ public boolean getHasTableParent() {
+ return hasTableParent;
}
}
\ No newline at end of file
import java.io.Writer;
import java.io.IOException;
+import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTextrun;
/** Model of an RTF list item, which can contain RTF paragraphs
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
*/
public class RtfListItem
extends RtfContainer
-implements IRtfParagraphContainer {
+implements IRtfTextrunContainer,
+ IRtfListContainer,
+ IRtfParagraphContainer {
+
private RtfList parentList;
private RtfParagraph paragraph;
+ private RtfListStyle listStyle;
+ private int number=0;
/** special RtfParagraph that writes list item setup code before its content */
private class RtfListItemParagraph extends RtfParagraph {
protected void writeRtfPrefix() throws IOException {
super.writeRtfPrefix();
- // for bulleted list, add list item setup group before paragraph contents
- if (parentList.isBulletedList()) {
- writeGroupMark(true);
- writeControlWord("pntext");
- writeControlWord("f" + RtfFontManager.getInstance().getFontNumber("Symbol"));
- writeControlWord("'b7");
- writeControlWord("tab");
- writeGroupMark(false);
- } else {
- writeGroupMark(true);
- writeControlWord("pntext");
- writeGroupMark(false);
+ listStyle.writeParagraphPrefix(this);
+ }
}
+
+ public class RtfListItemLabel extends RtfTextrun implements IRtfTextrunContainer {
+ RtfListItem rtfListItem;
+
+ public RtfListItemLabel(RtfListItem item) throws IOException {
+ super(null, item.writer, null);
+
+ rtfListItem=item;
}
+ public RtfTextrun getTextrun() throws IOException {
+ return this;
+ }
+
+ public void addString(String s) throws IOException {
+
+ final String label = s.trim();
+ if(label.length() > 0 && Character.isDigit(label.charAt(0))) {
+ rtfListItem.setRtfListStyle(new RtfListStyleNumber());
+ } else {
+ rtfListItem.setRtfListStyle(new RtfListStyleText(label));
+ }
+ }
}
/** Create an RTF list item as a child of given container with default attributes */
parentList = parent;
}
- /** Create an RTF list item as a child of given container with given attributes */
- RtfListItem(RtfList parent, Writer w, RtfAttributes attr) throws IOException {
- super((RtfContainer)parent, w, attr);
- parentList = parent;
- }
-
/**
* Close current paragraph if any and start a new one
* @param attrs attributes of new paragraph
return newParagraph(null);
}
+ /** Create an RTF list item as a child of given container with given attributes */
+ RtfListItem(RtfList parent, Writer w, RtfAttributes attr) throws IOException {
+ super((RtfContainer)parent, w, attr);
+ parentList = parent;
+ }
+
+ public RtfTextrun getTextrun()
+ throws IOException {
+ RtfTextrun textrun=RtfTextrun.getTextrun(this, writer, null);
+ textrun.setRtfListItem(this);
+ return textrun;
+ }
+
+ /**
+ * Start a new list after closing current paragraph, list and table
+ * @param attrs attributes of new RftList object
+ * @return new RtfList
+ * @throws IOException for I/O problems
+ */
+ public RtfList newList(RtfAttributes attrs) throws IOException {
+ RtfList list = new RtfList(this, writer, attrs);
+ return list;
+ }
+
+ /**
+ * Overridden to setup the list: start a group with appropriate attributes
+ * @throws IOException for I/O problems
+ */
+ protected void writeRtfPrefix() throws IOException {
+
+ // pard causes word97 (and sometimes 2000 too) to crash if the list is nested in a table
+ if (!parentList.getHasTableParent()) {
+ writeControlWord("pard");
+ }
+
+ writeOneAttribute(RtfText.LEFT_INDENT_FIRST, attrib.getValue(RtfListTable.LIST_INDENT));
+ writeOneAttribute(RtfText.LEFT_INDENT_BODY, attrib.getValue(RtfText.LEFT_INDENT_BODY));
+
+ // group for list setup info
+ writeGroupMark(true);
+
+ writeStarControlWord("pn");
+ //Modified by Chris Scott
+ //fixes second line indentation
+ getRtfListStyle().writeListPrefix(this);
+
+ writeGroupMark(false);
+ writeOneAttribute(RtfListTable.LIST_NUMBER,new Integer(number));
+ }
+
+ /**
+ * End the list group
+ * @throws IOException for I/O problems
+ */
+ protected void writeRtfSuffix() throws IOException {
+ super.writeRtfSuffix();
+
+ /* reset paragraph defaults to make sure list ends
+ * but pard causes word97 (and sometimes 2000 too) to crash if the list
+ * is nested in a table
+ */
+ if (!parentList.getHasTableParent()) {
+ writeControlWord("pard");
+ }
+
+ }
+
+ /**
+ * Change list style
+ * @param ls ListStyle to set
+ */
+ public void setRtfListStyle(RtfListStyle ls) {
+ listStyle = ls;
+
+ listStyle.setRtfListItem(this);
+ number = getRtfFile().getListTable().addRtfListStyle(ls);
+ }
+
+ /**
+ * Get list style
+ * @return ListSytle of the List
+ */
+ public RtfListStyle getRtfListStyle() {
+ if(listStyle==null) {
+ return parentList.getRtfListStyle();
+ } else {
+ return listStyle;
+ }
+ }
+
+ public RtfList getParentList() {
+ return parentList;
+ }
+
+ public int getNumber() {
+ return number;
+ }
}
--- /dev/null
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 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 <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
+
+/*
+ * This file is part of the RTF library of the FOP project, which was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other
+ * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
+ * the FOP project.
+ */
+package org.apache.fop.render.rtf.rtflib.rtfdoc;
+
+//Java
+import java.io.IOException;
+
+//FOP
+import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement;
+
+/**
+ * Class to handle list styles.
+ */
+public class RtfListStyle {
+ private RtfListItem rtfListItem;
+
+ public void setRtfListItem(RtfListItem item) {
+ rtfListItem=item;
+ }
+
+ public RtfListItem getRtfListItem() {
+ return rtfListItem;
+ }
+
+ public RtfList getRtfList() {
+ return rtfListItem.getParentList();
+ }
+
+ /**
+ * Gets call before a RtfListItem has to be written.
+ */
+ public void writeListPrefix(RtfListItem item)
+ throws IOException {
+ }
+ /**
+ * Gets call before a paragraph, which is contained by a RtfListItem has to be written.
+ */
+ public void writeParagraphPrefix(RtfElement element)
+ throws IOException {
+ }
+
+ /**
+ * Gets call when the list table has to be written.
+ */
+ public void writeLevelGroup(RtfElement element)
+ throws IOException {
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 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 <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
+
+/*
+ * This file is part of the RTF library of the FOP project, which was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other
+ * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
+ * the FOP project.
+ */
+package org.apache.fop.render.rtf.rtflib.rtfdoc;
+
+//Java
+import java.io.IOException;
+
+//FOP
+import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement;
+
+public class RtfListStyleBullet extends RtfListStyle {
+
+ /**
+ * Gets call before a RtfListItem has to be written.
+ *
+ * @see org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListStyle#writeListPrefix()
+ */
+ public void writeListPrefix(RtfListItem item) throws IOException {
+ // bulleted list
+ item.writeControlWord("pnlvlblt");
+ item.writeControlWord("ilvl0");
+ item.writeOneAttribute(RtfListTable.LIST_NUMBER, new Integer(item.getNumber()));
+ item.writeOneAttribute("pnindent",
+ item.getParentList().attrib.getValue(RtfListTable.LIST_INDENT));
+ item.writeControlWord("pnf1");
+ item.writeGroupMark(true);
+ item.writeControlWord("pndec");
+ item.writeOneAttribute(RtfListTable.LIST_FONT_TYPE, "2");
+ item.writeControlWord("pntxtb");
+ item.writeControlWord("'b7");
+ item.writeGroupMark(false);
+ }
+
+ /**
+ * Gets call before a paragraph, which is contained by a RtfListItem has to be written.
+ *
+ * @see org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListStyle#writeParagraphPrefix()
+ */
+ public void writeParagraphPrefix(RtfElement element) throws IOException {
+ element.writeGroupMark(true);
+ element.writeControlWord("pntext");
+ element.writeGroupMark(false);
+ }
+
+ /**
+ * Gets call when the list table has to be written.
+ *
+ * @see org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListStyle#writeLevelGroup()
+ */
+ public void writeLevelGroup(RtfElement element) throws IOException {
+ element.attrib.set(RtfListTable.LIST_NUMBER_TYPE, 23);
+ element.writeGroupMark(true);
+ element.writeOneAttributeNS(RtfListTable.LIST_TEXT_FORM, "\\'01\\'b7");
+ element.writeGroupMark(false);
+
+ element.writeGroupMark(true);
+ element.writeOneAttributeNS(RtfListTable.LIST_NUM_POSITION, null);
+ element.writeGroupMark(false);
+
+ element.attrib.set(RtfListTable.LIST_FONT_TYPE, 2);
+ }
+
+}
--- /dev/null
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 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 <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
+
+/*
+ * This file is part of the RTF library of the FOP project, which was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other
+ * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
+ * the FOP project.
+ */
+package org.apache.fop.render.rtf.rtflib.rtfdoc;
+
+//Java
+import java.io.IOException;
+
+//FOP
+import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement;
+
+public class RtfListStyleNumber extends RtfListStyle {
+
+ /**
+ * Gets call before a RtfListItem has to be written.
+ *
+ * @see org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListStyle#writeListPrefix()
+ */
+ public void writeListPrefix(RtfList list)
+ throws IOException {
+ list.writeControlWord("pnlvlbody");
+ list.writeControlWord("ilvl0");
+ list.writeOneAttribute(RtfListTable.LIST_NUMBER, "0");
+ list.writeControlWord("pndec");
+ list.writeOneAttribute("pnstart", new Integer(1));
+ list.writeOneAttribute("pnindent",
+ list.attrib.getValue(RtfListTable.LIST_INDENT));
+ list.writeControlWord("pntxta.");
+ }
+
+ /**
+ * Gets call before a paragraph, which is contained by a RtfListItem has to be written.
+ *
+ * @see org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListStyle#writeParagraphPrefix()
+ */
+ public void writeParagraphPrefix(RtfElement element)
+ throws IOException {
+ element.writeGroupMark(true);
+ element.writeControlWord("pntext");
+ element.writeControlWord("f" + RtfFontManager.getInstance().getFontNumber("Symbol"));
+ element.writeControlWord("'b7");
+ element.writeControlWord("tab");
+ element.writeGroupMark(false);
+ }
+
+ /**
+ * Gets call when the list table has to be written.
+ *
+ * @see org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListStyle#writeLevelGroup()
+ */
+ public void writeLevelGroup(RtfElement element)
+ throws IOException {
+ element.writeOneAttributeNS(
+ RtfListTable.LIST_START_AT, new Integer(1));
+ element.attrib.set(RtfListTable.LIST_NUMBER_TYPE, 0);
+
+ element.writeGroupMark(true);
+ element.writeOneAttributeNS(
+ RtfListTable.LIST_TEXT_FORM, "\\'03\\\'00. ;");
+ element.writeGroupMark(false);
+
+ element.writeGroupMark(true);
+ element.writeOneAttributeNS(
+ RtfListTable.LIST_NUM_POSITION, "\\'01;");
+ element.writeGroupMark(false);
+
+ element.writeOneAttribute(RtfListTable.LIST_FONT_TYPE, new Integer(0));
+ }
+}
--- /dev/null
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 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 <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
+
+/*
+ * This file is part of the RTF library of the FOP project, which was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other
+ * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
+ * the FOP project.
+ */
+package org.apache.fop.render.rtf.rtflib.rtfdoc;
+
+//Java
+import java.io.IOException;
+
+//FOP
+import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement;
+
+public class RtfListStyleText extends RtfListStyle {
+ String text;
+
+ public RtfListStyleText(String s) {
+ text=s;
+ }
+
+ /**
+ * Gets call before a RtfListItem has to be written.
+ *
+ * @see org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListStyle#writeListPrefix()
+ */
+ public void writeListPrefix(RtfListItem item)
+ throws IOException {
+ // bulleted list
+ item.writeControlWord("pnlvlblt");
+ item.writeControlWord("ilvl0");
+ item.writeOneAttribute(RtfListTable.LIST_NUMBER, new Integer(item.getNumber()));
+ item.writeOneAttribute("pnindent",
+ item.getParentList().attrib.getValue(RtfListTable.LIST_INDENT));
+ item.writeControlWord("pnf1");
+ item.writeGroupMark(true);
+ item.writeControlWord("pndec");
+ item.writeOneAttribute(RtfListTable.LIST_FONT_TYPE, "2");
+ item.writeControlWord("pntxtb " + text);
+ item.writeGroupMark(false);
+ }
+
+ /**
+ * Gets call before a paragraph, which is contained by a RtfListItem has to be written.
+ *
+ * @see org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListStyle#writeParagraphPrefix()
+ */
+ public void writeParagraphPrefix(RtfElement element)
+ throws IOException {
+ element.writeGroupMark(true);
+ element.writeControlWord("pntext");
+ element.writeGroupMark(false);
+ }
+
+ /**
+ * Gets call when the list table has to be written.
+ *
+ * @see org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListStyle#writeLevelGroup()
+ */
+ public void writeLevelGroup(RtfElement element)
+ throws IOException {
+ element.attrib.set(RtfListTable.LIST_NUMBER_TYPE, 23);
+ element.writeGroupMark(true);
+
+ String sCount;
+ if(text.length()<10) {
+ sCount = "0" + String.valueOf(text.length());
+ } else {
+ sCount = String.valueOf(text.length());
+ }
+ element.writeOneAttributeNS(
+ RtfListTable.LIST_TEXT_FORM, "\\'" + sCount + text);
+ element.writeGroupMark(false);
+
+ element.writeGroupMark(true);
+ element.writeOneAttributeNS(RtfListTable.LIST_NUM_POSITION, null);
+ element.writeGroupMark(false);
+
+ element.attrib.set(RtfListTable.LIST_FONT_TYPE, 2);
+ }
+}
package org.apache.fop.render.rtf.rtflib.rtfdoc;
-import java.util.Date;
-import java.util.Random;
+import java.util.LinkedList;
+import java.util.Iterator;
+import java.util.LinkedList;
import java.io.Writer;
import java.io.IOException;
//import org.apache.fop.render.rtf.rtflib.jfor.main.JForVersionInfo;
* @author Christopher Scott, scottc@westinghouse.com
*/
public class RtfListTable extends RtfContainer {
+ private LinkedList lists;
+ private LinkedList styles;
- /** number of list in document */
- private Integer listNum;
- /** id of list */
- private Integer listId;
- private Integer listTemplateId;
- private RtfList parentList;
//static data members
/** constant for a list table */
public static final String LIST_TABLE = "listtable";
public RtfListTable(RtfContainer parent, Writer w, Integer num, RtfAttributes attrs)
throws IOException {
super(parent, w, attrs);
- listNum = new Integer(num.intValue());
- //random number generator for ids
- Date runTime = new Date();
- Random listIdGenerator = new Random(runTime.getTime());
- listId = new Integer(listIdGenerator.nextInt());
- attrib.set(LIST_ID, listId.toString());
- listTemplateId = new Integer(listIdGenerator.nextInt());
- attrib.set(LIST_NUMBER_TYPE, 0);
- }
- /**
- * Set parentList
- * @param parent parentList to set
- */
- public void setParentList(RtfList parent) {
- parentList = parent;
+ styles=new LinkedList();
}
/**
- * Accessor for listNum
- * @return listNum
+ * Add List
+ * @param list RtfList to add
*/
- public Integer getListNumber() {
- return listNum;
- }
-
- /** Set whether the list is a bulleted list not, and set attributes
- * accordingly */
- private void setListType() {
- if (parentList.isBulletedList()) {
- // bullet definition for bulleted lists
- // Chris Scott's version was "\\\'01\\u-3913 ?;"
- // 'b7 is what was used in jfor V0.5.2
- attrib.set(LIST_TEXT_FORM, "\\\'01\\'b7 ?;");
- attrib.set(LIST_NUM_POSITION);
- attrib.set(LIST_NUMBER_TYPE, 23);
- attrib.set(LIST_FONT_TYPE, 2);
- } else {
- attrib.set(LIST_TEXT_FORM, "\\\'03\\\'00. ;");
- attrib.set(LIST_NUM_POSITION, "\\\'01;");
- attrib.set(LIST_NUMBER_TYPE, 0);
- attrib.set(LIST_FONT_TYPE, 0);
+ public int addList(RtfList list) {
+ if(lists == null) {
+ lists=new LinkedList();
}
+
+ lists.add(list);
+
+ return lists.size();
}
/**
* @throws IOException for I/O problems
*/
public void writeRtfContent() throws IOException {
- setListType();
+ if(lists!=null) {
+ //write '\listtable'
writeGroupMark(true);
writeStarControlWordNS(LIST_TABLE);
+ for (Iterator it = lists.iterator(); it.hasNext();) {
+ final RtfList list = (RtfList)it.next();
+ writeListTableEntry(list);
+ }
+ writeGroupMark(false);
+
+ //write '\listoveridetable'
writeGroupMark(true);
+ writeStarControlWordNS(LIST_OVR_TABLE);
+ int z=1;
+
+ for (Iterator it = styles.iterator(); it.hasNext();) {
+ final RtfListStyle style = (RtfListStyle)it.next();
+
+ writeGroupMark(true);
+ writeStarControlWordNS(LIST_OVR);
+ writeGroupMark(true);
+
+ writeOneAttributeNS(LIST_ID, style.getRtfList().getListId().toString());
+ writeOneAttributeNS(LIST_OVR_COUNT, new Integer(0));
+ writeOneAttributeNS(LIST_NUMBER, new Integer(z++));
+
+ writeGroupMark(false);
+ writeGroupMark(false);
+ }
+
+ writeGroupMark(false);
+ }
+ }
+ /**
+ * Since this has no text content we have to overwrite isEmpty to print
+ * the table
+ * @return false (always)
+ */
+ public boolean isEmpty() {
+ return false;
+ }
+
+ private void writeListTableEntry(RtfList list)
+ throws IOException {
+ //write list-specific attributes
+ writeGroupMark(true);
writeControlWordNS(LIST);
- writeOneAttributeNS(LIST_TEMPLATE_ID, listTemplateId.toString());
+ writeOneAttributeNS(LIST_TEMPLATE_ID, list.getListTemplateId().toString());
writeOneAttributeNS(LIST, attrib.getValue(LIST));
+
+ // write level-specific attributes
writeGroupMark(true);
writeControlWordNS(LIST_LEVEL);
- writeOneAttributeNS(LIST_NUMBER_TYPE, attrib.getValue(LIST_NUMBER_TYPE));
+
writeOneAttributeNS(LIST_JUSTIFICATION, attrib.getValue(LIST_JUSTIFICATION));
writeOneAttributeNS(LIST_FOLLOWING_CHAR, attrib.getValue(LIST_FOLLOWING_CHAR));
- writeOneAttributeNS(LIST_START_AT, attrib.getValue(LIST_START_AT));
writeOneAttributeNS(LIST_SPACE, new Integer(0));
writeOneAttributeNS(LIST_INDENT, attrib.getValue(LIST_INDENT));
- writeGroupMark(true);
- writeOneAttributeNS(LIST_TEXT_FORM, attrib.getValue(LIST_TEXT_FORM));
- writeGroupMark(false);
- writeGroupMark(true);
- writeOneAttributeNS(LIST_NUM_POSITION, attrib.getValue(LIST_NUM_POSITION));
- writeGroupMark(false);
- writeOneAttributeNS(LIST_FONT_TYPE, attrib.getValue(LIST_FONT_TYPE));
+
+ RtfListItem item=(RtfListItem)list.getChildren().get(0);
+ item.getRtfListStyle().writeLevelGroup(this);
+
writeGroupMark(false);
+
writeGroupMark(true);
writeControlWordNS(LIST_NAME);
writeGroupMark(false);
- writeOneAttributeNS(LIST_ID, listId.toString());
- writeGroupMark(false);
- writeGroupMark(false);
- writeGroupMark(true);
- writeStarControlWordNS(LIST_OVR_TABLE);
- writeGroupMark(true);
- writeControlWordNS(LIST_OVR);
- writeOneAttributeNS(LIST_ID, listId.toString());
- writeOneAttributeNS(LIST_OVR_COUNT, new Integer(0));
- writeOneAttributeNS(LIST_NUMBER, listNum.toString());
- writeGroupMark(false);
+
+ writeOneAttributeNS(LIST_ID, list.getListId().toString());
+
writeGroupMark(false);
}
/**
- * Since this has no text content we have to overwrite isEmpty to print
- * the table
- * @return false (always)
+ * Change list style
+ * @param ls ListStyle to set
*/
- public boolean isEmpty() {
- return false;
+ public int addRtfListStyle(RtfListStyle ls) {
+ styles.add(ls);
+ return styles.size();
}
-
-
}
\ No newline at end of file
package org.apache.fop.render.rtf.rtflib.rtfdoc;
+// Java
import java.io.IOException;
import java.io.Writer;
import java.util.List;
import java.util.Iterator;
+
+// FOP
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfExternalGraphic;
+import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfList;
/**
* Class which contains a linear text run. It has methods to add attributes,
*/
public class RtfTextrun extends RtfContainer {
private boolean bSuppressLastPar = false;
+ private RtfListItem rtfListItem;
/** Class which represents the opening of a RTF group mark.*/
private class RtfOpenGroupMark extends RtfElement {
//may contain for example \intbl
writeAttributes(attrib, null);
+ if(rtfListItem!=null) {
+ rtfListItem.getRtfListStyle().writeParagraphPrefix(this);
+ }
+
//write all children
boolean bPrevPar = false;
boolean bFirst = true;
if (!bHide) {
e.writeRtf();
+
+ if (rtfListItem!=null && e instanceof RtfParagraphBreak) {
+ rtfListItem.getRtfListStyle().writeParagraphPrefix(this);
+ }
}
if (e instanceof RtfParagraphBreak) {
}
}
}
+
+ public void setRtfListItem(RtfListItem listItem) {
+ rtfListItem=listItem;
+ }
+
+ public RtfListItem getRtfListItem() {
+ return rtfListItem;
+ }
}
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfList;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListItem;
+import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListStyle;
+import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListStyleNumber;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph;
/** Generates a simple RTF test document for the jfor rtflib package.
sect.newParagraph().newText("Normal paragraph after list 2.");
sect.newParagraph().newText("Now a numbered list (4 items):");
- final RtfList.NumberingStyle nn = new RtfList.NumberingStyle();
- nn.setIsBulletedList(false);
- makeList(sect, 3, 4, nn);
+ makeList(sect, 3, 4, new RtfListStyleNumber());
}
- private void makeList(RtfSection sect, int listIndex, int nItems, RtfList.NumberingStyle ns)
+ private void makeList(RtfSection sect, int listIndex, int nItems, RtfListStyle ls)
throws IOException {
final RtfList list = sect.newList(null);
- if (ns != null) {
- list.setNumberingStyle(ns);
+ if (ls != null) {
+ list.setRtfListStyle(ls);
}
for (int i = 0; i < nItems; i++) {
final RtfListItem item = list.newListItem();