LibreOffice源码开发_重要数据结构
2016-07-22 13:39
351 查看
暂时记录一下,有空整理
SfxPoolItem, SfxItemPool and SfxItemSet
From object property's view, a SfxPoolItem represents one property of an object. For an example, SvxBrushItem(sub of SfxPoolItem) represents background of an object. The object can be a cell, a drawing object, etc. SvxFontHeightItem represents font size of
character. Every SfxPoolItem has a nWhich as its identity. Every object has several properties. For complex object, it may have tens of properties. For an example, Spreadsheet cell can have 53 properties. There are thousands of objects in one document. If
the document model holds every object's every properties independently, it must use huge of memory. So there is a pool to hold the SfxPoolItems, SfxItemPool. Let's take ScDocumentPool as example. A SfxItemPool can hold many designated(nWhich id is between
nStart and nEnd) SfxPoolItems. It has 2 level pointer array. The first level array is used to hold different kinds of SfxPoolItem. The second level array is used to hold different instance of one SfxPoolItem. SfxItemPool has a member pImp points to SfxItemPool_Impl
structure, which has a member ppPoolItems points to a pointer array(blue part). For ScDocumentPool, it can be considered that ScDocumentPool has a pointer array to hold SfxPoolItems which nWhich ids are from 100 to 188. Every pointer in the array points to
another structure, SfxPoolItemArray_Impl. SfxPoolItemArray_Impl has a member, pData, which points to a SfxPoolItem pointer array(green part). Every element in this array is a pointer points to real SfxPoolItem object.
The SfxPoolItems are different in the pool. When user set a property of one object, the corresponding SfxPoolItem should be set to the object. It will check whether this SfxPoolItem is existed in the pool before put it in the pool. If it is existed, it will
return a pooled SfxPoolItem to set to the object. If it is not existed, it will be added in the pool. So every SfxPoolItem object is distinct from each other. Please refer SfxItemPool::Put(const SfxPoolItem rItem, USHORT nWhich) for detail info. All obejcts'
properties are put into the pool. Because there is only one instance of SfxPoolItem for one value in the pool, and because most object has similar properties, the memory will not be taken too much though there are many objects which has many properties. The
SfxPoolItem is shared by many object. The life cycle of SfxPoolItem is not same as the related object. It uses reference count. When get one SfxPoolItem from pool to set to one object, the reference of this SfxPoolItem object should be plus one. When remove
one property from object, the reference of this SfxPoolItem object should be minus one. Please refer SfxItemPool::Put(const SfxPoolItem rItem, USHORT nWhich) and SfxItemPool::Remove(const SfxPoolItem& rItem)for detail info. SfxItemSet is a set of SfxPoolItem.
Which SfxPoolItem can be put into the set is decided when construct the SfxItemSet. SfxItemSet::_pWhichRanges is used to specify the ranges for nWhich ID. SfxItemSet::_aItems is a pointer array. Each pointer points the real SfxPoolItem object in the pool.
SfxPoolItem, SfxItemPool and SfxItemSet
From object property's view, a SfxPoolItem represents one property of an object. For an example, SvxBrushItem(sub of SfxPoolItem) represents background of an object. The object can be a cell, a drawing object, etc. SvxFontHeightItem represents font size of
character. Every SfxPoolItem has a nWhich as its identity. Every object has several properties. For complex object, it may have tens of properties. For an example, Spreadsheet cell can have 53 properties. There are thousands of objects in one document. If
the document model holds every object's every properties independently, it must use huge of memory. So there is a pool to hold the SfxPoolItems, SfxItemPool. Let's take ScDocumentPool as example. A SfxItemPool can hold many designated(nWhich id is between
nStart and nEnd) SfxPoolItems. It has 2 level pointer array. The first level array is used to hold different kinds of SfxPoolItem. The second level array is used to hold different instance of one SfxPoolItem. SfxItemPool has a member pImp points to SfxItemPool_Impl
structure, which has a member ppPoolItems points to a pointer array(blue part). For ScDocumentPool, it can be considered that ScDocumentPool has a pointer array to hold SfxPoolItems which nWhich ids are from 100 to 188. Every pointer in the array points to
another structure, SfxPoolItemArray_Impl. SfxPoolItemArray_Impl has a member, pData, which points to a SfxPoolItem pointer array(green part). Every element in this array is a pointer points to real SfxPoolItem object.
The SfxPoolItems are different in the pool. When user set a property of one object, the corresponding SfxPoolItem should be set to the object. It will check whether this SfxPoolItem is existed in the pool before put it in the pool. If it is existed, it will
return a pooled SfxPoolItem to set to the object. If it is not existed, it will be added in the pool. So every SfxPoolItem object is distinct from each other. Please refer SfxItemPool::Put(const SfxPoolItem rItem, USHORT nWhich) for detail info. All obejcts'
properties are put into the pool. Because there is only one instance of SfxPoolItem for one value in the pool, and because most object has similar properties, the memory will not be taken too much though there are many objects which has many properties. The
SfxPoolItem is shared by many object. The life cycle of SfxPoolItem is not same as the related object. It uses reference count. When get one SfxPoolItem from pool to set to one object, the reference of this SfxPoolItem object should be plus one. When remove
one property from object, the reference of this SfxPoolItem object should be minus one. Please refer SfxItemPool::Put(const SfxPoolItem rItem, USHORT nWhich) and SfxItemPool::Remove(const SfxPoolItem& rItem)for detail info. SfxItemSet is a set of SfxPoolItem.
Which SfxPoolItem can be put into the set is decided when construct the SfxItemSet. SfxItemSet::_pWhichRanges is used to specify the ranges for nWhich ID. SfxItemSet::_aItems is a pointer array. Each pointer points the real SfxPoolItem object in the pool.
相关文章推荐
- 数据结构实验之数组三:快速转置
- MySQL索引背后的数据结构及算法原理
- 复习(数据结构):栈:c语言:练习题
- 几种简单的查找和排序思想
- SDUT 3341数据结构实验之二叉树二:遍历二叉树
- 数据结构实验之数组二:稀疏矩阵
- vector用法详解
- 数据结构和算法C++语言实现:使用链表实现稀疏多项式
- hdu1010_tempter_of_the_Bone(dfs减枝)
- SDUT2117数据结构实验之链表二:逆序建立链表
- SDUT2116数据结构实验之链表一:顺序建立链表
- lintcode线段树的应用
- 数据结构 有1个人和99个僵尸,僵尸吃了人就会恢复成人类,一个人可以让两个僵尸吃,但是被僵尸吃了人就会死掉。问:最后可以活下来的人有多少个? 解
- 数据结构 打印两个有序链表的公共部分
- 数据结构 线性顺序栈
- 红黑树
- 数据结构 最大值减去最小值小于或等于num的子数组数量
- java链表的数据结构和二叉树的实现
- 数据结构基本概念
- 数据结构-串的堆分配存储