com.hfg.xml.msofficexml.docx.wordprocessingml.WmlInline 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.Pixels;
import com.hfg.xml.XMLTag;
import com.hfg.xml.msofficexml.docx.Docx;
import com.hfg.xml.msofficexml.docx.drawingml.DmlGraphic;
import com.hfg.xml.msofficexml.docx.drawingml.DmlXML;
/*
Sequence [1..1]
1. wp:extent [1..1] Drawing Object Size
2. wp:effectExtent [0..1] Inline Wrapping Extent
3. wp:docPr [1..1] Drawing Object Non-Visual Properties
4. wp:cNvGraphicFramePr [0..1] Common DrawingML Non-Visual Properties
5. a:graphic [1..1] Graphic Object
*/
public class WmlInline extends WmlXMLTag
{
private XMLTag mExtentTag;
private WmlEffectExtent mEffectExtentTag;
private DmlGraphic mGraphicTag;
private WmlDrawingObjNonVisualProperties mDrawingObjNonVisualProperties;
private WmlCommonDrawingMLNonVisualProperties mCommonDrawingMLNonVisualProperties;
//---------------------------------------------------------------------------
public WmlInline(Docx inDocx)
{
super(WmlXML.INLINE, inDocx);
init();
}
//---------------------------------------------------------------------------
private void init()
{
setMarginLeft(new Pixels(0));
setMarginRight(new Pixels(0));
setMarginTop(new Pixels(0));
setMarginBottom(new Pixels(0));
getEffectExtent();
}
//---------------------------------------------------------------------------
/**
* Specifies the left margin for the drawing.
*/
public WmlInline setMarginLeft(GfxSize inValue)
{
setAttribute(WmlXML.DIST_LEFT_ATT, inValue.toInt(GfxUnits.emus));
return this;
}
//---------------------------------------------------------------------------
/**
* Specifies the right margin for the drawing.
*/
public WmlInline setMarginRight(GfxSize inValue)
{
setAttribute(WmlXML.DIST_RIGHT_ATT, inValue.toInt(GfxUnits.emus));
return this;
}
//---------------------------------------------------------------------------
/**
* Specifies the top margin for the drawing.
*/
public WmlInline setMarginTop(GfxSize inValue)
{
setAttribute(WmlXML.DIST_TOP_ATT, inValue.toInt(GfxUnits.emus));
return this;
}
//---------------------------------------------------------------------------
/**
* Specifies the top margin for the drawing.
*/
public WmlInline setMarginBottom(GfxSize inValue)
{
setAttribute(WmlXML.DIST_BOTTOM_ATT, inValue.toInt(GfxUnits.emus));
return this;
}
//---------------------------------------------------------------------------
/**
* Specifies the width of the drawing.
*/
public WmlInline setWidth(GfxSize inValue)
{
getExtent().setAttribute(WmlXML.CX_ATT, inValue.toInt(GfxUnits.emus));
return this;
}
//---------------------------------------------------------------------------
/**
* Specifies the height of the drawing.
*/
public WmlInline setHeight(GfxSize inValue)
{
getExtent().setAttribute(WmlXML.CY_ATT, inValue.toInt(GfxUnits.emus));
return this;
}
//---------------------------------------------------------------------------
/**
* Returns the graphic tag if one exists or else instantiates a new one.
* @return the graphic tag for this drawing
*/
public DmlGraphic getGraphic()
{
if (null == mGraphicTag)
{
// Check if it has been added via addSubtag()...
mGraphicTag = getOptionalSubtagByName(DmlXML.GRAPHIC);
if (null == mGraphicTag)
{
mGraphicTag = new DmlGraphic(getParentDoc());
addSubtag(mGraphicTag);
}
}
return mGraphicTag;
}
//---------------------------------------------------------------------------
/**
* Returns the drawing obj non-visual properties tag if one exists or else instantiates a new one.
* @return the drawing obj non-visual properties tag for this inline
*/
public WmlDrawingObjNonVisualProperties getDrawingObjNonVisualProperties()
{
if (null == mDrawingObjNonVisualProperties)
{
// Check if it has been added via addSubtag()...
mDrawingObjNonVisualProperties = getOptionalSubtagByName(WmlXML.DRAWING_OBJ_NON_VISUAL_PROPS);
if (null == mDrawingObjNonVisualProperties)
{
mDrawingObjNonVisualProperties = new WmlDrawingObjNonVisualProperties();
addSubtag(mDrawingObjNonVisualProperties);
}
}
return mDrawingObjNonVisualProperties;
}
//---------------------------------------------------------------------------
/**
* Returns the drawingML common non-visual properties tag if one exists or else instantiates a new one.
* @return the drawingML common non-visual properties tag for this inline
*/
public WmlCommonDrawingMLNonVisualProperties getCommonDrawingMLNonVisualProperties()
{
if (null == mCommonDrawingMLNonVisualProperties)
{
// Check if it has been added via addSubtag()...
mCommonDrawingMLNonVisualProperties = getOptionalSubtagByName(WmlXML.COMMON_DRAWINGML_NON_VISUAL_PROPS);
if (null == mCommonDrawingMLNonVisualProperties)
{
mCommonDrawingMLNonVisualProperties = new WmlCommonDrawingMLNonVisualProperties();
addSubtag(mCommonDrawingMLNonVisualProperties);
}
}
return mCommonDrawingMLNonVisualProperties;
}
//---------------------------------------------------------------------------
/**
* Returns the effect extent tag if one exists or else instantiates a new one.
* @return the effect extent tag for this drawing
*/
public XMLTag getEffectExtent()
{
if (null == mEffectExtentTag)
{
// Check if it has been added via addSubtag()...
mEffectExtentTag = getOptionalSubtagByName(WmlXML.EFFECT_EXTENT);
if (null == mEffectExtentTag)
{
mEffectExtentTag = new WmlEffectExtent();
addSubtag(mEffectExtentTag);
}
}
return mEffectExtentTag;
}
//---------------------------------------------------------------------------
/**
* Returns the extent tag if one exists or else instantiates a new one.
* @return the extent tag for this drawing
*/
private XMLTag getExtent()
{
if (null == mExtentTag)
{
// Check if it has been added via addSubtag()...
mExtentTag = getOptionalSubtagByName(WmlXML.EXTENT);
if (null == mExtentTag)
{
mExtentTag = new XMLTag(WmlXML.EXTENT);
addSubtag(mExtentTag);
}
}
return mExtentTag;
}
}