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>
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#include <xmlprop.hxx>
50
51using namespace ::xmloff::token;
52using namespace ::com::sun::star::uno;
53using namespace ::com::sun::star::lang;
54using namespace ::com::sun::star::table;
55using namespace ::com::sun::star::beans;
56using namespace ::com::sun::star::container;
57using namespace ::com::sun::star::text;
58using namespace ::com::sun::star::style;
59
60#define MAP_(name,prefix,token,type,context) { name, prefix, token, type, context, SvtSaveOptions::ODFSVER_010, false }
61#define CMAP(name,prefix,token,type,context) MAP_(name,prefix,token,type|XML_TYPE_PROP_TABLE_COLUMN,context)
62#define RMAP(name,prefix,token,type,context) MAP_(name,prefix,token,type|XML_TYPE_PROP_TABLE_ROW,context)
63#define CELLMAP(name,prefix,token,type,context) MAP_(name,prefix,token,type|XML_TYPE_PROP_TABLE_CELL,context)
64#define MAP_END { nullptr }
65
67{
68 static const XMLPropertyMapEntry aXMLColumnProperties[] =
69 {
73 };
74
75 return &aXMLColumnProperties[0];
76}
77
79{
80 static const XMLPropertyMapEntry aXMLRowProperties[] =
81 {
86 };
87
88 return &aXMLRowProperties[0];
89}
90
92{
93 static const XMLPropertyMapEntry aXMLCellProperties[] =
94 {
108 MAP_END
109 };
110
111 return &aXMLCellProperties[0];
112}
113
114namespace {
115
116class StringStatisticHelper
117{
118private:
119 std::map< OUString, sal_Int32 > mStats;
120
121public:
122 void add( const OUString& rStyleName );
123 void clear() { mStats.clear(); }
124
125 sal_Int32 getModeString( /* out */ OUString& rModeString );
126};
127
128}
129
130void StringStatisticHelper::add( const OUString& rStyleName )
131{
132 std::map< OUString, sal_Int32 >::iterator iter( mStats.find( rStyleName ) );
133 if( iter == mStats.end() )
134 {
135 mStats[rStyleName] = 1;
136 }
137 else
138 {
139 (*iter).second += 1;
140 }
141}
142
143sal_Int32 StringStatisticHelper::getModeString( OUString& rStyleName )
144{
145 sal_Int32 nMax = 0;
146 for( const auto& rStatsEntry : mStats )
147 {
148 if( rStatsEntry.second > nMax )
149 {
150 rStyleName = rStatsEntry.first;
151 nMax = rStatsEntry.second;
152 }
153 }
154
155 return nMax;
156}
157
158namespace {
159
160class XMLCellExportPropertyMapper : public SvXMLExportPropertyMapper
161{
162public:
167 const SvXMLNamespaceMap&, const std::vector<XMLPropertyState>*, sal_uInt32) const override
168 {
169 // the SpecialItem NumberFormat must not be handled by this method
170 }
171};
172
173}
174
176: mrExport( rExp )
177, mbExportTables( false )
178, mbWriter( false )
179{
180 Reference< XMultiServiceFactory > xFac( rExp.GetModel(), UNO_QUERY );
181 if( xFac.is() ) try
182 {
183 const Sequence< OUString > sSNS( xFac->getAvailableServiceNames() );
184 const OUString* pSNS = std::find_if(sSNS.begin(), sSNS.end(),
185 [](const OUString& rSNS) {
186 return rSNS == "com.sun.star.drawing.TableShape"
187 || rSNS == "com.sun.star.style.TableStyle"; });
188 if (pSNS != sSNS.end())
189 {
190 mbExportTables = true;
191 mbWriter = (*pSNS == "com.sun.star.style.TableStyle");
192 }
193 }
194 catch(const Exception&)
195 {
196 }
197
198 if (mbWriter)
199 {
200 mxCellExportPropertySetMapper = new XMLCellExportPropertyMapper(new XMLTextPropertySetMapper(TextPropMap::CELL, true));
201 }
202 else
203 {
204 mxCellExportPropertySetMapper = xExportPropertyMapper;
206 mxCellExportPropertySetMapper->ChainExportMapper(new XMLCellExportPropertyMapper(new XMLPropertySetMapper(getCellPropertiesMap(), xFactoryRef, true)));
207 }
208
211
224}
225
227{
228}
229
230static bool has_states( const std::vector< XMLPropertyState >& xPropStates )
231{
232 return std::any_of(xPropStates.cbegin(), xPropStates.cend(),
233 [](const XMLPropertyState& rPropertyState) { return rPropertyState.mnIndex != -1; });
234}
235
236 void XMLTableExport::collectTableAutoStyles(const Reference < XColumnRowRange >& xColumnRowRange)
237 {
238 if( !mbExportTables )
239 return;
240
241 auto xTableInfo = std::make_shared<XMLTableInfo>();
242 maTableInfoMap[xColumnRowRange] = xTableInfo;
243
244 try
245 {
246 Reference< XIndexAccess > xIndexAccessCols( xColumnRowRange->getColumns(), UNO_QUERY_THROW );
247 const sal_Int32 nColumnCount = xIndexAccessCols->getCount();
248 for( sal_Int32 nColumn = 0; nColumn < nColumnCount; ++nColumn ) try
249 {
250 Reference< XPropertySet > xPropSet( xIndexAccessCols->getByIndex(nColumn) , UNO_QUERY_THROW );
251 std::vector<XMLPropertyState> aPropStates(mxColumnExportPropertySetMapper->Filter(mrExport, xPropSet));
252
253 if( has_states( aPropStates ) )
254 {
255 const OUString sStyleName( mrExport.GetAutoStylePool()->Add(XmlStyleFamily::TABLE_COLUMN, std::move(aPropStates)) );
256 Reference< XInterface > xKey( xPropSet, UNO_QUERY );
257 xTableInfo->maColumnStyleMap[xKey] = sStyleName;
258 }
259 }
260 catch(const Exception&)
261 {
262 TOOLS_WARN_EXCEPTION("xmloff.table", "exception during column style collection!");
263 }
264
265 Reference< XIndexAccess > xIndexAccessRows( xColumnRowRange->getRows(), UNO_QUERY_THROW );
266 const sal_Int32 nRowCount = xIndexAccessRows->getCount();
267 xTableInfo->maDefaultRowCellStyles.resize(nRowCount);
268
269 StringStatisticHelper aStringStatistic;
270
271 for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow )
272 try
273 {
274 Reference< XPropertySet > xPropSet( xIndexAccessRows->getByIndex(nRow) , UNO_QUERY_THROW );
275 std::vector<XMLPropertyState> aRowPropStates(mxRowExportPropertySetMapper->Filter(mrExport, xPropSet));
276
277 if( has_states( aRowPropStates ) )
278 {
279 const OUString sStyleName( mrExport.GetAutoStylePool()->Add(XmlStyleFamily::TABLE_ROW, std::move(aRowPropStates)) );
280 Reference< XInterface > xKey( xPropSet, UNO_QUERY );
281 xTableInfo->maRowStyleMap[xKey] = sStyleName;
282 }
283
284 // get the current row
285 Reference< XCellRange > xCellRange( xPropSet, UNO_QUERY_THROW );
286 for ( sal_Int32 nColumn = 0; nColumn < nColumnCount; ++nColumn )
287 {
288 // get current cell, remarks row index is 0, because we get the range for each row separate
289 Reference< XPropertySet > xCellSet( xCellRange->getCellByPosition(nColumn, 0), UNO_QUERY_THROW );
290
291 // get style
292 OUString sParentStyleName;
293 Reference< XPropertySetInfo > xPropertySetInfo( xCellSet->getPropertySetInfo() );
294 if( xPropertySetInfo.is() && xPropertySetInfo->hasPropertyByName("Style") )
295 {
296 Reference< XStyle > xStyle( xCellSet->getPropertyValue("Style"), UNO_QUERY );
297 if( xStyle.is() )
298 sParentStyleName = xStyle->getName();
299 }
300
301 // create auto style, if needed
302 OUString sStyleName;
303 std::vector<XMLPropertyState> aCellPropStates(mxCellExportPropertySetMapper->Filter(mrExport, xCellSet));
304 if( has_states( aCellPropStates ) )
305 sStyleName = mrExport.GetAutoStylePool()->Add(XmlStyleFamily::TABLE_CELL, std::move(aCellPropStates));
306 else
307 sStyleName = sParentStyleName;
308
309 if( !sStyleName.isEmpty() )
310 {
311 Reference< XInterface > xKey( xCellSet, UNO_QUERY );
312 xTableInfo->maCellStyleMap[xKey] = sStyleName;
313 }
314
315 // create auto style for text
316 Reference< XText > xText(xCellSet, UNO_QUERY);
317 if(xText.is() && !xText->getString().isEmpty())
318 GetExport().GetTextParagraphExport()->collectTextAutoStyles( xText );
319
320 aStringStatistic.add( sStyleName );
321 }
322
323 OUString sDefaultCellStyle;
324 if( aStringStatistic.getModeString( sDefaultCellStyle ) > 1 )
325 xTableInfo->maDefaultRowCellStyles[nRow] = sDefaultCellStyle;
326
327 aStringStatistic.clear();
328 }
329 catch(const Exception&)
330 {
331 TOOLS_WARN_EXCEPTION("xmloff.table", "exception during column style collection!");
332 }
333 }
334 catch(const Exception&)
335 {
336 TOOLS_WARN_EXCEPTION("xmloff.table", "exception caught!");
337 }
338 }
339
340 void XMLTableExport::exportTable( const Reference < XColumnRowRange >& xColumnRowRange )
341 {
342 if( !mbExportTables )
343 return;
344
345 try
346 {
347 std::shared_ptr< XMLTableInfo > xTableInfo( maTableInfoMap[xColumnRowRange] );
348
349 // get row and column count
350 Reference< XIndexAccess > xIndexAccess( xColumnRowRange->getRows(), UNO_QUERY_THROW );
351 Reference< XIndexAccess > xIndexAccessCols( xColumnRowRange->getColumns(), UNO_QUERY_THROW );
352
353 const sal_Int32 rowCount = xIndexAccess->getCount();
354 const sal_Int32 columnCount = xIndexAccessCols->getCount();
355
356 SvXMLElementExport tableElement( mrExport, XML_NAMESPACE_TABLE, XML_TABLE, true, true );
357
358 // export table columns
359 ExportTableColumns( xIndexAccessCols, xTableInfo );
360
361 // start iterating rows and columns
362 for ( sal_Int32 rowIndex = 0; rowIndex < rowCount; rowIndex++ )
363 {
364 // get the current row
365 Reference< XCellRange > xCellRange( xIndexAccess->getByIndex(rowIndex), UNO_QUERY_THROW );
366
367 OUString sDefaultCellStyle;
368
369 // table:style-name
370 if( xTableInfo )
371 {
372 Reference< XInterface > xKey( xCellRange, UNO_QUERY );
373 const OUString sStyleName( xTableInfo->maRowStyleMap[xKey] );
374 if( !sStyleName.isEmpty() )
376
377 sDefaultCellStyle = xTableInfo->maDefaultRowCellStyles[rowIndex];
378 if( !sDefaultCellStyle.isEmpty() )
380 }
381
382 // write row element
383 SvXMLElementExport tableRowElement( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_ROW, true, true );
384
385 for ( sal_Int32 columnIndex = 0; columnIndex < columnCount; columnIndex++ )
386 {
387 // get current cell, remarks row index is 0, because we get the range for each row separate
388 Reference< XCell > xCell( xCellRange->getCellByPosition(columnIndex, 0), UNO_SET_THROW );
389
390 // use XMergeableCell interface from offapi
391 Reference< XMergeableCell > xMergeableCell( xCell, UNO_QUERY_THROW );
392
393 // export cell
394 ExportCell( xCell, xTableInfo, sDefaultCellStyle );
395 }
396 }
397 }
398 catch(const Exception&)
399 {
400 TOOLS_WARN_EXCEPTION("xmloff.table", "" );
401 }
402 }
403
404// Export the table columns
405
406 void XMLTableExport::ExportTableColumns( const Reference < XIndexAccess >& xtableColumnsIndexAccess, const std::shared_ptr< XMLTableInfo >& rTableInfo )
407 {
408 const sal_Int32 nColumnCount = xtableColumnsIndexAccess->getCount();
409 for( sal_Int32 nColumn = 0; nColumn < nColumnCount; ++nColumn )
410 {
411 Reference< XPropertySet > xColumnProperties( xtableColumnsIndexAccess->getByIndex(nColumn) , UNO_QUERY );
412 if ( xColumnProperties.is() )
413 {
414 // table:style-name
415 if( rTableInfo )
416 {
417 Reference< XInterface > xKey( xColumnProperties, UNO_QUERY );
418 const OUString sStyleName( rTableInfo->maColumnStyleMap[xKey] );
419 if( !sStyleName.isEmpty() )
421 }
422
423 // TODO: all columns first have to be checked if someone
424 // have identical properties. If yes, attr table:number-columns-repeated
425 // has to be written.
426 SvXMLElementExport tableColumnElement( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, true, true );
427 }
428 }
429 }
430
431// ODF export for a table cell.
432
433 void XMLTableExport::ExportCell( const Reference < XCell >& xCell, const std::shared_ptr< XMLTableInfo >& rTableInfo, std::u16string_view rDefaultCellStyle )
434 {
435 bool bIsMerged = false;
436 sal_Int32 nRowSpan = 0;
437 sal_Int32 nColSpan = 0;
438
439 try
440 {
441 if( rTableInfo )
442 {
443 // table:style-name
444 Reference< XInterface > xKey( xCell, UNO_QUERY );
445 const OUString sStyleName( rTableInfo->maCellStyleMap[xKey] );
446 if( !sStyleName.isEmpty() && (sStyleName != rDefaultCellStyle) )
448 }
449
450 Reference< XMergeableCell > xMerge( xCell, UNO_QUERY );
451 if( xMerge.is() )
452 {
453 bIsMerged = xMerge->isMerged();
454 nRowSpan = xMerge->getRowSpan();
455 nColSpan = xMerge->getColumnSpan();
456 }
457 SAL_WARN_IF( (nRowSpan < 1) || (nColSpan < 1), "xmloff", "xmloff::XMLTableExport::ExportCell(), illegal row or col span < 1?" );
458 }
459 catch (const Exception&)
460 {
461 TOOLS_WARN_EXCEPTION("xmloff.table", "exception while exporting a table cell");
462 }
463
464 // table:number-columns-repeated
465 // todo
466
467 // table:number-columns-spanned
468 if( nColSpan > 1 )
470
471 // table:number-rows-spanned
472 if( nRowSpan > 1 )
473 mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_SPANNED, OUString::number( nRowSpan ) );
474
475 // <table:table-cell> or <table:covered-table-cell>
476 SvXMLElementExport tableCellElement( mrExport, XML_NAMESPACE_TABLE, bIsMerged ? XML_COVERED_TABLE_CELL : XML_TABLE_CELL, true, true );
477
478 // export cells text content
479 ImpExportText( xCell );
480 }
481
482// ODF export of the text contents of a table cell.
483// Remarks: Up to now we only export text contents!
484// TODO: Check against nested tables...
485
486 void XMLTableExport::ImpExportText( const Reference< XCell >& xCell )
487 {
488 Reference< XText > xText( xCell, UNO_QUERY );
489 if( xText.is() && !xText->getString().isEmpty())
490 mrExport.GetTextParagraphExport()->exportText( xText );
491 }
492
494{
495 if( !mbExportTables )
496 return;
497
499 OUString sCellStyleName;
500 if (mbWriter)
501 {
502 sCellStyleName = "CellStyles";
503 aStEx.set(new XMLCellStyleExport(mrExport));
504 }
505 else
506 {
507 // write graphic family styles
508 sCellStyleName = "cell";
509 aStEx.set(new XMLStyleExport(mrExport, mrExport.GetAutoStylePool().get()));
510 }
511
512 aStEx->exportStyleFamily(sCellStyleName, OUString(XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME), mxCellExportPropertySetMapper, true, XmlStyleFamily::TABLE_CELL);
513
515}
516
517// Export the collected automatic styles
518
520{
521 if( !mbExportTables )
522 return;
523
527}
528
530{
531 static const struct TableStyleElement gTableStyleElements[] =
532 {
533 { XML_FIRST_ROW, OUString("first-row") },
534 { XML_LAST_ROW, OUString("last-row") },
535 { XML_FIRST_COLUMN, OUString("first-column") },
536 { XML_LAST_COLUMN, OUString("last-column") },
537 { XML_BODY, OUString("body") },
538 { XML_EVEN_ROWS, OUString("even-rows") },
539 { XML_ODD_ROWS, OUString("odd-rows") },
540 { XML_EVEN_COLUMNS, OUString("even-columns") },
541 { XML_ODD_COLUMNS, OUString("odd-columns") },
542 { XML_BACKGROUND, OUString("background") },
543 { XML_TOKEN_END, OUString() }
544 };
545
546 return &gTableStyleElements[0];
547}
548
550{
551 static const struct TableStyleElement gWriterSpecificTableStyleElements[] =
552 {
553 { XML_FIRST_ROW_EVEN_COLUMN, OUString("first-row-even-column") },
554 { XML_LAST_ROW_EVEN_COLUMN, OUString("last-row-even-column") },
555 { XML_FIRST_ROW_END_COLUMN, OUString("first-row-end-column") },
556 { XML_FIRST_ROW_START_COLUMN, OUString("first-row-start-column") },
557 { XML_LAST_ROW_END_COLUMN, OUString("last-row-end-column") },
558 { XML_LAST_ROW_START_COLUMN, OUString("last-row-start-column") },
559 { XML_TOKEN_END, OUString() }
560 };
561
562 return &gWriterSpecificTableStyleElements[0];
563}
564
566{
567 static const struct TableStyleElement gWriterSpecifitTableStyleAttributes[] =
568 {
569 { XML_FIRST_ROW_END_COLUMN, OUString("FirstRowEndColumn") },
570 { XML_FIRST_ROW_START_COLUMN, OUString("FirstRowStartColumn") },
571 { XML_LAST_ROW_END_COLUMN, OUString("LastRowEndColumn") },
572 { XML_LAST_ROW_START_COLUMN, OUString("LastRowStartColumn") },
573 { XML_TOKEN_END, OUString() }
574 };
575
576 return &gWriterSpecifitTableStyleAttributes[0];
577}
578
580{
581 if( !mbExportTables )
582 return;
583
584 try
585 {
586 Reference< XStyleFamiliesSupplier > xFamiliesSupp( mrExport.GetModel(), UNO_QUERY_THROW );
587 Reference< XNameAccess > xFamilies( xFamiliesSupp->getStyleFamilies() );
588 OUString sFamilyName;
589 if (mbWriter)
590 sFamilyName = "TableStyles";
591 else
592 sFamilyName = "table";
593
594 Reference< XIndexAccess > xTableFamily( xFamilies->getByName( sFamilyName ), UNO_QUERY_THROW );
595
596 for( sal_Int32 nIndex = 0; nIndex < xTableFamily->getCount(); nIndex++ ) try
597 {
599
600 Reference< XStyle > xTableStyle( xTableFamily->getByIndex( nIndex ), UNO_QUERY_THROW );
601 Reference<XPropertySet> xTableStylePropSet( xTableStyle, UNO_QUERY_THROW );
602 bool bPhysical = false;
603
604 try
605 {
606 xTableStylePropSet->getPropertyValue("IsPhysical") >>= bPhysical;
607 }
608 catch(const Exception&)
609 {
610 }
611
612 if (!xTableStyle->isInUse() && !bPhysical)
613 continue;
614
615 const TableStyleElement* pElements;
616 if (mbWriter)
617 {
618 mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, xTableStyle->getName());
620 while(pElements->meElement != XML_TOKEN_END)
621 {
622 try
623 {
624 OUString sVal;
625 xTableStylePropSet->getPropertyValue(pElements->msStyleName) >>= sVal;
627 }
628 catch(const Exception&)
629 {
630 TOOLS_WARN_EXCEPTION("xmloff", "XMLTableExport::exportTableTemplates(), export Writer specific attributes, exception caught!");
631 }
632 pElements++;
633 }
634 }
635 else
636 {
637 // checks if any of the extended version of ODF are set
639 {
640 // tdf#106780 historically this wrong attribute was used
641 // for the name; write it if extended because LO < 5.3 can
642 // read only text:style-name, not the correct table:name
643 mrExport.AddAttribute(XML_NAMESPACE_TEXT, XML_STYLE_NAME, xTableStyle->getName());
644 }
645 mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, xTableStyle->getName());
646 }
647
649
650 Reference< XNameAccess > xStyleNames( xTableStyle, UNO_QUERY_THROW );
651 pElements = getTableStyleMap();
652 while( pElements->meElement != XML_TOKEN_END )
653 {
654 try
655 {
656 Reference< XStyle > xStyle( xStyleNames->getByName( pElements->msStyleName ), UNO_QUERY );
657 if( xStyle.is() )
658 {
659 mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_STYLE_NAME, GetExport().EncodeStyleName( xStyle->getName() ) );
660 SvXMLElementExport element( mrExport, XML_NAMESPACE_TABLE, pElements->meElement, true, true );
661 }
662 }
663 catch(const Exception&)
664 {
665 TOOLS_WARN_EXCEPTION("xmloff.table", "");
666 }
667
668 pElements++;
669 }
670
671 if (mbWriter && ((eVersion & SvtSaveOptions::ODFSVER_EXTENDED) != 0))
672 {
673 pElements = getWriterSpecificTableStyleMap();
674 while(pElements->meElement != XML_TOKEN_END)
675 {
676 try
677 {
678 Reference<XStyle> xStyle(xStyleNames->getByName(pElements->msStyleName), UNO_QUERY);
679 if(xStyle.is())
680 {
681 mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_STYLE_NAME, GetExport().EncodeStyleName(xStyle->getName()));
682 SvXMLElementExport element(mrExport, XML_NAMESPACE_LO_EXT, pElements->meElement, true, true);
683 }
684 }
685 catch(const Exception&)
686 {
687 TOOLS_WARN_EXCEPTION("xmloff", "XMLTableExport::exportTableTemplates(), export Writer specific styles, exception caught!");
688 }
689 pElements++;
690 }
691 }
692 }
693 catch(const Exception&)
694 {
695 TOOLS_WARN_EXCEPTION("xmloff", "XMLTableExport::exportTableDesigns(), exception caught while exporting a table design!");
696 }
697 }
698 catch(const Exception&)
699 {
700 TOOLS_WARN_EXCEPTION("xmloff", "XMLTableExport::exportTableDesigns()");
701 }
702}
703
704void XMLCellStyleExport::exportStyleContent(const Reference<XStyle>& /*rStyle*/)
705{
706}
707
708void XMLCellStyleExport::exportStyleAttributes(const Reference<XStyle>& rStyle)
709{
710 Reference<XPropertySet> xPropSet(rStyle, UNO_QUERY);
711 if (!xPropSet.is())
712 return;
713
714 Reference<XPropertySetInfo> xPropSetInfo(xPropSet->getPropertySetInfo());
715 static constexpr OUStringLiteral sNumberFormat(u"NumberFormat");
716 if (xPropSetInfo->hasPropertyByName(sNumberFormat))
717 {
718 Reference<XPropertyState> xPropState(xPropSet, UNO_QUERY);
719 if (xPropState.is() && (PropertyState_DIRECT_VALUE ==
720 xPropState->getPropertyState(sNumberFormat)))
721 {
722 sal_Int32 nNumberFormat = 0;
723 if (xPropSet->getPropertyValue(sNumberFormat) >>= nNumberFormat)
725 GetExport().getDataStyleName(nNumberFormat));
726 }
727 }
728}
729
730/* 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)
virtual void handleSpecialItem(comphelper::AttributeList &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:848
SvXMLExportPropertyMapper(const rtl::Reference< XMLPropertySetMapper > &rMapper)
Definition: xmlexppr.cxx:472
rtl::Reference< XMLTextParagraphExport > const & GetTextParagraphExport()
Definition: xmlexp.hxx:557
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
Definition: xmlexp.cxx:907
const css::uno::Reference< css::frame::XModel > & GetModel() const
Definition: xmlexp.hxx:411
SvtSaveOptions::ODFSaneDefaultVersion getSaneDefaultVersion() const
returns the deterministic version for odf export
Definition: xmlexp.cxx:2264
rtl::Reference< SvXMLAutoStylePoolP > const & GetAutoStylePool()
Definition: xmlexp.hxx:573
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:1542
#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:3217
@ XML_COVERED_TABLE_CELL
Definition: xmltoken.hxx:541
@ XML_FIRST_ROW_EVEN_COLUMN
Definition: xmltoken.hxx:3216
@ XML_LAST_ROW_END_COLUMN
Definition: xmltoken.hxx:3220
@ XML_DEFAULT_CELL_STYLE_NAME
Definition: xmltoken.hxx:652
@ XML_FIRST_ROW_START_COLUMN
Definition: xmltoken.hxx:3219
@ XML_USE_OPTIMAL_ROW_HEIGHT
Definition: xmltoken.hxx:2080
@ XML_USE_OPTIMAL_COLUMN_WIDTH
Definition: xmltoken.hxx:2079
@ XML_NUMBER_COLUMNS_SPANNED
Definition: xmltoken.hxx:1413
@ XML_NUMBER_ROWS_SPANNED
Definition: xmltoken.hxx:1419
@ XML_FIRST_ROW_END_COLUMN
Definition: xmltoken.hxx:3218
@ XML_BACKGROUND_COLOR
Definition: xmltoken.hxx:313
@ XML_LAST_ROW_START_COLUMN
Definition: xmltoken.hxx:3221
::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:140
#define CTF_CHARBOTTOMBORDER
Definition: txtprmap.hxx:196
#define CTF_CHARALLBORDERDISTANCE
Definition: txtprmap.hxx:187
#define CTF_CHARTOPBORDER
Definition: txtprmap.hxx:195
#define CTF_CHARBOTTOMBORDERDISTANCE
Definition: txtprmap.hxx:191
#define CTF_CHARALLBORDER
Definition: txtprmap.hxx:192
#define CTF_CHARTOPBORDERDISTANCE
Definition: txtprmap.hxx:190
#define CTF_CHARRIGHTBORDER
Definition: txtprmap.hxx:194
#define CTF_CHARLEFTBORDER
Definition: txtprmap.hxx:193
#define CTF_CHARRIGHTBORDERDISTANCE
Definition: txtprmap.hxx:189
#define CTF_CHARLEFTBORDERDISTANCE
Definition: txtprmap.hxx:188
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
constexpr sal_uInt16 XML_NAMESPACE_FO
constexpr OUStringLiteral PROP_RightBorder
Definition: xmlprop.hxx:549
constexpr OUStringLiteral PROP_RotateAngle
Definition: xmlprop.hxx:552
constexpr OUStringLiteral PROP_TextLeftDistance
Definition: xmlprop.hxx:620
constexpr OUStringLiteral PROP_TextUpperDistance
Definition: xmlprop.hxx:629
constexpr OUStringLiteral PROP_MinHeight
Definition: xmlprop.hxx:452
constexpr OUStringLiteral PROP_BackColor
Definition: xmlprop.hxx:23
constexpr OUStringLiteral PROP_Height
Definition: xmlprop.hxx:378
constexpr OUStringLiteral PROP_LeftBorder
Definition: xmlprop.hxx:413
constexpr OUStringLiteral PROP_OptimalWidth
Definition: xmlprop.hxx:465
constexpr OUStringLiteral PROP_TextLowerDistance
Definition: xmlprop.hxx:622
constexpr OUStringLiteral PROP_TextRightDistance
Definition: xmlprop.hxx:627
constexpr OUStringLiteral PROP_OptimalHeight
Definition: xmlprop.hxx:464
constexpr OUStringLiteral PROP_TopBorder
Definition: xmlprop.hxx:635
constexpr OUStringLiteral PROP_TextVerticalAdjust
Definition: xmlprop.hxx:631
constexpr OUStringLiteral PROP_BottomBorder
Definition: xmlprop.hxx:34
constexpr OUStringLiteral PROP_Width
Definition: xmlprop.hxx:662
#define XML_SD_TYPE_VERTICAL_ALIGN
Definition: xmlsdtypes.hxx:59
#define XML_SD_TYPE_CELL_ROTATION_ANGLE
Definition: xmlsdtypes.hxx:120
#define XML_TYPE_COLORTRANSPARENT
Definition: xmltypes.hxx:140
#define MID_FLAG_SPECIAL_ITEM
Definition: xmltypes.hxx:87
#define MID_FLAG_SPECIAL_ITEM_EXPORT
Definition: xmltypes.hxx:86
#define XML_TYPE_BORDER
Definition: xmltypes.hxx:191
#define XML_TYPE_MEASURE
Definition: xmltypes.hxx:126
#define XML_TYPE_BOOL
Definition: xmltypes.hxx:125