CVS: jfor/src/org/jfor/jfor/rtflib/rtfdoc RtfPageNumberCitation.java,NONE,1.1 IRtfPageNumberCitationContainer.java,NONE,1.1

Marra Roberto <[email protected]> Mon, 29 Jul 2002 06:50:23 -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-serv4018

Added Files:
	RtfPageNumberCitation.java 
	IRtfPageNumberCitationContainer.java 
Log Message:
initial check-in M.Boris Poudérous contribution

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

import java.io.Writer;
import java.io.IOException;

/*-----------------------------------------------------------------------------
 * 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):
 * Christopher Scott, [email protected]
 * Portions created by Christopher Scott are Coypright (C) 2001
 * Westinghouse Electric Company. All Rights Reserved.
 *
 * Boris Poudérous, [email protected]
 * Portions created by Boris Poudérous are Coypright (C) 2002
 * All Rights Reserved.
-----------------------------------------------------------------------------*/

public class RtfPageNumberCitation extends RtfContainer
{
  // Page field :
	//  "{\field {\*\fldinst {PAGEREF xx}} {\fldrslt}}" where xx represents the
  // 'id' of the referenced page
	public static String RTF_FIELD = "field";
	public String RTF_FIELD_PAGEREF = "fldinst { PAGEREF }"; // non static to avoid enlargment
	public static String RTF_FIELD_RESULT = "fldrslt";

  // The 'id' of the referenced page
  private String id = null;

  /** Create an RTF paragraph as a child of given container with default attributes */
  RtfPageNumberCitation (IRtfPageNumberCitationContainer parent, Writer w, String id) throws IOException
  {
     super((RtfContainer)parent,w);
     this.id = id;
  }

  /** overridden to write our attributes before our content */
  protected void writeRtfContent() throws IOException
  {
      // If the <fo:page-citation-number> contains a 'ref-id' attribute
      if (isValid())
        {
          // Update page reference
          int insertionIndex = RTF_FIELD_PAGEREF.indexOf("}");
          RTF_FIELD_PAGEREF = RTF_FIELD_PAGEREF.substring(0,insertionIndex) + "\"" + id + "\"" + " " +
                              RTF_FIELD_PAGEREF.substring(insertionIndex, RTF_FIELD_PAGEREF.length());
          id = null;

          // Write RTF content
          writeGroupMark(true);
          writeControlWord(RTF_FIELD);
          writeGroupMark(true);
          writeStarControlWord(RTF_FIELD_PAGEREF);
          writeGroupMark(false);
          writeGroupMark(true);
          writeControlWord(RTF_FIELD_RESULT);
          writeGroupMark(false);
          writeGroupMark(false);
        }
  }

  /** checks that the 'ref-id' attribute exists */
  private boolean isValid()
  {
    if (id != null)
      return true;
    else
      return false;
  }

  /** true if this element would generate no "useful" RTF content */
  public boolean isEmpty()
  {
      return false;
  }
}

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

import java.io.IOException;

/*-----------------------------------------------------------------------------
 * 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):
 * Christopher Scott, [email protected]
 * Portions created by Christopher Scott are Coypright (C) 2001
 * Westinghouse Electric Company. All Rights Reserved.
 *
 * Boris Poudérous, [email protected]
 * Portions created by Boris Poudérous are Coypright (C) 2002
 * All Rights Reserved.
-----------------------------------------------------------------------------*/

public interface IRtfPageNumberCitationContainer
{
    public RtfPageNumberCitation newPageNumberCitation(String id) throws IOException;
}



-------------------------------------------------------
This sf.net email is sponsored by: Dice - The leading online job board
for high-tech professionals. Search and apply for tech jobs today!
http://seeker.dice.com/seeker.epl?rel_code=31