001package com.hfg.xml.msofficexml.docx.drawingml.text; 002 003import com.hfg.xml.XMLTag; 004import com.hfg.xml.msofficexml.docx.drawingml.DmlXML; 005 006//------------------------------------------------------------------------------ 007/** 008 Represents an Office Open XML drawingml text run (<a:r>) tag. 009 <div> 010 @author J. Alex Taylor, hairyfatguy.com 011 </div> 012 */ 013//------------------------------------------------------------------------------ 014// com.hfg XML/HTML Coding Library 015// 016// This library is free software; you can redistribute it and/or 017// modify it under the terms of the GNU Lesser General Public 018// License as published by the Free Software Foundation; either 019// version 2.1 of the License, or (at your option) any later version. 020// 021// This library is distributed in the hope that it will be useful, 022// but WITHOUT ANY WARRANTY; without even the implied warranty of 023// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 024// Lesser General Public License for more details. 025// 026// You should have received a copy of the GNU Lesser General Public 027// License along with this library; if not, write to the Free Software 028// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 029// 030// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 031// jataylor@hairyfatguy.com 032//------------------------------------------------------------------------------ 033 034public class DmlTextRun extends XMLTag 035{ 036 private DmlTextRunProperties mProperties; 037 038 //########################################################################### 039 // CONSTRUCTORS 040 //########################################################################### 041 042 //--------------------------------------------------------------------------- 043 public DmlTextRun() 044 { 045 super(DmlXML.TEXT_RUN); 046 } 047 048 //########################################################################### 049 // PUBLIC METHODS 050 //########################################################################### 051 052 //--------------------------------------------------------------------------- 053 /** 054 * Returns whether or not this text run has a run properties subtag. 055 */ 056 public boolean hasProperties() 057 { 058 return (getOptionalSubtagByName(DmlXML.RUN_PROPS) != null); 059 } 060 061 //--------------------------------------------------------------------------- 062 public void setProperties(DmlTextRunProperties inValue) 063 { 064 mProperties = getOptionalSubtagByName(DmlXML.RUN_PROPS); 065 if (mProperties != null) 066 { 067 removeSubtag(mProperties); 068 } 069 070 mProperties = inValue; 071 if (inValue != null) 072 { 073 addSubtag(inValue); 074 } 075 } 076 077 //--------------------------------------------------------------------------- 078 /** 079 * Returns the run properties tag if one exists or else instantiates a new one. 080 * @return the run properties for this table 081 */ 082 public DmlTextRunProperties getProperties() 083 { 084 if (null == mProperties) 085 { 086 // Check if it has been added via addSubtag()... 087 mProperties = getOptionalSubtagByName(DmlXML.RUN_PROPS); 088 if (null == mProperties) 089 { 090 mProperties = new DmlTextRunProperties(); 091 addSubtag(0, mProperties); 092 } 093 } 094 095 return mProperties; 096 } 097 098 //--------------------------------------------------------------------------- 099 public DmlTextRun addText(String inText) 100 { 101 addSubtag(new DmlText().setContent(inText)); 102 103 return this; 104 } 105 106 107 108}