com.hfg.xml.msofficexml.docx.wordprocessingml.WmlTable 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;
// Section 17.4 (pg. 364) of Ecma Office Open XML Part 1
import com.hfg.graphics.units.GfxSize;
import com.hfg.graphics.units.GfxUnits;
import com.hfg.xml.XMLTag;
import com.hfg.xml.msofficexml.docx.Docx;
import java.util.ArrayList;
import java.util.List;
public class WmlTable extends WmlXMLTag
{
private WmlTableProperties mTableProps;
private XMLTag mTableGrid;
//---------------------------------------------------------------------------
public WmlTable(Docx inDocx)
{
super(WmlXML.TABLE, inDocx);
}
//---------------------------------------------------------------------------
/**
* Returns the table properties tag if one exists or else instantiates a new one.
* @return the table properties for this table
*/
public WmlTableProperties getTableProperties()
{
if (null == mTableProps)
{
// Check it it has been added via addSubtag()...
mTableProps = (WmlTableProperties) getOptionalSubtagByName(WmlXML.TABLE_PROPS);
if (null == mTableProps)
{
mTableProps = new WmlTableProperties();
addSubtag(mTableProps);
}
}
return mTableProps;
}
//---------------------------------------------------------------------------
public WmlTable defineColumn(GfxSize inSize)
{
if (null == mTableGrid)
{
mTableGrid = new XMLTag(WmlXML.TABLE_GRID);
addSubtag(mTableGrid);
}
XMLTag colTag = new XMLTag(WmlXML.GRID_COL);
colTag.setAttribute(WmlXML.WIDTH_ATT, inSize.toInt(GfxUnits.dxa));
mTableGrid.addSubtag(colTag);
return this;
}
//---------------------------------------------------------------------------
/**
* Generates a new table row.
*/
public WmlTableRow addRow()
{
WmlTableRow row = new WmlTableRow(getParentDoc());
addSubtag(row);
return row;
}
//---------------------------------------------------------------------------
/**
* Returns the table rows.
*/
public List getRows()
{
return getSubtagsByName(WmlXML.TABLE_ROW);
}
}