21 #include <document.hxx>
22 #include <osl/diagnose.h>
36 bool bIsDate(nType & SvNumFormatType::DATE);
51 bDummyUpperLeft( false )
58 aRangeListRef( rRangeList ),
65 bDummyUpperLeft( false )
72 aRangeListRef( rPositioner.aRangeListRef ),
73 rDocument(rPositioner.rDocument),
74 eGlue(rPositioner.eGlue),
75 nStartCol(rPositioner.nStartCol),
76 nStartRow(rPositioner.nStartRow),
77 bColHeaders(rPositioner.bColHeaders),
78 bRowHeaders(rPositioner.bRowHeaders),
79 bDummyUpperLeft( rPositioner.bDummyUpperLeft )
124 SCROW nMaxRows, nEndRow;
125 nMaxCols = nEndCol = 0;
126 nMaxRows = nEndRow = 0;
133 if ( (n2 = pR->
aEnd.
Col() ) > nEndCol ) nEndCol =
static_cast<SCCOL>(n2 );
134 if ( (nTmp = n2 - n1 + 1 ) > nMaxCols ) nMaxCols = static_cast<SCCOL>(nTmp);
136 if ( (n2 = pR->
aEnd.
Row() ) > nEndRow ) nEndRow =
static_cast<SCROW>(n2 );
137 if ( (nTmp = n2 - n1 + 1 ) > nMaxRows ) nMaxRows = static_cast<SCROW>(nTmp);
141 pR = &(*aRangeListRef)[
i];
167 std::unique_ptr<CellState[]> pA(
new CellState[ nCR ]);
168 memset( pA.get(), 0, nCR *
sizeof(CellState) );
170 SCCOL nCol, nCol1, nCol2;
171 SCROW nRow, nRow1, nRow2;
174 pR = &(*aRangeListRef)[
i];
179 for ( nCol = nCol1; nCol <= nCol2; nCol++ )
181 p = pA.get() +
static_cast<sal_uLong>(nCol) * nR + nRow1;
182 for ( nRow = nRow1; nRow <= nRow2; nRow++, p++ )
183 *p = CellState::Occupied;
188 bool bGlueCols =
false;
189 for ( nCol = 0; bGlue && nCol < nC; nCol++ )
191 p = pA.get() +
static_cast<sal_uLong>(nCol) * nR;
192 for ( nRow = 0; bGlue && nRow < nR; nRow++, p++ )
194 if ( *p == CellState::Occupied )
198 if ( nRow > 0 && nCol > 0 )
204 *p = CellState::Free;
208 p = pA.get() + (((
static_cast<sal_uLong>(nCol)+1) * nR) - 1);
209 if (*p == CellState::Free)
211 *p = CellState::Glue;
217 bool bGlueRows =
false;
218 for ( nRow = 0; bGlue && nRow < nR; nRow++ )
221 for ( nCol = 0; bGlue && nCol < nC; nCol++, p+=nR )
223 if ( *p == CellState::Occupied )
225 if ( nCol > 0 && nRow > 0 )
231 *p = CellState::Free;
235 p = pA.get() + (((
static_cast<sal_uLong>(nC)-1) * nR) + nRow);
236 if (*p == CellState::Free )
238 *p = CellState::Glue;
249 if ( *p == CellState::Hole )
254 if ( bGlueCols && bGlueRows )
256 else if ( bGlueRows )
260 if ( pA[0] != CellState::Occupied )
271 SCCOL nCol1, nCol2, iCol;
272 SCROW nRow1, nRow2, iRow;
275 bool bColStrings =
true;
276 bool bRowStrings =
true;
281 if ( nCol1 > nCol2 || nRow1 > nRow2 )
282 bColStrings = bRowStrings =
false;
285 for (iCol=nCol1; iCol<=nCol2 && bColStrings; iCol++)
287 if (lcl_hasValueDataButNoDates( rDocument, iCol, nRow1, nTab1 ))
290 for (iRow=nRow1; iRow<=nRow2 && bRowStrings; iRow++)
292 if (lcl_hasValueDataButNoDates( rDocument, nCol1, iRow, nTab1 ))
301 (
i < nRanges) && (bColStrings || bRowStrings);
305 const ScRange & rR = (*aRangeListRef)[
i];
306 rR.
GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
308 if ( bRowStrings && (bVert || nCol1 ==
nStartCol) )
311 if ( nCol1 <= nCol2 )
312 for (iRow=nRow1; iRow<=nRow2 && bRowStrings; iRow++)
314 if (lcl_hasValueDataButNoDates( rDocument, nCol1, iRow, nTab1 ))
318 if ( bColStrings && bTopRow )
320 if ( nRow1 <= nRow2 )
321 for (iCol=nCol1; iCol<=nCol2 && bColStrings; iCol++)
323 if (lcl_hasValueDataButNoDates( rDocument, iCol, nRow1, nTab1 ))
352 SCCOL nCol, nCol1, nCol2;
353 SCROW nRow, nRow1, nRow2;
354 SCTAB nTab, nTab1, nTab2;
365 SCROW nNoGlueRow = 0;
368 const ScRange & rR = (*aRangeListRef)[
i];
369 rR.
GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
370 for ( nTab = nTab1; nTab <= nTab2; nTab++ )
375 for ( nCol = nCol1; nCol <= nCol2; ++nCol, ++nInsCol )
377 RowMap* pCol = &aColMap[nInsCol];
381 sal_uLong nInsRow = (bNoGlue ? nNoGlueRow : nRow1);
382 for ( nRow = nRow1; nRow <= nRow2; nRow++, nInsRow++ )
384 if ( pCol->find( nInsRow ) == pCol->end() )
386 pCol->emplace( nInsRow, std::make_unique<ScAddress>( nCol, nRow, nTab ) );
392 nNoGlueRow += nRow2 - nRow1 + 1;
396 nColCount =
static_cast< SCSIZE >( aColMap.size());
397 if ( !aColMap.empty() )
399 RowMap& rCol = aColMap.begin()->second;
402 nRowCount =
static_cast< SCSIZE >( rCol.size());
407 nColCount -= nColAdd;
409 nRowCount -= nRowAdd;
411 if ( nColCount==0 || nRowCount==0 )
413 RowMap& rCol = aColMap[0];
424 RowMap& rFirstCol = aColMap.begin()->second;
426 RowMap::const_iterator it1 = rFirstCol.begin();
430 for (ColumnMap::iterator it2 = ++aColMap.begin(); it2 != aColMap.end(); ++it2 )
431 it2->second.emplace( nKey,
nullptr );
437 static_cast<SCCOL>(nColAdd), static_cast<SCROW>(nRowAdd), aColMap ) );
448 ppData( new
std::unique_ptr<
ScAddress> [ nChartCols * nChartRows ] ),
449 ppColHeader( new
std::unique_ptr<
ScAddress> [ nChartCols ] ),
450 ppRowHeader( new
std::unique_ptr<
ScAddress> [ nChartRows ] ),
453 nRowCount( nChartRows )
457 ColumnMap::iterator pColIter = rCols.begin();
458 RowMap& rCol1 = pColIter->second;
461 auto pPos1Iter = rCol1.begin();
467 for ( ; nRow <
nRowCount && pPos1Iter != rCol1.end(); nRow++ )
469 ppRowHeader[ nRow ] = std::move(pPos1Iter->second);
476 for ( ; nRow <
nRowCount && pPos1Iter != rCol1.end(); nRow++ )
478 if (pPos1Iter->second)
492 if ( pColIter != rCols.end() )
494 RowMap& rCol2 = pColIter->second;
495 RowMap::iterator pPosIter = rCol2.begin();
496 if ( pPosIter != rCol2.end() )
503 else if ( pPosIter->second )
508 for ( ; nRow <
nRowCount && pPosIter != rCol2.end(); nRow++, nIndex++ )
510 ppData[ nIndex ] = std::move(pPosIter->second);
std::unique_ptr< std::unique_ptr< ScAddress >[]> ppColHeader
SC_DLLPUBLIC void GetNumberFormat(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt32 &rFormat) const
ScRangeListRef aRangeListRef
std::map< sal_uLong, std::unique_ptr< ScAddress > > RowMap
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
ScChartPositioner(ScDocument &rDoc, SCTAB nTab, SCCOL nStartColP, SCROW nStartRowP, SCCOL nEndColP, SCROW nEndRowP)
void SetRangeList(const ScRange &rNew)
ScChartPositionMap(SCCOL nChartCols, SCROW nChartRows, SCCOL nColAdd, SCROW nRowAdd, ColumnMap &rCols)
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
std::unique_ptr< ScChartPositionMap > pPositionMap
void CheckColRowHeaders()
std::unique_ptr< std::unique_ptr< ScAddress >[]> ppData
void GetVars(SCCOL &nCol1, SCROW &nRow1, SCTAB &nTab1, SCCOL &nCol2, SCROW &nRow2, SCTAB &nTab2) const
SC_DLLPUBLIC bool HasValueData(SCCOL nCol, SCROW nRow, SCTAB nTab) const
std::map< sal_uLong, RowMap > ColumnMap
std::unique_ptr< std::unique_ptr< ScAddress >[]> ppRowHeader
const ScChartPositionMap * GetPositionMap()