21#include <document.hxx>
22#include <osl/diagnose.h>
38 bool bIsDate(
nType & SvNumFormatType::DATE);
53 bDummyUpperLeft( false )
60 aRangeListRef(
std::move( xRangeList )),
67 bDummyUpperLeft( false )
74 aRangeListRef( rPositioner.aRangeListRef ),
75 rDocument(rPositioner.rDocument),
76 eGlue(rPositioner.eGlue),
77 nStartCol(rPositioner.nStartCol),
78 nStartRow(rPositioner.nStartRow),
79 bColHeaders(rPositioner.bColHeaders),
80 bRowHeaders(rPositioner.bRowHeaders),
81 bDummyUpperLeft( rPositioner.bDummyUpperLeft )
126 SCROW nMaxRows, nEndRow;
128 nMaxRows = nEndRow = 0;
139 if ( (nTmp =
n2 -
n1 + 1 ) > nMaxRows ) nMaxRows =
static_cast<SCROW>(nTmp);
143 pR = &(*aRangeListRef)[
i];
169 std::unique_ptr<CellState[]> pA(
new CellState[ nCR ]);
170 memset( pA.get(), 0, nCR *
sizeof(CellState) );
172 SCCOL nCol, nCol1, nCol2;
173 SCROW nRow, nRow1, nRow2;
176 pR = &(*aRangeListRef)[
i];
181 for ( nCol = nCol1; nCol <= nCol2; nCol++ )
183 p = pA.get() +
static_cast<sal_uLong>(nCol) * nR + nRow1;
184 for ( nRow = nRow1; nRow <= nRow2; nRow++,
p++ )
185 *
p = CellState::Occupied;
190 bool bGlueCols =
false;
191 for ( nCol = 0; bGlue && nCol < nC; nCol++ )
193 p = pA.get() +
static_cast<sal_uLong>(nCol) * nR;
194 for ( nRow = 0; bGlue && nRow < nR; nRow++,
p++ )
196 if ( *
p == CellState::Occupied )
200 if ( nRow > 0 && nCol > 0 )
206 *
p = CellState::Free;
210 p = pA.get() + (((
static_cast<sal_uLong>(nCol)+1) * nR) - 1);
211 if (*
p == CellState::Free)
213 *
p = CellState::Glue;
219 bool bGlueRows =
false;
220 for ( nRow = 0; bGlue && nRow < nR; nRow++ )
223 for ( nCol = 0; bGlue && nCol < nC; nCol++,
p+=nR )
225 if ( *
p == CellState::Occupied )
227 if ( nCol > 0 && nRow > 0 )
233 *
p = CellState::Free;
237 p = pA.get() + (((
static_cast<sal_uLong>(nC)-1) * nR) + nRow);
238 if (*
p == CellState::Free )
240 *
p = CellState::Glue;
251 if ( *
p == CellState::Hole )
256 if ( bGlueCols && bGlueRows )
258 else if ( bGlueRows )
262 if ( pA[0] != CellState::Occupied )
273 SCCOL nCol1, nCol2, iCol;
274 SCROW nRow1, nRow2, iRow;
277 bool bColStrings =
true;
278 bool bRowStrings =
true;
282 aRangeListRef->front().GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
283 if ( nCol1 > nCol2 || nRow1 > nRow2 )
284 bColStrings = bRowStrings =
false;
287 for (iCol=nCol1; iCol<=nCol2 && bColStrings; iCol++)
289 if (lcl_hasValueDataButNoDates(
rDocument, iCol, nRow1, nTab1 ))
292 for (iRow=nRow1; iRow<=nRow2 && bRowStrings; iRow++)
294 if (lcl_hasValueDataButNoDates(
rDocument, nCol1, iRow, nTab1 ))
303 (
i < nRanges) && (bColStrings || bRowStrings);
307 const ScRange & rR = (*aRangeListRef)[
i];
308 rR.
GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
310 if ( bRowStrings && (bVert || nCol1 ==
nStartCol) )
313 if ( nCol1 <= nCol2 )
314 for (iRow=nRow1; iRow<=nRow2 && bRowStrings; iRow++)
316 if (lcl_hasValueDataButNoDates(
rDocument, nCol1, iRow, nTab1 ))
320 if ( bColStrings && bTopRow )
322 if ( nRow1 <= nRow2 )
323 for (iCol=nCol1; iCol<=nCol2 && bColStrings; iCol++)
325 if (lcl_hasValueDataButNoDates(
rDocument, iCol, nRow1, nTab1 ))
354 SCCOL nCol, nCol1, nCol2;
355 SCROW nRow, nRow1, nRow2;
356 SCTAB nTab, nTab1, nTab2;
367 SCROW nNoGlueRow = 0;
370 const ScRange & rR = (*aRangeListRef)[
i];
371 rR.
GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
372 for ( nTab = nTab1; nTab <= nTab2; nTab++ )
377 for ( nCol = nCol1; nCol <= nCol2; ++nCol, ++nInsCol )
379 RowMap* pCol = &aColMap[nInsCol];
383 sal_uLong nInsRow = (bNoGlue ? nNoGlueRow : nRow1);
384 for ( nRow = nRow1; nRow <= nRow2; nRow++, nInsRow++ )
386 if ( pCol->find( nInsRow ) == pCol->end() )
388 pCol->emplace( nInsRow, std::make_unique<ScAddress>( nCol, nRow, nTab ) );
394 nNoGlueRow += nRow2 - nRow1 + 1;
398 nColCount =
static_cast< SCSIZE >( aColMap.size());
399 if ( !aColMap.empty() )
401 RowMap& rCol = aColMap.begin()->second;
404 nRowCount =
static_cast< SCSIZE >( rCol.size());
409 nColCount -= nColAdd;
411 nRowCount -= nRowAdd;
413 if ( nColCount==0 || nRowCount==0 )
415 RowMap& rCol = aColMap[0];
426 RowMap& rFirstCol = aColMap.begin()->second;
428 for (
const auto& it1 : rFirstCol )
431 for (ColumnMap::iterator it2 = ++aColMap.begin(); it2 != aColMap.end(); ++it2 )
432 it2->second.emplace( nKey,
nullptr );
438 static_cast<SCCOL>(nColAdd),
static_cast<SCROW>(nRowAdd), aColMap ) );
449 ppData( new
std::unique_ptr<
ScAddress> [ nChartCols * nChartRows ] ),
450 ppColHeader( new
std::unique_ptr<
ScAddress> [ nChartCols ] ),
451 ppRowHeader( new
std::unique_ptr<
ScAddress> [ nChartRows ] ),
453 nColCount( nChartCols ),
454 nRowCount( nChartRows )
458 ColumnMap::iterator pColIter = rCols.begin();
459 RowMap& rCol1 = pColIter->second;
462 auto pPos1Iter = rCol1.begin();
468 for ( ; nRow <
nRowCount && pPos1Iter != rCol1.end(); nRow++ )
470 ppRowHeader[ nRow ] = std::move(pPos1Iter->second);
477 for ( ; nRow <
nRowCount && pPos1Iter != rCol1.end(); nRow++ )
479 if (pPos1Iter->second)
493 if ( pColIter != rCols.end() )
495 RowMap& rCol2 = pColIter->second;
496 RowMap::iterator pPosIter = rCol2.begin();
497 if ( pPosIter != rCol2.end() )
504 else if ( pPosIter->second )
509 for ( ; nRow <
nRowCount && pPosIter != rCol2.end(); nRow++,
nIndex++ )
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 ...
std::map< SCCOL, RowMap > ColumnMap
std::map< SCROW, std::unique_ptr< ScAddress > > RowMap
std::unique_ptr< std::unique_ptr< ScAddress >[]> ppRowHeader
std::unique_ptr< std::unique_ptr< ScAddress >[]> ppColHeader
ScChartPositionMap(SCCOL nChartCols, SCROW nChartRows, SCCOL nColAdd, SCROW nRowAdd, ColumnMap &rCols)
std::unique_ptr< std::unique_ptr< ScAddress >[]> ppData
void CheckColRowHeaders()
const ScChartPositionMap * GetPositionMap()
void SetRangeList(const ScRange &rNew)
ScChartPositioner(ScDocument &rDoc, SCTAB nTab, SCCOL nStartColP, SCROW nStartRowP, SCCOL nEndColP, SCROW nEndRowP)
ScRangeListRef aRangeListRef
std::unique_ptr< ScChartPositionMap > pPositionMap
SC_DLLPUBLIC sal_uInt32 GetNumberFormat(SCCOL nCol, SCROW nRow, SCTAB nTab) const
SC_DLLPUBLIC bool HasValueData(SCCOL nCol, SCROW nRow, SCTAB nTab) const
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
void GetVars(SCCOL &nCol1, SCROW &nRow1, SCTAB &nTab1, SCCOL &nCol2, SCROW &nRow2, SCTAB &nTab2) const
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW