bump product version to 4.1.6.2
[LibreOffice.git] / xmloff / source / table / XMLTableExport.cxx
blob611273d10589e9fd4434bc5a3afab19910838021
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "xmloff/dllapi.h"
22 #include "sal/config.h"
23 #include <osl/diagnose.h>
25 #include <rtl/ustring.hxx>
26 #include <rtl/ustrbuf.hxx>
28 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
29 #include <com/sun/star/text/XText.hpp>
30 #include <com/sun/star/container/XNamed.hpp>
31 #include <com/sun/star/container/XEnumerationAccess.hpp>
32 #include <com/sun/star/table/XCellRange.hpp>
33 #include <com/sun/star/table/XColumnRowRange.hpp>
34 #include <com/sun/star/table/CellContentType.hpp>
35 #include <com/sun/star/table/XMergeableCell.hpp>
36 #include <com/sun/star/style/XStyle.hpp>
37 #include <com/sun/star/beans/XPropertySetInfo.hpp>
39 #include "xmloff/table/XMLTableExport.hxx"
40 #include "xmloff/xmlnmspe.hxx"
41 #include <xmloff/xmlprmap.hxx>
42 #include <xmloff/xmlexppr.hxx>
43 #include <xmloff/xmlexp.hxx>
44 #include "table.hxx"
46 using namespace ::xmloff::token;
47 using namespace ::com::sun::star::uno;
48 using namespace ::com::sun::star::lang;
49 using namespace ::com::sun::star::table;
50 using namespace ::com::sun::star::beans;
51 using namespace ::com::sun::star::container;
52 using namespace ::com::sun::star::text;
53 using namespace ::com::sun::star::style;
55 // --------------------------------------------------------------------
57 #define _MAP(name,prefix,token,type,context) { name, sizeof(name)-1, prefix, token, type, context, SvtSaveOptions::ODFVER_010, false }
58 #define CMAP(name,prefix,token,type,context) _MAP(name,prefix,token,type|XML_TYPE_PROP_TABLE_COLUMN,context)
59 #define RMAP(name,prefix,token,type,context) _MAP(name,prefix,token,type|XML_TYPE_PROP_TABLE_ROW,context)
60 #define MAP_END { 0L, 0, 0, XML_EMPTY, 0, 0, SvtSaveOptions::ODFVER_010, false }
62 // --------------------------------------------------------------------
64 const XMLPropertyMapEntry* getColumnPropertiesMap()
66 static const XMLPropertyMapEntry aXMLColumnProperties[] =
68 CMAP( "Width", XML_NAMESPACE_STYLE, XML_COLUMN_WIDTH, XML_TYPE_MEASURE, 0 ),
69 CMAP( "OptimalWidth", XML_NAMESPACE_STYLE, XML_USE_OPTIMAL_COLUMN_WIDTH, XML_TYPE_BOOL, 0 ),
70 MAP_END
73 return &aXMLColumnProperties[0];
76 // --------------------------------------------------------------------
78 const XMLPropertyMapEntry* getRowPropertiesMap()
80 static const XMLPropertyMapEntry aXMLRowProperties[] =
82 RMAP( "Height", XML_NAMESPACE_STYLE, XML_ROW_HEIGHT, XML_TYPE_MEASURE, 0 ),
83 RMAP( "OptimalHeight", XML_NAMESPACE_STYLE, XML_MIN_ROW_HEIGHT, XML_TYPE_MEASURE, 0 ),
84 RMAP( "OptimalWidth", XML_NAMESPACE_STYLE, XML_USE_OPTIMAL_ROW_HEIGHT, XML_TYPE_BOOL, 0 ),
85 MAP_END
88 return &aXMLRowProperties[0];
91 // --------------------------------------------------------------------
93 class StringStatisticHelper : public std::map< OUString, sal_Int32 >
95 public:
96 void add( const OUString& rStyleName );
97 void clear() { std::map< OUString, sal_Int32 >::clear(); }
99 sal_Int32 getModeString( /* out */ OUString& rModeString );
102 // --------------------------------------------------------------------
104 void StringStatisticHelper::add( const OUString& rStyleName )
106 std::map< OUString, sal_Int32 >::iterator iter( find( rStyleName ) );
107 if( iter == end() )
109 (*this)[rStyleName] = 1;
111 else
113 (*iter).second += 1;
117 // --------------------------------------------------------------------
119 sal_Int32 StringStatisticHelper::getModeString( OUString& rStyleName )
121 sal_Int32 nMax = 0;
122 const std::map< OUString, sal_Int32 >::const_iterator aEnd( end() );
123 for( std::map< OUString, sal_Int32 >::iterator iter( begin() );
124 iter != aEnd; ++iter)
126 if( (*iter).second > nMax )
128 rStyleName = (*iter).first;
129 nMax = (*iter).second;
133 return nMax;
136 // --------------------------------------------------------------------
137 // class XMLTableExport
138 // --------------------------------------------------------------------
140 XMLTableExport::XMLTableExport(SvXMLExport& rExp, const rtl::Reference< SvXMLExportPropertyMapper >& xExportPropertyMapper, const rtl::Reference< XMLPropertyHandlerFactory >& xFactoryRef )
141 : mrExport( rExp )
142 , mbExportTables( false )
144 Reference< XMultiServiceFactory > xFac( rExp.GetModel(), UNO_QUERY );
145 if( xFac.is() ) try
147 Sequence< OUString > sSNS( xFac->getAvailableServiceNames() );
148 sal_Int32 n = sSNS.getLength();
149 const OUString* pSNS( sSNS.getConstArray() );
150 while( --n > 0 )
152 if( (*pSNS++) == "com.sun.star.drawing.TableShape" )
154 mbExportTables = true;
155 break;
159 catch(const Exception&)
163 mxCellExportPropertySetMapper = xExportPropertyMapper;
164 mxCellExportPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(rExp));
166 mxRowExportPropertySetMapper = new SvXMLExportPropertyMapper( new XMLPropertySetMapper( getRowPropertiesMap(), xFactoryRef.get(), true ) );
167 mxColumnExportPropertySetMapper = new SvXMLExportPropertyMapper( new XMLPropertySetMapper( getColumnPropertiesMap(), xFactoryRef.get(), true ) );
169 mrExport.GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_COLUMN,
170 OUString(XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_NAME),
171 mxColumnExportPropertySetMapper.get(),
172 OUString(XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_PREFIX));
173 mrExport.GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_ROW,
174 OUString(XML_STYLE_FAMILY_TABLE_ROW_STYLES_NAME),
175 mxRowExportPropertySetMapper.get(),
176 OUString(XML_STYLE_FAMILY_TABLE_ROW_STYLES_PREFIX));
177 mrExport.GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_CELL,
178 OUString(XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME),
179 mxCellExportPropertySetMapper.get(),
180 OUString(XML_STYLE_FAMILY_TABLE_CELL_STYLES_PREFIX));
183 // --------------------------------------------------------------------
185 XMLTableExport::~XMLTableExport ()
189 // --------------------------------------------------------------------
191 static bool has_states( const std::vector< XMLPropertyState >& xPropStates )
193 if( !xPropStates.empty() )
195 std::vector< XMLPropertyState >::const_iterator aIter( xPropStates.begin() );
196 std::vector< XMLPropertyState >::const_iterator aEnd( xPropStates.end() );
197 while( aIter != aEnd )
199 if( aIter->mnIndex != -1 )
200 return true;
201 ++aIter;
204 return false;
207 // --------------------------------------------------------------------
209 void XMLTableExport::collectTableAutoStyles(const Reference < XColumnRowRange >& xColumnRowRange)
211 if( !mbExportTables )
212 return;
214 boost::shared_ptr< XMLTableInfo > pTableInfo( new XMLTableInfo() );
215 maTableInfoMap[xColumnRowRange] = pTableInfo;
219 Reference< XIndexAccess > xIndexAccessCols( xColumnRowRange->getColumns(), UNO_QUERY_THROW );
220 const sal_Int32 nColumnCount = xIndexAccessCols->getCount();
221 for( sal_Int32 nColumn = 0; nColumn < nColumnCount; ++nColumn ) try
223 Reference< XPropertySet > xPropSet( xIndexAccessCols->getByIndex(nColumn) , UNO_QUERY_THROW );
224 std::vector< XMLPropertyState > xPropStates( mxColumnExportPropertySetMapper->Filter( xPropSet ) );
226 if( has_states( xPropStates ) )
228 const OUString sStyleName( mrExport.GetAutoStylePool()->Add(XML_STYLE_FAMILY_TABLE_COLUMN, xPropStates) );
229 Reference< XInterface > xKey( xPropSet, UNO_QUERY );
230 pTableInfo->maColumnStyleMap[xKey] = sStyleName;
233 catch(const Exception&)
235 OSL_FAIL("xmloff::XMLTableExport::collectTableAutoStyles(), exception during column style collection!");
238 Reference< XIndexAccess > xIndexAccessRows( xColumnRowRange->getRows(), UNO_QUERY_THROW );
239 const sal_Int32 nRowCount = xIndexAccessRows->getCount();
240 pTableInfo->maDefaultRowCellStyles.resize(nRowCount);
242 StringStatisticHelper aStringStatistic;
244 for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow ) try
246 Reference< XPropertySet > xPropSet( xIndexAccessRows->getByIndex(nRow) , UNO_QUERY_THROW );
247 std::vector< XMLPropertyState > xRowPropStates( mxRowExportPropertySetMapper->Filter( xPropSet ) );
249 if( has_states( xRowPropStates ) )
251 const OUString sStyleName( mrExport.GetAutoStylePool()->Add(XML_STYLE_FAMILY_TABLE_ROW, xRowPropStates) );
252 Reference< XInterface > xKey( xPropSet, UNO_QUERY );
253 pTableInfo->maRowStyleMap[xKey] = sStyleName;
256 // get the current row
257 Reference< XCellRange > xCellRange( xPropSet, UNO_QUERY_THROW );
258 for ( sal_Int32 nColumn = 0; nColumn < nColumnCount; ++nColumn )
260 // get current cell, remarks row index is 0, because we get the range for each row separate
261 Reference< XPropertySet > xCellSet( xCellRange->getCellByPosition(nColumn, 0), UNO_QUERY_THROW );
263 // get style
264 OUString sParentStyleName;
265 Reference< XPropertySetInfo > xPropertySetInfo( xCellSet->getPropertySetInfo() );
266 if( xPropertySetInfo.is() && xPropertySetInfo->hasPropertyByName( OUString("Style")) )
268 Reference< XStyle > xStyle( xCellSet->getPropertyValue(OUString("Style")), UNO_QUERY );
269 if( xStyle.is() )
270 sParentStyleName = xStyle->getName();
273 // create auto style, if needed
274 OUString sStyleName;
275 std::vector< XMLPropertyState > xCellPropStates( mxCellExportPropertySetMapper->Filter( xCellSet ) );
276 if( has_states( xCellPropStates ) )
277 sStyleName = mrExport.GetAutoStylePool()->Add(XML_STYLE_FAMILY_TABLE_CELL, xCellPropStates);
278 else
279 sStyleName = sParentStyleName;
281 if( !sStyleName.isEmpty() )
283 Reference< XInterface > xKey( xCellSet, UNO_QUERY );
284 pTableInfo->maCellStyleMap[xKey] = sStyleName;
287 // create auto style for text
288 Reference< XText > xText(xCellSet, UNO_QUERY);
289 if(xText.is() && !xText->getString().isEmpty())
290 GetExport().GetTextParagraphExport()->collectTextAutoStyles( xText );
292 aStringStatistic.add( sStyleName );
295 OUString sDefaultCellStyle;
296 if( aStringStatistic.getModeString( sDefaultCellStyle ) > 1 )
297 pTableInfo->maDefaultRowCellStyles[nRow] = sDefaultCellStyle;
299 aStringStatistic.clear();
301 catch(const Exception&)
303 OSL_FAIL("xmloff::XMLTableExport::collectTableAutoStyles(), exception during column style collection!");
306 catch(const Exception&)
308 OSL_FAIL("xmloff::XMLTableExport::collectTableAutoStyles(), exception caught!");
312 // --------------------------------------------------------------------
314 void XMLTableExport::exportTable( const Reference < XColumnRowRange >& xColumnRowRange )
316 if( !mbExportTables )
317 return;
321 boost::shared_ptr< XMLTableInfo > pTableInfo( maTableInfoMap[xColumnRowRange] );
323 // get row and column count
324 Reference< XIndexAccess > xIndexAccess( xColumnRowRange->getRows(), UNO_QUERY_THROW );
325 Reference< XIndexAccess > xIndexAccessCols( xColumnRowRange->getColumns(), UNO_QUERY_THROW );
327 const sal_Int32 rowCount = xIndexAccess->getCount();
328 const sal_Int32 columnCount = xIndexAccessCols->getCount();
330 SvXMLElementExport tableElement( mrExport, XML_NAMESPACE_TABLE, XML_TABLE, sal_True, sal_True );
332 // export table columns
333 ExportTableColumns( xIndexAccessCols, pTableInfo );
335 // start iterating rows and columns
336 for ( sal_Int32 rowIndex = 0; rowIndex < rowCount; rowIndex++ )
338 // get the current row
339 Reference< XCellRange > xCellRange( xIndexAccess->getByIndex(rowIndex), UNO_QUERY_THROW );
341 OUString sDefaultCellStyle;
343 // table:style-name
344 if( pTableInfo.get() )
346 Reference< XInterface > xKey( xCellRange, UNO_QUERY );
347 const OUString sStyleName( pTableInfo->maRowStyleMap[xKey] );
348 if( !sStyleName.isEmpty() )
349 mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_STYLE_NAME, sStyleName );
351 sDefaultCellStyle = pTableInfo->maDefaultRowCellStyles[rowIndex];
352 if( !sDefaultCellStyle.isEmpty() )
353 mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DEFAULT_CELL_STYLE_NAME, sDefaultCellStyle );
356 // write row element
357 SvXMLElementExport tableRowElement( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_ROW, sal_True, sal_True );
359 for ( sal_Int32 columnIndex = 0; columnIndex < columnCount; columnIndex++ )
361 // get current cell, remarks row index is 0, because we get the range for each row separate
362 Reference< XCell > xCell( xCellRange->getCellByPosition(columnIndex, 0), UNO_QUERY_THROW );
364 // use XMergeableCell interface from offapi
365 Reference< XMergeableCell > xMergeableCell( xCell, UNO_QUERY_THROW );
367 // export cell
368 ExportCell( xCell, pTableInfo, sDefaultCellStyle );
372 catch(const Exception&)
374 OSL_FAIL( "XMLTableExport::exportTable(), exception cought!" );
378 // --------------------------------------------------------------------
379 // Export the table columns
380 // --------------------------------------------------------------------
382 void XMLTableExport::ExportTableColumns( const Reference < XIndexAccess >& xtableColumnsIndexAccess, const boost::shared_ptr< XMLTableInfo >& pTableInfo )
384 const sal_Int32 nColumnCount = xtableColumnsIndexAccess->getCount();
385 for( sal_Int32 nColumn = 0; nColumn < nColumnCount; ++nColumn )
387 Reference< XPropertySet > xColumnProperties( xtableColumnsIndexAccess->getByIndex(nColumn) , UNO_QUERY );
388 if ( xColumnProperties.is() )
390 // table:style-name
391 if( pTableInfo.get() )
393 Reference< XInterface > xKey( xColumnProperties, UNO_QUERY );
394 const OUString sStyleName( pTableInfo->maColumnStyleMap[xKey] );
395 if( !sStyleName.isEmpty() )
396 mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_STYLE_NAME, sStyleName );
399 // TODO: All columns first have to be checked if some ones
400 // have identical properties. If yes, attr table:number-columns-repeated
401 // has to be written.
402 SvXMLElementExport tableColumnElement( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, sal_True, sal_True );
407 // --------------------------------------------------------------------
408 // ODF export for a table cell.
409 // --------------------------------------------------------------------
411 void XMLTableExport::ExportCell( const Reference < XCell >& xCell, const boost::shared_ptr< XMLTableInfo >& pTableInfo, const OUString& rDefaultCellStyle )
413 bool bIsMerged = false;
414 sal_Int32 nRowSpan = 0;
415 sal_Int32 nColSpan = 0;
419 if( pTableInfo.get() )
421 // table:style-name
422 Reference< XInterface > xKey( xCell, UNO_QUERY );
423 const OUString sStyleName( pTableInfo->maCellStyleMap[xKey] );
424 if( !sStyleName.isEmpty() && (sStyleName != rDefaultCellStyle) )
425 mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_STYLE_NAME, sStyleName );
428 Reference< XMergeableCell > xMerge( xCell, UNO_QUERY );
429 if( xMerge.is() )
431 bIsMerged = xMerge->isMerged();
432 nRowSpan = xMerge->getRowSpan();
433 nColSpan = xMerge->getColumnSpan();
435 DBG_ASSERT( (nRowSpan >= 1) && (nColSpan >= 1), "xmloff::XMLTableExport::ExportCell(), illegal row or col span < 1?" );
437 catch (const Exception&)
439 OSL_FAIL( "exception while exporting a table cell" );
442 // table:number-columns-repeated
443 // todo
445 // table:number-columns-spanned
446 if( nColSpan > 1 )
447 mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_SPANNED, OUString::valueOf( nColSpan ) );
449 // table:number-rows-spanned
450 if( nRowSpan > 1 )
451 mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_SPANNED, OUString::valueOf( nRowSpan ) );
453 // <table:table-cell> or <table:covered-table-cell>
454 SvXMLElementExport tableCellElement( mrExport, XML_NAMESPACE_TABLE, bIsMerged ? XML_COVERED_TABLE_CELL : XML_TABLE_CELL, sal_True, sal_True );
456 // export cells text content
457 ImpExportText( xCell );
460 // --------------------------------------------------------------------
461 // ODF export of the text contents of a table cell.
462 // Remarks: Up to now we only export text contents!
463 // TODO: Check against nested tables ....
464 // --------------------------------------------------------------------
466 void XMLTableExport::ImpExportText( const Reference< XCell >& xCell )
468 Reference< XText > xText( xCell, UNO_QUERY );
469 if( xText.is() && !xText->getString().isEmpty())
470 mrExport.GetTextParagraphExport()->exportText( xText );
473 // --------------------------------------------------------------------
475 void XMLTableExport::exportTableStyles()
477 if( !mbExportTables )
478 return;
480 XMLStyleExport aStEx(mrExport, OUString(), mrExport.GetAutoStylePool().get());
482 // write graphic family styles
483 aStEx.exportStyleFamily("cell", OUString(XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME), mxCellExportPropertySetMapper.get(), sal_True, XML_STYLE_FAMILY_TABLE_CELL);
485 exportTableTemplates();
488 // --------------------------------------------------------------------
489 // Export the collected automatic styles
490 // --------------------------------------------------------------------
492 void XMLTableExport::exportAutoStyles()
494 if( !mbExportTables )
495 return;
497 mrExport.GetAutoStylePool()->exportXML( XML_STYLE_FAMILY_TABLE_COLUMN, mrExport.GetDocHandler(), mrExport.GetMM100UnitConverter(), mrExport.GetNamespaceMap() );
498 mrExport.GetAutoStylePool()->exportXML( XML_STYLE_FAMILY_TABLE_ROW, mrExport.GetDocHandler(), mrExport.GetMM100UnitConverter(), mrExport.GetNamespaceMap() );
499 mrExport.GetAutoStylePool()->exportXML( XML_STYLE_FAMILY_TABLE_CELL, mrExport.GetDocHandler(), mrExport.GetMM100UnitConverter(), mrExport.GetNamespaceMap() );
502 // --------------------------------------------------------------------
504 const TableStyleElement* getTableStyleMap()
506 static struct TableStyleElement gTableStyleElements[] =
508 { XML_FIRST_ROW, OUString("first-row") },
509 { XML_LAST_ROW, OUString("last-row") },
510 { XML_FIRST_COLUMN, OUString("first-column") },
511 { XML_LAST_COLUMN, OUString("last-column") },
512 { XML_EVEN_ROWS, OUString("even-rows") },
513 { XML_ODD_ROWS, OUString("odd-rows") },
514 { XML_EVEN_COLUMNS, OUString("even-columns") },
515 { XML_ODD_COLUMNS, OUString("odd-columns") },
516 { XML_BODY, OUString("body") },
517 { XML_TOKEN_END, OUString() }
520 return &gTableStyleElements[0];
523 // --------------------------------------------------------------------
525 void XMLTableExport::exportTableTemplates()
527 if( !mbExportTables )
528 return;
532 Reference< XStyleFamiliesSupplier > xFamiliesSupp( mrExport.GetModel(), UNO_QUERY_THROW );
533 Reference< XNameAccess > xFamilies( xFamiliesSupp->getStyleFamilies() );
534 const OUString sFamilyName( "table" );
535 Reference< XIndexAccess > xTableFamily( xFamilies->getByName( sFamilyName ), UNO_QUERY_THROW );
537 for( sal_Int32 nIndex = 0; nIndex < xTableFamily->getCount(); nIndex++ ) try
539 Reference< XStyle > xTableStyle( xTableFamily->getByIndex( nIndex ), UNO_QUERY_THROW );
540 if( !xTableStyle->isInUse() )
541 continue;
543 Reference< XNameAccess > xStyleNames( xTableStyle, UNO_QUERY_THROW );
545 mrExport.AddAttribute(XML_NAMESPACE_TEXT, XML_STYLE_NAME, GetExport().EncodeStyleName( xTableStyle->getName() ) );
546 SvXMLElementExport tableTemplate( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_TEMPLATE, sal_True, sal_True );
548 const TableStyleElement* pElements = getTableStyleMap();
549 while( pElements->meElement != XML_TOKEN_END )
553 Reference< XStyle > xStyle( xStyleNames->getByName( pElements->msStyleName ), UNO_QUERY );
554 if( xStyle.is() )
556 mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_STYLE_NAME, GetExport().EncodeStyleName( xStyle->getName() ) );
557 SvXMLElementExport element( mrExport, XML_NAMESPACE_TABLE, pElements->meElement, sal_True, sal_True );
560 catch(const Exception&)
562 OSL_FAIL("xmloff::XMLTableExport::exportTableTemplates(), exception caught!");
565 pElements++;
568 catch(const Exception&)
570 OSL_FAIL("xmloff::XMLTableExport::exportTableDesigns(), exception caught while exporting a table design!");
573 catch(const Exception&)
575 OSL_FAIL("xmloff::XMLTableExport::exportTableDesigns(), exception caught!");
579 // --------------------------------------------------------------------
581 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */