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.

RtfString.java 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * ============================================================================
  3. * The Apache Software License, Version 1.1
  4. * ============================================================================
  5. *
  6. * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without modifica-
  9. * tion, are permitted provided that the following conditions are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright notice,
  12. * this list of conditions and the following disclaimer.
  13. *
  14. * 2. Redistributions in binary form must reproduce the above copyright notice,
  15. * this list of conditions and the following disclaimer in the documentation
  16. * and/or other materials provided with the distribution.
  17. *
  18. * 3. The end-user documentation included with the redistribution, if any, must
  19. * include the following acknowledgment: "This product includes software
  20. * developed by the Apache Software Foundation (http://www.apache.org/)."
  21. * Alternately, this acknowledgment may appear in the software itself, if
  22. * and wherever such third-party acknowledgments normally appear.
  23. *
  24. * 4. The names "FOP" and "Apache Software Foundation" must not be used to
  25. * endorse or promote products derived from this software without prior
  26. * written permission. For written permission, please contact
  27. * apache@apache.org.
  28. *
  29. * 5. Products derived from this software may not be called "Apache", nor may
  30. * "Apache" appear in their name, without prior written permission of the
  31. * Apache Software Foundation.
  32. *
  33. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  34. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  35. * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  36. * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  37. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
  38. * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  39. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  40. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  41. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  42. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  43. * ============================================================================
  44. *
  45. * This software consists of voluntary contributions made by many individuals
  46. * on behalf of the Apache Software Foundation and was originally created by
  47. * James Tauber <jtauber@jtauber.com>. For more information on the Apache
  48. * Software Foundation, please see <http://www.apache.org/>.
  49. */
  50. /*
  51. * This file is part of the RTF library of the FOP project, which was originally
  52. * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other
  53. * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
  54. * the FOP project.
  55. */
  56. package org.apache.fop.render.rtf.rtflib.rtfdoc;
  57. import java.io.IOException;
  58. import java.io.Writer;
  59. /** Plain text in a RTF file, without any formatings.
  60. * @author Peter Herweg, pherweg@web.de
  61. */
  62. public class RtfString extends RtfElement
  63. {
  64. String text="";
  65. RtfString(RtfContainer parent, Writer w, String s)
  66. throws IOException {
  67. super(parent, w);
  68. text=s;
  69. }
  70. /**
  71. * @return true if this element would generate no "useful" RTF content
  72. */
  73. public boolean isEmpty() {
  74. return text.trim().equals("");
  75. }
  76. /**
  77. * write RTF code of all our children
  78. * @throws IOException for I/O problems
  79. */
  80. protected void writeRtfContent() throws IOException {
  81. RtfStringConverter.getInstance().writeRtfString(writer, text);
  82. }
  83. public String getText() {
  84. return text;
  85. }
  86. public void setText(String s) {
  87. text=s;
  88. }
  89. }