Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <iostream>
31 : : #include <set>
32 : : #include <stdio.h>
33 : : #include "WW8TableInfo.hxx"
34 : : #include "fmtfsize.hxx"
35 : : #include "attributeoutputbase.hxx"
36 : : #include "swtable.hxx"
37 : : #include "frmfmt.hxx"
38 : : #include "pam.hxx"
39 : : #include "ndtxt.hxx"
40 : : #include "dbgoutsw.hxx"
41 : :
42 : : namespace ww8
43 : : {
44 : :
45 : : // WW8TableNodeInfoInner
46 : :
47 : 0 : WW8TableNodeInfoInner::WW8TableNodeInfoInner(WW8TableNodeInfo * pParent)
48 : : : mpParent(pParent)
49 : : , mnCell(0)
50 : : , mnRow(0)
51 : : , mnShadowsBefore(0)
52 : : , mnShadowsAfter(0)
53 : : , mbEndOfLine(false)
54 : : , mbEndOfCell(false)
55 : : , mbFirstInTable(false)
56 : : , mbVertMerge(false)
57 : : , mpTableBox(NULL)
58 : 0 : , mpTable(NULL)
59 : : {
60 : 0 : }
61 : :
62 : 0 : WW8TableNodeInfoInner::~WW8TableNodeInfoInner()
63 : : {
64 : 0 : }
65 : :
66 : 0 : void WW8TableNodeInfoInner::setDepth(sal_uInt32 nDepth)
67 : : {
68 : 0 : mnDepth = nDepth;
69 : 0 : }
70 : :
71 : 0 : void WW8TableNodeInfoInner::setCell(sal_uInt32 nCell)
72 : : {
73 : 0 : mnCell = nCell;
74 : 0 : }
75 : :
76 : 0 : void WW8TableNodeInfoInner::setRow(sal_uInt32 nRow)
77 : : {
78 : 0 : mnRow = nRow;
79 : 0 : }
80 : :
81 : 0 : void WW8TableNodeInfoInner::setShadowsBefore(sal_uInt32 nShadowsBefore)
82 : : {
83 : 0 : mnShadowsBefore = nShadowsBefore;
84 : 0 : }
85 : :
86 : 0 : void WW8TableNodeInfoInner::setShadowsAfter(sal_uInt32 nShadowsAfter)
87 : : {
88 : 0 : mnShadowsAfter = nShadowsAfter;
89 : 0 : }
90 : :
91 : 0 : void WW8TableNodeInfoInner::setEndOfLine(bool bEndOfLine)
92 : : {
93 : 0 : mbEndOfLine = bEndOfLine;
94 : 0 : }
95 : :
96 : 0 : void WW8TableNodeInfoInner::setEndOfCell(bool bEndOfCell)
97 : : {
98 : 0 : mbEndOfCell = bEndOfCell;
99 : 0 : }
100 : :
101 : 0 : void WW8TableNodeInfoInner::setFirstInTable(bool bFirstInTable)
102 : : {
103 : 0 : mbFirstInTable = bFirstInTable;
104 : 0 : }
105 : :
106 : 0 : void WW8TableNodeInfoInner::setVertMerge(bool bVertMerge)
107 : :
108 : : {
109 : 0 : mbVertMerge = bVertMerge;
110 : 0 : }
111 : :
112 : 0 : void WW8TableNodeInfoInner::setTableBox(const SwTableBox * pTableBox)
113 : : {
114 : 0 : mpTableBox = pTableBox;
115 : 0 : }
116 : :
117 : 0 : void WW8TableNodeInfoInner::setTable(const SwTable * pTable)
118 : : {
119 : 0 : mpTable = pTable;
120 : 0 : }
121 : :
122 : 0 : void WW8TableNodeInfoInner::setRect(const SwRect & rRect)
123 : : {
124 : 0 : maRect = rRect;
125 : 0 : }
126 : :
127 : 0 : sal_uInt32 WW8TableNodeInfoInner::getDepth() const
128 : : {
129 : 0 : return mnDepth;
130 : : }
131 : :
132 : 0 : sal_uInt32 WW8TableNodeInfoInner::getCell() const
133 : : {
134 : 0 : return mnCell;
135 : : }
136 : :
137 : 0 : sal_uInt32 WW8TableNodeInfoInner::getRow() const
138 : : {
139 : 0 : return mnRow;
140 : : }
141 : :
142 : 0 : sal_uInt32 WW8TableNodeInfoInner::getShadowsBefore() const
143 : : {
144 : 0 : return mnShadowsBefore;
145 : : }
146 : :
147 : 0 : sal_uInt32 WW8TableNodeInfoInner::getShadowsAfter() const
148 : : {
149 : 0 : return mnShadowsAfter;
150 : : }
151 : :
152 : 0 : bool WW8TableNodeInfoInner::isEndOfCell() const
153 : : {
154 : 0 : return mbEndOfCell;
155 : : }
156 : :
157 : 0 : bool WW8TableNodeInfoInner::isEndOfLine() const
158 : : {
159 : 0 : return mbEndOfLine;
160 : : }
161 : :
162 : 0 : bool WW8TableNodeInfoInner::isFirstInTable() const
163 : : {
164 : 0 : return mbFirstInTable;
165 : : }
166 : :
167 : 0 : const SwNode * WW8TableNodeInfoInner::getNode() const
168 : : {
169 : 0 : const SwNode * pResult = NULL;
170 : :
171 [ # # ]: 0 : if (mpParent != NULL)
172 : 0 : pResult = mpParent->getNode();
173 : :
174 : 0 : return pResult;
175 : : }
176 : :
177 : 0 : TableBoxVectorPtr WW8TableNodeInfoInner::getTableBoxesOfRow()
178 : : {
179 [ # # ][ # # ]: 0 : TableBoxVectorPtr pResult(new TableBoxVector);
[ # # ]
180 : :
181 : : WW8TableCellGrid::Pointer_t pCellGrid =
182 [ # # ]: 0 : mpParent->getParent()->getCellGridForTable(getTable(), false);
183 : :
184 [ # # ]: 0 : if (pCellGrid.get() == NULL)
185 : : {
186 : 0 : const SwTableLine * pTabLine = getTableBox()->GetUpper();
187 : 0 : const SwTableBoxes & rTblBoxes = pTabLine->GetTabBoxes();
188 : :
189 : 0 : sal_uInt8 nBoxes = rTblBoxes.size();
190 [ # # ]: 0 : for ( sal_uInt8 n = 0; n < nBoxes; n++ )
191 : : {
192 [ # # ]: 0 : pResult->push_back(rTblBoxes[n]);
193 : : }
194 : : }
195 : : else
196 [ # # ][ # # ]: 0 : pResult = pCellGrid->getTableBoxesOfRow(this);
[ # # ]
197 : :
198 [ # # ]: 0 : return pResult;
199 : : }
200 : :
201 : 0 : GridColsPtr WW8TableNodeInfoInner::getGridColsOfRow(AttributeOutputBase & rBase)
202 : : {
203 [ # # ][ # # ]: 0 : GridColsPtr pResult(new GridCols);
[ # # ]
204 [ # # ]: 0 : WidthsPtr pWidths(getWidthsOfRow());
205 : :
206 : 0 : const SwFrmFmt *pFmt = getTable()->GetFrmFmt();
207 : : OSL_ENSURE(pFmt,"Impossible");
208 [ # # ]: 0 : if (!pFmt)
209 : : return pResult;
210 : :
211 [ # # ]: 0 : const SwFmtFrmSize &rSize = pFmt->GetFrmSize();
212 : 0 : unsigned long nTblSz = static_cast<unsigned long>(rSize.GetWidth());
213 : :
214 : 0 : sal_uInt32 nPageSize = 0;
215 : 0 : bool bRelBoxSize = false;
216 : :
217 : : rBase.GetTablePageSize
218 [ # # ]: 0 : ( this, nPageSize, bRelBoxSize );
219 : :
220 : 0 : SwTwips nSz = 0;
221 [ # # ]: 0 : Widths::const_iterator aWidthsEnd = pWidths->end();
222 [ # # ][ # # ]: 0 : for ( Widths::const_iterator aIt = pWidths->begin();
[ # # ][ # # ]
223 : : aIt != aWidthsEnd;
224 : : ++aIt)
225 : : {
226 [ # # ]: 0 : nSz += *aIt;
227 : 0 : SwTwips nCalc = nSz;
228 [ # # ]: 0 : if ( bRelBoxSize )
229 : 0 : nCalc = ( nCalc * nPageSize ) / nTblSz;
230 : :
231 [ # # ]: 0 : pResult->push_back( nCalc );
232 : : }
233 : :
234 [ # # ]: 0 : return pResult;
235 : : }
236 : :
237 : 0 : WidthsPtr WW8TableNodeInfoInner::getWidthsOfRow()
238 : : {
239 [ # # ]: 0 : WidthsPtr pWidths;
240 : :
241 : : WW8TableCellGrid::Pointer_t pCellGrid =
242 [ # # ]: 0 : mpParent->getParent()->getCellGridForTable(getTable(), false);
243 : :
244 [ # # ]: 0 : if (pCellGrid.get() == NULL)
245 : : {
246 : 0 : const SwTableBox * pTabBox = getTableBox();
247 : 0 : const SwTableLine * pTabLine = pTabBox->GetUpper();
248 : 0 : const SwTableBoxes & rTabBoxes = pTabLine->GetTabBoxes();
249 : :
250 [ # # ][ # # ]: 0 : pWidths = WidthsPtr(new Widths);
[ # # ][ # # ]
[ # # ]
251 : : // number of cell written
252 : 0 : sal_uInt32 nBoxes = rTabBoxes.size();
253 [ # # ]: 0 : if ( nBoxes > MAXTABLECELLS )
254 : 0 : nBoxes = MAXTABLECELLS;
255 : :
256 [ # # ]: 0 : for (sal_uInt32 n = 0; n < nBoxes; n++)
257 : : {
258 : 0 : const SwFrmFmt* pBoxFmt = rTabBoxes[ n ]->GetFrmFmt();
259 [ # # ]: 0 : const SwFmtFrmSize& rLSz = pBoxFmt->GetFrmSize();
260 : :
261 [ # # ]: 0 : pWidths->push_back(rLSz.GetWidth());
262 : : }
263 : : }
264 : : else
265 [ # # ][ # # ]: 0 : pWidths = pCellGrid->getWidthsOfRow(this);
[ # # ]
266 : :
267 [ # # ]: 0 : return pWidths;
268 : : }
269 : :
270 : 0 : RowSpansPtr WW8TableNodeInfoInner::getRowSpansOfRow()
271 : : {
272 [ # # ][ # # ]: 0 : RowSpansPtr pResult(new RowSpans);
[ # # ]
273 : :
274 : : WW8TableCellGrid::Pointer_t pCellGrid =
275 [ # # ]: 0 : mpParent->getParent()->getCellGridForTable(getTable(), false);
276 : :
277 [ # # ]: 0 : if (pCellGrid.get() == NULL)
278 : : {
279 : 0 : const SwTableBox * pTabBox = getTableBox();
280 : 0 : const SwTableLine * pTabLine = pTabBox->GetUpper();
281 : 0 : const SwTableBoxes & rTabBoxes = pTabLine->GetTabBoxes();
282 : :
283 : 0 : sal_uInt32 nBoxes = rTabBoxes.size();
284 [ # # ]: 0 : if (nBoxes > MAXTABLECELLS)
285 : 0 : nBoxes = MAXTABLECELLS;
286 : :
287 [ # # ]: 0 : for (sal_uInt32 n = 0; n < nBoxes; ++n)
288 : : {
289 [ # # ][ # # ]: 0 : pResult->push_back(rTabBoxes[n]->getRowSpan());
290 : : }
291 : : }
292 : : else
293 [ # # ][ # # ]: 0 : pResult = pCellGrid->getRowSpansOfRow(this);
[ # # ]
294 : :
295 [ # # ]: 0 : return pResult;
296 : : }
297 : :
298 : 0 : const SwTableBox * WW8TableNodeInfoInner::getTableBox() const
299 : : {
300 : 0 : return mpTableBox;
301 : : }
302 : :
303 : 0 : const SwTable * WW8TableNodeInfoInner::getTable() const
304 : : {
305 : 0 : return mpTable;
306 : : }
307 : :
308 : 0 : const SwRect & WW8TableNodeInfoInner::getRect() const
309 : : {
310 : 0 : return maRect;
311 : : }
312 : :
313 : : #ifdef DBG_UTIL
314 : : ::std::string WW8TableNodeInfoInner::toString() const
315 : : {
316 : : static char buffer[256];
317 : : snprintf(buffer, sizeof(buffer),
318 : : "<tableinner depth=\"%" SAL_PRIuUINT32 "\""
319 : : " cell=\"%" SAL_PRIuUINT32 "\""
320 : : " row=\"%" SAL_PRIuUINT32 "\""
321 : : " endOfCell=\"%s\""
322 : : " endOfLine=\"%s\""
323 : : " shadowsBefore=\"%" SAL_PRIuUINT32 "\""
324 : : " shadowsAfter=\"%" SAL_PRIuUINT32 "\""
325 : : " vertMerge=\"%s\"/>",
326 : : mnDepth, mnCell, mnRow,
327 : : mbEndOfCell ? "yes" : "no",
328 : : mbEndOfLine ? "yes" : "no",
329 : : mnShadowsBefore,
330 : : mnShadowsAfter,
331 : : mbVertMerge ? "yes" : "no");
332 : :
333 : : return string(buffer);
334 : : }
335 : : #endif
336 : :
337 : 0 : WW8TableNodeInfo::WW8TableNodeInfo(WW8TableInfo * pParent,
338 : : const SwNode * pNode)
339 : : : mpParent(pParent),
340 : : mnDepth(0),
341 : : mpNode(pNode),
342 : : mpNext(NULL),
343 : 0 : mpNextNode(NULL)
344 : : {
345 : 0 : }
346 : :
347 : 0 : WW8TableNodeInfo::~WW8TableNodeInfo()
348 : : {
349 [ # # ]: 0 : }
350 : :
351 : : #ifdef DBG_UTIL
352 : : ::std::string WW8TableNodeInfo::toString() const
353 : : {
354 : : static char buffer[1024];
355 : : snprintf(buffer, sizeof(buffer),
356 : : "<tableNodeInfo p=\"%p\" depth=\"%" SAL_PRIuUINT32 "\">"
357 : : ,this, getDepth());
358 : :
359 : : ::std::string sResult(buffer);
360 : :
361 : : Inners_t::const_iterator aIt(mInners.begin());
362 : : Inners_t::const_iterator aEnd(mInners.end());
363 : :
364 : : while (aIt != aEnd)
365 : : {
366 : : WW8TableNodeInfoInner::Pointer_t pInner = aIt->second;
367 : : sResult += pInner->toString();
368 : :
369 : : aIt++;
370 : : }
371 : : sResult += dbg_out(*mpNode);
372 : : sResult += "</tableNodeInfo>";
373 : :
374 : : return sResult;
375 : : }
376 : : #endif
377 : :
378 : 0 : void WW8TableNodeInfo::setDepth(sal_uInt32 nDepth)
379 : : {
380 : 0 : mnDepth = nDepth;
381 : :
382 [ # # ]: 0 : Inners_t::iterator aIt = mInners.find(mnDepth);
383 : :
384 [ # # ]: 0 : if (aIt == mInners.end())
385 [ # # ][ # # ]: 0 : mInners[mnDepth] = WW8TableNodeInfoInner::Pointer_t(new WW8TableNodeInfoInner(this));
[ # # ][ # # ]
[ # # ]
386 : :
387 [ # # ]: 0 : mInners[mnDepth]->setDepth(mnDepth);
388 : 0 : }
389 : :
390 : 0 : void WW8TableNodeInfo::setEndOfLine(bool bEndOfLine)
391 : : {
392 [ # # ]: 0 : WW8TableNodeInfoInner::Pointer_t pInner = getInnerForDepth(mnDepth);
393 [ # # ]: 0 : pInner->setEndOfLine(bEndOfLine);
394 : :
395 : : #ifdef DBG_UTIL
396 : : ::std::clog << "<endOfLine depth=\"" << mnDepth << "\">"
397 : : << toString() << "</endOfLine>" << ::std::endl;
398 : : #endif
399 : 0 : }
400 : :
401 : 0 : void WW8TableNodeInfo::setEndOfCell(bool bEndOfCell)
402 : : {
403 [ # # ]: 0 : WW8TableNodeInfoInner::Pointer_t pInner = getInnerForDepth(mnDepth);
404 [ # # ]: 0 : pInner->setEndOfCell(bEndOfCell);
405 : :
406 : : #ifdef DBG_UTIL
407 : : ::std::clog << "<endOfCell depth=\"" << mnDepth << "\">"
408 : : << toString() << "</endOfCell>" << ::std::endl;
409 : : #endif
410 : 0 : }
411 : :
412 : 0 : void WW8TableNodeInfo::setFirstInTable(bool bFirstInTable)
413 : : {
414 [ # # ]: 0 : WW8TableNodeInfoInner::Pointer_t pInner = getInnerForDepth(mnDepth);
415 : :
416 [ # # ]: 0 : pInner->setFirstInTable(bFirstInTable);
417 : :
418 : : #ifdef DBG_UTIL
419 : : ::std::clog << "<firstInTable depth=\"" << mnDepth << "\">"
420 : : << toString() << "</firstInTable>" << ::std::endl;
421 : : #endif
422 : 0 : }
423 : :
424 : 0 : void WW8TableNodeInfo::setVertMerge(bool bVertMerge)
425 : : {
426 [ # # ]: 0 : WW8TableNodeInfoInner::Pointer_t pInner = getInnerForDepth(mnDepth);
427 : :
428 [ # # ]: 0 : pInner->setVertMerge(bVertMerge);
429 : :
430 : :
431 : : #ifdef DBG_UTIL
432 : : ::std::clog << "<vertMerge depth=\"" << mnDepth << "\">"
433 : : << toString() << "</vertMerge>" << ::std::endl;
434 : : #endif
435 : 0 : }
436 : :
437 : 0 : void WW8TableNodeInfo::setTableBox(const SwTableBox * pTableBox)
438 : : {
439 : 0 : getInnerForDepth(mnDepth)->setTableBox(pTableBox);
440 : 0 : }
441 : :
442 : 0 : void WW8TableNodeInfo::setTable(const SwTable * pTable)
443 : : {
444 : 0 : getInnerForDepth(mnDepth)->setTable(pTable);
445 : 0 : }
446 : :
447 : 0 : void WW8TableNodeInfo::setNext(WW8TableNodeInfo * pNext)
448 : : {
449 : 0 : mpNext = pNext;
450 : :
451 : : #ifdef DBG_UTIL
452 : : ::std::clog << "<setnext><from>" << toString() << "</from><to>"
453 : : << pNext->toString() << "</to></setnext>"
454 : : << ::std::endl;
455 : : #endif
456 : 0 : }
457 : :
458 : 0 : void WW8TableNodeInfo::setNextNode(const SwNode * pNode)
459 : : {
460 : 0 : mpNextNode = pNode;
461 : 0 : }
462 : :
463 : 0 : void WW8TableNodeInfo::setRect(const SwRect & rRect)
464 : : {
465 : 0 : getInnerForDepth(mnDepth)->setRect(rRect);
466 : 0 : }
467 : :
468 : 0 : void WW8TableNodeInfo::setCell(sal_uInt32 nCell)
469 : : {
470 : 0 : getInnerForDepth(mnDepth)->setCell(nCell);
471 : 0 : }
472 : :
473 : 0 : void WW8TableNodeInfo::setRow(sal_uInt32 nRow)
474 : : {
475 : 0 : getInnerForDepth(mnDepth)->setRow(nRow);
476 : 0 : }
477 : :
478 : 0 : void WW8TableNodeInfo::setShadowsBefore(sal_uInt32 nShadowsBefore)
479 : : {
480 : 0 : getInnerForDepth(mnDepth)->setShadowsBefore(nShadowsBefore);
481 : 0 : }
482 : :
483 : 0 : void WW8TableNodeInfo::setShadowsAfter(sal_uInt32 nShadowsAfter)
484 : : {
485 : 0 : getInnerForDepth(mnDepth)->setShadowsAfter(nShadowsAfter);
486 : 0 : }
487 : :
488 : 0 : WW8TableInfo * WW8TableNodeInfo::getParent() const
489 : : {
490 : 0 : return mpParent;
491 : : }
492 : :
493 : 0 : sal_uInt32 WW8TableNodeInfo::getDepth() const
494 : : {
495 [ # # ]: 0 : if (!mInners.empty())
496 : 0 : return mInners.begin()->second->getDepth();
497 : :
498 : 0 : return mnDepth;
499 : : }
500 : :
501 : 0 : const SwNode * WW8TableNodeInfo::getNode() const
502 : : {
503 : 0 : return mpNode;
504 : : }
505 : :
506 : 0 : const SwTableBox * WW8TableNodeInfo::getTableBox() const
507 : : {
508 : 0 : return getInnerForDepth(mnDepth)->getTableBox();
509 : : }
510 : :
511 : 0 : WW8TableNodeInfo * WW8TableNodeInfo::getNext() const
512 : : {
513 : 0 : return mpNext;
514 : : }
515 : :
516 : 0 : const SwNode * WW8TableNodeInfo::getNextNode() const
517 : : {
518 : 0 : return mpNextNode;
519 : : }
520 : :
521 : 0 : sal_uInt32 WW8TableNodeInfo::getCell() const
522 : : {
523 : 0 : return getInnerForDepth(mnDepth)->getCell();
524 : : }
525 : :
526 : 0 : sal_uInt32 WW8TableNodeInfo::getRow() const
527 : : {
528 : 0 : return getInnerForDepth(mnDepth)->getRow();
529 : : }
530 : :
531 : 0 : const ww8::WW8TableNodeInfo::Inners_t & WW8TableNodeInfo::getInners() const
532 : : {
533 : 0 : return mInners;
534 : : }
535 : :
536 : 0 : const WW8TableNodeInfoInner::Pointer_t WW8TableNodeInfo::getFirstInner() const
537 : : {
538 : 0 : WW8TableNodeInfoInner::Pointer_t pResult;
539 : :
540 [ # # ]: 0 : if (!mInners.empty())
541 [ # # ]: 0 : pResult = mInners.begin()->second;
542 : :
543 : 0 : return pResult;
544 : : }
545 : :
546 : 0 : const WW8TableNodeInfoInner::Pointer_t WW8TableNodeInfo::getInnerForDepth(sal_uInt32 nDepth) const
547 : : {
548 [ # # ]: 0 : WW8TableNodeInfoInner::Pointer_t pResult;
549 : :
550 [ # # ]: 0 : Inners_t::const_iterator aIt = mInners.find(nDepth);
551 [ # # ]: 0 : if (aIt != mInners.end())
552 : : {
553 [ # # ]: 0 : pResult = aIt->second;
554 : : }
555 : :
556 : 0 : return pResult;
557 : : }
558 : :
559 : : // WW8TableInfo
560 : :
561 [ + - ][ + - ]: 222 : WW8TableInfo::WW8TableInfo()
[ + - ]
562 : : {
563 : 222 : }
564 : :
565 [ + - ][ + - ]: 222 : WW8TableInfo::~WW8TableInfo()
566 : : {
567 [ - + ]: 444 : }
568 : :
569 : : WW8TableNodeInfo *
570 : 0 : WW8TableInfo::processSwTableByLayout(const SwTable * pTable)
571 : : {
572 [ # # ]: 0 : SwTableCellInfo aTableCellInfo(pTable);
573 : 0 : WW8TableNodeInfo * pPrev = NULL;
574 : :
575 [ # # ][ # # ]: 0 : while (aTableCellInfo.getNext())
576 : : {
577 [ # # ]: 0 : SwRect aRect = aTableCellInfo.getRect();
578 : :
579 : : #ifdef DBG_UTIL
580 : : static char sBuffer[1024];
581 : : ::std::clog << "<CellFrm>" << ::std::endl;
582 : :
583 : : snprintf(sBuffer, sizeof(sBuffer),
584 : : "<rect top=\"%ld\" bottom=\"%ld\" left=\"%ld\" right=\"%ld\"/>",
585 : : aRect.Top(), aRect.Bottom(), aRect.Left(), aRect.Right());
586 : : ::std::clog << sBuffer << ::std::endl;
587 : : #endif
588 [ # # ]: 0 : const SwTableBox * pTableBox = aTableCellInfo.getTableBox();
589 : 0 : const SwStartNode * pSttNd = pTableBox->GetSttNd();
590 : :
591 [ # # ]: 0 : if (pSttNd != NULL)
592 : : {
593 [ # # ]: 0 : SwPaM aPam(*pSttNd, 0);
594 : :
595 : 0 : bool bDone = false;
596 [ # # ]: 0 : do
597 : : {
598 : 0 : SwNode & rNode = aPam.GetPoint()->nNode.GetNode();
599 : :
600 [ # # ][ # # ]: 0 : insertTableNodeInfo(&rNode, pTable, pTableBox, 0, 0, 1, & aRect);
601 : :
602 [ # # ]: 0 : if (rNode.IsEndNode())
603 : : {
604 : 0 : SwEndNode * pEndNode = rNode.GetEndNode();
605 : 0 : SwStartNode * pTmpSttNd = pEndNode->StartOfSectionNode();
606 : :
607 [ # # ]: 0 : if (pTmpSttNd == pSttNd)
608 : 0 : bDone = true;
609 : : }
610 : :
611 [ # # ]: 0 : aPam.GetPoint()->nNode++;
612 : : }
613 [ # # ]: 0 : while (!bDone);
614 : : }
615 : :
616 : : #ifdef DBG_UTIL
617 : : ::std::clog << "</CellFrm>" << ::std::endl;
618 : : #endif
619 : : }
620 : :
621 [ # # ]: 0 : pPrev = reorderByLayout(pTable);
622 : :
623 [ # # ]: 0 : return pPrev;
624 : : }
625 : :
626 : 0 : void WW8TableInfo::processSwTable(const SwTable * pTable)
627 : : {
628 : : #ifdef DBG_UTIL
629 : : ::std::clog << "<processSwTable>" << ::std::endl;
630 : : #endif
631 : :
632 : 0 : WW8TableNodeInfo * pPrev = NULL;
633 : :
634 [ # # ][ # # ]: 0 : if (pTable->IsTblComplex() && pTable->HasLayout())
[ # # ]
635 : : {
636 : 0 : pPrev = processSwTableByLayout(pTable);
637 : :
638 : : #ifdef DBG_UTIL
639 : : WW8TableCellGrid::Pointer_t pCellGrid(getCellGridForTable(pTable));
640 : : ::std::clog << pCellGrid->toString() << ::std::endl;
641 : : #endif
642 : : }
643 : : else
644 : : {
645 : 0 : const SwTableLines & rLines = pTable->GetTabLines();
646 : :
647 [ # # ]: 0 : for (sal_uInt16 n = 0; n < rLines.size(); n++)
648 : : {
649 : 0 : const SwTableLine * pLine = rLines[n];
650 : :
651 : 0 : pPrev = processTableLine(pTable, pLine, n, 1, pPrev);
652 : : }
653 : :
654 : : }
655 : :
656 [ # # ]: 0 : if (pPrev != NULL)
657 : : {
658 : 0 : SwTableNode * pTableNode = pTable->GetTableNode();
659 : 0 : SwEndNode * pEndNode = pTableNode->EndOfSectionNode();
660 : :
661 : 0 : pPrev->setNextNode(pEndNode);
662 : : }
663 : : #ifdef DBG_UTIL
664 : : ::std::clog << "</processSwTable>" << ::std::endl;
665 : : #endif
666 : 0 : }
667 : :
668 : : WW8TableNodeInfo *
669 : 0 : WW8TableInfo::processTableLine(const SwTable * pTable,
670 : : const SwTableLine * pTableLine,
671 : : sal_uInt32 nRow,
672 : : sal_uInt32 nDepth, WW8TableNodeInfo * pPrev)
673 : : {
674 : : #ifdef DBG_UTIL
675 : : ::std::clog << "<processTableLine row=\"" << nRow << "\" depth=\""
676 : : << nDepth << "\">" << ::std::endl;
677 : : #endif
678 : :
679 : 0 : const SwTableBoxes & rBoxes = pTableLine->GetTabBoxes();
680 : :
681 [ # # ]: 0 : WW8TableNodeInfo::Pointer_t pTextNodeInfo;
682 : :
683 [ # # ]: 0 : for (sal_uInt16 n = 0; n < rBoxes.size(); n++)
684 : : {
685 : 0 : const SwTableBox * pBox = rBoxes[n];
686 : :
687 [ # # ]: 0 : pPrev = processTableBox(pTable, pBox, nRow, n, nDepth, n == rBoxes.size() - 1, pPrev);
688 : : }
689 : :
690 : : #ifdef DBG_UTIL
691 : : ::std::clog << "</processTableLine>" << ::std::endl;
692 : : #endif
693 : :
694 [ # # ]: 0 : return pPrev;
695 : : }
696 : :
697 : : WW8TableNodeInfo::Pointer_t
698 : 0 : WW8TableInfo::processTableBoxLines(const SwTableBox * pBox,
699 : : const SwTable * pTable,
700 : : const SwTableBox * pBoxToSet,
701 : : sal_uInt32 nRow,
702 : : sal_uInt32 nCell,
703 : : sal_uInt32 nDepth)
704 : : {
705 : : #ifdef DBG_UTIL
706 : : ::std::clog << "<processTableBoxLines depth=\"" << nDepth
707 : : << "\" row=\"" << nRow << "\" cell=\"" << nCell << "\">" << ::std::endl;
708 : : #endif
709 : :
710 : 0 : const SwTableLines & rLines = pBox->GetTabLines();
711 : 0 : WW8TableNodeInfo::Pointer_t pNodeInfo;
712 : :
713 [ # # ]: 0 : if (!rLines.empty())
714 : : {
715 [ # # ]: 0 : for (sal_uInt32 n = 0; n < rLines.size(); n++)
716 : : {
717 : 0 : const SwTableLine * pLine = rLines[n];
718 : 0 : const SwTableBoxes & rBoxes = pLine->GetTabBoxes();
719 : :
720 [ # # ]: 0 : for (sal_uInt16 nBox = 0; nBox < rBoxes.size(); nBox++)
721 [ # # ][ # # ]: 0 : pNodeInfo = processTableBoxLines(rBoxes[nBox], pTable, pBoxToSet, nRow, nCell, nDepth);
[ # # ]
722 : : }
723 : : }
724 : : else
725 : : {
726 : 0 : const SwStartNode * pSttNd = pBox->GetSttNd();
727 : 0 : const SwEndNode * pEndNd = pSttNd->EndOfSectionNode();
728 [ # # ]: 0 : SwPaM aPaM(*pSttNd, 0);
729 [ # # ]: 0 : SwPaM aEndPaM(*pEndNd, 0);
730 : :
731 : 0 : bool bDone = false;
732 [ # # ]: 0 : while (!bDone)
733 : : {
734 : 0 : SwNode & rNode = aPaM.GetPoint()->nNode.GetNode();
735 : :
736 [ # # ][ # # ]: 0 : pNodeInfo = insertTableNodeInfo(&rNode, pTable, pBoxToSet, nRow, nCell, nDepth);
[ # # ]
737 : :
738 [ # # ]: 0 : if (aPaM.GetPoint()->nNode == aEndPaM.GetPoint()->nNode)
739 : 0 : bDone = true;
740 : : else
741 [ # # ]: 0 : aPaM.GetPoint()->nNode++;
742 [ # # ][ # # ]: 0 : }
743 : : }
744 : :
745 : : #ifdef DBG_UTIL
746 : : ::std::clog << "</processTableBoxLines>" << ::std::endl;
747 : : #endif
748 : :
749 : 0 : return pNodeInfo;
750 : : }
751 : :
752 : : WW8TableNodeInfo *
753 : 0 : WW8TableInfo::processTableBox(const SwTable * pTable,
754 : : const SwTableBox * pBox,
755 : : sal_uInt32 nRow,
756 : : sal_uInt32 nCell,
757 : : sal_uInt32 nDepth,
758 : : bool bEndOfLine,
759 : : WW8TableNodeInfo * pPrev)
760 : : {
761 : : #ifdef DBG_UTIL
762 : : ::std::clog << "<processTableBox row=\"" << nRow << "\" cell=\"" << nCell
763 : : << "\" depth=\"" << nDepth << "\">" << ::std::endl;
764 : : #endif
765 : :
766 [ # # ]: 0 : WW8TableNodeInfo::Pointer_t pNodeInfo;
767 : 0 : const SwTableLines & rLines = pBox->GetTabLines();
768 : 0 : const SwStartNode * pSttNd = pBox->GetSttNd();
769 [ # # ]: 0 : WW8TableNodeInfo::Pointer_t pEndOfCellInfo;
770 : :
771 [ # # ]: 0 : if (!rLines.empty())
772 : : {
773 [ # # ][ # # ]: 0 : pNodeInfo = processTableBoxLines(pBox, pTable, pBox, nRow, nCell, nDepth);
[ # # ]
774 [ # # ]: 0 : pNodeInfo->setEndOfCell(true);
775 [ # # ]: 0 : if (bEndOfLine)
776 [ # # ]: 0 : pNodeInfo->setEndOfLine(true);
777 : :
778 [ # # ]: 0 : for (sal_uInt32 n = 0; n < rLines.size(); n++)
779 : : {
780 : 0 : const SwTableLine * pLine = rLines[n];
781 : :
782 [ # # ]: 0 : pPrev = processTableLine(pTable, pLine, n, 1, pPrev);
783 : : }
784 : : }
785 : : else
786 : : {
787 [ # # ]: 0 : SwPaM aPaM(*pSttNd, 0);
788 : :
789 : 0 : bool bDone = false;
790 : 0 : sal_uInt32 nDepthInsideCell = 0;
791 : :
792 [ # # ]: 0 : do
793 : : {
794 : 0 : SwNode & rNode = aPaM.GetPoint()->nNode.GetNode();
795 : :
796 [ # # ]: 0 : if (rNode.IsStartNode())
797 : : {
798 [ # # ]: 0 : if (nDepthInsideCell > 0)
799 [ # # ]: 0 : pEndOfCellInfo.reset();
800 : :
801 : 0 : nDepthInsideCell++;
802 : : }
803 : :
804 [ # # ][ # # ]: 0 : pNodeInfo = insertTableNodeInfo(&rNode, pTable, pBox, nRow, nCell, nDepth);
[ # # ]
805 : :
806 [ # # ]: 0 : if (pPrev != NULL)
807 : 0 : pPrev->setNext(pNodeInfo.get());
808 : :
809 : 0 : pPrev = pNodeInfo.get();
810 : :
811 [ # # ][ # # ]: 0 : if (nDepthInsideCell == 1 && rNode.IsTxtNode())
[ # # ]
812 [ # # ]: 0 : pEndOfCellInfo = pNodeInfo;
813 : :
814 [ # # ]: 0 : if (rNode.IsEndNode())
815 : : {
816 : 0 : nDepthInsideCell--;
817 : :
818 [ # # ][ # # ]: 0 : if (nDepthInsideCell == 0 && pEndOfCellInfo.get() == NULL)
[ # # ]
819 [ # # ]: 0 : pEndOfCellInfo = pNodeInfo;
820 : :
821 : 0 : SwEndNode * pEndNode = rNode.GetEndNode( );
822 : 0 : SwStartNode * pTmpSttNd = pEndNode->StartOfSectionNode();
823 [ # # ]: 0 : if (pTmpSttNd == pSttNd)
824 : 0 : bDone = true;
825 : : }
826 : :
827 [ # # ]: 0 : aPaM.GetPoint()->nNode++;
828 : : }
829 : 0 : while (!bDone);
830 : :
831 [ # # ]: 0 : if (pEndOfCellInfo.get() != NULL)
832 : : {
833 [ # # ]: 0 : pEndOfCellInfo->setEndOfCell(true);
834 : :
835 [ # # ]: 0 : if (bEndOfLine)
836 [ # # ]: 0 : pEndOfCellInfo->setEndOfLine(true);
837 [ # # ]: 0 : }
838 : : }
839 : :
840 : : #ifdef DBG_UTIL
841 : : ::std::clog << "</processTableBox>" << ::std::endl;
842 : : #endif
843 : :
844 [ # # ][ # # ]: 0 : return pPrev;
845 : : }
846 : :
847 : 0 : WW8TableNodeInfo::Pointer_t WW8TableInfo::insertTableNodeInfo
848 : : (const SwNode * pNode,
849 : : const SwTable * pTable,
850 : : const SwTableBox * pTableBox,
851 : : sal_uInt32 nRow,
852 : : sal_uInt32 nCell,
853 : : sal_uInt32 nDepth,
854 : : SwRect * pRect)
855 : : {
856 : 0 : WW8TableNodeInfo::Pointer_t pNodeInfo = getTableNodeInfo(pNode);
857 : :
858 [ # # ]: 0 : if (pNodeInfo.get() == NULL)
859 : : {
860 : : pNodeInfo =
861 [ # # ][ # # ]: 0 : WW8TableNodeInfo::Pointer_t(new WW8TableNodeInfo(this, pNode));
[ # # ][ # # ]
[ # # ]
862 [ # # ][ # # ]: 0 : mMap.insert(Map_t::value_type(pNode, pNodeInfo));
[ # # ]
863 : : }
864 : :
865 [ # # ][ # # ]: 0 : pNodeInfo->setDepth(nDepth + pNodeInfo->getDepth());
866 : :
867 [ # # ]: 0 : pNodeInfo->setTable(pTable);
868 [ # # ]: 0 : pNodeInfo->setTableBox(pTableBox);
869 : :
870 [ # # ]: 0 : pNodeInfo->setCell(nCell);
871 [ # # ]: 0 : pNodeInfo->setRow(nRow);
872 : :
873 [ # # ]: 0 : if (pNode->IsTxtNode())
874 : : {
875 [ # # ]: 0 : FirstInTableMap_t::const_iterator aIt = mFirstInTableMap.find(pTable);
876 [ # # ][ # # ]: 0 : if (aIt == mFirstInTableMap.end())
877 : : {
878 [ # # ]: 0 : mFirstInTableMap[pTable] = pNode;
879 [ # # ]: 0 : pNodeInfo->setFirstInTable(true);
880 : : }
881 : : }
882 : :
883 [ # # ]: 0 : if (pRect)
884 : : {
885 [ # # ]: 0 : WW8TableCellGrid::Pointer_t pCellGrid = getCellGridForTable(pTable);
886 : :
887 [ # # ]: 0 : pCellGrid->insert(*pRect, pNodeInfo.get());
888 [ # # ][ # # ]: 0 : pNodeInfo->setRect(*pRect);
889 : : }
890 : :
891 : : #ifdef DBG_UTIL
892 : : ::std::clog << pNodeInfo->toString() << ::std::endl;
893 : : #endif
894 : :
895 : 0 : return pNodeInfo;
896 : : }
897 : :
898 : 0 : WW8TableCellGrid::Pointer_t WW8TableInfo::getCellGridForTable
899 : : (const SwTable * pTable, bool bCreate)
900 : : {
901 [ # # ]: 0 : WW8TableCellGrid::Pointer_t pResult;
902 [ # # ]: 0 : CellGridMap_t::iterator aIt = mCellGridMap.find(pTable);
903 : :
904 [ # # ][ # # ]: 0 : if (aIt == mCellGridMap.end())
905 : : {
906 [ # # ]: 0 : if (bCreate)
907 : : {
908 [ # # ][ # # ]: 0 : pResult = WW8TableCellGrid::Pointer_t(new WW8TableCellGrid);
[ # # ][ # # ]
[ # # ]
909 [ # # ][ # # ]: 0 : mCellGridMap[pTable] = pResult;
910 : : }
911 : : }
912 : : else
913 [ # # ][ # # ]: 0 : pResult = mCellGridMap[pTable];
914 : :
915 : 0 : return pResult;
916 : : }
917 : :
918 : 1032 : WW8TableNodeInfo::Pointer_t WW8TableInfo::getTableNodeInfo
919 : : (const SwNode * pNode)
920 : : {
921 [ + - ]: 1032 : WW8TableNodeInfo::Pointer_t pResult;
922 [ + - ]: 1032 : Map_t::iterator aIt = mMap.find(pNode);
923 : :
924 [ + - ][ - + ]: 1032 : if (aIt != mMap.end())
925 [ # # ][ # # ]: 1032 : pResult = (*aIt).second;
926 : :
927 : 1032 : return pResult;
928 : : }
929 : :
930 : 444 : const SwNode * WW8TableInfo::getNextNode(const SwNode * pNode)
931 : : {
932 : 444 : const SwNode * pResult = NULL;
933 : :
934 [ + - ]: 444 : WW8TableNodeInfo::Pointer_t pNodeInfo = getTableNodeInfo(pNode);
935 : :
936 [ - + ]: 444 : if (pNodeInfo.get() != NULL)
937 : : {
938 : 0 : WW8TableNodeInfo * pNextInfo = pNodeInfo->getNext();
939 : :
940 [ # # ]: 0 : if (pNextInfo != NULL)
941 : 0 : pResult = pNextInfo->getNode();
942 : : else
943 : : {
944 : 0 : const SwNode * pNextNode = pNodeInfo->getNextNode();
945 : :
946 [ # # ]: 0 : if (pNextNode != NULL)
947 : 0 : pResult = pNextNode;
948 : : }
949 : : }
950 : :
951 [ + - ]: 444 : return pResult;
952 : : }
953 : :
954 : 0 : bool WW8TableNodeInfo::operator < (const WW8TableNodeInfo & rInfo) const
955 : : {
956 : 0 : bool bRet = false;
957 : :
958 [ # # ]: 0 : if (rInfo.mpNode != NULL)
959 : : {
960 [ # # ]: 0 : if (mpNode == NULL)
961 : : {
962 : 0 : bRet = true;
963 : : }
964 : : else
965 : : {
966 [ # # ]: 0 : if (mpNode->GetIndex() < rInfo.mpNode->GetIndex())
967 : 0 : bRet = true;
968 : : }
969 : : }
970 : :
971 : 0 : return bRet;
972 : : }
973 : :
974 : 0 : bool CellInfo::operator < (const CellInfo & aCellInfo) const
975 : : {
976 : 0 : bool aRet = false;
977 : :
978 [ # # ]: 0 : if (top() < aCellInfo.top())
979 : 0 : aRet = true;
980 [ # # ]: 0 : else if (top() == aCellInfo.top())
981 : : {
982 [ # # ]: 0 : if (left() < aCellInfo.left())
983 : 0 : aRet = true;
984 [ # # ]: 0 : else if (left() == aCellInfo.left())
985 : : {
986 [ # # ]: 0 : if (width() < aCellInfo.width())
987 : 0 : aRet = true;
988 [ # # ]: 0 : else if (width() == aCellInfo.width())
989 : : {
990 [ # # ]: 0 : if (height() < aCellInfo.height())
991 : 0 : aRet = true;
992 [ # # ]: 0 : else if (height() == aCellInfo.height())
993 : : {
994 [ # # ]: 0 : if (aCellInfo.getTableNodeInfo() != NULL)
995 : : {
996 [ # # ]: 0 : if (m_pNodeInfo == NULL)
997 : 0 : aRet = true;
998 : : else
999 : : {
1000 : 0 : aRet = *m_pNodeInfo < *aCellInfo.getTableNodeInfo();
1001 : : }
1002 : : }
1003 : : }
1004 : : }
1005 : : }
1006 : : }
1007 : :
1008 : 0 : return aRet;
1009 : : }
1010 : :
1011 : : #ifdef DBG_UTIL
1012 : : ::std::string CellInfo::toString() const
1013 : : {
1014 : : static char sBuffer[256];
1015 : :
1016 : : snprintf(sBuffer, sizeof(sBuffer),
1017 : : "<cellinfo left=\"%ld\""
1018 : : " right=\"%ld\""
1019 : : " top=\"%ld\""
1020 : : " bottom=\"%ld\""
1021 : : " node=\"%p\"/>",
1022 : : left(),
1023 : : right(),
1024 : : top(),
1025 : : bottom(),
1026 : : m_pNodeInfo);
1027 : :
1028 : : return sBuffer;
1029 : : }
1030 : : #endif
1031 : :
1032 : 0 : WW8TableNodeInfo * WW8TableInfo::reorderByLayout(const SwTable * pTable)
1033 : : {
1034 : 0 : WW8TableNodeInfo * pPrev = NULL;
1035 [ # # ]: 0 : WW8TableCellGrid::Pointer_t pCellGrid = getCellGridForTable(pTable);
1036 : :
1037 : : #ifdef DBG_UTIL
1038 : : ::std::clog << pCellGrid->toString() << ::std::endl;
1039 : : #endif
1040 : :
1041 [ # # ]: 0 : pCellGrid->addShadowCells();
1042 [ # # ]: 0 : pPrev = pCellGrid->connectCells();
1043 : :
1044 [ # # ]: 0 : return pPrev;
1045 : : }
1046 : :
1047 [ # # ]: 0 : WW8TableCellGrid::WW8TableCellGrid()
1048 : : {
1049 : 0 : }
1050 : :
1051 : 0 : WW8TableCellGrid::~WW8TableCellGrid()
1052 : : {
1053 : 0 : }
1054 : :
1055 : 0 : WW8TableCellGridRow::Pointer_t WW8TableCellGrid::getRow(long nTop, bool bCreate)
1056 : : {
1057 [ # # ]: 0 : WW8TableCellGridRow::Pointer_t pResult;
1058 : :
1059 [ # # ]: 0 : RowTops_t::iterator aIt = m_aRowTops.find(nTop);
1060 : :
1061 [ # # ][ # # ]: 0 : if (aIt == m_aRowTops.end())
1062 : : {
1063 [ # # ]: 0 : if (bCreate)
1064 : : {
1065 [ # # ][ # # ]: 0 : pResult = WW8TableCellGridRow::Pointer_t(new WW8TableCellGridRow);
[ # # ][ # # ]
[ # # ]
1066 [ # # ][ # # ]: 0 : m_aRows[nTop] = pResult;
1067 [ # # ]: 0 : m_aRowTops.insert(nTop);
1068 : : }
1069 : : }
1070 : : else
1071 [ # # ][ # # ]: 0 : pResult = m_aRows[nTop];
1072 : :
1073 : 0 : return pResult;
1074 : : }
1075 : :
1076 : 0 : WW8TableCellGrid::RowTops_t::const_iterator WW8TableCellGrid::getRowTopsBegin() const
1077 : : {
1078 : 0 : return m_aRowTops.begin();
1079 : : }
1080 : :
1081 : 0 : WW8TableCellGrid::RowTops_t::const_iterator WW8TableCellGrid::getRowTopsEnd() const
1082 : : {
1083 : 0 : return m_aRowTops.end();
1084 : : }
1085 : :
1086 : 0 : CellInfoMultiSet::const_iterator WW8TableCellGrid::getCellsBegin(long nTop)
1087 : : {
1088 [ # # ]: 0 : return getRow(nTop)->begin();
1089 : : }
1090 : :
1091 : 0 : CellInfoMultiSet::const_iterator WW8TableCellGrid::getCellsEnd(long nTop)
1092 : : {
1093 [ # # ]: 0 : return getRow(nTop)->end();
1094 : : }
1095 : :
1096 : 0 : void WW8TableCellGrid::insert(const SwRect & rRect,
1097 : : WW8TableNodeInfo * pNodeInfo,
1098 : : unsigned long * pFmtFrmWidth)
1099 : : {
1100 [ # # ]: 0 : CellInfo aCellInfo(rRect, pNodeInfo);
1101 : :
1102 [ # # ]: 0 : if (pFmtFrmWidth != NULL)
1103 : 0 : aCellInfo.setFmtFrmWidth(*pFmtFrmWidth);
1104 : :
1105 [ # # ]: 0 : WW8TableCellGridRow::Pointer_t pRow = getRow(rRect.Top());
1106 [ # # ][ # # ]: 0 : pRow->insert(aCellInfo);
1107 : 0 : }
1108 : :
1109 : 0 : void WW8TableCellGrid::addShadowCells()
1110 : : {
1111 : : #ifdef DBG_UTIL
1112 : : ::std::clog << "<addShadowCells>" << ::std::endl;
1113 : : #endif
1114 : :
1115 : 0 : RowTops_t::const_iterator aTopsIt = getRowTopsBegin();
1116 : :
1117 [ # # ][ # # ]: 0 : while (aTopsIt != getRowTopsEnd())
1118 : : {
1119 : : #ifdef DBG_UTIL
1120 : : long nTop = *aTopsIt;
1121 : : (void) nTop;
1122 : : #endif
1123 [ # # ][ # # ]: 0 : CellInfoMultiSet::const_iterator aCellIt = getCellsBegin(*aTopsIt);
1124 [ # # ][ # # ]: 0 : CellInfoMultiSet::const_iterator aCellEndIt = getCellsEnd(*aTopsIt);
1125 : :
1126 [ # # ][ # # ]: 0 : RowSpansPtr pRowSpans(new RowSpans);
[ # # ]
1127 : :
1128 : 0 : bool bBeginningOfCell = true;
1129 : 0 : bool bVertMerge = false;
1130 : 0 : SwRect aRect = aCellIt->getRect();
1131 : 0 : long nRowSpan = 1;
1132 [ # # ]: 0 : while (aCellIt != aCellEndIt)
1133 : : {
1134 : 0 : WW8TableNodeInfo * pNodeInfo = aCellIt->getTableNodeInfo();
1135 : :
1136 [ # # ]: 0 : if (bBeginningOfCell)
1137 : : {
1138 : 0 : RowTops_t::const_iterator aRowSpanIt(aTopsIt);
1139 [ # # ]: 0 : ++aRowSpanIt;
1140 : :
1141 [ # # ]: 0 : if (aRowSpanIt != getRowTopsEnd() &&
[ # # # # ]
[ # # ]
[ # # # # ]
1142 [ # # ]: 0 : *aRowSpanIt < aCellIt->bottom())
1143 : : {
1144 [ # # ]: 0 : aRect.Top(*aRowSpanIt);
1145 : 0 : unsigned long nFmtFrmWidth = aCellIt->getFmtFrmWidth();
1146 [ # # ]: 0 : insert(aRect, NULL, &nFmtFrmWidth);
1147 : :
1148 : 0 : bVertMerge = true;
1149 : : }
1150 : : else
1151 : 0 : bVertMerge = false;
1152 : :
1153 : 0 : nRowSpan = 1;
1154 [ # # ]: 0 : while (aRowSpanIt != getRowTopsEnd() &&
[ # # # # ]
[ # # ]
[ # # # # ]
1155 [ # # ]: 0 : *aRowSpanIt < aCellIt->bottom())
1156 : : {
1157 [ # # ]: 0 : ++aRowSpanIt;
1158 : 0 : nRowSpan++;
1159 : : }
1160 : :
1161 [ # # ]: 0 : if (pNodeInfo != NULL)
1162 [ # # ]: 0 : pRowSpans->push_back(nRowSpan);
1163 : : else
1164 [ # # ]: 0 : pRowSpans->push_back(-nRowSpan);
1165 : : }
1166 : :
1167 [ # # ]: 0 : if (pNodeInfo != NULL)
1168 : : {
1169 [ # # ]: 0 : pNodeInfo->setVertMerge(bVertMerge);
1170 : : }
1171 : :
1172 : 0 : ++aCellIt;
1173 [ # # ]: 0 : if (aCellIt != aCellEndIt)
1174 : : {
1175 : 0 : bBeginningOfCell = (aRect.Left() != aCellIt->left());
1176 : 0 : aRect = aCellIt->getRect();
1177 : : }
1178 : : }
1179 : :
1180 [ # # ][ # # ]: 0 : WW8TableCellGridRow::Pointer_t pRow = getRow(*aTopsIt);
1181 [ # # ]: 0 : if (pRow.get() != NULL)
1182 [ # # ][ # # ]: 0 : pRow->setRowSpans(pRowSpans);
[ # # ]
1183 : :
1184 [ # # ]: 0 : ++aTopsIt;
1185 [ # # ][ # # ]: 0 : }
1186 : : #ifdef DBG_UTIL
1187 : : ::std::clog << "</addShadowCells>" << ::std::endl;
1188 : : #endif
1189 : 0 : }
1190 : :
1191 : 0 : WW8TableNodeInfo * WW8TableCellGrid::connectCells()
1192 : : {
1193 : 0 : RowTops_t::const_iterator aTopsIt = getRowTopsBegin();
1194 : 0 : sal_uInt32 nRow = 0;
1195 : 0 : WW8TableNodeInfo * pLastNodeInfo = NULL;
1196 : :
1197 [ # # ][ # # ]: 0 : while (aTopsIt != getRowTopsEnd())
1198 : : {
1199 [ # # ][ # # ]: 0 : CellInfoMultiSet::const_iterator aCellIt = getCellsBegin(*aTopsIt);
1200 [ # # ][ # # ]: 0 : CellInfoMultiSet::const_iterator aCellEndIt = getCellsEnd(*aTopsIt);
1201 [ # # ][ # # ]: 0 : GridColsPtr pWidths(new Widths);
[ # # ]
1202 [ # # ][ # # ]: 0 : TableBoxVectorPtr pTableBoxes(new TableBoxVector);
[ # # ]
1203 : :
1204 : 0 : sal_uInt32 nShadows = 0;
1205 : 0 : sal_uInt32 nCell = 0;
1206 : 0 : bool bBeginningOfCell = true;
1207 : 0 : WW8TableNodeInfo * pEndOfCellInfo = NULL;
1208 : 0 : sal_uInt32 nDepthInCell = 0;
1209 [ # # ]: 0 : while (aCellIt != aCellEndIt)
1210 : : {
1211 : 0 : long nCellX = aCellIt->left();
1212 : 0 : WW8TableNodeInfo * pNodeInfo = aCellIt->getTableNodeInfo();
1213 [ # # ]: 0 : if (pNodeInfo != NULL)
1214 : : {
1215 : 0 : const SwNode * pNode = pNodeInfo->getNode();
1216 : :
1217 [ # # ]: 0 : if (pNode->IsStartNode())
1218 : : {
1219 : 0 : nDepthInCell++;
1220 : 0 : pEndOfCellInfo = NULL;
1221 : : }
1222 : :
1223 [ # # ][ # # ]: 0 : if (nDepthInCell == 1 && pNode->IsTxtNode())
[ # # ]
1224 : 0 : pEndOfCellInfo = pNodeInfo;
1225 : :
1226 [ # # ]: 0 : pNodeInfo->setShadowsBefore(nShadows);
1227 [ # # ]: 0 : pNodeInfo->setCell(nCell);
1228 [ # # ]: 0 : pNodeInfo->setRow(nRow);
1229 [ # # ]: 0 : if (pLastNodeInfo != NULL)
1230 : : {
1231 : 0 : pLastNodeInfo->setNext(pNodeInfo);
1232 : 0 : pLastNodeInfo->setNextNode(pNode);
1233 : : }
1234 : 0 : pLastNodeInfo = pNodeInfo;
1235 : 0 : nShadows = 0;
1236 : :
1237 [ # # ]: 0 : if (pNode->IsEndNode())
1238 : : {
1239 : 0 : nDepthInCell--;
1240 : :
1241 [ # # ][ # # ]: 0 : if (nDepthInCell == 0 && pEndOfCellInfo == NULL)
1242 : 0 : pEndOfCellInfo = pNodeInfo;
1243 : : }
1244 : : }
1245 : : else
1246 : : {
1247 : 0 : nShadows++;
1248 : : }
1249 : :
1250 [ # # ]: 0 : if (bBeginningOfCell)
1251 : : {
1252 [ # # ]: 0 : pWidths->push_back(aCellIt->getFmtFrmWidth());
1253 : :
1254 [ # # ]: 0 : if (pNodeInfo != NULL)
1255 [ # # ][ # # ]: 0 : pTableBoxes->push_back(pNodeInfo->getTableBox());
1256 : : else
1257 [ # # ]: 0 : pTableBoxes->push_back(NULL);
1258 : : }
1259 : :
1260 : 0 : ++aCellIt;
1261 : 0 : bBeginningOfCell = false;
1262 : :
1263 [ # # ][ # # ]: 0 : if (aCellIt != aCellEndIt && aCellIt->left() != nCellX)
[ # # ]
1264 : : {
1265 : 0 : nCell++;
1266 : 0 : bBeginningOfCell = true;
1267 : :
1268 [ # # ]: 0 : if (pEndOfCellInfo != NULL)
1269 : : {
1270 [ # # ]: 0 : pEndOfCellInfo->setEndOfCell(true);
1271 : : }
1272 : :
1273 : 0 : pEndOfCellInfo = NULL;
1274 : : }
1275 : : }
1276 : :
1277 [ # # ]: 0 : pLastNodeInfo->setShadowsAfter(nShadows);
1278 : :
1279 [ # # ]: 0 : if (pEndOfCellInfo == NULL)
1280 : : {
1281 : 0 : pEndOfCellInfo = pLastNodeInfo;
1282 : : }
1283 : :
1284 [ # # ]: 0 : pEndOfCellInfo->setEndOfCell(true);
1285 [ # # ]: 0 : pLastNodeInfo->setEndOfLine(true);
1286 : :
1287 [ # # ][ # # ]: 0 : WW8TableCellGridRow::Pointer_t pRow(getRow(*aTopsIt));
1288 [ # # ][ # # ]: 0 : pRow->setTableBoxVector(pTableBoxes);
[ # # ]
1289 [ # # ][ # # ]: 0 : pRow->setWidths(pWidths);
[ # # ]
1290 : :
1291 : 0 : nShadows = 0;
1292 : :
1293 [ # # ]: 0 : ++aTopsIt;
1294 : 0 : nRow++;
1295 [ # # ][ # # ]: 0 : }
[ # # ]
1296 : :
1297 : 0 : return pLastNodeInfo;
1298 : : }
1299 : :
1300 : : #ifdef DBG_UTIL
1301 : : ::std::string WW8TableCellGrid::toString()
1302 : : {
1303 : : string sResult = "<WW8TableCellGrid>";
1304 : :
1305 : : RowTops_t::const_iterator aTopsIt = getRowTopsBegin();
1306 : : static char sBuffer[1024];
1307 : : while (aTopsIt != getRowTopsEnd())
1308 : : {
1309 : : sprintf(sBuffer, "<row y=\"%ld\">", *aTopsIt);
1310 : : sResult += sBuffer;
1311 : :
1312 : : CellInfoMultiSet::const_iterator aCellIt = getCellsBegin(*aTopsIt);
1313 : : CellInfoMultiSet::const_iterator aCellsEnd = getCellsEnd(*aTopsIt);
1314 : :
1315 : : while (aCellIt != aCellsEnd)
1316 : : {
1317 : : snprintf(sBuffer, sizeof(sBuffer), "<cellInfo top=\"%ld\" bottom=\"%ld\" left=\"%ld\" right=\"%ld\">",
1318 : : aCellIt->top(), aCellIt->bottom(), aCellIt->left(), aCellIt->right());
1319 : : sResult += sBuffer;
1320 : :
1321 : : WW8TableNodeInfo * pInfo = aCellIt->getTableNodeInfo();
1322 : : if (pInfo != NULL)
1323 : : sResult += pInfo->toString();
1324 : : else
1325 : : sResult += "<shadow/>\n";
1326 : :
1327 : : sResult += "</cellInfo>\n";
1328 : : ++aCellIt;
1329 : : }
1330 : :
1331 : : WW8TableCellGridRow::Pointer_t pRow = getRow(*aTopsIt);
1332 : : WidthsPtr pWidths = pRow->getWidths();
1333 : : if (pWidths != NULL)
1334 : : {
1335 : : sResult += "<widths>";
1336 : :
1337 : : Widths::const_iterator aItEnd = pWidths->end();
1338 : : for (Widths::const_iterator aIt = pWidths->begin();
1339 : : aIt != aItEnd;
1340 : : ++aIt)
1341 : : {
1342 : : if (aIt != pWidths->begin())
1343 : : sResult += ", ";
1344 : :
1345 : : snprintf(sBuffer, sizeof(sBuffer), "%" SAL_PRIxUINT32 "", *aIt);
1346 : : sResult += sBuffer;
1347 : : }
1348 : :
1349 : : sResult += "</widths>";
1350 : : }
1351 : :
1352 : : RowSpansPtr pRowSpans = pRow->getRowSpans();
1353 : : if (pRowSpans.get() != NULL)
1354 : : {
1355 : : sResult += "<rowspans>";
1356 : :
1357 : : RowSpans::const_iterator aItEnd = pRowSpans->end();
1358 : : for (RowSpans::const_iterator aIt = pRowSpans->begin();
1359 : : aIt != aItEnd;
1360 : : ++aIt)
1361 : : {
1362 : : if (aIt != pRowSpans->begin())
1363 : : sResult += ", ";
1364 : :
1365 : : snprintf(sBuffer, sizeof(sBuffer), "%" SAL_PRIxUINT32 "", *aIt);
1366 : : sResult += sBuffer;
1367 : : }
1368 : :
1369 : : sResult += "</rowspans>";
1370 : : }
1371 : :
1372 : : sResult += "</row>\n";
1373 : : ++aTopsIt;
1374 : : }
1375 : :
1376 : : sResult += "</WW8TableCellGrid>\n";
1377 : :
1378 : : return sResult;
1379 : : }
1380 : : #endif
1381 : :
1382 : 0 : TableBoxVectorPtr WW8TableCellGrid::getTableBoxesOfRow
1383 : : (WW8TableNodeInfoInner * pNodeInfoInner)
1384 : : {
1385 [ # # ]: 0 : TableBoxVectorPtr pResult;
1386 : : WW8TableCellGridRow::Pointer_t pRow =
1387 [ # # ]: 0 : getRow(pNodeInfoInner->getRect().Top(), false);
1388 : :
1389 [ # # ]: 0 : if (pRow.get() != NULL)
1390 : : {
1391 [ # # ][ # # ]: 0 : pResult = pRow->getTableBoxVector();
[ # # ]
1392 : : }
1393 : :
1394 [ # # ]: 0 : return pResult;
1395 : : }
1396 : :
1397 : 0 : WidthsPtr WW8TableCellGrid::getWidthsOfRow
1398 : : (WW8TableNodeInfoInner * pNodeInfoInner)
1399 : : {
1400 [ # # ]: 0 : GridColsPtr pResult;
1401 : :
1402 : : WW8TableCellGridRow::Pointer_t pRow =
1403 [ # # ]: 0 : getRow(pNodeInfoInner->getRect().Top(), false);
1404 : :
1405 [ # # ]: 0 : if (pRow.get() != NULL)
1406 : : {
1407 [ # # ][ # # ]: 0 : pResult = pRow->getWidths();
[ # # ]
1408 : : }
1409 : :
1410 [ # # ]: 0 : return pResult;
1411 : : }
1412 : :
1413 : 0 : RowSpansPtr WW8TableCellGrid::getRowSpansOfRow
1414 : : (WW8TableNodeInfoInner * pNodeInfoInner)
1415 : : {
1416 [ # # ]: 0 : RowSpansPtr pResult;
1417 : :
1418 : : WW8TableCellGridRow::Pointer_t pRow =
1419 [ # # ]: 0 : getRow(pNodeInfoInner->getRect().Top(), false);
1420 : :
1421 [ # # ]: 0 : if (pRow.get() != NULL)
1422 : : {
1423 [ # # ][ # # ]: 0 : pResult = pRow->getRowSpans();
[ # # ]
1424 : : }
1425 : :
1426 [ # # ]: 0 : return pResult;
1427 : : }
1428 : :
1429 : 0 : WW8TableCellGridRow::WW8TableCellGridRow()
1430 [ # # ][ # # ]: 0 : : m_pCellInfos(new CellInfoMultiSet)
[ # # ][ # # ]
1431 : : {
1432 : 0 : }
1433 : :
1434 [ # # ][ # # ]: 0 : WW8TableCellGridRow::~WW8TableCellGridRow()
[ # # ]
1435 : : {
1436 : 0 : }
1437 : :
1438 : 0 : void WW8TableCellGridRow::insert(const CellInfo & rCellInfo)
1439 : : {
1440 : 0 : m_pCellInfos->insert(rCellInfo);
1441 : :
1442 : : #ifdef DBG_UTIL
1443 : : ::std::clog << "<gridRowInsert>"
1444 : : << rCellInfo.toString()
1445 : : << "</gridRowInsert>"
1446 : : << ::std::endl;
1447 : : #endif
1448 : 0 : }
1449 : :
1450 : 0 : CellInfoMultiSet::const_iterator WW8TableCellGridRow::begin() const
1451 : : {
1452 : 0 : return m_pCellInfos->begin();
1453 : : }
1454 : :
1455 : 0 : CellInfoMultiSet::const_iterator WW8TableCellGridRow::end() const
1456 : : {
1457 : 0 : return m_pCellInfos->end();
1458 : : }
1459 : :
1460 : 0 : void WW8TableCellGridRow::setTableBoxVector(TableBoxVectorPtr pTableBoxVector)
1461 : : {
1462 : 0 : m_pTableBoxVector = pTableBoxVector;
1463 : 0 : }
1464 : :
1465 : 0 : void WW8TableCellGridRow::setWidths(WidthsPtr pWidths)
1466 : : {
1467 : 0 : m_pWidths = pWidths;
1468 : 0 : }
1469 : :
1470 : 0 : void WW8TableCellGridRow::setRowSpans(RowSpansPtr pRowSpans)
1471 : : {
1472 : 0 : m_pRowSpans = pRowSpans;
1473 : 0 : }
1474 : :
1475 : 0 : TableBoxVectorPtr WW8TableCellGridRow::getTableBoxVector() const
1476 : : {
1477 : 0 : return m_pTableBoxVector;
1478 : : }
1479 : :
1480 : 0 : WidthsPtr WW8TableCellGridRow::getWidths() const
1481 : : {
1482 : 0 : return m_pWidths;
1483 : : }
1484 : :
1485 : 0 : RowSpansPtr WW8TableCellGridRow::getRowSpans() const
1486 : : {
1487 : 0 : return m_pRowSpans;
1488 : : }
1489 : :
1490 : 0 : CellInfo::CellInfo(const SwRect & aRect, WW8TableNodeInfo * pNodeInfo)
1491 : 0 : : m_aRect(aRect), m_pNodeInfo(pNodeInfo), m_nFmtFrmWidth(0)
1492 : : {
1493 [ # # ]: 0 : if (pNodeInfo != NULL)
1494 : : {
1495 : 0 : const SwTableBox * pBox = pNodeInfo->getTableBox();
1496 : 0 : const SwFrmFmt * pFrmFmt = pBox->GetFrmFmt();
1497 : 0 : const SwFmtFrmSize & rSize = pFrmFmt->GetFrmSize();
1498 : :
1499 : 0 : m_nFmtFrmWidth = rSize.GetWidth();
1500 : : }
1501 : 0 : }
1502 : :
1503 [ + - ][ + - ]: 54 : }
1504 : :
1505 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|