23#include <com/sun/star/table/XTable.hpp>
24#include <com/sun/star/table/XMergeableCellRange.hpp>
47static void CreateTableRows(
const uno::Reference< XTableRows >& xTableRows,
const std::vector< TableRow >& rvTableRows )
49 if ( rvTableRows.size() > 1 )
50 xTableRows->insertByIndex( 0, rvTableRows.size() - 1 );
51 std::vector< TableRow >::const_iterator aTableRowIter( rvTableRows.begin() );
52 uno::Reference< container::XIndexAccess > xIndexAccess( xTableRows, UNO_QUERY_THROW );
53 sal_Int32 nCols = std::min<sal_Int32>(xIndexAccess->getCount(), rvTableRows.size());
54 for (sal_Int32
n = 0;
n < nCols; ++
n)
57 xPropSet->setPropertyValue(
"Height",
Any(
static_cast< sal_Int32
>( aTableRowIter->getHeight() / 360 ) ) );
64 if ( rvTableGrid.size() > 1 )
65 xTableColumns->insertByIndex( 0, rvTableGrid.size() - 1 );
66 std::vector< sal_Int32 >::const_iterator aTableGridIter( rvTableGrid.begin() );
67 uno::Reference< container::XIndexAccess > xIndexAccess( xTableColumns, UNO_QUERY_THROW );
68 sal_Int32 nCols = std::min<sal_Int32>(xIndexAccess->getCount(), rvTableGrid.size());
69 for (sal_Int32
n = 0;
n < nCols; ++
n)
72 xPropSet->setPropertyValue(
"Width",
Any(
static_cast< sal_Int32
>( *aTableGridIter++ / 360 ) ) );
76static void MergeCells(
const uno::Reference< XTable >& xTable, sal_Int32 nCol, sal_Int32 nRow, sal_Int32 nColSpan, sal_Int32 nRowSpan )
80 Reference< XMergeableCellRange > xRange( xTable->createCursorByRange( xTable->getCellRangeByPosition( nCol, nRow,nCol + nColSpan - 1, nRow + nRowSpan - 1 ) ), UNO_QUERY_THROW );
81 if( xRange->isMergeable() )
98 const std::vector< TableStyle >& rTableStyles( rBase.
getTableStyles()->getTableStyles() );
101 for (
auto const& tableStyle : rTableStyles)
105 pTableStyle = &
const_cast< TableStyle&
>(tableStyle);
113 pTableStyle = rTableStyleToDelete.get();
120 return theDefaultTableStyle;
130 uno::Reference<XColumnRowRange> xColumnRowRange(xPropSet->getPropertyValue(
"Model"),
131 uno::UNO_QUERY_THROW);
136 std::unique_ptr<TableStyle> xTableStyleToDelete;
142 sal_Int32 nColumn = 0;
143 sal_Int32 nColumnSize = tableRow.getTableCells().size();
144 sal_Int32 nRemovedColumn = 0;
145 sal_Int32 nRemovedRow = 0;
147 for (sal_Int32 nColIndex = 0; nColIndex < nColumnSize; nColIndex++)
149 TableCell& rTableCell(tableRow.getTableCells().at(nColIndex));
153 uno::Reference<XTable> xTable(xColumnRowRange, uno::UNO_QUERY_THROW);
154 bool bMerged =
false;
166 nColIndex += nRemovedColumn;
183 xCell = xCellRange->getCellByPosition(nColumn, nRow);
189 xCell = xCellRange->getCellByPosition(nColumn - nRemovedColumn, nRow);
193 xCell = xCellRange->getCellByPosition(nColumn, nRow);
196 sal_Int32 nMaxCol = tableRow.getTableCells().size() - nRemovedColumn - 1;
197 sal_Int32 nMaxRow =
mvTableRows.size() - nRemovedRow - 1;
199 rTableCell.
pushToXCell(rFilterBase, pMasterTextListStyle, xCell, *
this, rTableStyle,
200 nColumn, nMaxCol, nRow, nMaxRow);
203 nColumn += nRemovedColumn;
212 xTableStyleToDelete.reset();
virtual ::oox::drawingml::table::TableStyleListPtr getTableStyles()=0
Has to be implemented by each filter to return the table style list.
void setUnused()
Sets the color to unused state.
sal_Int32 getGridSpan() const
sal_Int32 getRowSpan() const
void pushToXCell(const ::oox::core::XmlFilterBase &rFilterBase, const ::oox::drawingml::TextListStylePtr &pMasterTextListStyle, const css::uno::Reference< css::table::XCell > &rxCell, const TableProperties &rTableProperties, const TableStyle &rTable, sal_Int32 nColumn, sal_Int32 nMaxColumn, sal_Int32 nRow, sal_Int32 nMaxRow)
std::vector< TableRow > mvTableRows
const TableStyle & getUsedTableStyle(const ::oox::core::XmlFilterBase &rFilterBase, std::unique_ptr< TableStyle > &rTableStyleToDelete)
std::shared_ptr< TableStyle > mpTableStyle
std::vector< sal_Int32 > mvTableGrid
void pushToPropSet(const ::oox::core::XmlFilterBase &rFilterBase, const css::uno::Reference< css::beans::XPropertySet > &xPropSet, const ::oox::drawingml::TextListStylePtr &pMasterTextListStyle)
static void CreateTableRows(const uno::Reference< XTableRows > &xTableRows, const std::vector< TableRow > &rvTableRows)
static void CreateTableColumns(const Reference< XTableColumns > &xTableColumns, const std::vector< sal_Int32 > &rvTableGrid)
static void MergeCells(const uno::Reference< XTable > &xTable, sal_Int32 nCol, sal_Int32 nRow, sal_Int32 nColSpan, sal_Int32 nRowSpan)
std::shared_ptr< TextListStyle > TextListStylePtr
std::unique_ptr< TableStyle > CreateTableStyle(const OUString &styleId)