Abiword中自定義字段對象流程分析
1、定義對象的id,ap_String_Id.h
dcl(FIELD_Type_Custom, "Custom") //字段所屬分類
dcl(FIELD_Custom_FieldCustom, "FieldCustom") // 字段
2、繼承fp_FieldRun類,實現自定義字段
?
3、fp_Fields.h
_FIELDTYPE(CUSTOM, AP_STRING_ID_FIELD_Type_Custom)
_FIELD(CUSTOM, AP_STRING_ID_FIELD_Custom_FieldCustom, CustomField)
4、fp_Run.h
???? 6.1. 定義_FIELD、_FIELDTYPE宏
???? 6.2.根據fp_Fields.h定義fp_FieldTypesEnum、fp_FieldsEnum枚舉
???? 6.3.根據fp_Fields.h定義fp_FieldTypeData、fp_FieldData結構數組
?
5、添加_FieldType枚舉數
???? FD_Custom
?
6、fl_BlockLayout::_doInsertFieldRun,實例化自定義字段
if(strcmp(pszType, "CustomField") == 0)
?{
??pNewRun = new fp_FieldCustomRun(this,?? blockOffset, 1);
?}
7、pf_Frag_Object::pf_Frag_Object設置自定的類型
??? if (0 == strcmp(pszType, "CustomField"))
????{
???????? fieldType = fd_Field::FD_Custom;
????}
????else
????{
????????? UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN);
??????????//Better than segfaulting I figure
??????????fieldType = fd_Field::FD_None;
?????}
8、在刪除Field時,在fp_Line::removeRun函數中做如下修改
if(pRun->getType() == FPRUN_FIELD)
?{
??getBlock()->getView()->setActiveFieldRun(NULL);
?}
????
?
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
