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.

TextParagraph.java 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.sl.usermodel;
  16. import java.awt.Color;
  17. import java.util.List;
  18. public interface TextParagraph<
  19. S extends Shape<S,P>,
  20. P extends TextParagraph<S,P,T>,
  21. T extends TextRun
  22. > extends Iterable<T> {
  23. /**
  24. * Specifies a list of text alignment types
  25. */
  26. public enum TextAlign {
  27. /**
  28. * For horizontal text, left aligned.
  29. * For vertical text, top aligned.
  30. */
  31. LEFT,
  32. /**
  33. * For horizontal text, centered.
  34. * For vertical text, middle aligned.
  35. */
  36. CENTER,
  37. /**
  38. * For horizontal text, right aligned.
  39. * For vertical text, bottom aligned.
  40. */
  41. RIGHT,
  42. /**
  43. * Align text so that it is justified across the whole line. It
  44. * is smart in the sense that it will not justify sentences
  45. * which are short
  46. *
  47. * For horizontal text, flush left and right.
  48. * For vertical text, flush top and bottom.
  49. */
  50. JUSTIFY,
  51. /**
  52. * Kashida justify low.
  53. */
  54. JUSTIFY_LOW,
  55. /**
  56. * Distribute space between characters.
  57. */
  58. DIST,
  59. /**
  60. * Thai distribution justification.
  61. */
  62. THAI_DIST
  63. }
  64. /**
  65. *
  66. */
  67. public enum FontAlign {
  68. AUTO,
  69. /**
  70. * Characters hang from top of line height.
  71. * Also known as "Hanging"
  72. */
  73. TOP,
  74. /**
  75. * Characters centered within line height.
  76. */
  77. CENTER,
  78. /**
  79. * Place characters on font baseline.
  80. * Also known as "Roman"
  81. */
  82. BASELINE,
  83. /**
  84. * Characters are anchored to the very bottom of a single line.
  85. * This is different than BASELINE because of letters such as "g", "q", and "y".
  86. * Also known as "UpholdFixed"
  87. */
  88. BOTTOM
  89. }
  90. public interface BulletStyle {
  91. String getBulletCharacter();
  92. String getBulletFont();
  93. /**
  94. * The bullet point font size
  95. * If bulletFontSize >= 0, then space is a percentage of normal line height.
  96. * If bulletFontSize < 0, the absolute value in points
  97. *
  98. * @return the bullet point font size
  99. */
  100. Double getBulletFontSize();
  101. /**
  102. * Convenience function to set a solid color
  103. */
  104. void setBulletFontColor(Color color);
  105. void setBulletFontColor(PaintStyle color);
  106. /**
  107. *
  108. * @return the color of bullet characters within a given paragraph.
  109. * A {@code null} value means to use the text font color.
  110. */
  111. PaintStyle getBulletFontColor();
  112. AutoNumberingScheme getAutoNumberingScheme();
  113. /**
  114. * Index (1-based) of the first auto number value, or null if auto numbering scheme
  115. * wasn't assigned.
  116. */
  117. Integer getAutoNumberingStartAt();
  118. }
  119. /**
  120. * The amount of vertical white space before the paragraph
  121. * This may be specified in two different ways, percentage spacing and font point spacing:
  122. * <p>
  123. * If spaceBefore >= 0, then space is a percentage of normal line height.
  124. * If spaceBefore < 0, the absolute value in points
  125. * </p>
  126. *
  127. * @return the vertical white space before the paragraph, or null if unset
  128. */
  129. Double getSpaceBefore();
  130. /**
  131. * Set the amount of vertical white space that will be present before the paragraph.
  132. * This space is specified in either percentage or points:
  133. * <p>
  134. * If spaceBefore >= 0, then space is a percentage of normal line height.
  135. * If spaceBefore < 0, the absolute value of linespacing is the spacing in points
  136. * </p>
  137. * Examples:
  138. * <pre><code>
  139. * // The paragraph will be formatted to have a spacing before the paragraph text.
  140. * // The spacing will be 200% of the size of the largest text on each line
  141. * paragraph.setSpaceBefore(200);
  142. *
  143. * // The spacing will be a size of 48 points
  144. * paragraph.setSpaceBefore(-48.0);
  145. * </code></pre>
  146. *
  147. * @param spaceBefore the vertical white space before the paragraph, null to unset
  148. */
  149. void setSpaceBefore(Double spaceBefore);
  150. /**
  151. * The amount of vertical white space after the paragraph
  152. * This may be specified in two different ways, percentage spacing and font point spacing:
  153. * <p>
  154. * If spaceBefore >= 0, then space is a percentage of normal line height.
  155. * If spaceBefore < 0, the absolute value of linespacing is the spacing in points
  156. * </p>
  157. *
  158. * @return the vertical white space after the paragraph or null, if unset
  159. */
  160. Double getSpaceAfter();
  161. /**
  162. * Set the amount of vertical white space that will be present after the paragraph.
  163. * This space is specified in either percentage or points:
  164. * <p>
  165. * If spaceAfter >= 0, then space is a percentage of normal line height.
  166. * If spaceAfter < 0, the absolute value of linespacing is the spacing in points
  167. * </p>
  168. * Examples:
  169. * <pre><code>
  170. * // The paragraph will be formatted to have a spacing after the paragraph text.
  171. * // The spacing will be 200% of the size of the largest text on each line
  172. * paragraph.setSpaceAfter(200);
  173. *
  174. * // The spacing will be a size of 48 points
  175. * paragraph.setSpaceAfter(-48.0);
  176. * </code></pre>
  177. *
  178. * @param spaceAfter the vertical white space after the paragraph, null to unset
  179. */
  180. public void setSpaceAfter(Double spaceAfter);
  181. /**
  182. * @return the left margin (in points) of the paragraph or null, if unset
  183. */
  184. Double getLeftMargin();
  185. /**
  186. * Specifies the left margin of the paragraph. This is specified in addition to the text body
  187. * inset and applies only to this text paragraph. That is the text body Inset and the LeftMargin
  188. * attributes are additive with respect to the text position.
  189. *
  190. * @param leftMargin the left margin (in points) or null to unset
  191. */
  192. void setLeftMargin(Double leftMargin);
  193. /**
  194. * Specifies the right margin of the paragraph. This is specified in addition to the text body
  195. * inset and applies only to this text paragraph. That is the text body Inset and the RightMargin
  196. * attributes are additive with respect to the text position.
  197. *
  198. * The right margin is not support and therefore ignored by the HSLF implementation.
  199. *
  200. * @return the right margin (in points) of the paragraph or null, if unset
  201. */
  202. Double getRightMargin();
  203. /**
  204. * @param rightMargin the right margin (in points) of the paragraph
  205. */
  206. void setRightMargin(Double rightMargin);
  207. /**
  208. * @return the indent (in points) applied to the first line of text in the paragraph.
  209. * or null, if unset
  210. */
  211. Double getIndent();
  212. /**
  213. * Specifies the indent size that will be applied to the first line of text in the paragraph.
  214. *
  215. * @param indent the indent (in points) applied to the first line of text in the paragraph
  216. */
  217. void setIndent(Double indent);
  218. /**
  219. * @return the text level of this paragraph (0-based). Default is 0.
  220. */
  221. int getIndentLevel();
  222. /**
  223. * Specifies the particular level text properties that this paragraph will follow.
  224. * The value for this attribute formats the text according to the corresponding level
  225. * paragraph properties defined in the SlideMaster.
  226. *
  227. * @param level the level (0 ... 4)
  228. */
  229. void setIndentLevel(int level);
  230. /**
  231. * Returns the vertical line spacing that is to be used within a paragraph.
  232. * This may be specified in two different ways, percentage spacing and font point spacing:
  233. * <p>
  234. * If linespacing >= 0, then linespacing is a percentage of normal line height.
  235. * If linespacing < 0, the absolute value of linespacing is the spacing in points
  236. * </p>
  237. *
  238. * @return the vertical line spacing or null, if unset
  239. */
  240. Double getLineSpacing();
  241. /**
  242. * This element specifies the vertical line spacing that is to be used within a paragraph.
  243. * This may be specified in two different ways, percentage spacing and font point spacing:
  244. * <p>
  245. * If linespacing >= 0, then linespacing is a percentage of normal line height
  246. * If linespacing < 0, the absolute value of linespacing is the spacing in points
  247. * </p>
  248. * Examples:
  249. * <pre><code>
  250. * // spacing will be 120% of the size of the largest text on each line
  251. * paragraph.setLineSpacing(120);
  252. *
  253. * // spacing will be 200% of the size of the largest text on each line
  254. * paragraph.setLineSpacing(200);
  255. *
  256. * // spacing will be 48 points
  257. * paragraph.setLineSpacing(-48.0);
  258. * </code></pre>
  259. *
  260. * @param lineSpacing the vertical line spacing
  261. */
  262. void setLineSpacing(Double lineSpacing);
  263. String getDefaultFontFamily();
  264. /**
  265. * @return the default font size, in case its not set in the textrun or null, if unset
  266. */
  267. Double getDefaultFontSize();
  268. /**
  269. * Returns the alignment that is applied to the paragraph.
  270. *
  271. * If this attribute is omitted, then null is returned.
  272. * User code can imply the value {@link org.apache.poi.sl.usermodel.TextParagraph.TextAlign#LEFT} then.
  273. *
  274. * @return alignment that is applied to the paragraph
  275. */
  276. TextAlign getTextAlign();
  277. /**
  278. * Specifies the alignment that is to be applied to the paragraph.
  279. * Possible values for this include left, right, centered, justified and distributed,
  280. * see {@link org.apache.poi.sl.usermodel.TextParagraph.TextAlign}.
  281. *
  282. * @param align text align
  283. */
  284. void setTextAlign(TextAlign align);
  285. /**
  286. * Returns the font alignment that is applied to the paragraph.
  287. *
  288. * If this attribute is omitted, then null is return,
  289. * user code can imply the a value of {@link FontAlign#AUTO}
  290. *
  291. * @return alignment that is applied to the paragraph
  292. */
  293. FontAlign getFontAlign();
  294. /**
  295. * @return the bullet style of the paragraph, if {@code null} then no bullets are used
  296. */
  297. BulletStyle getBulletStyle();
  298. /**
  299. * Sets the bullet styles. If no styles are given, the bullets are omitted.
  300. * Possible attributes are integer/double (bullet size), Color (bullet color),
  301. * character (bullet character), string (bullet font), AutoNumberingScheme
  302. *
  303. * @param styles
  304. */
  305. void setBulletStyle(Object... styles);
  306. /**
  307. * @return the default size for a tab character within this paragraph in points, null if unset
  308. */
  309. Double getDefaultTabSize();
  310. TextShape<S,P> getParentShape();
  311. /**
  312. * Fetch the text runs that are contained within this block of text
  313. */
  314. List<T> getTextRuns();
  315. /**
  316. * Convenience method to determine if this text paragraph is part of
  317. * the slide header or footer
  318. *
  319. * @return true if this paragraph is part of a header or footer placeholder
  320. *
  321. * @since POI 3.15-beta2
  322. */
  323. boolean isHeaderOrFooter();
  324. }