LibreOffice Module sw (master)  1
xmltble.cxx
Go to the documentation of this file.
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 <sal/config.h>
21 
22 #include <string_view>
23 
24 #include <com/sun/star/text/XTextTable.hpp>
25 #include <com/sun/star/text/XTextSection.hpp>
26 
27 #include <hintids.hxx>
28 #include <rtl/ustrbuf.hxx>
29 #include <xmloff/xmlnamespace.hxx>
30 #include <xmloff/xmltoken.hxx>
31 #include <xmloff/xmluconv.hxx>
32 #include <xmloff/numehelp.hxx>
33 #include <editeng/brushitem.hxx>
34 #include <editeng/boxitem.hxx>
35 #include <editeng/prntitem.hxx>
36 #include <editeng/xmlcnitm.hxx>
37 #include <fmtrowsplt.hxx>
38 #include <editeng/frmdiritem.hxx>
39 #include <swtable.hxx>
40 #include <doc.hxx>
41 #include <frmfmt.hxx>
42 #include <wrtswtbl.hxx>
43 #include <fmtfsize.hxx>
44 #include <fmtornt.hxx>
45 #include <cellatr.hxx>
46 #include <ddefld.hxx>
47 #include <swddetbl.hxx>
48 #include <xmloff/namespacemap.hxx>
49 #include <sfx2/linkmgr.hxx>
50 #include <unotbl.hxx>
51 #include "xmltexte.hxx"
52 #include "xmlexp.hxx"
53 #include <o3tl/any.hxx>
54 #include <o3tl/sorted_vector.hxx>
55 #include <textboxhelper.hxx>
56 #include <SwStyleNameMapper.hxx>
57 
58 using namespace ::com::sun::star;
59 using namespace ::com::sun::star::uno;
60 using namespace ::com::sun::star::text;
61 using namespace ::com::sun::star::beans;
62 using namespace ::com::sun::star::lang;
63 using namespace ::com::sun::star::container;
64 using namespace ::xmloff::token;
65 using table::XCell;
66 using std::vector;
67 using std::advance;
68 
69 
71 {
72  OUString m_sStyleName;
73  sal_uInt32 m_nRelWidth;
74 
75 public:
76 
77  explicit SwXMLTableColumn_Impl(sal_uInt32 nPosition)
78  : SwWriteTableCol(nPosition)
79  , m_nRelWidth(0)
80  {};
81 
82  void SetStyleName( const OUString& rName ) { m_sStyleName = rName; }
83  const OUString& GetStyleName() const { return m_sStyleName; }
84 
85  void SetRelWidth( sal_uInt32 nSet ) { m_nRelWidth = nSet; }
86  sal_uInt32 GetRelWidth() const { return m_nRelWidth; }
87 };
88 
89 namespace {
90 
91 struct SwXMLTableColumnCmpWidth_Impl
92 {
93  bool operator()( SwXMLTableColumn_Impl* const& lhs, SwXMLTableColumn_Impl* const& rhs ) const
94  {
95  sal_Int32 n = static_cast<sal_Int32>(lhs->GetWidthOpt()) - static_cast<sal_Int32>(rhs->GetWidthOpt());
96  if( !n )
97  n = static_cast<sal_Int32>(lhs->GetRelWidth()) - static_cast<sal_Int32>(rhs->GetRelWidth());
98  return n < 0;
99  }
100 };
101 
102 class SwXMLTableColumns_Impl : public o3tl::sorted_vector<std::unique_ptr<SwXMLTableColumn_Impl>, o3tl::less_uniqueptr_to<SwXMLTableColumn_Impl> > {
103 };
104 
105 }
106 
107 class SwXMLTableColumnsSortByWidth_Impl : public o3tl::sorted_vector<SwXMLTableColumn_Impl*, SwXMLTableColumnCmpWidth_Impl> {};
108 
110 {
111  SwXMLTableColumns_Impl m_aCols;
113  sal_uInt32 m_nWidth;
114 
115 public:
116 
117  explicit SwXMLTableLines_Impl( const SwTableLines& rLines );
118 
119  sal_uInt32 GetWidth() const { return m_nWidth; }
120  const SwTableLines *GetLines() const { return m_pLines; }
121 
122  const SwXMLTableColumns_Impl& GetColumns() const { return m_aCols; }
123 };
124 
126  m_pLines( &rLines ),
127  m_nWidth( 0 )
128 {
129 #if OSL_DEBUG_LEVEL > 0
130  sal_uInt32 nEndCPos = 0U;
131 #endif
132  const size_t nLines = rLines.size();
133  for( size_t nLine=0U; nLine<nLines; ++nLine )
134  {
135  const SwTableLine *pLine = rLines[nLine];
136  const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
137  const size_t nBoxes = rBoxes.size();
138 
139  sal_uInt32 nCPos = 0U;
140  for( size_t nBox=0U; nBox<nBoxes; ++nBox )
141  {
142  const SwTableBox *pBox = rBoxes[nBox];
143 
144  if( nBox < nBoxes-1U || m_nWidth==0 )
145  {
146  nCPos = nCPos + SwWriteTable::GetBoxWidth( pBox );
147  std::unique_ptr<SwXMLTableColumn_Impl> pCol(
148  new SwXMLTableColumn_Impl( nCPos ));
149 
150  m_aCols.insert( std::move(pCol) );
151 
152  if( nBox==nBoxes-1U )
153  {
154  OSL_ENSURE( nLine==0U && m_nWidth==0,
155  "parent width will be lost" );
156  m_nWidth = nCPos;
157  }
158  }
159  else
160  {
161 #if OSL_DEBUG_LEVEL > 0
162  sal_uInt32 nCheckPos =
163  nCPos + SwWriteTable::GetBoxWidth( pBox );
164  if( !nEndCPos )
165  {
166  nEndCPos = nCheckPos;
167  }
168 #endif
169  nCPos = m_nWidth;
170 #if OSL_DEBUG_LEVEL > 0
172  OSL_ENSURE( m_aCols.find(&aCol) != m_aCols.end(), "couldn't find last column" );
173  OSL_ENSURE( SwXMLTableColumn_Impl(nCheckPos) ==
174  SwXMLTableColumn_Impl(nCPos),
175  "rows have different total widths" );
176 #endif
177  }
178  }
179  }
180 }
181 
182 typedef vector< SwFrameFormat* > SwXMLFrameFormats_Impl;
183 
185 {
186 private:
187  SwXMLFrameFormats_Impl m_aFormatList;
188 public:
189  bool AddRow( SwFrameFormat& rFrameFormat, std::u16string_view rNamePrefix, sal_uInt32 nLine );
190  bool AddCell( SwFrameFormat& rFrameFormat, std::u16string_view rNamePrefix,
191  sal_uInt32 nCol, sal_uInt32 nRow, bool bTop );
192 };
193 
195  std::u16string_view rNamePrefix,
196  sal_uInt32 nLine )
197 {
198  const SwFormatFrameSize *pFrameSize = nullptr;
199  const SwFormatRowSplit* pRowSplit = nullptr;
200  const SvxBrushItem *pBrush = nullptr;
201  const SvxPrintItem *pHasTextChangesOnly = nullptr;
202 
203  const SfxItemSet& rItemSet = rFrameFormat.GetAttrSet();
204  const SfxPoolItem *pItem;
205  if( SfxItemState::SET == rItemSet.GetItemState( RES_FRM_SIZE, false, &pItem ) )
206  pFrameSize = static_cast<const SwFormatFrameSize *>(pItem);
207 
208  if( SfxItemState::SET == rItemSet.GetItemState( RES_ROW_SPLIT, false, &pItem ) )
209  pRowSplit = static_cast<const SwFormatRowSplit *>(pItem);
210 
211  if( SfxItemState::SET == rItemSet.GetItemState( RES_BACKGROUND, false, &pItem ) )
212  pBrush = static_cast<const SvxBrushItem *>(pItem);
213 
214  if( SfxItemState::SET == rItemSet.GetItemState( RES_PRINT, false, &pItem ) )
215  pHasTextChangesOnly = static_cast<const SvxPrintItem *>(pItem);
216 
217  // empty styles have not to be exported
218  if( !pFrameSize && !pBrush && !pRowSplit && !pHasTextChangesOnly )
219  return false;
220 
221  // order is: -/brush, size/-, size/brush
222  bool bInsert = true;
223  SwXMLFrameFormats_Impl::iterator i;
224  for( i = m_aFormatList.begin(); i < m_aFormatList.end(); ++i )
225  {
226  const SwFormatFrameSize *pTestFrameSize = nullptr;
227  const SwFormatRowSplit* pTestRowSplit = nullptr;
228  const SvxBrushItem *pTestBrush = nullptr;
229  const SvxPrintItem *pTestHasTextChangesOnly = nullptr;
230  const SwFrameFormat *pTestFormat = *i;
231  const SfxItemSet& rTestSet = pTestFormat->GetAttrSet();
232  if( SfxItemState::SET == rTestSet.GetItemState( RES_FRM_SIZE, false,
233  &pItem ) )
234  {
235  if( !pFrameSize )
236  break;
237 
238  pTestFrameSize = static_cast<const SwFormatFrameSize *>(pItem);
239  }
240  else
241  {
242  if( pFrameSize )
243  continue;
244  }
245 
246  if( SfxItemState::SET == rTestSet.GetItemState( RES_BACKGROUND, false,
247  &pItem ) )
248  {
249  if( !pBrush )
250  break;
251 
252  pTestBrush = static_cast<const SvxBrushItem *>(pItem);
253  }
254  else
255  {
256  if( pBrush )
257  continue;
258  }
259 
260  if( SfxItemState::SET == rTestSet.GetItemState( RES_ROW_SPLIT, false,
261  &pItem ) )
262  {
263  if( !pRowSplit )
264  break;
265 
266  pTestRowSplit = static_cast<const SwFormatRowSplit *>(pItem);
267  }
268  else
269  {
270  if( pRowSplit )
271  continue;
272  }
273 
274  if( SfxItemState::SET == rTestSet.GetItemState( RES_PRINT, false,
275  &pItem ) )
276  {
277  if( !pHasTextChangesOnly )
278  break;
279 
280  pTestHasTextChangesOnly = static_cast<const SvxPrintItem *>(pItem);
281  }
282  else
283  {
284  if( pHasTextChangesOnly )
285  continue;
286  }
287 
288  if( pFrameSize &&
289  ( pFrameSize->GetHeightSizeType() != pTestFrameSize->GetHeightSizeType() ||
290  pFrameSize->GetHeight() != pTestFrameSize->GetHeight() ) )
291  continue;
292 
293  if( pBrush && (*pBrush != *pTestBrush) )
294  continue;
295 
296  if( pRowSplit && (!pRowSplit->GetValue() != !pTestRowSplit->GetValue()) )
297  continue;
298 
299  if( pHasTextChangesOnly && (!pHasTextChangesOnly->GetValue() != !pTestHasTextChangesOnly->GetValue()) )
300  continue;
301 
302  // found!
303  rFrameFormat.SetName( pTestFormat->GetName() );
304  bInsert = false;
305  break;
306  }
307 
308  if( bInsert )
309  {
310  rFrameFormat.SetName( OUString::Concat(rNamePrefix) + "." + OUString::number(nLine+1) );
311  if ( i != m_aFormatList.end() ) ++i;
312  m_aFormatList.insert( i, &rFrameFormat );
313  }
314 
315  return bInsert;
316 }
317 
318 static OUString lcl_xmltble_appendBoxPrefix(std::u16string_view rNamePrefix,
319  sal_uInt32 nCol, sal_uInt32 nRow, bool bTop )
320 {
321  if( bTop )
322  {
323  OUString sTmp;
324  sw_GetTableBoxColStr( o3tl::narrowing<sal_uInt16>(nCol), sTmp );
325  return OUString::Concat(rNamePrefix) + "." + sTmp + OUString::number(nRow + 1);
326  }
327  return OUString::Concat(rNamePrefix)
328  + "." + OUString::number(nCol + 1)
329  + "." + OUString::number(nRow + 1);
330 }
331 
333  std::u16string_view rNamePrefix,
334  sal_uInt32 nCol, sal_uInt32 nRow, bool bTop )
335 {
336  const SwFormatVertOrient *pVertOrient = nullptr;
337  const SvxBrushItem *pBrush = nullptr;
338  const SvxBoxItem *pBox = nullptr;
339  const SwTableBoxNumFormat *pNumFormat = nullptr;
340  const SvxFrameDirectionItem *pFrameDir = nullptr;
341  const SvXMLAttrContainerItem *pAttCnt = nullptr;
342 
343  const SfxItemSet& rItemSet = rFrameFormat.GetAttrSet();
344  const SfxPoolItem *pItem;
345  if( SfxItemState::SET == rItemSet.GetItemState( RES_VERT_ORIENT, false,
346  &pItem ) )
347  pVertOrient = static_cast<const SwFormatVertOrient *>(pItem);
348 
349  if( SfxItemState::SET == rItemSet.GetItemState( RES_BACKGROUND, false, &pItem ) )
350  pBrush = static_cast<const SvxBrushItem *>(pItem);
351 
352  if( SfxItemState::SET == rItemSet.GetItemState( RES_BOX, false, &pItem ) )
353  pBox = static_cast<const SvxBoxItem *>(pItem);
354 
355  if ( SfxItemState::SET == rItemSet.GetItemState( RES_BOXATR_FORMAT,
356  false, &pItem ) )
357  pNumFormat = static_cast<const SwTableBoxNumFormat *>(pItem);
358  if ( SfxItemState::SET == rItemSet.GetItemState( RES_FRAMEDIR,
359  false, &pItem ) )
360  pFrameDir = static_cast<const SvxFrameDirectionItem *>(pItem);
361  if ( SfxItemState::SET == rItemSet.GetItemState( RES_UNKNOWNATR_CONTAINER,
362  false, &pItem ) )
363  pAttCnt = static_cast<const SvXMLAttrContainerItem *>(pItem);
364 
365  // empty styles have not to be exported
366  if( !pVertOrient && !pBrush && !pBox && !pNumFormat && !pFrameDir && !pAttCnt )
367  return false;
368 
369  // order is: -/-/-/num,
370  // -/-/box/-, -/-/box/num,
371  // -/brush/-/-, -/brush/-/num, -/brush/box/-, -/brush/box/num,
372  // vert/-/-/-, vert/-/-/num, vert/-/box/-, ver/-/box/num,
373  // vert/brush/-/-, vert/brush/-/num, vert/brush/box/-,
374  // vert/brush/box/num
375  bool bInsert = true;
376  SwXMLFrameFormats_Impl::iterator i;
377  for( i = m_aFormatList.begin(); i < m_aFormatList.end(); ++i )
378  {
379  const SwFormatVertOrient *pTestVertOrient = nullptr;
380  const SvxBrushItem *pTestBrush = nullptr;
381  const SvxBoxItem *pTestBox = nullptr;
382  const SwTableBoxNumFormat *pTestNumFormat = nullptr;
383  const SvxFrameDirectionItem *pTestFrameDir = nullptr;
384  const SvXMLAttrContainerItem *pTestAttCnt = nullptr;
385  const SwFrameFormat* pTestFormat = *i;
386  const SfxItemSet& rTestSet = pTestFormat->GetAttrSet();
387  if( SfxItemState::SET == rTestSet.GetItemState( RES_VERT_ORIENT, false,
388  &pItem ) )
389  {
390  if( !pVertOrient )
391  break;
392 
393  pTestVertOrient = static_cast<const SwFormatVertOrient *>(pItem);
394  }
395  else
396  {
397  if( pVertOrient )
398  continue;
399  }
400 
401  if( SfxItemState::SET == rTestSet.GetItemState( RES_BACKGROUND, false,
402  &pItem ) )
403  {
404  if( !pBrush )
405  break;
406 
407  pTestBrush = static_cast<const SvxBrushItem *>(pItem);
408  }
409  else
410  {
411  if( pBrush )
412  continue;
413  }
414 
415  if( SfxItemState::SET == rTestSet.GetItemState( RES_BOX, false, &pItem ) )
416  {
417  if( !pBox )
418  break;
419 
420  pTestBox = static_cast<const SvxBoxItem *>(pItem);
421  }
422  else
423  {
424  if( pBox )
425  continue;
426  }
427 
428  if ( SfxItemState::SET == rTestSet.GetItemState( RES_BOXATR_FORMAT,
429  false, &pItem ) )
430  {
431  if( !pNumFormat )
432  break;
433 
434  pTestNumFormat = static_cast<const SwTableBoxNumFormat *>(pItem);
435  }
436  else
437  {
438  if( pNumFormat )
439  continue;
440 
441  }
442 
443  if ( SfxItemState::SET == rTestSet.GetItemState( RES_FRAMEDIR,
444  false, &pItem ) )
445  {
446  if( !pFrameDir )
447  break;
448 
449  pTestFrameDir = static_cast<const SvxFrameDirectionItem *>(pItem);
450  }
451  else
452  {
453  if( pFrameDir )
454  continue;
455 
456  }
457 
458  if ( SfxItemState::SET == rTestSet.GetItemState( RES_UNKNOWNATR_CONTAINER,
459  false, &pItem ) )
460  {
461  if( !pAttCnt )
462  break;
463 
464  pTestAttCnt = static_cast<const SvXMLAttrContainerItem *>(pItem);
465  }
466  else
467  {
468  if ( pAttCnt )
469  continue;
470 
471  }
472 
473  if( pVertOrient &&
474  pVertOrient->GetVertOrient() != pTestVertOrient->GetVertOrient() )
475  continue;
476 
477  if( pBrush && ( *pBrush != *pTestBrush ) )
478  continue;
479 
480  if( pBox && ( *pBox != *pTestBox ) )
481  continue;
482 
483  if( pNumFormat && pNumFormat->GetValue() != pTestNumFormat->GetValue() )
484  continue;
485 
486  if( pFrameDir && pFrameDir->GetValue() != pTestFrameDir->GetValue() )
487  continue;
488 
489  if( pAttCnt && ( *pAttCnt != *pTestAttCnt ) )
490  continue;
491 
492  // found!
493  rFrameFormat.SetName( pTestFormat->GetName() );
494  bInsert = false;
495  break;
496  }
497 
498  if( bInsert )
499  {
500  rFrameFormat.SetName( lcl_xmltble_appendBoxPrefix( rNamePrefix, nCol, nRow, bTop ) );
501  if ( i != m_aFormatList.end() ) ++i;
502  m_aFormatList.insert( i, &rFrameFormat );
503  }
504 
505  return bInsert;
506 }
507 
509 {
511  Reference<XTextSection> m_xBaseSection;
513  sal_uInt32 m_nPrefix;
514 
515 public:
516 
517  inline SwXMLTableInfo_Impl( const SwTable *pTable, sal_uInt16 nPrefix );
518 
519  const SwTable *GetTable() const { return m_pTable; }
520  const SwFrameFormat *GetTableFormat() const { return m_pTable->GetFrameFormat(); }
521 
522  bool IsBaseSectionValid() const { return m_bBaseSectionValid; }
523  const Reference<XTextSection>& GetBaseSection() const { return m_xBaseSection; }
524  inline void SetBaseSection( const Reference < XTextSection >& rBase );
526  sal_uInt16 GetPrefix() const { return m_nPrefix; }
527 };
528 
529 inline SwXMLTableInfo_Impl::SwXMLTableInfo_Impl(const SwTable *pTable, sal_uInt16 nPrefix) :
530  m_pTable(pTable),
531  m_bBaseSectionValid(false),
532  m_nPrefix(nPrefix)
533 {
534 }
535 
537  const Reference < XTextSection >& rBaseSection )
538 {
539  m_xBaseSection = rBaseSection;
540  m_bBaseSectionValid = true;
541 }
542 
544 {
545  // <style:style ...>
546  CheckAttrList();
547 
548  // style:name="..."
549  bool bEncoded = false;
551  EncodeStyleName( rCol.GetStyleName(), &bEncoded ) );
552  if( bEncoded )
554 
555  // style:family="table-column"
557 
558  {
559  SvXMLElementExport aElem( *this, XML_NAMESPACE_STYLE, XML_STYLE, true,
560  true );
561  OUStringBuffer sValue;
562  if( rCol.GetWidthOpt() )
563  {
565  rCol.GetWidthOpt() );
567  sValue.makeStringAndClear() );
568  }
569  if( rCol.GetRelWidth() )
570  {
571  sValue.append( static_cast<sal_Int32>(rCol.GetRelWidth()) );
572  sValue.append( '*' );
574  sValue.makeStringAndClear() );
575  }
576 
577  {
578  SvXMLElementExport aElemExport( *this, XML_NAMESPACE_STYLE,
580  true, true );
581  }
582  }
583 }
584 
586  sal_uInt32 nAbsWidth, sal_uInt32 nBaseWidth,
587  std::u16string_view rNamePrefix,
591  SwXMLTableInfo_Impl& rTableInfo,
592  bool bTop )
593 {
594  // pass 1: calculate columns
595  SwXMLTableLines_Impl *pLines = new SwXMLTableLines_Impl( rLines );
596  if( !m_pTableLines )
598 
599  m_pTableLines->push_back( pLines );
600 
601  // pass 2: export column styles
602  {
603  const SwXMLTableColumns_Impl& rCols = pLines->GetColumns();
604  sal_uInt32 nCPos = 0U;
605  const size_t nColumns = rCols.size();
606  for( size_t nColumn=0U; nColumn<nColumns; ++nColumn )
607  {
608  SwXMLTableColumn_Impl *pColumn = rCols[nColumn].get();
609 
610  sal_uInt32 nOldCPos = nCPos;
611  nCPos = pColumn->GetPos();
612 
613  sal_uInt32 nWidth = nCPos - nOldCPos;
614 
615  // If a base width is given, the table has either an automatic
616  // or margin alignment, or a percentage width. In either case,
617  // relative widths should be exported.
618  if( nBaseWidth )
619  {
620  pColumn->SetRelWidth( nWidth );
621  }
622 
623  // If an absolute width is given, the table either has a fixed
624  // width, or the current width is known from the layout. In the
625  // later case, a base width is set in addition and must be used
626  // to "absolutize" the relative column width.
627  if( nAbsWidth )
628  {
629  sal_uInt32 nColAbsWidth = nWidth;
630  if( nBaseWidth )
631  {
632  nColAbsWidth *= nAbsWidth;
633  nColAbsWidth += (nBaseWidth/2UL);
634  nColAbsWidth /= nBaseWidth;
635  }
636  pColumn->SetWidthOpt( nColAbsWidth, false );
637  }
638 
640  if( it != rExpCols.end() )
641  {
642  pColumn->SetStyleName( (*it)->GetStyleName() );
643  }
644  else
645  {
646  if( bTop )
647  {
648  OUString sTmp;
649  sw_GetTableBoxColStr( nColumn, sTmp );
650  pColumn->SetStyleName( OUString::Concat(rNamePrefix) + "." + sTmp );
651  }
652  else
653  {
654  pColumn->SetStyleName(
655  OUString::Concat(rNamePrefix) + "." + OUString::number(nColumn + 1U) );
656  }
657  ExportTableColumnStyle( *pColumn );
658  rExpCols.insert( pColumn );
659  }
660  }
661  }
662 
663  // pass 3: export line/rows
664  const size_t nLines = rLines.size();
665  for( size_t nLine=0U; nLine<nLines; ++nLine )
666  {
667  SwTableLine *pLine = rLines[nLine];
668 
669  SwFrameFormat *pFrameFormat = pLine->GetFrameFormat();
670  if( rExpRows.AddRow( *pFrameFormat, rNamePrefix, nLine ) )
671  ExportFormat( *pFrameFormat, XML_TABLE_ROW );
672 
673  const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
674  const size_t nBoxes = rBoxes.size();
675 
676  sal_uInt32 nCPos = 0U;
677  size_t nCol = 0U;
678  for( size_t nBox=0U; nBox<nBoxes; nBox++ )
679  {
680  SwTableBox *pBox = rBoxes[nBox];
681 
682  if( nBox < nBoxes-1U )
683  nCPos = nCPos + SwWriteTable::GetBoxWidth( pBox );
684  else
685  nCPos = pLines->GetWidth();
686 
687  // and their index
688  const size_t nOldCol = nCol;
689  SwXMLTableColumn_Impl aCol( nCPos );
690  SwXMLTableColumns_Impl::const_iterator it = pLines->GetColumns().find( &aCol );
691  OSL_ENSURE( it != pLines->GetColumns().end(), "couldn't find column" );
692  nCol = it - pLines->GetColumns().begin();
693 
694  const SwStartNode *pBoxSttNd = pBox->GetSttNd();
695  if( pBoxSttNd )
696  {
697  SwFrameFormat *pFrameFormat2 = pBox->GetFrameFormat();
698  if( rExpCells.AddCell( *pFrameFormat2, rNamePrefix, nOldCol, nLine,
699  bTop) )
700  ExportFormat( *pFrameFormat2, XML_TABLE_CELL );
701 
702  Reference < XCell > xCell = SwXCell::CreateXCell(
703  const_cast<SwFrameFormat *>(rTableInfo.GetTableFormat()),
704  pBox,
705  const_cast<SwTable *>(rTableInfo.GetTable()) );
706  if (xCell.is())
707  {
708  Reference < XText > xText( xCell, UNO_QUERY );
709  if( !rTableInfo.IsBaseSectionValid() )
710  {
711  Reference<XPropertySet> xCellPropertySet( xCell,
712  UNO_QUERY );
713  Any aAny = xCellPropertySet->getPropertyValue("TextSection");
714  Reference < XTextSection > xTextSection;
715  aAny >>= xTextSection;
716  rTableInfo.SetBaseSection( xTextSection );
717  }
718 
719  const bool bExportContent = bool(getExportFlags() & SvXMLExportFlags::CONTENT );
720  if ( !bExportContent )
721  {
722  // AUTOSTYLES - not needed anymore if we are currently exporting content.xml
723  GetTextParagraphExport()->collectTextAutoStyles(
724  xText, rTableInfo.GetBaseSection(), IsShowProgress() );
725  }
726  }
727  else {
728  OSL_FAIL("here should be a XCell");
729  }
730  }
731  else
732  {
734  nAbsWidth, nBaseWidth,
735  lcl_xmltble_appendBoxPrefix( rNamePrefix,
736  nOldCol, nLine, bTop ),
737  rExpCols, rExpRows, rExpCells,
738  rTableInfo );
739  }
740 
741  nCol++;
742  }
743  }
744 }
745 
747 {
748  const SwTable& rTable = rTableNd.GetTable();
749  const SwFrameFormat *pTableFormat = rTable.GetFrameFormat();
750 
751  if( !pTableFormat )
752  return;
753 
754  sal_Int16 eTabHoriOri = pTableFormat->GetHoriOrient().GetHoriOrient();
755  const SwFormatFrameSize& rFrameSize = pTableFormat->GetFrameSize();
756 
757  sal_uInt32 nAbsWidth = rFrameSize.GetSize().Width();
758  sal_uInt32 nBaseWidth = 0;
759  sal_Int8 nPercentWidth = rFrameSize.GetWidthPercent();
760 
761  bool bFixAbsWidth = nPercentWidth != 0 || /*text::*/HoriOrientation::NONE == eTabHoriOri
762  || /*text::*/HoriOrientation::FULL == eTabHoriOri;
763  if( bFixAbsWidth )
764  {
765  nBaseWidth = nAbsWidth;
766  nAbsWidth = pTableFormat->FindLayoutRect(true).Width();
767  if( !nAbsWidth )
768  {
769  // TODO?
770  }
771  }
772  ExportTableFormat( *pTableFormat, nAbsWidth );
773 
777  SwXMLTableInfo_Impl aTableInfo( &rTable, XML_NAMESPACE_TABLE );
778  ExportTableLinesAutoStyles( rTable.GetTabLines(), nAbsWidth, nBaseWidth,
779  pTableFormat->GetName(), aExpCols, aExpRows, aExpCells,
780  aTableInfo, true);
781 
782 }
783 
785  sal_uInt32 nColSpan,
786  sal_uInt32 nRowSpan,
787  SwXMLTableInfo_Impl& rTableInfo )
788 {
789  const SwStartNode *pBoxSttNd = rBox.GetSttNd();
790  if( pBoxSttNd )
791  {
792  const SwFrameFormat *pFrameFormat = rBox.GetFrameFormat();
793  if( pFrameFormat )
794  {
795  const OUString& sName = pFrameFormat->GetName();
796  if( !sName.isEmpty() )
797  {
799  }
800  }
801  }
802 
803  if( nRowSpan != 1 )
804  {
806  OUString::number(nRowSpan) );
807  }
808 
809  if( nColSpan != 1 )
810  {
812  OUString::number(nColSpan) );
813  }
814 
815  {
816  if( pBoxSttNd )
817  {
818  // start node -> normal cell
819  // get cell range for table
820  Reference<XCell> xCell = SwXCell::CreateXCell( const_cast<SwFrameFormat *>(rTableInfo.GetTableFormat()),
821  const_cast<SwTableBox *>(&rBox),
822  const_cast<SwTable *>(rTableInfo.GetTable()) );
823 
824  if (xCell.is())
825  {
826  Reference<XText> xText( xCell, UNO_QUERY );
827 
828  // get formula (and protection)
829  const OUString sCellFormula = xCell->getFormula();
830 
831  // if this cell has a formula, export it
832  // (with value and number format)
833  if (!sCellFormula.isEmpty())
834  {
835  const OUString sQValue =
837  XML_NAMESPACE_OOOW, sCellFormula, false );
838  // formula
840  }
841 
842  // value and format (if NumberFormat != -1)
843  Reference<XPropertySet> xCellPropertySet(xCell,
844  UNO_QUERY);
845  if (xCellPropertySet.is())
846  {
847  sal_Int32 nNumberFormat = 0;
848  Any aAny = xCellPropertySet->getPropertyValue("NumberFormat");
849  aAny >>= nNumberFormat;
850 
851  if (static_cast<sal_Int32>(getSwDefaultTextFormat()) == nNumberFormat)
852  {
853  // text format
856  }
857  else if ( (-1 != nNumberFormat) && !xText->getString().isEmpty() )
858  {
859  // number format key:
860  // (export values only if cell contains text;)
863  *this, nNumberFormat, xCell->getValue() );
864  }
865  // else: invalid key; ignore
866 
867  // cell protection
868  aAny = xCellPropertySet->getPropertyValue("IsProtected");
869  if (*o3tl::doAccess<bool>(aAny))
870  {
872  XML_TRUE );
873  }
874 
875  if( !rTableInfo.IsBaseSectionValid() )
876  {
877  aAny = xCellPropertySet->getPropertyValue("TextSection");
878  Reference < XTextSection > xTextSection;
879  aAny >>= xTextSection;
880  rTableInfo.SetBaseSection( xTextSection );
881  }
882  }
883 
884  // export cell element
885  SvXMLElementExport aElem( *this, rTableInfo.GetPrefix(),
886  XML_TABLE_CELL, true, true );
887 
888  // export cell content
889  GetTextParagraphExport()->exportText( xText,
890  rTableInfo.GetBaseSection(),
891  IsShowProgress() );
892  }
893  else
894  {
895  OSL_FAIL("here should be a XCell");
896  ClearAttrList();
897  }
898  }
899  else
900  {
901  // no start node -> merged cells: export subtable in cell
903  XML_TABLE_CELL, true, true );
904  {
906  GetXMLToken( XML_TRUE ) );
907 
908  SvXMLElementExport aElemExport( *this, XML_NAMESPACE_TABLE,
909  XML_TABLE, true, true );
910  ExportTableLines( rBox.GetTabLines(), rTableInfo );
911  }
912  }
913  }
914 }
915 
917  const SwXMLTableLines_Impl& rLines,
918  SwXMLTableInfo_Impl& rTableInfo )
919 {
920  if( rLine.hasSoftPageBreak() )
921  {
923  XML_SOFT_PAGE_BREAK, true, true );
924  }
925  const SwFrameFormat *pFrameFormat = rLine.GetFrameFormat();
926  if( pFrameFormat )
927  {
928  const OUString& sName = pFrameFormat->GetName();
929  if( !sName.isEmpty() )
930  {
932  }
933  }
934 
935  {
936  SvXMLElementExport aElem( *this, rTableInfo.GetPrefix(), XML_TABLE_ROW, true, true );
937  const SwTableBoxes& rBoxes = rLine.GetTabBoxes();
938  const size_t nBoxes = rBoxes.size();
939 
940  sal_uInt32 nCPos = 0U;
941  size_t nCol = 0U;
942  for( size_t nBox=0U; nBox<nBoxes; ++nBox )
943  {
944  const SwTableBox *pBox = rBoxes[nBox];
945 
946  // NEW TABLES
947  const sal_Int32 nRowSpan = pBox->getRowSpan();
948  if( nRowSpan < 1 )
949  {
950  // Export style of covered cell, it includes border information.
951  const SwFrameFormat* pFormat = pBox->GetFrameFormat();
952  if (pFormat)
953  {
954  const OUString& sName = pFormat->GetName();
955  if (!sName.isEmpty())
956  {
958  }
959  }
960 
961  SvXMLElementExport aElem2( *this, rTableInfo.GetPrefix(),
963  false );
964  }
965 
966  if( nBox < nBoxes-1U )
967  nCPos = nCPos + SwWriteTable::GetBoxWidth( pBox );
968  else
969  nCPos = rLines.GetWidth();
970 
971  // and their index
972  const size_t nOldCol = nCol;
973  SwXMLTableColumn_Impl aCol( nCPos );
974  SwXMLTableColumns_Impl::const_iterator it = rLines.GetColumns().find( &aCol );
975  OSL_ENSURE( it != rLines.GetColumns().end(), "couldn't find column" );
976  nCol = it - rLines.GetColumns().begin();
977 
978  // #i95726# - Some fault tolerance, if table is somehow corrupted.
979  if ( nCol < nOldCol )
980  {
981  OSL_FAIL( "table and/or table information seems to be corrupted." );
982  // NOTE: nOldCol is not necessarily a valid index into
983  // GetColumns(), but that doesn't matter here
984  nCol = nOldCol;
985  }
986 
987  const sal_uInt32 nColSpan = nCol - nOldCol + 1U;
988 
989  if ( nRowSpan >= 1 )
990  ExportTableBox( *pBox, nColSpan, static_cast< sal_uInt32 >(nRowSpan), rTableInfo );
991 
992  for( size_t i=nOldCol; i<nCol; ++i )
993  {
994  SvXMLElementExport aElemExport( *this, rTableInfo.GetPrefix(),
996  false );
997  }
998 
999  nCol++;
1000  }
1001  }
1002 }
1003 
1005  SwXMLTableInfo_Impl& rTableInfo,
1006  sal_uInt32 nHeaderRows )
1007 {
1008  OSL_ENSURE( m_pTableLines && !m_pTableLines->empty(),
1009  "SwXMLExport::ExportTableLines: table columns infos missing" );
1010  if( !m_pTableLines || m_pTableLines->empty() )
1011  return;
1012 
1013  SwXMLTableLines_Impl* pLines = nullptr;
1014  size_t nInfoPos;
1015  for( nInfoPos=0; nInfoPos < m_pTableLines->size(); nInfoPos++ )
1016  {
1017  if( m_pTableLines->at( nInfoPos )->GetLines() == &rLines )
1018  {
1019  pLines = m_pTableLines->at( nInfoPos );
1020  break;
1021  }
1022  }
1023  OSL_ENSURE( pLines,
1024  "SwXMLExport::ExportTableLines: table columns info missing" );
1025  OSL_ENSURE( 0==nInfoPos,
1026  "SwXMLExport::ExportTableLines: table columns infos are unsorted" );
1027  if( !pLines )
1028  return;
1029 
1030  SwXMLTableLinesCache_Impl::iterator it = m_pTableLines->begin();
1031  advance( it, nInfoPos );
1032  m_pTableLines->erase( it );
1033 
1034  if( m_pTableLines->empty() )
1035  m_pTableLines.reset();
1036 
1037  // pass 2: export columns
1038  const SwXMLTableColumns_Impl& rCols = pLines->GetColumns();
1039  size_t nColumn = 0U;
1040  const size_t nColumns = rCols.size();
1041  sal_Int32 nColRep = 1;
1042  SwXMLTableColumn_Impl *pColumn = (nColumns > 0) ? rCols.front().get() : nullptr;
1043  while( pColumn )
1044  {
1045  nColumn++;
1046  SwXMLTableColumn_Impl *pNextColumn =
1047  (nColumn < nColumns) ? rCols[nColumn].get() : nullptr;
1048  if( pNextColumn &&
1049  pNextColumn->GetStyleName() == pColumn->GetStyleName() )
1050  {
1051  nColRep++;
1052  }
1053  else
1054  {
1056  EncodeStyleName(pColumn->GetStyleName()) );
1057 
1058  if( nColRep > 1 )
1059  {
1061  OUString::number(nColRep) );
1062  }
1063 
1064  {
1065  SvXMLElementExport aElem( *this, rTableInfo.GetPrefix(), XML_TABLE_COLUMN, true, true );
1066  }
1067 
1068  nColRep = 1;
1069  }
1070  pColumn = pNextColumn;
1071  }
1072 
1073  // pass 3: export line/rows
1074  const size_t nLines = rLines.size();
1075  // export header rows, if present
1076  if( nHeaderRows > 0 )
1077  {
1079  XML_TABLE_HEADER_ROWS, true, true );
1080 
1081  OSL_ENSURE( nHeaderRows <= nLines, "more headers then lines?" );
1082  for( size_t nLine = 0U; nLine < nHeaderRows; ++nLine )
1083  ExportTableLine( *(rLines[nLine]), *pLines, rTableInfo );
1084  }
1085  // export remaining rows
1086  for( size_t nLine = nHeaderRows; nLine < nLines; ++nLine )
1087  {
1088  ExportTableLine( *(rLines[nLine]), *pLines, rTableInfo );
1089  }
1090 
1091  delete pLines;
1092 }
1093 
1094 static void lcl_xmltble_ClearName_Line( SwTableLine* pLine );
1095 
1097 {
1098  if( !pBox->GetSttNd() )
1099  {
1100  for( SwTableLine* pLine : pBox->GetTabLines() )
1101  lcl_xmltble_ClearName_Line( pLine );
1102  }
1103  else
1104  {
1105  SwFrameFormat *pFrameFormat = pBox->GetFrameFormat();
1106  if( pFrameFormat && !pFrameFormat->GetName().isEmpty() )
1107  pFrameFormat->SetName( OUString() );
1108  }
1109 }
1110 
1112 {
1113  for( SwTableBox* pBox : pLine->GetTabBoxes() )
1114  lcl_xmltble_ClearName_Box( pBox );
1115 }
1116 
1117 void SwXMLExport::ExportTable( const SwTableNode& rTableNd )
1118 {
1119  ::std::optional<sal_uInt16> oPrefix = XML_NAMESPACE_TABLE;
1120  if (const SwFrameFormat* pFlyFormat = rTableNd.GetFlyFormat())
1121  {
1122  if (SwTextBoxHelper::isTextBox(pFlyFormat, RES_FLYFRMFMT))
1123  {
1124  // TODO ODF 1.4 OFFICE-3761
1126  {
1127  oPrefix = XML_NAMESPACE_LO_EXT;
1128  }
1129  else
1130  {
1131  oPrefix.reset(); // no export to OASIS namespace yet
1132  }
1133  }
1134  }
1135 
1136  if (!oPrefix)
1137  return;
1138 
1139  const SwTable& rTable = rTableNd.GetTable();
1140  const SwFrameFormat *pTableFormat = rTable.GetFrameFormat();
1141  if (pTableFormat && !pTableFormat->GetName().isEmpty())
1142  {
1143  AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, pTableFormat->GetName());
1145  EncodeStyleName(pTableFormat->GetName()));
1146  }
1147 
1148  // table:template-name=
1149  if (!rTable.GetTableStyleName().isEmpty())
1150  {
1151  OUString sStyleName;
1154  }
1155 
1156  SvXMLElementExport aElem(*this, *oPrefix, XML_TABLE, true, true);
1157 
1158  // export DDE source (if this is a DDE table)
1159  if ( auto pSwDdeTable = dynamic_cast<const SwDDETable*>( &rTable) )
1160  {
1161  // get DDE Field Type (contains the DDE connection)
1162  const SwDDEFieldType* pDDEFieldType = pSwDdeTable->GetDDEFieldType();
1163 
1164  // connection name
1166  pDDEFieldType->GetName() );
1167 
1168  // DDE command
1169  const OUString& sCmd = pDDEFieldType->GetCmd();
1170  sal_Int32 nIdx{ 0 };
1172  sCmd.getToken(0, sfx2::cTokenSeparator, nIdx) );
1174  sCmd.getToken(0, sfx2::cTokenSeparator, nIdx) );
1176  sCmd.getToken(0, sfx2::cTokenSeparator, nIdx) );
1177 
1178  // auto update
1179  if (pDDEFieldType->GetType() == SfxLinkUpdateMode::ALWAYS)
1180  {
1183  }
1184 
1185  // DDE source element (always empty)
1187  XML_DDE_SOURCE, true, false);
1188  }
1189 
1190  SwXMLTableInfo_Impl aTableInfo(&rTable, *oPrefix);
1191  ExportTableLines( rTable.GetTabLines(), aTableInfo, rTable.GetRowsToRepeat() );
1192 
1193  for( SwTableLine *pLine : const_cast<SwTable &>(rTable).GetTabLines() )
1194  lcl_xmltble_ClearName_Line( pLine );
1195 }
1196 
1198  for (const auto* pTableNode : maTableNodes)
1199  {
1200  static_cast<SwXMLExport&>(GetExport()).ExportTableAutoStyles(*pTableNode);
1201  }
1202 }
1203 
1205  const Reference < XTextContent > & rTextContent,
1206  bool bAutoStyles, bool _bProgress )
1207 {
1208  bool bOldShowProgress = static_cast<SwXMLExport&>(GetExport()).IsShowProgress();
1209  static_cast<SwXMLExport&>(GetExport()).SetShowProgress( _bProgress );
1210 
1211  Reference < XTextTable > xTextTable( rTextContent, UNO_QUERY );
1212  OSL_ENSURE( xTextTable.is(), "text table missing" );
1213  if( xTextTable.is() )
1214  {
1215  Reference<XUnoTunnel> xTableTunnel( rTextContent, UNO_QUERY);
1216  SwXTextTable* pXTable = comphelper::getFromUnoTunnel<SwXTextTable>(xTableTunnel);
1217  if( pXTable )
1218  {
1219  SwFrameFormat *const pFormat = pXTable->GetFrameFormat();
1220  OSL_ENSURE( pFormat, "table format missing" );
1221  const SwTable *pTable = SwTable::FindTable( pFormat );
1222  OSL_ENSURE( pTable, "table missing" );
1223  const SwTableNode *pTableNd = pTable->GetTableNode();
1224  OSL_ENSURE( pTableNd, "table node missing" );
1225  if( bAutoStyles )
1226  {
1227  SwNodeIndex aIdx( *pTableNd );
1228  // AUTOSTYLES: Optimization: Do not export table autostyle if
1229  // we are currently exporting the content.xml stuff and
1230  // the table is located in header/footer:
1231  // During the flat XML export (used e.g. by .sdw-export)
1232  // ALL flags are set at the same time.
1233  const bool bExportStyles = bool( GetExport().getExportFlags() & SvXMLExportFlags::STYLES );
1234  if (!isAutoStylesCollected()
1235  && (bExportStyles || !pFormat->GetDoc()->IsInHeaderFooter(aIdx)))
1236  {
1237  maTableNodes.push_back(pTableNd);
1238  // Collect all tables inside cells of this table, too
1239  const auto aCellNames = pXTable->getCellNames();
1240  for (const OUString& rCellName : aCellNames)
1241  {
1242  css::uno::Reference<css::container::XEnumerationAccess> xCell(
1243  pXTable->getCellByName(rCellName), css::uno::UNO_QUERY);
1244  if (!xCell)
1245  continue;
1246  auto xEnumeration = xCell->createEnumeration();
1247  while (xEnumeration->hasMoreElements())
1248  {
1249  if (css::uno::Reference<css::text::XTextTable> xInnerTable{
1250  xEnumeration->nextElement(), css::uno::UNO_QUERY })
1251  exportTable(xInnerTable, bAutoStyles, _bProgress);
1252  }
1253  }
1254  }
1255  }
1256  else
1257  {
1258  static_cast<SwXMLExport&>(GetExport()).ExportTable( *pTableNd );
1259  }
1260  }
1261  }
1262 
1263  static_cast<SwXMLExport&>(GetExport()).SetShowProgress( bOldShowProgress );
1264 }
1265 
1267 {
1268  if ( m_pTableLines )
1269  {
1271  delete p;
1272  m_pTableLines->clear();
1273  m_pTableLines.reset();
1274  }
1275 }
1276 
1277 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool GetValue() const
XML_TEMPLATE_NAME
Starts a section of nodes in the document model.
Definition: node.hxx:313
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(120)
constexpr TypedWhichId< SvXMLAttrContainerItem > RES_UNKNOWNATR_CONTAINER(RES_UNKNOWNATR_BEGIN)
XML_NUMBER_COLUMNS_SPANNED
constexpr sal_uInt16 XML_NAMESPACE_OFFICE
XML_DDE_ITEM
constexpr TypedWhichId< SvxPrintItem > RES_PRINT(98)
void ExportTableAutoStyles(const SwTableNode &rTableNd)
Definition: xmltble.cxx:746
constexpr TypedWhichId< SwTableBoxNumFormat > RES_BOXATR_FORMAT(RES_BOXATR_BEGIN)
static rtl::Reference< SwXCell > CreateXCell(SwFrameFormat *pTableFormat, SwTableBox *pBox, SwTable *pTable=nullptr)
Definition: unotbl.cxx:1129
signed char sal_Int8
const SwTableLines * m_pLines
Definition: xmltble.cxx:112
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
rtl::Reference< XMLTextParagraphExport > const & GetTextParagraphExport()
XML_DDE_APPLICATION
bool isAutoStylesCollected() const
void CheckAttrList()
std::vector< SwXMLTableLines_Impl * > SwXMLTableLinesCache_Impl
Definition: xmlexp.hxx:46
SwRect FindLayoutRect(const bool bPrtArea=false, const Point *pPoint=nullptr) const
Definition: atrfrm.cxx:2720
const sal_Unicode cTokenSeparator
const Reference< XTextSection > & GetBaseSection() const
Definition: xmltble.cxx:523
sal_Int64 n
SfxLinkUpdateMode GetType() const
Definition: ddefld.hxx:83
XML_AUTOMATIC_UPDATE
sal_uInt32 GetRelWidth() const
Definition: xmltble.cxx:86
void SetRelWidth(sal_uInt32 nSet)
Definition: xmltble.cxx:85
XML_VALUE_TYPE
Reference< XTextSection > m_xBaseSection
Definition: xmltble.cxx:511
SwXMLTableColumn_Impl(sal_uInt32 nPosition)
Definition: xmltble.cxx:77
static sal_uInt32 GetBoxWidth(const SwTableBox *pBox)
Definition: wrtswtbl.cxx:84
const_iterator find(const Value &x) const
SwTableLine is one table row in the document model.
Definition: swtable.hxx:358
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
sal_uInt16 GetRowsToRepeat() const
Definition: swtable.hxx:197
static OUString lcl_xmltble_appendBoxPrefix(std::u16string_view rNamePrefix, sal_uInt32 nCol, sal_uInt32 nRow, bool bTop)
Definition: xmltble.cxx:318
XML_TABLE_CELL
sal_uInt32 m_nWidth
Definition: xmltble.cxx:113
const SwTable * GetTable() const
Definition: xmltble.cxx:519
SwXMLFrameFormats_Impl m_aFormatList
Definition: xmltble.cxx:187
SwTableFormat * GetFrameFormat()
Definition: swtable.hxx:205
bool IsInHeaderFooter(const SwNodeIndex &rIdx) const
Definition: doclay.cxx:1552
sal_uInt32 GetWidthOpt() const
Definition: wrtswtbl.hxx:185
bool AddCell(SwFrameFormat &rFrameFormat, std::u16string_view rNamePrefix, sal_uInt32 nCol, sal_uInt32 nRow, bool bTop)
Definition: xmltble.cxx:332
size_type size() const
Definition: swtable.hxx:77
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(156)
SvXMLExport & GetExport()
XML_NUMBER_ROWS_SPANNED
sal_Int32 getRowSpan() const
Definition: swtable.cxx:76
constexpr tools::Long Width() const
OUString const & GetCmd() const
Definition: ddefld.cxx:229
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
void sw_GetTableBoxColStr(sal_uInt16 nCol, OUString &rNm)
Definition: swtable.cxx:1815
XML_FORMULA
const OUString & GetName() const
Definition: format.hxx:115
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
virtual void SetName(const OUString &rNewName, bool bBroadcast=false) override
Definition: atrfrm.cxx:2570
virtual void exportTableAutoStyles() override
Definition: xmltble.cxx:1197
void ExportTableLinesAutoStyles(const SwTableLines &rLines, sal_uInt32 nAbsWidth, sal_uInt32 nBaseWidth, std::u16string_view rNamePrefix, SwXMLTableColumnsSortByWidth_Impl &rExpCols, SwXMLTableFrameFormatsSort_Impl &rExpRows, SwXMLTableFrameFormatsSort_Impl &rExpCells, SwXMLTableInfo_Impl &rTableInfo, bool bTop=false)
Definition: xmltble.cxx:585
void Width(tools::Long nNew)
Definition: swrect.hxx:189
const SwTable & GetTable() const
Definition: node.hxx:500
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
Is the frame format a text box?
const OUString & GetTableStyleName() const
Return the table style name of this table.
Definition: swtable.hxx:192
XML_DISPLAY_NAME
XML_REL_COLUMN_WIDTH
void SetWidthOpt(sal_uInt32 nWidth, bool bRel)
Definition: wrtswtbl.hxx:181
const char * sName
OUString m_sStyleName
Definition: xmltble.cxx:72
void DeleteTableLines()
Definition: xmltble.cxx:1266
constexpr TypedWhichId< SwFormatRowSplit > RES_ROW_SPLIT(122)
void ExportFormat(const SwFormat &rFormat, enum::xmloff::token::XMLTokenEnum eClass)
Definition: xmlfmte.cxx:49
sal_uInt32 m_nPrefix
Definition: xmltble.cxx:513
SvtSaveOptions::ODFSaneDefaultVersion getSaneDefaultVersion() const
XML_IS_SUB_TABLE
XML_PROTECTED
XML_NUMBER_COLUMNS_REPEATED
bool IsBaseSectionValid() const
Definition: xmltble.cxx:522
XML_TABLE_COLUMN_PROPERTIES
virtual css::uno::Sequence< OUString > SAL_CALL getCellNames() override
Definition: unotbl.cxx:2064
static SwTable * FindTable(SwFrameFormat const *const pFormat)
Definition: swtable.cxx:1966
XML_TABLE_ROW
Style of a layout element.
Definition: frmfmt.hxx:59
bool IsShowProgress() const
Definition: xmlexp.hxx:128
SwXMLTableColumns_Impl m_aCols
Definition: xmltble.cxx:111
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
int i
static void lcl_xmltble_ClearName_Line(SwTableLine *pLine)
Definition: xmltble.cxx:1111
constexpr sal_uInt16 XML_NAMESPACE_TEXT
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:108
std::vector< const SwTableNode * > maTableNodes
Definition: xmltexte.hxx:41
const SwFrameFormat * GetTableFormat() const
Definition: xmltble.cxx:520
SwXMLTableLines_Impl(const SwTableLines &rLines)
Definition: xmltble.cxx:125
vector< SwFrameFormat * > SwXMLFrameFormats_Impl
Definition: xmltble.cxx:182
void ExportTableColumnStyle(const SwXMLTableColumn_Impl &rCol)
Definition: xmltble.cxx:543
XML_TABLE
bool hasSoftPageBreak() const
const SvXMLUnitConverter & GetTwipUnitConverter() const
Definition: xmlexp.hxx:139
sal_Int16 GetHoriOrient() const
Definition: fmtornt.hxx:87
SwXMLTableInfo_Impl(const SwTable *pTable, sal_uInt16 nPrefix)
Definition: xmltble.cxx:529
SwFrameFormat * GetFrameFormat()
Definition: swtable.hxx:380
sal_uInt32 m_nRelWidth
Definition: xmltble.cxx:73
Marks a node in the document model.
Definition: ndindex.hxx:32
SwFrameFormat * GetFrameFormat()
Definition: swtable.hxx:445
void ExportTableLines(const SwTableLines &rLines, SwXMLTableInfo_Impl &rTableInfo, sal_uInt32 nHeaderRows=0)
Definition: xmltble.cxx:1004
void ExportTableFormat(const SwFrameFormat &rFormat, sal_uInt32 nAbsWidth)
Definition: xmliteme.cxx:244
const_iterator end() const
OUString GetQNameByKey(sal_uInt16 nKey, const OUString &rLocalName, bool bCache=true) const
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:123
sal_uInt8 GetWidthPercent() const
Definition: fmtfsize.hxx:91
tools::Long GetHeight() const
void SetBaseSection(const Reference< XTextSection > &rBase)
Definition: xmltble.cxx:536
const SwTableLines * GetLines() const
Definition: xmltble.cxx:120
virtual void exportTable(const css::uno::Reference< css::text::XTextContent > &rTextContent, bool bAutoStyles, bool bProgress) override
Definition: xmltble.cxx:1204
SwTableLines & GetTabLines()
Definition: swtable.hxx:202
const SvXMLNamespaceMap & GetNamespaceMap() const
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:113
XML_FAMILY
const SwXMLTableColumns_Impl & GetColumns() const
Definition: xmltble.cxx:122
XML_COVERED_TABLE_CELL
SwTableLines & GetTabLines()
Definition: swtable.hxx:438
XML_TRUE
const SwTable * m_pTable
Definition: xmltble.cxx:510
sal_uInt16 GetPrefix() const
The namespace (table or loext) that should be used for the elements.
Definition: xmltble.cxx:526
OUString EncodeStyleName(const OUString &rName, bool *pEncoded=nullptr) const
void ClearAttrList()
SwTableBoxes & GetTabBoxes()
Definition: swtable.hxx:368
void ExportTable(const SwTableNode &rTableNd)
Definition: xmltble.cxx:1117
void ExportTableLine(const SwTableLine &rLine, const SwXMLTableLines_Impl &rLines, SwXMLTableInfo_Impl &rTableInfo)
Definition: xmltble.cxx:916
std::vector< SwTableBox * > SwTableBoxes
Definition: swtable.hxx:106
XML_TABLE_HEADER_ROWS
const SwStartNode * GetSttNd() const
Definition: swtable.hxx:459
XML_TABLE_COLUMN
constexpr sal_uInt16 XML_NAMESPACE_TABLE
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
XML_COLUMN_WIDTH
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
static void FillProgName(const OUString &rName, OUString &rFillName, SwGetPoolIdFromName)
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:406
const OUString & GetStyleName() const
Definition: xmltble.cxx:83
void * p
XML_DDE_TOPIC
XML_STYLE_NAME
sal_Int16 GetVertOrient() const
Definition: fmtornt.hxx:54
constexpr TypedWhichId< SvxBoxItem > RES_BOX(106)
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:104
sal_uInt32 GetWidth() const
Definition: xmltble.cxx:119
sal_uInt32 GetValue() const
XML_STRING
static void lcl_xmltble_ClearName_Box(SwTableBox *pBox)
Definition: xmltble.cxx:1096
void ExportTableBox(const SwTableBox &rBox, sal_uInt32 nColSpan, sal_uInt32 nRowSpan, SwXMLTableInfo_Impl &rTableInfo)
Definition: xmltble.cxx:784
XML_SOFT_PAGE_BREAK
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:120
std::pair< const_iterator, bool > insert(Value &&x)
void SetStyleName(const OUString &rName)
Definition: xmltble.cxx:82
constexpr sal_uInt16 XML_NAMESPACE_OOOW
virtual OUString GetName() const override
Only in derived classes.
Definition: ddefld.cxx:213
SvXMLExportFlags getExportFlags() const
XML_DDE_SOURCE
SwFrameFormat * GetFlyFormat() const
If node is in a fly return the respective format.
Definition: node.cxx:719
void convertMeasureToXML(OUStringBuffer &rBuffer, sal_Int32 nMeasure) const
constexpr sal_uInt32 getSwDefaultTextFormat()
The number formatter's default locale's @ Text format.
Definition: cellatr.hxx:34
bool AddRow(SwFrameFormat &rFrameFormat, std::u16string_view rNamePrefix, sal_uInt32 nLine)
Definition: xmltble.cxx:194
constexpr sal_uInt16 XML_NAMESPACE_STYLE
XML_STYLE
const Size & GetSize() const
virtual css::uno::Reference< css::table::XCell > SAL_CALL getCellByName(const OUString &aCellName) override
Definition: unotbl.cxx:2053
std::vector< SwXMLTableColumn_Impl * >::const_iterator const_iterator
void SetNumberFormatAttributes(const sal_Int32 nNumberFormat, const double &rValue, bool bExportValue=true, sal_uInt16 nNamespace=XML_NAMESPACE_OFFICE, bool bExportCurrencySymbol=true)
XML_NAME
sal_uInt32 GetPos() const
Definition: wrtswtbl.hxx:172
SwFrameSize GetHeightSizeType() const
Definition: fmtfsize.hxx:80
std::unique_ptr< SwXMLTableLinesCache_Impl > m_pTableLines
Definition: xmlexp.hxx:54
SwTableNode * GetTableNode() const
Definition: swtable.cxx:1973
SW_DLLPUBLIC SwFrameFormat * GetFrameFormat()
Definition: unotbl.cxx:2014