abiword的属性/样式初始化

属性/样式初始化【转】

一、PP_AttrProp类
   1、类功能说明,代表了一个相同类型的属性/样式集合
   PP_AttrProp captures the complete set of XML and CSS
   Attributes/Properties for a piece of the document.
   These are generally created by the file-reader.  Attributes
   represent all of the attribute/value pairs in the XML with
   the exception of the PT_PROPS_ATTRIBUTE_NAME attribute.
   The value of the this attribute is parsed into CSS properties.
   PP_AttrProp just provides a pair of association lists
   (one for attributes and one for properties), it does not
   know the meaning of any of them.
二、pp_TableAttrProp类
   1、代表一个数组,数组中的元素类型是PP_AttrProp对象的指针。

三、pt_VarSet类
   1、存储文档数据
      UT_GrowBuf         m_buffer[2];--存储字符、图片等数据
      pp_TableAttrProp  m_tableAttrProp[2];--存储属性/样式
      0代表读取的数据,1代表编辑时插入的数据

四、初始化流程
   1、pt_VarSet::_finishConstruction函数初始化m_tableAttrProp数组,分别存入索引值为0的PP_AttrProp对象
   2、pt_PieceTable::_loadBuiltinStyles函数构建不同名字的属性/样式,将数据存入m_tableAttrProp[0]中,
      索引值从1开始
   3、根据PP_AttrProp的实例的索引构建PD_Style对象
   3、在PD_Document::setAttrProp函数初始化文档的属性/样式

五、输入文字时属性/样式处理流程
   1、pp_Author对象的初始化
   2、在pt_PieceTable::createAndSendDocPropCR函数中,初始化文档的样式,创建PP_AttrProp实例
   3、在PD_Document::addAuthorAttributeIfBlank函数中,初始化一个静态的PP_AttrProp实例(0x80000001),设      置属性是PT_AUTHOR_NAME宏。可以替换为:author 字符串。
   4、在pt_PieceTable::_insertFmtMarkFragWithNotify函数中,构建一个具有author 属性的PP_AttrProp实例        (0x80000002),如果是插入后面(如第二个字符),前面四步不在执行。
   5、在pt_PieceTable::_realInsertSpan中,可以根据pf_Frag_FmtMark实例获取PT_AttrPropIndex的值,根据该       值可以获取PP_AttrProp实例,插入pf_Frag_Text对象实例。如果是插入后面(如第二个字符),该                 pf_Frag_Text对象的属性/样式继承他前面的对象样式
   6、在pf_Frag_Text构造函数中,调用lookupProperties函数,设置字体的样式。
      6.1、display、bgcolor样式的设置。在PP_lookupProperty函数中,查找系统定义的static PP_Property     _props[]数组中该样式的值。返回PP_Property指针对象。
      
      6.2、根据pf_Frag对象实例的pSpanAttrProp查找样式的值,如果找不到继续
      6.3、根据fl_BlockLayout对象实例的pBlockAttrProp查找样式的值,如果找不到继续
      6.4、获取Normal样式对象PD_Style查找样式的值,如果找不到继续
      6.5、获取文档对象的PP_AttrProp实例查找样式的值,如果找不到继续
      6.6、继承PP_Property对象的值
   7、FL_DocLayout::findFont设置字体,查找样式的方式参考第6步。
   
六、改变系统的字体样式
   1、当改变当前编辑的字体样式时(比如:字体的大小),系统会按第五步的前5步添加pf_Frag_FmtMark对象

原文地址:https://www.cnblogs.com/songtzu/p/3539765.html