Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

BorderAttributesConverter.java 8.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. * $Id$
  3. * ============================================================================
  4. * The Apache Software License, Version 1.1
  5. * ============================================================================
  6. *
  7. * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  8. *
  9. * Redistribution and use in source and binary forms, with or without modifica-
  10. * tion, are permitted provided that the following conditions are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright notice,
  13. * this list of conditions and the following disclaimer.
  14. *
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. *
  19. * 3. The end-user documentation included with the redistribution, if any, must
  20. * include the following acknowledgment: "This product includes software
  21. * developed by the Apache Software Foundation (http://www.apache.org/)."
  22. * Alternately, this acknowledgment may appear in the software itself, if
  23. * and wherever such third-party acknowledgments normally appear.
  24. *
  25. * 4. The names "FOP" and "Apache Software Foundation" must not be used to
  26. * endorse or promote products derived from this software without prior
  27. * written permission. For written permission, please contact
  28. * apache@apache.org.
  29. *
  30. * 5. Products derived from this software may not be called "Apache", nor may
  31. * "Apache" appear in their name, without prior written permission of the
  32. * Apache Software Foundation.
  33. *
  34. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  35. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  36. * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  37. * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  38. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
  39. * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  40. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  41. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  42. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  43. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  44. * ============================================================================
  45. *
  46. * This software consists of voluntary contributions made by many individuals
  47. * on behalf of the Apache Software Foundation and was originally created by
  48. * James Tauber <jtauber@jtauber.com>. For more information on the Apache
  49. * Software Foundation, please see <http://www.apache.org/>.
  50. */
  51. /*
  52. * This file is part of the RTF library of the FOP project, which was originally
  53. * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other
  54. * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
  55. * the FOP project.
  56. */
  57. package org.apache.fop.render.rtf.rtflib.rtfdoc;
  58. /** Constants for RTF border attribute names, and a static method for converting
  59. * fo attribute strings. */
  60. public class BorderAttributesConverter {
  61. /** Constant for a single-thick border */
  62. public static final String BORDER_SINGLE_THICKNESS = "brdrs";
  63. /** Constant for a double-thick border */
  64. public static final String BORDER_DOUBLE_THICKNESS = "brdrth";
  65. /** Constant for a shadowed border */
  66. public static final String BORDER_SHADOWED = "brdrsh";
  67. /** Constant for a double border */
  68. public static final String BORDER_DOUBLE = "brdrdb";
  69. /** Constant for a dotted border */
  70. public static final String BORDER_DOTTED = "brdrdot";
  71. /** Constant for a dashed border */
  72. public static final String BORDER_DASH = "brdrdash";
  73. /** Constant for a hairline border */
  74. public static final String BORDER_HAIRLINE = "brdrhair";
  75. /** Constant for a small-dashed border */
  76. public static final String BORDER_DASH_SMALL = "brdrdashsm";
  77. /** Constant for a dot-dashed border */
  78. public static final String BORDER_DOT_DASH = "brdrdashd";
  79. /** Constant for a dot-dot-dashed border */
  80. public static final String BORDER_DOT_DOT_DASH = "brdrdashdd";
  81. /** Constant for a triple border */
  82. public static final String BORDER_TRIPLE = "brdrtriple";
  83. /** Constant for a think-thin-small border */
  84. public static final String BORDER_THINK_THIN_SMALL = "brdrtnthsg";
  85. /** Constant for a thin-thick-small border */
  86. public static final String BORDER_THIN_THICK_SMALL = "brdrthtnsg";
  87. /** Constant for a thin-thick-thin-small border */
  88. public static final String BORDER_THIN_THICK_THIN_SMALL = "brdrthtnthsg";
  89. /** Constant for a think-thin-medium border */
  90. public static final String BORDER_THINK_THIN_MEDIUM = "brdrtnthmg";
  91. /** Constant for a thin-thick-medium border */
  92. public static final String BORDER_THIN_THICK_MEDIUM = "brdrthtnmg";
  93. /** Constant for a thin-thick-thin-medium border */
  94. public static final String BORDER_THIN_THICK_THIN_MEDIUM = "brdrthtnthmg";
  95. /** Constant for a think-thin-large border */
  96. public static final String BORDER_THINK_THIN_LARGE = "brdrtnthlg";
  97. /** Constant for a thin-thick-large border */
  98. public static final String BORDER_THIN_THICK_LARGE = "brdrthtnlg";
  99. /** Constant for a thin-thick-thin-large border */
  100. public static final String BORDER_THIN_THICK_THIN_LARGE = "brdrthtnthlg";
  101. /** Constant for a wavy border */
  102. public static final String BORDER_WAVY = "brdrwavy";
  103. /** Constant for a double wavy border */
  104. public static final String BORDER_WAVY_DOUBLE = "brdrwavydb";
  105. /** Constant for a striped border */
  106. public static final String BORDER_STRIPED = "brdrdashdotstr";
  107. /** Constant for an embossed border */
  108. public static final String BORDER_EMBOSS = "brdremboss";
  109. /** Constant for an engraved border */
  110. public static final String BORDER_ENGRAVE = "brdrengrave";
  111. /** Constant for border color */
  112. public static final String BORDER_COLOR = "brdrcf";
  113. /** Constant for border space */
  114. public static final String BORDER_SPACE = "brsp";
  115. /** Constant for border width */
  116. public static final String BORDER_WIDTH = "brdrw";
  117. /** String array of border attributes */
  118. public static final String [] BORDERS = new String[] {
  119. BORDER_SINGLE_THICKNESS, BORDER_DOUBLE_THICKNESS, BORDER_SHADOWED,
  120. BORDER_DOUBLE, BORDER_DOTTED, BORDER_DASH,
  121. BORDER_HAIRLINE, BORDER_DASH_SMALL, BORDER_DOT_DASH,
  122. BORDER_DOT_DOT_DASH, BORDER_TRIPLE, BORDER_THINK_THIN_SMALL,
  123. BORDER_THIN_THICK_SMALL, BORDER_THIN_THICK_THIN_SMALL, BORDER_THINK_THIN_MEDIUM,
  124. BORDER_THIN_THICK_MEDIUM, BORDER_THIN_THICK_THIN_MEDIUM, BORDER_THINK_THIN_LARGE,
  125. BORDER_THIN_THICK_LARGE, BORDER_THIN_THICK_THIN_LARGE, BORDER_WAVY,
  126. BORDER_WAVY_DOUBLE, BORDER_STRIPED, BORDER_EMBOSS,
  127. BORDER_ENGRAVE, BORDER_COLOR, BORDER_SPACE,
  128. BORDER_WIDTH
  129. };
  130. /**
  131. * BorderAttributesConverter: Static Method for converting FO strings
  132. * to RTF control words
  133. * @param value FO string
  134. * @return RTF control word
  135. */
  136. public static String convertAttributetoRtf(String value) {
  137. // Added by Normand Masse
  138. // "solid" is interpreted like "thin"
  139. if (value.equals("thin") || value.equals("solid")) {
  140. return BORDER_SINGLE_THICKNESS;
  141. } else if (value.equals("thick")) {
  142. return BORDER_DOUBLE_THICKNESS;
  143. } else if (value.equals("shadowed")) {
  144. return BORDER_SHADOWED;
  145. } else if (value.equals("double")) {
  146. return BORDER_DOUBLE;
  147. } else if (value.equals("dotted")) {
  148. return BORDER_DOTTED;
  149. } else if (value.equals("dash")) {
  150. return BORDER_DASH;
  151. } else if (value.equals("hairline")) {
  152. return BORDER_HAIRLINE;
  153. } else if (value.equals("dot-dash")) {
  154. return BORDER_DOT_DASH;
  155. } else if (value.equals("dot-dot-dash")) {
  156. return BORDER_DOT_DOT_DASH;
  157. } else if (value.equals("triple")) {
  158. return BORDER_TRIPLE;
  159. } else if (value.equals("wavy")) {
  160. return BORDER_WAVY;
  161. } else if (value.equals("wavy-double")) {
  162. return BORDER_WAVY_DOUBLE;
  163. } else if (value.equals("striped")) {
  164. return BORDER_STRIPED;
  165. } else if (value.equals("emboss")) {
  166. return BORDER_EMBOSS;
  167. } else if (value.equals("engrave")) {
  168. return BORDER_ENGRAVE;
  169. } else {
  170. return null;
  171. }
  172. }
  173. }