<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.openoffice.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Leiw</id>
	<title>Apache OpenOffice Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.openoffice.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Leiw"/>
	<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/wiki/Special:Contributions/Leiw"/>
	<updated>2026-05-25T12:02:48Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.14</generator>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Formula_cell_and_cells_dependence&amp;diff=209463</id>
		<title>Calc/Implementation/Formula cell and cells dependence</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Formula_cell_and_cells_dependence&amp;diff=209463"/>
		<updated>2012-11-08T10:08:57Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
Calculation is the most important feature for Spreadsheet. There are many formulas to help user to complete some work. User can use formula to calculate literal data. For an example, &amp;quot;=SUM(1;2)&amp;quot;. But in most cases, users use formula to calculate data stored in other cells. For an example, &amp;quot;=SUM(A1;D3)&amp;quot;. When the data is changed in one cell, the formula cell which references this cell need be notified to recalculate to reflect the new value. How this happens? Broadcast and Listener.&lt;br /&gt;
&lt;br /&gt;
== 1. Reference single cell ==&lt;br /&gt;
&lt;br /&gt;
It is a typical broadcaster and listener relationship when a formula cell reference a single cell. For an example, B2 is a formula cell(=A1+B1), which reference cell A1 and B1 directly.&lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_1.png]]&lt;br /&gt;
&lt;br /&gt;
ScBaseCell is the basic class for any cell. A cell can be a value cell, string cell, formula cell, etc. Only formula cell need listen to other cells. A ScFormulaCell is a listener. A ScBaseCell has a broadcaster. It takes ownership of the broadcaster.&lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_2.png]]&lt;br /&gt;
&lt;br /&gt;
1.1 establish the broadcaster and listener relationship&lt;br /&gt;
&lt;br /&gt;
A cell does not need have a broadcaster if it is not referenced by any other formula cell. After a formula cell is created, the formula cell tries to listen the cells which is referenced by it directly when it is inserting in the column. In ScColumn::Insert() method, it calls ScBaseCell::StartListeningTo() method, in which it analyze the reference address of a formula. For single reference address, ScFormulaCell does not try to get the referenced cell from address directly and listen to it. The reason is that the referenced cell may not existed, such as B1. So ScFormulaCell calls ScDocument::StartListeningCell(). At last, ScColumn::StartListening() is called, which can create a empty cell(ScNoteCell) if the referenced cell is not existed, and establish broadcaster and listener relationship. &lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_3.png]]&lt;br /&gt;
&lt;br /&gt;
So there are two kinds of ScNoteCell. One is an empty cell with comments. The other is an empty cell which is referenced by other formula cell directly. This is also the reason why use ScNoteCell to replace a normal cell when deleting a cell from a column if this cell has a broadcaster. Please refer ScColumn::Delete(SCROW) for detail.&lt;br /&gt;
&lt;br /&gt;
1.2 Break the broadcaster and listener relationship&lt;br /&gt;
&lt;br /&gt;
When a formula cell is deleted or modified, ScBaseCell::EndListeningTo() is called to to end listening to its directly referenced cell. In ScBaseCell::EndListeningTo() method, it need analyze the reference address of a formula.  For single reference address, it calls ScDocument::EndListeningCell(). At last, ScColumn::EndListening() is called, which removes the listener from broadcaster. In addition, it will delete the broadcaster from the source cell if the broadcaster does not have any listener, even delete the source cell if it is a empty cell with no listener.&lt;br /&gt;
&lt;br /&gt;
== 2. Reference cell range ==&lt;br /&gt;
&lt;br /&gt;
2.1 ScBroadcastArea and ScBroadcastAreaSlot&lt;br /&gt;
&lt;br /&gt;
If a formula cell reference a cell range, any change in the referenced cell range need notify the formula cell. Spreadsheet use ScBroadcastArea to represent the broadcaster. ScBroadcastArea has a broadcaster and record related cell range. &lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_4.png]]&lt;br /&gt;
&lt;br /&gt;
A ScBroadcastArea object is created if a formula reference a cell range. For a simple method, the area broadcaster can be put into an unique container. The container is a set. So different formula cells referencing same cell range will only create one broadcast area. When any cell is changed, Spreadsheet need search the container to find related area broadcaster. Then it use area broadcaster to broadcast the change.&lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_5.png]]&lt;br /&gt;
&lt;br /&gt;
There may be lots of area broadcasters in a complex Spreadsheet document with many formulas. It will have performance problem to search in a very large container to response to any change in any cell. So Spreadsheet divide the unique container into several small containers by row and column. Each small container has a predefined range. It only stores the area broadcaster whose cell range is in its scope. If one referenced cell range is crossed the scope of several containers, every related container need store the area broadcaster. ScBroadcastAreaSlot is such container.&lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_6.png]]&lt;br /&gt;
&lt;br /&gt;
2.2 Partition of the table&lt;br /&gt;
&lt;br /&gt;
A table has 1,048,576 rows and 1,024 columns. How to divide the table into slots to make every slot does not contain a very large cell range and number of slots is not a large number either. Considering the upper sheet part usually is more populated and referneced, a logarithmic distribution method is used. From row 1 to row 32k, it divides the rows by 128. From row 32k to row 64k, it divides the rows by 256. From row 64k to row 128k, it divides the row by 512. And so on. Totally it divides rows into 896 slices. It divides 1024 columns by 16, that is 64 slices. So there are 57,344 slots in one table.&lt;br /&gt;
&lt;br /&gt;
2.3 Establish and break the broadcaster and listener relationship&lt;br /&gt;
&lt;br /&gt;
After a formula cell is created, the formula cell tries to listen the cell range which is referenced by formula when it is inserting in the column. In ScColumn::Insert() method, it calls ScBaseCell::StartListeningTo() method, in which it analyze the reference address of a formula. For double reference address, it call ScDocument::StartListeningArea() method. ScDocument has a ScBroadcastAreaSlotMachine which contains ScBroadcastAreaSlot by table. According to the cell range, the slot machine can find related slots. If the area is not existed in the slot, slot will create a ScBroadcastArea. Then make formula listen to the broadcast area. In ScBroadcastAreaSlotMachine::StarListeningArea() method, the area will be added to several slots if the area cross the scope of several slots. In ScBroadcastAreaSlot::StarListeningArea(), it guarantee that the broadcast area with same cell range will not be created twice.&lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_7.png]]&lt;br /&gt;
&lt;br /&gt;
When a formula cell is deleted or modified, ScBaseCell::EndListeningTo() is called to to end listening to its directly referenced cell. In ScBaseCell::EndListeningTo() method, it need analyze the reference address of a formula.  For double reference address, it calls ScDocument::EndListeningArea() which will call ScBroadcastAreaSlotMachine::EndListeningArea() . According to the cell range, the slot machine can find related slots. At last, ScBroadcastAreaSlot::EndListeningArea() is called, which removes the listener from broadcaster. In addition, it will remove the broadcaster area from the slot if the broadcaster area does not have any listener, even delete the broadcaster area if it does not has reference, which means it is not stored in other slot because of it cross several slot area.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Response to the change&lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_8.png]]&lt;br /&gt;
&lt;br /&gt;
As before mentioned broadcast-listener mechanism, cell A1 listen to B1 and B2, cell B1 and B2 listen to cell C1. When C1 changed, B1 and B2 will be notified. How to spread the change to A1 in an efficient way. When a formula is notified that its dependency is changed, it set itself dirty and put itself into a FormulaTrackList in ScFormulaCell::Notify() method. FormulaTrackList is a doubly linked list in ScDocument. Every time, when some cell changes, besides broadcast the change information, ScDocument::TrackFormulas() is called. In ScDocument::TrackFormulas() method, for every formula cell in the list, it broadcasts the event that it is changed. The influenced formula cell which is not in the list will be added to the end of the list. When cell B1 broadcast, Cell A1 will be added to the FormulaTrackList  in ScFormulaCell::Notify() method. Then A1 will broadcast it is changed. So all formula cells which has direct or indirect dependency for the original changed cell will be notified. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4 .Recalculate the formula&lt;br /&gt;
&lt;br /&gt;
If one cell is modified, it will broadcast the event. The listening formula cells will be notified and set itself as dirty. When there is some request to get the cell value, such as Paint(get the value to paint), Saving(get the value to save in xml), the formula need be calculated. This is a efficient and high performance method that AOO does not need recalculate all related cells when a cell is modified. It only set the flag. For a cell is modified, ScDocShell::SetDocumentModified() is called, which cause ScTabViewShell be notified(ScTabViewShell::Notify()). Then ScTabView::UpdateFormulas() method is called to update all formula cells in visible area.&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Formula_cell_and_cells_dependence&amp;diff=209462</id>
		<title>Calc/Implementation/Formula cell and cells dependence</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Formula_cell_and_cells_dependence&amp;diff=209462"/>
		<updated>2012-11-08T10:07:57Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
Calculation is the most important feature for Spreadsheet. There are many formulas to help user to complete some work. User can use formula to calculate literal data. For an example, &amp;quot;=SUM(1;2)&amp;quot;. But in most cases, users use formula to calculate data stored in other cells. For an example, &amp;quot;=SUM(A1;D3)&amp;quot;. When the data is changed in one cell, the formula cell which references this cell need be notified to recalculate to reflect the new value. How this happens? Broadcast and Listener.&lt;br /&gt;
&lt;br /&gt;
== 1. Reference single cell ==&lt;br /&gt;
&lt;br /&gt;
It is a typical broadcaster and listener relationship when a formula cell reference a single cell. For an example, B2 is a formula cell(=A1+B1), which reference cell A1 and B1 directly.&lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_1.png]]&lt;br /&gt;
&lt;br /&gt;
ScBaseCell is the basic class for any cell. A cell can be a value cell, string cell, formula cell, etc. Only formula cell need listen to other cells. A ScFormulaCell is a listener. A ScBaseCell has a broadcaster. It takes ownership of the broadcaster.&lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_2.png]]&lt;br /&gt;
&lt;br /&gt;
1.1 establish the broadcaster and listener relationship&lt;br /&gt;
&lt;br /&gt;
A cell does not need have a broadcaster if it is not referenced by any other formula cell. After a formula cell is created, the formula cell tries to listen the cells which is referenced by it directly when it is inserting in the column. In ScColumn::Insert() method, it calls ScBaseCell::StartListeningTo() method, in which it analyze the reference address of a formula. For single reference address, ScFormulaCell does not try to get the referenced cell from address directly and listen to it. The reason is that the referenced cell may not existed, such as B1. So ScFormulaCell calls ScDocument::StartListeningCell(). At last, ScColumn::StartListening() is called, which can create a empty cell(ScNoteCell) if the referenced cell is not existed, and establish broadcaster and listener relationship. &lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_3.png]]&lt;br /&gt;
&lt;br /&gt;
So there are two kinds of ScNoteCell. One is an empty cell with comments. The other is an empty cell which is referenced by other formula cell directly. This is also the reason why use ScNoteCell to replace a normal cell when deleting a cell from a column if this cell has a broadcaster. Please refer ScColumn::Delete(SCROW) for detail.&lt;br /&gt;
&lt;br /&gt;
1.2 Break the broadcaster and listener relationship&lt;br /&gt;
&lt;br /&gt;
When a formula cell is deleted or modified, ScBaseCell::EndListeningTo() is called to to end listening to its directly referenced cell. In ScBaseCell::EndListeningTo() method, it need analyze the reference address of a formula.  For single reference address, it calls ScDocument::EndListeningCell(). At last, ScColumn::EndListening() is called, which removes the listener from broadcaster. In addition, it will delete the broadcaster from the source cell if the broadcaster does not have any listener, even delete the source cell if it is a empty cell with no listener.&lt;br /&gt;
&lt;br /&gt;
== 2. Reference cell range ==&lt;br /&gt;
&lt;br /&gt;
2.1 ScBroadcastArea and ScBroadcastAreaSlot&lt;br /&gt;
&lt;br /&gt;
If a formula cell reference a cell range, any change in the referenced cell range need notify the formula cell. Spreadsheet use ScBroadcastArea to represent the broadcaster. ScBroadcastArea has a broadcaster and record related cell range. &lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_4.png]]&lt;br /&gt;
&lt;br /&gt;
A ScBroadcastArea object is created if a formula reference a cell range. For a simple method, the area broadcaster can be put into an unique container. The container is a set. So different formula cells referencing same cell range will only create one broadcast area. When any cell is changed, Spreadsheet need search the container to find related area broadcaster. Then it use area broadcaster to broadcast the change.&lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_5.png]]&lt;br /&gt;
&lt;br /&gt;
There may be lots of area broadcasters in a complex Spreadsheet document with many formulas. It will have performance problem to search in a very large container to response to any change in any cell. So Spreadsheet divide the unique container into several small containers by row and column. Each small container has a predefined range. It only stores the area broadcaster whose cell range is in its scope. If one referenced cell range is crossed the scope of several containers, every related container need store the area broadcaster. ScBroadcastAreaSlot is such container.&lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_6.png]]&lt;br /&gt;
&lt;br /&gt;
2.2 Partition of the table&lt;br /&gt;
&lt;br /&gt;
A table has 1,048,576 rows and 1,024 columns. How to divide the table into slots to make every slot does not contain a very large cell range and number of slots is not a large number either. Considering the upper sheet part usually is more populated and referneced, a logarithmic distribution method is used. From row 1 to row 32k, it divides the rows by 128. From row 32k to row 64k, it divides the rows by 256. From row 64k to row 128k, it divides the row by 512. And so on. Totally it divides rows into 896 slices. It divides 1024 columns by 16, that is 64 slices. So there are 57,344 slots in one table.&lt;br /&gt;
&lt;br /&gt;
2.3 Establish and break the broadcaster and listener relationship&lt;br /&gt;
&lt;br /&gt;
After a formula cell is created, the formula cell tries to listen the cell range which is referenced by formula when it is inserting in the column. In ScColumn::Insert() method, it calls ScBaseCell::StartListeningTo() method, in which it analyze the reference address of a formula. For double reference address, it call ScDocument::StartListeningArea() method. ScDocument has a ScBroadcastAreaSlotMachine which contains ScBroadcastAreaSlot by table. According to the cell range, the slot machine can find related slots. If the area is not existed in the slot, slot will create a ScBroadcastArea. Then make formula listen to the broadcast area. In ScBroadcastAreaSlotMachine::StarListeningArea() method, the area will be added to several slots if the area cross the scope of several slots. In ScBroadcastAreaSlot::StarListeningArea(), it guarantee that the broadcast area with same cell range will not be created twice.&lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_7.png]]&lt;br /&gt;
&lt;br /&gt;
When a formula cell is deleted or modified, ScBaseCell::EndListeningTo() is called to to end listening to its directly referenced cell. In ScBaseCell::EndListeningTo() method, it need analyze the reference address of a formula.  For double reference address, it calls ScDocument::EndListeningArea() which will call ScBroadcastAreaSlotMachine::EndListeningArea() . According to the cell range, the slot machine can find related slots. At last, ScBroadcastAreaSlot::EndListeningArea() is called, which removes the listener from broadcaster. In addition, it will remove the broadcaster area from the slot if the broadcaster area does not have any listener, even delete the broadcaster area if it does not has reference, which means it is not stored in other slot because of it cross several slot area.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Response to the change&lt;br /&gt;
[[File:FormulaCell_8.png]]&lt;br /&gt;
As before mentioned broadcast-listener mechanism, cell A1 listen to B1 and B2, cell B1 and B2 listen to cell C1. When C1 changed, B1 and B2 will be notified. How to spread the change to A1 in an efficient way. When a formula is notified that its dependency is changed, it set itself dirty and put itself into a FormulaTrackList in ScFormulaCell::Notify() method. FormulaTrackList is a doubly linked list in ScDocument. Every time, when some cell changes, besides broadcast the change information, ScDocument::TrackFormulas() is called. In ScDocument::TrackFormulas() method, for every formula cell in the list, it broadcasts the event that it is changed. The influenced formula cell which is not in the list will be added to the end of the list. When cell B1 broadcast, Cell A1 will be added to the FormulaTrackList  in ScFormulaCell::Notify() method. Then A1 will broadcast it is changed. So all formula cells which has direct or indirect dependency for the original changed cell will be notified. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4 .Recalculate the formula&lt;br /&gt;
If one cell is modified, it will broadcast the event. The listening formula cells will be notified and set itself as dirty. When there is some request to get the cell value, such as Paint(get the value to paint), Saving(get the value to save in xml), the formula need be calculated. This is a efficient and high performance method that AOO does not need recalculate all related cells when a cell is modified. It only set the flag. For a cell is modified, ScDocShell::SetDocumentModified() is called, which cause ScTabViewShell be notified(ScTabViewShell::Notify()). Then ScTabView::UpdateFormulas() method is called to update all formula cells in visible area.&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=File:FormulaCell_8.png&amp;diff=209461</id>
		<title>File:FormulaCell 8.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=File:FormulaCell_8.png&amp;diff=209461"/>
		<updated>2012-11-08T10:04:29Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Svtools_Numfmt&amp;diff=202049</id>
		<title>Calc/Implementation/Svtools Numfmt</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Svtools_Numfmt&amp;diff=202049"/>
		<updated>2012-06-12T09:56:23Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Architecture Introduction&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
Number format module is in the path of  &amp;quot;.\lib\svtools\&amp;quot;, which is a basic and public module, is used by other application, &lt;br /&gt;
not only spreadsheet. There are 2 way to access number format module, uno api and call directly. This module has an UNO interface &lt;br /&gt;
layer, provides unified APIs for other application and test module.&lt;br /&gt;
&lt;br /&gt;
ICU is an important component for number format, following type format code need to call ICU APIs to get final result: &lt;br /&gt;
&lt;br /&gt;
standard date and time, basic number, currency data. &lt;br /&gt;
&lt;br /&gt;
[[File:1..jpg]]&lt;br /&gt;
&lt;br /&gt;
The number format module located in src path of “…\lib\svtools\source\numbers”. There are 4 main classes in this module. &lt;br /&gt;
&lt;br /&gt;
[[File:2.jpg]]&lt;br /&gt;
&lt;br /&gt;
Class SvNumberformat represents a number format, which contain 4 sections, info to each section is stored in the array named &lt;br /&gt;
&amp;quot;NumFor[]&amp;quot;. Function GetOutputString() could return the result of specific input content formatted according to one format code.&lt;br /&gt;
In constructed function of class SvNumberformat,  &lt;br /&gt;
&lt;br /&gt;
 SvNumberformat::SvNumberformat(String&amp;amp; rString,&lt;br /&gt;
                               ImpSvNumberformatScan* pSc,&lt;br /&gt;
                               ImpSvNumberInputScan* pISc,&lt;br /&gt;
                               xub_StrLen&amp;amp; nCheckPos,&lt;br /&gt;
                               LanguageType&amp;amp; eLan,&lt;br /&gt;
                               BOOL bStan)&lt;br /&gt;
 {&lt;br /&gt;
     for (Split into 4 sub formats)&lt;br /&gt;
     {&lt;br /&gt;
         // for each section&lt;br /&gt;
         do{  &lt;br /&gt;
             eSymbolType = ImpNextSymbol();  //get next token type&lt;br /&gt;
             if(eSymbolType&amp;gt;0)  // is condition, e.g. ”[&amp;gt;0]”&lt;br /&gt;
             {	   &lt;br /&gt;
                 Handle condition  &lt;br /&gt;
             }&lt;br /&gt;
             else&lt;br /&gt;
             {   &lt;br /&gt;
                 Handle predicate before format code, e.g. color, native number…   &lt;br /&gt;
             }&lt;br /&gt;
         }while(condition)&lt;br /&gt;
         pSc-&amp;gt;ScanFormat( aAdd, aTmp )  //scan format string, collect format info&lt;br /&gt;
         Handle remaining format code string&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
SvNumberFormatter is a container, which has a table named aFTable. If a new format code will be added, should call function &lt;br /&gt;
PutEntry(), which will call  constructed function of class SvNumberformat to get a number format object, and insert it to &lt;br /&gt;
aFTable. The structure of aFTable is as following:&lt;br /&gt;
&lt;br /&gt;
 SV_COUNTRY_LANGUAGE_OFFSET(5000) | SV_COUNTRY_LANGUAGE_OFFSET  |...... | ......&lt;br /&gt;
&lt;br /&gt;
There are many language sections in this table, each language section offset is 5000.&lt;br /&gt;
&lt;br /&gt;
 #define SV_COUNTRY_LANGUAGE_OFFSET  5000 // Max count of formats per country/language&lt;br /&gt;
Each number format object will insert to specific section according to its language type.&lt;br /&gt;
All system default local language and English(USA) format code will be added to this table when initializing.&lt;br /&gt;
&lt;br /&gt;
Class ImpSvNumberformatScan could make lexical analysis to number format code and collect info(e.g. type, integer place, &lt;br /&gt;
decimal place…), put each token to array sStrArray[], and put each token’s type to array nTypeArray[]. The key function of this &lt;br /&gt;
class is ScanFormat.&lt;br /&gt;
&lt;br /&gt;
 xub_StrLen ImpSvNumberformatScan::ScanFormat( String&amp;amp; rString, String&amp;amp; rComment )&lt;br /&gt;
 { &lt;br /&gt;
     xub_StrLen res = Symbol_Division(rString);	// lexical analysis&lt;br /&gt;
     if (!res)&lt;br /&gt;
         res = ScanType(rString);            // determine the type of this format code&lt;br /&gt;
         if (!res)&lt;br /&gt;
             res = FinalScan( rString, rComment );	// collect info&lt;br /&gt;
         return res;				        // res = error position&lt;br /&gt;
                                                        // res = 0 =&amp;gt; Format ok&lt;br /&gt;
 } &lt;br /&gt;
&lt;br /&gt;
Symbol_Division(): lexical analysis, generate 2 array, put each token’s string to array sStrArray[], and put each token’s type &lt;br /&gt;
to array nTypeArray[].&lt;br /&gt;
&lt;br /&gt;
ScanType(): determine the type of this format code, which is listed as following (eScannedType)&lt;br /&gt;
&lt;br /&gt;
 #define NUMBERFORMAT_DEFINED		 0x001	/// Format defined by user&lt;br /&gt;
 #define NUMBERFORMAT_DATE	         0x002	/// Number as date&lt;br /&gt;
 #define NUMBERFORMAT_TIME		 0x004	/// Number as time&lt;br /&gt;
 #define NUMBERFORMAT_CURRENCY		 0x008	/// Number as currency&lt;br /&gt;
 #define NUMBERFORMAT_NUMBER	         0x010	/// Any &amp;quot;normal&amp;quot; number format&lt;br /&gt;
 #define NUMBERFORMAT_SCIENTIFIC		 0x020	/// Number as scientific&lt;br /&gt;
 #define NUMBERFORMAT_FRACTION		 0x040	/// Number as fraction&lt;br /&gt;
 #define NUMBERFORMAT_PERCENT		 0x080	/// Number as percent&lt;br /&gt;
 #define NUMBERFORMAT_TEXT		 0x100	/// Text format&lt;br /&gt;
 #define NUMBERFORMAT_DATETIME		 0x006	/// Number as date and time&lt;br /&gt;
 #define NUMBERFORMAT_LOGICAL		 0x400	/// Number as boolean value&lt;br /&gt;
 #define NUMBERFORMAT_UNDEFINED		 0x800	/// Format undefined yet in analyzing&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
FinalScan():  Get all other detail info for further calculate, e.g. integer bit, decimal place …&lt;br /&gt;
&lt;br /&gt;
Class ImpSvNumberInputScan could determine whether a format code is legal or illegal, and provide date/time/string service.&lt;br /&gt;
Class SvxNumberFormatTabPage and Class SvxNumberFormatShell are UI view and shell controller, there is member SvNumberFormatter  &lt;br /&gt;
pFormatter in the shell, to finish all number format logical operation. &lt;br /&gt;
There 2 kinds of number format code will be inserted into table when initializing spreadsheet. One is built-in code, which &lt;br /&gt;
located in path “…\lib\i18npool\source\localedata\data”, there are some xml files, each one related to one locale’s format code, &lt;br /&gt;
e.g. zh_CN.xml, en_US.xml, de_DE.xml… . Two locale’s format code will be loaded automatically, en_US.xml and system default &lt;br /&gt;
locale. If user change locale in language category list-box, new locale’s format code list will be loaded. &lt;br /&gt;
Another is hardcode format code, in source code “…\lib\svtools\source\numbers\zforlist.cxx”. In the construct function of class &lt;br /&gt;
SvNumberFormatter, some codes will be inserted into format table in hardcode way. Following is part source code snapshot.&lt;br /&gt;
&lt;br /&gt;
[[File:4.jpg]]&lt;br /&gt;
&lt;br /&gt;
Following sequence chart describes a whole flow to create a new number format and insert into format table.&lt;br /&gt;
&lt;br /&gt;
[[File:3.jpg]]&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Formula_cell_and_cells_dependence&amp;diff=202038</id>
		<title>Calc/Implementation/Formula cell and cells dependence</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Formula_cell_and_cells_dependence&amp;diff=202038"/>
		<updated>2012-06-12T09:36:55Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
Calculation is the most important feature for Spreadsheet. There are many formulas to help user to complete some work. User can use formula to calculate literal data. For an example, &amp;quot;=SUM(1;2)&amp;quot;. But in most cases, users use formula to calculate data stored in other cells. For an example, &amp;quot;=SUM(A1;D3)&amp;quot;. When the data is changed in one cell, the formula cell which references this cell need be notified to recalculate to reflect the new value. How this happens? Broadcast and Listener.&lt;br /&gt;
&lt;br /&gt;
== 1. Reference single cell ==&lt;br /&gt;
&lt;br /&gt;
It is a typical broadcaster and listener relationship when a formula cell reference a single cell. For an example, B2 is a formula cell(=A1+B1), which reference cell A1 and B1 directly.&lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_1.png]]&lt;br /&gt;
&lt;br /&gt;
ScBaseCell is the basic class for any cell. A cell can be a value cell, string cell, formula cell, etc. Only formula cell need listen to other cells. A ScFormulaCell is a listener. A ScBaseCell has a broadcaster. It takes ownership of the broadcaster.&lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_2.png]]&lt;br /&gt;
&lt;br /&gt;
1.1 establish the broadcaster and listener relationship&lt;br /&gt;
&lt;br /&gt;
A cell does not need have a broadcaster if it is not referenced by any other formula cell. After a formula cell is created, the formula cell tries to listen the cells which is referenced by it directly when it is inserting in the column. In ScColumn::Insert() method, it calls ScBaseCell::StartListeningTo() method, in which it analyze the reference address of a formula. For single reference address, ScFormulaCell does not try to get the referenced cell from address directly and listen to it. The reason is that the referenced cell may not existed, such as B1. So ScFormulaCell calls ScDocument::StartListeningCell(). At last, ScColumn::StartListening() is called, which can create a empty cell(ScNoteCell) if the referenced cell is not existed, and establish broadcaster and listener relationship. &lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_3.png]]&lt;br /&gt;
&lt;br /&gt;
So there are two kinds of ScNoteCell. One is an empty cell with comments. The other is an empty cell which is referenced by other formula cell directly. This is also the reason why use ScNoteCell to replace a normal cell when deleting a cell from a column if this cell has a broadcaster. Please refer ScColumn::Delete(SCROW) for detail.&lt;br /&gt;
&lt;br /&gt;
1.2 Break the broadcaster and listener relationship&lt;br /&gt;
&lt;br /&gt;
When a formula cell is deleted or modified, ScBaseCell::EndListeningTo() is called to to end listening to its directly referenced cell. In ScBaseCell::EndListeningTo() method, it need analyze the reference address of a formula.  For single reference address, it calls ScDocument::EndListeningCell(). At last, ScColumn::EndListening() is called, which removes the listener from broadcaster. In addition, it will delete the broadcaster from the source cell if the broadcaster does not have any listener, even delete the source cell if it is a empty cell with no listener.&lt;br /&gt;
&lt;br /&gt;
== 2. Reference cell range ==&lt;br /&gt;
&lt;br /&gt;
2.1 ScBroadcastArea and ScBroadcastAreaSlot&lt;br /&gt;
&lt;br /&gt;
If a formula cell reference a cell range, any change in the referenced cell range need notify the formula cell. Spreadsheet use ScBroadcastArea to represent the broadcaster. ScBroadcastArea has a broadcaster and record related cell range. &lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_4.png]]&lt;br /&gt;
&lt;br /&gt;
A ScBroadcastArea object is created if a formula reference a cell range. For a simple method, the area broadcaster can be put into an unique container. The container is a set. So different formula cells referencing same cell range will only create one broadcast area. When any cell is changed, Spreadsheet need search the container to find related area broadcaster. Then it use area broadcaster to broadcast the change.&lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_5.png]]&lt;br /&gt;
&lt;br /&gt;
There may be lots of area broadcasters in a complex Spreadsheet document with many formulas. It will have performance problem to search in a very large container to response to any change in any cell. So Spreadsheet divide the unique container into several small containers by row and column. Each small container has a predefined range. It only stores the area broadcaster whose cell range is in its scope. If one referenced cell range is crossed the scope of several containers, every related container need store the area broadcaster. ScBroadcastAreaSlot is such container.&lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_6.png]]&lt;br /&gt;
&lt;br /&gt;
2.2 Partition of the table&lt;br /&gt;
&lt;br /&gt;
A table has 1,048,576 rows and 1,024 columns. How to divide the table into slots to make every slot does not contain a very large cell range and number of slots is not a large number either. Considering the upper sheet part usually is more populated and referneced, a logarithmic distribution method is used. From row 1 to row 32k, it divides the rows by 128. From row 32k to row 64k, it divides the rows by 256. From row 64k to row 128k, it divides the row by 512. And so on. Totally it divides rows into 896 slices. It divides 1024 columns by 16, that is 64 slices. So there are 57,344 slots in one table.&lt;br /&gt;
&lt;br /&gt;
2.3 Establish and break the broadcaster and listener relationship&lt;br /&gt;
&lt;br /&gt;
After a formula cell is created, the formula cell tries to listen the cell range which is referenced by formula when it is inserting in the column. In ScColumn::Insert() method, it calls ScBaseCell::StartListeningTo() method, in which it analyze the reference address of a formula. For double reference address, it call ScDocument::StartListeningArea() method. ScDocument has a ScBroadcastAreaSlotMachine which contains ScBroadcastAreaSlot by table. According to the cell range, the slot machine can find related slots. If the area is not existed in the slot, slot will create a ScBroadcastArea. Then make formula listen to the broadcast area. In ScBroadcastAreaSlotMachine::StarListeningArea() method, the area will be added to several slots if the area cross the scope of several slots. In ScBroadcastAreaSlot::StarListeningArea(), it guarantee that the broadcast area with same cell range will not be created twice.&lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_7.png]]&lt;br /&gt;
&lt;br /&gt;
When a formula cell is deleted or modified, ScBaseCell::EndListeningTo() is called to to end listening to its directly referenced cell. In ScBaseCell::EndListeningTo() method, it need analyze the reference address of a formula.  For double reference address, it calls ScDocument::EndListeningArea() which will call ScBroadcastAreaSlotMachine::EndListeningArea() . According to the cell range, the slot machine can find related slots. At last, ScBroadcastAreaSlot::EndListeningArea() is called, which removes the listener from broadcaster. In addition, it will remove the broadcaster area from the slot if the broadcaster area does not have any listener, even delete the broadcaster area if it does not has reference, which means it is not stored in other slot because of it cross several slot area.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Response to the change&lt;br /&gt;
&amp;lt;TBC&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4 .Recalculate the formula&lt;br /&gt;
&amp;lt;TBC&amp;gt;&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Formula_cell_and_cells_dependence&amp;diff=202036</id>
		<title>Calc/Implementation/Formula cell and cells dependence</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Formula_cell_and_cells_dependence&amp;diff=202036"/>
		<updated>2012-06-12T09:34:48Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
Calculation is the most important feature for Spreadsheet. There are many formulas to help user to complete some work. User can use formula to calculate literal data. For an example, &amp;quot;=SUM(1;2)&amp;quot;. But in most cases, users use formula to calculate data stored in other cells. For an example, &amp;quot;=SUM(A1;D3)&amp;quot;. When the data is changed in one cell, the formula cell which references this cell need be notified to recalculate to reflect the new value. How this happens? Broadcast and Listener.&lt;br /&gt;
&lt;br /&gt;
== 1. Reference single cell ==&lt;br /&gt;
&lt;br /&gt;
It is a typical broadcaster and listener relationship when a formula cell reference a single cell. For an example, B2 is a formula cell(=A1+B1), which reference cell A1 and B1 directly.&lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_1.png]]&lt;br /&gt;
&lt;br /&gt;
ScBaseCell is the basic class for any cell. A cell can be a value cell, string cell, formula cell, etc. Only formula cell need listen to other cells. A ScFormulaCell is a listener. A ScBaseCell has a broadcaster. It takes ownership of the broadcaster.&lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_2.png]]&lt;br /&gt;
&lt;br /&gt;
1.1 establish the broadcaster and listener relationship&lt;br /&gt;
A cell does not need have a broadcaster if it is not referenced by any other formula cell. After a formula cell is created, the formula cell tries to listen the cells which is referenced by it directly when it is inserting in the column. In ScColumn::Insert() method, it calls ScBaseCell::StartListeningTo() method, in which it analyze the reference address of a formula. For single reference address, ScFormulaCell does not try to get the referenced cell from address directly and listen to it. The reason is that the referenced cell may not existed, such as B1. So ScFormulaCell calls ScDocument::StartListeningCell(). At last, ScColumn::StartListening() is called, which can create a empty cell(ScNoteCell) if the referenced cell is not existed, and establish broadcaster and listener relationship. &lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_3.png]]&lt;br /&gt;
&lt;br /&gt;
So there are two kinds of ScNoteCell. One is an empty cell with comments. The other is an empty cell which is referenced by other formula cell directly. This is also the reason why use ScNoteCell to replace a normal cell when deleting a cell from a column if this cell has a broadcaster. Please refer ScColumn::Delete(SCROW) for detail.&lt;br /&gt;
&lt;br /&gt;
1.2 Break the broadcaster and listener relationship&lt;br /&gt;
When a formula cell is deleted or modified, ScBaseCell::EndListeningTo() is called to to end listening to its directly referenced cell. In ScBaseCell::EndListeningTo() method, it need analyze the reference address of a formula.  For single reference address, it calls ScDocument::EndListeningCell(). At last, ScColumn::EndListening() is called, which removes the listener from broadcaster. In addition, it will delete the broadcaster from the source cell if the broadcaster does not have any listener, even delete the source cell if it is a empty cell with no listener.&lt;br /&gt;
&lt;br /&gt;
== 2. Reference cell range ==&lt;br /&gt;
2.1 ScBroadcastArea and ScBroadcastAreaSlot&lt;br /&gt;
If a formula cell reference a cell range, any change in the referenced cell range need notify the formula cell. Spreadsheet use ScBroadcastArea to represent the broadcaster. ScBroadcastArea has a broadcaster and record related cell range. &lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_4.png]]&lt;br /&gt;
&lt;br /&gt;
A ScBroadcastArea object is created if a formula reference a cell range. For a simple method, the area broadcaster can be put into an unique container. The container is a set. So different formula cells referencing same cell range will only create one broadcast area. When any cell is changed, Spreadsheet need search the container to find related area broadcaster. Then it use area broadcaster to broadcast the change.&lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_5.png]]&lt;br /&gt;
&lt;br /&gt;
There may be lots of area broadcasters in a complex Spreadsheet document with many formulas. It will have performance problem to search in a very large container to response to any change in any cell. So Spreadsheet divide the unique container into several small containers by row and column. Each small container has a predefined range. It only stores the area broadcaster whose cell range is in its scope. If one referenced cell range is crossed the scope of several containers, every related container need store the area broadcaster. ScBroadcastAreaSlot is such container.&lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_6.png]]&lt;br /&gt;
&lt;br /&gt;
2.2 Partition of the table&lt;br /&gt;
A table has 1,048,576 rows and 1,024 columns. How to divide the table into slots to make every slot does not contain a very large cell range and number of slots is not a large number either. Considering the upper sheet part usually is more populated and referneced, a logarithmic distribution method is used. From row 1 to row 32k, it divides the rows by 128. From row 32k to row 64k, it divides the rows by 256. From row 64k to row 128k, it divides the row by 512. And so on. Totally it divides rows into 896 slices. It divides 1024 columns by 16, that is 64 slices. So there are 57,344 slots in one table.&lt;br /&gt;
&lt;br /&gt;
2.3 Establish and break the broadcaster and listener relationship&lt;br /&gt;
After a formula cell is created, the formula cell tries to listen the cell range which is referenced by formula when it is inserting in the column. In ScColumn::Insert() method, it calls ScBaseCell::StartListeningTo() method, in which it analyze the reference address of a formula. For double reference address, it call ScDocument::StartListeningArea() method. ScDocument has a ScBroadcastAreaSlotMachine which contains ScBroadcastAreaSlot by table. According to the cell range, the slot machine can find related slots. If the area is not existed in the slot, slot will create a ScBroadcastArea. Then make formula listen to the broadcast area. In ScBroadcastAreaSlotMachine::StarListeningArea() method, the area will be added to several slots if the area cross the scope of several slots. In ScBroadcastAreaSlot::StarListeningArea(), it guarantee that the broadcast area with same cell range will not be created twice.&lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_7.png]]&lt;br /&gt;
&lt;br /&gt;
When a formula cell is deleted or modified, ScBaseCell::EndListeningTo() is called to to end listening to its directly referenced cell. In ScBaseCell::EndListeningTo() method, it need analyze the reference address of a formula.  For double reference address, it calls ScDocument::EndListeningArea() which will call ScBroadcastAreaSlotMachine::EndListeningArea() . According to the cell range, the slot machine can find related slots. At last, ScBroadcastAreaSlot::EndListeningArea() is called, which removes the listener from broadcaster. In addition, it will remove the broadcaster area from the slot if the broadcaster area does not have any listener, even delete the broadcaster area if it does not has reference, which means it is not stored in other slot because of it cross several slot area.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Response to the change&lt;br /&gt;
&amp;lt;TBC&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4 .Recalculate the formula&lt;br /&gt;
&amp;lt;TBC&amp;gt;&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Formula_cell_and_cell_dependence&amp;diff=202034</id>
		<title>Calc/Implementation/Formula cell and cell dependence</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Formula_cell_and_cell_dependence&amp;diff=202034"/>
		<updated>2012-06-12T09:32:53Z</updated>

		<summary type="html">&lt;p&gt;Leiw: moved Calc/Implementation/Formula cell and cell dependence to Calc/Implementation/Formula cell and cells dependence&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Calc/Implementation/Formula cell and cells dependence]]&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Formula_cell_and_cells_dependence&amp;diff=202033</id>
		<title>Calc/Implementation/Formula cell and cells dependence</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Formula_cell_and_cells_dependence&amp;diff=202033"/>
		<updated>2012-06-12T09:32:53Z</updated>

		<summary type="html">&lt;p&gt;Leiw: moved Calc/Implementation/Formula cell and cell dependence to Calc/Implementation/Formula cell and cells dependence&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
Calculation is the most important feature for Spreadsheet. There are many formulas to help user to complete some work. User can use formula to calculate literal data. For an example, &amp;quot;=SUM(1;2)&amp;quot;. But in most cases, users use formula to calculate data stored in other cells. For an example, &amp;quot;=SUM(A1;D3)&amp;quot;. When the data is changed in one cell, the formula cell which references this cell need be notified to recalculate to reflect the new value. How this happens? Broadcast and Listener.&lt;br /&gt;
&lt;br /&gt;
== 1. Reference single cell ==&lt;br /&gt;
&lt;br /&gt;
It is a typical broadcaster and listener relationship when a formula cell reference a single cell. For an example, B2 is a formula cell(=A1+B1), which reference cell A1 and B1 directly.&lt;br /&gt;
[[File:FormulaCell_1.png]]&lt;br /&gt;
&lt;br /&gt;
ScBaseCell is the basic class for any cell. A cell can be a value cell, string cell, formula cell, etc. Only formula cell need listen to other cells. A ScFormulaCell is a listener. A ScBaseCell has a broadcaster. It takes ownership of the broadcaster.&lt;br /&gt;
[[File:FormulaCell_2.png]]&lt;br /&gt;
&lt;br /&gt;
1.1 establish the broadcaster and listener relationship&lt;br /&gt;
A cell does not need have a broadcaster if it is not referenced by any other formula cell. After a formula cell is created, the formula cell tries to listen the cells which is referenced by it directly when it is inserting in the column. In ScColumn::Insert() method, it calls ScBaseCell::StartListeningTo() method, in which it analyze the reference address of a formula. For single reference address, ScFormulaCell does not try to get the referenced cell from address directly and listen to it. The reason is that the referenced cell may not existed, such as B1. So ScFormulaCell calls ScDocument::StartListeningCell(). At last, ScColumn::StartListening() is called, which can create a empty cell(ScNoteCell) if the referenced cell is not existed, and establish broadcaster and listener relationship. &lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_3.png]]&lt;br /&gt;
&lt;br /&gt;
So there are two kinds of ScNoteCell. One is an empty cell with comments. The other is an empty cell which is referenced by other formula cell directly. This is also the reason why use ScNoteCell to replace a normal cell when deleting a cell from a column if this cell has a broadcaster. Please refer ScColumn::Delete(SCROW) for detail.&lt;br /&gt;
&lt;br /&gt;
1.2 Break the broadcaster and listener relationship&lt;br /&gt;
When a formula cell is deleted or modified, ScBaseCell::EndListeningTo() is called to to end listening to its directly referenced cell. In ScBaseCell::EndListeningTo() method, it need analyze the reference address of a formula.  For single reference address, it calls ScDocument::EndListeningCell(). At last, ScColumn::EndListening() is called, which removes the listener from broadcaster. In addition, it will delete the broadcaster from the source cell if the broadcaster does not have any listener, even delete the source cell if it is a empty cell with no listener.&lt;br /&gt;
&lt;br /&gt;
== 2. Reference cell range ==&lt;br /&gt;
2.1 ScBroadcastArea and ScBroadcastAreaSlot&lt;br /&gt;
If a formula cell reference a cell range, any change in the referenced cell range need notify the formula cell. Spreadsheet use ScBroadcastArea to represent the broadcaster. ScBroadcastArea has a broadcaster and record related cell range. &lt;br /&gt;
[[File:FormulaCell_4.png]]&lt;br /&gt;
&lt;br /&gt;
A ScBroadcastArea object is created if a formula reference a cell range. For a simple method, the area broadcaster can be put into an unique container. The container is a set. So different formula cells referencing same cell range will only create one broadcast area. When any cell is changed, Spreadsheet need search the container to find related area broadcaster. Then it use area broadcaster to broadcast the change.&lt;br /&gt;
[[File:FormulaCell_5.png]]&lt;br /&gt;
&lt;br /&gt;
There may be lots of area broadcasters in a complex Spreadsheet document with many formulas. It will have performance problem to search in a very large container to response to any change in any cell. So Spreadsheet divide the unique container into several small containers by row and column. Each small container has a predefined range. It only stores the area broadcaster whose cell range is in its scope. If one referenced cell range is crossed the scope of several containers, every related container need store the area broadcaster. ScBroadcastAreaSlot is such container.&lt;br /&gt;
[[File:FormulaCell_6.png]]&lt;br /&gt;
&lt;br /&gt;
2.2 Partition of the table&lt;br /&gt;
A table has 1,048,576 rows and 1,024 columns. How to divide the table into slots to make every slot does not contain a very large cell range and number of slots is not a large number either. Considering the upper sheet part usually is more populated and referneced, a logarithmic distribution method is used. From row 1 to row 32k, it divides the rows by 128. From row 32k to row 64k, it divides the rows by 256. From row 64k to row 128k, it divides the row by 512. And so on. Totally it divides rows into 896 slices. It divides 1024 columns by 16, that is 64 slices. So there are 57,344 slots in one table.&lt;br /&gt;
&lt;br /&gt;
2.3 Establish and break the broadcaster and listener relationship&lt;br /&gt;
After a formula cell is created, the formula cell tries to listen the cell range which is referenced by formula when it is inserting in the column. In ScColumn::Insert() method, it calls ScBaseCell::StartListeningTo() method, in which it analyze the reference address of a formula. For double reference address, it call ScDocument::StartListeningArea() method. ScDocument has a ScBroadcastAreaSlotMachine which contains ScBroadcastAreaSlot by table. According to the cell range, the slot machine can find related slots. If the area is not existed in the slot, slot will create a ScBroadcastArea. Then make formula listen to the broadcast area. In ScBroadcastAreaSlotMachine::StarListeningArea() method, the area will be added to several slots if the area cross the scope of several slots. In ScBroadcastAreaSlot::StarListeningArea(), it guarantee that the broadcast area with same cell range will not be created twice.&lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_7.png]]&lt;br /&gt;
&lt;br /&gt;
When a formula cell is deleted or modified, ScBaseCell::EndListeningTo() is called to to end listening to its directly referenced cell. In ScBaseCell::EndListeningTo() method, it need analyze the reference address of a formula.  For double reference address, it calls ScDocument::EndListeningArea() which will call ScBroadcastAreaSlotMachine::EndListeningArea() . According to the cell range, the slot machine can find related slots. At last, ScBroadcastAreaSlot::EndListeningArea() is called, which removes the listener from broadcaster. In addition, it will remove the broadcaster area from the slot if the broadcaster area does not have any listener, even delete the broadcaster area if it does not has reference, which means it is not stored in other slot because of it cross several slot area.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Response to the change&lt;br /&gt;
&amp;lt;TBC&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4 .Recalculate the formula&lt;br /&gt;
&amp;lt;TBC&amp;gt;&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Formula_cell_and_cells_dependence&amp;diff=202032</id>
		<title>Calc/Implementation/Formula cell and cells dependence</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Formula_cell_and_cells_dependence&amp;diff=202032"/>
		<updated>2012-06-12T09:31:56Z</updated>

		<summary type="html">&lt;p&gt;Leiw: Created page with &amp;quot;Category:Calc Category:Implementation  Calculation is the most important feature for Spreadsheet. There are many formulas to help user to complete some work. User can use…&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
Calculation is the most important feature for Spreadsheet. There are many formulas to help user to complete some work. User can use formula to calculate literal data. For an example, &amp;quot;=SUM(1;2)&amp;quot;. But in most cases, users use formula to calculate data stored in other cells. For an example, &amp;quot;=SUM(A1;D3)&amp;quot;. When the data is changed in one cell, the formula cell which references this cell need be notified to recalculate to reflect the new value. How this happens? Broadcast and Listener.&lt;br /&gt;
&lt;br /&gt;
== 1. Reference single cell ==&lt;br /&gt;
&lt;br /&gt;
It is a typical broadcaster and listener relationship when a formula cell reference a single cell. For an example, B2 is a formula cell(=A1+B1), which reference cell A1 and B1 directly.&lt;br /&gt;
[[File:FormulaCell_1.png]]&lt;br /&gt;
&lt;br /&gt;
ScBaseCell is the basic class for any cell. A cell can be a value cell, string cell, formula cell, etc. Only formula cell need listen to other cells. A ScFormulaCell is a listener. A ScBaseCell has a broadcaster. It takes ownership of the broadcaster.&lt;br /&gt;
[[File:FormulaCell_2.png]]&lt;br /&gt;
&lt;br /&gt;
1.1 establish the broadcaster and listener relationship&lt;br /&gt;
A cell does not need have a broadcaster if it is not referenced by any other formula cell. After a formula cell is created, the formula cell tries to listen the cells which is referenced by it directly when it is inserting in the column. In ScColumn::Insert() method, it calls ScBaseCell::StartListeningTo() method, in which it analyze the reference address of a formula. For single reference address, ScFormulaCell does not try to get the referenced cell from address directly and listen to it. The reason is that the referenced cell may not existed, such as B1. So ScFormulaCell calls ScDocument::StartListeningCell(). At last, ScColumn::StartListening() is called, which can create a empty cell(ScNoteCell) if the referenced cell is not existed, and establish broadcaster and listener relationship. &lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_3.png]]&lt;br /&gt;
&lt;br /&gt;
So there are two kinds of ScNoteCell. One is an empty cell with comments. The other is an empty cell which is referenced by other formula cell directly. This is also the reason why use ScNoteCell to replace a normal cell when deleting a cell from a column if this cell has a broadcaster. Please refer ScColumn::Delete(SCROW) for detail.&lt;br /&gt;
&lt;br /&gt;
1.2 Break the broadcaster and listener relationship&lt;br /&gt;
When a formula cell is deleted or modified, ScBaseCell::EndListeningTo() is called to to end listening to its directly referenced cell. In ScBaseCell::EndListeningTo() method, it need analyze the reference address of a formula.  For single reference address, it calls ScDocument::EndListeningCell(). At last, ScColumn::EndListening() is called, which removes the listener from broadcaster. In addition, it will delete the broadcaster from the source cell if the broadcaster does not have any listener, even delete the source cell if it is a empty cell with no listener.&lt;br /&gt;
&lt;br /&gt;
== 2. Reference cell range ==&lt;br /&gt;
2.1 ScBroadcastArea and ScBroadcastAreaSlot&lt;br /&gt;
If a formula cell reference a cell range, any change in the referenced cell range need notify the formula cell. Spreadsheet use ScBroadcastArea to represent the broadcaster. ScBroadcastArea has a broadcaster and record related cell range. &lt;br /&gt;
[[File:FormulaCell_4.png]]&lt;br /&gt;
&lt;br /&gt;
A ScBroadcastArea object is created if a formula reference a cell range. For a simple method, the area broadcaster can be put into an unique container. The container is a set. So different formula cells referencing same cell range will only create one broadcast area. When any cell is changed, Spreadsheet need search the container to find related area broadcaster. Then it use area broadcaster to broadcast the change.&lt;br /&gt;
[[File:FormulaCell_5.png]]&lt;br /&gt;
&lt;br /&gt;
There may be lots of area broadcasters in a complex Spreadsheet document with many formulas. It will have performance problem to search in a very large container to response to any change in any cell. So Spreadsheet divide the unique container into several small containers by row and column. Each small container has a predefined range. It only stores the area broadcaster whose cell range is in its scope. If one referenced cell range is crossed the scope of several containers, every related container need store the area broadcaster. ScBroadcastAreaSlot is such container.&lt;br /&gt;
[[File:FormulaCell_6.png]]&lt;br /&gt;
&lt;br /&gt;
2.2 Partition of the table&lt;br /&gt;
A table has 1,048,576 rows and 1,024 columns. How to divide the table into slots to make every slot does not contain a very large cell range and number of slots is not a large number either. Considering the upper sheet part usually is more populated and referneced, a logarithmic distribution method is used. From row 1 to row 32k, it divides the rows by 128. From row 32k to row 64k, it divides the rows by 256. From row 64k to row 128k, it divides the row by 512. And so on. Totally it divides rows into 896 slices. It divides 1024 columns by 16, that is 64 slices. So there are 57,344 slots in one table.&lt;br /&gt;
&lt;br /&gt;
2.3 Establish and break the broadcaster and listener relationship&lt;br /&gt;
After a formula cell is created, the formula cell tries to listen the cell range which is referenced by formula when it is inserting in the column. In ScColumn::Insert() method, it calls ScBaseCell::StartListeningTo() method, in which it analyze the reference address of a formula. For double reference address, it call ScDocument::StartListeningArea() method. ScDocument has a ScBroadcastAreaSlotMachine which contains ScBroadcastAreaSlot by table. According to the cell range, the slot machine can find related slots. If the area is not existed in the slot, slot will create a ScBroadcastArea. Then make formula listen to the broadcast area. In ScBroadcastAreaSlotMachine::StarListeningArea() method, the area will be added to several slots if the area cross the scope of several slots. In ScBroadcastAreaSlot::StarListeningArea(), it guarantee that the broadcast area with same cell range will not be created twice.&lt;br /&gt;
&lt;br /&gt;
[[File:FormulaCell_7.png]]&lt;br /&gt;
&lt;br /&gt;
When a formula cell is deleted or modified, ScBaseCell::EndListeningTo() is called to to end listening to its directly referenced cell. In ScBaseCell::EndListeningTo() method, it need analyze the reference address of a formula.  For double reference address, it calls ScDocument::EndListeningArea() which will call ScBroadcastAreaSlotMachine::EndListeningArea() . According to the cell range, the slot machine can find related slots. At last, ScBroadcastAreaSlot::EndListeningArea() is called, which removes the listener from broadcaster. In addition, it will remove the broadcaster area from the slot if the broadcaster area does not have any listener, even delete the broadcaster area if it does not has reference, which means it is not stored in other slot because of it cross several slot area.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Response to the change&lt;br /&gt;
&amp;lt;TBC&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4 .Recalculate the formula&lt;br /&gt;
&amp;lt;TBC&amp;gt;&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=File:FormulaCell_7.png&amp;diff=202031</id>
		<title>File:FormulaCell 7.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=File:FormulaCell_7.png&amp;diff=202031"/>
		<updated>2012-06-12T09:31:42Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=File:FormulaCell_6.png&amp;diff=202030</id>
		<title>File:FormulaCell 6.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=File:FormulaCell_6.png&amp;diff=202030"/>
		<updated>2012-06-12T09:31:24Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=File:FormulaCell_5.png&amp;diff=202027</id>
		<title>File:FormulaCell 5.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=File:FormulaCell_5.png&amp;diff=202027"/>
		<updated>2012-06-12T09:29:57Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=File:FormulaCell_4.png&amp;diff=202026</id>
		<title>File:FormulaCell 4.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=File:FormulaCell_4.png&amp;diff=202026"/>
		<updated>2012-06-12T09:29:33Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=File:FormulaCell_3.png&amp;diff=202025</id>
		<title>File:FormulaCell 3.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=File:FormulaCell_3.png&amp;diff=202025"/>
		<updated>2012-06-12T09:28:12Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=File:FormulaCell_2.png&amp;diff=202023</id>
		<title>File:FormulaCell 2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=File:FormulaCell_2.png&amp;diff=202023"/>
		<updated>2012-06-12T09:27:20Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=File:FormulaCell_1.png&amp;diff=202021</id>
		<title>File:FormulaCell 1.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=File:FormulaCell_1.png&amp;diff=202021"/>
		<updated>2012-06-12T09:26:23Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Filter_in_spreadsheet&amp;diff=201666</id>
		<title>Calc/Implementation/Filter in spreadsheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Filter_in_spreadsheet&amp;diff=201666"/>
		<updated>2012-06-01T06:04:20Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
== The whole view of filter ==&lt;br /&gt;
An in-memory Symphony document is represented by it&amp;#039;s document model. On disk, the same document is represented as a file. An import component must turn the latter into the former as shown by this diagram.&lt;br /&gt;
&lt;br /&gt;
[[File:Filter_structure.JPG]]&lt;br /&gt;
&lt;br /&gt;
== Filter in symphony ==&lt;br /&gt;
When open a file in symphony, the supported filters will be initialized by the class of SfxFilterContainer in sfx2\inc\sfx2. &lt;br /&gt;
It contains a member of SfxFilterContainer_Impl *pImpl. Symphony uses this class to control every SfxFilter.&lt;br /&gt;
&lt;br /&gt;
[[File:SfxFilterContainer.JPG]]&lt;br /&gt;
&lt;br /&gt;
There are a global variable for storing SfxFilter, the name is &lt;br /&gt;
static SfxFilterList_Impl* pFilterArr = 0; &lt;br /&gt;
it is defined in sfx2\source\bastyp\fltfnc.cxx.&lt;br /&gt;
Indeed SfxFilterList_Impl is a list defined by DECLARE_LIST( SfxFilterList_Impl, SfxFilter* ) in sfx2\inc\arrdecl.hxx.&lt;br /&gt;
The detail can be traced by the call stack.&lt;br /&gt;
[[File:Callstack.JPG]]&lt;br /&gt;
== Get the correct filter to load a document ==&lt;br /&gt;
To import a real document, symphony should get the file type to use the correct filter.&lt;br /&gt;
To get the filter, Symphony will use flat detection and deep detection.&lt;br /&gt;
In few words the &amp;quot;flat detection&amp;quot; is a type detection based on document extension, for example,a document named &amp;quot;test.xls&amp;quot;, it will get calc to load it by the extension of &amp;quot;xls&amp;quot;. &lt;br /&gt;
The &amp;quot;deep detection&amp;quot; is the detection that analyzes the document contents. For example, if a document named &amp;quot;test.xls&amp;quot;,but it is presentation document, then the deep detection should be joined. &lt;br /&gt;
In the file of  filter\source\config\cache\typedetection.cxx, the function of &lt;br /&gt;
TypeDetection::queryTypeByDescriptor is the entry for getting the filter to loading the document.&lt;br /&gt;
*Flat detection&lt;br /&gt;
FilterCache::detectFlatForURL, it can get the correct filter by the extention of the document name.&lt;br /&gt;
The function is defined in filter\source\config\cache\filtercache.cxx&lt;br /&gt;
A subset of document types is defined for a real filter. For example, to calc, it is defined in Basis\share\registry\modules\org\openoffice\TypeDetection\Filter\fcfg_calc_filters.xcu, here is an item for MS excel 97 file format.&lt;br /&gt;
&amp;lt;node oor:name=&amp;quot;MS Excel 97&amp;quot; oor:op=&amp;quot;replace&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;prop oor:name=&amp;quot;Flags&amp;quot;&amp;gt;&amp;lt;value&amp;gt;IMPORT EXPORT ALIEN PREFERRED&amp;lt;/value&amp;gt;&amp;lt;/prop&amp;gt;&lt;br /&gt;
	&amp;lt;prop oor:name=&amp;quot;UIComponent&amp;quot;/&amp;gt;&lt;br /&gt;
	&amp;lt;prop oor:name=&amp;quot;FilterService&amp;quot;/&amp;gt;&lt;br /&gt;
	&amp;lt;prop oor:name=&amp;quot;UserData&amp;quot;/&amp;gt;&lt;br /&gt;
	&amp;lt;prop oor:name=&amp;quot;UIName&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;value xml:lang=&amp;quot;x-default&amp;quot;&amp;gt;Microsoft Excel 97/2000/XP&amp;lt;/value&amp;gt;&lt;br /&gt;
	&amp;lt;/prop&amp;gt;&lt;br /&gt;
	&amp;lt;prop oor:name=&amp;quot;FileFormatVersion&amp;quot;&amp;gt;&amp;lt;value&amp;gt;0&amp;lt;/value&amp;gt;&amp;lt;/prop&amp;gt;&lt;br /&gt;
	&amp;lt;prop oor:name=&amp;quot;Type&amp;quot;&amp;gt;&amp;lt;value&amp;gt;calc_MS_Excel_97&amp;lt;/value&amp;gt;&amp;lt;/prop&amp;gt;&lt;br /&gt;
	&amp;lt;prop oor:name=&amp;quot;TemplateName&amp;quot;/&amp;gt;&lt;br /&gt;
	&amp;lt;prop oor:name=&amp;quot;DocumentService&amp;quot;&amp;gt;&amp;lt;value&amp;gt;com.sun.star.sheet.SpreadsheetDocument&amp;lt;/value&amp;gt;&amp;lt;/prop&amp;gt;&lt;br /&gt;
&amp;lt;/node&amp;gt;&lt;br /&gt;
The UIName defines the string of MS excel 97 displayed for open/save dialog.&lt;br /&gt;
The Type defines the string used in the internal code of Symphony.&lt;br /&gt;
The DocumentService defines which service is used to import/export such document.&lt;br /&gt;
&lt;br /&gt;
[[File:Callstack2.JPG]]&lt;br /&gt;
&lt;br /&gt;
*Deep detection&lt;br /&gt;
Symphony uses the interface XExtendedFilterDetection to look into the document stream to detect the format. It belongs to :: com :: sun :: star :: document.&lt;br /&gt;
This function is called by TypeDetection::impl_askDetectService &lt;br /&gt;
in the file filter\source\config\cache\typedetection.cxx&lt;br /&gt;
sDeepType = xDetector-&amp;gt;detect(lDescriptor);&lt;br /&gt;
In the step 3.1, Symphony has got the filters by the file&amp;#039;s extention.&lt;br /&gt;
The types matching to the given extention.&lt;br /&gt;
Calc_MS_Excel_40&lt;br /&gt;
Calc_MS_Excel_95&lt;br /&gt;
Calc_MS_Excel_97&lt;br /&gt;
Calc_Text_txt_csv_StarCalc&lt;br /&gt;
Calc_MS_Excel_5095&lt;br /&gt;
By the types, Symphony will do the deep detection. It is realized by a spreadsheet servcie of &lt;br /&gt;
com.sun.star.comp.calc.FormatDetector.&lt;br /&gt;
&lt;br /&gt;
In the function of TypeDetection::impl_askDetectService(), It &lt;br /&gt;
calls xDetector-&amp;gt;detect(lDescriptor);&lt;br /&gt;
The real implement function is ScFilterDetect::detect()&lt;br /&gt;
It is defined in sc\source\ui\unoobj\scdetect.cxx&lt;br /&gt;
At first, make a SotStorage by the input stream of MS excel&lt;br /&gt;
SotStorageRef aStorage = new SotStorage ( pStream, FALSE );&lt;br /&gt;
Then check the content of the file, if there is a sub stream named &amp;quot;Workbook&amp;quot; or &amp;quot;Book&amp;quot;.&lt;br /&gt;
String aStreamName(RTL_CONSTASCII_STRINGPARAM(&amp;quot;Workbook&amp;quot;));&lt;br /&gt;
BOOL bExcel97Stream = ( aStorage-&amp;gt;IsStream( aStreamName ) );&lt;br /&gt;
&lt;br /&gt;
aStreamName = String(RTL_CONSTASCII_STRINGPARAM(&amp;quot;Book&amp;quot;));&lt;br /&gt;
BOOL bExcel5Stream = ( aStorage-&amp;gt;IsStream( aStreamName ) );&lt;br /&gt;
[[File:deepdetect.jpg]]&lt;br /&gt;
*Load a chart in spreadsheet filter&lt;br /&gt;
Chart is managed by the class of XclImpObjectManager in spreadsheet. The real implement is XclImpChartObj that is base on XclImplDrawObjBase.&lt;br /&gt;
XclImpChart will import the parts of chart, for example, diagram, series, title, background, etc.&lt;br /&gt;
&lt;br /&gt;
[[File:Loadchart.JPG]]&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Filter_in_spreadsheet&amp;diff=201665</id>
		<title>Calc/Implementation/Filter in spreadsheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Filter_in_spreadsheet&amp;diff=201665"/>
		<updated>2012-06-01T06:03:56Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== The whole view of filter ==&lt;br /&gt;
An in-memory Symphony document is represented by it&amp;#039;s document model. On disk, the same document is represented as a file. An import component must turn the latter into the former as shown by this diagram.&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Filter_in_spreadsheet&amp;diff=201664</id>
		<title>Calc/Implementation/Filter in spreadsheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Filter_in_spreadsheet&amp;diff=201664"/>
		<updated>2012-06-01T05:58:49Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== The whole view of filter ==&lt;br /&gt;
An in-memory Symphony document is represented by it&amp;#039;s document model. On disk, the same document is represented as a file. An import component must turn the latter into the former as shown by this diagram.&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Filter_in_spreadsheet&amp;diff=201663</id>
		<title>Calc/Implementation/Filter in spreadsheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Filter_in_spreadsheet&amp;diff=201663"/>
		<updated>2012-06-01T05:58:05Z</updated>

		<summary type="html">&lt;p&gt;Leiw: Replaced content with &amp;quot;Category:Calc
Category:Implementation

== The whole view of filter ==
An in-memory Symphony document is represented by it&amp;#039;s document model. On disk, the same document…&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
== The whole view of filter ==&lt;br /&gt;
An in-memory Symphony document is represented by it&amp;#039;s document model. On disk, the same document is represented as a file. An import component must turn the latter into the former as shown by this diagram.&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Overview_of_DataPilot_Development&amp;diff=201660</id>
		<title>Calc/Implementation/Overview of DataPilot Development</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Overview_of_DataPilot_Development&amp;diff=201660"/>
		<updated>2012-06-01T02:48:46Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
== 1. What is DataPilot ==&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;DataPilot is a professional tool for data Analysis. It is very powerful at summary of data report, analysis of data and representation of data. DataPilot analyzes source data, and generates a clear Data report.  We can provide different type of data source, such as a spreadsheet table, or a table in a database, and then the DataPilot can generate a clear data view for us.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 2.Overview of DataPilot at source code level ==&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;2.1. Source data abstract&amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;To abstract different type of Data source, and to make DataPilot calculable after damange of source data, the source data is standardized and stored as a middle data structure of DataPilot source data cache. The DataPilot source data cache is a 2D table of data generated from the original source data. The data structure of DataPilot source data cache is named as ScDPTableDataCache.&amp;lt;p style=&amp;quot;text-align:center;&amp;quot;&amp;gt;[[File:Untitled16.PNG]]&amp;lt;/p&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;2.2. Calculation Settings&amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;To do data summarization, we need apply some calculation settings, such as which field is assigned to Data area/Row area/Column area/Page area, which function we want to summarize( Sum/Count/Average/Max/.... ). These settings determine how to do data summarization on the data to be analyzed. The structure to store the calculation settings is named ScDPSaveData. It has some members which store settings for the entire DataPilot table, such as whether to display column grand total/row grand total. And the ScDPSaveData has a member container which contains settings for each Field. The structure for Field settings is named as ScDPSaveDimension. The ScDPSaveDimension structure stored the settings for entire field, such as Field display name. And the ScDPSaveDimension structure also has a container which contains settings for each data item of this Field. The structure for data item settings is named as ScDPSaveMember.&amp;lt;p style=&amp;quot;text-align:center;&amp;quot;&amp;gt;[[File:DataPilot_calculation_settings.png]]&amp;lt;/p&amp;gt; &amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;2.2. Calculation Result&amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;Since both the data to be analyzed and the calculation settings are ready, then the data is calculated and stored. The structure which takes the responsibility of calculation and result storage is named as ScDPSource.&amp;lt;p style=&amp;quot;text-align:center;&amp;quot;&amp;gt;[[File:DataPilot_calculation.PNG]]&amp;lt;/p&amp;gt;&amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;2.3. Output Result&amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;The class ScDPOuput takes the responsibility of outputting calculation result. It works with the result provider ScDPSource via access of the interface of XDataPilotResults. It checks the output settings such as whether to keep customized format, and generates output result base on calculation result and output settings.&amp;lt;p style=&amp;quot;text-align:center;&amp;quot;&amp;gt;[[File:DataPilot_output.PNG]]&amp;lt;/p&amp;gt;&amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;2.4. Overview of the whole process&amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;p style=&amp;quot;text-align:center;&amp;quot;&amp;gt;[[File:DataPilot_process_overview.PNG]]&amp;lt;/p&amp;gt;&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Overview_of_DataPilot_Development&amp;diff=201659</id>
		<title>Overview of DataPilot Development</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Overview_of_DataPilot_Development&amp;diff=201659"/>
		<updated>2012-06-01T02:47:47Z</updated>

		<summary type="html">&lt;p&gt;Leiw: moved Overview of DataPilot Development to Calc/Implementation/Overview of DataPilot Development&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Calc/Implementation/Overview of DataPilot Development]]&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Overview_of_DataPilot_Development&amp;diff=201658</id>
		<title>Calc/Implementation/Overview of DataPilot Development</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Overview_of_DataPilot_Development&amp;diff=201658"/>
		<updated>2012-06-01T02:47:47Z</updated>

		<summary type="html">&lt;p&gt;Leiw: moved Overview of DataPilot Development to Calc/Implementation/Overview of DataPilot Development&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
== What is DataPilot ==&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;DataPilot is a professional tool for data Analysis. It is very powerful at summary of data report, analysis of data and representation of data. DataPilot analyzes source data, and generates a clear Data report.  We can provide different type of data source, such as a spreadsheet table, or a table in a database, and then the DataPilot can generate a clear data view for us.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview of DataPilot at source code level ==&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;2.1. Source data abstract&amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;To abstract different type of Data source, and to make DataPilot calculable after damange of source data, the source data is standardized and stored as a middle data structure of DataPilot source data cache. The DataPilot source data cache is a 2D table of data generated from the original source data. The data structure of DataPilot source data cache is named as ScDPTableDataCache.&amp;lt;p style=&amp;quot;text-align:center;&amp;quot;&amp;gt;[[File:Untitled16.PNG]]&amp;lt;/p&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;2.2. Calculation Settings&amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;To do data summarization, we need apply some calculation settings, such as which field is assigned to Data area/Row area/Column area/Page area, which function we want to summarize( Sum/Count/Average/Max/.... ). These settings determine how to do data summarization on the data to be analyzed. The structure to store the calculation settings is named ScDPSaveData. It has some members which store settings for the entire DataPilot table, such as whether to display column grand total/row grand total. And the ScDPSaveData has a member container which contains settings for each Field. The structure for Field settings is named as ScDPSaveDimension. The ScDPSaveDimension structure stored the settings for entire field, such as Field display name. And the ScDPSaveDimension structure also has a container which contains settings for each data item of this Field. The structure for data item settings is named as ScDPSaveMember.&amp;lt;p style=&amp;quot;text-align:center;&amp;quot;&amp;gt;[[File:DataPilot_calculation_settings.png]]&amp;lt;/p&amp;gt; &amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;2.2. Calculation Result&amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;Since both the data to be analyzed and the calculation settings are ready, then the data is calculated and stored. The structure which takes the responsibility of calculation and result storage is named as ScDPSource.&amp;lt;p style=&amp;quot;text-align:center;&amp;quot;&amp;gt;[[File:DataPilot_calculation.PNG]]&amp;lt;/p&amp;gt;&amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;2.3. Output Result&amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;The class ScDPOuput takes the responsibility of outputting calculation result. It works with the result provider ScDPSource via access of the interface of XDataPilotResults. It checks the output settings such as whether to keep customized format, and generates output result base on calculation result and output settings.&amp;lt;p style=&amp;quot;text-align:center;&amp;quot;&amp;gt;[[File:DataPilot_output.PNG]]&amp;lt;/p&amp;gt;&amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;2.4. Overview of the whole process&amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;p style=&amp;quot;text-align:center;&amp;quot;&amp;gt;[[File:DataPilot_process_overview.PNG]]&amp;lt;/p&amp;gt;&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Overview_of_DataPilot_Development&amp;diff=201657</id>
		<title>Calc/Implementation/Overview of DataPilot Development</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Overview_of_DataPilot_Development&amp;diff=201657"/>
		<updated>2012-06-01T02:46:10Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
== What is DataPilot ==&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;DataPilot is a professional tool for data Analysis. It is very powerful at summary of data report, analysis of data and representation of data. DataPilot analyzes source data, and generates a clear Data report.  We can provide different type of data source, such as a spreadsheet table, or a table in a database, and then the DataPilot can generate a clear data view for us.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview of DataPilot at source code level ==&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;2.1. Source data abstract&amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;To abstract different type of Data source, and to make DataPilot calculable after damange of source data, the source data is standardized and stored as a middle data structure of DataPilot source data cache. The DataPilot source data cache is a 2D table of data generated from the original source data. The data structure of DataPilot source data cache is named as ScDPTableDataCache.&amp;lt;p style=&amp;quot;text-align:center;&amp;quot;&amp;gt;[[File:Untitled16.PNG]]&amp;lt;/p&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;2.2. Calculation Settings&amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;To do data summarization, we need apply some calculation settings, such as which field is assigned to Data area/Row area/Column area/Page area, which function we want to summarize( Sum/Count/Average/Max/.... ). These settings determine how to do data summarization on the data to be analyzed. The structure to store the calculation settings is named ScDPSaveData. It has some members which store settings for the entire DataPilot table, such as whether to display column grand total/row grand total. And the ScDPSaveData has a member container which contains settings for each Field. The structure for Field settings is named as ScDPSaveDimension. The ScDPSaveDimension structure stored the settings for entire field, such as Field display name. And the ScDPSaveDimension structure also has a container which contains settings for each data item of this Field. The structure for data item settings is named as ScDPSaveMember.&amp;lt;p style=&amp;quot;text-align:center;&amp;quot;&amp;gt;[[File:DataPilot_calculation_settings.png]]&amp;lt;/p&amp;gt; &amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;2.2. Calculation Result&amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;Since both the data to be analyzed and the calculation settings are ready, then the data is calculated and stored. The structure which takes the responsibility of calculation and result storage is named as ScDPSource.&amp;lt;p style=&amp;quot;text-align:center;&amp;quot;&amp;gt;[[File:DataPilot_calculation.PNG]]&amp;lt;/p&amp;gt;&amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;2.3. Output Result&amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;The class ScDPOuput takes the responsibility of outputting calculation result. It works with the result provider ScDPSource via access of the interface of XDataPilotResults. It checks the output settings such as whether to keep customized format, and generates output result base on calculation result and output settings.&amp;lt;p style=&amp;quot;text-align:center;&amp;quot;&amp;gt;[[File:DataPilot_output.PNG]]&amp;lt;/p&amp;gt;&amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;2.4. Overview of the whole process&amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;p style=&amp;quot;text-align:center;&amp;quot;&amp;gt;[[File:DataPilot_process_overview.PNG]]&amp;lt;/p&amp;gt;&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Chart2_Framework&amp;diff=200379</id>
		<title>Chart2 Framework</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Chart2_Framework&amp;diff=200379"/>
		<updated>2012-04-28T05:12:29Z</updated>

		<summary type="html">&lt;p&gt;Leiw: moved Chart2 Framework to Calc/Implementation/Chart2 Framework&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Calc/Implementation/Chart2 Framework]]&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Chart2_Framework&amp;diff=200378</id>
		<title>Calc/Implementation/Chart2 Framework</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Chart2_Framework&amp;diff=200378"/>
		<updated>2012-04-28T05:12:29Z</updated>

		<summary type="html">&lt;p&gt;Leiw: moved Chart2 Framework to Calc/Implementation/Chart2 Framework&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
== &amp;#039;&amp;#039;&amp;#039;1. Basic Concepts of Chart Kernel Objects&amp;#039;&amp;#039;&amp;#039; ==&lt;br /&gt;
A chart model contains three major parts, titles(main title and sub-title), legend, and diagram which contains concrete chart data. The chart data is organized by chart type in a coordinate system. The chart type consist of data series, which represents as a series of individual data points with the same color. The data series is generally organized by column which is the default in the chart data table, but it can be organized by row as well. For some chart types, a data point needs several data units. For example, a bubble chart needs three data units: a X coordinate point, a Y coordinate point, and the bubble size. So it needs three columns(or rows according to the direction of the data series) to represent a completed data series. Each column or row is called data sequence.&lt;br /&gt;
A diagram has a wall as the background of the coordinate system. For 3D charts, it also needs a floor.&lt;br /&gt;
The hierarchical model of the chart kernel objects is like below chart.&lt;br /&gt;
&lt;br /&gt;
* Chart Model&lt;br /&gt;
  Titles&lt;br /&gt;
    - Main title&lt;br /&gt;
    - Sub-title&lt;br /&gt;
  Legend&lt;br /&gt;
  Diagram&lt;br /&gt;
    - Chart wall&lt;br /&gt;
    - Chart floor&lt;br /&gt;
    - Coordinate system&lt;br /&gt;
      - Chart type&lt;br /&gt;
        - Data series&lt;br /&gt;
          - Data sequence&lt;br /&gt;
          - Data points&lt;br /&gt;
&lt;br /&gt;
http://wiki.services.openoffice.org/w/images/8/8b/ChartElements.jpg&lt;br /&gt;
&lt;br /&gt;
== &amp;#039;&amp;#039;&amp;#039;2. Characters of chart2 Module&amp;#039;&amp;#039;&amp;#039; ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;2.1. Well implemented uno interfaces&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Chart2 module well implemented uno interfaces. These interfaces are located in offapi\com\sun\star\chart which is the old interfaces and offapi\com\sun\star\chart2 which is the new. Each kernel chart objects must implement the corresponding interface defined in the offapi module. In order to keep the consistency with the old interface, some kernel objects implemented the new interface and also aggregated the old interface in the other hand.&lt;br /&gt;
Below chart is an illustration of ChartModel, which implemented the new interface chart2::XChartDocument and aggregated the old interface chart::XChartDocument.&lt;br /&gt;
&lt;br /&gt;
http://wiki.services.openoffice.org/w/images/8/8a/ChartModelInterface.jpg&lt;br /&gt;
&lt;br /&gt;
Below chart is another example to illustrate the interface implementations of some other kernel objects.&lt;br /&gt;
&lt;br /&gt;
http://wiki.services.openoffice.org/w/images/thumb/0/04/ChartInterfaces.jpg/800px-ChartInterfaces.jpg&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;2.2. Typical MVC design pattern&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The source code under chart2 module was categorized into five parts: model, view, controller, inc and tools, which is a typical MVC design pattern.&lt;br /&gt;
*model: kernel objects, binary file: chartmodelmi.dll&lt;br /&gt;
*view: drawing, binary file: chartviewmi.dll&lt;br /&gt;
*controller: events handler, interfaces for outside callers..., binary file: chartcontrollermi.dll&lt;br /&gt;
*tools: tools for chart handling, helper classes, binary file: charttoolsmi.dll&lt;br /&gt;
*inc: private include files&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;2.3. Breakdown of the MVC model&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The section breakdowns the source code under chart2\source to interpret the major functions of each folder under model, view, controller.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;2.3.1. Model&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Folder&lt;br /&gt;
! Major Function&lt;br /&gt;
|-&lt;br /&gt;
| filter&lt;br /&gt;
| Interface with xmloff&lt;br /&gt;
|-&lt;br /&gt;
| main&lt;br /&gt;
| Kernel objects: ChartModel, Diagram, Title, Legend, DataSeries, DataPoint...&lt;br /&gt;
|-&lt;br /&gt;
| template&lt;br /&gt;
| Templates to create each chart type based on the chart data table&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For each chart type, we must have below objects(use bubble chart as illustration):&lt;br /&gt;
* a template (BubbleChartTypeTemplate under source\model\template) to create chart type model based on the original data source&lt;br /&gt;
* a data source interpreter (BubbleDataInterpreter under source\model\template) to interpret the original data source and generate the chart type model according to the corresponding template&lt;br /&gt;
* a chart type model (BubbleChartType under source\model\template)&lt;br /&gt;
* a view object (BubbleChart under source\view\charttypes)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;2.3.2. View&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Folder&lt;br /&gt;
! Major Function&lt;br /&gt;
|-&lt;br /&gt;
| axes&lt;br /&gt;
| Coordinate system and axes&lt;br /&gt;
|-&lt;br /&gt;
| charttypes&lt;br /&gt;
| Shape creator for individual chart types&lt;br /&gt;
|-&lt;br /&gt;
| diagram&lt;br /&gt;
| View of diagram&lt;br /&gt;
|-&lt;br /&gt;
| main&lt;br /&gt;
| Kernel view objects: ChartView, VLegend, VTitle, VDataSeries...&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
VDataSeries contains view information for a data series, for example, X value, Y value, which coordinate this data series will be applied to(the diagram might contain two coordinate systems, main coordinate system and secondary coordinate system). Then chartypes uses these information to draw the corresponding shapes for each data point.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;2.3.3. controller&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Folder&lt;br /&gt;
! Major Function&lt;br /&gt;
|-&lt;br /&gt;
| accessibility&lt;br /&gt;
| ACC&lt;br /&gt;
|-&lt;br /&gt;
| chartapiwrapper&lt;br /&gt;
| Interfaces for outside callers&lt;br /&gt;
|-&lt;br /&gt;
| dialogs&lt;br /&gt;
| Chart internal dialogs&lt;br /&gt;
|-&lt;br /&gt;
| drawinglayer&lt;br /&gt;
| Bridge between drawing layer and SdrObject&lt;br /&gt;
|-&lt;br /&gt;
| itemsetwrapper&lt;br /&gt;
| Converter between property set and item set&lt;br /&gt;
|-&lt;br /&gt;
| main&lt;br /&gt;
| Major controllers: event handling, command dispatch...&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Each visual object in chart will also correspond a SdrObject. drawinglayer is responsible for establishing a bridge between the visual objects to it&amp;#039;s concrete SdrObject.&lt;br /&gt;
&lt;br /&gt;
Under AOO&amp;#039;s architecture, SfxItemSet is generally used to transfer object attributes. But as fore-mentioned, each object in chart2 module implemented uno interface, so XPropertySet which is a uno interface is used to transfer attributes within the chart2 module. Therefore itemsetwrapper was designed to be responsible for converting the attributes between SfxItemSet and XPropertySet.&lt;br /&gt;
&lt;br /&gt;
== &amp;#039;&amp;#039;&amp;#039;3. Model, View, Wrapper and Helper&amp;#039;&amp;#039;&amp;#039; ==&lt;br /&gt;
&lt;br /&gt;
In general, a concrete model object will correspond a object set which contains four class. We use [Object] as the placeholder of the model object. &lt;br /&gt;
* [Object]: kernel object in model&lt;br /&gt;
* V[Object]: view-side object corresponding to model&lt;br /&gt;
* [Object]Wrapper: wrapper to access the kernel object for outside callers&lt;br /&gt;
* [Object]Helper: tool to create model object, or get/set the internal attributes of the model&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
* Diagram, VDiagram, DiagramWrapper, DiagramHelper&lt;br /&gt;
* Title, VTitle, TitleWrapper, TitleHelper&lt;br /&gt;
* Legend, VLegend, LegendWrapper, LegendHelper&lt;br /&gt;
&lt;br /&gt;
== &amp;#039;&amp;#039;&amp;#039;4. Chart handling process&amp;#039;&amp;#039;&amp;#039; ==&lt;br /&gt;
&lt;br /&gt;
This section will use two typical process to interpret how the chart model works to create each MVC objects. The first order is top to bottom; the second order is left to right.&lt;br /&gt;
&lt;br /&gt;
Legend: M – Model; V – View; C – Controller; T – Tools&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;4.1. Create a default column chart&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
http://wiki.services.openoffice.org/w/images/thumb/b/b9/CreateDefaultChartProcess.jpg/800px-CreateDefaultChartProcess.jpg&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;4.2. Create a title on chart&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
http://wiki.services.openoffice.org/w/images/thumb/6/6d/CreateTitleProcess.jpg/800px-CreateTitleProcess.jpg&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Chart2_Framework&amp;diff=200377</id>
		<title>Calc/Implementation/Chart2 Framework</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Chart2_Framework&amp;diff=200377"/>
		<updated>2012-04-28T05:11:39Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
== &amp;#039;&amp;#039;&amp;#039;1. Basic Concepts of Chart Kernel Objects&amp;#039;&amp;#039;&amp;#039; ==&lt;br /&gt;
A chart model contains three major parts, titles(main title and sub-title), legend, and diagram which contains concrete chart data. The chart data is organized by chart type in a coordinate system. The chart type consist of data series, which represents as a series of individual data points with the same color. The data series is generally organized by column which is the default in the chart data table, but it can be organized by row as well. For some chart types, a data point needs several data units. For example, a bubble chart needs three data units: a X coordinate point, a Y coordinate point, and the bubble size. So it needs three columns(or rows according to the direction of the data series) to represent a completed data series. Each column or row is called data sequence.&lt;br /&gt;
A diagram has a wall as the background of the coordinate system. For 3D charts, it also needs a floor.&lt;br /&gt;
The hierarchical model of the chart kernel objects is like below chart.&lt;br /&gt;
&lt;br /&gt;
* Chart Model&lt;br /&gt;
  Titles&lt;br /&gt;
    - Main title&lt;br /&gt;
    - Sub-title&lt;br /&gt;
  Legend&lt;br /&gt;
  Diagram&lt;br /&gt;
    - Chart wall&lt;br /&gt;
    - Chart floor&lt;br /&gt;
    - Coordinate system&lt;br /&gt;
      - Chart type&lt;br /&gt;
        - Data series&lt;br /&gt;
          - Data sequence&lt;br /&gt;
          - Data points&lt;br /&gt;
&lt;br /&gt;
http://wiki.services.openoffice.org/w/images/8/8b/ChartElements.jpg&lt;br /&gt;
&lt;br /&gt;
== &amp;#039;&amp;#039;&amp;#039;2. Characters of chart2 Module&amp;#039;&amp;#039;&amp;#039; ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;2.1. Well implemented uno interfaces&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Chart2 module well implemented uno interfaces. These interfaces are located in offapi\com\sun\star\chart which is the old interfaces and offapi\com\sun\star\chart2 which is the new. Each kernel chart objects must implement the corresponding interface defined in the offapi module. In order to keep the consistency with the old interface, some kernel objects implemented the new interface and also aggregated the old interface in the other hand.&lt;br /&gt;
Below chart is an illustration of ChartModel, which implemented the new interface chart2::XChartDocument and aggregated the old interface chart::XChartDocument.&lt;br /&gt;
&lt;br /&gt;
http://wiki.services.openoffice.org/w/images/8/8a/ChartModelInterface.jpg&lt;br /&gt;
&lt;br /&gt;
Below chart is another example to illustrate the interface implementations of some other kernel objects.&lt;br /&gt;
&lt;br /&gt;
http://wiki.services.openoffice.org/w/images/thumb/0/04/ChartInterfaces.jpg/800px-ChartInterfaces.jpg&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;2.2. Typical MVC design pattern&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The source code under chart2 module was categorized into five parts: model, view, controller, inc and tools, which is a typical MVC design pattern.&lt;br /&gt;
*model: kernel objects, binary file: chartmodelmi.dll&lt;br /&gt;
*view: drawing, binary file: chartviewmi.dll&lt;br /&gt;
*controller: events handler, interfaces for outside callers..., binary file: chartcontrollermi.dll&lt;br /&gt;
*tools: tools for chart handling, helper classes, binary file: charttoolsmi.dll&lt;br /&gt;
*inc: private include files&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;2.3. Breakdown of the MVC model&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The section breakdowns the source code under chart2\source to interpret the major functions of each folder under model, view, controller.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;2.3.1. Model&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Folder&lt;br /&gt;
! Major Function&lt;br /&gt;
|-&lt;br /&gt;
| filter&lt;br /&gt;
| Interface with xmloff&lt;br /&gt;
|-&lt;br /&gt;
| main&lt;br /&gt;
| Kernel objects: ChartModel, Diagram, Title, Legend, DataSeries, DataPoint...&lt;br /&gt;
|-&lt;br /&gt;
| template&lt;br /&gt;
| Templates to create each chart type based on the chart data table&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For each chart type, we must have below objects(use bubble chart as illustration):&lt;br /&gt;
* a template (BubbleChartTypeTemplate under source\model\template) to create chart type model based on the original data source&lt;br /&gt;
* a data source interpreter (BubbleDataInterpreter under source\model\template) to interpret the original data source and generate the chart type model according to the corresponding template&lt;br /&gt;
* a chart type model (BubbleChartType under source\model\template)&lt;br /&gt;
* a view object (BubbleChart under source\view\charttypes)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;2.3.2. View&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Folder&lt;br /&gt;
! Major Function&lt;br /&gt;
|-&lt;br /&gt;
| axes&lt;br /&gt;
| Coordinate system and axes&lt;br /&gt;
|-&lt;br /&gt;
| charttypes&lt;br /&gt;
| Shape creator for individual chart types&lt;br /&gt;
|-&lt;br /&gt;
| diagram&lt;br /&gt;
| View of diagram&lt;br /&gt;
|-&lt;br /&gt;
| main&lt;br /&gt;
| Kernel view objects: ChartView, VLegend, VTitle, VDataSeries...&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
VDataSeries contains view information for a data series, for example, X value, Y value, which coordinate this data series will be applied to(the diagram might contain two coordinate systems, main coordinate system and secondary coordinate system). Then chartypes uses these information to draw the corresponding shapes for each data point.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;2.3.3. controller&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Folder&lt;br /&gt;
! Major Function&lt;br /&gt;
|-&lt;br /&gt;
| accessibility&lt;br /&gt;
| ACC&lt;br /&gt;
|-&lt;br /&gt;
| chartapiwrapper&lt;br /&gt;
| Interfaces for outside callers&lt;br /&gt;
|-&lt;br /&gt;
| dialogs&lt;br /&gt;
| Chart internal dialogs&lt;br /&gt;
|-&lt;br /&gt;
| drawinglayer&lt;br /&gt;
| Bridge between drawing layer and SdrObject&lt;br /&gt;
|-&lt;br /&gt;
| itemsetwrapper&lt;br /&gt;
| Converter between property set and item set&lt;br /&gt;
|-&lt;br /&gt;
| main&lt;br /&gt;
| Major controllers: event handling, command dispatch...&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Each visual object in chart will also correspond a SdrObject. drawinglayer is responsible for establishing a bridge between the visual objects to it&amp;#039;s concrete SdrObject.&lt;br /&gt;
&lt;br /&gt;
Under AOO&amp;#039;s architecture, SfxItemSet is generally used to transfer object attributes. But as fore-mentioned, each object in chart2 module implemented uno interface, so XPropertySet which is a uno interface is used to transfer attributes within the chart2 module. Therefore itemsetwrapper was designed to be responsible for converting the attributes between SfxItemSet and XPropertySet.&lt;br /&gt;
&lt;br /&gt;
== &amp;#039;&amp;#039;&amp;#039;3. Model, View, Wrapper and Helper&amp;#039;&amp;#039;&amp;#039; ==&lt;br /&gt;
&lt;br /&gt;
In general, a concrete model object will correspond a object set which contains four class. We use [Object] as the placeholder of the model object. &lt;br /&gt;
* [Object]: kernel object in model&lt;br /&gt;
* V[Object]: view-side object corresponding to model&lt;br /&gt;
* [Object]Wrapper: wrapper to access the kernel object for outside callers&lt;br /&gt;
* [Object]Helper: tool to create model object, or get/set the internal attributes of the model&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
* Diagram, VDiagram, DiagramWrapper, DiagramHelper&lt;br /&gt;
* Title, VTitle, TitleWrapper, TitleHelper&lt;br /&gt;
* Legend, VLegend, LegendWrapper, LegendHelper&lt;br /&gt;
&lt;br /&gt;
== &amp;#039;&amp;#039;&amp;#039;4. Chart handling process&amp;#039;&amp;#039;&amp;#039; ==&lt;br /&gt;
&lt;br /&gt;
This section will use two typical process to interpret how the chart model works to create each MVC objects. The first order is top to bottom; the second order is left to right.&lt;br /&gt;
&lt;br /&gt;
Legend: M – Model; V – View; C – Controller; T – Tools&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;4.1. Create a default column chart&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
http://wiki.services.openoffice.org/w/images/thumb/b/b9/CreateDefaultChartProcess.jpg/800px-CreateDefaultChartProcess.jpg&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;4.2. Create a title on chart&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
http://wiki.services.openoffice.org/w/images/thumb/6/6d/CreateTitleProcess.jpg/800px-CreateTitleProcess.jpg&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Chart_Filter_Process&amp;diff=200376</id>
		<title>Calc/Implementation/Chart Filter Process</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Chart_Filter_Process&amp;diff=200376"/>
		<updated>2012-04-28T05:10:49Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This wiki is about the ODF filter process of chart.&lt;br /&gt;
&lt;br /&gt;
== &amp;#039;&amp;#039;&amp;#039;Classes&amp;#039;&amp;#039;&amp;#039; ==&lt;br /&gt;
&lt;br /&gt;
In ODF filter (xmloff), there are 4 major classes used to do filter works of key chart elements:&lt;br /&gt;
* SchXMLChartContext for whole chart&lt;br /&gt;
* SchXMLPlotAreaContext for chart area&lt;br /&gt;
* SchXMLSeries2Context for data series&lt;br /&gt;
* SchXMLDataPointContext for data points&lt;br /&gt;
&lt;br /&gt;
SchXMLChartContext creates SchXMLPlotAreaContext after call it&amp;#039;s StartElement method;  SchXMLPlotAreaContext creates SchXMLSeries2Context,  SchXMLSeries2Context creates SchXMLDataPointContext respectively after call their StartElement method.&lt;br /&gt;
&lt;br /&gt;
http://wiki.services.openoffice.org/w/images/thumb/3/36/ChartFilterObjects.jpg/675px-ChartFilterObjects.jpg&lt;br /&gt;
&lt;br /&gt;
SchXMLChartContext has a critical member maSeriesDefaultsAndStyles which stores default values for series and styles for series and data points. This member will be passed to SchXMLPlotAreaContext, SchXMLSeries2Context and SchXMLDataPointContext one by one as reference because the values can only be filled when the corresponding context begin to work.&lt;br /&gt;
Another critical member in SchXMLChartContext is mbAllRangeAddressesAvailable, which means whether the data sequences are all valid. For some charts, in special for stock charts, if the data source range is not correct, the chart will contain some empty data sequences. In this case, mbAllRangeAddressesAvailable will be false.&lt;br /&gt;
Similar as maSeriesDefaultsAndStyles, it is also passed to SchXMLPlotAreaContext and lower context one by one as reference and will be filled when the corresponding context begin to work.&lt;br /&gt;
&lt;br /&gt;
http://wiki.services.openoffice.org/w/images/4/4d/ChartFilterClasses.jpg&lt;br /&gt;
&lt;br /&gt;
== &amp;#039;&amp;#039;&amp;#039;Import Process&amp;#039;&amp;#039;&amp;#039; ==&lt;br /&gt;
&lt;br /&gt;
This process is for both data series in column and data series in row. Paste will follow the same process.&lt;br /&gt;
But this process is only for chart whose mbAllRangeAddressesAvailable of SchXMLChartContext is true, which means there are no empty data sequence.&lt;br /&gt;
&lt;br /&gt;
http://wiki.services.openoffice.org/w/images/thumb/1/11/ChartImportProcess.jpg/800px-ChartImportProcess.jpg&lt;br /&gt;
&lt;br /&gt;
== &amp;#039;&amp;#039;&amp;#039;Export Process&amp;#039;&amp;#039;&amp;#039; ==&lt;br /&gt;
&lt;br /&gt;
This process is for both data series in column and data series in row. Copy will follow the same process.&lt;br /&gt;
&lt;br /&gt;
http://wiki.services.openoffice.org/w/images/thumb/b/b2/ChartExportProcess.jpg/800px-ChartExportProcess.jpg&lt;br /&gt;
&lt;br /&gt;
== &amp;#039;&amp;#039;&amp;#039;Import Process for charts which contain empty data sequences&amp;#039;&amp;#039;&amp;#039; ==&lt;br /&gt;
&lt;br /&gt;
In this case, mbAllRangeAddressesAvailable of SchXMLChartContext is false. Basically, the process is same as normal import. The only difference is at the beginning of SchXMLChartContext.EndElement, it will additionally call ApplyDataFromRectangularRangeToDiagram because mbAllRangeAddressesAvailable is false. In this method, it will reorganise the data series, which will probably make delete old series and reset to new ones.&lt;br /&gt;
&lt;br /&gt;
http://wiki.services.openoffice.org/w/images/thumb/4/4f/ChartComplexExportProcess.jpg/800px-ChartComplexExportProcess.jpg&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Chart_Filter_Process&amp;diff=200375</id>
		<title>Chart Filter Process</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Chart_Filter_Process&amp;diff=200375"/>
		<updated>2012-04-28T05:09:39Z</updated>

		<summary type="html">&lt;p&gt;Leiw: moved Chart Filter Process to Calc/Implementation/Chart Filter Process&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Calc/Implementation/Chart Filter Process]]&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Chart_Filter_Process&amp;diff=200374</id>
		<title>Calc/Implementation/Chart Filter Process</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Chart_Filter_Process&amp;diff=200374"/>
		<updated>2012-04-28T05:09:39Z</updated>

		<summary type="html">&lt;p&gt;Leiw: moved Chart Filter Process to Calc/Implementation/Chart Filter Process&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki is about the ODF filter process of chart.&lt;br /&gt;
&lt;br /&gt;
== &amp;#039;&amp;#039;&amp;#039;Classes&amp;#039;&amp;#039;&amp;#039; ==&lt;br /&gt;
&lt;br /&gt;
In ODF filter (xmloff), there are 4 major classes used to do filter works of key chart elements:&lt;br /&gt;
* SchXMLChartContext for whole chart&lt;br /&gt;
* SchXMLPlotAreaContext for chart area&lt;br /&gt;
* SchXMLSeries2Context for data series&lt;br /&gt;
* SchXMLDataPointContext for data points&lt;br /&gt;
&lt;br /&gt;
SchXMLChartContext creates SchXMLPlotAreaContext after call it&amp;#039;s StartElement method;  SchXMLPlotAreaContext creates SchXMLSeries2Context,  SchXMLSeries2Context creates SchXMLDataPointContext respectively after call their StartElement method.&lt;br /&gt;
&lt;br /&gt;
http://wiki.services.openoffice.org/w/images/thumb/3/36/ChartFilterObjects.jpg/675px-ChartFilterObjects.jpg&lt;br /&gt;
&lt;br /&gt;
SchXMLChartContext has a critical member maSeriesDefaultsAndStyles which stores default values for series and styles for series and data points. This member will be passed to SchXMLPlotAreaContext, SchXMLSeries2Context and SchXMLDataPointContext one by one as reference because the values can only be filled when the corresponding context begin to work.&lt;br /&gt;
Another critical member in SchXMLChartContext is mbAllRangeAddressesAvailable, which means whether the data sequences are all valid. For some charts, in special for stock charts, if the data source range is not correct, the chart will contain some empty data sequences. In this case, mbAllRangeAddressesAvailable will be false.&lt;br /&gt;
Similar as maSeriesDefaultsAndStyles, it is also passed to SchXMLPlotAreaContext and lower context one by one as reference and will be filled when the corresponding context begin to work.&lt;br /&gt;
&lt;br /&gt;
http://wiki.services.openoffice.org/w/images/4/4d/ChartFilterClasses.jpg&lt;br /&gt;
&lt;br /&gt;
== &amp;#039;&amp;#039;&amp;#039;Import Process&amp;#039;&amp;#039;&amp;#039; ==&lt;br /&gt;
&lt;br /&gt;
This process is for both data series in column and data series in row. Paste will follow the same process.&lt;br /&gt;
But this process is only for chart whose mbAllRangeAddressesAvailable of SchXMLChartContext is true, which means there are no empty data sequence.&lt;br /&gt;
&lt;br /&gt;
http://wiki.services.openoffice.org/w/images/thumb/1/11/ChartImportProcess.jpg/800px-ChartImportProcess.jpg&lt;br /&gt;
&lt;br /&gt;
== &amp;#039;&amp;#039;&amp;#039;Export Process&amp;#039;&amp;#039;&amp;#039; ==&lt;br /&gt;
&lt;br /&gt;
This process is for both data series in column and data series in row. Copy will follow the same process.&lt;br /&gt;
&lt;br /&gt;
http://wiki.services.openoffice.org/w/images/thumb/b/b2/ChartExportProcess.jpg/800px-ChartExportProcess.jpg&lt;br /&gt;
&lt;br /&gt;
== &amp;#039;&amp;#039;&amp;#039;Import Process for charts which contain empty data sequences&amp;#039;&amp;#039;&amp;#039; ==&lt;br /&gt;
&lt;br /&gt;
In this case, mbAllRangeAddressesAvailable of SchXMLChartContext is false. Basically, the process is same as normal import. The only difference is at the beginning of SchXMLChartContext.EndElement, it will additionally call ApplyDataFromRectangularRangeToDiagram because mbAllRangeAddressesAvailable is false. In this method, it will reorganise the data series, which will probably make delete old series and reset to new ones.&lt;br /&gt;
&lt;br /&gt;
http://wiki.services.openoffice.org/w/images/thumb/4/4f/ChartComplexExportProcess.jpg/800px-ChartComplexExportProcess.jpg&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Calc_copy_paste&amp;diff=200347</id>
		<title>Calc/Implementation/Calc copy paste</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Calc_copy_paste&amp;diff=200347"/>
		<updated>2012-04-27T08:44:52Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
== Copy&amp;amp;paste,clipboard concepts ==&lt;br /&gt;
&lt;br /&gt;
*Clipboard&lt;br /&gt;
Users can copy, cut and paste information such as text and pictures from one program into another or between different editors. The Clipboard stores your information, which can be a picture or a section of text from a word processor, in a temporary storage, enabling you to move that snippet of information from one place to another.&lt;br /&gt;
&lt;br /&gt;
The clipboard is a software facility that can be used for short-term data storage and/or data transfer between documents or applications, via copy and paste operations. It is most commonly a part of a GUI environment and is usually implemented as an anonymous, temporary data buffer that can be accessed from programs within the environment via defined programming interfaces. A typical application accesses clipboard functionality by mapping user input (keybindings, menu selections, etc.) to these interfaces.&lt;br /&gt;
&lt;br /&gt;
*OLE clipboard&lt;br /&gt;
Microsoft Windows defines a number of standard formats that can be used for transferring data through the Clipboard. These include metafiles, text, bitmaps, and others. OLE defines a number of OLE-specific formats, as well. It is a good idea for applications that need more detail than given by these standard formats to register their own custom Clipboard formats.&lt;br /&gt;
&lt;br /&gt;
For example, Microsoft Excel registers a custom format for spreadsheets. This format carries much more information than, for example, a bitmap does. When this data is pasted into an application that supports the spreadsheet format, all the formulas and values from the spreadsheet are retained and can be updated if necessary. Microsoft Excel also puts data on the Clipboard in formats so that it can be pasted as an OLE item. Any OLE document container can paste this information as an embedded item.&lt;br /&gt;
&lt;br /&gt;
== System clipboard and internal clipboard in OpenOffice ==&lt;br /&gt;
&lt;br /&gt;
When copy&amp;amp;paste, the operation system will tell the clipboard how many formats it can be supported to do data exchange and transfer, this process is called format register. &lt;br /&gt;
This figure will show the registered formats when copy a picture in Microsoft windows.&lt;br /&gt;
&lt;br /&gt;
[[File:Window_clipboard.png]]&lt;br /&gt;
&lt;br /&gt;
when doing copy in OpenOffice, the register action occurred at first, and OpenOffice will collect all supported formats and register them to the clipboard of operation system. &lt;br /&gt;
For example, in presentation, in the function of SdTransferable::AddSupportedFormats(), it will call TransferableHelper::AddFormat() to add a single format.&lt;br /&gt;
&lt;br /&gt;
There are two kinds of clipboard in OpenOffice, external clipboard and internal clipboard. &lt;br /&gt;
Here is the top structure of copy&amp;amp;paster in OpenOffice.&lt;br /&gt;
&lt;br /&gt;
[[File:Copy_paste_structure.JPG]]&lt;br /&gt;
&lt;br /&gt;
The class of SotExchange is a data format manager for system clipboard. It will initialize an array to represent data format.&lt;br /&gt;
The class of DataFlavorRepresentation has three member variables: pMimeType, pName and pType. &lt;br /&gt;
The pMimeType indicates the MIME content-type(type/subtype) string describing the data format of the object to transfer. MimeType must follows the RFC2045 and RFC2046(Request For Comments). The pName indicates a human readable name for the data format, The pType indicates the type of the object to transfer, for example, xOutputStream.&lt;br /&gt;
Here take RTF format as an example:&lt;br /&gt;
The values of that three variables are like this(defined in the file of sot/source/base/exchange.cxx):&lt;br /&gt;
{ &amp;quot;text/richtext&amp;quot;, &amp;quot;Rich Text Format&amp;quot;, &amp;amp;::getCppuType( (const Sequence&amp;lt; sal_Int8 &amp;gt;*) 0 ) }.&lt;br /&gt;
&lt;br /&gt;
The other data structure is DataFlavor, it is a struct in the ::com::sun::star::datatransfer namespace. The real function of DataFlavor is equal with  DataFlavorRepresentation, these two structs can be mapped each other. DataFlavor can be used by UNO API.&lt;br /&gt;
&lt;br /&gt;
The external clipboard is a wrapper of operate system clipboard and it cooperated with OpenOffice &amp;#039;s Data Transfer Classes to transfer data between operate system clipboard and itself. External clipboard is a bridge between operation system clipboard and the applications in OpenOffice. &lt;br /&gt;
&lt;br /&gt;
The internal clipboard is used for private data transfer in the applications of OpenOffice.&lt;br /&gt;
The internal clipboard,copy&amp;amp;paste may be executed in the same document or same kind of documents in a same process, such as copying some data in a Writer document to paste these data to another Writer document. For the efficiency consideration, OpenOffice uses internal clipboard to do copy&amp;amp;paste in such scenarios.&lt;br /&gt;
Which object can handle internal clipboard? The answer is document module, such as ScModule, SdModule and SwModule. Document module can be a bridge for the documents with same type in a same process. So those documents with the same type can copy&amp;amp;paste through internal clipboard directly.&lt;br /&gt;
When doing a copy&amp;amp;paste between documents with different types, the internal clipboard can not be used anymore, because the module of the document type is unknown by the other.&lt;br /&gt;
The internal clipboard can be represented by a figure like:&lt;br /&gt;
&lt;br /&gt;
[[File:Scmodule.JPG]]&lt;br /&gt;
&lt;br /&gt;
== Process of copy&amp;amp;paste in spreadsheet ==&lt;br /&gt;
&lt;br /&gt;
When getting data from clipboard, the real data transferring starts immediately. Operation system will ask OpenOffice to get the real transferable data. &lt;br /&gt;
Openoffice creates the OLE object when copying cells from a sheet and paste them into Writer. In the function of ScTransferObj::InitDocShell (sc/source/ui/app/transobj.cxx),it creates and fills a ScDocShell, which is an embedded object.&lt;br /&gt;
And the main point entry is ScTransferObj::GetData(), which will call InitDocShell to create OLE object by the object format.&lt;br /&gt;
If pasting the object in writer, the real OLE spreadsheet document is inserted.&lt;br /&gt;
&lt;br /&gt;
[[File:ScTransferObj.JPG]]&lt;br /&gt;
&lt;br /&gt;
When copy some cells in a spreadsheet, paste it in the same document, then Openoffice will use the internal clipboard. And Openoffice uses the such logic to make a decision.&lt;br /&gt;
The principle of format selection is more complex, more complex clipboard format is used.&lt;br /&gt;
It is presented in the function of ScViewFunc::PasteFromSystem()&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;small&amp;gt;if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_DRAWING ))&amp;lt;br /&amp;gt;&lt;br /&gt;
{&amp;lt;br /&amp;gt;&lt;br /&gt;
		// special case for tables from drawing&amp;lt;br /&amp;gt;&lt;br /&gt;
		if( aDataHelper.HasFormat( SOT_FORMAT_RTF ) )&amp;lt;br /&amp;gt;&lt;br /&gt;
			PasteFromSystem( FORMAT_RTF );&amp;lt;br /&amp;gt;&lt;br /&gt;
		else		PasteFromSystem( SOT_FORMATSTR_ID_DRAWING );&amp;lt;br /&amp;gt;&lt;br /&gt;
}&amp;lt;br /&amp;gt;&lt;br /&gt;
else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVXB ))&amp;lt;br /&amp;gt;&lt;br /&gt;
		PasteFromSystem( SOT_FORMATSTR_ID_SVXB );&amp;lt;br /&amp;gt;&lt;br /&gt;
Else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE ))&amp;lt;br /&amp;gt;&lt;br /&gt;
	{   ……&amp;lt;br /&amp;gt;&lt;br /&gt;
		if ( bDoRtf )&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem( FORMAT_RTF );&amp;lt;br /&amp;gt;&lt;br /&gt;
			else&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem( SOT_FORMATSTR_ID_EMBED_SOURCE );&amp;lt;br /&amp;gt;&lt;br /&gt;
			}&amp;lt;br /&amp;gt;&lt;br /&gt;
			else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE ))&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem( SOT_FORMATSTR_ID_LINK_SOURCE );&amp;lt;br /&amp;gt;&lt;br /&gt;
			else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE ))&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE );&amp;lt;br /&amp;gt;&lt;br /&gt;
            	else if (aDataHelper.HasFormat(nBiff8))     &amp;lt;br /&amp;gt;&lt;br /&gt;
                	PasteFromSystem(nBiff8);&amp;lt;br /&amp;gt;&lt;br /&gt;
            	else if (aDataHelper.HasFormat(nBiff5))&amp;lt;br /&amp;gt;&lt;br /&gt;
                	PasteFromSystem(nBiff5);&amp;lt;br /&amp;gt;&lt;br /&gt;
			else if (aDataHelper.HasFormat(FORMAT_RTF))&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem(FORMAT_RTF);&amp;lt;br /&amp;gt;&lt;br /&gt;
			else if (aDataHelper.HasFormat(SOT_FORMATSTR_ID_HTML))&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem(SOT_FORMATSTR_ID_HTML);&amp;lt;br /&amp;gt;&lt;br /&gt;
			else if (aDataHelper.HasFormat(SOT_FORMATSTR_ID_HTML_SIMPLE))&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem(SOT_FORMATSTR_ID_HTML_SIMPLE);&amp;lt;br /&amp;gt;&lt;br /&gt;
			else if (aDataHelper.HasFormat(SOT_FORMATSTR_ID_SYLK))&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem(SOT_FORMATSTR_ID_SYLK);&amp;lt;br /&amp;gt;&lt;br /&gt;
			else if (aDataHelper.HasFormat(FORMAT_STRING))&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem(FORMAT_STRING);&amp;lt;br /&amp;gt;&lt;br /&gt;
			else if (aDataHelper.HasFormat(FORMAT_GDIMETAFILE))&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem(FORMAT_GDIMETAFILE);&amp;lt;br /&amp;gt;&lt;br /&gt;
			else if (aDataHelper.HasFormat(FORMAT_BITMAP))&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem(FORMAT_BITMAP);&amp;lt;br /&amp;gt;&lt;br /&gt;
			else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ))&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE );&amp;lt;br /&amp;gt;&lt;br /&gt;
			else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE_OLE ))&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem( SOT_FORMATSTR_ID_LINK_SOURCE_OLE );&amp;lt;br /&amp;gt;&lt;br /&gt;
            	else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_BITMAP_WINDDB ) )&amp;lt;br /&amp;gt;&lt;br /&gt;
                	PasteFromSystem( SOT_FORMATSTR_ID_BITMAP_WINDDB );&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To the internal clipboard, the main class is ScClipData in the sc\inc\scmod.hxx, it is defined as&amp;lt;br /&amp;gt;&lt;br /&gt;
struct ScClipData&amp;lt;br /&amp;gt;&lt;br /&gt;
{&amp;lt;br /&amp;gt;     &lt;br /&gt;
&lt;br /&gt;
ScTransferObj*		pCellClipboard;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ScDrawTransferObj*	pDrawClipboard;&amp;lt;br /&amp;gt;&lt;br /&gt;
};&amp;lt;br /&amp;gt;&lt;br /&gt;
ScTransferObj is used for the selected cells, ScDrawTransferObj for the selected drawing objects.&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Calc_copy_paste&amp;diff=200346</id>
		<title>Calc/Implementation/Calc copy paste</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Calc_copy_paste&amp;diff=200346"/>
		<updated>2012-04-27T08:41:17Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Copy&amp;amp;paste,clipboard concepts ==&lt;br /&gt;
&lt;br /&gt;
*Clipboard&lt;br /&gt;
Users can copy, cut and paste information such as text and pictures from one program into another or between different editors. The Clipboard stores your information, which can be a picture or a section of text from a word processor, in a temporary storage, enabling you to move that snippet of information from one place to another.&lt;br /&gt;
&lt;br /&gt;
The clipboard is a software facility that can be used for short-term data storage and/or data transfer between documents or applications, via copy and paste operations. It is most commonly a part of a GUI environment and is usually implemented as an anonymous, temporary data buffer that can be accessed from programs within the environment via defined programming interfaces. A typical application accesses clipboard functionality by mapping user input (keybindings, menu selections, etc.) to these interfaces.&lt;br /&gt;
&lt;br /&gt;
*OLE clipboard&lt;br /&gt;
Microsoft Windows defines a number of standard formats that can be used for transferring data through the Clipboard. These include metafiles, text, bitmaps, and others. OLE defines a number of OLE-specific formats, as well. It is a good idea for applications that need more detail than given by these standard formats to register their own custom Clipboard formats.&lt;br /&gt;
&lt;br /&gt;
For example, Microsoft Excel registers a custom format for spreadsheets. This format carries much more information than, for example, a bitmap does. When this data is pasted into an application that supports the spreadsheet format, all the formulas and values from the spreadsheet are retained and can be updated if necessary. Microsoft Excel also puts data on the Clipboard in formats so that it can be pasted as an OLE item. Any OLE document container can paste this information as an embedded item.&lt;br /&gt;
&lt;br /&gt;
== System clipboard and internal clipboard in OpenOffice ==&lt;br /&gt;
&lt;br /&gt;
When copy&amp;amp;paste, the operation system will tell the clipboard how many formats it can be supported to do data exchange and transfer, this process is called format register. &lt;br /&gt;
This figure will show the registered formats when copy a picture in Microsoft windows.&lt;br /&gt;
&lt;br /&gt;
[[File:Window_clipboard.png]]&lt;br /&gt;
&lt;br /&gt;
when doing copy in OpenOffice, the register action occurred at first, and OpenOffice will collect all supported formats and register them to the clipboard of operation system. &lt;br /&gt;
For example, in presentation, in the function of SdTransferable::AddSupportedFormats(), it will call TransferableHelper::AddFormat() to add a single format.&lt;br /&gt;
&lt;br /&gt;
There are two kinds of clipboard in OpenOffice, external clipboard and internal clipboard. &lt;br /&gt;
Here is the top structure of copy&amp;amp;paster in OpenOffice.&lt;br /&gt;
&lt;br /&gt;
[[File:Copy_paste_structure.JPG]]&lt;br /&gt;
&lt;br /&gt;
The class of SotExchange is a data format manager for system clipboard. It will initialize an array to represent data format.&lt;br /&gt;
The class of DataFlavorRepresentation has three member variables: pMimeType, pName and pType. &lt;br /&gt;
The pMimeType indicates the MIME content-type(type/subtype) string describing the data format of the object to transfer. MimeType must follows the RFC2045 and RFC2046(Request For Comments). The pName indicates a human readable name for the data format, The pType indicates the type of the object to transfer, for example, xOutputStream.&lt;br /&gt;
Here take RTF format as an example:&lt;br /&gt;
The values of that three variables are like this(defined in the file of sot/source/base/exchange.cxx):&lt;br /&gt;
{ &amp;quot;text/richtext&amp;quot;, &amp;quot;Rich Text Format&amp;quot;, &amp;amp;::getCppuType( (const Sequence&amp;lt; sal_Int8 &amp;gt;*) 0 ) }.&lt;br /&gt;
&lt;br /&gt;
The other data structure is DataFlavor, it is a struct in the ::com::sun::star::datatransfer namespace. The real function of DataFlavor is equal with  DataFlavorRepresentation, these two structs can be mapped each other. DataFlavor can be used by UNO API.&lt;br /&gt;
&lt;br /&gt;
The external clipboard is a wrapper of operate system clipboard and it cooperated with OpenOffice &amp;#039;s Data Transfer Classes to transfer data between operate system clipboard and itself. External clipboard is a bridge between operation system clipboard and the applications in OpenOffice. &lt;br /&gt;
&lt;br /&gt;
The internal clipboard is used for private data transfer in the applications of OpenOffice.&lt;br /&gt;
The internal clipboard,copy&amp;amp;paste may be executed in the same document or same kind of documents in a same process, such as copying some data in a Writer document to paste these data to another Writer document. For the efficiency consideration, OpenOffice uses internal clipboard to do copy&amp;amp;paste in such scenarios.&lt;br /&gt;
Which object can handle internal clipboard? The answer is document module, such as ScModule, SdModule and SwModule. Document module can be a bridge for the documents with same type in a same process. So those documents with the same type can copy&amp;amp;paste through internal clipboard directly.&lt;br /&gt;
When doing a copy&amp;amp;paste between documents with different types, the internal clipboard can not be used anymore, because the module of the document type is unknown by the other.&lt;br /&gt;
The internal clipboard can be represented by a figure like:&lt;br /&gt;
&lt;br /&gt;
[[File:Scmodule.JPG]]&lt;br /&gt;
&lt;br /&gt;
== Process of copy&amp;amp;paste in spreadsheet ==&lt;br /&gt;
&lt;br /&gt;
When getting data from clipboard, the real data transferring starts immediately. Operation system will ask OpenOffice to get the real transferable data. &lt;br /&gt;
Openoffice creates the OLE object when copying cells from a sheet and paste them into Writer. In the function of ScTransferObj::InitDocShell (sc/source/ui/app/transobj.cxx),it creates and fills a ScDocShell, which is an embedded object.&lt;br /&gt;
And the main point entry is ScTransferObj::GetData(), which will call InitDocShell to create OLE object by the object format.&lt;br /&gt;
If pasting the object in writer, the real OLE spreadsheet document is inserted.&lt;br /&gt;
&lt;br /&gt;
[[File:ScTransferObj.JPG]]&lt;br /&gt;
&lt;br /&gt;
When copy some cells in a spreadsheet, paste it in the same document, then Openoffice will use the internal clipboard. And Openoffice uses the such logic to make a decision.&lt;br /&gt;
The principle of format selection is more complex, more complex clipboard format is used.&lt;br /&gt;
It is presented in the function of ScViewFunc::PasteFromSystem()&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;small&amp;gt;if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_DRAWING ))&amp;lt;br /&amp;gt;&lt;br /&gt;
{&amp;lt;br /&amp;gt;&lt;br /&gt;
		// special case for tables from drawing&amp;lt;br /&amp;gt;&lt;br /&gt;
		if( aDataHelper.HasFormat( SOT_FORMAT_RTF ) )&amp;lt;br /&amp;gt;&lt;br /&gt;
			PasteFromSystem( FORMAT_RTF );&amp;lt;br /&amp;gt;&lt;br /&gt;
		else		PasteFromSystem( SOT_FORMATSTR_ID_DRAWING );&amp;lt;br /&amp;gt;&lt;br /&gt;
}&amp;lt;br /&amp;gt;&lt;br /&gt;
else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVXB ))&amp;lt;br /&amp;gt;&lt;br /&gt;
		PasteFromSystem( SOT_FORMATSTR_ID_SVXB );&amp;lt;br /&amp;gt;&lt;br /&gt;
Else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE ))&amp;lt;br /&amp;gt;&lt;br /&gt;
	{   ……&amp;lt;br /&amp;gt;&lt;br /&gt;
		if ( bDoRtf )&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem( FORMAT_RTF );&amp;lt;br /&amp;gt;&lt;br /&gt;
			else&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem( SOT_FORMATSTR_ID_EMBED_SOURCE );&amp;lt;br /&amp;gt;&lt;br /&gt;
			}&amp;lt;br /&amp;gt;&lt;br /&gt;
			else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE ))&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem( SOT_FORMATSTR_ID_LINK_SOURCE );&amp;lt;br /&amp;gt;&lt;br /&gt;
			else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE ))&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE );&amp;lt;br /&amp;gt;&lt;br /&gt;
            	else if (aDataHelper.HasFormat(nBiff8))     &amp;lt;br /&amp;gt;&lt;br /&gt;
                	PasteFromSystem(nBiff8);&amp;lt;br /&amp;gt;&lt;br /&gt;
            	else if (aDataHelper.HasFormat(nBiff5))&amp;lt;br /&amp;gt;&lt;br /&gt;
                	PasteFromSystem(nBiff5);&amp;lt;br /&amp;gt;&lt;br /&gt;
			else if (aDataHelper.HasFormat(FORMAT_RTF))&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem(FORMAT_RTF);&amp;lt;br /&amp;gt;&lt;br /&gt;
			else if (aDataHelper.HasFormat(SOT_FORMATSTR_ID_HTML))&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem(SOT_FORMATSTR_ID_HTML);&amp;lt;br /&amp;gt;&lt;br /&gt;
			else if (aDataHelper.HasFormat(SOT_FORMATSTR_ID_HTML_SIMPLE))&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem(SOT_FORMATSTR_ID_HTML_SIMPLE);&amp;lt;br /&amp;gt;&lt;br /&gt;
			else if (aDataHelper.HasFormat(SOT_FORMATSTR_ID_SYLK))&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem(SOT_FORMATSTR_ID_SYLK);&amp;lt;br /&amp;gt;&lt;br /&gt;
			else if (aDataHelper.HasFormat(FORMAT_STRING))&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem(FORMAT_STRING);&amp;lt;br /&amp;gt;&lt;br /&gt;
			else if (aDataHelper.HasFormat(FORMAT_GDIMETAFILE))&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem(FORMAT_GDIMETAFILE);&amp;lt;br /&amp;gt;&lt;br /&gt;
			else if (aDataHelper.HasFormat(FORMAT_BITMAP))&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem(FORMAT_BITMAP);&amp;lt;br /&amp;gt;&lt;br /&gt;
			else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ))&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE );&amp;lt;br /&amp;gt;&lt;br /&gt;
			else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE_OLE ))&amp;lt;br /&amp;gt;&lt;br /&gt;
				PasteFromSystem( SOT_FORMATSTR_ID_LINK_SOURCE_OLE );&amp;lt;br /&amp;gt;&lt;br /&gt;
            	else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_BITMAP_WINDDB ) )&amp;lt;br /&amp;gt;&lt;br /&gt;
                	PasteFromSystem( SOT_FORMATSTR_ID_BITMAP_WINDDB );&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To the internal clipboard, the main class is ScClipData in the sc\inc\scmod.hxx, it is defined as&amp;lt;br /&amp;gt;&lt;br /&gt;
struct ScClipData&amp;lt;br /&amp;gt;&lt;br /&gt;
{&amp;lt;br /&amp;gt;     &lt;br /&gt;
&lt;br /&gt;
ScTransferObj*		pCellClipboard;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ScDrawTransferObj*	pDrawClipboard;&amp;lt;br /&amp;gt;&lt;br /&gt;
};&amp;lt;br /&amp;gt;&lt;br /&gt;
ScTransferObj is used for the selected cells, ScDrawTransferObj for the selected drawing objects.&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=User:Leiw&amp;diff=200228</id>
		<title>User:Leiw</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=User:Leiw&amp;diff=200228"/>
		<updated>2012-04-15T14:50:31Z</updated>

		<summary type="html">&lt;p&gt;Leiw: moved User:Leiw to Calc/Implementation/Data Model for sheet and cell&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Calc/Implementation/Data Model for sheet and cell]]&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Data_Model_for_sheet_and_cell&amp;diff=200227</id>
		<title>Calc/Implementation/Data Model for sheet and cell</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Data_Model_for_sheet_and_cell&amp;diff=200227"/>
		<updated>2012-04-15T14:50:30Z</updated>

		<summary type="html">&lt;p&gt;Leiw: moved User:Leiw to Calc/Implementation/Data Model for sheet and cell&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
== The relationship between document, table, column and cell ==&lt;br /&gt;
&lt;br /&gt;
From Spreadsheet user&amp;#039;s view, a Spreadsheet document is composed by several tables. Each table contains many cells which are organized by row and column. The codes just reflect this fact. ScDocument(Spreadsheet document) has a one dimension fix size(MAXTABCOUNT=256) array member. Each element in the array is a pointer to a ScTable. But ScTable does not contain a two dimension array, which covers every cells, since most of cells are empty. If every cell is stored in table, it need huge memory to contain 1G(1M rows * 1024 columns) cell objects/pointers for one table. Cells are organized in column. ScTable has a fix size (MAXCOLCOUNT=1024) array member. Each element in the array is a ScColumn object. ScColumn only stores useful cells, which is not empty cell or empty cell is referenced by other cell directly. ScColumn uses a dynamic array ScColumn::pItems to store cells. &lt;br /&gt;
&lt;br /&gt;
== Column, the building block of Spreadsheet ==&lt;br /&gt;
&lt;br /&gt;
Cell is the basic element in a Spreadsheet. There are two kinds of data structure related with cell. One is related with content, ScBaseCell(and its sub). The other is related with property, ScPatternAttr. ScColumn does not only store cell content, but also store cell property. &lt;br /&gt;
ScColumn::pItems is the a dynamic array holds cells. The sequence of cells in ScColumn::pItems is by their row number from small to big. The element in the array is the object of ColEntry, which hold a ScBaseCell pointer and corresponding row number(nRow). ScColumn::nCount is the number of cells stored in the column. ScColumn:nLimit is size of the dynamic array which does not need to resize to hold more cells. Please refer to ScColumn::Insert(SCROW nRow, ScBaseCell* pNewCell), ScColumn::Delete(SCROW nRow) and ScColumn::Append(SCROW nRow, ScBaseCell* pNewCell) to get more info about how this dynamic array work. Users can use index to retrieve the cell(pItems[index]). The index can be found by ScColumn::Search(SCROW nRow, SCSIZE&amp;amp; nIndex) from a row number.&lt;br /&gt;
Every cell has properties. But not every cell&amp;#039;s properties are stored as an individual object. If adjacent cells have same properties, they use one ScPatternAttr object. ScAttrArray is the data structure to hold cell&amp;#039;s properties in one column. ScAttrArray::pData is the dynamic array holds properties. ScAttrArray::nCount and ScAttrArray::nLimit are similar to other dynamic array. The element in the array is the object of ScAttrEntry, which hold a ScPatternAttr pointer and a related row number info(nRow). The nRow indicate the last row in an adjacent cell range which has same properties. For an example like following, the row from 7 to the end of column are same.&lt;br /&gt;
&lt;br /&gt;
[[File:ScDataModel.png]]&lt;br /&gt;
&lt;br /&gt;
The initial status of ScAttrArray has one element in pData, which pData[0].row is MAX_ROW, pData[0].pPattern is default pattern. That means whole column has default property. When user set cell&amp;#039;s property, it may divide the range into pieces and add new ScAttrEntry. Sometimes, setting cell&amp;#039;s property may merge adjacent ScAttrEntry into one because they have same properties. Please refer ScAttrArray::SetPatternArea(...) for more detail.&lt;br /&gt;
&lt;br /&gt;
== SfxPoolItem, SfxItemPool and SfxItemSet ==&lt;br /&gt;
&lt;br /&gt;
From object property&amp;#039;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&amp;#039;s every properties independently, it must use huge of memory. So there is a pool to hold the SfxPoolItems, SfxItemPool.&lt;br /&gt;
Let&amp;#039;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. &lt;br /&gt;
&lt;br /&gt;
[[File:SfxItemPool.png]]&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
All obejcts&amp;#039; 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&amp;amp; rItem)for detail info.&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== ScPatternAttr, SfxSetItem and SfxItemSet ==&lt;br /&gt;
&lt;br /&gt;
SfxSetItem is sub class of SfxPoolItem. It is a kind of SfxPoolItem, which just wrap a SfxItemSet. ScPatternAttr is sub class of SfxSetItem. It represents cell&amp;#039;s attributes, including text attributes, number format attributes, background attributes, border attributes, etc. Most SfxPoolItems do not have many instant because a specific property does not have many different value in one document. But for ScPatternAttr, it can have maximum 53 sub attributes. It may have a lot of instances, which make size of SfxPoolItemArray_Impl::pData large. So when put a ScPatternAttr in the pool, it need a lot of comparison. Each comparison for two ScPatternAttr need compare all its sub attributes. It is time consuming, especially for putting an existed ScPatternAttr into the pool. Developer need pay more attention for this potential performance bottleneck.&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Data_Model_for_sheet_and_cell&amp;diff=200226</id>
		<title>Calc/Implementation/Data Model for sheet and cell</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Data_Model_for_sheet_and_cell&amp;diff=200226"/>
		<updated>2012-04-15T14:48:46Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
== The relationship between document, table, column and cell ==&lt;br /&gt;
&lt;br /&gt;
From Spreadsheet user&amp;#039;s view, a Spreadsheet document is composed by several tables. Each table contains many cells which are organized by row and column. The codes just reflect this fact. ScDocument(Spreadsheet document) has a one dimension fix size(MAXTABCOUNT=256) array member. Each element in the array is a pointer to a ScTable. But ScTable does not contain a two dimension array, which covers every cells, since most of cells are empty. If every cell is stored in table, it need huge memory to contain 1G(1M rows * 1024 columns) cell objects/pointers for one table. Cells are organized in column. ScTable has a fix size (MAXCOLCOUNT=1024) array member. Each element in the array is a ScColumn object. ScColumn only stores useful cells, which is not empty cell or empty cell is referenced by other cell directly. ScColumn uses a dynamic array ScColumn::pItems to store cells. &lt;br /&gt;
&lt;br /&gt;
== Column, the building block of Spreadsheet ==&lt;br /&gt;
&lt;br /&gt;
Cell is the basic element in a Spreadsheet. There are two kinds of data structure related with cell. One is related with content, ScBaseCell(and its sub). The other is related with property, ScPatternAttr. ScColumn does not only store cell content, but also store cell property. &lt;br /&gt;
ScColumn::pItems is the a dynamic array holds cells. The sequence of cells in ScColumn::pItems is by their row number from small to big. The element in the array is the object of ColEntry, which hold a ScBaseCell pointer and corresponding row number(nRow). ScColumn::nCount is the number of cells stored in the column. ScColumn:nLimit is size of the dynamic array which does not need to resize to hold more cells. Please refer to ScColumn::Insert(SCROW nRow, ScBaseCell* pNewCell), ScColumn::Delete(SCROW nRow) and ScColumn::Append(SCROW nRow, ScBaseCell* pNewCell) to get more info about how this dynamic array work. Users can use index to retrieve the cell(pItems[index]). The index can be found by ScColumn::Search(SCROW nRow, SCSIZE&amp;amp; nIndex) from a row number.&lt;br /&gt;
Every cell has properties. But not every cell&amp;#039;s properties are stored as an individual object. If adjacent cells have same properties, they use one ScPatternAttr object. ScAttrArray is the data structure to hold cell&amp;#039;s properties in one column. ScAttrArray::pData is the dynamic array holds properties. ScAttrArray::nCount and ScAttrArray::nLimit are similar to other dynamic array. The element in the array is the object of ScAttrEntry, which hold a ScPatternAttr pointer and a related row number info(nRow). The nRow indicate the last row in an adjacent cell range which has same properties. For an example like following, the row from 7 to the end of column are same.&lt;br /&gt;
&lt;br /&gt;
[[File:ScDataModel.png]]&lt;br /&gt;
&lt;br /&gt;
The initial status of ScAttrArray has one element in pData, which pData[0].row is MAX_ROW, pData[0].pPattern is default pattern. That means whole column has default property. When user set cell&amp;#039;s property, it may divide the range into pieces and add new ScAttrEntry. Sometimes, setting cell&amp;#039;s property may merge adjacent ScAttrEntry into one because they have same properties. Please refer ScAttrArray::SetPatternArea(...) for more detail.&lt;br /&gt;
&lt;br /&gt;
== SfxPoolItem, SfxItemPool and SfxItemSet ==&lt;br /&gt;
&lt;br /&gt;
From object property&amp;#039;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&amp;#039;s every properties independently, it must use huge of memory. So there is a pool to hold the SfxPoolItems, SfxItemPool.&lt;br /&gt;
Let&amp;#039;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. &lt;br /&gt;
&lt;br /&gt;
[[File:SfxItemPool.png]]&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
All obejcts&amp;#039; 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&amp;amp; rItem)for detail info.&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== ScPatternAttr, SfxSetItem and SfxItemSet ==&lt;br /&gt;
&lt;br /&gt;
SfxSetItem is sub class of SfxPoolItem. It is a kind of SfxPoolItem, which just wrap a SfxItemSet. ScPatternAttr is sub class of SfxSetItem. It represents cell&amp;#039;s attributes, including text attributes, number format attributes, background attributes, border attributes, etc. Most SfxPoolItems do not have many instant because a specific property does not have many different value in one document. But for ScPatternAttr, it can have maximum 53 sub attributes. It may have a lot of instances, which make size of SfxPoolItemArray_Impl::pData large. So when put a ScPatternAttr in the pool, it need a lot of comparison. Each comparison for two ScPatternAttr need compare all its sub attributes. It is time consuming, especially for putting an existed ScPatternAttr into the pool. Developer need pay more attention for this potential performance bottleneck.&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=File:ScDataModel.png&amp;diff=200225</id>
		<title>File:ScDataModel.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=File:ScDataModel.png&amp;diff=200225"/>
		<updated>2012-04-15T14:48:24Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=File:SfxItemPool.png&amp;diff=200224</id>
		<title>File:SfxItemPool.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=File:SfxItemPool.png&amp;diff=200224"/>
		<updated>2012-04-15T14:46:46Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Data_Model_for_sheet_and_cell&amp;diff=200223</id>
		<title>Calc/Implementation/Data Model for sheet and cell</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Data_Model_for_sheet_and_cell&amp;diff=200223"/>
		<updated>2012-04-15T14:44:40Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
== The relationship between document, table, column and cell ==&lt;br /&gt;
&lt;br /&gt;
From Spreadsheet user&amp;#039;s view, a Spreadsheet document is composed by several tables. Each table contains many cells which are organized by row and column. The codes just reflect this fact. ScDocument(Spreadsheet document) has a one dimension fix size(MAXTABCOUNT=256) array member. Each element in the array is a pointer to a ScTable. But ScTable does not contain a two dimension array, which covers every cells, since most of cells are empty. If every cell is stored in table, it need huge memory to contain 1G(1M rows * 1024 columns) cell objects/pointers for one table. Cells are organized in column. ScTable has a fix size (MAXCOLCOUNT=1024) array member. Each element in the array is a ScColumn object. ScColumn only stores useful cells, which is not empty cell or empty cell is referenced by other cell directly. ScColumn uses a dynamic array ScColumn::pItems to store cells. &lt;br /&gt;
&lt;br /&gt;
== Column, the building block of Spreadsheet ==&lt;br /&gt;
&lt;br /&gt;
Cell is the basic element in a Spreadsheet. There are two kinds of data structure related with cell. One is related with content, ScBaseCell(and its sub). The other is related with property, ScPatternAttr. ScColumn does not only store cell content, but also store cell property. &lt;br /&gt;
ScColumn::pItems is the a dynamic array holds cells. The sequence of cells in ScColumn::pItems is by their row number from small to big. The element in the array is the object of ColEntry, which hold a ScBaseCell pointer and corresponding row number(nRow). ScColumn::nCount is the number of cells stored in the column. ScColumn:nLimit is size of the dynamic array which does not need to resize to hold more cells. Please refer to ScColumn::Insert(SCROW nRow, ScBaseCell* pNewCell), ScColumn::Delete(SCROW nRow) and ScColumn::Append(SCROW nRow, ScBaseCell* pNewCell) to get more info about how this dynamic array work. Users can use index to retrieve the cell(pItems[index]). The index can be found by ScColumn::Search(SCROW nRow, SCSIZE&amp;amp; nIndex) from a row number.&lt;br /&gt;
Every cell has properties. But not every cell&amp;#039;s properties are stored as an individual object. If adjacent cells have same properties, they use one ScPatternAttr object. ScAttrArray is the data structure to hold cell&amp;#039;s properties in one column. ScAttrArray::pData is the dynamic array holds properties. ScAttrArray::nCount and ScAttrArray::nLimit are similar to other dynamic array. The element in the array is the object of ScAttrEntry, which hold a ScPatternAttr pointer and a related row number info(nRow). The nRow indicate the last row in an adjacent cell range which has same properties. For an example like following, the row from 7 to the end of column are same.&lt;br /&gt;
&lt;br /&gt;
[[File:DataModel_1.png]]&lt;br /&gt;
&lt;br /&gt;
The initial status of ScAttrArray has one element in pData, which pData[0].row is MAX_ROW, pData[0].pPattern is default pattern. That means whole column has default property. When user set cell&amp;#039;s property, it may divide the range into pieces and add new ScAttrEntry. Sometimes, setting cell&amp;#039;s property may merge adjacent ScAttrEntry into one because they have same properties. Please refer ScAttrArray::SetPatternArea(...) for more detail.&lt;br /&gt;
&lt;br /&gt;
== SfxPoolItem, SfxItemPool and SfxItemSet ==&lt;br /&gt;
&lt;br /&gt;
From object property&amp;#039;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&amp;#039;s every properties independently, it must use huge of memory. So there is a pool to hold the SfxPoolItems, SfxItemPool.&lt;br /&gt;
Let&amp;#039;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. &lt;br /&gt;
&lt;br /&gt;
[[File:ItemPool.png]]&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
All obejcts&amp;#039; 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&amp;amp; rItem)for detail info.&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== ScPatternAttr, SfxSetItem and SfxItemSet ==&lt;br /&gt;
&lt;br /&gt;
SfxSetItem is sub class of SfxPoolItem. It is a kind of SfxPoolItem, which just wrap a SfxItemSet. ScPatternAttr is sub class of SfxSetItem. It represents cell&amp;#039;s attributes, including text attributes, number format attributes, background attributes, border attributes, etc. Most SfxPoolItems do not have many instant because a specific property does not have many different value in one document. But for ScPatternAttr, it can have maximum 53 sub attributes. It may have a lot of instances, which make size of SfxPoolItemArray_Impl::pData large. So when put a ScPatternAttr in the pool, it need a lot of comparison. Each comparison for two ScPatternAttr need compare all its sub attributes. It is time consuming, especially for putting an existed ScPatternAttr into the pool. Developer need pay more attention for this potential performance bottleneck.&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Data_Model_for_sheet_and_cell&amp;diff=200222</id>
		<title>Calc/Implementation/Data Model for sheet and cell</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Data_Model_for_sheet_and_cell&amp;diff=200222"/>
		<updated>2012-04-15T14:43:53Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
== The relationship between document, table, column and cell ==&lt;br /&gt;
&lt;br /&gt;
From Spreadsheet user&amp;#039;s view, a Spreadsheet document is composed by several tables. Each table contains many cells which are organized by row and column. The codes just reflect this fact. ScDocument(Spreadsheet document) has a one dimension fix size(MAXTABCOUNT=256) array member. Each element in the array is a pointer to a ScTable. But ScTable does not contain a two dimension array, which covers every cells, since most of cells are empty. If every cell is stored in table, it need huge memory to contain 1G(1M rows * 1024 columns) cell objects/pointers for one table. Cells are organized in column. ScTable has a fix size (MAXCOLCOUNT=1024) array member. Each element in the array is a ScColumn object. ScColumn only stores useful cells, which is not empty cell or empty cell is referenced by other cell directly. ScColumn uses a dynamic array ScColumn::pItems to store cells. &lt;br /&gt;
&lt;br /&gt;
== Column, the building block of Spreadsheet ==&lt;br /&gt;
&lt;br /&gt;
Cell is the basic element in a Spreadsheet. There are two kinds of data structure related with cell. One is related with content, ScBaseCell(and its sub). The other is related with property, ScPatternAttr. ScColumn does not only store cell content, but also store cell property. &lt;br /&gt;
ScColumn::pItems is the a dynamic array holds cells. The sequence of cells in ScColumn::pItems is by their row number from small to big. The element in the array is the object of ColEntry, which hold a ScBaseCell pointer and corresponding row number(nRow). ScColumn::nCount is the number of cells stored in the column. ScColumn:nLimit is size of the dynamic array which does not need to resize to hold more cells. Please refer to ScColumn::Insert(SCROW nRow, ScBaseCell* pNewCell), ScColumn::Delete(SCROW nRow) and ScColumn::Append(SCROW nRow, ScBaseCell* pNewCell) to get more info about how this dynamic array work. Users can use index to retrieve the cell(pItems[index]). The index can be found by ScColumn::Search(SCROW nRow, SCSIZE&amp;amp; nIndex) from a row number.&lt;br /&gt;
Every cell has properties. But not every cell&amp;#039;s properties are stored as an individual object. If adjacent cells have same properties, they use one ScPatternAttr object. ScAttrArray is the data structure to hold cell&amp;#039;s properties in one column. ScAttrArray::pData is the dynamic array holds properties. ScAttrArray::nCount and ScAttrArray::nLimit are similar to other dynamic array. The element in the array is the object of ScAttrEntry, which hold a ScPatternAttr pointer and a related row number info(nRow). The nRow indicate the last row in an adjacent cell range which has same properties. For an example like following, the row from 7 to the end of column are same.&lt;br /&gt;
&lt;br /&gt;
[[File:DataModel_1.png|315px]]&lt;br /&gt;
&lt;br /&gt;
The initial status of ScAttrArray has one element in pData, which pData[0].row is MAX_ROW, pData[0].pPattern is default pattern. That means whole column has default property. When user set cell&amp;#039;s property, it may divide the range into pieces and add new ScAttrEntry. Sometimes, setting cell&amp;#039;s property may merge adjacent ScAttrEntry into one because they have same properties. Please refer ScAttrArray::SetPatternArea(...) for more detail.&lt;br /&gt;
&lt;br /&gt;
== SfxPoolItem, SfxItemPool and SfxItemSet ==&lt;br /&gt;
&lt;br /&gt;
From object property&amp;#039;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&amp;#039;s every properties independently, it must use huge of memory. So there is a pool to hold the SfxPoolItems, SfxItemPool.&lt;br /&gt;
Let&amp;#039;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. &lt;br /&gt;
&lt;br /&gt;
[[File:ItemPool.png|784px]]&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
All obejcts&amp;#039; 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&amp;amp; rItem)for detail info.&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== ScPatternAttr, SfxSetItem and SfxItemSet ==&lt;br /&gt;
&lt;br /&gt;
SfxSetItem is sub class of SfxPoolItem. It is a kind of SfxPoolItem, which just wrap a SfxItemSet. ScPatternAttr is sub class of SfxSetItem. It represents cell&amp;#039;s attributes, including text attributes, number format attributes, background attributes, border attributes, etc. Most SfxPoolItems do not have many instant because a specific property does not have many different value in one document. But for ScPatternAttr, it can have maximum 53 sub attributes. It may have a lot of instances, which make size of SfxPoolItemArray_Impl::pData large. So when put a ScPatternAttr in the pool, it need a lot of comparison. Each comparison for two ScPatternAttr need compare all its sub attributes. It is time consuming, especially for putting an existed ScPatternAttr into the pool. Developer need pay more attention for this potential performance bottleneck.&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Data_Model_for_sheet_and_cell&amp;diff=200221</id>
		<title>Calc/Implementation/Data Model for sheet and cell</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Data_Model_for_sheet_and_cell&amp;diff=200221"/>
		<updated>2012-04-15T14:36:45Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
== The relationship between document, table, column and cell ==&lt;br /&gt;
&lt;br /&gt;
From Spreadsheet user&amp;#039;s view, a Spreadsheet document is composed by several tables. Each table contains many cells which are organized by row and column. The codes just reflect this fact. ScDocument(Spreadsheet document) has a one dimension fix size(MAXTABCOUNT=256) array member. Each element in the array is a pointer to a ScTable. But ScTable does not contain a two dimension array, which covers every cells, since most of cells are empty. If every cell is stored in table, it need huge memory to contain 1G(1M rows * 1024 columns) cell objects/pointers for one table. Cells are organized in column. ScTable has a fix size (MAXCOLCOUNT=1024) array member. Each element in the array is a ScColumn object. ScColumn only stores useful cells, which is not empty cell or empty cell is referenced by other cell directly. ScColumn uses a dynamic array ScColumn::pItems to store cells. &lt;br /&gt;
&lt;br /&gt;
== Column, the building block of Spreadsheet ==&lt;br /&gt;
&lt;br /&gt;
Cell is the basic element in a Spreadsheet. There are two kinds of data structure related with cell. One is related with content, ScBaseCell(and its sub). The other is related with property, ScPatternAttr. ScColumn does not only store cell content, but also store cell property. &lt;br /&gt;
ScColumn::pItems is the a dynamic array holds cells. The sequence of cells in ScColumn::pItems is by their row number from small to big. The element in the array is the object of ColEntry, which hold a ScBaseCell pointer and corresponding row number(nRow). ScColumn::nCount is the number of cells stored in the column. ScColumn:nLimit is size of the dynamic array which does not need to resize to hold more cells. Please refer to ScColumn::Insert(SCROW nRow, ScBaseCell* pNewCell), ScColumn::Delete(SCROW nRow) and ScColumn::Append(SCROW nRow, ScBaseCell* pNewCell) to get more info about how this dynamic array work. Users can use index to retrieve the cell(pItems[index]). The index can be found by ScColumn::Search(SCROW nRow, SCSIZE&amp;amp; nIndex) from a row number.&lt;br /&gt;
Every cell has properties. But not every cell&amp;#039;s properties are stored as an individual object. If adjacent cells have same properties, they use one ScPatternAttr object. ScAttrArray is the data structure to hold cell&amp;#039;s properties in one column. ScAttrArray::pData is the dynamic array holds properties. ScAttrArray::nCount and ScAttrArray::nLimit are similar to other dynamic array. The element in the array is the object of ScAttrEntry, which hold a ScPatternAttr pointer and a related row number info(nRow). The nRow indicate the last row in an adjacent cell range which has same properties. For an example like following, the row from 7 to the end of column are same.&lt;br /&gt;
&lt;br /&gt;
[[File:DataModel_1.png|200px]]&lt;br /&gt;
&lt;br /&gt;
The initial status of ScAttrArray has one element in pData, which pData[0].row is MAX_ROW, pData[0].pPattern is default pattern. That means whole column has default property. When user set cell&amp;#039;s property, it may divide the range into pieces and add new ScAttrEntry. Sometimes, setting cell&amp;#039;s property may merge adjacent ScAttrEntry into one because they have same properties. Please refer ScAttrArray::SetPatternArea(...) for more detail.&lt;br /&gt;
&lt;br /&gt;
== SfxPoolItem, SfxItemPool and SfxItemSet ==&lt;br /&gt;
&lt;br /&gt;
From object property&amp;#039;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&amp;#039;s every properties independently, it must use huge of memory. So there is a pool to hold the SfxPoolItems, SfxItemPool.&lt;br /&gt;
Let&amp;#039;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. &lt;br /&gt;
&lt;br /&gt;
[[File:ItemPool.png|784px]]&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
All obejcts&amp;#039; 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&amp;amp; rItem)for detail info.&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== ScPatternAttr, SfxSetItem and SfxItemSet ==&lt;br /&gt;
&lt;br /&gt;
SfxSetItem is sub class of SfxPoolItem. It is a kind of SfxPoolItem, which just wrap a SfxItemSet. ScPatternAttr is sub class of SfxSetItem. It represents cell&amp;#039;s attributes, including text attributes, number format attributes, background attributes, border attributes, etc. Most SfxPoolItems do not have many instant because a specific property does not have many different value in one document. But for ScPatternAttr, it can have maximum 53 sub attributes. It may have a lot of instances, which make size of SfxPoolItemArray_Impl::pData large. So when put a ScPatternAttr in the pool, it need a lot of comparison. Each comparison for two ScPatternAttr need compare all its sub attributes. It is time consuming, especially for putting an existed ScPatternAttr into the pool. Developer need pay more attention for this potential performance bottleneck.&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Data_Model_for_sheet_and_cell&amp;diff=200218</id>
		<title>Calc/Implementation/Data Model for sheet and cell</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Data_Model_for_sheet_and_cell&amp;diff=200218"/>
		<updated>2012-04-15T14:18:57Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
== The relationship between document, table, column and cell ==&lt;br /&gt;
&lt;br /&gt;
From Spreadsheet user&amp;#039;s view, a Spreadsheet document is composed by several tables. Each table contains many cells which are organized by row and column. The codes just reflect this fact. ScDocument(Spreadsheet document) has a one dimension fix size(MAXTABCOUNT=256) array member. Each element in the array is a pointer to a ScTable. But ScTable does not contain a two dimension array, which covers every cells, since most of cells are empty. If every cell is stored in table, it need huge memory to contain 1G(1M rows * 1024 columns) cell objects/pointers for one table. Cells are organized in column. ScTable has a fix size (MAXCOLCOUNT=1024) array member. Each element in the array is a ScColumn object. ScColumn only stores useful cells, which is not empty cell or empty cell is referenced by other cell directly. ScColumn uses a dynamic array ScColumn::pItems to store cells. &lt;br /&gt;
&lt;br /&gt;
== Column, the building block of Spreadsheet ==&lt;br /&gt;
&lt;br /&gt;
Cell is the basic element in a Spreadsheet. There are two kinds of data structure related with cell. One is related with content, ScBaseCell(and its sub). The other is related with property, ScPatternAttr. ScColumn does not only store cell content, but also store cell property. &lt;br /&gt;
ScColumn::pItems is the a dynamic array holds cells. The sequence of cells in ScColumn::pItems is by their row number from small to big. The element in the array is the object of ColEntry, which hold a ScBaseCell pointer and corresponding row number(nRow). ScColumn::nCount is the number of cells stored in the column. ScColumn:nLimit is size of the dynamic array which does not need to resize to hold more cells. Please refer to ScColumn::Insert(SCROW nRow, ScBaseCell* pNewCell), ScColumn::Delete(SCROW nRow) and ScColumn::Append(SCROW nRow, ScBaseCell* pNewCell) to get more info about how this dynamic array work. Users can use index to retrieve the cell(pItems[index]). The index can be found by ScColumn::Search(SCROW nRow, SCSIZE&amp;amp; nIndex) from a row number.&lt;br /&gt;
Every cell has properties. But not every cell&amp;#039;s properties are stored as an individual object. If adjacent cells have same properties, they use one ScPatternAttr object. ScAttrArray is the data structure to hold cell&amp;#039;s properties in one column. ScAttrArray::pData is the dynamic array holds properties. ScAttrArray::nCount and ScAttrArray::nLimit are similar to other dynamic array. The element in the array is the object of ScAttrEntry, which hold a ScPatternAttr pointer and a related row number info(nRow). The nRow indicate the last row in an adjacent cell range which has same properties. For an example like following, the row from 7 to the end of column are same.&lt;br /&gt;
&lt;br /&gt;
[[File:DataModel_1.png]]&lt;br /&gt;
&lt;br /&gt;
The initial status of ScAttrArray has one element in pData, which pData[0].row is MAX_ROW, pData[0].pPattern is default pattern. That means whole column has default property. When user set cell&amp;#039;s property, it may divide the range into pieces and add new ScAttrEntry. Sometimes, setting cell&amp;#039;s property may merge adjacent ScAttrEntry into one because they have same properties. Please refer ScAttrArray::SetPatternArea(...) for more detail.&lt;br /&gt;
&lt;br /&gt;
== SfxPoolItem, SfxItemPool and SfxItemSet ==&lt;br /&gt;
&lt;br /&gt;
From object property&amp;#039;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&amp;#039;s every properties independently, it must use huge of memory. So there is a pool to hold the SfxPoolItems, SfxItemPool.&lt;br /&gt;
Let&amp;#039;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. &lt;br /&gt;
&lt;br /&gt;
[[File:ItemPool.png]]&lt;br /&gt;
&lt;br /&gt;
Data Model for sheet and cell&lt;br /&gt;
&lt;br /&gt;
The relationship between document, table, column and cell&lt;br /&gt;
&lt;br /&gt;
From Spreadsheet user&amp;#039;s view, a Spreadsheet document is composed by several tables. Each table contains many cells which are organized by row and column. The codes just reflect this fact. ScDocument(Spreadsheet document) has a one dimension fix size(MAXTABCOUNT=256) array member. Each element in the array is a pointer to a ScTable. But ScTable does not contain a two dimension array, which covers every cells, since most of cells are empty. If every cell is stored in table, it need huge memory to contain 1G(1M rows * 1024 columns) cell objects/pointers for one table. Cells are organized in column. ScTable has a fix size (MAXCOLCOUNT=1024) array member. Each element in the array is a ScColumn object. ScColumn only stores useful cells, which is not empty cell or empty cell is referenced by other cell directly. ScColumn uses a dynamic array ScColumn::pItems to store cells. &lt;br /&gt;
&lt;br /&gt;
Column, the building block of Spreadsheet&lt;br /&gt;
&lt;br /&gt;
Cell is the basic element in a Spreadsheet. There are two kinds of data structure related with cell. One is related with content, ScBaseCell(and its sub). The other is related with property, ScPatternAttr. ScColumn does not only store cell content, but also store cell property. &lt;br /&gt;
ScColumn::pItems is the a dynamic array holds cells. The sequence of cells in ScColumn::pItems is by their row number from small to big. The element in the array is the object of ColEntry, which hold a ScBaseCell pointer and corresponding row number(nRow). ScColumn::nCount is the number of cells stored in the column. ScColumn:nLimit is size of the dynamic array which does not need to resize to hold more cells. Please refer to ScColumn::Insert(SCROW nRow, ScBaseCell* pNewCell), ScColumn::Delete(SCROW nRow) and ScColumn::Append(SCROW nRow, ScBaseCell* pNewCell) to get more info about how this dynamic array work. Users can use index to retrieve the cell(pItems[index]). The index can be found by ScColumn::Search(SCROW nRow, SCSIZE&amp;amp; nIndex) from a row number.&lt;br /&gt;
Every cell has properties. But not every cell&amp;#039;s properties are stored as an individual object. If adjacent cells have same properties, they use one ScPatternAttr object. ScAttrArray is the data structure to hold cell&amp;#039;s properties in one column. ScAttrArray::pData is the dynamic array holds properties. ScAttrArray::nCount and ScAttrArray::nLimit are similar to other dynamic array. The element in the array is the object of ScAttrEntry, which hold a ScPatternAttr pointer and a related row number info(nRow). The nRow indicate the last row in an adjacent cell range which has same properties. For an example like following, the row from 7 to the end of column are same.&lt;br /&gt;
&lt;br /&gt;
The initial status of ScAttrArray has one element in pData, which pData[0].row is MAX_ROW, pData[0].pPattern is default pattern. That means whole column has default property. When user set cell&amp;#039;s property, it may divide the range into pieces and add new ScAttrEntry. Sometimes, setting cell&amp;#039;s property may merge adjacent ScAttrEntry into one because they have same properties. Please refer ScAttrArray::SetPatternArea(...) for more detail.&lt;br /&gt;
&lt;br /&gt;
SfxPoolItem, SfxItemPool and SfxItemSet&lt;br /&gt;
&lt;br /&gt;
From object property&amp;#039;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&amp;#039;s every properties independently, it must use huge of memory. So there is a pool to hold the SfxPoolItems, SfxItemPool.&lt;br /&gt;
Let&amp;#039;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. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
All obejcts&amp;#039; 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&amp;amp; rItem)for detail info.&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== ScPatternAttr, SfxSetItem and SfxItemSet ==&lt;br /&gt;
&lt;br /&gt;
SfxSetItem is sub class of SfxPoolItem. It is a kind of SfxPoolItem, which just wrap a SfxItemSet. ScPatternAttr is sub class of SfxSetItem. It represents cell&amp;#039;s attributes, including text attributes, number format attributes, background attributes, border attributes, etc. Most SfxPoolItems do not have many instant because a specific property does not have many different value in one document. But for ScPatternAttr, it can have maximum 53 sub attributes. It may have a lot of instances, which make size of SfxPoolItemArray_Impl::pData large. So when put a ScPatternAttr in the pool, it need a lot of comparison. Each comparison for two ScPatternAttr need compare all its sub attributes. It is time consuming, especially for putting an existed ScPatternAttr into the pool. Developer need pay more attention for this potential performance bottleneck.&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Data_Model_for_sheet_and_cell&amp;diff=200216</id>
		<title>Calc/Implementation/Data Model for sheet and cell</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Data_Model_for_sheet_and_cell&amp;diff=200216"/>
		<updated>2012-04-15T14:14:25Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
== The relationship between document, table, column and cell ==&lt;br /&gt;
&lt;br /&gt;
From Spreadsheet user&amp;#039;s view, a Spreadsheet document is composed by several tables. Each table contains many cells which are organized by row and column. The codes just reflect this fact. ScDocument(Spreadsheet document) has a one dimension fix size(MAXTABCOUNT=256) array member. Each element in the array is a pointer to a ScTable. But ScTable does not contain a two dimension array, which covers every cells, since most of cells are empty. If every cell is stored in table, it need huge memory to contain 1G(1M rows * 1024 columns) cell objects/pointers for one table. Cells are organized in column. ScTable has a fix size (MAXCOLCOUNT=1024) array member. Each element in the array is a ScColumn object. ScColumn only stores useful cells, which is not empty cell or empty cell is referenced by other cell directly. ScColumn uses a dynamic array ScColumn::pItems to store cells. &lt;br /&gt;
&lt;br /&gt;
== Column, the building block of Spreadsheet ==&lt;br /&gt;
&lt;br /&gt;
Cell is the basic element in a Spreadsheet. There are two kinds of data structure related with cell. One is related with content, ScBaseCell(and its sub). The other is related with property, ScPatternAttr. ScColumn does not only store cell content, but also store cell property. &lt;br /&gt;
ScColumn::pItems is the a dynamic array holds cells. The sequence of cells in ScColumn::pItems is by their row number from small to big. The element in the array is the object of ColEntry, which hold a ScBaseCell pointer and corresponding row number(nRow). ScColumn::nCount is the number of cells stored in the column. ScColumn:nLimit is size of the dynamic array which does not need to resize to hold more cells. Please refer to ScColumn::Insert(SCROW nRow, ScBaseCell* pNewCell), ScColumn::Delete(SCROW nRow) and ScColumn::Append(SCROW nRow, ScBaseCell* pNewCell) to get more info about how this dynamic array work. Users can use index to retrieve the cell(pItems[index]). The index can be found by ScColumn::Search(SCROW nRow, SCSIZE&amp;amp; nIndex) from a row number.&lt;br /&gt;
Every cell has properties. But not every cell&amp;#039;s properties are stored as an individual object. If adjacent cells have same properties, they use one ScPatternAttr object. ScAttrArray is the data structure to hold cell&amp;#039;s properties in one column. ScAttrArray::pData is the dynamic array holds properties. ScAttrArray::nCount and ScAttrArray::nLimit are similar to other dynamic array. The element in the array is the object of ScAttrEntry, which hold a ScPatternAttr pointer and a related row number info(nRow). The nRow indicate the last row in an adjacent cell range which has same properties. For an example like following, the row from 7 to the end of column are same.&lt;br /&gt;
&lt;br /&gt;
[[File:DataModel_1.png]]&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Data_Model_for_sheet_and_cell&amp;diff=200214</id>
		<title>Calc/Implementation/Data Model for sheet and cell</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Data_Model_for_sheet_and_cell&amp;diff=200214"/>
		<updated>2012-04-15T14:03:05Z</updated>

		<summary type="html">&lt;p&gt;Leiw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
The relationship between document, table, column and cell&lt;br /&gt;
&lt;br /&gt;
From Spreadsheet user&amp;#039;s view, a Spreadsheet document is composed by several tables. Each table contains many cells which are organized by row and column. The codes just reflect this fact. ScDocument(Spreadsheet document) has a one dimension fix size(MAXTABCOUNT=256) array member. Each element in the array is a pointer to a ScTable. But ScTable does not contain a two dimension array, which covers every cells, since most of cells are empty. If every cell is stored in table, it need huge memory to contain 1G(1M rows * 1024 columns) cell objects/pointers for one table. Cells are organized in column. ScTable has a fix size (MAXCOLCOUNT=1024) array member. Each element in the array is a ScColumn object. ScColumn only stores useful cells, which is not empty cell or empty cell is referenced by other cell directly. ScColumn uses a dynamic array ScColumn::pItems to store cells. &lt;br /&gt;
&lt;br /&gt;
Column, the building block of Spreadsheet&lt;br /&gt;
&lt;br /&gt;
Cell is the basic element in a Spreadsheet. There are two kinds of data structure related with cell. One is related with content, ScBaseCell(and its sub). The other is related with property, ScPatternAttr. ScColumn does not only store cell content, but also store cell property. &lt;br /&gt;
ScColumn::pItems is the a dynamic array holds cells. The sequence of cells in ScColumn::pItems is by their row number from small to big. The element in the array is the object of ColEntry, which hold a ScBaseCell pointer and corresponding row number(nRow). ScColumn::nCount is the number of cells stored in the column. ScColumn:nLimit is size of the dynamic array which does not need to resize to hold more cells. Please refer to ScColumn::Insert(SCROW nRow, ScBaseCell* pNewCell), ScColumn::Delete(SCROW nRow) and ScColumn::Append(SCROW nRow, ScBaseCell* pNewCell) to get more info about how this dynamic array work. Users can use index to retrieve the cell(pItems[index]). The index can be found by ScColumn::Search(SCROW nRow, SCSIZE&amp;amp; nIndex) from a row number.&lt;br /&gt;
Every cell has properties. But not every cell&amp;#039;s properties are stored as an individual object. If adjacent cells have same properties, they use one ScPatternAttr object. ScAttrArray is the data structure to hold cell&amp;#039;s properties in one column. ScAttrArray::pData is the dynamic array holds properties. ScAttrArray::nCount and ScAttrArray::nLimit are similar to other dynamic array. The element in the array is the object of ScAttrEntry, which hold a ScPatternAttr pointer and a related row number info(nRow). The nRow indicate the last row in an adjacent cell range which has same properties. For an example like following, the row from 7 to the end of column are same.&lt;br /&gt;
&lt;br /&gt;
[[File:Example.jpg]]&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Data_Model_for_sheet_and_cell&amp;diff=200213</id>
		<title>Calc/Implementation/Data Model for sheet and cell</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Calc/Implementation/Data_Model_for_sheet_and_cell&amp;diff=200213"/>
		<updated>2012-04-15T14:00:34Z</updated>

		<summary type="html">&lt;p&gt;Leiw: Created page with &amp;quot;Category:Calc Category:Implementation&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Calc]]&lt;br /&gt;
[[Category:Implementation]]&lt;/div&gt;</summary>
		<author><name>Leiw</name></author>
	</entry>
</feed>