summaryrefslogtreecommitdiff
path: root/sw/source/core/unocore/unotext.cxx
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@libreoffice.org>2017-09-17 23:13:39 +0200
committerBjörn Michaelsen <bjoern.michaelsen@libreoffice.org>2017-09-18 22:45:25 +0200
commite6b7ad06c6c99ff9bc3f814cfe9a5d44714a4ac1 (patch)
treeffd30b816314f51d198b8322a38f438f79ddecca /sw/source/core/unocore/unotext.cxx
parent5e381ffbe7069a454dc807113ab4058fad005c55 (diff)
use some C++11 and check for incomplete merges (lcl_MergeCells)
Change-Id: Id58762bb4914cdbb358bfd8afb916647c964d38b Reviewed-on: https://gerrit.libreoffice.org/42399 Tested-by: Björn Michaelsen <bjoern.michaelsen@libreoffice.org> Reviewed-by: Björn Michaelsen <bjoern.michaelsen@libreoffice.org>
Diffstat (limited to 'sw/source/core/unocore/unotext.cxx')
-rw-r--r--sw/source/core/unocore/unotext.cxx38
1 files changed, 12 insertions, 26 deletions
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index 70d3b682deb9..b0e0f051aed7 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -2070,35 +2070,21 @@ lcl_ApplyCellProperties(
static void
lcl_MergeCells(std::vector<VerticallyMergedCell> & rMergedCells)
{
- if (rMergedCells.size())
+ for(auto& aMergedCell : rMergedCells)
{
- std::vector<VerticallyMergedCell>::iterator aMergedIter =
- rMergedCells.begin();
- while (aMergedIter != rMergedCells.end())
+ // the first of the cells gets the number of cells set as RowSpan
+ // the others get the inverted number of remaining merged cells
+ // (3,-2,-1)
+ sal_Int32 nCellCount = static_cast<sal_Int32>(aMergedCell.aCells.size());
+ if(nCellCount<2)
{
- sal_Int32 nCellCount =
- static_cast<sal_Int32>(aMergedIter->aCells.size());
- std::vector<uno::Reference< beans::XPropertySet > >::iterator
- aCellIter = aMergedIter->aCells.begin();
- bool bFirstCell = true;
- // the first of the cells gets the number of cells set as RowSpan
- // the others get the inverted number of remaining merged cells
- // (3,-2,-1)
- while (aCellIter != aMergedIter->aCells.end())
- {
- (*aCellIter)->setPropertyValue(
- UNO_NAME_ROW_SPAN,
- uno::makeAny(nCellCount));
- if (bFirstCell)
- {
- nCellCount *= -1;
- bFirstCell = false;
- }
- ++nCellCount;
- ++aCellIter;
- }
- ++aMergedIter;
+ SAL_WARN("sw.uno", "incomplete vertical cell merge");
+ continue;
}
+ aMergedCell.aCells.front()->setPropertyValue(UNO_NAME_ROW_SPAN, uno::makeAny(nCellCount--));
+ nCellCount*=-1;
+ for(auto pxPSet = aMergedCell.aCells.begin()+1; nCellCount<0; ++pxPSet, ++nCellCount)
+ (*pxPSet)->setPropertyValue(UNO_NAME_ROW_SPAN, uno::makeAny(nCellCount));
}
}