1 | <?php |
---|
2 | /*- |
---|
3 | * Copyright (c) 2009 Laurent VUIBERT |
---|
4 | * License : GNU Lesser General Public License v3 |
---|
5 | */ |
---|
6 | |
---|
7 | class odsTable { |
---|
8 | private $name; |
---|
9 | private $styleName; |
---|
10 | private $print; |
---|
11 | |
---|
12 | private $cursorPositionX; |
---|
13 | private $cursorPositionY; |
---|
14 | private $horizontalSplitMode; |
---|
15 | private $verticalSplitMode; |
---|
16 | private $horizontalSplitPosition; |
---|
17 | private $verticalSplitPosition; |
---|
18 | private $positionLeft; |
---|
19 | private $positionRight; |
---|
20 | private $positionTop; |
---|
21 | private $positionBottom; |
---|
22 | |
---|
23 | |
---|
24 | private $tableColumns; |
---|
25 | private $rows; |
---|
26 | |
---|
27 | public function __construct($name, $odsStyleTable = null) { |
---|
28 | $this->name = $name; |
---|
29 | if($odsStyleTable) $this->styleName = $odsStyleTable->getName; |
---|
30 | else $this->styleName = "ta1"; |
---|
31 | $this->print = "false"; |
---|
32 | |
---|
33 | $this->cursorPositionX = 0; |
---|
34 | $this->cursorPositionY = 0; |
---|
35 | $this->horizontalSplitMode = 0; |
---|
36 | $this->verticalSplitMode = 0; |
---|
37 | $this->horizontalSplitPosition = 0; |
---|
38 | $this->verticalSplitPosition = 0; |
---|
39 | $this->positionLeft = 0; |
---|
40 | $this->positionRight = 0; |
---|
41 | $this->positionTop = 0; |
---|
42 | $this->positionBottom = 0; |
---|
43 | |
---|
44 | $this->tableColumns = array(); |
---|
45 | $this->rows = array(); |
---|
46 | } |
---|
47 | |
---|
48 | public function getName() { |
---|
49 | return $this->name; |
---|
50 | } |
---|
51 | |
---|
52 | public function setHorizontalSplit($colones = 1) { |
---|
53 | $this->setHorizontalSplitMode(2); |
---|
54 | $this->setHorizontalSplitPosition($colones); |
---|
55 | $this->setPositionRight($colones); |
---|
56 | } |
---|
57 | |
---|
58 | public function setVerticalSplit($lines = 1) { |
---|
59 | $this->setVerticalSplitMode(2); |
---|
60 | $this->setVerticalSplitPosition($lines); |
---|
61 | $this->setPositionBottom($lines); |
---|
62 | } |
---|
63 | |
---|
64 | public function addRow($odsTableRow) { |
---|
65 | array_push($this->rows,$odsTableRow); |
---|
66 | } |
---|
67 | |
---|
68 | public function addTableColumn($odsTableColumn) { |
---|
69 | array_push($this->tableColumns, $odsTableColumn); |
---|
70 | } |
---|
71 | |
---|
72 | public function setCursorPositionX($cursorPositionX) { |
---|
73 | $this->cursorPositionX = $cursorPositionX; |
---|
74 | } |
---|
75 | |
---|
76 | public function setCursorPositionY($cursorPositionY) { |
---|
77 | $this->cursorPositionY = $cursorPositionY; |
---|
78 | } |
---|
79 | |
---|
80 | public function setHorizontalSplitMode($horizontalSplitMode) { |
---|
81 | $this->horizontalSplitMode = $horizontalSplitMode; |
---|
82 | } |
---|
83 | |
---|
84 | public function setVerticalSplitMode($verticalSplitMode) { |
---|
85 | $this->verticalSplitMode = $verticalSplitMode; |
---|
86 | } |
---|
87 | |
---|
88 | public function setHorizontalSplitPosition($horizontalSplitPosition) { |
---|
89 | $this->horizontalSplitPosition = $horizontalSplitPosition; |
---|
90 | } |
---|
91 | |
---|
92 | public function setVerticalSplitPosition($verticalSplitPosition) { |
---|
93 | $this->verticalSplitPosition = $verticalSplitPosition; |
---|
94 | } |
---|
95 | |
---|
96 | public function setPositionLeft($positionLeft) { |
---|
97 | $this->positionLeft = $positionLeft; |
---|
98 | } |
---|
99 | |
---|
100 | public function setPositionRight($positionRight) { |
---|
101 | $this->positionRight = $positionRight; |
---|
102 | } |
---|
103 | |
---|
104 | public function setPositionTop($positionTop) { |
---|
105 | $this->positionTop = $positionTop; |
---|
106 | } |
---|
107 | |
---|
108 | public function setPositionBottom($positionBottom) { |
---|
109 | $this->positionBottom = $positionBottom; |
---|
110 | } |
---|
111 | |
---|
112 | public function getContent(ods $ods, DOMDocument $dom) { |
---|
113 | $table_table = $dom->createElement('table:table'); |
---|
114 | $table_table->setAttribute("table:name", $this->name); |
---|
115 | $table_table->setAttribute("table:style-name", $this->styleName); |
---|
116 | $table_table->setAttribute("table:print", $this->print); |
---|
117 | |
---|
118 | if(count($this->tableColumns)) { |
---|
119 | foreach($this->tableColumns as $tableColumn) |
---|
120 | $table_table->appendChild($tableColumn->getContent($ods,$dom)); |
---|
121 | } else { |
---|
122 | $column = new odsTableColumn($ods->getStyleByName('co1')); |
---|
123 | $table_table->appendChild($column->getContent($ods,$dom)); |
---|
124 | } |
---|
125 | |
---|
126 | if(count($this->rows)) { |
---|
127 | foreach($this->rows as $row) |
---|
128 | $table_table->appendChild($row->getContent($ods,$dom)); |
---|
129 | } else { |
---|
130 | $row = new odsTableRow(); |
---|
131 | $table_table->appendChild($row->getContent($ods,$dom)); |
---|
132 | } |
---|
133 | |
---|
134 | return $table_table; |
---|
135 | } |
---|
136 | |
---|
137 | public function getSettings(ods $ods, DOMDocument $dom) { |
---|
138 | $config_config_item_map_entry2 = $dom->createElement('config:config-item-map-entry'); |
---|
139 | $config_config_item_map_entry2->setAttribute("config:name", $this->name); |
---|
140 | //$config_config_item_map_named->appendChild($config_config_item_map_entry2); |
---|
141 | |
---|
142 | $config_config_item = $dom->createElement('config:config-item',$this->cursorPositionX); |
---|
143 | $config_config_item->setAttribute("config:name", "CursorPositionX"); |
---|
144 | $config_config_item->setAttribute("config:type", "int"); |
---|
145 | $config_config_item_map_entry2->appendChild($config_config_item); |
---|
146 | |
---|
147 | $config_config_item = $dom->createElement('config:config-item',$this->cursorPositionY); |
---|
148 | $config_config_item->setAttribute("config:name", "CursorPositionY"); |
---|
149 | $config_config_item->setAttribute("config:type", "int"); |
---|
150 | $config_config_item_map_entry2->appendChild($config_config_item); |
---|
151 | |
---|
152 | $config_config_item = $dom->createElement('config:config-item',$this->horizontalSplitMode); |
---|
153 | $config_config_item->setAttribute("config:name", "HorizontalSplitMode"); |
---|
154 | $config_config_item->setAttribute("config:type", "short"); |
---|
155 | $config_config_item_map_entry2->appendChild($config_config_item); |
---|
156 | |
---|
157 | $config_config_item = $dom->createElement('config:config-item', $this->verticalSplitMode); |
---|
158 | $config_config_item->setAttribute("config:name", "VerticalSplitMode"); |
---|
159 | $config_config_item->setAttribute("config:type", "short"); |
---|
160 | $config_config_item_map_entry2->appendChild($config_config_item); |
---|
161 | |
---|
162 | $config_config_item = $dom->createElement('config:config-item',$this->horizontalSplitPosition); |
---|
163 | $config_config_item->setAttribute("config:name", "HorizontalSplitPosition"); |
---|
164 | $config_config_item->setAttribute("config:type", "int"); |
---|
165 | $config_config_item_map_entry2->appendChild($config_config_item); |
---|
166 | |
---|
167 | $config_config_item = $dom->createElement('config:config-item',$this->verticalSplitPosition); |
---|
168 | $config_config_item->setAttribute("config:name", "VerticalSplitPosition"); |
---|
169 | $config_config_item->setAttribute("config:type", "int"); |
---|
170 | $config_config_item_map_entry2->appendChild($config_config_item); |
---|
171 | |
---|
172 | $config_config_item = $dom->createElement('config:config-item',2); |
---|
173 | $config_config_item->setAttribute("config:name", "ActiveSplitRange"); |
---|
174 | $config_config_item->setAttribute("config:type", "short"); |
---|
175 | $config_config_item_map_entry2->appendChild($config_config_item); |
---|
176 | |
---|
177 | $config_config_item = $dom->createElement('config:config-item',$this->positionLeft); |
---|
178 | $config_config_item->setAttribute("config:name", "PositionLeft"); |
---|
179 | $config_config_item->setAttribute("config:type", "int"); |
---|
180 | $config_config_item_map_entry2->appendChild($config_config_item); |
---|
181 | |
---|
182 | $config_config_item = $dom->createElement('config:config-item',$this->positionRight); |
---|
183 | $config_config_item->setAttribute("config:name", "PositionRight"); |
---|
184 | $config_config_item->setAttribute("config:type", "int"); |
---|
185 | $config_config_item_map_entry2->appendChild($config_config_item); |
---|
186 | |
---|
187 | $config_config_item = $dom->createElement('config:config-item',$this->positionTop); |
---|
188 | $config_config_item->setAttribute("config:name", "PositionTop"); |
---|
189 | $config_config_item->setAttribute("config:type", "int"); |
---|
190 | $config_config_item_map_entry2->appendChild($config_config_item); |
---|
191 | |
---|
192 | $config_config_item = $dom->createElement('config:config-item',$this->positionBottom); |
---|
193 | $config_config_item->setAttribute("config:name", "PositionBottom"); |
---|
194 | $config_config_item->setAttribute("config:type", "int"); |
---|
195 | $config_config_item_map_entry2->appendChild($config_config_item); |
---|
196 | |
---|
197 | $config_config_item = $dom->createElement('config:config-item',0); |
---|
198 | $config_config_item->setAttribute("config:name", "ZoomType"); |
---|
199 | $config_config_item->setAttribute("config:type", "short"); |
---|
200 | $config_config_item_map_entry2->appendChild($config_config_item); |
---|
201 | |
---|
202 | $config_config_item = $dom->createElement('config:config-item',100); |
---|
203 | $config_config_item->setAttribute("config:name", "ZoomValue"); |
---|
204 | $config_config_item->setAttribute("config:type", "int"); |
---|
205 | $config_config_item_map_entry2->appendChild($config_config_item); |
---|
206 | |
---|
207 | $config_config_item = $dom->createElement('config:config-item',60); |
---|
208 | $config_config_item->setAttribute("config:name", "PageViewZoomValue"); |
---|
209 | $config_config_item->setAttribute("config:type", "int"); |
---|
210 | $config_config_item_map_entry2->appendChild($config_config_item); |
---|
211 | |
---|
212 | $config_config_item = $dom->createElement('config:config-item',"true"); |
---|
213 | $config_config_item->setAttribute("config:name", "ShowGrid"); |
---|
214 | $config_config_item->setAttribute("config:type", "boolean"); |
---|
215 | $config_config_item_map_entry2->appendChild($config_config_item); |
---|
216 | |
---|
217 | return $config_config_item_map_entry2; |
---|
218 | } |
---|
219 | } |
---|
220 | |
---|
221 | ?> |
---|