merge the formfield patch from ooo-build
[ooovba.git] / xmloff / source / table / XMLTableExport.cxx
blob7c8d3c5c2aeec2b57458e5e4debb87861ee1f1df
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XMLTableExport.cxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include "xmloff/dllapi.h"
35 #include "sal/config.h"
36 #include <osl/diagnose.h>
38 #include <rtl/ustring.hxx>
39 #include <rtl/ustrbuf.hxx>
41 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
42 #include <com/sun/star/text/XText.hpp>
43 #include <com/sun/star/container/XNamed.hpp>
44 #include <com/sun/star/container/XEnumerationAccess.hpp>
45 #include <com/sun/star/table/XCellRange.hpp>
46 #include <com/sun/star/table/XColumnRowRange.hpp>
47 #include <com/sun/star/table/CellContentType.hpp>
48 #include <com/sun/star/table/XMergeableCell.hpp>
49 #include <com/sun/star/style/XStyle.hpp>
50 #include <com/sun/star/beans/XPropertySetInfo.hpp>
52 #include "xmloff/table/XMLTableExport.hxx"
53 #include "xmlnmspe.hxx"
54 #include <xmloff/xmlprmap.hxx>
55 #include <xmloff/xmlexppr.hxx>
56 #include <xmloff/xmlexp.hxx>
57 #include "table.hxx"
59 using ::rtl::OUString;
60 using namespace ::xmloff::token;
61 using namespace ::com::sun::star::uno;
62 using namespace ::com::sun::star::lang;
63 using namespace ::com::sun::star::table;
64 using namespace ::com::sun::star::beans;
65 using namespace ::com::sun::star::container;
66 using namespace ::com::sun::star::text;
67 using namespace ::com::sun::star::style;
68 using namespace ::xmloff::token;
70 // --------------------------------------------------------------------
72 #define _MAP(name,prefix,token,type,context) { name, sizeof(name)-1, prefix, token, type, context, SvtSaveOptions::ODFVER_010 }
73 #define CMAP(name,prefix,token,type,context) _MAP(name,prefix,token,type|XML_TYPE_PROP_TABLE_COLUMN,context)
74 #define RMAP(name,prefix,token,type,context) _MAP(name,prefix,token,type|XML_TYPE_PROP_TABLE_ROW,context)
75 #define MAP_END { 0L, 0, 0, XML_EMPTY, 0, 0, SvtSaveOptions::ODFVER_010 }
77 // --------------------------------------------------------------------
79 const XMLPropertyMapEntry* getColumnPropertiesMap()
81 static const XMLPropertyMapEntry aXMLColumnProperties[] =
83 CMAP( "Width", XML_NAMESPACE_STYLE, XML_COLUMN_WIDTH, XML_TYPE_MEASURE, 0 ),
84 CMAP( "OptimalWidth", XML_NAMESPACE_STYLE, XML_USE_OPTIMAL_COLUMN_WIDTH, XML_TYPE_BOOL, 0 ),
85 MAP_END
88 return &aXMLColumnProperties[0];
91 // --------------------------------------------------------------------
93 const XMLPropertyMapEntry* getRowPropertiesMap()
95 static const XMLPropertyMapEntry aXMLRowProperties[] =
97 RMAP( "Height", XML_NAMESPACE_STYLE, XML_ROW_HEIGHT, XML_TYPE_MEASURE, 0 ),
98 RMAP( "OptimalHeight", XML_NAMESPACE_STYLE, XML_MIN_ROW_HEIGHT, XML_TYPE_MEASURE, 0 ),
99 RMAP( "OptimalWidth", XML_NAMESPACE_STYLE, XML_USE_OPTIMAL_ROW_HEIGHT, XML_TYPE_BOOL, 0 ),
100 MAP_END
103 return &aXMLRowProperties[0];
106 // --------------------------------------------------------------------
108 class StringStatisticHelper : public std::map< OUString, sal_Int32 >
110 public:
111 void add( const OUString& rStyleName );
112 void clear() { std::map< OUString, sal_Int32 >::clear(); }
114 sal_Int32 getModeString( /* out */ OUString& rModeString );
117 // --------------------------------------------------------------------
119 void StringStatisticHelper::add( const OUString& rStyleName )
121 std::map< OUString, sal_Int32 >::iterator iter( find( rStyleName ) );
122 if( iter == end() )
124 (*this)[rStyleName] = 1;
126 else
128 (*iter).second += 1;
132 // --------------------------------------------------------------------
134 sal_Int32 StringStatisticHelper::getModeString( OUString& rStyleName )
136 sal_Int32 nMax = 0;
137 for( std::map< OUString, sal_Int32 >::iterator iter( begin() ); iter != end(); iter++ )
139 if( (*iter).second > nMax )
141 rStyleName = (*iter).first;
142 nMax = (*iter).second;
146 return nMax;
149 // --------------------------------------------------------------------
150 // class XMLTableExport
151 // --------------------------------------------------------------------
153 XMLTableExport::XMLTableExport(SvXMLExport& rExp, const rtl::Reference< SvXMLExportPropertyMapper >& xExportPropertyMapper, const rtl::Reference< XMLPropertyHandlerFactory >& xFactoryRef )
154 : mrExport( rExp )
155 , mbExportTables( false )
157 Reference< XMultiServiceFactory > xFac( rExp.GetModel(), UNO_QUERY );
158 if( xFac.is() ) try
160 Sequence< OUString > sSNS( xFac->getAvailableServiceNames() );
161 sal_Int32 n = sSNS.getLength();
162 const OUString* pSNS( sSNS.getConstArray() );
163 while( --n > 0 )
165 if( (*pSNS++).equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TableShape") ) )
167 mbExportTables = true;
168 break;
172 catch( Exception& e )
174 (void)e;
177 mxCellExportPropertySetMapper = xExportPropertyMapper;
178 mxCellExportPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(rExp));
180 mxRowExportPropertySetMapper = new SvXMLExportPropertyMapper( new XMLPropertySetMapper( getRowPropertiesMap(), xFactoryRef.get() ) );
181 mxColumnExportPropertySetMapper = new SvXMLExportPropertyMapper( new XMLPropertySetMapper( getColumnPropertiesMap(), xFactoryRef.get() ) );
183 mrExport.GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_COLUMN,
184 OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_NAME)),
185 mxColumnExportPropertySetMapper.get(),
186 OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_PREFIX)));
187 mrExport.GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_ROW,
188 OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_ROW_STYLES_NAME)),
189 mxRowExportPropertySetMapper.get(),
190 OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_ROW_STYLES_PREFIX)));
191 // mrExport.GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_TABLE
192 // OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_TABLE_STYLES_NAME)),
193 // xTableStylesExportPropertySetMapper,
194 // OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_TABLE_STYLES_PREFIX)));
195 mrExport.GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_CELL,
196 OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME)),
197 mxCellExportPropertySetMapper.get(),
198 OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_CELL_STYLES_PREFIX)));
201 // --------------------------------------------------------------------
203 XMLTableExport::~XMLTableExport ()
207 // --------------------------------------------------------------------
209 static bool has_states( const std::vector< XMLPropertyState >& xPropStates )
211 if( !xPropStates.empty() )
213 std::vector< XMLPropertyState >::const_iterator aIter( xPropStates.begin() );
214 std::vector< XMLPropertyState >::const_iterator aEnd( xPropStates.end() );
215 while( aIter != aEnd )
217 if( aIter->mnIndex != -1 )
218 return true;
219 aIter++;
222 return false;
225 // --------------------------------------------------------------------
227 void XMLTableExport::collectTableAutoStyles(const Reference < XColumnRowRange >& xColumnRowRange)
229 if( !mbExportTables )
230 return;
232 boost::shared_ptr< XMLTableInfo > pTableInfo( new XMLTableInfo() );
233 maTableInfoMap[xColumnRowRange] = pTableInfo;
237 Reference< XIndexAccess > xIndexAccessCols( xColumnRowRange->getColumns(), UNO_QUERY_THROW );
238 const sal_Int32 nColumnCount = xIndexAccessCols->getCount();
239 for( sal_Int32 nColumn = 0; nColumn < nColumnCount; ++nColumn ) try
241 Reference< XPropertySet > xPropSet( xIndexAccessCols->getByIndex(nColumn) , UNO_QUERY_THROW );
242 std::vector< XMLPropertyState > xPropStates( mxColumnExportPropertySetMapper->Filter( xPropSet ) );
244 if( has_states( xPropStates ) )
246 const OUString sStyleName( mrExport.GetAutoStylePool()->Add(XML_STYLE_FAMILY_TABLE_COLUMN, xPropStates) );
247 Reference< XInterface > xKey( xPropSet, UNO_QUERY );
248 pTableInfo->maColumnStyleMap[xKey] = sStyleName;
251 catch( Exception& )
253 DBG_ERROR("xmloff::XMLTableExport::collectTableAutoStyles(), exception during column style collection!");
256 Reference< XIndexAccess > xIndexAccessRows( xColumnRowRange->getRows(), UNO_QUERY_THROW );
257 const sal_Int32 nRowCount = xIndexAccessRows->getCount();
258 pTableInfo->maDefaultRowCellStyles.resize(nRowCount);
260 StringStatisticHelper aStringStatistic;
262 for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow ) try
264 Reference< XPropertySet > xPropSet( xIndexAccessRows->getByIndex(nRow) , UNO_QUERY_THROW );
265 std::vector< XMLPropertyState > xRowPropStates( mxRowExportPropertySetMapper->Filter( xPropSet ) );
267 if( has_states( xRowPropStates ) )
269 const OUString sStyleName( mrExport.GetAutoStylePool()->Add(XML_STYLE_FAMILY_TABLE_ROW, xRowPropStates) );
270 Reference< XInterface > xKey( xPropSet, UNO_QUERY );
271 pTableInfo->maRowStyleMap[xKey] = sStyleName;
274 // get the current row
275 Reference< XCellRange > xCellRange( xPropSet, UNO_QUERY_THROW );
276 for ( sal_Int32 nColumn = 0; nColumn < nColumnCount; ++nColumn )
278 // get current cell, remarks row index is 0, because we get the range for each row seperate
279 Reference< XPropertySet > xCellSet( xCellRange->getCellByPosition(nColumn, 0), UNO_QUERY_THROW );
281 // get style
282 OUString sParentStyleName;
283 Reference< XPropertySetInfo > xPropertySetInfo( xCellSet->getPropertySetInfo() );
284 if( xPropertySetInfo.is() && xPropertySetInfo->hasPropertyByName( OUString(RTL_CONSTASCII_USTRINGPARAM("Style"))) )
286 Reference< XStyle > xStyle( xCellSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Style"))), UNO_QUERY );
287 if( xStyle.is() )
288 sParentStyleName = xStyle->getName();
291 // create auto style, if needed
292 OUString sStyleName;
293 std::vector< XMLPropertyState > xCellPropStates( mxCellExportPropertySetMapper->Filter( xCellSet ) );
294 if( has_states( xCellPropStates ) )
295 sStyleName = mrExport.GetAutoStylePool()->Add(XML_STYLE_FAMILY_TABLE_CELL, xCellPropStates);
296 else
297 sStyleName = sParentStyleName;
299 if( sStyleName.getLength() )
301 Reference< XInterface > xKey( xCellSet, UNO_QUERY );
302 pTableInfo->maCellStyleMap[xKey] = sStyleName;
305 // create auto style for text
306 Reference< XText > xText(xCellSet, UNO_QUERY);
307 if(xText.is() && xText->getString().getLength())
308 GetExport().GetTextParagraphExport()->collectTextAutoStyles( xText );
310 aStringStatistic.add( sStyleName );
313 OUString sDefaultCellStyle;
314 if( aStringStatistic.getModeString( sDefaultCellStyle ) > 1 )
315 pTableInfo->maDefaultRowCellStyles[nRow] = sDefaultCellStyle;
317 aStringStatistic.clear();
319 catch( Exception& )
321 DBG_ERROR("xmloff::XMLTableExport::collectTableAutoStyles(), exception during column style collection!");
324 catch( Exception& )
326 DBG_ERROR("xmloff::XMLTableExport::collectTableAutoStyles(), exception caught!");
330 // --------------------------------------------------------------------
332 void XMLTableExport::exportTable( const Reference < XColumnRowRange >& xColumnRowRange )
334 if( !mbExportTables )
335 return;
339 boost::shared_ptr< XMLTableInfo > pTableInfo( maTableInfoMap[xColumnRowRange] );
341 // get row and column count
342 Reference< XIndexAccess > xIndexAccess( xColumnRowRange->getRows(), UNO_QUERY_THROW );
343 Reference< XIndexAccess > xIndexAccessCols( xColumnRowRange->getColumns(), UNO_QUERY_THROW );
345 const sal_Int32 rowCount = xIndexAccess->getCount();
346 const sal_Int32 columnCount = xIndexAccessCols->getCount();
348 SvXMLElementExport tableElement( mrExport, XML_NAMESPACE_TABLE, XML_TABLE, sal_True, sal_True );
350 // export table columns
351 ExportTableColumns( xIndexAccessCols, pTableInfo );
353 // start iterating rows and columns
354 for ( sal_Int32 rowIndex = 0; rowIndex < rowCount; rowIndex++ )
356 // get the current row
357 Reference< XCellRange > xCellRange( xIndexAccess->getByIndex(rowIndex), UNO_QUERY_THROW );
359 // table:style-name
360 if( pTableInfo.get() )
362 Reference< XInterface > xKey( xCellRange, UNO_QUERY );
363 const OUString sStyleName( pTableInfo->maRowStyleMap[xKey] );
364 if( sStyleName.getLength() )
365 mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_STYLE_NAME, sStyleName );
368 const OUString sDefaultCellStyle( pTableInfo->maDefaultRowCellStyles[rowIndex] );
369 if( sDefaultCellStyle.getLength() )
370 mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DEFAULT_CELL_STYLE_NAME, sDefaultCellStyle );
372 // write row element
373 SvXMLElementExport tableRowElement( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_ROW, sal_True, sal_True );
375 for ( sal_Int32 columnIndex = 0; columnIndex < columnCount; columnIndex++ )
377 // get current cell, remarks row index is 0, because we get the range for each row seperate
378 Reference< XCell > xCell( xCellRange->getCellByPosition(columnIndex, 0), UNO_QUERY_THROW );
380 // use XMergeableCell interface from offapi
381 Reference< XMergeableCell > xMergeableCell( xCell, UNO_QUERY_THROW );
383 // export cell
384 ExportCell( xCell, pTableInfo, sDefaultCellStyle );
388 catch( Exception )
390 DBG_ERROR( "XMLTableExport::exportTable(), exception cought!" );
394 // --------------------------------------------------------------------
395 // Export the table columns
396 // --------------------------------------------------------------------
398 void XMLTableExport::ExportTableColumns( const Reference < XIndexAccess >& xtableColumnsIndexAccess, const boost::shared_ptr< XMLTableInfo >& pTableInfo )
400 const sal_Int32 nColumnCount = xtableColumnsIndexAccess->getCount();
401 for( sal_Int32 nColumn = 0; nColumn < nColumnCount; ++nColumn )
403 Reference< XPropertySet > xColumnProperties( xtableColumnsIndexAccess->getByIndex(nColumn) , UNO_QUERY );
404 if ( xColumnProperties.is() )
406 // table:style-name
407 if( pTableInfo.get() )
409 Reference< XInterface > xKey( xColumnProperties, UNO_QUERY );
410 const OUString sStyleName( pTableInfo->maColumnStyleMap[xKey] );
411 if( sStyleName.getLength() )
412 mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_STYLE_NAME, sStyleName );
415 // TODO: All columns first have to be checked if some ones
416 // have identical properties. If yes, attr table:number-columns-repeated
417 // has to be written.
418 SvXMLElementExport tableColumnElement( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, sal_True, sal_True );
423 // --------------------------------------------------------------------
424 // ODF export for a table cell.
425 // --------------------------------------------------------------------
427 void XMLTableExport::ExportCell( const Reference < XCell >& xCell, const boost::shared_ptr< XMLTableInfo >& pTableInfo, const OUString& rDefaultCellStyle )
429 bool bIsMerged = false;
430 sal_Int32 nRowSpan = 0;
431 sal_Int32 nColSpan = 0;
435 if( pTableInfo.get() )
437 // table:style-name
438 Reference< XInterface > xKey( xCell, UNO_QUERY );
439 const OUString sStyleName( pTableInfo->maCellStyleMap[xKey] );
440 if( sStyleName.getLength() && (sStyleName != rDefaultCellStyle) )
441 mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_STYLE_NAME, sStyleName );
444 Reference< XMergeableCell > xMerge( xCell, UNO_QUERY );
445 if( xMerge.is() )
447 bIsMerged = xMerge->isMerged();
448 nRowSpan = xMerge->getRowSpan();
449 nColSpan = xMerge->getColumnSpan();
451 DBG_ASSERT( (nRowSpan >= 1) && (nColSpan >= 1), "xmloff::XMLTableExport::ExportCell(), illegal row or col span < 1?" );
453 catch ( Exception )
455 DBG_ERROR( "exception while exporting a table cell" );
458 // table:number-columns-repeated
459 // todo
461 // table:number-columns-spanned
462 if( nColSpan > 1 )
463 mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_SPANNED, OUString::valueOf( nColSpan ) );
465 // table:number-rows-spanned
466 if( nRowSpan > 1 )
467 mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_SPANNED, OUString::valueOf( nRowSpan ) );
469 // <table:table-cell> or <table:covered-table-cell>
470 SvXMLElementExport tableCellElement( mrExport, XML_NAMESPACE_TABLE, bIsMerged ? XML_COVERED_TABLE_CELL : XML_TABLE_CELL, sal_True, sal_True );
472 // export cells text content
473 ImpExportText( xCell );
476 // --------------------------------------------------------------------
477 // ODF export of the text contents of a table cell.
478 // Remarks: Up to now we only export text contents!
479 // TODO: Check against nested tables ....
480 // --------------------------------------------------------------------
482 void XMLTableExport::ImpExportText( const Reference< XCell >& xCell )
484 Reference< XText > xText( xCell, UNO_QUERY );
485 if( xText.is() && xText->getString().getLength())
486 mrExport.GetTextParagraphExport()->exportText( xText );
489 // --------------------------------------------------------------------
491 void XMLTableExport::exportTableStyles()
493 if( !mbExportTables )
494 return;
496 XMLStyleExport aStEx(mrExport, OUString(), mrExport.GetAutoStylePool().get());
498 // write graphic family styles
499 aStEx.exportStyleFamily("cell", OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME)), mxCellExportPropertySetMapper.get(), TRUE, XML_STYLE_FAMILY_TABLE_CELL);
501 exportTableTemplates();
504 // --------------------------------------------------------------------
505 // Export the collected automatic styles
506 // --------------------------------------------------------------------
508 void XMLTableExport::exportAutoStyles()
510 if( !mbExportTables )
511 return;
513 mrExport.GetAutoStylePool()->exportXML( XML_STYLE_FAMILY_TABLE_COLUMN, mrExport.GetDocHandler(), mrExport.GetMM100UnitConverter(), mrExport.GetNamespaceMap() );
514 mrExport.GetAutoStylePool()->exportXML( XML_STYLE_FAMILY_TABLE_ROW, mrExport.GetDocHandler(), mrExport.GetMM100UnitConverter(), mrExport.GetNamespaceMap() );
515 mrExport.GetAutoStylePool()->exportXML( XML_STYLE_FAMILY_TABLE_CELL, mrExport.GetDocHandler(), mrExport.GetMM100UnitConverter(), mrExport.GetNamespaceMap() );
518 // --------------------------------------------------------------------
520 const TableStyleElement* getTableStyleMap()
522 static struct TableStyleElement gTableStyleElements[] =
524 { XML_FIRST_ROW, OUString( RTL_CONSTASCII_USTRINGPARAM( "first-row" ) ) },
525 { XML_LAST_ROW, OUString( RTL_CONSTASCII_USTRINGPARAM( "last-row" ) ) },
526 { XML_FIRST_COLUMN, OUString( RTL_CONSTASCII_USTRINGPARAM( "first-column" ) ) },
527 { XML_LAST_COLUMN, OUString( RTL_CONSTASCII_USTRINGPARAM( "last-column" ) ) },
528 { XML_EVEN_ROWS, OUString( RTL_CONSTASCII_USTRINGPARAM( "even-rows" ) ) },
529 { XML_ODD_ROWS, OUString( RTL_CONSTASCII_USTRINGPARAM( "odd-rows" ) ) },
530 { XML_EVEN_COLUMNS, OUString( RTL_CONSTASCII_USTRINGPARAM( "even-columns" ) ) },
531 { XML_ODD_COLUMNS, OUString( RTL_CONSTASCII_USTRINGPARAM( "odd-columns" ) ) },
532 { XML_BODY, OUString( RTL_CONSTASCII_USTRINGPARAM( "body" ) ) },
533 { XML_TOKEN_END, OUString() }
536 return &gTableStyleElements[0];
539 // --------------------------------------------------------------------
541 void XMLTableExport::exportTableTemplates()
543 if( !mbExportTables )
544 return;
548 Reference< XStyleFamiliesSupplier > xFamiliesSupp( mrExport.GetModel(), UNO_QUERY_THROW );
549 Reference< XNameAccess > xFamilies( xFamiliesSupp->getStyleFamilies() );
550 const OUString sFamilyName( RTL_CONSTASCII_USTRINGPARAM("table" ) );
551 Reference< XIndexAccess > xTableFamily( xFamilies->getByName( sFamilyName ), UNO_QUERY_THROW );
553 for( sal_Int32 nIndex = 0; nIndex < xTableFamily->getCount(); nIndex++ ) try
555 Reference< XStyle > xTableStyle( xTableFamily->getByIndex( nIndex ), UNO_QUERY_THROW );
556 if( !xTableStyle->isInUse() )
557 continue;
559 Reference< XNameAccess > xStyleNames( xTableStyle, UNO_QUERY_THROW );
561 mrExport.AddAttribute(XML_NAMESPACE_TEXT, XML_STYLE_NAME, GetExport().EncodeStyleName( xTableStyle->getName() ) );
562 SvXMLElementExport tableTemplate( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_TEMPLATE, sal_True, sal_True );
564 const TableStyleElement* pElements = getTableStyleMap();
565 while( pElements->meElement != XML_TOKEN_END )
569 Reference< XStyle > xStyle( xStyleNames->getByName( pElements->msStyleName ), UNO_QUERY );
570 if( xStyle.is() )
572 mrExport.AddAttribute(XML_NAMESPACE_TEXT, XML_STYLE_NAME, GetExport().EncodeStyleName( xStyle->getName() ) );
573 SvXMLElementExport element( mrExport, XML_NAMESPACE_TABLE, pElements->meElement, sal_True, sal_True );
576 catch( Exception& )
578 DBG_ERROR("xmloff::XMLTableExport::exportTableTemplates(), exception caught!");
581 pElements++;
584 catch( Exception& )
586 DBG_ERROR("xmloff::XMLTableExport::exportTableDesigns(), exception caught while exporting a table design!");
589 catch( Exception& )
591 DBG_ERROR("xmloff::XMLTableExport::exportTableDesigns(), exception caught!");
595 // --------------------------------------------------------------------