CVS: jfor/src/org/jfor/jfor/rtflib/rtfdoc RtfJforCmd.java,1.2,1.3 ParagraphKeeptogetherContext.java,NONE,1.1 IRtfJforCmdContainer.java,1.2,1.3 RtfSection.java,1.10,1.11

Marra Roberto <[email protected]> Mon, 23 Sep 2002 06:14:31 -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-serv10373

Modified Files:
	RtfSection.java 
Added Files:
	RtfJforCmd.java ParagraphKeeptogetherContext.java 
	IRtfJforCmdContainer.java 
Log Message:
added jfor-cmd processing


--- NEW FILE: ParagraphKeeptogetherContext.java ---
package org.jfor.jfor.rtflib.rtfdoc;

/*-----------------------------------------------------------------------------
 * jfor - Open-Source XSL-FO to RTF converter - see www.jfor.org
 *
 * ====================================================================
 * jfor Apache-Style Software License.
 * Copyright (c) 2002 by the jfor project. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, 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 jfor project (http://www.jfor.org)."
 * Alternately, this acknowledgment may appear in the software itself,
 * if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The name "jfor" must not be used to endorse
 * or promote products derived from this software without prior written
 * permission.  For written permission, please contact [email protected].
 *
 * 5. Products derived from this software may not be called "jfor",
 * nor may "jfor" appear in their name, without prior written
 * permission of [email protected].
 *
 * 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 JFOR PROJECT OR ITS CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, 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.
 * ====================================================================
 * Contributor(s):
-----------------------------------------------------------------------------*/

/** 
 *	
 * 	This context is used to manage the "keepn" RTF attribute
 *  Used by ParagraphBuilder and JforCmd 
 *
 */

public class ParagraphKeeptogetherContext {

    private static int m_paraKeepTogetherOpen=0;
    private static boolean m_paraResetProperties=false;
	private static ParagraphKeeptogetherContext m_instance = null;
	
	ParagraphKeeptogetherContext() {
	}
	
	
	/**
	 * Singelton.
	 *
	 * @return The instance of ParagraphKeeptogetherContext
	 */
	public static ParagraphKeeptogetherContext getInstance() {
		if (m_instance==null) m_instance = new 	ParagraphKeeptogetherContext();
		return m_instance;
	}
	
	/** Return the level of current "keep whith next" paragraph */
	public static int getKeepTogetherOpenValue() {
		return m_paraKeepTogetherOpen;
	}

	/** Open a new "keep whith next" paragraph */
	public static void KeepTogetherOpen() {
		m_paraKeepTogetherOpen++;	
	}

	/** Close a "keep whith next" paragraph */
	public static void KeepTogetherClose() {
		if(m_paraKeepTogetherOpen > 0) {
			m_paraKeepTogetherOpen--;
			
			//If the \pard control word is not present, the current paragraph inherits all paragraph properties. 
			//Also the next paragraph must reset the properties otherwise the \keepn don't stop.
			m_paraResetProperties= (m_paraKeepTogetherOpen==0);
		}
	}
	
	/** Determine if the next paragraph must reset the properites */
	public static boolean paragraphResetProperties() {
		return m_paraResetProperties;	
	}
	
	/** Reset the flag if the paragraph properties have been resested */
	public static void setParagraphResetPropertiesUsed() {
		m_paraResetProperties=false;
	}
	
}


Index: RtfSection.java
===================================================================
RCS file: /cvsroot/jfor/jfor/src/org/jfor/jfor/rtflib/rtfdoc/RtfSection.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** RtfSection.java	12 Aug 2002 09:40:03 -0000	1.10
--- RtfSection.java	23 Sep 2002 13:14:28 -0000	1.11
***************
*** 64,67 ****
--- 64,70 ----
  // $Id$
  // $Log$
+ // Revision 1.11  2002/09/23 13:14:28  rmarra
+ // added jfor-cmd processing
+ //
  // Revision 1.10  2002/08/12 09:40:03  bdelacretaz
  // V0.7.1dev-e, contributions from Boris Poudérous for number-columns-spanned
***************
*** 115,119 ****
      IRtfBeforeContainer,
      IRtfParagraphKeepTogetherContainer,
!     IRtfAfterContainer
  {
  	private RtfParagraph m_paragraph;
--- 118,123 ----
      IRtfBeforeContainer,
      IRtfParagraphKeepTogetherContainer,
!     IRtfAfterContainer,
!     IRtfJforCmdContainer
  {
  	private RtfParagraph m_paragraph;
***************
*** 123,126 ****
--- 127,131 ----
  	private RtfBefore m_before;
      private RtfAfter m_after;
+     private RtfJforCmd m_jforCmd;
  
  	/** Create an RTF container as a child of given container */
***************
*** 185,189 ****
  		return m_before;
  	}
! 
      /** IRtfAfterContainer */
  	public RtfAfter newAfter(RtfAttributes attrs) throws IOException {
--- 190,194 ----
  		return m_before;
  	}
! 	
      /** IRtfAfterContainer */
  	public RtfAfter newAfter(RtfAttributes attrs) throws IOException {
***************
*** 192,195 ****
--- 197,208 ----
  		return m_after;
  	}
+ 
+ 
+ 	public RtfJforCmd newJforCmd(RtfAttributes attrs) throws IOException {
+ 		m_jforCmd  = new RtfJforCmd(this,m_writer,attrs);
+ 		return m_jforCmd;
+ 	}
+ 
+ 
  
  	/** can be overridden to write RTF prefix code, what comes before our children */



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf