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
25#include <rtl/ustring.hxx>
26#include <com/sun/star/frame/XModel.hpp>
27#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
28#include <com/sun/star/text/XText.hpp>
29#include <com/sun/star/table/XCellRange.hpp>
30#include <com/sun/star/table/XColumnRowRange.hpp>
31#include <com/sun/star/table/XMergeableCell.hpp>
32#include <com/sun/star/style/XStyle.hpp>
33#include <com/sun/star/beans/XPropertyState.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
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
50using namespace ::xmloff::token;
51using namespace ::com::sun::star::uno;
52using namespace ::com::sun::star::lang;
53using namespace ::com::sun::star::table;
54using namespace ::com::sun::star::beans;
55using namespace ::com::sun::star::container;
56using namespace ::com::sun::star::text;
57using namespace ::com::sun::star::style;
58
59#define MAP_(name,prefix,token,type,context) { name, prefix, token, type, context, SvtSaveOptions::ODFSVER_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, XML_EMPTY, 0, 0, SvtSaveOptions::ODFSVER_010, false }
64
66{
67 static const XMLPropertyMapEntry aXMLColumnProperties[] =
68 {
72 };
73
74 return &aXMLColumnProperties[0];
75}
76
78{
79 static const XMLPropertyMapEntry aXMLRowProperties[] =
80 {
85 };
86
87 return &aXMLRowProperties[0];
88}
89
91{
92 static const XMLPropertyMapEntry aXMLCellProperties[] =
93 {
96 };
97
98 return &aXMLCellProperties[0];
99}
100
101namespace {
102
103class StringStatisticHelper
104{
105private:
106 std::map< OUString, sal_Int32 > mStats;
107
108public:
109 void add( const OUString& rStyleName );
110 void clear() { mStats.clear(); }
111
112 sal_Int32 getModeString( /* out */ OUString& rModeString );
113};
114
115}
116
117void 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
130sal_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
145namespace {
146
147class XMLCellExportPropertyMapper : public SvXMLExportPropertyMapper
148{
149public:
154 const SvXMLNamespaceMap&, const std::vector<XMLPropertyState>*, sal_uInt32) const override
155 {
156 // the SpecialItem NumberFormat must not be handled by this method
157 }
158};
159
160}
161
163: mrExport( rExp )
164, mbExportTables( false )
165, mbWriter( false )
166{
167 Reference< XMultiServiceFactory > xFac( rExp.GetModel(), UNO_QUERY );
168 if( xFac.is() ) try
169 {
170 const Sequence< OUString > sSNS( xFac->getAvailableServiceNames() );
171 const OUString* pSNS = std::find_if(sSNS.begin(), sSNS.end(),
172 [](const OUString& rSNS) {
173 return rSNS == "com.sun.star.drawing.TableShape"
174 || rSNS == "com.sun.star.style.TableStyle"; });
175 if (pSNS != sSNS.end())
176 {
177 mbExportTables = true;
178 mbWriter = (*pSNS == "com.sun.star.style.TableStyle");
179 }
180 }
181 catch(const Exception&)
182 {
183 }
184
185 if (mbWriter)
186 {
187 mxCellExportPropertySetMapper = new XMLCellExportPropertyMapper(new XMLTextPropertySetMapper(TextPropMap::CELL, true));
188 }
189 else
190 {
191 mxCellExportPropertySetMapper = xExportPropertyMapper;
194 }
195
198
211}
212
214{
215}
216
217static bool has_states( const std::vector< XMLPropertyState >& xPropStates )
218{
219 return std::any_of(xPropStates.cbegin(), xPropStates.cend(),
220 [](const XMLPropertyState& rPropertyState) { return rPropertyState.mnIndex != -1; });
221}
222
223 void XMLTableExport::collectTableAutoStyles(const Reference < XColumnRowRange >& xColumnRowRange)
224 {
225 if( !mbExportTables )
226 return;
227
228 auto xTableInfo = std::make_shared<XMLTableInfo>();
229 maTableInfoMap[xColumnRowRange] = xTableInfo;
230
231 try
232 {
233 Reference< XIndexAccess > xIndexAccessCols( xColumnRowRange->getColumns(), UNO_QUERY_THROW );
234 const sal_Int32 nColumnCount = xIndexAccessCols->getCount();
235 for( sal_Int32 nColumn = 0; nColumn < nColumnCount; ++nColumn ) try
236 {
237 Reference< XPropertySet > xPropSet( xIndexAccessCols->getByIndex(nColumn) , UNO_QUERY_THROW );
238 std::vector<XMLPropertyState> aPropStates(mxColumnExportPropertySetMapper->Filter(mrExport, xPropSet));
239
240 if( has_states( aPropStates ) )
241 {
242 const OUString sStyleName( mrExport.GetAutoStylePool()->Add(XmlStyleFamily::TABLE_COLUMN, std::move(aPropStates)) );
243 Reference< XInterface > xKey( xPropSet, UNO_QUERY );
244 xTableInfo->maColumnStyleMap[xKey] = sStyleName;
245 }
246 }
247 catch(const Exception&)
248 {
249 TOOLS_WARN_EXCEPTION("xmloff.table", "exception during column style collection!");
250 }
251
252 Reference< XIndexAccess > xIndexAccessRows( xColumnRowRange->getRows(), UNO_QUERY_THROW );
253 const sal_Int32 nRowCount = xIndexAccessRows->getCount();
254 xTableInfo->maDefaultRowCellStyles.resize(nRowCount);
255
256 StringStatisticHelper aStringStatistic;
257
258 for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow )
259 try
260 {
261 Reference< XPropertySet > xPropSet( xIndexAccessRows->getByIndex(nRow) , UNO_QUERY_THROW );
262 std::vector<XMLPropertyState> aRowPropStates(mxRowExportPropertySetMapper->Filter(mrExport, xPropSet));
263
264 if( has_states( aRowPropStates ) )
265 {
266 const OUString sStyleName( mrExport.GetAutoStylePool()->Add(XmlStyleFamily::TABLE_ROW, std::move(aRowPropStates)) );
267 Reference< XInterface > xKey( xPropSet, UNO_QUERY );
268 xTableInfo->maRowStyleMap[xKey] = sStyleName;
269 }
270
271 // get the current row
272 Reference< XCellRange > xCellRange( xPropSet, UNO_QUERY_THROW );
273 for ( sal_Int32 nColumn = 0; nColumn < nColumnCount; ++nColumn )
274 {
275 // get current cell, remarks row index is 0, because we get the range for each row separate
276 Reference< XPropertySet > xCellSet( xCellRange->getCellByPosition(nColumn, 0), UNO_QUERY_THROW );
277
278 // get style
279 OUString sParentStyleName;
280 Reference< XPropertySetInfo > xPropertySetInfo( xCellSet->getPropertySetInfo() );
281 if( xPropertySetInfo.is() && xPropertySetInfo->hasPropertyByName("Style") )
282 {
283 Reference< XStyle > xStyle( xCellSet->getPropertyValue("Style"), UNO_QUERY );
284 if( xStyle.is() )
285 sParentStyleName = xStyle->getName();
286 }
287
288 // create auto style, if needed
289 OUString sStyleName;
290 std::vector<XMLPropertyState> aCellPropStates(mxCellExportPropertySetMapper->Filter(mrExport, xCellSet));
291 if( has_states( aCellPropStates ) )
292 sStyleName = mrExport.GetAutoStylePool()->Add(XmlStyleFamily::TABLE_CELL, std::move(aCellPropStates));
293 else
294 sStyleName = sParentStyleName;
295
296 if( !sStyleName.isEmpty() )
297 {
298 Reference< XInterface > xKey( xCellSet, UNO_QUERY );
299 xTableInfo->maCellStyleMap[xKey] = sStyleName;
300 }
301
302 // create auto style for text
303 Reference< XText > xText(xCellSet, UNO_QUERY);
304 if(xText.is() && !xText->getString().isEmpty())
305 GetExport().GetTextParagraphExport()->collectTextAutoStyles( xText );
306
307 aStringStatistic.add( sStyleName );
308 }
309
310 OUString sDefaultCellStyle;
311 if( aStringStatistic.getModeString( sDefaultCellStyle ) > 1 )
312 xTableInfo->maDefaultRowCellStyles[nRow] = sDefaultCellStyle;
313
314 aStringStatistic.clear();
315 }
316 catch(const Exception&)
317 {
318 TOOLS_WARN_EXCEPTION("xmloff.table", "exception during column style collection!");
319 }
320 }
321 catch(const Exception&)
322 {
323 TOOLS_WARN_EXCEPTION("xmloff.table", "exception caught!");
324 }
325 }
326
327 void XMLTableExport::exportTable( const Reference < XColumnRowRange >& xColumnRowRange )
328 {
329 if( !mbExportTables )
330 return;
331
332 try
333 {
334 std::shared_ptr< XMLTableInfo > xTableInfo( maTableInfoMap[xColumnRowRange] );
335
336 // get row and column count
337 Reference< XIndexAccess > xIndexAccess( xColumnRowRange->getRows(), UNO_QUERY_THROW );
338 Reference< XIndexAccess > xIndexAccessCols( xColumnRowRange->getColumns(), UNO_QUERY_THROW );
339
340 const sal_Int32 rowCount = xIndexAccess->getCount();
341 const sal_Int32 columnCount = xIndexAccessCols->getCount();
342
343 SvXMLElementExport tableElement( mrExport, XML_NAMESPACE_TABLE, XML_TABLE, true, true );
344
345 // export table columns
346 ExportTableColumns( xIndexAccessCols, xTableInfo );
347
348 // start iterating rows and columns
349 for ( sal_Int32 rowIndex = 0; rowIndex < rowCount; rowIndex++ )
350 {
351 // get the current row
352 Reference< XCellRange > xCellRange( xIndexAccess->getByIndex(rowIndex), UNO_QUERY_THROW );
353
354 OUString sDefaultCellStyle;
355
356 // table:style-name
357 if( xTableInfo )
358 {
359 Reference< XInterface > xKey( xCellRange, UNO_QUERY );
360 const OUString sStyleName( xTableInfo->maRowStyleMap[xKey] );
361 if( !sStyleName.isEmpty() )
363
364 sDefaultCellStyle = xTableInfo->maDefaultRowCellStyles[rowIndex];
365 if( !sDefaultCellStyle.isEmpty() )
367 }
368
369 // write row element
370 SvXMLElementExport tableRowElement( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_ROW, true, true );
371
372 for ( sal_Int32 columnIndex = 0; columnIndex < columnCount; columnIndex++ )
373 {
374 // get current cell, remarks row index is 0, because we get the range for each row separate
375 Reference< XCell > xCell( xCellRange->getCellByPosition(columnIndex, 0), UNO_SET_THROW );
376
377 // use XMergeableCell interface from offapi
378 Reference< XMergeableCell > xMergeableCell( xCell, UNO_QUERY_THROW );
379
380 // export cell
381 ExportCell( xCell, xTableInfo, sDefaultCellStyle );
382 }
383 }
384 }
385 catch(const Exception&)
386 {
387 TOOLS_WARN_EXCEPTION("xmloff.table", "" );
388 }
389 }
390
391// Export the table columns
392
393 void XMLTableExport::ExportTableColumns( const Reference < XIndexAccess >& xtableColumnsIndexAccess, const std::shared_ptr< XMLTableInfo >& rTableInfo )
394 {
395 const sal_Int32 nColumnCount = xtableColumnsIndexAccess->getCount();
396 for( sal_Int32 nColumn = 0; nColumn < nColumnCount; ++nColumn )
397 {
398 Reference< XPropertySet > xColumnProperties( xtableColumnsIndexAccess->getByIndex(nColumn) , UNO_QUERY );
399 if ( xColumnProperties.is() )
400 {
401 // table:style-name
402 if( rTableInfo )
403 {
404 Reference< XInterface > xKey( xColumnProperties, UNO_QUERY );
405 const OUString sStyleName( rTableInfo->maColumnStyleMap[xKey] );
406 if( !sStyleName.isEmpty() )
408 }
409
410 // TODO: all columns first have to be checked if someone
411 // have identical properties. If yes, attr table:number-columns-repeated
412 // has to be written.
413 SvXMLElementExport tableColumnElement( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, true, true );
414 }
415 }
416 }
417
418// ODF export for a table cell.
419
420 void XMLTableExport::ExportCell( const Reference < XCell >& xCell, const std::shared_ptr< XMLTableInfo >& rTableInfo, std::u16string_view rDefaultCellStyle )
421 {
422 bool bIsMerged = false;
423 sal_Int32 nRowSpan = 0;
424 sal_Int32 nColSpan = 0;
425
426 try
427 {
428 if( rTableInfo )
429 {
430 // table:style-name
431 Reference< XInterface > xKey( xCell, UNO_QUERY );
432 const OUString sStyleName( rTableInfo->maCellStyleMap[xKey] );
433 if( !sStyleName.isEmpty() && (sStyleName != rDefaultCellStyle) )
435 }
436
437 Reference< XMergeableCell > xMerge( xCell, UNO_QUERY );
438 if( xMerge.is() )
439 {
440 bIsMerged = xMerge->isMerged();
441 nRowSpan = xMerge->getRowSpan();
442 nColSpan = xMerge->getColumnSpan();
443 }
444 SAL_WARN_IF( (nRowSpan < 1) || (nColSpan < 1), "xmloff", "xmloff::XMLTableExport::ExportCell(), illegal row or col span < 1?" );
445 }
446 catch (const Exception&)
447 {
448 TOOLS_WARN_EXCEPTION("xmloff.table", "exception while exporting a table cell");
449 }
450
451 // table:number-columns-repeated
452 // todo
453
454 // table:number-columns-spanned
455 if( nColSpan > 1 )
457
458 // table:number-rows-spanned
459 if( nRowSpan > 1 )
460 mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_SPANNED, OUString::number( nRowSpan ) );
461
462 // <table:table-cell> or <table:covered-table-cell>
463 SvXMLElementExport tableCellElement( mrExport, XML_NAMESPACE_TABLE, bIsMerged ? XML_COVERED_TABLE_CELL : XML_TABLE_CELL, true, true );
464
465 // export cells text content
466 ImpExportText( xCell );
467 }
468
469// ODF export of the text contents of a table cell.
470// Remarks: Up to now we only export text contents!
471// TODO: Check against nested tables...
472
473 void XMLTableExport::ImpExportText( const Reference< XCell >& xCell )
474 {
475 Reference< XText > xText( xCell, UNO_QUERY );
476 if( xText.is() && !xText->getString().isEmpty())
477 mrExport.GetTextParagraphExport()->exportText( xText );
478 }
479
481{
482 if( !mbExportTables )
483 return;
484
486 OUString sCellStyleName;
487 if (mbWriter)
488 {
489 sCellStyleName = "CellStyles";
490 aStEx.set(new XMLCellStyleExport(mrExport));
491 }
492 else
493 {
494 // write graphic family styles
495 sCellStyleName = "cell";
496 aStEx.set(new XMLStyleExport(mrExport, mrExport.GetAutoStylePool().get()));
497 }
498
499 aStEx->exportStyleFamily(sCellStyleName, OUString(XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME), mxCellExportPropertySetMapper, true, XmlStyleFamily::TABLE_CELL);
500
502}
503
504// Export the collected automatic styles
505
507{
508 if( !mbExportTables )
509 return;
510
514}
515
517{
518 static const struct TableStyleElement gTableStyleElements[] =
519 {
520 { XML_FIRST_ROW, OUString("first-row") },
521 { XML_LAST_ROW, OUString("last-row") },
522 { XML_FIRST_COLUMN, OUString("first-column") },
523 { XML_LAST_COLUMN, OUString("last-column") },
524 { XML_BODY, OUString("body") },
525 { XML_EVEN_ROWS, OUString("even-rows") },
526 { XML_ODD_ROWS, OUString("odd-rows") },
527 { XML_EVEN_COLUMNS, OUString("even-columns") },
528 { XML_ODD_COLUMNS, OUString("odd-columns") },
529 { XML_BACKGROUND, OUString("background") },
530 { XML_TOKEN_END, OUString() }
531 };
532
533 return &gTableStyleElements[0];
534}
535
537{
538 static const struct TableStyleElement gWriterSpecificTableStyleElements[] =
539 {
540 { XML_FIRST_ROW_EVEN_COLUMN, OUString("first-row-even-column") },
541 { XML_LAST_ROW_EVEN_COLUMN, OUString("last-row-even-column") },
542 { XML_FIRST_ROW_END_COLUMN, OUString("first-row-end-column") },
543 { XML_FIRST_ROW_START_COLUMN, OUString("first-row-start-column") },
544 { XML_LAST_ROW_END_COLUMN, OUString("last-row-end-column") },
545 { XML_LAST_ROW_START_COLUMN, OUString("last-row-start-column") },
546 { XML_TOKEN_END, OUString() }
547 };
548
549 return &gWriterSpecificTableStyleElements[0];
550}
551
553{
554 static const struct TableStyleElement gWriterSpecifitTableStyleAttributes[] =
555 {
556 { XML_FIRST_ROW_END_COLUMN, OUString("FirstRowEndColumn") },
557 { XML_FIRST_ROW_START_COLUMN, OUString("FirstRowStartColumn") },
558 { XML_LAST_ROW_END_COLUMN, OUString("LastRowEndColumn") },
559 { XML_LAST_ROW_START_COLUMN, OUString("LastRowStartColumn") },
560 { XML_TOKEN_END, OUString() }
561 };
562
563 return &gWriterSpecifitTableStyleAttributes[0];
564}
565
567{
568 if( !mbExportTables )
569 return;
570
571 try
572 {
573 Reference< XStyleFamiliesSupplier > xFamiliesSupp( mrExport.GetModel(), UNO_QUERY_THROW );
574 Reference< XNameAccess > xFamilies( xFamiliesSupp->getStyleFamilies() );
575 OUString sFamilyName;
576 if (mbWriter)
577 sFamilyName = "TableStyles";
578 else
579 sFamilyName = "table";
580
581 Reference< XIndexAccess > xTableFamily( xFamilies->getByName( sFamilyName ), UNO_QUERY_THROW );
582
583 for( sal_Int32 nIndex = 0; nIndex < xTableFamily->getCount(); nIndex++ ) try
584 {
586
587 Reference< XStyle > xTableStyle( xTableFamily->getByIndex( nIndex ), UNO_QUERY_THROW );
588 if( !xTableStyle->isInUse() )
589 continue;
590
591 const TableStyleElement* pElements;
592 if (mbWriter)
593 {
594 mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, xTableStyle->getName());
595 Reference<XPropertySet> xTableStylePropSet(xTableStyle, UNO_QUERY_THROW);
597 while(pElements->meElement != XML_TOKEN_END)
598 {
599 try
600 {
601 OUString sVal;
602 xTableStylePropSet->getPropertyValue(pElements->msStyleName) >>= sVal;
604 }
605 catch(const Exception&)
606 {
607 TOOLS_WARN_EXCEPTION("xmloff", "XMLTableExport::exportTableTemplates(), export Writer specific attributes, exception caught!");
608 }
609 pElements++;
610 }
611 }
612 else
613 {
614 // checks if any of the extended version of ODF are set
616 {
617 // tdf#106780 historically this wrong attribute was used
618 // for the name; write it if extended because LO < 5.3 can
619 // read only text:style-name, not the correct table:name
620 mrExport.AddAttribute(XML_NAMESPACE_TEXT, XML_STYLE_NAME, GetExport().EncodeStyleName( xTableStyle->getName() ) );
621 }
622 mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, GetExport().EncodeStyleName(xTableStyle->getName()));
623 }
624
626
627 Reference< XNameAccess > xStyleNames( xTableStyle, UNO_QUERY_THROW );
628 pElements = getTableStyleMap();
629 while( pElements->meElement != XML_TOKEN_END )
630 {
631 try
632 {
633 Reference< XStyle > xStyle( xStyleNames->getByName( pElements->msStyleName ), UNO_QUERY );
634 if( xStyle.is() )
635 {
636 mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_STYLE_NAME, GetExport().EncodeStyleName( xStyle->getName() ) );
637 SvXMLElementExport element( mrExport, XML_NAMESPACE_TABLE, pElements->meElement, true, true );
638 }
639 }
640 catch(const Exception&)
641 {
642 TOOLS_WARN_EXCEPTION("xmloff.table", "");
643 }
644
645 pElements++;
646 }
647
648 if (mbWriter && ((eVersion & SvtSaveOptions::ODFSVER_EXTENDED) != 0))
649 {
650 pElements = getWriterSpecificTableStyleMap();
651 while(pElements->meElement != XML_TOKEN_END)
652 {
653 try
654 {
655 Reference<XStyle> xStyle(xStyleNames->getByName(pElements->msStyleName), UNO_QUERY);
656 if(xStyle.is())
657 {
658 mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_STYLE_NAME, GetExport().EncodeStyleName(xStyle->getName()));
659 SvXMLElementExport element(mrExport, XML_NAMESPACE_LO_EXT, pElements->meElement, true, true);
660 }
661 }
662 catch(const Exception&)
663 {
664 TOOLS_WARN_EXCEPTION("xmloff", "XMLTableExport::exportTableTemplates(), export Writer specific styles, exception caught!");
665 }
666 pElements++;
667 }
668 }
669 }
670 catch(const Exception&)
671 {
672 TOOLS_WARN_EXCEPTION("xmloff", "XMLTableExport::exportTableDesigns(), exception caught while exporting a table design!");
673 }
674 }
675 catch(const Exception&)
676 {
677 TOOLS_WARN_EXCEPTION("xmloff", "XMLTableExport::exportTableDesigns()");
678 }
679}
680
681void XMLCellStyleExport::exportStyleContent(const Reference<XStyle>& /*rStyle*/)
682{
683}
684
685void XMLCellStyleExport::exportStyleAttributes(const Reference<XStyle>& rStyle)
686{
687 Reference<XPropertySet> xPropSet(rStyle, UNO_QUERY);
688 if (!xPropSet.is())
689 return;
690
691 Reference<XPropertySetInfo> xPropSetInfo(xPropSet->getPropertySetInfo());
692 static const OUStringLiteral sNumberFormat(u"NumberFormat");
693 if (xPropSetInfo->hasPropertyByName(sNumberFormat))
694 {
695 Reference<XPropertyState> xPropState(xPropSet, UNO_QUERY);
696 if (xPropState.is() && (PropertyState_DIRECT_VALUE ==
697 xPropState->getPropertyState(sNumberFormat)))
698 {
699 sal_Int32 nNumberFormat = 0;
700 if (xPropSet->getPropertyValue(sNumberFormat) >>= nNumberFormat)
702 GetExport().getDataStyleName(nNumberFormat));
703 }
704 }
705}
706
707/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const XMLPropertyMapEntry * getColumnPropertiesMap()
static const TableStyleElement * getWriterSpecificTableStyleAttributes()
static bool has_states(const std::vector< XMLPropertyState > &xPropStates)
#define MAP_END
#define CELLMAP(name, prefix, token, type, context)
const TableStyleElement * getTableStyleMap()
const TableStyleElement * getWriterSpecificTableStyleMap()
#define RMAP(name, prefix, token, type, context)
const XMLPropertyMapEntry * getRowPropertiesMap()
const XMLPropertyMapEntry * getCellPropertiesMap()
#define CMAP(name, prefix, token, type, context)
SvXMLExportPropertyMapper(const rtl::Reference< XMLPropertySetMapper > &rMapper)
Definition: xmlexppr.cxx:474
virtual void handleSpecialItem(SvXMLAttributeList &rAttrList, const XMLPropertyState &rProperty, const SvXMLUnitConverter &rUnitConverter, const SvXMLNamespaceMap &rNamespaceMap, const ::std::vector< XMLPropertyState > *pProperties, sal_uInt32 nIdx) const
this method is called for every item that has the MID_FLAG_SPECIAL_ITEM_EXPORT flag set
Definition: xmlexppr.cxx:850
rtl::Reference< XMLTextParagraphExport > const & GetTextParagraphExport()
Definition: xmlexp.hxx:562
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
Definition: xmlexp.cxx:911
const css::uno::Reference< css::frame::XModel > & GetModel() const
Definition: xmlexp.hxx:416
SvtSaveOptions::ODFSaneDefaultVersion getSaneDefaultVersion() const
returns the deterministic version for odf export
Definition: xmlexp.cxx:2271
rtl::Reference< SvXMLAutoStylePoolP > const & GetAutoStylePool()
Definition: xmlexp.hxx:578
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
Definition: xmluconv.hxx:83
virtual void exportStyleAttributes(const css::uno::Reference< css::style::XStyle > &rStyle) override
virtual void exportStyleContent(const css::uno::Reference< css::style::XStyle > &rStyle) override
SvXMLExport & GetExport()
Definition: styleexp.hxx:59
virtual ~XMLTableExport() override
void collectTableAutoStyles(const css::uno::Reference< css::table::XColumnRowRange > &xColumnRowRange)
void exportTable(const css::uno::Reference< css::table::XColumnRowRange > &xColumnRowRange)
void ExportCell(const css::uno::Reference< css::table::XCell > &xCell, const std::shared_ptr< XMLTableInfo > &pTableInfo, std::u16string_view sDefaultCellStyle)
rtl::Reference< SvXMLExportPropertyMapper > mxColumnExportPropertySetMapper
void ExportTableColumns(const css::uno::Reference< css::container::XIndexAccess > &xtableColumns, const std::shared_ptr< XMLTableInfo > &pTableInfo)
SAL_DLLPRIVATE void ImpExportText(const css::uno::Reference< css::table::XCell > &xCell)
XMLTableExport(SvXMLExport &rExp, const rtl::Reference< SvXMLExportPropertyMapper > &xCellExportPropertySetMapper, const rtl::Reference< XMLPropertyHandlerFactory > &xFactoryRef)
SvXMLExport & mrExport
void exportTableTemplates()
rtl::Reference< SvXMLExportPropertyMapper > mxRowExportPropertySetMapper
SvXMLExport & GetExport()
rtl::Reference< SvXMLExportPropertyMapper > mxCellExportPropertySetMapper
std::map< const css::uno::Reference< css::table::XColumnRowRange >, std::shared_ptr< XMLTableInfo > > maTableInfoMap
static SvXMLExportPropertyMapper * CreateParaExtPropMapper(SvXMLExport &rExport)
Definition: txtparae.cxx:1459
#define TOOLS_WARN_EXCEPTION(area, stream)
float u
constexpr OUStringLiteral XML_STYLE_FAMILY_TABLE_ROW_STYLES_PREFIX
Definition: families.hxx:35
constexpr OUStringLiteral XML_STYLE_FAMILY_TABLE_CELL_STYLES_PREFIX
Definition: families.hxx:37
constexpr OUStringLiteral XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_NAME
Definition: families.hxx:32
constexpr OUStringLiteral XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_PREFIX
Definition: families.hxx:33
constexpr OUStringLiteral XML_STYLE_FAMILY_TABLE_ROW_STYLES_NAME
Definition: families.hxx:34
constexpr OUStringLiteral XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME
Definition: families.hxx:36
sal_Int32 nIndex
#define SAL_WARN_IF(condition, area, stream)
@ Exception
Handling of tokens in XML:
@ XML_LAST_ROW_EVEN_COLUMN
Definition: xmltoken.hxx:3203
@ XML_COVERED_TABLE_CELL
Definition: xmltoken.hxx:539
@ XML_FIRST_ROW_EVEN_COLUMN
Definition: xmltoken.hxx:3202
@ XML_LAST_ROW_END_COLUMN
Definition: xmltoken.hxx:3206
@ XML_DEFAULT_CELL_STYLE_NAME
Definition: xmltoken.hxx:649
@ XML_FIRST_ROW_START_COLUMN
Definition: xmltoken.hxx:3205
@ XML_USE_OPTIMAL_ROW_HEIGHT
Definition: xmltoken.hxx:2069
@ XML_USE_OPTIMAL_COLUMN_WIDTH
Definition: xmltoken.hxx:2068
@ XML_NUMBER_COLUMNS_SPANNED
Definition: xmltoken.hxx:1407
@ XML_NUMBER_ROWS_SPANNED
Definition: xmltoken.hxx:1413
@ XML_FIRST_ROW_END_COLUMN
Definition: xmltoken.hxx:3204
@ XML_LAST_ROW_START_COLUMN
Definition: xmltoken.hxx:3207
::xmloff::token::XMLTokenEnum meElement
Definition: table.hxx:28
OUString msStyleName
Definition: table.hxx:29
Represents a property with its API-name, its XML-name and the type of its value.
Definition: maptype.hxx:33
Smart struct to transport an Any with an index to the appropriate property-name.
Definition: maptype.hxx:141
constexpr sal_uInt16 XML_NAMESPACE_TEXT
constexpr sal_uInt16 XML_NAMESPACE_TABLE
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
constexpr sal_uInt16 XML_NAMESPACE_STYLE
#define XML_SD_TYPE_CELL_ROTATION_ANGLE
Definition: xmlsdtypes.hxx:120
#define XML_TYPE_MEASURE
Definition: xmltypes.hxx:126
#define XML_TYPE_BOOL
Definition: xmltypes.hxx:125