Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

XDDFParagraphBulletProperties.java 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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.xddf.usermodel.text;
  16. import org.apache.poi.common.usermodel.fonts.FontGroup;
  17. import org.apache.poi.util.Beta;
  18. import org.apache.poi.util.Internal;
  19. import org.apache.poi.xddf.usermodel.XDDFColor;
  20. import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties;
  21. @Beta
  22. public class XDDFParagraphBulletProperties {
  23. private CTTextParagraphProperties props;
  24. @Internal
  25. protected XDDFParagraphBulletProperties(CTTextParagraphProperties properties) {
  26. this.props = properties;
  27. }
  28. public XDDFBulletStyle getBulletStyle() {
  29. if (props.isSetBuAutoNum()) {
  30. return new XDDFBulletStyleAutoNumbered(props.getBuAutoNum());
  31. } else if (props.isSetBuBlip()) {
  32. return new XDDFBulletStylePicture(props.getBuBlip());
  33. } else if (props.isSetBuChar()) {
  34. return new XDDFBulletStyleCharacter(props.getBuChar());
  35. } else if (props.isSetBuNone()) {
  36. return new XDDFBulletStyleNone(props.getBuNone());
  37. } else {
  38. return null;
  39. }
  40. }
  41. public void setBulletStyle(XDDFBulletStyle style) {
  42. if (props.isSetBuAutoNum()) {
  43. props.unsetBuAutoNum();
  44. }
  45. if (props.isSetBuBlip()) {
  46. props.unsetBuBlip();
  47. }
  48. if (props.isSetBuChar()) {
  49. props.unsetBuChar();
  50. }
  51. if (props.isSetBuNone()) {
  52. props.unsetBuNone();
  53. }
  54. if (style != null) {
  55. if (style instanceof XDDFBulletStyleAutoNumbered) {
  56. props.setBuAutoNum(((XDDFBulletStyleAutoNumbered) style).getXmlObject());
  57. } else if (style instanceof XDDFBulletStyleCharacter) {
  58. props.setBuChar(((XDDFBulletStyleCharacter) style).getXmlObject());
  59. } else if (style instanceof XDDFBulletStyleNone) {
  60. props.setBuNone(((XDDFBulletStyleNone) style).getXmlObject());
  61. } else if (style instanceof XDDFBulletStylePicture) {
  62. props.setBuBlip(((XDDFBulletStylePicture) style).getXmlObject());
  63. }
  64. }
  65. }
  66. public XDDFColor getBulletColor() {
  67. if (props.isSetBuClr()) {
  68. return XDDFColor.forColorContainer(props.getBuClr());
  69. } else {
  70. return null;
  71. }
  72. }
  73. public void setBulletColor(XDDFColor color) {
  74. if (props.isSetBuClrTx()) {
  75. props.unsetBuClrTx();
  76. }
  77. if (color == null) {
  78. if (props.isSetBuClr()) {
  79. props.unsetBuClr();
  80. }
  81. } else {
  82. props.setBuClr(color.getColorContainer());
  83. }
  84. }
  85. public void setBulletColorFollowText() {
  86. if (props.isSetBuClr()) {
  87. props.unsetBuClr();
  88. }
  89. if (props.isSetBuClrTx()) {
  90. // nothing to do: already set
  91. } else {
  92. props.addNewBuClrTx();
  93. }
  94. }
  95. public XDDFFont getBulletFont() {
  96. if (props.isSetBuFont()) {
  97. return new XDDFFont(FontGroup.SYMBOL, props.getBuFont());
  98. } else {
  99. return null;
  100. }
  101. }
  102. public void setBulletFont(XDDFFont font) {
  103. if (props.isSetBuFontTx()) {
  104. props.unsetBuFontTx();
  105. }
  106. if (font == null) {
  107. if (props.isSetBuFont()) {
  108. props.unsetBuFont();
  109. }
  110. } else {
  111. props.setBuFont(font.getXmlObject());
  112. }
  113. }
  114. public void setBulletFontFollowText() {
  115. if (props.isSetBuFont()) {
  116. props.unsetBuFont();
  117. }
  118. if (props.isSetBuFontTx()) {
  119. // nothing to do: already set
  120. } else {
  121. props.addNewBuFontTx();
  122. }
  123. }
  124. public XDDFBulletSize getBulletSize() {
  125. if (props.isSetBuSzPct()) {
  126. return new XDDFBulletSizePercent(props.getBuSzPct(), null);
  127. } else if (props.isSetBuSzPts()) {
  128. return new XDDFBulletSizePoints(props.getBuSzPts());
  129. } else if (props.isSetBuSzTx()) {
  130. return new XDDFBulletSizeFollowText(props.getBuSzTx());
  131. } else {
  132. return null;
  133. }
  134. }
  135. public void setBulletSize(XDDFBulletSize size) {
  136. if (props.isSetBuSzPct()) {
  137. props.unsetBuSzPct();
  138. }
  139. if (props.isSetBuSzPts()) {
  140. props.unsetBuSzPts();
  141. }
  142. if (props.isSetBuSzTx()) {
  143. props.unsetBuSzTx();
  144. }
  145. if (size != null) {
  146. if (size instanceof XDDFBulletSizeFollowText) {
  147. props.setBuSzTx(((XDDFBulletSizeFollowText) size).getXmlObject());
  148. } else if (size instanceof XDDFBulletSizePercent) {
  149. props.setBuSzPct(((XDDFBulletSizePercent) size).getXmlObject());
  150. } else if (size instanceof XDDFBulletSizePoints) {
  151. props.setBuSzPts(((XDDFBulletSizePoints) size).getXmlObject());
  152. }
  153. }
  154. }
  155. public void clearAll() {
  156. if (props.isSetBuAutoNum()) {
  157. props.unsetBuAutoNum();
  158. }
  159. if (props.isSetBuBlip()) {
  160. props.unsetBuBlip();
  161. }
  162. if (props.isSetBuChar()) {
  163. props.unsetBuChar();
  164. }
  165. if (props.isSetBuNone()) {
  166. props.unsetBuNone();
  167. }
  168. if (props.isSetBuClr()) {
  169. props.unsetBuClr();
  170. }
  171. if (props.isSetBuClrTx()) {
  172. props.unsetBuClrTx();
  173. }
  174. if (props.isSetBuFont()) {
  175. props.unsetBuFont();
  176. }
  177. if (props.isSetBuFontTx()) {
  178. props.unsetBuFontTx();
  179. }
  180. if (props.isSetBuSzPct()) {
  181. props.unsetBuSzPct();
  182. }
  183. if (props.isSetBuSzPts()) {
  184. props.unsetBuSzPts();
  185. }
  186. if (props.isSetBuSzTx()) {
  187. props.unsetBuSzTx();
  188. }
  189. }
  190. public CTTextParagraphProperties getXmlObject() {
  191. return props;
  192. }
  193. }