001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: /* $Id: RtfPageNumber.java 426576 2006-07-28 15:44:37Z jeremias $ */
019:
020: package org.apache.fop.render.rtf.rtflib.rtfdoc;
021:
022: /*
023: * This file is part of the RTF library of the FOP project, which was originally
024: * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other
025: * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
026: * the FOP project.
027: */
028:
029: import java.io.Writer;
030: import java.io.IOException;
031:
032: /**
033: * @author Christopher Scott, scottc@westinghouse.com
034: */
035: public class RtfPageNumber extends RtfContainer {
036: /* RtfText attributes: fields
037: must be carefull of group markings and star control
038: ie page field:
039: "{\field {\*\fldinst {PAGE}} {\fldrslt}}"
040: */
041:
042: /** constant for field */
043: public static final String RTF_FIELD = "field";
044: /** constant for field on page */
045: public static final String RTF_FIELD_PAGE = "fldinst { PAGE }";
046: /** constant for field result */
047: public static final String RTF_FIELD_RESULT = "fldrslt";
048:
049: /** Create an RTF paragraph as a child of given container with default attributes */
050: RtfPageNumber(IRtfPageNumberContainer parent, Writer w)
051: throws IOException {
052: super ((RtfContainer) parent, w);
053: }
054:
055: /** Create an RTF page number as a child of given container with given attributes */
056: RtfPageNumber(RtfContainer parent, Writer w, RtfAttributes attrs)
057: throws IOException {
058: // Adds the attributes of the parent paragraph
059: super (parent, w, attrs);
060: }
061:
062: /** Create an RTF page number as a child of given paragraph,
063: * copying the paragraph attributes
064: */
065: RtfPageNumber(RtfParagraph parent, Writer w) throws IOException {
066: // Adds the attributes of the parent paragraph
067: super ((RtfContainer) parent, w, parent.attrib);
068:
069: // copy parent's text attributes
070: if (parent.getTextAttributes() != null) {
071: attrib.set(parent.getTextAttributes());
072: }
073: }
074:
075: /**
076: * Write our attributes and content
077: * @throws IOException for I/O problems
078: */
079: protected void writeRtfContent() throws IOException {
080: /*
081: writeGroupMark(true);
082: writeControlWord(RTF_FIELD);
083: writeGroupMark(true);
084: writeAttributes(attrib, RtfText.ATTR_NAMES); // Added by Boris Poudérous
085: writeStarControlWord(RTF_FIELD_PAGE);
086: writeGroupMark(false);
087: writeGroupMark(true);
088: writeControlWord(RTF_FIELD_RESULT);
089: writeGroupMark(false);
090: writeGroupMark(false);
091: */
092: writeGroupMark(true);
093: writeAttributes(attrib, RtfText.ATTR_NAMES);
094: writeControlWord("chpgn");
095: writeGroupMark(false);
096: }
097:
098: /**
099: * @return true if this element would generate no "useful" RTF content
100: */
101: public boolean isEmpty() {
102: return false;
103: }
104: }
|