Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <com/sun/star/text/XTextTable.hpp>
21 : #include <com/sun/star/text/XTextSection.hpp>
22 :
23 : #include <hintids.hxx>
24 : #include <rtl/ustrbuf.hxx>
25 : #include <xmloff/xmlnmspe.hxx>
26 : #include <xmloff/xmltoken.hxx>
27 : #include <xmloff/xmluconv.hxx>
28 : #include <xmloff/numehelp.hxx>
29 : #include <svl/zforlist.hxx>
30 : #include <editeng/brushitem.hxx>
31 : #include <editeng/boxitem.hxx>
32 : #include <fmtrowsplt.hxx>
33 : #include <editeng/frmdiritem.hxx>
34 : #include <list>
35 : #include "swtable.hxx"
36 : #include "doc.hxx"
37 : #include "pam.hxx"
38 : #include "frmfmt.hxx"
39 : #include "wrtswtbl.hxx"
40 : #include "fmtfsize.hxx"
41 : #include "fmtornt.hxx"
42 : #include "cellatr.hxx"
43 : #include "ddefld.hxx"
44 : #include "swddetbl.hxx"
45 : #include <ndole.hxx>
46 : #include <xmloff/nmspmap.hxx>
47 : #include <sfx2/linkmgr.hxx>
48 : #include "unotbl.hxx"
49 : #include "xmltexte.hxx"
50 : #include "xmlexp.hxx"
51 : #include <boost/foreach.hpp>
52 : #include <o3tl/sorted_vector.hxx>
53 :
54 : using namespace ::com::sun::star;
55 : using namespace ::com::sun::star::uno;
56 : using namespace ::com::sun::star::text;
57 : using namespace ::com::sun::star::beans;
58 : using namespace ::com::sun::star::lang;
59 : using namespace ::com::sun::star::container;
60 : using namespace ::xmloff::token;
61 : using table::XCell;
62 : using ::std::vector;
63 : using ::std::advance;
64 :
65 36 : class SwXMLTableColumn_Impl : public SwWriteTableCol
66 : {
67 : OUString sStyleName;
68 : sal_uInt32 nRelWidth;
69 :
70 : public:
71 :
72 36 : SwXMLTableColumn_Impl( sal_uInt32 nPosition ) :
73 : SwWriteTableCol( nPosition ),
74 36 : nRelWidth( 0UL )
75 36 : {};
76 :
77 8 : void SetStyleName( const OUString& rName ) { sStyleName = rName; }
78 16 : const OUString& GetStyleName() const { return sStyleName; }
79 :
80 8 : void SetRelWidth( sal_uInt32 nSet ) { nRelWidth = nSet; }
81 16 : sal_uInt32 GetRelWidth() const { return nRelWidth; }
82 : };
83 :
84 : struct SwXMLTableColumnCmpWidth_Impl
85 : {
86 8 : bool operator()( SwXMLTableColumn_Impl* const& lhs, SwXMLTableColumn_Impl* const& rhs ) const
87 : {
88 8 : sal_Int32 n = (sal_Int32)lhs->GetWidthOpt() - (sal_Int32)rhs->GetWidthOpt();
89 8 : if( !n )
90 0 : n = (sal_Int32)lhs->GetRelWidth() - (sal_Int32)rhs->GetRelWidth();
91 8 : return n < 0;
92 : }
93 : };
94 :
95 4 : class SwXMLTableColumns_Impl : public o3tl::sorted_vector<SwXMLTableColumn_Impl*, o3tl::less_ptr_to<SwXMLTableColumn_Impl> > {
96 : public:
97 4 : ~SwXMLTableColumns_Impl() { DeleteAndDestroyAll(); }
98 : };
99 :
100 8 : class SwXMLTableColumnsSortByWidth_Impl : public o3tl::sorted_vector<SwXMLTableColumn_Impl*, SwXMLTableColumnCmpWidth_Impl> {};
101 :
102 : class SwXMLTableLines_Impl
103 : {
104 : SwXMLTableColumns_Impl aCols;
105 : const SwTableLines *pLines;
106 : sal_uInt32 nWidth;
107 :
108 : public:
109 :
110 : SwXMLTableLines_Impl( const SwTableLines& rLines );
111 :
112 4 : ~SwXMLTableLines_Impl() {}
113 :
114 12 : sal_uInt32 GetWidth() const { return nWidth; }
115 2 : const SwTableLines *GetLines() const { return pLines; }
116 :
117 54 : const SwXMLTableColumns_Impl& GetColumns() const { return aCols; }
118 : };
119 :
120 4 : SwXMLTableLines_Impl::SwXMLTableLines_Impl( const SwTableLines& rLines ) :
121 : pLines( &rLines ),
122 4 : nWidth( 0UL )
123 : {
124 : #if OSL_DEBUG_LEVEL > 0
125 : sal_uInt32 nEndCPos = 0U;
126 : #endif
127 4 : const size_t nLines = rLines.size();
128 12 : for( size_t nLine=0U; nLine<nLines; ++nLine )
129 : {
130 8 : const SwTableLine *pLine = rLines[nLine];
131 8 : const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
132 8 : const size_t nBoxes = rBoxes.size();
133 :
134 8 : sal_uInt32 nCPos = 0U;
135 24 : for( size_t nBox=0U; nBox<nBoxes; ++nBox )
136 : {
137 16 : const SwTableBox *pBox = rBoxes[nBox];
138 :
139 16 : if( nBox < nBoxes-1U || nWidth==0UL )
140 : {
141 12 : nCPos = nCPos + SwWriteTable::GetBoxWidth( pBox );
142 : SwXMLTableColumn_Impl *pCol =
143 12 : new SwXMLTableColumn_Impl( nCPos );
144 :
145 12 : if( !aCols.insert( pCol ).second )
146 4 : delete pCol;
147 :
148 12 : if( nBox==nBoxes-1U )
149 : {
150 : OSL_ENSURE( nLine==0U && nWidth==0UL,
151 : "parent width will be lost" );
152 4 : nWidth = nCPos;
153 12 : }
154 : }
155 : else
156 : {
157 : #if OSL_DEBUG_LEVEL > 0
158 : sal_uInt32 nCheckPos =
159 : nCPos + SwWriteTable::GetBoxWidth( pBox );
160 : if( !nEndCPos )
161 : {
162 : nEndCPos = nCheckPos;
163 : }
164 : #endif
165 4 : nCPos = nWidth;
166 : #if OSL_DEBUG_LEVEL > 0
167 : SwXMLTableColumn_Impl aCol( nWidth );
168 : OSL_ENSURE( aCols.find(&aCol) != aCols.end(), "couldn't find last column" );
169 : OSL_ENSURE( SwXMLTableColumn_Impl(nCheckPos) ==
170 : SwXMLTableColumn_Impl(nCPos),
171 : "rows have different total widths" );
172 : #endif
173 : }
174 : }
175 : }
176 4 : }
177 :
178 : typedef vector< SwFrmFmt* > SwXMLFrmFmts_Impl;
179 :
180 16 : class SwXMLTableFrmFmtsSort_Impl
181 : {
182 : private:
183 : SwXMLFrmFmts_Impl aFormatList;
184 : public:
185 : bool AddRow( SwFrmFmt& rFrmFmt, const OUString& rNamePrefix, sal_uInt32 nLine );
186 : bool AddCell( SwFrmFmt& rFrmFmt, const OUString& rNamePrefix,
187 : sal_uInt32 nCol, sal_uInt32 nRow, bool bTop );
188 : };
189 :
190 8 : bool SwXMLTableFrmFmtsSort_Impl::AddRow( SwFrmFmt& rFrmFmt,
191 : const OUString& rNamePrefix,
192 : sal_uInt32 nLine )
193 : {
194 8 : const SwFmtFrmSize *pFrmSize = 0;
195 8 : const SwFmtRowSplit* pRowSplit = 0;
196 8 : const SvxBrushItem *pBrush = 0;
197 :
198 8 : const SfxItemSet& rItemSet = rFrmFmt.GetAttrSet();
199 : const SfxPoolItem *pItem;
200 8 : if( SfxItemState::SET == rItemSet.GetItemState( RES_FRM_SIZE, false, &pItem ) )
201 0 : pFrmSize = (const SwFmtFrmSize *)pItem;
202 :
203 8 : if( SfxItemState::SET == rItemSet.GetItemState( RES_ROW_SPLIT, false, &pItem ) )
204 0 : pRowSplit = (const SwFmtRowSplit *)pItem;
205 :
206 8 : if( SfxItemState::SET == rItemSet.GetItemState( RES_BACKGROUND, false, &pItem ) )
207 0 : pBrush = (const SvxBrushItem *)pItem;
208 :
209 : // empty styles have not to be exported
210 8 : if( !pFrmSize && !pBrush && !pRowSplit )
211 8 : return false;
212 :
213 : // order is: -/brush, size/-, size/brush
214 0 : bool bInsert = true;
215 0 : SwXMLFrmFmts_Impl::iterator i;
216 0 : for( i = aFormatList.begin(); i < aFormatList.end(); ++i )
217 : {
218 0 : const SwFmtFrmSize *pTestFrmSize = 0;
219 0 : const SwFmtRowSplit* pTestRowSplit = 0;
220 0 : const SvxBrushItem *pTestBrush = 0;
221 0 : const SwFrmFmt *pTestFmt = *i;
222 0 : const SfxItemSet& rTestSet = pTestFmt->GetAttrSet();
223 0 : if( SfxItemState::SET == rTestSet.GetItemState( RES_FRM_SIZE, false,
224 0 : &pItem ) )
225 : {
226 0 : if( !pFrmSize )
227 0 : break;
228 :
229 0 : pTestFrmSize = (const SwFmtFrmSize *)pItem;
230 : }
231 : else
232 : {
233 0 : if( pFrmSize )
234 0 : continue;
235 : }
236 :
237 0 : if( SfxItemState::SET == rTestSet.GetItemState( RES_BACKGROUND, false,
238 0 : &pItem ) )
239 : {
240 0 : if( !pBrush )
241 0 : break;
242 :
243 0 : pTestBrush = (const SvxBrushItem *)pItem;
244 : }
245 : else
246 : {
247 0 : if( pBrush )
248 0 : continue;
249 : }
250 :
251 0 : if( SfxItemState::SET == rTestSet.GetItemState( RES_ROW_SPLIT, false,
252 0 : &pItem ) )
253 : {
254 0 : if( !pRowSplit )
255 0 : break;
256 :
257 0 : pTestRowSplit = (const SwFmtRowSplit *)pItem;
258 : }
259 : else
260 : {
261 0 : if( pRowSplit )
262 0 : continue;
263 : }
264 :
265 0 : if( pFrmSize &&
266 0 : ( pFrmSize->GetHeightSizeType() != pTestFrmSize->GetHeightSizeType() ||
267 0 : pFrmSize->GetHeight() != pTestFrmSize->GetHeight() ) )
268 0 : continue;
269 :
270 0 : if( pBrush && (*pBrush != *pTestBrush) )
271 0 : continue;
272 :
273 0 : if( pRowSplit && (!pRowSplit->GetValue() != !pTestRowSplit->GetValue()) )
274 0 : continue;
275 :
276 : // found!
277 0 : rFrmFmt.SetName( pTestFmt->GetName() );
278 0 : bInsert = false;
279 0 : break;
280 : }
281 :
282 0 : if( bInsert )
283 : {
284 0 : rFrmFmt.SetName( rNamePrefix + "." + OUString::number(nLine+1UL) );
285 0 : if ( i != aFormatList.end() ) ++i;
286 0 : aFormatList.insert( i, &rFrmFmt );
287 : }
288 :
289 0 : return bInsert;
290 : }
291 :
292 16 : static OUString lcl_xmltble_appendBoxPrefix(const OUString& rNamePrefix,
293 : sal_uInt32 nCol, sal_uInt32 nRow, bool bTop )
294 : {
295 16 : if( bTop )
296 : {
297 16 : OUString sTmp;
298 16 : sw_GetTblBoxColStr( (sal_uInt16)nCol, sTmp );
299 16 : return rNamePrefix + "." + sTmp + OUString::number(nRow + 1);
300 : }
301 : return rNamePrefix
302 0 : + "." + OUString::number(nCol + 1)
303 0 : + "." + OUString::number(nRow + 1);
304 : }
305 :
306 16 : bool SwXMLTableFrmFmtsSort_Impl::AddCell( SwFrmFmt& rFrmFmt,
307 : const OUString& rNamePrefix,
308 : sal_uInt32 nCol, sal_uInt32 nRow, bool bTop )
309 : {
310 16 : const SwFmtVertOrient *pVertOrient = 0;
311 16 : const SvxBrushItem *pBrush = 0;
312 16 : const SvxBoxItem *pBox = 0;
313 16 : const SwTblBoxNumFormat *pNumFmt = 0;
314 16 : const SvxFrameDirectionItem *pFrameDir = 0;
315 :
316 16 : const SfxItemSet& rItemSet = rFrmFmt.GetAttrSet();
317 : const SfxPoolItem *pItem;
318 16 : if( SfxItemState::SET == rItemSet.GetItemState( RES_VERT_ORIENT, false,
319 16 : &pItem ) )
320 0 : pVertOrient = (const SwFmtVertOrient *)pItem;
321 :
322 16 : if( SfxItemState::SET == rItemSet.GetItemState( RES_BACKGROUND, false, &pItem ) )
323 0 : pBrush = (const SvxBrushItem *)pItem;
324 :
325 16 : if( SfxItemState::SET == rItemSet.GetItemState( RES_BOX, false, &pItem ) )
326 16 : pBox = (const SvxBoxItem *)pItem;
327 :
328 16 : if ( SfxItemState::SET == rItemSet.GetItemState( RES_BOXATR_FORMAT,
329 16 : false, &pItem ) )
330 0 : pNumFmt = (const SwTblBoxNumFormat *)pItem;
331 16 : if ( SfxItemState::SET == rItemSet.GetItemState( RES_FRAMEDIR,
332 16 : false, &pItem ) )
333 0 : pFrameDir = (const SvxFrameDirectionItem *)pItem;
334 :
335 : // empty styles have not to be exported
336 16 : if( !pVertOrient && !pBrush && !pBox && !pNumFmt && !pFrameDir )
337 0 : return false;
338 :
339 : // order is: -/-/-/num,
340 : // -/-/box/-, --/-/box/num,
341 : // -/brush/-/-, -/brush/-/num, -/brush/box/-, -/brush/box/num,
342 : // vert/-/-/-, vert/-/-/num, vert/-/box/-, ver/-/box/num,
343 : // vert/brush/-/-, vert/brush/-/num, vert/brush/box/-,
344 : // vert/brush/box/num
345 16 : bool bInsert = true;
346 16 : SwXMLFrmFmts_Impl::iterator i;
347 40 : for( i = aFormatList.begin(); i < aFormatList.end(); ++i )
348 : {
349 24 : const SwFmtVertOrient *pTestVertOrient = 0;
350 24 : const SvxBrushItem *pTestBrush = 0;
351 24 : const SvxBoxItem *pTestBox = 0;
352 24 : const SwTblBoxNumFormat *pTestNumFmt = 0;
353 24 : const SvxFrameDirectionItem *pTestFrameDir = 0;
354 24 : const SwFrmFmt* pTestFmt = *i;
355 24 : const SfxItemSet& rTestSet = pTestFmt->GetAttrSet();
356 24 : if( SfxItemState::SET == rTestSet.GetItemState( RES_VERT_ORIENT, false,
357 24 : &pItem ) )
358 : {
359 0 : if( !pVertOrient )
360 0 : break;
361 :
362 0 : pTestVertOrient = (const SwFmtVertOrient *)pItem;
363 : }
364 : else
365 : {
366 24 : if( pVertOrient )
367 0 : continue;
368 : }
369 :
370 24 : if( SfxItemState::SET == rTestSet.GetItemState( RES_BACKGROUND, false,
371 24 : &pItem ) )
372 : {
373 0 : if( !pBrush )
374 0 : break;
375 :
376 0 : pTestBrush = (const SvxBrushItem *)pItem;
377 : }
378 : else
379 : {
380 24 : if( pBrush )
381 0 : continue;
382 : }
383 :
384 24 : if( SfxItemState::SET == rTestSet.GetItemState( RES_BOX, false, &pItem ) )
385 : {
386 24 : if( !pBox )
387 0 : break;
388 :
389 24 : pTestBox = (const SvxBoxItem *)pItem;
390 : }
391 : else
392 : {
393 0 : if( pBox )
394 0 : continue;
395 : }
396 :
397 24 : if ( SfxItemState::SET == rTestSet.GetItemState( RES_BOXATR_FORMAT,
398 24 : false, &pItem ) )
399 : {
400 0 : if( !pNumFmt )
401 0 : break;
402 :
403 0 : pTestNumFmt = (const SwTblBoxNumFormat *)pItem;
404 : }
405 : else
406 : {
407 24 : if( pNumFmt )
408 0 : continue;
409 :
410 : }
411 :
412 24 : if ( SfxItemState::SET == rTestSet.GetItemState( RES_FRAMEDIR,
413 24 : false, &pItem ) )
414 : {
415 0 : if( !pFrameDir )
416 0 : break;
417 :
418 0 : pTestFrameDir = (const SvxFrameDirectionItem *)pItem;
419 : }
420 : else
421 : {
422 24 : if( pFrameDir )
423 0 : continue;
424 :
425 : }
426 :
427 24 : if( pVertOrient &&
428 0 : pVertOrient->GetVertOrient() != pTestVertOrient->GetVertOrient() )
429 0 : continue;
430 :
431 24 : if( pBrush && ( *pBrush != *pTestBrush ) )
432 0 : continue;
433 :
434 24 : if( pBox && ( *pBox != *pTestBox ) )
435 24 : continue;
436 :
437 0 : if( pNumFmt && pNumFmt->GetValue() != pTestNumFmt->GetValue() )
438 0 : continue;
439 :
440 0 : if( pFrameDir && pFrameDir->GetValue() != pTestFrameDir->GetValue() )
441 0 : continue;
442 :
443 : // found!
444 0 : rFrmFmt.SetName( pTestFmt->GetName() );
445 0 : bInsert = false;
446 0 : break;
447 : }
448 :
449 16 : if( bInsert )
450 : {
451 16 : rFrmFmt.SetName( lcl_xmltble_appendBoxPrefix( rNamePrefix, nCol, nRow, bTop ) );
452 16 : if ( i != aFormatList.end() ) ++i;
453 16 : aFormatList.insert( i, &rFrmFmt );
454 : }
455 :
456 16 : return bInsert;
457 : }
458 :
459 6 : class SwXMLTableInfo_Impl
460 : {
461 : const SwTable *pTable;
462 : Reference < XTextSection > xBaseSection;
463 : bool bBaseSectionValid;
464 :
465 : public:
466 :
467 : inline SwXMLTableInfo_Impl( const SwTable *pTbl );
468 :
469 24 : const SwTable *GetTable() const { return pTable; }
470 24 : const SwFrmFmt *GetTblFmt() const { return pTable->GetFrmFmt(); }
471 :
472 24 : bool IsBaseSectionValid() const { return bBaseSectionValid; }
473 8 : const Reference < XTextSection >& GetBaseSection() const { return xBaseSection; }
474 : inline void SetBaseSection( const Reference < XTextSection >& rBase );
475 : };
476 :
477 6 : inline SwXMLTableInfo_Impl::SwXMLTableInfo_Impl( const SwTable *pTbl ) :
478 : pTable( pTbl ),
479 6 : bBaseSectionValid( false )
480 : {
481 6 : }
482 :
483 6 : inline void SwXMLTableInfo_Impl::SetBaseSection(
484 : const Reference < XTextSection >& rBaseSection )
485 : {
486 6 : xBaseSection = rBaseSection;
487 6 : bBaseSectionValid = true;
488 6 : }
489 :
490 8 : void SwXMLExport::ExportTableColumnStyle( const SwXMLTableColumn_Impl& rCol )
491 : {
492 : // <style:style ...>
493 8 : CheckAttrList();
494 :
495 : // style:name="..."
496 8 : bool bEncoded = false;
497 : AddAttribute( XML_NAMESPACE_STYLE, XML_NAME,
498 8 : EncodeStyleName( rCol.GetStyleName(), &bEncoded ) );
499 8 : if( bEncoded )
500 0 : AddAttribute( XML_NAMESPACE_STYLE, XML_DISPLAY_NAME, rCol.GetStyleName() );
501 :
502 : // style:family="table-column"
503 8 : AddAttribute( XML_NAMESPACE_STYLE, XML_FAMILY, XML_TABLE_COLUMN );
504 :
505 : {
506 : SvXMLElementExport aElem( *this, XML_NAMESPACE_STYLE, XML_STYLE, true,
507 8 : true );
508 16 : OUStringBuffer sValue;
509 8 : if( rCol.GetWidthOpt() )
510 : {
511 8 : GetTwipUnitConverter().convertMeasureToXML( sValue,
512 16 : rCol.GetWidthOpt() );
513 : AddAttribute( XML_NAMESPACE_STYLE, XML_COLUMN_WIDTH,
514 8 : sValue.makeStringAndClear() );
515 : }
516 8 : if( rCol.GetRelWidth() )
517 : {
518 8 : sValue.append( (sal_Int32)rCol.GetRelWidth() );
519 8 : sValue.append( '*' );
520 : AddAttribute( XML_NAMESPACE_STYLE, XML_REL_COLUMN_WIDTH,
521 8 : sValue.makeStringAndClear() );
522 : }
523 :
524 : {
525 : SvXMLElementExport aElemExport( *this, XML_NAMESPACE_STYLE,
526 : XML_TABLE_COLUMN_PROPERTIES,
527 8 : true, true );
528 8 : }
529 : }
530 8 : }
531 :
532 4 : void SwXMLExport::ExportTableLinesAutoStyles( const SwTableLines& rLines,
533 : sal_uInt32 nAbsWidth, sal_uInt32 nBaseWidth,
534 : const OUString& rNamePrefix,
535 : SwXMLTableColumnsSortByWidth_Impl& rExpCols,
536 : SwXMLTableFrmFmtsSort_Impl& rExpRows,
537 : SwXMLTableFrmFmtsSort_Impl& rExpCells,
538 : SwXMLTableInfo_Impl& rTblInfo,
539 : bool bTop )
540 : {
541 : // pass 1: calculate columns
542 4 : SwXMLTableLines_Impl *pLines = new SwXMLTableLines_Impl( rLines );
543 4 : if( !pTableLines )
544 2 : pTableLines = new SwXMLTableLinesCache_Impl();
545 :
546 4 : pTableLines->push_back( pLines );
547 :
548 : // pass 2: export column styles
549 : {
550 4 : const SwXMLTableColumns_Impl& rCols = pLines->GetColumns();
551 4 : sal_uInt32 nCPos = 0U;
552 4 : const size_t nColumns = rCols.size();
553 12 : for( size_t nColumn=0U; nColumn<nColumns; ++nColumn )
554 : {
555 8 : SwXMLTableColumn_Impl *pColumn = rCols[nColumn];
556 :
557 8 : sal_uInt32 nOldCPos = nCPos;
558 8 : nCPos = pColumn->GetPos();
559 :
560 8 : sal_uInt32 nWidth = nCPos - nOldCPos;
561 :
562 : // If a base width is given, the table has either an automatic
563 : // or margin alignment, or an percentage width. In either case,
564 : // relative widths should be exported.
565 8 : if( nBaseWidth )
566 : {
567 8 : pColumn->SetRelWidth( nWidth );
568 : }
569 :
570 : // If an absolute width is given, the table either has a fixed
571 : // width, or the current width is known from the layout. In the
572 : // later case, a base width is set in addition and must be used
573 : // to "absoultize" the relative column width.
574 8 : if( nAbsWidth )
575 : {
576 8 : sal_uInt32 nColAbsWidth = nWidth;
577 8 : if( nBaseWidth )
578 : {
579 8 : nColAbsWidth *= nAbsWidth;
580 8 : nColAbsWidth += (nBaseWidth/2UL);
581 8 : nColAbsWidth /= nBaseWidth;
582 : }
583 8 : pColumn->SetWidthOpt( nColAbsWidth, false );
584 : }
585 :
586 8 : SwXMLTableColumnsSortByWidth_Impl::const_iterator it = rExpCols.find( pColumn );
587 8 : if( it != rExpCols.end() )
588 : {
589 0 : pColumn->SetStyleName( (*it)->GetStyleName() );
590 : }
591 : else
592 : {
593 8 : if( bTop )
594 : {
595 8 : OUString sTmp;
596 8 : sw_GetTblBoxColStr( nColumn, sTmp );
597 8 : pColumn->SetStyleName( rNamePrefix + "." + sTmp );
598 : }
599 : else
600 : {
601 0 : pColumn->SetStyleName( rNamePrefix + "." + OUString::number(nColumn + 1U) );
602 : }
603 8 : ExportTableColumnStyle( *pColumn );
604 8 : rExpCols.insert( pColumn );
605 : }
606 : }
607 : }
608 :
609 : // pass 3: export line/rows
610 4 : const size_t nLines = rLines.size();
611 12 : for( size_t nLine=0U; nLine<nLines; ++nLine )
612 : {
613 8 : SwTableLine *pLine = rLines[nLine];
614 :
615 8 : SwFrmFmt *pFrmFmt = pLine->GetFrmFmt();
616 8 : if( rExpRows.AddRow( *pFrmFmt, rNamePrefix, nLine ) )
617 0 : ExportFmt( *pFrmFmt, XML_TABLE_ROW );
618 :
619 8 : const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
620 8 : const size_t nBoxes = rBoxes.size();
621 :
622 8 : sal_uInt32 nCPos = 0U;
623 8 : size_t nCol = 0U;
624 24 : for( size_t nBox=0U; nBox<nBoxes; nBox++ )
625 : {
626 16 : SwTableBox *pBox = rBoxes[nBox];
627 :
628 16 : if( nBox < nBoxes-1U )
629 8 : nCPos = nCPos + SwWriteTable::GetBoxWidth( pBox );
630 : else
631 8 : nCPos = pLines->GetWidth();
632 :
633 : // Und ihren Index
634 16 : const size_t nOldCol = nCol;
635 16 : SwXMLTableColumn_Impl aCol( nCPos );
636 16 : SwXMLTableColumns_Impl::const_iterator it = pLines->GetColumns().find( &aCol );
637 : OSL_ENSURE( it != pLines->GetColumns().end(), "couldn't find column" );
638 16 : nCol = it - pLines->GetColumns().begin();
639 :
640 16 : const SwStartNode *pBoxSttNd = pBox->GetSttNd();
641 16 : if( pBoxSttNd )
642 : {
643 16 : SwFrmFmt *pFrmFmt2 = pBox->GetFrmFmt();
644 16 : if( rExpCells.AddCell( *pFrmFmt2, rNamePrefix, nOldCol, nLine,
645 16 : bTop) )
646 16 : ExportFmt( *pFrmFmt2, XML_TABLE_CELL );
647 :
648 : Reference < XCell > xCell = SwXCell::CreateXCell(
649 16 : (SwFrmFmt *)rTblInfo.GetTblFmt(),
650 : pBox,
651 32 : (SwTable *)rTblInfo.GetTable() );
652 16 : if (xCell.is())
653 : {
654 16 : Reference < XText > xText( xCell, UNO_QUERY );
655 16 : if( !rTblInfo.IsBaseSectionValid() )
656 : {
657 : Reference<XPropertySet> xCellPropertySet( xCell,
658 4 : UNO_QUERY );
659 8 : Any aAny = xCellPropertySet->getPropertyValue("TextSection");
660 8 : Reference < XTextSection > xTextSection;
661 4 : aAny >>= xTextSection;
662 8 : rTblInfo.SetBaseSection( xTextSection );
663 : }
664 :
665 16 : const bool bExportContent = (getExportFlags() & EXPORT_CONTENT ) != 0;
666 16 : if ( !bExportContent )
667 : {
668 : // AUTOSTYLES - not needed anymore if we are currently exporting content.xml
669 : GetTextParagraphExport()->collectTextAutoStyles(
670 0 : xText, rTblInfo.GetBaseSection(), IsShowProgress() );
671 16 : }
672 : }
673 : else {
674 : OSL_FAIL("here should be a XCell");
675 16 : }
676 : }
677 : else
678 : {
679 0 : ExportTableLinesAutoStyles( pBox->GetTabLines(),
680 : nAbsWidth, nBaseWidth,
681 : lcl_xmltble_appendBoxPrefix( rNamePrefix,
682 : nOldCol, nLine, bTop ),
683 : rExpCols, rExpRows, rExpCells,
684 0 : rTblInfo );
685 : }
686 :
687 16 : nCol++;
688 16 : }
689 : }
690 4 : }
691 :
692 4 : void SwXMLExport::ExportTableAutoStyles( const SwTableNode& rTblNd )
693 : {
694 4 : const SwTable& rTbl = rTblNd.GetTable();
695 4 : const SwFrmFmt *pTblFmt = rTbl.GetFrmFmt();
696 :
697 4 : if( pTblFmt )
698 : {
699 4 : sal_Int16 eTabHoriOri = pTblFmt->GetHoriOrient().GetHoriOrient();
700 4 : const SwFmtFrmSize& rFrmSize = pTblFmt->GetFrmSize();
701 :
702 4 : sal_uInt32 nAbsWidth = rFrmSize.GetSize().Width();
703 4 : sal_uInt32 nBaseWidth = 0UL;
704 4 : sal_Int8 nPrcWidth = rFrmSize.GetWidthPercent();
705 :
706 4 : bool bFixAbsWidth = nPrcWidth != 0 || /*text::*/HoriOrientation::NONE == eTabHoriOri
707 8 : || /*text::*/HoriOrientation::FULL == eTabHoriOri;
708 4 : if( bFixAbsWidth )
709 : {
710 4 : nBaseWidth = nAbsWidth;
711 4 : nAbsWidth = pTblFmt->FindLayoutRect(true).Width();
712 : if( !nAbsWidth )
713 : {
714 : // TODO?
715 : }
716 : }
717 4 : ExportTableFmt( *pTblFmt, nAbsWidth );
718 :
719 4 : SwXMLTableColumnsSortByWidth_Impl aExpCols;
720 8 : SwXMLTableFrmFmtsSort_Impl aExpRows;
721 8 : SwXMLTableFrmFmtsSort_Impl aExpCells;
722 8 : SwXMLTableInfo_Impl aTblInfo( &rTbl );
723 4 : ExportTableLinesAutoStyles( rTbl.GetTabLines(), nAbsWidth, nBaseWidth,
724 : pTblFmt->GetName(), aExpCols, aExpRows, aExpCells,
725 12 : aTblInfo, true);
726 : }
727 4 : }
728 :
729 8 : void SwXMLExport::ExportTableBox( const SwTableBox& rBox,
730 : sal_uInt32 nColSpan,
731 : sal_uInt32 nRowSpan,
732 : SwXMLTableInfo_Impl& rTblInfo )
733 : {
734 8 : const SwStartNode *pBoxSttNd = rBox.GetSttNd();
735 8 : if( pBoxSttNd )
736 : {
737 8 : const SwFrmFmt *pFrmFmt = rBox.GetFrmFmt();
738 8 : if( pFrmFmt )
739 : {
740 8 : const OUString sName = pFrmFmt->GetName();
741 8 : if( !sName.isEmpty() )
742 : {
743 8 : AddAttribute( XML_NAMESPACE_TABLE, XML_STYLE_NAME, EncodeStyleName(sName) );
744 8 : }
745 : }
746 : }
747 :
748 8 : if( nRowSpan != 1 )
749 : {
750 : AddAttribute( XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_SPANNED,
751 0 : OUString::number(nRowSpan) );
752 : }
753 :
754 8 : if( nColSpan != 1 )
755 : {
756 : AddAttribute( XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_SPANNED,
757 0 : OUString::number(nColSpan) );
758 : }
759 :
760 : {
761 8 : if( pBoxSttNd )
762 : {
763 : // start node -> normal cell
764 : // get cell range for table
765 8 : Reference<XCell> xCell = SwXCell::CreateXCell( (SwFrmFmt *)rTblInfo.GetTblFmt(),
766 : (SwTableBox *)&rBox,
767 16 : (SwTable *)rTblInfo.GetTable() );
768 :
769 8 : if (xCell.is())
770 : {
771 8 : Reference<XText> xText( xCell, UNO_QUERY );
772 :
773 : // get formula (and protection)
774 16 : const OUString sCellFormula = xCell->getFormula();
775 :
776 : // if this cell has a formula, export it
777 : // (with value and number format)
778 8 : if (!sCellFormula.isEmpty())
779 : {
780 : const OUString sQValue =
781 0 : GetNamespaceMap().GetQNameByKey(
782 0 : XML_NAMESPACE_OOOW, sCellFormula, false );
783 : // formula
784 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_FORMULA, sQValue );
785 : }
786 :
787 : // value and format (if NumberFormat != -1)
788 : Reference<XPropertySet> xCellPropertySet(xCell,
789 16 : UNO_QUERY);
790 8 : if (xCellPropertySet.is())
791 : {
792 8 : sal_Int32 nNumberFormat = 0;
793 8 : Any aAny = xCellPropertySet->getPropertyValue(sNumberFormat);
794 8 : aAny >>= nNumberFormat;
795 :
796 8 : if (NUMBERFORMAT_TEXT == nNumberFormat)
797 : {
798 : // text format
799 : AddAttribute( XML_NAMESPACE_OFFICE,
800 8 : XML_VALUE_TYPE, XML_STRING );
801 : }
802 0 : else if ( (-1 != nNumberFormat) && !xText->getString().isEmpty() )
803 : {
804 : // number format key:
805 : // (export values only if cell contains text;)
806 : XMLNumberFormatAttributesExportHelper::
807 : SetNumberFormatAttributes(
808 0 : *this, nNumberFormat, xCell->getValue(),
809 0 : true );
810 : }
811 : // else: invalid key; ignore
812 :
813 : // cell protection
814 8 : aAny = xCellPropertySet->getPropertyValue(sIsProtected);
815 8 : if (*(sal_Bool*)aAny.getValue())
816 : {
817 : AddAttribute( XML_NAMESPACE_TABLE, XML_PROTECTED,
818 0 : XML_TRUE );
819 : }
820 :
821 8 : if( !rTblInfo.IsBaseSectionValid() )
822 : {
823 2 : aAny = xCellPropertySet->getPropertyValue("TextSection");
824 2 : Reference < XTextSection > xTextSection;
825 2 : aAny >>= xTextSection;
826 2 : rTblInfo.SetBaseSection( xTextSection );
827 8 : }
828 : }
829 :
830 : // export cell element
831 : SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
832 16 : XML_TABLE_CELL, true, true );
833 :
834 : // export cell content
835 : GetTextParagraphExport()->exportText( xText,
836 8 : rTblInfo.GetBaseSection(),
837 24 : IsShowProgress() );
838 : }
839 : else
840 : {
841 : OSL_FAIL("here should be a XCell");
842 0 : ClearAttrList();
843 8 : }
844 : }
845 : else
846 : {
847 : // no start node -> merged cells: export subtable in cell
848 : SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
849 0 : XML_TABLE_CELL, true, true );
850 : {
851 : AddAttribute( XML_NAMESPACE_TABLE, XML_IS_SUB_TABLE,
852 0 : GetXMLToken( XML_TRUE ) );
853 :
854 : SvXMLElementExport aElemExport( *this, XML_NAMESPACE_TABLE,
855 0 : XML_TABLE, true, true );
856 0 : ExportTableLines( rBox.GetTabLines(), rTblInfo );
857 0 : }
858 : }
859 : }
860 8 : }
861 :
862 4 : void SwXMLExport::ExportTableLine( const SwTableLine& rLine,
863 : const SwXMLTableLines_Impl& rLines,
864 : SwXMLTableInfo_Impl& rTblInfo )
865 : {
866 4 : if( rLine.hasSoftPageBreak() )
867 : {
868 : SvXMLElementExport aElem( *this, XML_NAMESPACE_TEXT,
869 0 : XML_SOFT_PAGE_BREAK, true, true );
870 : }
871 4 : const SwFrmFmt *pFrmFmt = rLine.GetFrmFmt();
872 4 : if( pFrmFmt )
873 : {
874 4 : const OUString sName = pFrmFmt->GetName();
875 4 : if( !sName.isEmpty() )
876 : {
877 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_STYLE_NAME, EncodeStyleName(sName) );
878 4 : }
879 : }
880 :
881 : {
882 : SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
883 4 : XML_TABLE_ROW, true, true );
884 4 : const SwTableBoxes& rBoxes = rLine.GetTabBoxes();
885 4 : const size_t nBoxes = rBoxes.size();
886 :
887 4 : sal_uInt32 nCPos = 0U;
888 4 : size_t nCol = 0U;
889 12 : for( size_t nBox=0U; nBox<nBoxes; ++nBox )
890 : {
891 8 : const SwTableBox *pBox = rBoxes[nBox];
892 :
893 : // NEW TABLES
894 8 : const long nRowSpan = pBox->getRowSpan();
895 8 : if( nRowSpan < 1 )
896 : {
897 : SvXMLElementExport aElem2( *this, XML_NAMESPACE_TABLE,
898 : XML_COVERED_TABLE_CELL, true,
899 0 : false );
900 : }
901 :
902 8 : if( nBox < nBoxes-1U )
903 4 : nCPos = nCPos + SwWriteTable::GetBoxWidth( pBox );
904 : else
905 4 : nCPos = rLines.GetWidth();
906 :
907 : // Und ihren Index
908 8 : const size_t nOldCol = nCol;
909 8 : SwXMLTableColumn_Impl aCol( nCPos );
910 8 : SwXMLTableColumns_Impl::const_iterator it = rLines.GetColumns().find( &aCol );
911 : OSL_ENSURE( it != rLines.GetColumns().end(), "couldn't find column" );
912 8 : nCol = it - rLines.GetColumns().begin();
913 :
914 : // #i95726# - Some fault tolerance, if table is somehow corrupted.
915 8 : if ( nCol < nOldCol )
916 : {
917 : OSL_FAIL( "table and/or table information seems to be corrupted." );
918 : // NOTE: nOldCol is not necessarily a valid index into
919 : // GetColumns(), but that doesn't matter here
920 0 : nCol = nOldCol;
921 : }
922 :
923 8 : const sal_uInt32 nColSpan = nCol - nOldCol + 1U;
924 :
925 8 : if ( nRowSpan >= 1 )
926 8 : ExportTableBox( *pBox, nColSpan, static_cast< sal_uInt32 >(nRowSpan), rTblInfo );
927 :
928 8 : for( size_t i=nOldCol; i<nCol; ++i )
929 : {
930 : SvXMLElementExport aElemExport( *this, XML_NAMESPACE_TABLE,
931 : XML_COVERED_TABLE_CELL, true,
932 0 : false );
933 0 : }
934 :
935 8 : nCol++;
936 12 : }
937 : }
938 4 : }
939 :
940 2 : void SwXMLExport::ExportTableLines( const SwTableLines& rLines,
941 : SwXMLTableInfo_Impl& rTblInfo,
942 : sal_uInt32 nHeaderRows )
943 : {
944 : OSL_ENSURE( pTableLines && !pTableLines->empty(),
945 : "SwXMLExport::ExportTableLines: table columns infos missing" );
946 2 : if( !pTableLines || pTableLines->empty() )
947 0 : return;
948 :
949 2 : SwXMLTableLines_Impl* pLines = NULL;
950 : size_t nInfoPos;
951 2 : for( nInfoPos=0; nInfoPos < pTableLines->size(); nInfoPos++ )
952 : {
953 2 : if( pTableLines->at( nInfoPos )->GetLines() == &rLines )
954 : {
955 2 : pLines = pTableLines->at( nInfoPos );
956 2 : break;
957 : }
958 : }
959 : OSL_ENSURE( pLines,
960 : "SwXMLExport::ExportTableLines: table columns info missing" );
961 : OSL_ENSURE( 0==nInfoPos,
962 : "SwXMLExport::ExportTableLines: table columns infos are unsorted" );
963 2 : if( !pLines )
964 0 : return;
965 :
966 2 : SwXMLTableLinesCache_Impl::iterator it = pTableLines->begin();
967 2 : advance( it, nInfoPos );
968 2 : pTableLines->erase( it );
969 :
970 2 : if( pTableLines->empty() )
971 : {
972 0 : delete pTableLines ;
973 0 : pTableLines = NULL;
974 : }
975 :
976 : // pass 2: export columns
977 2 : const SwXMLTableColumns_Impl& rCols = pLines->GetColumns();
978 2 : size_t nColumn = 0U;
979 2 : const size_t nColumns = rCols.size();
980 2 : sal_Int32 nColRep = 1;
981 2 : SwXMLTableColumn_Impl *pColumn = (nColumns > 0) ? rCols[0U] : 0;
982 8 : while( pColumn )
983 : {
984 4 : nColumn++;
985 : SwXMLTableColumn_Impl *pNextColumn =
986 4 : (nColumn < nColumns) ? rCols[nColumn] : 0;
987 6 : if( pNextColumn &&
988 2 : pNextColumn->GetStyleName() == pColumn->GetStyleName() )
989 : {
990 0 : nColRep++;
991 : }
992 : else
993 : {
994 : AddAttribute( XML_NAMESPACE_TABLE, XML_STYLE_NAME,
995 4 : EncodeStyleName(pColumn->GetStyleName()) );
996 :
997 4 : if( nColRep > 1 )
998 : {
999 : AddAttribute( XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED,
1000 0 : OUString::number(nColRep) );
1001 : }
1002 :
1003 : {
1004 : SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
1005 4 : XML_TABLE_COLUMN, true, true );
1006 : }
1007 :
1008 4 : nColRep = 1;
1009 : }
1010 4 : pColumn = pNextColumn;
1011 : }
1012 :
1013 : // pass 3: export line/rows
1014 2 : const size_t nLines = rLines.size();
1015 : // export header rows, if present
1016 2 : if( nHeaderRows > 0 )
1017 : {
1018 : SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
1019 0 : XML_TABLE_HEADER_ROWS, true, true );
1020 :
1021 : OSL_ENSURE( nHeaderRows <= nLines, "more headers then lines?" );
1022 0 : for( size_t nLine = 0U; nLine < nHeaderRows; ++nLine )
1023 0 : ExportTableLine( *(rLines[nLine]), *pLines, rTblInfo );
1024 : }
1025 : // export remaining rows
1026 6 : for( size_t nLine = nHeaderRows; nLine < nLines; ++nLine )
1027 : {
1028 4 : ExportTableLine( *(rLines[nLine]), *pLines, rTblInfo );
1029 : }
1030 :
1031 2 : delete pLines;
1032 : }
1033 :
1034 : static void lcl_xmltble_ClearName_Line( SwTableLine* pLine );
1035 :
1036 8 : static void lcl_xmltble_ClearName_Box( SwTableBox* pBox )
1037 : {
1038 8 : if( !pBox->GetSttNd() )
1039 : {
1040 0 : BOOST_FOREACH( SwTableLine* pLine, pBox->GetTabLines() )
1041 0 : lcl_xmltble_ClearName_Line( pLine );
1042 : }
1043 : else
1044 : {
1045 8 : SwFrmFmt *pFrmFmt = pBox->GetFrmFmt();
1046 8 : if( pFrmFmt && !pFrmFmt->GetName().isEmpty() )
1047 8 : pFrmFmt->SetName( OUString() );
1048 : }
1049 8 : }
1050 :
1051 4 : void lcl_xmltble_ClearName_Line( SwTableLine* pLine )
1052 : {
1053 12 : BOOST_FOREACH( SwTableBox* pBox, pLine->GetTabBoxes() )
1054 8 : lcl_xmltble_ClearName_Box( pBox );
1055 4 : }
1056 :
1057 2 : void SwXMLExport::ExportTable( const SwTableNode& rTblNd )
1058 : {
1059 2 : const SwTable& rTbl = rTblNd.GetTable();
1060 2 : const SwFrmFmt *pTblFmt = rTbl.GetFrmFmt();
1061 2 : if( pTblFmt && !pTblFmt->GetName().isEmpty() )
1062 : {
1063 2 : AddAttribute( XML_NAMESPACE_TABLE, XML_NAME, pTblFmt->GetName() );
1064 : AddAttribute( XML_NAMESPACE_TABLE, XML_STYLE_NAME,
1065 2 : EncodeStyleName( pTblFmt->GetName() ) );
1066 : }
1067 :
1068 : {
1069 : SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, XML_TABLE,
1070 2 : true, true );
1071 :
1072 : // export DDE source (if this is a DDE table)
1073 2 : if ( rTbl.ISA(SwDDETable) )
1074 : {
1075 : // get DDE Field Type (contains the DDE connection)
1076 : const SwDDEFieldType* pDDEFldType =
1077 0 : ((SwDDETable&)rTbl).GetDDEFldType();
1078 :
1079 : // connection name
1080 : AddAttribute( XML_NAMESPACE_OFFICE, XML_NAME,
1081 0 : pDDEFldType->GetName() );
1082 :
1083 : // DDE command
1084 0 : const OUString sCmd = pDDEFldType->GetCmd();
1085 : AddAttribute( XML_NAMESPACE_OFFICE, XML_DDE_APPLICATION,
1086 0 : sCmd.getToken(0, sfx2::cTokenSeparator) );
1087 : AddAttribute( XML_NAMESPACE_OFFICE, XML_DDE_ITEM,
1088 0 : sCmd.getToken(1, sfx2::cTokenSeparator) );
1089 : AddAttribute( XML_NAMESPACE_OFFICE, XML_DDE_TOPIC,
1090 0 : sCmd.getToken(2, sfx2::cTokenSeparator) );
1091 :
1092 : // auto update
1093 0 : if (pDDEFldType->GetType() == sfx2::LINKUPDATE_ALWAYS)
1094 : {
1095 : AddAttribute( XML_NAMESPACE_OFFICE,
1096 0 : XML_AUTOMATIC_UPDATE, XML_TRUE );
1097 : }
1098 :
1099 : // DDE source element (always empty)
1100 : SvXMLElementExport aSource(*this, XML_NAMESPACE_OFFICE,
1101 0 : XML_DDE_SOURCE, true, false);
1102 : }
1103 :
1104 4 : SwXMLTableInfo_Impl aTblInfo( &rTbl );
1105 2 : ExportTableLines( rTbl.GetTabLines(), aTblInfo, rTbl.GetRowsToRepeat() );
1106 :
1107 6 : BOOST_FOREACH( SwTableLine *pLine, ((SwTable &)rTbl).GetTabLines() )
1108 6 : lcl_xmltble_ClearName_Line( pLine );
1109 : }
1110 2 : }
1111 :
1112 6 : void SwXMLTextParagraphExport::exportTable(
1113 : const Reference < XTextContent > & rTextContent,
1114 : bool bAutoStyles, bool _bProgress )
1115 : {
1116 6 : bool bOldShowProgress = ((SwXMLExport&)GetExport()).IsShowProgress();
1117 6 : ((SwXMLExport&)GetExport()).SetShowProgress( _bProgress );
1118 :
1119 6 : Reference < XTextTable > xTxtTbl( rTextContent, UNO_QUERY );
1120 : OSL_ENSURE( xTxtTbl.is(), "text table missing" );
1121 6 : if( xTxtTbl.is() )
1122 : {
1123 6 : const SwXTextTable *pXTable = 0;
1124 6 : Reference<XUnoTunnel> xTableTunnel( rTextContent, UNO_QUERY);
1125 6 : if( xTableTunnel.is() )
1126 : {
1127 : pXTable = reinterpret_cast< SwXTextTable * >(
1128 6 : sal::static_int_cast< sal_IntPtr >( xTableTunnel->getSomething( SwXTextTable::getUnoTunnelId() )));
1129 : OSL_ENSURE( pXTable, "SwXTextTable missing" );
1130 : }
1131 6 : if( pXTable )
1132 : {
1133 6 : SwFrmFmt *pFmt = pXTable->GetFrmFmt();
1134 : OSL_ENSURE( pFmt, "table format missing" );
1135 6 : const SwTable *pTbl = SwTable::FindTable( pFmt );
1136 : OSL_ENSURE( pTbl, "table missing" );
1137 6 : const SwTableNode *pTblNd = pTbl->GetTableNode();
1138 : OSL_ENSURE( pTblNd, "table node missing" );
1139 6 : if( bAutoStyles )
1140 : {
1141 4 : SwNodeIndex aIdx( *pTblNd );
1142 : // AUTOSTYLES: Optimization: Do not export table autostyle if
1143 : // we are currently exporting the content.xml stuff and
1144 : // the table is located in header/footer:
1145 : // During the flat XML export (used e.g. by .sdw-export)
1146 : // ALL flags are set at the same time.
1147 4 : const bool bExportStyles = ( GetExport().getExportFlags() & EXPORT_STYLES ) != 0;
1148 4 : if ( bExportStyles || !pFmt->GetDoc()->IsInHeaderFooter( aIdx ) )
1149 4 : ((SwXMLExport&)GetExport()).ExportTableAutoStyles( *pTblNd );
1150 : }
1151 : else
1152 : {
1153 2 : ((SwXMLExport&)GetExport()).ExportTable( *pTblNd );
1154 : }
1155 6 : }
1156 : }
1157 :
1158 6 : ((SwXMLExport&)GetExport()).SetShowProgress( bOldShowProgress );
1159 6 : }
1160 :
1161 242 : void SwXMLExport::DeleteTableLines()
1162 : {
1163 242 : if ( pTableLines )
1164 : {
1165 4 : for ( size_t i = 0, n = pTableLines->size(); i < n; ++i )
1166 2 : delete pTableLines->at( i );
1167 2 : pTableLines->clear();
1168 2 : delete pTableLines;
1169 : }
1170 512 : }
1171 :
1172 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|