程序包 org.ddr.poi.html

类 HtmlRenderContext

java.lang.Object
com.deepoove.poi.render.RenderContext<String>
org.ddr.poi.html.HtmlRenderContext

public class HtmlRenderContext extends com.deepoove.poi.render.RenderContext<String>
HTML字符串渲染上下文
从以下版本开始:
2021-02-08
  • 构造器详细资料

    • HtmlRenderContext

      public HtmlRenderContext(com.deepoove.poi.render.RenderContext<String> context, ElementRendererProvider rendererProvider)
      构造方法
      参数:
      context - 原始渲染上下文
  • 方法详细资料

    • getContainer

      public org.apache.poi.xwpf.usermodel.IBody getContainer()
      覆盖:
      getContainer 在类中 com.deepoove.poi.render.RenderContext<String>
    • pushContainer

      public void pushContainer(org.apache.poi.xwpf.usermodel.IBody body)
      父容器入栈
      参数:
      body - 父容器
    • popContainer

      public void popContainer()
      父容器出栈
    • getClosestParagraph

      public org.apache.poi.xwpf.usermodel.XWPFParagraph getClosestParagraph()
      获取最近的段落,如果当前最近位置的内容元素是表格,则创建一个与之平级的段落
      返回:
      最近的段落
    • startHyperlink

      public void startHyperlink(String uri)
      开始渲染超链接
      参数:
      uri - 链接地址
    • endHyperlink

      public void endHyperlink()
      结束渲染超链接
    • newParagraph

      public org.apache.poi.xwpf.usermodel.XWPFParagraph newParagraph(org.apache.poi.xwpf.usermodel.IBody container, org.apache.xmlbeans.XmlCursor cursor)
      新建段落
      参数:
      container - 容器
      cursor - xml指针
      返回:
      段落
    • newRun

      public org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR newRun()
      新建CTR
      返回:
      CTR
    • getClosestTable

      public org.apache.poi.xwpf.usermodel.XWPFTable getClosestTable()
      获取最近的表格,仅可在渲染表格及其内部元素的时候使用
      返回:
      最近的表格
    • pushInlineStyle

      public void pushInlineStyle(com.steadystate.css.dom.CSSStyleDeclarationImpl inlineStyle, boolean block)
      行内样式入栈
      参数:
      inlineStyle - 样式声明
      block - 是否为块状元素
    • popInlineStyle

      public void popInlineStyle()
      行内样式出栈
    • currentElementStyle

      public com.steadystate.css.dom.CSSStyleDeclarationImpl currentElementStyle()
      当前元素的样式声明,在HTML元素渲染开始时立即调用才可得到正确的声明,因为在解析的过程中可能会动态插入样式
      返回:
      当前元素的样式声明
    • getPropertyValue

      public String getPropertyValue(String property)
      获取样式值,将被转换为小写
      参数:
      property - 样式名称
      返回:
      样式值,未声明时返回空字符串
    • getPropertyValue

      public String getPropertyValue(String property, boolean inlineOnly)
      获取样式值,将被转换为小写
      参数:
      property - 样式名称
      inlineOnly - 是否仅获取行内元素样式
      返回:
      样式值,未声明时返回空字符串
    • getPropertyValue

      public String getPropertyValue(String property, boolean caseSensitive, boolean inlineOnly)
      获取样式值
      参数:
      property - 样式名称
      caseSensitive - 是否大小写无关,如果无关则将转换为小写,否则保留原始值
      inlineOnly - 是否仅获取行内元素样式
      返回:
      样式值,未声明时返回空字符串
    • getDefaultFontSize

      public CSSLength getDefaultFontSize()
      返回:
      Word中设置的默认字号
    • getInheritedFontSizeInHalfPoints

      public int getInheritedFontSizeInHalfPoints()
      返回:
      获取当前元素继承的字号,以“半点”为单位
    • getAvailableWidthInEMU

      public int getAvailableWidthInEMU()
      返回:
      父容器的可用宽度,以EMU为单位
    • computeLengthInEMU

      public int computeLengthInEMU(String length, String maxLength, int naturalEMU, int parentEMU)
      考虑约束计算长度,以EMU为单位
      参数:
      length - 长度声明
      maxLength - 最大长度声明
      naturalEMU - 原始长度
      parentEMU - 父容器长度
      返回:
      以EMU为单位的长度值
    • computeLengthInEMU

      public int computeLengthInEMU(CSSLength cssLength, int naturalEMU, int parentEMU)
      考虑约束计算长度,以EMU为单位
      参数:
      cssLength - 长度声明
      naturalEMU - 原始长度
      parentEMU - 父容器长度
      返回:
      以EMU为单位的长度值
    • renderText

      public void renderText(String text)
      渲染文本
      参数:
      text - 文本
    • renderPicture

      public void renderPicture(InputStream pictureData, int pictureType, String filename, int width, int height, byte[] svgData) throws IOException, org.apache.poi.openxml4j.exceptions.InvalidFormatException
      渲染图片
      参数:
      pictureData - 图片数据流
      pictureType - 图片类型
      filename - 文件名
      width - 宽度
      height - 高度
      svgData - SVG数据
      抛出:
      IOException
      org.apache.poi.openxml4j.exceptions.InvalidFormatException
    • lengthToEMU

      public int lengthToEMU(CSSLength length)
      将长度换算为EMU
      参数:
      length - 长度
      返回:
      EMU
    • getNumberingContext

      public NumberingContext getNumberingContext()
    • getPageWidth

      public CSSLength getPageWidth()
    • getPageHeight

      public CSSLength getPageHeight()
    • getMarginTop

      public CSSLength getMarginTop()
    • getMarginRight

      public CSSLength getMarginRight()
    • getMarginBottom

      public CSSLength getMarginBottom()
    • getMarginLeft

      public CSSLength getMarginLeft()
    • getAvailablePageWidth

      public int getAvailablePageWidth()
    • getAvailablePageHeight

      public int getAvailablePageHeight()
    • getMathRenderConfig

      public MathRenderConfig getMathRenderConfig()
    • setMathRenderConfig

      public void setMathRenderConfig(MathRenderConfig mathRenderConfig)
    • getCurrentRun

      public org.apache.poi.xwpf.usermodel.XWPFRun getCurrentRun()
    • getGlobalFont

      public String getGlobalFont()
    • getGlobalFontSize

      public BigInteger getGlobalFontSize()
    • isShowDefaultTableBorderInTableCell

      public boolean isShowDefaultTableBorderInTableCell()
    • setShowDefaultTableBorderInTableCell

      public void setShowDefaultTableBorderInTableCell(boolean showDefaultTableBorderInTableCell)
    • setGlobalFont

      public void setGlobalFont(String globalFont)
    • setGlobalFontSize

      public void setGlobalFontSize(BigInteger globalFontSize)
    • isBlocked

      public boolean isBlocked()
    • incrementBlockLevel

      public void incrementBlockLevel()
    • decrementBlockLevel

      public void decrementBlockLevel()
    • renderDocument

      public void renderDocument(org.jsoup.nodes.Document document)
    • renderNode

      public void renderNode(org.jsoup.nodes.Node node)
    • renderElement

      public void renderElement(org.jsoup.nodes.Element element)
    • renderAsBlock

      public boolean renderAsBlock(org.jsoup.nodes.Element element)
      HTML元素是否按照块状进行渲染
      参数:
      element - HTML元素
      返回:
      是否按照块状进行渲染
    • getCssStyleDeclaration

      public com.steadystate.css.dom.CSSStyleDeclarationImpl getCssStyleDeclaration(org.jsoup.nodes.Element element)
    • pushCursor

      public void pushCursor(org.apache.xmlbeans.XmlCursor targetCursor)
      保存当前指针位置并移动到目标指针位置
      参数:
      targetCursor - 目标指针
    • popCursor

      public boolean popCursor()
      返回之前保存的指针位置
      返回:
      是否返回成功
    • currentCursorObject

      public org.apache.xmlbeans.XmlObject currentCursorObject()
      返回:
      指针当前指向的对象
    • markDedupe

      public void markDedupe(org.apache.poi.xwpf.usermodel.XWPFParagraph paragraph)
      标记段落以防止块状元素嵌套产生多余的空段落
      参数:
      paragraph - 段落
    • unmarkDedupe

      public void unmarkDedupe()
      取消段落防重标记