KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lowagie > text > rtf > field > RtfTotalPageNumber


1 /*
2  * $Id: RtfTotalPageNumber.java 2776 2007-05-23 20:01:40Z hallm $
3  * $Name$
4  *
5  * Copyright 2005 Jose Hurtado <a HREF="mailto:jose.hurtado@gft.com">jose.hurtado@gft.com</a>
6  * Parts Copyright 2005 Mark Hall
7  *
8  * The contents of this file are subject to the Mozilla Public License Version 1.1
9  * (the "License"); you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the License.
15  *
16  * The Original Code is 'iText, a free JAVA-PDF library'.
17  *
18  * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
19  * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
20  * All Rights Reserved.
21  * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
22  * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
23  *
24  * Contributor(s): all the names of the contributors are added in the source code
25  * where applicable.
26  *
27  * Alternatively, the contents of this file may be used under the terms of the
28  * LGPL license (the ?GNU LIBRARY GENERAL PUBLIC LICENSE?), in which case the
29  * provisions of LGPL are applicable instead of those above. If you wish to
30  * allow use of your version of this file only under the terms of the LGPL
31  * License and not to allow others to use your version of this file under
32  * the MPL, indicate your decision by deleting the provisions above and
33  * replace them with the notice and other provisions required by the LGPL.
34  * If you do not delete the provisions above, a recipient may use your version
35  * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
36  *
37  * This library is free software; you can redistribute it and/or modify it
38  * under the terms of the MPL as stated above or under the terms of the GNU
39  * Library General Public License as published by the Free Software Foundation;
40  * either version 2 of the License, or any later version.
41  *
42  * This library is distributed in the hope that it will be useful, but WITHOUT
43  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
44  * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
45  * details.
46  *
47  * If you didn't download this code from the following link, you should check if
48  * you aren't using an obsolete version:
49  * http://www.lowagie.com/iText/
50  */

51
52 package com.lowagie.text.rtf.field;
53
54 import java.io.IOException JavaDoc;
55 import java.io.OutputStream JavaDoc;
56
57 import com.lowagie.text.Font;
58 import com.lowagie.text.rtf.document.RtfDocument;
59
60 /**
61  * The RtfTotalPageNumber provides the total number of pages field in rtf documents.
62  *
63  * @version $Id: RtfTotalPageNumber.java 2776 2007-05-23 20:01:40Z hallm $
64  * @author Jose Hurtado (jose.hurtado@gft.com)
65  * @author Mark Hall (mhall@edu.uni-klu.ac.at)
66  * @author Thomas Bickel (tmb99@inode.at)
67  */

68 public class RtfTotalPageNumber extends RtfField {
69
70     /**
71      * Constant for arabic total page numbers.
72      */

73     private static final byte[] ARABIC_TOTAL_PAGES = "NUMPAGES \\\\* Arabic".getBytes();
74     
75     /**
76      * Constructs a RtfTotalPageNumber. This can be added anywhere to add a total number of pages field.
77      */

78     public RtfTotalPageNumber() {
79         super(null);
80     }
81     
82     /**
83      * Constructs a RtfTotalPageNumber with a specified Font. This can be added anywhere
84      * to add a total number of pages field.
85      * @param font
86      */

87     public RtfTotalPageNumber(Font font) {
88         super(null, font);
89     }
90     
91     /**
92      * Constructs a RtfTotalPageNumber object.
93      *
94      * @param doc The RtfDocument this RtfTotalPageNumber belongs to
95      */

96     public RtfTotalPageNumber(RtfDocument doc) {
97         super(doc);
98     }
99     
100     /**
101      * Constructs a RtfTotalPageNumber object with a specific font.
102      *
103      * @param doc The RtfDocument this RtfTotalPageNumber belongs to
104      * @param font The Font to use
105      */

106     public RtfTotalPageNumber(RtfDocument doc, Font font) {
107         super(doc, font);
108     }
109     
110     /**
111      * Writes the field NUMPAGES instruction with Arabic format
112      *
113      * @return A byte array containing "NUMPAGES \\\\* Arabic".
114      * @deprecated
115      * @throws IOException
116      */

117     protected byte[] writeFieldInstContent() throws IOException JavaDoc
118     {
119         return ARABIC_TOTAL_PAGES;
120     }
121     /**
122      * Writes the field NUMPAGES instruction with Arabic format: "NUMPAGES \\\\* Arabic".
123      */

124     protected void writeFieldInstContent(OutputStream JavaDoc out) throws IOException JavaDoc
125     {
126         out.write(ARABIC_TOTAL_PAGES);
127     }
128
129     /**
130      * Writes the field result content
131      *
132      * @return An byte array containing "1".
133      * @deprecated
134      * @throws IOException
135      */

136     protected byte[] writeFieldResultContent() throws IOException JavaDoc
137     {
138         return "1".getBytes();
139     }
140
141     /**
142      * Writes the field result content "1"
143      */

144     protected void writeFieldResultContent(final OutputStream JavaDoc out) throws IOException JavaDoc
145     {
146         out.write("1".getBytes());
147     }
148     
149 }
150
Popular Tags