LibreOffice Module xmloff (master)  1
XMLTableExport.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 
21 
22 #include <sal/config.h>
23 #include <sal/log.hxx>
24 #include <osl/diagnose.h>
25 
26 #include <rtl/ustring.hxx>
27 
28 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
29 #include <com/sun/star/text/XText.hpp>
30 #include <com/sun/star/table/XCellRange.hpp>
31 #include <com/sun/star/table/XColumnRowRange.hpp>
32 #include <com/sun/star/table/XMergeableCell.hpp>
33 #include <com/sun/star/style/XStyle.hpp>
34 #include <com/sun/star/beans/XPropertySet.hpp>
35 #include <com/sun/star/beans/XPropertySetInfo.hpp>
36 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37 #include <tools/diagnose_ex.h>
38 
39 #include <xmloff/xmlnmspe.hxx>
40 #include <xmloff/xmlprmap.hxx>
41 #include <xmloff/xmlexppr.hxx>
42 #include <xmloff/xmlexp.hxx>
43 #include <xmloff/xmltypes.hxx>
44 #include <xmlsdtypes.hxx>
45 #include <xmloff/maptype.hxx>
46 #include <xmloff/prhdlfac.hxx>
47 #include <xmloff/txtprmap.hxx>
48 #include "table.hxx"
49 
50 using namespace ::xmloff::token;
51 using namespace ::com::sun::star::uno;
52 using namespace ::com::sun::star::lang;
53 using namespace ::com::sun::star::table;
54 using namespace ::com::sun::star::beans;
55 using namespace ::com::sun::star::container;
56 using namespace ::com::sun::star::text;
57 using namespace ::com::sun::star::style;
58 
59 #define MAP_(name,prefix,token,type,context) { name, sizeof(name)-1, prefix, token, type, context, SvtSaveOptions::ODFVER_010, false }
60 #define CMAP(name,prefix,token,type,context) MAP_(name,prefix,token,type|XML_TYPE_PROP_TABLE_COLUMN,context)
61 #define RMAP(name,prefix,token,type,context) MAP_(name,prefix,token,type|XML_TYPE_PROP_TABLE_ROW,context)
62 #define CELLMAP(name,prefix,token,type,context) MAP_(name,prefix,token,type|XML_TYPE_PROP_TABLE_CELL,context)
63 #define MAP_END { nullptr, 0, 0, XML_EMPTY, 0, 0, SvtSaveOptions::ODFVER_010, false }
64 
66 {
67  static const XMLPropertyMapEntry aXMLColumnProperties[] =
68  {
71  MAP_END
72  };
73 
74  return &aXMLColumnProperties[0];
75 }
76 
78 {
79  static const XMLPropertyMapEntry aXMLRowProperties[] =
80  {
84  MAP_END
85  };
86 
87  return &aXMLRowProperties[0];
88 }
89 
91 {
92  static const XMLPropertyMapEntry aXMLCellProperties[] =
93  {
95  MAP_END
96  };
97 
98  return &aXMLCellProperties[0];
99 }
100 
101 namespace {
102 
103 class StringStatisticHelper
104 {
105 private:
106  std::map< OUString, sal_Int32 > mStats;
107 
108 public:
109  void add( const OUString& rStyleName );
110  void clear() { mStats.clear(); }
111 
112  sal_Int32 getModeString( /* out */ OUString& rModeString );
113 };
114 
115 }
116 
117 void StringStatisticHelper::add( const OUString& rStyleName )
118 {
119  std::map< OUString, sal_Int32 >::iterator iter( mStats.find( rStyleName ) );
120  if( iter == mStats.end() )
121  {
122  mStats[rStyleName] = 1;
123  }
124  else
125  {
126  (*iter).second += 1;
127  }
128 }
129 
130 sal_Int32 StringStatisticHelper::getModeString( OUString& rStyleName )
131 {
132  sal_Int32 nMax = 0;
133  for( const auto& rStatsEntry : mStats )
134  {
135  if( rStatsEntry.second > nMax )
136  {
137  rStyleName = rStatsEntry.first;
138  nMax = rStatsEntry.second;
139  }
140  }
141 
142  return nMax;
143 }
144 
145 
147 : mrExport( rExp )
148 , mbExportTables( false )
149 , mbWriter( false )
150 {
151  Reference< XMultiServiceFactory > xFac( rExp.GetModel(), UNO_QUERY );
152  if( xFac.is() ) try
153  {
154  Sequence< OUString > sSNS( xFac->getAvailableServiceNames() );
155  const OUString* pSNS = std::find_if(sSNS.begin(), sSNS.end(),
156  [](const OUString& rSNS) {
157  return rSNS == "com.sun.star.drawing.TableShape"
158  || rSNS == "com.sun.star.style.TableStyle"; });
159  if (pSNS != sSNS.end())
160  {
161  mbExportTables = true;
162  mbWriter = (*pSNS == "com.sun.star.style.TableStyle");
163  }
164  }
165  catch(const Exception&)
166  {
167  }
168 
169  if (mbWriter)
170  {
172  }
173  else
174  {
175  mxCellExportPropertySetMapper = xExportPropertyMapper;
177  mxCellExportPropertySetMapper->ChainExportMapper(new SvXMLExportPropertyMapper(new XMLPropertySetMapper(getCellPropertiesMap(), xFactoryRef.get(), true)));
178  }
179 
182 
195 }
196 
198 {
199 }
200 
201 static bool has_states( const std::vector< XMLPropertyState >& xPropStates )
202 {
203  return std::any_of(xPropStates.cbegin(), xPropStates.cend(),
204  [](const XMLPropertyState& rPropertyState) { return rPropertyState.mnIndex != -1; });
205 }
206 
207  void XMLTableExport::collectTableAutoStyles(const Reference < XColumnRowRange >& xColumnRowRange)
208  {
209  if( !mbExportTables )
210  return;
211 
212  auto xTableInfo = std::make_shared<XMLTableInfo>();
213  maTableInfoMap[xColumnRowRange] = xTableInfo;
214 
215  try
216  {
217  Reference< XIndexAccess > xIndexAccessCols( xColumnRowRange->getColumns(), UNO_QUERY_THROW );
218  const sal_Int32 nColumnCount = xIndexAccessCols->getCount();
219  for( sal_Int32 nColumn = 0; nColumn < nColumnCount; ++nColumn ) try
220  {
221  Reference< XPropertySet > xPropSet( xIndexAccessCols->getByIndex(nColumn) , UNO_QUERY_THROW );
222  std::vector< XMLPropertyState > aPropStates( mxColumnExportPropertySetMapper->Filter( xPropSet ) );
223 
224  if( has_states( aPropStates ) )
225  {
226  const OUString sStyleName( mrExport.GetAutoStylePool()->Add(XmlStyleFamily::TABLE_COLUMN, aPropStates) );
227  Reference< XInterface > xKey( xPropSet, UNO_QUERY );
228  xTableInfo->maColumnStyleMap[xKey] = sStyleName;
229  }
230  }
231  catch(const Exception&)
232  {
233  OSL_FAIL("xmloff::XMLTableExport::collectTableAutoStyles(), exception during column style collection!");
234  }
235 
236  Reference< XIndexAccess > xIndexAccessRows( xColumnRowRange->getRows(), UNO_QUERY_THROW );
237  const sal_Int32 nRowCount = xIndexAccessRows->getCount();
238  xTableInfo->maDefaultRowCellStyles.resize(nRowCount);
239 
240  StringStatisticHelper aStringStatistic;
241 
242  for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow )
243  try
244  {
245  Reference< XPropertySet > xPropSet( xIndexAccessRows->getByIndex(nRow) , UNO_QUERY_THROW );
246  std::vector< XMLPropertyState > aRowPropStates( mxRowExportPropertySetMapper->Filter( xPropSet ) );
247 
248  if( has_states( aRowPropStates ) )
249  {
250  const OUString sStyleName( mrExport.GetAutoStylePool()->Add(XmlStyleFamily::TABLE_ROW, aRowPropStates) );
251  Reference< XInterface > xKey( xPropSet, UNO_QUERY );
252  xTableInfo->maRowStyleMap[xKey] = sStyleName;
253  }
254 
255  // get the current row
256  Reference< XCellRange > xCellRange( xPropSet, UNO_QUERY_THROW );
257  for ( sal_Int32 nColumn = 0; nColumn < nColumnCount; ++nColumn )
258  {
259  // get current cell, remarks row index is 0, because we get the range for each row separate
260  Reference< XPropertySet > xCellSet( xCellRange->getCellByPosition(nColumn, 0), UNO_QUERY_THROW );
261 
262  // get style
263  OUString sParentStyleName;
264  Reference< XPropertySetInfo > xPropertySetInfo( xCellSet->getPropertySetInfo() );
265  if( xPropertySetInfo.is() && xPropertySetInfo->hasPropertyByName("Style") )
266  {
267  Reference< XStyle > xStyle( xCellSet->getPropertyValue("Style"), UNO_QUERY );
268  if( xStyle.is() )
269  sParentStyleName = xStyle->getName();
270  }
271 
272  // create auto style, if needed
273  OUString sStyleName;
274  std::vector< XMLPropertyState > aCellPropStates( mxCellExportPropertySetMapper->Filter( xCellSet ) );
275  if( has_states( aCellPropStates ) )
276  sStyleName = mrExport.GetAutoStylePool()->Add(XmlStyleFamily::TABLE_CELL, aCellPropStates);
277  else
278  sStyleName = sParentStyleName;
279 
280  if( !sStyleName.isEmpty() )
281  {
282  Reference< XInterface > xKey( xCellSet, UNO_QUERY );
283  xTableInfo->maCellStyleMap[xKey] = sStyleName;
284  }
285 
286  // create auto style for text
287  Reference< XText > xText(xCellSet, UNO_QUERY);
288  if(xText.is() && !xText->getString().isEmpty())
289  GetExport().GetTextParagraphExport()->collectTextAutoStyles( xText );
290 
291  aStringStatistic.add( sStyleName );
292  }
293 
294  OUString sDefaultCellStyle;
295  if( aStringStatistic.getModeString( sDefaultCellStyle ) > 1 )
296  xTableInfo->maDefaultRowCellStyles[nRow] = sDefaultCellStyle;
297 
298  aStringStatistic.clear();
299  }
300  catch(const Exception&)
301  {
302  OSL_FAIL("xmloff::XMLTableExport::collectTableAutoStyles(), exception during column style collection!");
303  }
304  }
305  catch(const Exception&)
306  {
307  OSL_FAIL("xmloff::XMLTableExport::collectTableAutoStyles(), exception caught!");
308  }
309  }
310 
311  void XMLTableExport::exportTable( const Reference < XColumnRowRange >& xColumnRowRange )
312  {
313  if( !mbExportTables )
314  return;
315 
316  try
317  {
318  std::shared_ptr< XMLTableInfo > xTableInfo( maTableInfoMap[xColumnRowRange] );
319 
320  // get row and column count
321  Reference< XIndexAccess > xIndexAccess( xColumnRowRange->getRows(), UNO_QUERY_THROW );
322  Reference< XIndexAccess > xIndexAccessCols( xColumnRowRange->getColumns(), UNO_QUERY_THROW );
323 
324  const sal_Int32 rowCount = xIndexAccess->getCount();
325  const sal_Int32 columnCount = xIndexAccessCols->getCount();
326 
327  SvXMLElementExport tableElement( mrExport, XML_NAMESPACE_TABLE, XML_TABLE, true, true );
328 
329  // export table columns
330  ExportTableColumns( xIndexAccessCols, xTableInfo );
331 
332  // start iterating rows and columns
333  for ( sal_Int32 rowIndex = 0; rowIndex < rowCount; rowIndex++ )
334  {
335  // get the current row
336  Reference< XCellRange > xCellRange( xIndexAccess->getByIndex(rowIndex), UNO_QUERY_THROW );
337 
338  OUString sDefaultCellStyle;
339 
340  // table:style-name
341  if( xTableInfo.get() )
342  {
343  Reference< XInterface > xKey( xCellRange, UNO_QUERY );
344  const OUString sStyleName( xTableInfo->maRowStyleMap[xKey] );
345  if( !sStyleName.isEmpty() )
347 
348  sDefaultCellStyle = xTableInfo->maDefaultRowCellStyles[rowIndex];
349  if( !sDefaultCellStyle.isEmpty() )
351  }
352 
353  // write row element
354  SvXMLElementExport tableRowElement( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_ROW, true, true );
355 
356  for ( sal_Int32 columnIndex = 0; columnIndex < columnCount; columnIndex++ )
357  {
358  // get current cell, remarks row index is 0, because we get the range for each row separate
359  Reference< XCell > xCell( xCellRange->getCellByPosition(columnIndex, 0), UNO_SET_THROW );
360 
361  // use XMergeableCell interface from offapi
362  Reference< XMergeableCell > xMergeableCell( xCell, UNO_QUERY_THROW );
363 
364  // export cell
365  ExportCell( xCell, xTableInfo, sDefaultCellStyle );
366  }
367  }
368  }
369  catch(const Exception&)
370  {
371  OSL_FAIL( "XMLTableExport::exportTable(), exception caught!" );
372  }
373  }
374 
375 // Export the table columns
376 
377  void XMLTableExport::ExportTableColumns( const Reference < XIndexAccess >& xtableColumnsIndexAccess, const std::shared_ptr< XMLTableInfo >& rTableInfo )
378  {
379  const sal_Int32 nColumnCount = xtableColumnsIndexAccess->getCount();
380  for( sal_Int32 nColumn = 0; nColumn < nColumnCount; ++nColumn )
381  {
382  Reference< XPropertySet > xColumnProperties( xtableColumnsIndexAccess->getByIndex(nColumn) , UNO_QUERY );
383  if ( xColumnProperties.is() )
384  {
385  // table:style-name
386  if( rTableInfo.get() )
387  {
388  Reference< XInterface > xKey( xColumnProperties, UNO_QUERY );
389  const OUString sStyleName( rTableInfo->maColumnStyleMap[xKey] );
390  if( !sStyleName.isEmpty() )
392  }
393 
394  // TODO: all columns first have to be checked if someone
395  // have identical properties. If yes, attr table:number-columns-repeated
396  // has to be written.
397  SvXMLElementExport tableColumnElement( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, true, true );
398  }
399  }
400  }
401 
402 // ODF export for a table cell.
403 
404  void XMLTableExport::ExportCell( const Reference < XCell >& xCell, const std::shared_ptr< XMLTableInfo >& rTableInfo, const OUString& rDefaultCellStyle )
405  {
406  bool bIsMerged = false;
407  sal_Int32 nRowSpan = 0;
408  sal_Int32 nColSpan = 0;
409 
410  try
411  {
412  if( rTableInfo.get() )
413  {
414  // table:style-name
415  Reference< XInterface > xKey( xCell, UNO_QUERY );
416  const OUString sStyleName( rTableInfo->maCellStyleMap[xKey] );
417  if( !sStyleName.isEmpty() && (sStyleName != rDefaultCellStyle) )
419  }
420 
421  Reference< XMergeableCell > xMerge( xCell, UNO_QUERY );
422  if( xMerge.is() )
423  {
424  bIsMerged = xMerge->isMerged();
425  nRowSpan = xMerge->getRowSpan();
426  nColSpan = xMerge->getColumnSpan();
427  }
428  SAL_WARN_IF( (nRowSpan < 1) || (nColSpan < 1), "xmloff", "xmloff::XMLTableExport::ExportCell(), illegal row or col span < 1?" );
429  }
430  catch (const Exception&)
431  {
432  OSL_FAIL( "exception while exporting a table cell" );
433  }
434 
435  // table:number-columns-repeated
436  // todo
437 
438  // table:number-columns-spanned
439  if( nColSpan > 1 )
440  mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_SPANNED, OUString::number( nColSpan ) );
441 
442  // table:number-rows-spanned
443  if( nRowSpan > 1 )
444  mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_SPANNED, OUString::number( nRowSpan ) );
445 
446  // <table:table-cell> or <table:covered-table-cell>
447  SvXMLElementExport tableCellElement( mrExport, XML_NAMESPACE_TABLE, bIsMerged ? XML_COVERED_TABLE_CELL : XML_TABLE_CELL, true, true );
448 
449  // export cells text content
450  ImpExportText( xCell );
451  }
452 
453 // ODF export of the text contents of a table cell.
454 // Remarks: Up to now we only export text contents!
455 // TODO: Check against nested tables...
456 
457  void XMLTableExport::ImpExportText( const Reference< XCell >& xCell )
458  {
459  Reference< XText > xText( xCell, UNO_QUERY );
460  if( xText.is() && !xText->getString().isEmpty())
461  mrExport.GetTextParagraphExport()->exportText( xText );
462  }
463 
465 {
466  if( !mbExportTables )
467  return;
468 
470  OUString sCellStyleName;
471  if (mbWriter)
472  {
473  sCellStyleName = "CellStyles";
474  aStEx.set(new XMLStyleExport(mrExport));
475  }
476  else
477  {
478  // write graphic family styles
479  sCellStyleName = "cell";
480  aStEx.set(new XMLStyleExport(mrExport, mrExport.GetAutoStylePool().get()));
481  }
482 
483  aStEx->exportStyleFamily(sCellStyleName, OUString(XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME), mxCellExportPropertySetMapper.get(), true, XmlStyleFamily::TABLE_CELL);
484 
486 }
487 
488 // Export the collected automatic styles
489 
491 {
492  if( !mbExportTables )
493  return;
494 
498 }
499 
501 {
502  static const struct TableStyleElement gTableStyleElements[] =
503  {
504  { XML_FIRST_ROW, OUString("first-row") },
505  { XML_LAST_ROW, OUString("last-row") },
506  { XML_FIRST_COLUMN, OUString("first-column") },
507  { XML_LAST_COLUMN, OUString("last-column") },
508  { XML_BODY, OUString("body") },
509  { XML_EVEN_ROWS, OUString("even-rows") },
510  { XML_ODD_ROWS, OUString("odd-rows") },
511  { XML_EVEN_COLUMNS, OUString("even-columns") },
512  { XML_ODD_COLUMNS, OUString("odd-columns") },
513  { XML_BACKGROUND, OUString("background") },
514  { XML_TOKEN_END, OUString() }
515  };
516 
517  return &gTableStyleElements[0];
518 }
519 
521 {
522  static const struct TableStyleElement gWriterSpecificTableStyleElements[] =
523  {
524  { XML_FIRST_ROW_EVEN_COLUMN, OUString("first-row-even-column") },
525  { XML_LAST_ROW_EVEN_COLUMN, OUString("last-row-even-column") },
526  { XML_FIRST_ROW_END_COLUMN, OUString("first-row-end-column") },
527  { XML_FIRST_ROW_START_COLUMN, OUString("first-row-start-column") },
528  { XML_LAST_ROW_END_COLUMN, OUString("last-row-end-column") },
529  { XML_LAST_ROW_START_COLUMN, OUString("last-row-start-column") },
530  { XML_TOKEN_END, OUString() }
531  };
532 
533  return &gWriterSpecificTableStyleElements[0];
534 }
535 
537 {
538  static const struct TableStyleElement gWriterSpecifitTableStyleAttributes[] =
539  {
540  { XML_FIRST_ROW_END_COLUMN, OUString("FirstRowEndColumn") },
541  { XML_FIRST_ROW_START_COLUMN, OUString("FirstRowStartColumn") },
542  { XML_LAST_ROW_END_COLUMN, OUString("LastRowEndColumn") },
543  { XML_LAST_ROW_START_COLUMN, OUString("LastRowStartColumn") },
544  { XML_TOKEN_END, OUString() }
545  };
546 
547  return &gWriterSpecifitTableStyleAttributes[0];
548 }
549 
551 {
552  if( !mbExportTables )
553  return;
554 
555  try
556  {
557  Reference< XStyleFamiliesSupplier > xFamiliesSupp( mrExport.GetModel(), UNO_QUERY_THROW );
558  Reference< XNameAccess > xFamilies( xFamiliesSupp->getStyleFamilies() );
559  OUString sFamilyName;
560  if (mbWriter)
561  sFamilyName = "TableStyles";
562  else
563  sFamilyName = "table";
564 
565  Reference< XIndexAccess > xTableFamily( xFamilies->getByName( sFamilyName ), UNO_QUERY_THROW );
566 
567  for( sal_Int32 nIndex = 0; nIndex < xTableFamily->getCount(); nIndex++ ) try
568  {
570 
571  Reference< XStyle > xTableStyle( xTableFamily->getByIndex( nIndex ), UNO_QUERY_THROW );
572  if( !xTableStyle->isInUse() )
573  continue;
574 
575  const TableStyleElement* pElements;
576  if (mbWriter)
577  {
578  mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, xTableStyle->getName());
579  Reference<XPropertySet> xTableStylePropSet(xTableStyle, UNO_QUERY_THROW);
581  while(pElements->meElement != XML_TOKEN_END)
582  {
583  try
584  {
585  OUString sVal;
586  xTableStylePropSet->getPropertyValue(pElements->msStyleName) >>= sVal;
588  }
589  catch(const Exception&)
590  {
591  TOOLS_WARN_EXCEPTION("xmloff", "XMLTableExport::exportTableTemplates(), export Writer specific attributes, exception caught!");
592  }
593  pElements++;
594  }
595  }
596  else
597  {
598  // checks if any of the extended version of ODF are set
599  if ((eVersion & SvtSaveOptions::ODFSVER_EXTENDED) != 0)
600  {
601  // tdf#106780 historically this wrong attribute was used
602  // for the name; write it if extended because LO < 5.3 can
603  // read only text:style-name, not the correct table:name
604  mrExport.AddAttribute(XML_NAMESPACE_TEXT, XML_STYLE_NAME, GetExport().EncodeStyleName( xTableStyle->getName() ) );
605  }
606  mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, GetExport().EncodeStyleName(xTableStyle->getName()));
607  }
608 
609  SvXMLElementExport tableTemplate( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_TEMPLATE, true, true );
610 
611  Reference< XNameAccess > xStyleNames( xTableStyle, UNO_QUERY_THROW );
612  pElements = getTableStyleMap();
613  while( pElements->meElement != XML_TOKEN_END )
614  {
615  try
616  {
617  Reference< XStyle > xStyle( xStyleNames->getByName( pElements->msStyleName ), UNO_QUERY );
618  if( xStyle.is() )
619  {
620  mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_STYLE_NAME, GetExport().EncodeStyleName( xStyle->getName() ) );
621  SvXMLElementExport element( mrExport, XML_NAMESPACE_TABLE, pElements->meElement, true, true );
622  }
623  }
624  catch(const Exception&)
625  {
626  OSL_FAIL("xmloff::XMLTableExport::exportTableTemplates(), exception caught!");
627  }
628 
629  pElements++;
630  }
631 
632  if (mbWriter && ((eVersion & SvtSaveOptions::ODFSVER_EXTENDED) != 0))
633  {
634  pElements = getWriterSpecificTableStyleMap();
635  while(pElements->meElement != XML_TOKEN_END)
636  {
637  try
638  {
639  Reference<XStyle> xStyle(xStyleNames->getByName(pElements->msStyleName), UNO_QUERY);
640  if(xStyle.is())
641  {
642  mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_STYLE_NAME, GetExport().EncodeStyleName(xStyle->getName()));
643  SvXMLElementExport element(mrExport, XML_NAMESPACE_LO_EXT, pElements->meElement, true, true);
644  }
645  }
646  catch(const Exception&)
647  {
648  TOOLS_WARN_EXCEPTION("xmloff", "XMLTableExport::exportTableTemplates(), export Writer specific styles, exception caught!");
649  }
650  pElements++;
651  }
652  }
653  }
654  catch(const Exception&)
655  {
656  TOOLS_WARN_EXCEPTION("xmloff", "XMLTableExport::exportTableDesigns(), exception caught while exporting a table design!");
657  }
658  }
659  catch(const Exception&)
660  {
661  TOOLS_WARN_EXCEPTION("xmloff", "XMLTableExport::exportTableDesigns()");
662  }
663 }
664 
665 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const XMLPropertyMapEntry * getRowPropertiesMap()
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
Definition: xmlnmspe.hxx:74
#define XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_NAME
Definition: families.hxx:30
static bool has_states(const std::vector< XMLPropertyState > &xPropStates)
#define XML_SD_TYPE_CELL_ROTATION_ANGLE
Definition: xmlsdtypes.hxx:121
constexpr sal_uInt16 XML_NAMESPACE_STYLE
Definition: xmlnmspe.hxx:29
void exportTableTemplates()
::xmloff::token::XMLTokenEnum const meElement
Definition: table.hxx:29
sal_Int32 nIndex
void exportTable(const css::uno::Reference< css::table::XColumnRowRange > &xColumnRowRange)
rtl::Reference< XMLTextParagraphExport > const & GetTextParagraphExport()
Definition: xmlexp.hxx:560
rtl::Reference< SvXMLExportPropertyMapper > mxColumnExportPropertySetMapper
#define XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_PREFIX
Definition: families.hxx:31
constexpr sal_uInt16 XML_NAMESPACE_TEXT
Definition: xmlnmspe.hxx:30
XMLTableExport(SvXMLExport &rExp, const rtl::Reference< SvXMLExportPropertyMapper > &xCellExportPropertySetMapper, const rtl::Reference< XMLPropertyHandlerFactory > &xFactoryRef)
SvXMLExport & GetExport()
#define RMAP(name, prefix, token, type, context)
#define XML_STYLE_FAMILY_TABLE_CELL_STYLES_PREFIX
Definition: families.hxx:35
const css::uno::Reference< css::frame::XModel > & GetModel() const
Definition: xmlexp.hxx:414
void ExportCell(const css::uno::Reference< css::table::XCell > &xCell, const std::shared_ptr< XMLTableInfo > &pTableInfo, const OUString &sDefaultCellStyle)
SvXMLExport & mrExport
void AddAttribute(sal_uInt16 nPrefix, const char *pName, const OUString &rValue)
Definition: xmlexp.cxx:923
#define CMAP(name, prefix, token, type, context)
#define XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME
Definition: families.hxx:34
SvtSaveOptions::ODFSaneDefaultVersion getSaneDefaultVersion() const
returns the deterministic version for odf export
Definition: xmlexp.cxx:2278
#define CELLMAP(name, prefix, token, type, context)
#define TOOLS_WARN_EXCEPTION(area, stream)
const TableStyleElement * getTableStyleMap()
#define MAP_END
Represents a property with its API-name, its XML-name and the type of its value.
Definition: maptype.hxx:31
OUString msStyleName
Definition: table.hxx:30
void collectTableAutoStyles(const css::uno::Reference< css::table::XColumnRowRange > &xColumnRowRange)
const TableStyleElement * getWriterSpecificTableStyleMap()
SAL_DLLPRIVATE void ImpExportText(const css::uno::Reference< css::table::XCell > &xCell)
std::map< const css::uno::Reference< css::table::XColumnRowRange >, std::shared_ptr< XMLTableInfo > > maTableInfoMap
#define SAL_WARN_IF(condition, area, stream)
static const TableStyleElement * getWriterSpecificTableStyleAttributes()
rtl::Reference< SvXMLExportPropertyMapper > mxRowExportPropertySetMapper
rtl::Reference< SvXMLAutoStylePoolP > const & GetAutoStylePool()
Definition: xmlexp.hxx:576
constexpr sal_uInt16 XML_NAMESPACE_TABLE
Definition: xmlnmspe.hxx:31
#define XML_STYLE_FAMILY_TABLE_ROW_STYLES_PREFIX
Definition: families.hxx:33
#define XML_TYPE_MEASURE
Definition: xmltypes.hxx:126
const XMLPropertyMapEntry * getCellPropertiesMap()
Smart struct to transport an Any with an index to the appropriate property-name.
Definition: maptype.hxx:104
const XMLPropertyMapEntry * getColumnPropertiesMap()
#define XML_STYLE_FAMILY_TABLE_ROW_STYLES_NAME
Definition: families.hxx:32
virtual ~XMLTableExport() override
static SvXMLExportPropertyMapper * CreateParaExtPropMapper(SvXMLExport &rExport)
Definition: txtparae.cxx:1353
#define XML_TYPE_BOOL
Definition: xmltypes.hxx:125
rtl::Reference< SvXMLExportPropertyMapper > mxCellExportPropertySetMapper
void ExportTableColumns(const css::uno::Reference< css::container::XIndexAccess > &xtableColumns, const std::shared_ptr< XMLTableInfo > &pTableInfo)