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.

RtfLeader.java 7.4KB

Merged revisions 636407-637074,637076-637118,637120-637790,637792-637856,637858-637992,637994-638047,638049-638307,638309-638315,638318-638936,638938-640888,640890-642905,642907-647402,647404-647536,647538-648983,648985-649005,649007-649013,649015-650549,650551-651301,651303-653536,653538-654452,654454-656285,656287-656523,656525-657519,657521-661579,661581-663481,663483-664691,664693-681285,681287-681290,681292-681298 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_95 ........ r666635 | jeremias | 2008-06-11 14:18:53 +0200 (Mi, 11 Jun 2008) | 1 line Fixed resolution handling inside AWT preview dialog. ........ r666662 | jeremias | 2008-06-11 15:33:20 +0200 (Mi, 11 Jun 2008) | 1 line Some notes on RTF and print output. ........ r668533 | jeremias | 2008-06-17 09:57:55 +0200 (Di, 17 Jun 2008) | 2 lines Bugzilla #45151: Note on the "compiling" page that Ant 1.7 is required. The README file already points to this page. ........ r668534 | jeremias | 2008-06-17 09:58:40 +0200 (Di, 17 Jun 2008) | 2 lines Update known issues. Remove ApacheConEU logo. ........ r668550 | jeremias | 2008-06-17 10:05:22 +0200 (Di, 17 Jun 2008) | 2 lines Bugzilla #45146: Removed duplicate LICENSE.txt and Notice.txt from the JAR. ........ r668570 | jeremias | 2008-06-17 10:54:07 +0200 (Di, 17 Jun 2008) | 1 line Wrong line number reported in the case of a line overflow. ........ r668641 | jeremias | 2008-06-17 14:59:25 +0200 (Di, 17 Jun 2008) | 1 line Fixed potential NPE. ........ r669118 | jeremias | 2008-06-18 11:02:45 +0200 (Mi, 18 Jun 2008) | 4 lines Bugzilla #44412: Regression fix for empty pages caused by multiple collapsible breaks. No more empty block areas if a break-before occurs on the first child of an FO to match the behaviour of tables and other FO implementations (clarification by XSL WG pending). Added an accessor interface for break-before/-after to avoid long if..else lists in BlockStackingLayoutManager. ........ r669173 | jeremias | 2008-06-18 16:07:27 +0200 (Mi, 18 Jun 2008) | 7 lines Bugzilla #44887: Fixed potential multi-threading problem concerning the use of DecimalFormat. Results from performance measurements in a separate test (operation repeated 100'000 times, exemplary): shared static variable: ~220ms (old choice, problematic!) always create new instance: ~480ms ThreadLocal: ~220ms (new choice) ........ r669478 | jeremias | 2008-06-19 15:03:57 +0200 (Do, 19 Jun 2008) | 4 lines Bugzilla #44412: Improvements after Vincent's feedback: Removal of the somewhat ugly Reference. getBreakBefore() reduced to private visibility. ........ r670551 | jeremias | 2008-06-23 14:54:27 +0200 (Mo, 23 Jun 2008) | 3 lines Use configured source and target resolution for foreign objects in RTF output. Fixed intrinsic size calculation for SVG images when source resolution is not 72 dpi. Fixed calculation of px2mm values in the SVG to G2D converter (used by RTF output). ........ r673750 | adelmelle | 2008-07-03 20:25:01 +0200 (Do, 03 Jul 2008) | 1 line Fix for Bugzilla 45295 (already committed to the trunk with r672010, r672495 and r672496) ........ r674304 | jeremias | 2008-07-06 17:09:10 +0200 (So, 06 Jul 2008) | 18 lines Bugzilla #43606: column-width accepts percent values (proportional-column-width and % working) Table width accepts percent values (100% of the page width as standard) Nested tables are working It is also possible to make nested tables with a higher depth than 3 without causing word to crash Submitted by: Maximilan Aster <maximilian.aster.at.boc-eu.com> Changes to the patch by Jeremias: - Patch simplified (reuse of ColumnSetup from the layoutmgr package) - Percentages and proportional-column-width didn't work properly in my tests -> fixed - Adjustments for FOP code conventions Bugzilla #43824: page-number-citation working but has to be refreshed inside word to show the correct values Submitted by: Maximilan Aster <maximilian.aster.at.boc-eu.com> Changes to the patch by Jeremias: - Adjustments for FOP code conventions ........ r674314 | jeremias | 2008-07-06 18:40:08 +0200 (So, 06 Jul 2008) | 7 lines Bugzilla #43825: leader supports fixed percent values for leader-length, most other properties use-content, leader-pattern-width not implemented Submitted by: Maximilan Aster <maximilian.aster.at.boc-eu.com> Changes to the patch by Jeremias: - Adjustments for FOP code conventions ........ r674317 | jeremias | 2008-07-06 18:44:43 +0200 (So, 06 Jul 2008) | 1 line Doc update after RTF changes. ........ r675106 | jeremias | 2008-07-09 09:03:46 +0200 (Mi, 09 Jul 2008) | 2 lines Bugzilla #45366: Document missing feature. ........ r675150 | jeremias | 2008-07-09 14:56:41 +0200 (Mi, 09 Jul 2008) | 2 lines Bugzilla #39980: Fixed image scaling for RTF output. ........ r675151 | jeremias | 2008-07-09 14:57:06 +0200 (Mi, 09 Jul 2008) | 1 line Removed unused code. ........ r675152 | jeremias | 2008-07-09 14:58:18 +0200 (Mi, 09 Jul 2008) | 1 line Don't generate commands for default values. ........ r675707 | jeremias | 2008-07-10 21:58:27 +0200 (Do, 10 Jul 2008) | 1 line Bugfix: -imagein didn't work because the stylesheet didn't get copied into fop.jar. ........ r680715 | jeremias | 2008-07-29 16:37:10 +0200 (Di, 29 Jul 2008) | 1 line Found a surplus "pop state" which somehow causes a regression (fill color doesn't get properly reset) between 0.94 and 0.95. Shows in Barcode4J's fop-extension-demo.fo. The line has already been there in 0.94 but only shows in 0.95 probably due to an additional save/restore state pair added in PDFRenderer for reference areas after the block-container area refactoring. ........ r680820 | jeremias | 2008-07-29 22:02:14 +0200 (Di, 29 Jul 2008) | 2 lines Bugzilla #41306: The AWT Renderer is really not out-of-order capable. ........ r681284 | jeremias | 2008-07-31 08:47:49 +0200 (Do, 31 Jul 2008) | 1 line Some updates to status.xml (I was not the only one working on the final release). ........ r681290 | jeremias | 2008-07-31 09:44:51 +0200 (Do, 31 Jul 2008) | 2 lines Website updates for the 0.95 release. The projectInfo plug-in of Forrest is not ideal for doing a bugfix release. It's not possible to combine the changes for two releases. ........ r681292 | jeremias | 2008-07-31 09:47:13 +0200 (Do, 31 Jul 2008) | 1 line Disabling the ApacheCon ad for the release build. ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@681307 13f79535-47bb-0310-9956-ffa450edef68
16 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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. import java.util.Iterator;
  22. /**
  23. * Generates the leader in RTF.
  24. */
  25. public class RtfLeader extends RtfContainer {
  26. /*
  27. * Format : \tqr \style \tx## { \pard \format \tab }
  28. * ## represents the width \style represents the style (tldot, tlth, ...)
  29. * \format represents standard formats (color, fontsize, ...)
  30. *
  31. *
  32. * \pard \zwnj {\fsxx <format> } \zwnj
  33. *
  34. * <format>: \\ulcN Underline color. \\uld Dotted underline. \\uldash Dashed
  35. * underline. \\uldashd Dash-dotted underline. \\uldashdd Dash-dot-dotted
  36. * underline. \\uldb Double underline. \\ulhwave Heavy wave underline.
  37. * \\ulldash Long dashed underline. \\ulnone Stops all underlining. \\ulth
  38. * Thick underline. \\ulthd Thick dotted underline. \\ulthdash Thick dashed
  39. * underline. \\ulthdashd Thick dash-dotted underline. \\ulthdashdd Thick
  40. * dash-dot-dotted underline. \\ulthldash Thick long dashed underline.
  41. * \\ululdbwave Double wave underline.
  42. */
  43. private RtfAttributes attrs = null;
  44. /** Private attribute: tab style */
  45. public static final String LEADER_TABLEAD = "tablead";
  46. /** Private attribute: tab usage indicator */
  47. public static final String LEADER_USETAB = "tabuse";
  48. /** Private attribute: leader width */
  49. public static final String LEADER_WIDTH = "lwidth";
  50. // +++++++++++++++ Styles Underline ++++++++++++++++++++++
  51. /** Dotted underline */
  52. public static final String LEADER_DOTTED = "uld"; // dotted
  53. /** Dashed underline */
  54. public static final String LEADER_MIDDLEDOTTED = "uldash"; // dashed
  55. /** Heavy wave underline */
  56. public static final String LEADER_HYPHENS = "ulhwave"; // groove
  57. /** Dash-dot-dotted underline */
  58. public static final String LEADER_UNDERLINE = "ulthdashdd"; // ridge
  59. /** Double underline */
  60. public static final String LEADER_EQUAL = "uldb"; // double
  61. /** Thick underline */
  62. public static final String LEADER_THICK = "ulth"; // solid
  63. // +++++++++++++++ Styles Tabulator +++++++++++++++++++++++
  64. /** Leader dots */
  65. public static final String LEADER_TAB_DOTTED = "tldot"; // dotted
  66. /** Leader middle dots */
  67. public static final String LEADER_TAB_MIDDLEDOTTED = "tlmdot"; // dashed
  68. /** Leader hyphens */
  69. public static final String LEADER_TAB_HYPHENS = "tlhyph"; // groove
  70. /** Leader underline */
  71. public static final String LEADER_TAB_UNDERLINE = "tlul"; // ridge
  72. /** Leader equal sign */
  73. public static final String LEADER_TAB_EQUAL = "tleq"; // double
  74. /** Leader thick line */
  75. public static final String LEADER_TAB_THICK = "tlth"; // solid
  76. // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  77. /** Resets to default properties */
  78. public static final String LEADER_IGNORE_STYLE = "pard";
  79. /** Font size determines rule thickness */
  80. public static final String LEADER_RULE_THICKNESS = "fs"; // thickness = fontsize
  81. /** Expansion or compression of the space between characters in twips */
  82. public static final String LEADER_PATTERN_WIDTH = "expndtw";
  83. /** Zero-width break opportunity */
  84. public static final String LEADER_ZERO_WIDTH = "zwbo";
  85. /** Standard leader width */
  86. public static final int LEADER_STANDARD_WIDTH = 30;
  87. /** Move up 4 half-points */
  88. public static final String LEADER_UP = "up4";
  89. /** Negative expansion */
  90. public static final String LEADER_EXPAND = "expnd-2"; // negative value
  91. // for compression
  92. /** Tab */
  93. public static final String LEADER_TAB_VALUE = "tab";
  94. /** Right-aligned tab */
  95. public static final String LEADER_TAB_RIGHT = "tqr";
  96. /** Tab width */
  97. public static final String LEADER_TAB_WIDTH = "tx";
  98. RtfLeader(RtfContainer parent, Writer w, RtfAttributes attrs) throws IOException {
  99. super(parent, w);
  100. this.attrs = attrs;
  101. }
  102. /** {@inheritDoc} */
  103. protected void writeRtfContent() throws IOException {
  104. int thickness = LEADER_STANDARD_WIDTH;
  105. String tablead = null;
  106. String tabwidth = null;
  107. for (Iterator it = attrs.nameIterator(); it.hasNext();) {
  108. final String name = (String)it.next();
  109. if (attrs.isSet(name)) {
  110. if (name.equals(LEADER_TABLEAD)) {
  111. tablead = attrs.getValue(LEADER_TABLEAD).toString();
  112. } else if (name.equals(LEADER_WIDTH)) {
  113. tabwidth = attrs.getValue(LEADER_WIDTH).toString();
  114. }
  115. }
  116. }
  117. if (attrs.getValue(LEADER_RULE_THICKNESS) != null) {
  118. thickness += Integer.parseInt(attrs.getValue(LEADER_RULE_THICKNESS).toString())
  119. / 1000 * 2;
  120. attrs.unset(LEADER_RULE_THICKNESS);
  121. }
  122. //Remove private attributes
  123. attrs.unset(LEADER_WIDTH);
  124. attrs.unset(LEADER_TABLEAD);
  125. // If leader is 100% we use a tabulator, because its more
  126. // comfortable, specially for the table of content
  127. if (attrs.getValue(LEADER_USETAB) != null) {
  128. attrs.unset(LEADER_USETAB);
  129. writeControlWord(LEADER_TAB_RIGHT);
  130. if (tablead != null) {
  131. writeControlWord(tablead);
  132. }
  133. writeControlWord(LEADER_TAB_WIDTH + tabwidth);
  134. writeGroupMark(true);
  135. writeControlWord(LEADER_IGNORE_STYLE);
  136. writeAttributes(attrs, null);
  137. writeControlWord(LEADER_EXPAND);
  138. writeControlWord(LEADER_TAB_VALUE);
  139. writeGroupMark(false);
  140. }
  141. // Using white spaces with different underline formats
  142. else {
  143. writeControlWord(LEADER_IGNORE_STYLE);
  144. writeControlWord(LEADER_ZERO_WIDTH);
  145. writeGroupMark(true);
  146. writeControlWord(LEADER_RULE_THICKNESS + thickness);
  147. writeControlWord(LEADER_UP);
  148. super.writeAttributes(attrs, null);
  149. if (tablead != null) {
  150. writeControlWord(tablead);
  151. }
  152. // Calculation for the necessary amount of white spaces
  153. // Depending on font-size 15 -> 1cm = 7,5 spaces
  154. // TODO for rule-thickness this has to be done better
  155. for (double d = (Integer.parseInt(tabwidth) / 560) * 7.5; d >= 1; d--) {
  156. RtfStringConverter.getInstance().writeRtfString(writer, " ");
  157. }
  158. writeGroupMark(false);
  159. writeControlWord(LEADER_ZERO_WIDTH);
  160. }
  161. }
  162. /** {@inheritDoc} */
  163. public boolean isEmpty() {
  164. return false;
  165. }
  166. }