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