CVS: jfor/src/org/jfor/jfor/rtflib/rtfdoc IRtfAfterContainer.java,NONE,1.1 RtfAfter.java,NONE,1.1

Bertrand Delacretaz <[email protected]> Sun, 14 Jul 2002 23:44:07 -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-serv21245/src/org/jfor/jfor/rtflib/rtfdoc

Added Files:
	IRtfAfterContainer.java RtfAfter.java 
Log Message:
footer code contributed by Andreas Lambert <[email protected]>

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

import java.io.IOException;
    
/*-----------------------------------------------------------------------------
 * 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):
 *  @author Andreas Lambert <[email protected]> 
-----------------------------------------------------------------------------*/

//------------------------------------------------------------------------------
// $Id: IRtfAfterContainer.java,v 1.1 2002/07/15 06:44:05 bdelacretaz Exp $
// $Log: IRtfAfterContainer.java,v $
// Revision 1.1  2002/07/15 06:44:05  bdelacretaz
// footer code contributed by Andreas Lambert <[email protected]>
//
//------------------------------------------------------------------------------

/** interface for RTF objects that can contain footers */    
public interface IRtfAfterContainer
{
    public RtfAfter newAfter(RtfAttributes attrs) throws IOException;
}
--- NEW FILE: RtfAfter.java ---
package org.jfor.jfor.rtflib.rtfdoc;

import java.io.Writer;
import java.io.*;
import java.util.*;
import java.io.IOException;

/*-----------------------------------------------------------------------------
 * 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):
 *  @author Andreas Lambert <[email protected]> 
-----------------------------------------------------------------------------*/

//------------------------------------------------------------------------------
// $Id: RtfAfter.java,v 1.1 2002/07/15 06:44:05 bdelacretaz Exp $
// $Log: RtfAfter.java,v $
// Revision 1.1  2002/07/15 06:44:05  bdelacretaz
// footer code contributed by Andreas Lambert <[email protected]>
//
//------------------------------------------------------------------------------

/** RtfContainer that encloses footers */
public class RtfAfter extends RtfContainer implements IRtfParagraphContainer, IRtfExternalGraphicContainer{
	private RtfAttributes m_attrib;
	private RtfParagraph m_para;
	private RtfExternalGraphic m_externalGraphic;

	/**RtfBefore attributes*/
	public final static String FOOTER = "footer";
	
	public final static String[] FOOTER_ATTR = new String[]{
		FOOTER
	};
	
	RtfAfter(RtfSection parent, Writer w, RtfAttributes attrs) throws IOException {
		super((RtfContainer)parent,w,attrs);
		m_attrib = attrs;
	}
	
	public RtfParagraph newParagraph() throws IOException {
		closeAll();
		m_para = new RtfParagraph(this,m_writer);
		return m_para;
	}

	public RtfParagraph newParagraph(RtfAttributes attrs) throws IOException {
		closeAll();
		m_para = new RtfParagraph(this,m_writer,attrs);
		return m_para;
	}

	public RtfExternalGraphic newImage() throws IOException {
		closeAll();
		m_externalGraphic = new RtfExternalGraphic(this,m_writer);
		return m_externalGraphic;
	}
	
	private void closeCurrentParagraph() throws IOException {
		if(m_para!=null) m_para.close();
	}

	private void closeCurrentExternalGraphic() throws IOException {
		if(m_externalGraphic!=null) m_externalGraphic.close();
	}	
	
	protected void writeRtfPrefix() throws IOException {
		writeGroupMark(true);
		writeAttributes(m_attrib,FOOTER_ATTR);
	}
	
	protected void writeRtfSuffix() throws IOException {
		writeGroupMark(false);
	}
	
	public RtfAttributes getAttributes(){
		return m_attrib;
	}
	
	public void closeAll() throws IOException
	{
		closeCurrentParagraph();
		closeCurrentExternalGraphic();
	}
}


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