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.

XSLFTextRun.java 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  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.xslf.usermodel;
  16. import java.awt.Color;
  17. import org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException;
  18. import org.apache.poi.openxml4j.opc.PackagePart;
  19. import org.apache.poi.sl.draw.DrawPaint;
  20. import org.apache.poi.sl.usermodel.PaintStyle;
  21. import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
  22. import org.apache.poi.sl.usermodel.TextRun;
  23. import org.apache.poi.util.Beta;
  24. import org.apache.poi.xslf.model.CharacterPropertyFetcher;
  25. import org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFFillProperties;
  26. import org.apache.xmlbeans.XmlObject;
  27. import org.openxmlformats.schemas.drawingml.x2006.main.CTHyperlink;
  28. import org.openxmlformats.schemas.drawingml.x2006.main.CTRegularTextRun;
  29. import org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor;
  30. import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeStyle;
  31. import org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties;
  32. import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties;
  33. import org.openxmlformats.schemas.drawingml.x2006.main.CTTextField;
  34. import org.openxmlformats.schemas.drawingml.x2006.main.CTTextFont;
  35. import org.openxmlformats.schemas.drawingml.x2006.main.CTTextLineBreak;
  36. import org.openxmlformats.schemas.drawingml.x2006.main.CTTextNormalAutofit;
  37. import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties;
  38. import org.openxmlformats.schemas.drawingml.x2006.main.STTextStrikeType;
  39. import org.openxmlformats.schemas.drawingml.x2006.main.STTextUnderlineType;
  40. import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
  41. /**
  42. * Represents a run of text within the containing text body. The run element is the
  43. * lowest level text separation mechanism within a text body.
  44. */
  45. @Beta
  46. public class XSLFTextRun implements TextRun {
  47. private final XmlObject _r;
  48. private final XSLFTextParagraph _p;
  49. protected XSLFTextRun(XmlObject r, XSLFTextParagraph p){
  50. _r = r;
  51. _p = p;
  52. if (!(r instanceof CTRegularTextRun || r instanceof CTTextLineBreak || r instanceof CTTextField)) {
  53. throw new OpenXML4JRuntimeException("unsupported text run of type "+r.getClass());
  54. }
  55. }
  56. XSLFTextParagraph getParentParagraph(){
  57. return _p;
  58. }
  59. @Override
  60. public String getRawText(){
  61. if (_r instanceof CTTextField) {
  62. return ((CTTextField)_r).getT();
  63. } else if (_r instanceof CTTextLineBreak) {
  64. return "\n";
  65. }
  66. return ((CTRegularTextRun)_r).getT();
  67. }
  68. String getRenderableText(){
  69. if (_r instanceof CTTextField) {
  70. CTTextField tf = (CTTextField)_r;
  71. XSLFSheet sheet = _p.getParentShape().getSheet();
  72. if ("slidenum".equals(tf.getType()) && sheet instanceof XSLFSlide) {
  73. return Integer.toString(((XSLFSlide)sheet).getSlideNumber());
  74. }
  75. return tf.getT();
  76. } else if (_r instanceof CTTextLineBreak) {
  77. return "\n";
  78. }
  79. String txt = ((CTRegularTextRun)_r).getT();
  80. TextCap cap = getTextCap();
  81. StringBuffer buf = new StringBuffer();
  82. for(int i = 0; i < txt.length(); i++) {
  83. char c = txt.charAt(i);
  84. if(c == '\t') {
  85. // TODO: finish support for tabs
  86. buf.append(" ");
  87. } else {
  88. switch (cap){
  89. case ALL:
  90. buf.append(Character.toUpperCase(c));
  91. break;
  92. case SMALL:
  93. buf.append(Character.toLowerCase(c));
  94. break;
  95. default:
  96. buf.append(c);
  97. }
  98. }
  99. }
  100. return buf.toString();
  101. }
  102. @Override
  103. public void setText(String text){
  104. if (_r instanceof CTTextField) {
  105. ((CTTextField)_r).setT(text);
  106. } else if (_r instanceof CTTextLineBreak) {
  107. // ignored
  108. return;
  109. } else {
  110. ((CTRegularTextRun)_r).setT(text);
  111. }
  112. }
  113. /**
  114. * Return the text run xmlbeans object.
  115. * Depending on the type of text run, this can be {@link CTTextField},
  116. * {@link CTTextLineBreak} or usually a {@link CTRegularTextRun}
  117. *
  118. * @return the xmlbeans object
  119. */
  120. public XmlObject getXmlObject(){
  121. return _r;
  122. }
  123. @Override
  124. public void setFontColor(Color color) {
  125. setFontColor(DrawPaint.createSolidPaint(color));
  126. }
  127. @Override
  128. public void setFontColor(PaintStyle color) {
  129. if (!(color instanceof SolidPaint)) {
  130. throw new IllegalArgumentException("Currently only SolidPaint is supported!");
  131. }
  132. SolidPaint sp = (SolidPaint)color;
  133. Color c = DrawPaint.applyColorTransform(sp.getSolidColor());
  134. CTTextCharacterProperties rPr = getRPr(true);
  135. CTSolidColorFillProperties fill = rPr.isSetSolidFill() ? rPr.getSolidFill() : rPr.addNewSolidFill();
  136. XSLFColor col = new XSLFColor(fill, getParentParagraph().getParentShape().getSheet().getTheme(), fill.getSchemeClr());
  137. col.setColor(c);
  138. }
  139. @Override
  140. public PaintStyle getFontColor(){
  141. final boolean hasPlaceholder = getParentParagraph().getParentShape().getPlaceholder() != null;
  142. CharacterPropertyFetcher<PaintStyle> fetcher = new CharacterPropertyFetcher<PaintStyle>(_p.getIndentLevel()){
  143. @Override
  144. public boolean fetch(CTTextCharacterProperties props){
  145. if (props == null) {
  146. return false;
  147. }
  148. XSLFShape shape = _p.getParentShape();
  149. CTShapeStyle style = shape.getSpStyle();
  150. CTSchemeColor phClr = null;
  151. if (style != null && style.getFontRef() != null) {
  152. phClr = style.getFontRef().getSchemeClr();
  153. }
  154. XSLFFillProperties fp = XSLFPropertiesDelegate.getFillDelegate(props);
  155. XSLFSheet sheet = shape.getSheet();
  156. PackagePart pp = sheet.getPackagePart();
  157. XSLFTheme theme = sheet.getTheme();
  158. PaintStyle ps = XSLFShape.selectPaint(fp, phClr, pp, theme, hasPlaceholder);
  159. if (ps != null) {
  160. setValue(ps);
  161. return true;
  162. }
  163. return false;
  164. }
  165. };
  166. fetchCharacterProperty(fetcher);
  167. return fetcher.getValue();
  168. }
  169. @Override
  170. public void setFontSize(Double fontSize){
  171. CTTextCharacterProperties rPr = getRPr(true);
  172. if(fontSize == null) {
  173. if (rPr.isSetSz()) {
  174. rPr.unsetSz();
  175. }
  176. } else {
  177. if (fontSize < 1.0) {
  178. throw new IllegalArgumentException("Minimum font size is 1pt but was " + fontSize);
  179. }
  180. rPr.setSz((int)(100*fontSize));
  181. }
  182. }
  183. @Override
  184. public Double getFontSize(){
  185. double scale = 1;
  186. CTTextNormalAutofit afit = getParentParagraph().getParentShape().getTextBodyPr().getNormAutofit();
  187. if(afit != null) {
  188. scale = (double)afit.getFontScale() / 100000;
  189. }
  190. CharacterPropertyFetcher<Double> fetcher = new CharacterPropertyFetcher<Double>(_p.getIndentLevel()){
  191. @Override
  192. public boolean fetch(CTTextCharacterProperties props){
  193. if (props != null && props.isSetSz()) {
  194. setValue(props.getSz()*0.01);
  195. return true;
  196. }
  197. return false;
  198. }
  199. };
  200. fetchCharacterProperty(fetcher);
  201. return fetcher.getValue() == null ? null : fetcher.getValue()*scale;
  202. }
  203. /**
  204. *
  205. * @return the spacing between characters within a text run,
  206. * If this attribute is omitted than a value of 0 or no adjustment is assumed.
  207. */
  208. public double getCharacterSpacing(){
  209. CharacterPropertyFetcher<Double> fetcher = new CharacterPropertyFetcher<Double>(_p.getIndentLevel()){
  210. @Override
  211. public boolean fetch(CTTextCharacterProperties props){
  212. if (props != null && props.isSetSpc()) {
  213. setValue(props.getSpc()*0.01);
  214. return true;
  215. }
  216. return false;
  217. }
  218. };
  219. fetchCharacterProperty(fetcher);
  220. return fetcher.getValue() == null ? 0 : fetcher.getValue();
  221. }
  222. /**
  223. * Set the spacing between characters within a text run.
  224. * <p>
  225. * The spacing is specified in points. Positive values will cause the text to expand,
  226. * negative values to condense.
  227. * </p>
  228. *
  229. * @param spc character spacing in points.
  230. */
  231. public void setCharacterSpacing(double spc){
  232. CTTextCharacterProperties rPr = getRPr(true);
  233. if(spc == 0.0) {
  234. if(rPr.isSetSpc()) {
  235. rPr.unsetSpc();
  236. }
  237. } else {
  238. rPr.setSpc((int)(100*spc));
  239. }
  240. }
  241. @Override
  242. public void setFontFamily(String typeface){
  243. setFontFamily(typeface, (byte)-1, (byte)-1, false);
  244. }
  245. public void setFontFamily(String typeface, byte charset, byte pictAndFamily, boolean isSymbol){
  246. CTTextCharacterProperties rPr = getRPr(true);
  247. if(typeface == null){
  248. if(rPr.isSetLatin()) {
  249. rPr.unsetLatin();
  250. }
  251. if(rPr.isSetCs()) {
  252. rPr.unsetCs();
  253. }
  254. if(rPr.isSetSym()) {
  255. rPr.unsetSym();
  256. }
  257. } else {
  258. if(isSymbol){
  259. CTTextFont font = rPr.isSetSym() ? rPr.getSym() : rPr.addNewSym();
  260. font.setTypeface(typeface);
  261. } else {
  262. CTTextFont latin = rPr.isSetLatin() ? rPr.getLatin() : rPr.addNewLatin();
  263. latin.setTypeface(typeface);
  264. if(charset != -1) {
  265. latin.setCharset(charset);
  266. }
  267. if(pictAndFamily != -1) {
  268. latin.setPitchFamily(pictAndFamily);
  269. }
  270. }
  271. }
  272. }
  273. @Override
  274. public String getFontFamily(){
  275. final XSLFTheme theme = _p.getParentShape().getSheet().getTheme();
  276. CharacterPropertyFetcher<String> visitor = new CharacterPropertyFetcher<String>(_p.getIndentLevel()){
  277. @Override
  278. public boolean fetch(CTTextCharacterProperties props){
  279. if (props != null) {
  280. CTTextFont font = props.getLatin();
  281. if (font != null) {
  282. String typeface = font.getTypeface();
  283. if("+mj-lt".equals(typeface)) {
  284. typeface = theme.getMajorFont();
  285. } else if ("+mn-lt".equals(typeface)){
  286. typeface = theme.getMinorFont();
  287. }
  288. setValue(typeface);
  289. return true;
  290. }
  291. }
  292. return false;
  293. }
  294. };
  295. fetchCharacterProperty(visitor);
  296. return visitor.getValue();
  297. }
  298. @Override
  299. public byte getPitchAndFamily(){
  300. // final XSLFTheme theme = _p.getParentShape().getSheet().getTheme();
  301. CharacterPropertyFetcher<Byte> visitor = new CharacterPropertyFetcher<Byte>(_p.getIndentLevel()){
  302. @Override
  303. public boolean fetch(CTTextCharacterProperties props){
  304. if (props != null) {
  305. CTTextFont font = props.getLatin();
  306. if (font != null) {
  307. setValue(font.getPitchFamily());
  308. return true;
  309. }
  310. }
  311. return false;
  312. }
  313. };
  314. fetchCharacterProperty(visitor);
  315. return visitor.getValue() == null ? 0 : visitor.getValue();
  316. }
  317. @Override
  318. public void setStrikethrough(boolean strike) {
  319. getRPr(true).setStrike(strike ? STTextStrikeType.SNG_STRIKE : STTextStrikeType.NO_STRIKE);
  320. }
  321. @Override
  322. public boolean isStrikethrough() {
  323. CharacterPropertyFetcher<Boolean> fetcher = new CharacterPropertyFetcher<Boolean>(_p.getIndentLevel()){
  324. @Override
  325. public boolean fetch(CTTextCharacterProperties props){
  326. if(props != null && props.isSetStrike()) {
  327. setValue(props.getStrike() != STTextStrikeType.NO_STRIKE);
  328. return true;
  329. }
  330. return false;
  331. }
  332. };
  333. fetchCharacterProperty(fetcher);
  334. return fetcher.getValue() == null ? false : fetcher.getValue();
  335. }
  336. @Override
  337. public boolean isSuperscript() {
  338. CharacterPropertyFetcher<Boolean> fetcher = new CharacterPropertyFetcher<Boolean>(_p.getIndentLevel()){
  339. @Override
  340. public boolean fetch(CTTextCharacterProperties props){
  341. if (props != null && props.isSetBaseline()) {
  342. setValue(props.getBaseline() > 0);
  343. return true;
  344. }
  345. return false;
  346. }
  347. };
  348. fetchCharacterProperty(fetcher);
  349. return fetcher.getValue() == null ? false : fetcher.getValue();
  350. }
  351. /**
  352. * Set the baseline for both the superscript and subscript fonts.
  353. * <p>
  354. * The size is specified using a percentage.
  355. * Positive values indicate superscript, negative values indicate subscript.
  356. * </p>
  357. *
  358. * @param baselineOffset
  359. */
  360. public void setBaselineOffset(double baselineOffset){
  361. getRPr(true).setBaseline((int) baselineOffset * 1000);
  362. }
  363. /**
  364. * Set whether the text in this run is formatted as superscript.
  365. * Default base line offset is 30%
  366. *
  367. * @see #setBaselineOffset(double)
  368. */
  369. public void setSuperscript(boolean flag){
  370. setBaselineOffset(flag ? 30. : 0.);
  371. }
  372. /**
  373. * Set whether the text in this run is formatted as subscript.
  374. * Default base line offset is -25%.
  375. *
  376. * @see #setBaselineOffset(double)
  377. */
  378. public void setSubscript(boolean flag){
  379. setBaselineOffset(flag ? -25.0 : 0.);
  380. }
  381. @Override
  382. public boolean isSubscript() {
  383. CharacterPropertyFetcher<Boolean> fetcher = new CharacterPropertyFetcher<Boolean>(_p.getIndentLevel()){
  384. @Override
  385. public boolean fetch(CTTextCharacterProperties props){
  386. if (props != null && props.isSetBaseline()) {
  387. setValue(props.getBaseline() < 0);
  388. return true;
  389. }
  390. return false;
  391. }
  392. };
  393. fetchCharacterProperty(fetcher);
  394. return fetcher.getValue() == null ? false : fetcher.getValue();
  395. }
  396. /**
  397. * @return whether a run of text will be formatted as a superscript text. Default is false.
  398. */
  399. @Override
  400. public TextCap getTextCap() {
  401. CharacterPropertyFetcher<TextCap> fetcher = new CharacterPropertyFetcher<TextCap>(_p.getIndentLevel()){
  402. @Override
  403. public boolean fetch(CTTextCharacterProperties props){
  404. if (props != null && props.isSetCap()) {
  405. int idx = props.getCap().intValue() - 1;
  406. setValue(TextCap.values()[idx]);
  407. return true;
  408. }
  409. return false;
  410. }
  411. };
  412. fetchCharacterProperty(fetcher);
  413. return fetcher.getValue() == null ? TextCap.NONE : fetcher.getValue();
  414. }
  415. @Override
  416. public void setBold(boolean bold){
  417. getRPr(true).setB(bold);
  418. }
  419. @Override
  420. public boolean isBold(){
  421. CharacterPropertyFetcher<Boolean> fetcher = new CharacterPropertyFetcher<Boolean>(_p.getIndentLevel()){
  422. @Override
  423. public boolean fetch(CTTextCharacterProperties props){
  424. if (props != null && props.isSetB()) {
  425. setValue(props.getB());
  426. return true;
  427. }
  428. return false;
  429. }
  430. };
  431. fetchCharacterProperty(fetcher);
  432. return fetcher.getValue() == null ? false : fetcher.getValue();
  433. }
  434. @Override
  435. public void setItalic(boolean italic){
  436. getRPr(true).setI(italic);
  437. }
  438. @Override
  439. public boolean isItalic(){
  440. CharacterPropertyFetcher<Boolean> fetcher = new CharacterPropertyFetcher<Boolean>(_p.getIndentLevel()){
  441. @Override
  442. public boolean fetch(CTTextCharacterProperties props){
  443. if (props != null && props.isSetI()) {
  444. setValue(props.getI());
  445. return true;
  446. }
  447. return false;
  448. }
  449. };
  450. fetchCharacterProperty(fetcher);
  451. return fetcher.getValue() == null ? false : fetcher.getValue();
  452. }
  453. @Override
  454. public void setUnderlined(boolean underline) {
  455. getRPr(true).setU(underline ? STTextUnderlineType.SNG : STTextUnderlineType.NONE);
  456. }
  457. @Override
  458. public boolean isUnderlined(){
  459. CharacterPropertyFetcher<Boolean> fetcher = new CharacterPropertyFetcher<Boolean>(_p.getIndentLevel()){
  460. @Override
  461. public boolean fetch(CTTextCharacterProperties props){
  462. if (props != null && props.isSetU()) {
  463. setValue(props.getU() != STTextUnderlineType.NONE);
  464. return true;
  465. }
  466. return false;
  467. }
  468. };
  469. fetchCharacterProperty(fetcher);
  470. return fetcher.getValue() == null ? false : fetcher.getValue();
  471. }
  472. /**
  473. * Return the character properties
  474. *
  475. * @param create if true, create an empty character properties object if it doesn't exist
  476. * @return the character properties or null if create was false and the properties haven't exist
  477. */
  478. protected CTTextCharacterProperties getRPr(boolean create) {
  479. if (_r instanceof CTTextField) {
  480. CTTextField tf = (CTTextField)_r;
  481. if (tf.isSetRPr()) {
  482. return tf.getRPr();
  483. } else if (create) {
  484. return tf.addNewRPr();
  485. }
  486. } else if (_r instanceof CTTextLineBreak) {
  487. CTTextLineBreak tlb = (CTTextLineBreak)_r;
  488. if (tlb.isSetRPr()) {
  489. return tlb.getRPr();
  490. } else if (create) {
  491. return tlb.addNewRPr();
  492. }
  493. } else {
  494. CTRegularTextRun tr = (CTRegularTextRun)_r;
  495. if (tr.isSetRPr()) {
  496. return tr.getRPr();
  497. } else if (create) {
  498. return tr.addNewRPr();
  499. }
  500. }
  501. return null;
  502. }
  503. @Override
  504. public String toString(){
  505. return "[" + getClass() + "]" + getRawText();
  506. }
  507. @Override
  508. public XSLFHyperlink createHyperlink(){
  509. XSLFHyperlink hl = getHyperlink();
  510. if (hl != null) {
  511. return hl;
  512. }
  513. CTTextCharacterProperties rPr = getRPr(true);
  514. return new XSLFHyperlink(rPr.addNewHlinkClick(), _p.getParentShape().getSheet());
  515. }
  516. @Override
  517. public XSLFHyperlink getHyperlink(){
  518. CTTextCharacterProperties rPr = getRPr(false);
  519. if (rPr == null) {
  520. return null;
  521. }
  522. CTHyperlink hl = rPr.getHlinkClick();
  523. if (hl == null) {
  524. return null;
  525. }
  526. return new XSLFHyperlink(hl, _p.getParentShape().getSheet());
  527. }
  528. private boolean fetchCharacterProperty(CharacterPropertyFetcher<?> fetcher){
  529. XSLFTextShape shape = _p.getParentShape();
  530. XSLFSheet sheet = shape.getSheet();
  531. CTTextCharacterProperties rPr = getRPr(false);
  532. if (rPr != null && fetcher.fetch(rPr)) {
  533. return true;
  534. }
  535. if (shape.fetchShapeProperty(fetcher)) {
  536. return true;
  537. }
  538. CTPlaceholder ph = shape.getCTPlaceholder();
  539. if (ph == null){
  540. // if it is a plain text box then take defaults from presentation.xml
  541. @SuppressWarnings("resource")
  542. XMLSlideShow ppt = sheet.getSlideShow();
  543. // TODO: determine master shape
  544. CTTextParagraphProperties themeProps = ppt.getDefaultParagraphStyle(_p.getIndentLevel());
  545. if (themeProps != null && fetcher.fetch(themeProps)) {
  546. return true;
  547. }
  548. }
  549. // TODO: determine master shape
  550. CTTextParagraphProperties defaultProps = _p.getDefaultMasterStyle();
  551. if(defaultProps != null && fetcher.fetch(defaultProps)) {
  552. return true;
  553. }
  554. return false;
  555. }
  556. void copy(XSLFTextRun r){
  557. String srcFontFamily = r.getFontFamily();
  558. if(srcFontFamily != null && !srcFontFamily.equals(getFontFamily())){
  559. setFontFamily(srcFontFamily);
  560. }
  561. PaintStyle srcFontColor = r.getFontColor();
  562. if(srcFontColor != null && !srcFontColor.equals(getFontColor())){
  563. setFontColor(srcFontColor);
  564. }
  565. double srcFontSize = r.getFontSize();
  566. if(srcFontSize != getFontSize()){
  567. setFontSize(srcFontSize);
  568. }
  569. boolean bold = r.isBold();
  570. if(bold != isBold()) {
  571. setBold(bold);
  572. }
  573. boolean italic = r.isItalic();
  574. if(italic != isItalic()) {
  575. setItalic(italic);
  576. }
  577. boolean underline = r.isUnderlined();
  578. if(underline != isUnderlined()) {
  579. setUnderlined(underline);
  580. }
  581. boolean strike = r.isStrikethrough();
  582. if(strike != isStrikethrough()) {
  583. setStrikethrough(strike);
  584. }
  585. }
  586. @Override
  587. public FieldType getFieldType() {
  588. if (_r instanceof CTTextField) {
  589. CTTextField tf = (CTTextField)_r;
  590. if ("slidenum".equals(tf.getType())) {
  591. return FieldType.SLIDE_NUMBER;
  592. }
  593. }
  594. return null;
  595. }
  596. }