You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RtfPageNumber.java 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.render.rtf.rtflib.rtfdoc;
  19. /*
  20. * This file is part of the RTF library of the FOP project, which was originally
  21. * created by Bertrand Delacretaz bdelacretaz@codeconsult.ch and by other
  22. * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
  23. * the FOP project.
  24. */
  25. import java.io.IOException;
  26. import java.io.Writer;
  27. /**
  28. * <p>Page number container.</p>
  29. *
  30. * <p>This work was authored by Christopher Scott (scottc@westinghouse.com).</p>
  31. */
  32. public class RtfPageNumber extends RtfContainer {
  33. /* RtfText attributes: fields
  34. must be carefull of group markings and star control
  35. ie page field:
  36. "{\field {\*\fldinst {PAGE}} {\fldrslt}}"
  37. */
  38. /** constant for field */
  39. public static final String RTF_FIELD = "field";
  40. /** constant for field on page */
  41. public static final String RTF_FIELD_PAGE = "fldinst { PAGE }";
  42. /** constant for field result */
  43. public static final String RTF_FIELD_RESULT = "fldrslt";
  44. /** Create an RTF paragraph as a child of given container with default attributes */
  45. RtfPageNumber(IRtfPageNumberContainer parent, Writer w) throws IOException {
  46. super((RtfContainer)parent, w);
  47. }
  48. /** Create an RTF page number as a child of given container with given attributes */
  49. RtfPageNumber(RtfContainer parent, Writer w, RtfAttributes attrs) throws IOException {
  50. // Adds the attributes of the parent paragraph
  51. super(parent, w, attrs);
  52. }
  53. /** Create an RTF page number as a child of given paragraph,
  54. * copying the paragraph attributes
  55. */
  56. RtfPageNumber(RtfParagraph parent, Writer w) throws IOException {
  57. // Adds the attributes of the parent paragraph
  58. super((RtfContainer)parent, w, parent.attrib);
  59. // copy parent's text attributes
  60. if (parent.getTextAttributes() != null) {
  61. attrib.set(parent.getTextAttributes());
  62. }
  63. }
  64. /**
  65. * Write our attributes and content
  66. * @throws IOException for I/O problems
  67. */
  68. protected void writeRtfContent() throws IOException {
  69. /*
  70. writeGroupMark(true);
  71. writeControlWord(RTF_FIELD);
  72. writeGroupMark(true);
  73. writeAttributes(attrib, RtfText.ATTR_NAMES); // Added by Boris Poudérous
  74. writeStarControlWord(RTF_FIELD_PAGE);
  75. writeGroupMark(false);
  76. writeGroupMark(true);
  77. writeControlWord(RTF_FIELD_RESULT);
  78. writeGroupMark(false);
  79. writeGroupMark(false);
  80. */
  81. writeGroupMark(true);
  82. writeAttributes(attrib, RtfText.ATTR_NAMES);
  83. writeControlWord("chpgn");
  84. writeGroupMark(false);
  85. }
  86. /**
  87. * @return true if this element would generate no "useful" RTF content
  88. */
  89. public boolean isEmpty() {
  90. return false;
  91. }
  92. }