com.hfg.xml.msofficexml.docx.wordprocessingml.WmlTab Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com_hfg Show documentation
Show all versions of com_hfg Show documentation
com.hfg xml, html, svg, and bioinformatics utility library
package com.hfg.xml.msofficexml.docx.wordprocessingml;
import com.hfg.graphics.units.GfxSize;
import com.hfg.graphics.units.GfxUnits;
import com.hfg.graphics.units.Twips;
import com.hfg.util.StringUtil;
import com.hfg.xml.msofficexml.docx.Docx;
//------------------------------------------------------------------------------
/**
Represents an Office Open XML tab (<w:tab>) tag.
Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference § 17.3.1.37 and § 17.3.1.38
@author J. Alex Taylor, hairyfatguy.com
*/
//------------------------------------------------------------------------------
// com.hfg XML/HTML Coding Library
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
// [email protected]
//------------------------------------------------------------------------------
public class WmlTab extends WmlXMLTag
{
//##########################################################################
// CONSTRUCTORS
//##########################################################################
//---------------------------------------------------------------------------
public WmlTab(Docx inDocx)
{
super(WmlXML.TAB, inDocx);
}
//##########################################################################
// PUBLIC METHODS
//##########################################################################
//---------------------------------------------------------------------------
/**
Specifies the position of the tab.
* @param inValue position specified in arbitrary units
* @return this tab object to enable method chaining.
*/
public WmlTab setPosition(GfxSize inValue)
{
setAttribute(WmlXML.POSITION_ATT, inValue.toInt(GfxUnits.dxa));
return this;
}
//---------------------------------------------------------------------------
public GfxSize getPosition()
{
String stringValue = getAttributeValue(WmlXML.POSITION_ATT);
GfxSize width = null;
if (StringUtil.isSet(stringValue))
{
width = new Twips(Integer.parseInt(stringValue));
}
return width;
}
//---------------------------------------------------------------------------
/**
Specifies the character used to fill in the space created by the tab. Optional.
Defaults to 'none'.
* @param inValue a WmlTabLeader value
* @return this tab object to enable method chaining.
*/
public WmlTab setTabLeader(WmlTabLeader inValue)
{
if (inValue != null)
{
setAttribute(WmlXML.LEADER_ATT, inValue.name());
}
else
{
removeAttribute(WmlXML.LEADER_ATT);
}
return this;
}
//---------------------------------------------------------------------------
public WmlTabLeader getTabLeader()
{
String stringValue = getAttributeValue(WmlXML.LEADER_ATT);
WmlTabLeader tabLeader = null;
if (StringUtil.isSet(stringValue))
{
tabLeader = WmlTabLeader.valueOf(stringValue);
}
return tabLeader;
}
//---------------------------------------------------------------------------
/**
Specifies the style for the tab.
* @param inValue a WmlTabStyle value
* @return this tab object to enable method chaining.
*/
public WmlTab setTabStyle(WmlTabStyle inValue)
{
if (inValue != null)
{
setAttribute(WmlXML.VALUE_ATT, inValue.name());
}
else
{
removeAttribute(WmlXML.VALUE_ATT);
}
return this;
}
//---------------------------------------------------------------------------
public WmlTabStyle getTabStyle()
{
String stringValue = getAttributeValue(WmlXML.VALUE_ATT);
WmlTabStyle tabStyle = null;
if (StringUtil.isSet(stringValue))
{
tabStyle = WmlTabStyle.valueOf(stringValue);
}
return tabStyle;
}
}