Abiword的页面展示模型

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. 

posted @ 2014-02-07 17:21  songtzu  阅读(357)  评论(0编辑  收藏  举报