Abiword文档对象初始化

本文深入探讨了Abiword文档对象初始化的过程,包括新建文档、物理存储架构初始化、片段类实例化及布局类创建等关键步骤。详细解释了如何通过PD_Document、pt_PieceTable、pf_Frag类及其子类来构建和编辑文档,以及如何在最终布局中整合这些元素。此外,还介绍了如何在文档中插入新行、块、段落运行、线条和文本运行,以及编辑文档时涉及的相关方法和类。

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

Abiword文档对象初始化

新建或开发文档

  • PD_Document类的实例化

如果是新建文档,调用PD_Document::newDocument函数创建新文档,或则调用PD_Document::readFromFile打开一个文档。

  • pt_PieceTable类的实例化,通过该类初始化文档的物理存储架构。也就是PieceTable数据结构的实现
  1. pf_Frag_Strux_Section类,该类实例化后放入pf_Fragments中。
  2. pf_Frag_Strux_Block 类,同样放入pf_Fragments中。
  3. pf_Frag 类,实例化pf_Frag::PFT_EndOfDoc的对象,表示文档结尾的片段。
  • AP_Frame::_showDocument方法
  1. 调用_createViewGraphics函数创建:GR_Graphics对象,FL_DocLayout类的实例化

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

  1. FV_View类的实例化, 调用AP_Frame::_replaceView函数
  2. FL_DocLayout::fillLayouts函数中,实例化fl_DocListener
  3. PD_Document::addListener方法将fl_DocListener对象添加到文档中
  4. pt_PieceTable::addListener,循环pf_Fragments(链表数据结构)对象,初始化对应的布局类。
  • fl_DocSectionLayout 类,该类对应pf_Frag_Strux_Section类,并且存储这个类对象的指针

该类实例化后,被添加到FL_DocLayout中。

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

  • fl_BlockLayout类,该类对应pf_Frag_Strux_Block ,并且存储这个类对象的指针

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

在fl_BlockLayout::_insertEndOfParagraphRun函数中,初始化FL_DocLayout的物理结构。

  •  fp_EndOfParagraphRun类的实例化。
  • fp_Line 类的实例化。
  • FL_DocLayout::addNewPage函数初始化fp_Page类
  • fp_Column 类实例化
  • 调用fp_VerticalContainer::insertContainer函数把fp_Line 添加到fp_Column 类中。
  • 把fp_EndOfParagraphRun对象添加到fp_Line 中

编辑文档

  •  FV_View::_charInsert函数
  1. FV_View::insertParaBreakIfNeededAtPos

            Insrts a block and returns true if the point is at the end of a 
            section or document and the previous strux is not a block

          if(!isParaBreakNeededAtPos(pos))
         {
             return false;
         }
         m_pDoc->insertStrux(pos,PTX_Block);//如果需要就插入Block
         return true;

  2.  PD_Document::insertSpan

         pt_PieceTable::_insertFmtMarkFragWithNotify, 实例化pf_Frag_FmtMark类、fp_FmtMarkRun类

         pt_PieceTable::insertSpan函数,实例化pf_Frag_Text

         通过构建PX_ChangeRecord类,调用PD_Document::notifyListeners函数,通过fl_DocListener::change方法通知fmt层数据发生变化。

         通过fl_SectionLayout,fl_BlockLayout::_doInsertTextSpan的方法,实例化fp_TextRun

 

  • 增加新行时,实例化pf_Frag_Strux_Block、fl_BlockLayout、fp_EndOfParagraphRun、fp_Line

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值