CVS: jfor/src/org/jfor/jfor/rtflib/rtfdoc RtfTableRowKeepWith.java,NONE,1.1 RtfParagraphKeepWithNext.java,NONE,1.1
Marra Roberto <[email protected]> Tue, 25 Jun 2002 06:23:38 -0700
| Newsgroups | gmane.text.xml.jfor.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/jfor/jfor/src/org/jfor/jfor/rtflib/rtfdoc In directory usw-pr-cvs1:/tmp/cvs-serv24835 Added Files: RtfTableRowKeepWith.java RtfParagraphKeepWithNext.java Log Message: initial check-in --- NEW FILE: RtfTableRowKeepWith.java --- package org.jfor.jfor.rtflib.rtfdoc; import java.io.*; import java.util.*; /*----------------------------------------------------------------------------- * jfor - Open-Source XSL-FO to RTF converter - see www.jfor.org * * The contents of this file are subject to the Mozilla Public * License Version 1.1 (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.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is the contents of this java source file, as distributed * on www.sourceforge.net/projects/jfor and/or www.jfor.org. * * The Initial Developer of the Original Code is Bertrand Delacrétaz, * codeconsult, Cugy/Lausanne, Switzerland [email protected]. * Portions created by Bertrand Delacrétaz are Copyright (C) 2001 codeconsult, * Bertrand Delacrétaz. All Rights Reserved. * * Contributor(s): * @author Andreas Putz [email protected] * @author Roberto Marra [email protected] -----------------------------------------------------------------------------*/ /* * Check for keep-with-next keep-with-previous row attribute. * For forcing this row to be on the same page as next row, * a new paragraph RtfParagraphKeepWithNext is created with the "Keep paragraph with the next paragraph" attribute. * The end of the group mark (started with the paragraph) is set when a keep-with-previous is detected. * */ class RtfTableRowKeepWith extends RtfElement implements ITableAttributes { private RtfParagraphKeepWithNext m_paraKeep=null; private RtfAttributes m_attrib=null; RtfTableRowKeepWith(RtfContainer parent,Writer w,RtfAttributes attr) throws IOException { super((RtfContainer)parent,w); m_attrib = attr; m_paraKeep = new RtfParagraphKeepWithNext(parent,w); } /** called before writeRtfContent() */ protected void writeRtfPrefix() throws IOException { //ROW_KEEP_TOGETHER can't be mixed with ROW_KEEP_WITH_NEXT or ROW_KEEP_WITH_PREVIOUS //ROW_KEEP_TOGETHER (that means row cannot be split by a page break) is used when data of one row must be kept together //ROW_KEEP_WITH_NEXT and ROW_KEEP_WITH_PREVIOUS is used as ROW_KEEP_TOGETHER but for more than one row. if(m_attrib != null && m_attrib.isSet(ITableAttributes.ROW_KEEP_TOGETHER)) return; if(m_attrib != null && m_attrib.isSet(ITableAttributes.ROW_KEEP_WITH_NEXT)) { m_paraKeep.startNewParagraph(); } //Check for keep-with-previous and close the paragraph if(m_attrib != null && m_attrib.isSet(ITableAttributes.ROW_KEEP_WITH_PREVIOUS)) { m_paraKeep.closeParagraph(); } } protected void writeRtfContent() throws IOException { } public boolean isEmpty() { return false; } } --- NEW FILE: RtfParagraphKeepWithNext.java --- package org.jfor.jfor.rtflib.rtfdoc; import java.io.*; import java.util.*; /*----------------------------------------------------------------------------- * jfor - Open-Source XSL-FO to RTF converter - see www.jfor.org * * The contents of this file are subject to the Mozilla Public * License Version 1.1 (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.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is the contents of this java source file, as distributed * on www.sourceforge.net/projects/jfor and/or www.jfor.org. * * The Initial Developer of the Original Code is Bertrand Delacrétaz, * codeconsult, Cugy/Lausanne, Switzerland [email protected]. * Portions created by Bertrand Delacrétaz are Copyright (C) 2001 codeconsult, * Bertrand Delacrétaz. All Rights Reserved. * * Contributor(s): * @author Andreas Putz [email protected] * @author Roberto Marra [email protected] -----------------------------------------------------------------------------*/ /* * RtfParagraphKeepWithNext use the RTF attribute "Keep paragraph with the next paragraph". * */ public class RtfParagraphKeepWithNext extends RtfElement { private static final int STATUS_NULL = 0; private static final int STATUS_NEW_PARA = 1; private static final int STATUS_CLOSE_PARA = 2; private static boolean keepWithNextActived=false; private static int m_status = STATUS_NULL; RtfParagraphKeepWithNext(RtfContainer parent,Writer w) throws IOException { super((RtfContainer)parent,w); } /** * Return true if the paragraph is closed. */ public static boolean isParagraphClosed() { return !keepWithNextActived; } /** start a new paragraph only if the previous is closed */ public void startNewParagraph() { if (!keepWithNextActived) m_status = STATUS_NEW_PARA; } /** close the paragraph */ public void closeParagraph() { if (keepWithNextActived) m_status = STATUS_CLOSE_PARA; } protected void writeRtfContent() throws IOException { //Create a new paragraph with the attribute "Keep paragraph with the next paragraph". if (m_status == STATUS_NEW_PARA) { //System.out.println ("RtfParagraphKeepWithNext keep-with-next"); keepWithNextActived=true; writeControlWord("pard"); writeControlWord("par"); writeControlWord("keepn"); writeGroupMark(true); m_status = STATUS_NULL; } //Set the end of group mark that was started if (m_status == STATUS_CLOSE_PARA) { //System.out.println ("RtfParagraphKeepWithNext keep-with-previous"); keepWithNextActived=false; writeGroupMark(false); m_status = STATUS_NULL; } } /** * Called by RtfSection to force the correct close of the paragraph. * If no fo:keep-with-previous where found before the end of RTF document */ public void writeRtfEndParagraph() throws IOException { if(keepWithNextActived) writeGroupMark(false); keepWithNextActived=false; m_status = STATUS_NULL; } public boolean isEmpty() { return false; } } ------------------------------------------------------- Sponsored by: ThinkGeek at http://www.ThinkGeek.com/