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.

RtfFootnote.java 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. import java.io.IOException;
  20. import java.io.Writer;
  21. /**
  22. * <p>Model of an RTF footnote.</p>
  23. *
  24. * <p>This work was authored by Peter Herweg (pherweg@web.de) and
  25. * Marc Wilhelm Kuester.</p>
  26. */
  27. public class RtfFootnote extends RtfContainer
  28. implements IRtfTextrunContainer, IRtfListContainer {
  29. RtfTextrun textrunInline;
  30. RtfContainer body;
  31. RtfList list;
  32. boolean bBody;
  33. /**
  34. * Create an RTF list item as a child of given container with default attributes.
  35. * @param parent a container
  36. * @param w a writer
  37. * @throws IOException if not caught
  38. */
  39. RtfFootnote(RtfContainer parent, Writer w) throws IOException {
  40. super(parent, w);
  41. textrunInline = new RtfTextrun(this, writer, null);
  42. body = new RtfContainer(this, writer);
  43. }
  44. /**
  45. * @return a text run
  46. * @throws IOException if not caught
  47. */
  48. public RtfTextrun getTextrun() throws IOException {
  49. if (bBody) {
  50. RtfTextrun textrun = RtfTextrun.getTextrun(body, writer, null);
  51. textrun.setSuppressLastPar(true);
  52. return textrun;
  53. } else {
  54. return textrunInline;
  55. }
  56. }
  57. /**
  58. * write RTF code of all our children
  59. * @throws IOException for I/O problems
  60. */
  61. protected void writeRtfContent() throws IOException {
  62. textrunInline.writeRtfContent();
  63. writeGroupMark(true);
  64. writeControlWord("footnote");
  65. writeControlWord("ftnalt");
  66. body.writeRtfContent();
  67. writeGroupMark(false);
  68. }
  69. /**
  70. * @param attrs some attributes
  71. * @return an rtf list
  72. * @throws IOException if not caught
  73. */
  74. public RtfList newList(RtfAttributes attrs) throws IOException {
  75. if (list != null) {
  76. list.close();
  77. }
  78. list = new RtfList(body, writer, attrs);
  79. return list;
  80. }
  81. /** start body */
  82. public void startBody() {
  83. bBody = true;
  84. }
  85. /** end body */
  86. public void endBody() {
  87. bBody = false;
  88. }
  89. }