Package com.nomagic.magicreport.format
Class DOCXFormatter
java.lang.Object
com.nomagic.magicreport.format.DefaultFormatter
com.nomagic.magicreport.format.DOCXFormatter
- All Implemented Interfaces:
IFormatter
The Velocity engine support for Docx.
- Since:
- Nov 16, 2009
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class com.nomagic.magicreport.format.DefaultFormatter
properties, styledDocumentFields inherited from interface com.nomagic.magicreport.format.IFormatter
DOT_PER_INCH -
Constructor Summary
ConstructorsConstructorDescriptionDOCXFormatter(ITemplateEngine templateEngine) Create a Docx formatter with specific properties.DOCXFormatter(Properties properties) Create a Docx formatter with specific properties. -
Method Summary
Modifier and TypeMethodDescriptionprotected float[]adjustImage(Image image, float w, float h, int flag) Returns [imageWidth, imageHeight, imageRotate, effectL, effectT, effectR, effectB ] the image will be rotated if necessary 914,400 EMU per inch 12,700 EMU in a point360,000 EMU per cm.protected ITool.RetainedStringcreateBookmark(Bookmark bookmark) Create a DOCX bookmark string from givenBookmarkobject.protected ITool.RetainedStringcreateChart(Chart chart) Create a DOCX chart string from givenChartobject.protected ITool.RetainedStringcreateGridRowSpan(GridRowSpan span) Create a DOCX gridrowspan (merge columns vertically) string from givenGridRowSpanobject.protected ITool.RetainedStringcreateGridSpan(GridSpan span) Create a DOCX gridspan (merge columns horizontally) string from givenGridSpanobject.protected ITool.RetainedStringcreateImage(Image image) Create a DOCX image string from givenImageobject.protected ITool.RetainedStringcreateImage(Image image, float width, float height, int flag) Create a DOCX image string from givenImageobject.protected ITool.RetainedStringcreateLink(Link link) Create a DOCX link string from givenLinkobject.protected ITool.RetainedStringcreateRef(TextReference bookmark) Create a DOCX bookmark string for REF from givenTextReferenceobject.Convert an Object value into HTML format.float[]Calculation for total paper width and total paper height after minus margin of page.protected doubleprotected doubleprotected doubleprotected doubleprotected ITool.RetainedStringhandleRef(TextReference bookmark) Handle TextReference for REF in DOCXprotected ITool.RetainedStringopenRef(TextReference bookmark) Create a DOCX ref string from givenTextReferenceobject.Methods inherited from class com.nomagic.magicreport.format.DefaultFormatter
getImageFlag, getObjectFormater, getProperties, registerObjectFormatter, setProperties, setStyledDocument, writeImage, writeImage, writeImage
-
Constructor Details
-
DOCXFormatter
Create a Docx formatter with specific properties.- Parameters:
templateEngine- template engine
-
DOCXFormatter
Create a Docx formatter with specific properties.- Parameters:
properties- template properties
-
-
Method Details
-
format
Convert an Object value into HTML format.- Specified by:
formatin interfaceIFormatter- Overrides:
formatin classDefaultFormatter- Parameters:
value- converting value- Returns:
- object in default format.
-
createImage
Create a DOCX image string from givenImageobject.- Parameters:
image- anImageobject- Returns:
- The String in DOCX image format.
- Throws:
IOException- when IO error occurs
-
createImage
protected ITool.RetainedString createImage(Image image, float width, float height, int flag) throws IOException Create a DOCX image string from givenImageobject.- Parameters:
image- anImageobjectwidth- the target image widthheight- the target image heightflag- scaling image flag- Returns:
- The String in DOCX image format.
- Throws:
IOException- when IO error occurs
-
getPageSize
public float[] getPageSize()Calculation for total paper width and total paper height after minus margin of page.- Returns:
- float[] array of paper width and paper height
-
adjustImage
Returns [imageWidth, imageHeight, imageRotate, effectL, effectT, effectR, effectB ] the image will be rotated if necessary 914,400 EMU per inch 12,700 EMU in a point360,000 EMU per cm.- Parameters:
image- image objectw- image widthh- image heightflag- scaling image flag- Returns:
- the new dimension of image
-
createBookmark
Create a DOCX bookmark string from givenBookmarkobject.- Parameters:
bookmark- anBookmarkobject- Returns:
- The String in DOCX bookmark format.
- Throws:
IOException- when IO error occurs
-
createLink
Create a DOCX link string from givenLinkobject.- Parameters:
link- anLinkobject- Returns:
- The String in DOCX link format.
- Throws:
IOException- when IO error occurs
-
handleRef
Handle TextReference for REF in DOCX- Parameters:
bookmark- anTextReferenceobject- Returns:
- The String in DOCX of bookmark or REF format.
- Throws:
IOException
-
openRef
Create a DOCX ref string from givenTextReferenceobject.- Parameters:
bookmark- anTextReferenceobject- Returns:
- The String in DOCX bookmark format.
- Throws:
IOException- when IO error occurs
-
createRef
Create a DOCX bookmark string for REF from givenTextReferenceobject.- Parameters:
bookmark- anTextReferenceobject- Returns:
- The String in DOCX bookmark for REF format.
- Throws:
IOException- when IO error occurs
-
createGridSpan
Create a DOCX gridspan (merge columns horizontally) string from givenGridSpanobject.- Parameters:
span- anGridSpanobject- Returns:
- The String in DOCX for gridspan format.
-
createChart
Create a DOCX chart string from givenChartobject.- Parameters:
span- anChartobject- Returns:
- The String in DOCX for chart format.
-
createGridRowSpan
Create a DOCX gridrowspan (merge columns vertically) string from givenGridRowSpanobject.- Parameters:
span- anGridRowSpanobject- Returns:
- The String in DOCX for gridrowspan format.
-
getPaperWidth
protected double getPaperWidth() -
getPropertyPageWidth
protected double getPropertyPageWidth() -
getPaperHeight
protected double getPaperHeight() -
getPropertyPageHeight
protected double getPropertyPageHeight()
-