Abiword的页面展示模型

本文介绍了文本模型(TextModel)的概念及其实现策略,包括树形结构和平面结构,并解释了如何通过TextModelCoords进行定位。此外,还详细阐述了FL_DocLayout类的功能及其在文档逻辑结构与物理布局之间的映射。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Text Model 存储文本以及相应属性的模型,主要有两种不同的实现策略:树形结构和平面结构。树形结构类似 Dom,可以很好的表现结构化文档,但是比较复杂。平面结构相对简单的多,大多数的编辑器(e.g. Emacs),字处理器(e.g. AbiWord, OpenOffice)都用的是平面结构。

Text Model Coords 用来在 Text Model 中定位的坐标系。对于树形结构的 Text Model 其定位方式为节点链接(或指向节点的路径 e.g. XPath)以及节点内偏移值。对于平面结构则仅仅是一个索引值。

Text Presentation 展示文本的模型,一般分别为 Block, Line, Run …

Text Presentation Coords 用来在 Text Presentation 中定位的坐标系,其值通常为 (x,y)。Text Editor 必须能够在 Text Model Coords 和 Text Presentation Coords 之间变换。例如将鼠标点击(x,y)对应到 Text Model 中的某个字符/元素。由fp_Page::mapXYToPosition成员函数实现

FL_DocLayout 类:

page fmt_overview Formatter

    FL_DocLayout is a formatted representation of a specific PD_Document, 
    formatted for a specific GR_Graphics context. 

    A %FL_DocLayout encapsulates two related hierarchies of objects. 

    The logical (or content) hierarchy corresponds
    to the logical structure of the document.

        - each FL_DocLayout contains a list of fl_SectionLayout objects
        - each fl_SectionLayout are composed of fl_BlockLayout objects

    Where each fl_BlockLayout corresponds to a logical element in
    the PD_Document (i.e., usually a paragraph of text).

    The physical (or layout) hierarchy, by contrast,
    encapsulates the subdivision of physical space into objects of
    successively finer granularity.

        - each FL_DocLayout contains a list of fp_Page objects, each
          of which was constructed during the process of formatting
          the document
        - each fp_Page is a list of fp_Columns (fp_Column)
        - each fp_Column is a list of fp_Lines (fp_Line)
        - each fp_Line is a list of fp_Runs (fp_Run)

    Where each fp_Run contains some fragment of content from the original 
    document, usually text. 

转载于:https://www.cnblogs.com/songtzu/p/3539734.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值