[Libreoffice-commits] core.git: sc/source
Aron Budea (via logerrit)
logerrit at kemper.freedesktop.org
Thu Oct 31 06:13:19 UTC 2019
sc/source/filter/dif/difimp.cxx | 2
sc/source/filter/lotus/lotattr.cxx | 2
sc/source/filter/lotus/op.cxx | 2
sc/source/filter/oox/revisionfragment.cxx | 2
sc/source/filter/oox/sheetdatabuffer.cxx | 21 +--
sc/source/filter/rtf/eeimpars.cxx | 10 -
sc/source/filter/rtf/rtfexp.cxx | 4
sc/source/filter/xcl97/XclImpChangeTrack.cxx | 7 -
sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx | 4
sc/source/filter/xml/XMLExportIterator.cxx | 5
sc/source/filter/xml/XMLStylesExportHelper.cxx | 5
sc/source/filter/xml/xmlcelli.cxx | 105 ++++++++---------
sc/source/filter/xml/xmlcoli.cxx | 9 -
sc/source/filter/xml/xmlexprt.cxx | 9 -
sc/source/filter/xml/xmlrowi.cxx | 9 -
sc/source/filter/xml/xmlsubti.cxx | 5
sc/source/filter/xml/xmlsubti.hxx | 2
17 files changed, 108 insertions(+), 95 deletions(-)
New commits:
commit dc4a4c392944afac3d8cb02d0036b653b251efba
Author: Aron Budea <aron.budea at collabora.com>
AuthorDate: Wed Oct 30 09:58:55 2019 +0100
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Oct 31 07:12:41 2019 +0100
sc: rowcol: tdf#50916 convert filter/*
filter/excel has not been touched here
Change-Id: I2ee15c0899157603ce0005a77b768cddf890261a
Reviewed-on: https://gerrit.libreoffice.org/81739
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sc/source/filter/dif/difimp.cxx b/sc/source/filter/dif/difimp.cxx
index 1add7d6d61d7..1d92ed568204 100644
--- a/sc/source/filter/dif/difimp.cxx
+++ b/sc/source/filter/dif/difimp.cxx
@@ -684,7 +684,7 @@ void DifAttrCache::SetNumFormat( const SCCOL nCol, const SCROW nRow, const sal_u
void DifAttrCache::Apply( ScDocument& rDoc, SCTAB nTab )
{
- for( SCCOL nCol : rDoc.GetColumnsRange(nTab, 0, MAXCOL) )
+ for( SCCOL nCol : rDoc.GetColumnsRange(nTab, 0, rDoc.MaxCol()) )
{
if( maColMap.count(nCol) )
maColMap[ nCol ]->Apply( rDoc, nCol, nTab );
diff --git a/sc/source/filter/lotus/lotattr.cxx b/sc/source/filter/lotus/lotattr.cxx
index 875c332bd858..dd7725b40ec2 100644
--- a/sc/source/filter/lotus/lotattr.cxx
+++ b/sc/source/filter/lotus/lotattr.cxx
@@ -243,7 +243,7 @@ void LotAttrTable::SetAttr( const SCCOL nColFirst, const SCCOL nColLast, const S
void LotAttrTable::Apply(LOTUS_ROOT* pLotusRoot, const SCTAB nTabNum)
{
SCCOL nColCnt;
- for( nColCnt = 0 ; nColCnt <= MAXCOL ; nColCnt++ )
+ for( nColCnt = 0 ; nColCnt <= aAttrCache.mpLotusRoot->pDoc->MaxCol() ; nColCnt++ )
pCols[ nColCnt ].Apply(pLotusRoot, nColCnt, nTabNum); // does a Clear() at end
}
diff --git a/sc/source/filter/lotus/op.cxx b/sc/source/filter/lotus/op.cxx
index 5ec588ff7d84..20790ac72bd6 100644
--- a/sc/source/filter/lotus/op.cxx
+++ b/sc/source/filter/lotus/op.cxx
@@ -323,7 +323,7 @@ void OP_Window1(LotusContext& rContext, SvStream& r, sal_uInt16 n)
const bool bFuzzing = utl::ConfigManager::IsFuzzing();
// instead of default, set all Cols in SC by hand
- for (SCCOL nCol = 0 ; nCol <= MAXCOL ; nCol++)
+ for (SCCOL nCol = 0 ; nCol <= rContext.pDoc->MaxCol() ; nCol++)
{
rContext.pDoc->SetColWidth( nCol, 0, nDefWidth );
if (bFuzzing)
diff --git a/sc/source/filter/oox/revisionfragment.cxx b/sc/source/filter/oox/revisionfragment.cxx
index 937c63a2010a..071b8f4717e4 100644
--- a/sc/source/filter/oox/revisionfragment.cxx
+++ b/sc/source/filter/oox/revisionfragment.cxx
@@ -420,7 +420,7 @@ void RevisionLogFragment::importRrc( const AttributeList& rAttribs )
{
case XML_insertRow:
mpImpl->meType = REV_INSERTROW;
- mpImpl->maRange.aEnd.SetCol(MAXCOL);
+ mpImpl->maRange.aEnd.SetCol(getScDocument().MaxCol());
mpImpl->maRange.aStart.SetTab(mpImpl->mnSheetIndex-1);
mpImpl->maRange.aEnd.SetTab(mpImpl->mnSheetIndex-1);
break;
diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx
index 1408d432e3d3..cd7ff12d8d3c 100644
--- a/sc/source/filter/oox/sheetdatabuffer.cxx
+++ b/sc/source/filter/oox/sheetdatabuffer.cxx
@@ -440,7 +440,8 @@ void SheetDataBuffer::finalizeImport()
}
}
- ScDocumentImport& rDoc = getDocImport();
+ ScDocumentImport& rDocImport = getDocImport();
+ ScDocument& rDoc = rDocImport.getDoc();
StylesBuffer& rStyles = getStyles();
for ( const auto& [rCol, rRowStyles] : maStylesPerColumn )
{
@@ -450,9 +451,9 @@ void SheetDataBuffer::finalizeImport()
const ScPatternAttr* pDefPattern = nullptr;
bool bAutoFilter = true;
SCROW nScRow = 0;
- while ( bAutoFilter && nScRow < MAXROW )
+ while ( bAutoFilter && nScRow < rDoc.MaxRow() )
{
- pDefPattern = rDoc.getDoc().GetPattern( nScCol, nScRow, getSheetIndex() );
+ pDefPattern = rDoc.GetPattern( nScCol, nScRow, getSheetIndex() );
if ( pDefPattern )
{
const ScMergeFlagAttr* pAttr = pDefPattern->GetItemSet().GetItem( ATTR_MERGE_FLAG );
@@ -462,8 +463,8 @@ void SheetDataBuffer::finalizeImport()
break;
nScRow++;
}
- if ( !pDefPattern || nScRow == MAXROW )
- pDefPattern = rDoc.getDoc().GetDefPattern();
+ if ( !pDefPattern || nScRow == rDoc.MaxRow() )
+ pDefPattern = rDoc.GetDefPattern();
Xf::AttrList aAttrs(pDefPattern);
for ( const auto& rRowStyle : rRowStyles )
@@ -473,15 +474,15 @@ void SheetDataBuffer::finalizeImport()
if ( pXf )
pXf->applyPatternToAttrList( aAttrs, rRowStyle.mnStartRow, rRowStyle.mnEndRow, rRowStyle.mnNumFmt.second );
}
- if (aAttrs.maAttrs.empty() || aAttrs.maAttrs.back().nEndRow != MAXROW)
+ if (aAttrs.maAttrs.empty() || aAttrs.maAttrs.back().nEndRow != rDoc.MaxRow())
{
ScAttrEntry aEntry;
- aEntry.nEndRow = MAXROW;
+ aEntry.nEndRow = rDoc.MaxRow();
aEntry.pPattern = pDefPattern;
- rDoc.getDoc().GetPool()->Put(*aEntry.pPattern);
+ rDoc.GetPool()->Put(*aEntry.pPattern);
aAttrs.maAttrs.push_back(aEntry);
- if (!sc::NumFmtUtil::isLatinScript(*aEntry.pPattern, rDoc.getDoc()))
+ if (!sc::NumFmtUtil::isLatinScript(*aEntry.pPattern, rDoc))
aAttrs.mbLatinNumFmtOnly = false;
}
@@ -489,7 +490,7 @@ void SheetDataBuffer::finalizeImport()
aAttrParam.mvData.swap(aAttrs.maAttrs);
aAttrParam.mbLatinNumFmtOnly = aAttrs.mbLatinNumFmtOnly;
- rDoc.setAttrEntries(getSheetIndex(), nScCol, std::move(aAttrParam));
+ rDocImport.setAttrEntries(getSheetIndex(), nScCol, std::move(aAttrParam));
}
// merge all cached merged ranges and update right/bottom cell borders
diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx
index 9c6d36b218b6..49acd09a3475 100644
--- a/sc/source/filter/rtf/eeimpars.cxx
+++ b/sc/source/filter/rtf/eeimpars.cxx
@@ -81,16 +81,16 @@ ErrCode ScEEImport::Read( SvStream& rStream, const OUString& rBaseURL )
if ( nEndCol != 0 )
{
nEndCol += maRange.aStart.Col() - 1;
- if ( nEndCol > MAXCOL )
- nEndCol = MAXCOL;
+ if ( nEndCol > mpDoc->MaxCol() )
+ nEndCol = mpDoc->MaxCol();
}
else
nEndCol = maRange.aStart.Col();
if ( nEndRow != 0 )
{
nEndRow += maRange.aStart.Row() - 1;
- if ( nEndRow > MAXROW )
- nEndRow = MAXROW;
+ if ( nEndRow > mpDoc->MaxRow() )
+ nEndRow = mpDoc->MaxRow();
}
else
nEndRow = maRange.aStart.Row();
@@ -151,7 +151,7 @@ void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNu
// Pure ColMerge and ColMerge of the first MergeRow already done during parsing
if (nRow <= nOverlapRowMax && ValidCol(nCol))
{
- while ( nCol <= MAXCOL && mpDoc->HasAttrib( nCol, nRow, nTab,
+ while ( nCol <= mpDoc->MaxCol() && mpDoc->HasAttrib( nCol, nRow, nTab,
nCol, nRow, nTab, HasAttrFlags::Overlapped ) )
{
nCol++;
diff --git a/sc/source/filter/rtf/rtfexp.cxx b/sc/source/filter/rtf/rtfexp.cxx
index 3c9441764b36..17fe3b442706 100644
--- a/sc/source/filter/rtf/rtfexp.cxx
+++ b/sc/source/filter/rtf/rtfexp.cxx
@@ -46,7 +46,7 @@ void ScFormatFilterPluginImpl::ScExportRTF( SvStream& rStrm, ScDocument* pDoc,
ScRTFExport::ScRTFExport( SvStream& rStrmP, ScDocument* pDocP, const ScRange& rRangeP )
:
ScExportBase( rStrmP, pDocP, rRangeP ),
- pCellX( new sal_uLong[ MAXCOL+2 ] )
+ pCellX( new sal_uLong[ pDoc->MaxCol()+2 ] )
{
}
@@ -75,7 +75,7 @@ void ScRTFExport::WriteTab( SCTAB nTab )
rStrm.WriteChar( '{' ).WriteCharPtr( SAL_NEWLINE_STRING );
if ( pDoc->HasTable( nTab ) )
{
- memset( &pCellX[0], 0, (MAXCOL+2) * sizeof(sal_uLong) );
+ memset( &pCellX[0], 0, (pDoc->MaxCol()+2) * sizeof(sal_uLong) );
SCCOL nCol;
SCCOL nEndCol = aRange.aEnd.Col();
for ( nCol = aRange.aStart.Col(); nCol <= nEndCol; nCol++ )
diff --git a/sc/source/filter/xcl97/XclImpChangeTrack.cxx b/sc/source/filter/xcl97/XclImpChangeTrack.cxx
index 8d1ea63facb3..3461652949f2 100644
--- a/sc/source/filter/xcl97/XclImpChangeTrack.cxx
+++ b/sc/source/filter/xcl97/XclImpChangeTrack.cxx
@@ -29,6 +29,7 @@
#include <xilink.hxx>
#include <externalrefmgr.hxx>
#include <document.hxx>
+#include <documentimport.hxx>
#include <excdefs.hxx>
// class XclImpChangeTrack
@@ -303,9 +304,9 @@ void XclImpChangeTrack::ReadChTrInsert()
Read2DRange( aRange );
if( aRecHeader.nOpCode & EXC_CHTR_OP_COLFLAG )
- aRange.aEnd.SetRow( MAXROW );
+ aRange.aEnd.SetRow( GetDocImport().getDoc().MaxRow() );
else
- aRange.aEnd.SetCol( MAXCOL );
+ aRange.aEnd.SetCol( GetDocImport().getDoc().MaxCol() );
bool bValid = pStrm->IsValid();
if( FoundNestedMode() )
@@ -429,7 +430,7 @@ void XclImpChangeTrack::ReadChTrInsertTab()
if( pStrm->IsValid() )
{
nTabIdCount++;
- DoInsertRange(ScRange(0, 0, nTab, MAXCOL, MAXROW, nTab), false);
+ DoInsertRange(ScRange(0, 0, nTab, GetDocImport().getDoc().MaxCol(), GetDocImport().getDoc().MaxRow(), nTab), false);
}
}
}
diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx
index cf12913a17f9..2a55ef3f12aa 100644
--- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx
+++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx
@@ -657,8 +657,8 @@ void ScXMLChangeTrackingImportHelper::SetNewCell(const ScMyContentAction* pActio
{
sal_Int32 nCol, nRow, nTab, nCol2, nRow2, nTab2;
pAction->aBigRange.GetVars(nCol, nRow, nTab, nCol2, nRow2, nTab2);
- if ((nCol >= 0) && (nCol <= MAXCOL) &&
- (nRow >= 0) && (nRow <= MAXROW) &&
+ if ((nCol >= 0) && (nCol <= pDoc->MaxCol()) &&
+ (nRow >= 0) && (nRow <= pDoc->MaxRow()) &&
(nTab >= 0) && (nTab <= MAXTAB))
{
ScAddress aAddress (static_cast<SCCOL>(nCol),
diff --git a/sc/source/filter/xml/XMLExportIterator.cxx b/sc/source/filter/xml/XMLExportIterator.cxx
index 24993493b3fc..80b911b74383 100644
--- a/sc/source/filter/xml/XMLExportIterator.cxx
+++ b/sc/source/filter/xml/XMLExportIterator.cxx
@@ -678,7 +678,8 @@ void ScMyNotEmptyCellsIterator::SkipTable(SCTAB nSkip)
bool ScMyNotEmptyCellsIterator::GetNext(ScMyCell& aCell, ScFormatRangeStyles* pCellStyles)
{
- ScAddress aAddress( MAXCOL + 1, MAXROW + 1, nCurrentTable );
+ ScDocument* pDoc = rExport.GetDocument();
+ ScAddress aAddress( pDoc->MaxCol() + 1, pDoc->MaxRow() + 1, nCurrentTable );
UpdateAddress( aAddress );
@@ -697,7 +698,7 @@ bool ScMyNotEmptyCellsIterator::GetNext(ScMyCell& aCell, ScFormatRangeStyles* pC
if( pDetectiveOp )
pDetectiveOp->UpdateAddress( aAddress );
- bool bFoundCell( ( aAddress.Col() <= MAXCOL ) && ( aAddress.Row() <= MAXROW ) );
+ bool bFoundCell( ( aAddress.Col() <= pDoc->MaxCol() ) && ( aAddress.Row() <= pDoc->MaxRow() + 1 ) );
if( bFoundCell )
{
SetCellData( aCell, aAddress );
diff --git a/sc/source/filter/xml/XMLStylesExportHelper.cxx b/sc/source/filter/xml/XMLStylesExportHelper.cxx
index 006248461bf2..400495d122e6 100644
--- a/sc/source/filter/xml/XMLStylesExportHelper.cxx
+++ b/sc/source/filter/xml/XMLStylesExportHelper.cxx
@@ -633,13 +633,12 @@ bool ScRowFormatRanges::GetNext(ScMyRowFormatRange& aFormatRange)
sal_Int32 ScRowFormatRanges::GetMaxRows() const
{
- sal_Int32 nMaxRows = MAXROW + 1;
+ sal_Int32 nMaxRows(0);
if (!aRowFormatRanges.empty())
{
auto aItr = std::min_element(aRowFormatRanges.begin(), aRowFormatRanges.end(),
[](const ScMyRowFormatRange& a, const ScMyRowFormatRange& b) { return a.nRepeatRows < b.nRepeatRows; });
- if ((*aItr).nRepeatRows < nMaxRows)
- nMaxRows = (*aItr).nRepeatRows;
+ nMaxRows = (*aItr).nRepeatRows;
}
else
{
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 5d8ecdd48401..359f48b1e24f 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -300,10 +300,10 @@ void ScXMLTableRowCellContext::LockSolarMutex()
namespace {
-bool cellExists( const ScAddress& rCellPos )
+bool cellExists( const ScDocument& rDoc, const ScAddress& rCellPos )
{
return( rCellPos.Col() >= 0 && rCellPos.Row() >= 0 &&
- rCellPos.Col() <= MAXCOL && rCellPos.Row() <= MAXROW );
+ rCellPos.Col() <= rDoc.MaxCol() && rCellPos.Row() <= rDoc.MaxRow() );
}
}
@@ -661,10 +661,11 @@ SvXMLImportContextRef ScXMLTableRowCellContext::CreateChildContext( sal_uInt16 n
uno::Reference<drawing::XShapes> xShapes (rXMLImport.GetTables().GetCurrentXShapes());
if (xShapes.is())
{
- if (aCellPos.Col() > MAXCOL)
- aCellPos.SetCol(MAXCOL);
- if (aCellPos.Row() > MAXROW)
- aCellPos.SetRow(MAXROW);
+ ScDocument* pDoc = rXMLImport.GetDocument();
+ if (aCellPos.Col() > pDoc->MaxCol())
+ aCellPos.SetCol(pDoc->MaxCol());
+ if (aCellPos.Row() > pDoc->MaxRow())
+ aCellPos.SetRow(pDoc->MaxRow());
XMLTableShapeImportHelper* pTableShapeImport =
static_cast< XMLTableShapeImportHelper* >( rXMLImport.GetShapeImport().get() );
pTableShapeImport->SetOnTable(false);
@@ -738,11 +739,12 @@ void ScXMLTableRowCellContext::DoMerge( const ScAddress& rScAddress, const SCCOL
{
SCCOL mergeToCol = rScAddress.Col() + nCols;
SCROW mergeToRow = rScAddress.Row() + nRows;
- bool bInBounds = rScAddress.Col() <= MAXCOL && rScAddress.Row() <= MAXROW &&
- mergeToCol <= MAXCOL && mergeToRow <= MAXROW;
+ ScDocument* pDoc = rXMLImport.GetDocument();
+ bool bInBounds = rScAddress.Col() <= pDoc->MaxCol() && rScAddress.Row() <= pDoc->MaxRow() &&
+ mergeToCol <= pDoc->MaxCol() && mergeToRow <= pDoc->MaxRow();
if( bInBounds )
{
- rXMLImport.GetDocument()->DoMerge( rScAddress.Tab(),
+ pDoc->DoMerge( rScAddress.Tab(),
rScAddress.Col(), rScAddress.Row(), mergeToCol, mergeToRow );
}
}
@@ -950,10 +952,11 @@ void ScXMLTableRowCellContext::SetAnnotation(const ScAddress& rPos)
// core implementation
void ScXMLTableRowCellContext::SetDetectiveObj( const ScAddress& rPosition )
{
- if( cellExists(rPosition) && pDetectiveObjVec && !pDetectiveObjVec->empty() )
+ ScDocument* pDoc = rXMLImport.GetDocument();
+ if( pDoc && cellExists(*pDoc, rPosition) && pDetectiveObjVec && !pDetectiveObjVec->empty() )
{
LockSolarMutex();
- ScDetectiveFunc aDetFunc( rXMLImport.GetDocument(), rPosition.Tab() );
+ ScDetectiveFunc aDetFunc( pDoc, rPosition.Tab() );
uno::Reference<container::XIndexAccess> xShapesIndex = rXMLImport.GetTables().GetCurrentXShapes(); // make draw page
for(const auto& rDetectiveObj : *pDetectiveObjVec)
{
@@ -971,23 +974,20 @@ void ScXMLTableRowCellContext::SetDetectiveObj( const ScAddress& rPosition )
// core implementation
void ScXMLTableRowCellContext::SetCellRangeSource( const ScAddress& rPosition )
{
- if( cellExists(rPosition) && pCellRangeSource && !pCellRangeSource->sSourceStr.isEmpty() &&
+ ScDocument* pDoc = rXMLImport.GetDocument();
+ if( pDoc && cellExists(*pDoc, rPosition) && pCellRangeSource && !pCellRangeSource->sSourceStr.isEmpty() &&
!pCellRangeSource->sFilterName.isEmpty() && !pCellRangeSource->sURL.isEmpty() )
{
- ScDocument* pDoc = rXMLImport.GetDocument();
- if (pDoc)
- {
- LockSolarMutex();
- ScRange aDestRange( rPosition.Col(), rPosition.Row(), rPosition.Tab(),
- rPosition.Col() + static_cast<SCCOL>(pCellRangeSource->nColumns - 1),
- rPosition.Row() + static_cast<SCROW>(pCellRangeSource->nRows - 1), rPosition.Tab() );
- OUString sFilterName( pCellRangeSource->sFilterName );
- OUString sSourceStr( pCellRangeSource->sSourceStr );
- ScAreaLink* pLink = new ScAreaLink( pDoc->GetDocumentShell(), pCellRangeSource->sURL,
- sFilterName, pCellRangeSource->sFilterOptions, sSourceStr, aDestRange, pCellRangeSource->nRefresh );
- sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
- pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, pCellRangeSource->sURL, &sFilterName, &sSourceStr );
- }
+ LockSolarMutex();
+ ScRange aDestRange( rPosition.Col(), rPosition.Row(), rPosition.Tab(),
+ rPosition.Col() + static_cast<SCCOL>(pCellRangeSource->nColumns - 1),
+ rPosition.Row() + static_cast<SCROW>(pCellRangeSource->nRows - 1), rPosition.Tab() );
+ OUString sFilterName( pCellRangeSource->sFilterName );
+ OUString sSourceStr( pCellRangeSource->sSourceStr );
+ ScAreaLink* pLink = new ScAreaLink( pDoc->GetDocumentShell(), pCellRangeSource->sURL,
+ sFilterName, pCellRangeSource->sFilterOptions, sSourceStr, aDestRange, pCellRangeSource->nRefresh );
+ sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
+ pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, pCellRangeSource->sURL, &sFilterName, &sSourceStr );
}
}
@@ -1036,12 +1036,13 @@ void ScXMLTableRowCellContext::SetFormulaCell(ScFormulaCell* pFCell) const
void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos,
const SCCOL nCurrentCol, const ::boost::optional< OUString >& pOUText )
{
+ ScDocument* pDoc = rXMLImport.GetDocument();
bool bDoIncrement = true;
//matrix reference cells that contain text formula results;
//cell was already put in document, just need to set text here.
- if( rXMLImport.GetTables().IsPartOfMatrix(rCurrentPos) )
+ if( pDoc && rXMLImport.GetTables().IsPartOfMatrix(rCurrentPos) )
{
- ScRefCellValue aCell(*rXMLImport.GetDocument(), rCurrentPos);
+ ScRefCellValue aCell(*pDoc, rCurrentPos);
bDoIncrement = aCell.meType == CELLTYPE_FORMULA;
if ( bDoIncrement )
{
@@ -1063,7 +1064,6 @@ void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos,
{
if (bDoIncrement && !IsPossibleErrorString() && pFCell)
{
- ScDocument* pDoc = rXMLImport.GetDocument();
pFCell->SetHybridString(pDoc->GetSharedStringPool().intern(aCellString));
pFCell->ResetDirty();
}
@@ -1072,7 +1072,7 @@ void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos,
ScAddress aTopLeftMatrixCell;
if (pFCell && pFCell->GetMatrixOrigin(aTopLeftMatrixCell))
{
- ScFormulaCell* pMatrixCell = rXMLImport.GetDocument()->GetFormulaCell(aTopLeftMatrixCell);
+ ScFormulaCell* pMatrixCell = pDoc->GetFormulaCell(aTopLeftMatrixCell);
if (pMatrixCell)
pMatrixCell->SetDirty();
}
@@ -1175,6 +1175,7 @@ bool isEmptyOrNote( const ScDocument* pDoc, const ScAddress& rCurrentPos )
void ScXMLTableRowCellContext::AddTextAndValueCell( const ScAddress& rCellPos,
const ::boost::optional< OUString >& pOUText, ScAddress& rCurrentPos )
{
+ ScDocument* pDoc = rXMLImport.GetDocument();
ScMyTables& rTables = rXMLImport.GetTables();
bool bWasEmpty = bIsEmpty;
for (SCCOL i = 0; i < nColsRepeated; ++i)
@@ -1183,7 +1184,7 @@ void ScXMLTableRowCellContext::AddTextAndValueCell( const ScAddress& rCellPos,
// it makes no sense to import data after the last supported column
// fdo#58539 & gnome#627150
- if(rCurrentPos.Col() > MAXCOL)
+ if(rCurrentPos.Col() > pDoc->MaxCol())
break;
if (i > 0)
@@ -1196,7 +1197,7 @@ void ScXMLTableRowCellContext::AddTextAndValueCell( const ScAddress& rCellPos,
// it makes no sense to import data after last supported row
// fdo#58539 & gnome#627150
- if(rCurrentPos.Row() > MAXROW)
+ if(rCurrentPos.Row() > pDoc->MaxRow())
break;
if( (rCurrentPos.Col() == 0) && (j > 0) )
@@ -1204,9 +1205,9 @@ void ScXMLTableRowCellContext::AddTextAndValueCell( const ScAddress& rCellPos,
rTables.AddRow();
rTables.AddColumn(false);
}
- if( cellExists(rCurrentPos) )
+ if( cellExists(*pDoc, rCurrentPos) )
{
- if( !bIsCovered || isEmptyOrNote(rXMLImport.GetDocument(), rCurrentPos) )
+ if( !bIsCovered || isEmptyOrNote(pDoc, rCurrentPos) )
{
switch (nCellType)
{
@@ -1241,7 +1242,7 @@ void ScXMLTableRowCellContext::AddTextAndValueCell( const ScAddress& rCellPos,
{
if (!bWasEmpty || mxAnnotationData.get())
{
- if (rCurrentPos.Row() > MAXROW)
+ if (rCurrentPos.Row() > pDoc->MaxRow())
rXMLImport.SetRangeOverflowType(SCWARN_IMPORT_ROW_OVERFLOW);
else
rXMLImport.SetRangeOverflowType(SCWARN_IMPORT_COLUMN_OVERFLOW);
@@ -1310,10 +1311,11 @@ void ScXMLTableRowCellContext::AddNonFormulaCell( const ScAddress& rCellPos )
{
::boost::optional< OUString > pOUText;
+ ScDocument* pDoc = rXMLImport.GetDocument();
if( nCellType == util::NumberFormat::TEXT )
{
- if( !bIsEmpty && !maStringValue && !mbEditEngineHasText && cellExists(rCellPos) && CellsAreRepeated() )
- pOUText = getOutputString(rXMLImport.GetDocument(), rCellPos);
+ if( !bIsEmpty && !maStringValue && !mbEditEngineHasText && cellExists(*pDoc, rCellPos) && CellsAreRepeated() )
+ pOUText = getOutputString(pDoc, rCellPos);
if (!mbEditEngineHasText && !pOUText && !maStringValue)
bIsEmpty = true;
@@ -1327,15 +1329,15 @@ void ScXMLTableRowCellContext::AddNonFormulaCell( const ScAddress& rCellPos )
if( CellsAreRepeated() )
{
- SCCOL nStartCol( std::min(rCellPos.Col(), MAXCOL) );
- SCROW nStartRow( std::min(rCellPos.Row(), MAXROW) );
- SCCOL nEndCol( std::min<SCCOL>(rCellPos.Col() + nColsRepeated - 1, MAXCOL) );
- SCROW nEndRow( std::min(rCellPos.Row() + nRepeatedRows - 1, MAXROW) );
+ SCCOL nStartCol( std::min(rCellPos.Col(), pDoc->MaxCol()) );
+ SCROW nStartRow( std::min(rCellPos.Row(), pDoc->MaxRow()) );
+ SCCOL nEndCol( std::min<SCCOL>(rCellPos.Col() + nColsRepeated - 1, pDoc->MaxCol()) );
+ SCROW nEndRow( std::min(rCellPos.Row() + nRepeatedRows - 1, pDoc->MaxRow()) );
ScRange aScRange( nStartCol, nStartRow, rCellPos.Tab(), nEndCol, nEndRow, rCellPos.Tab() );
SetContentValidation( aScRange );
rXMLImport.GetStylesImportHelper()->AddRange( aScRange );
}
- else if( cellExists(rCellPos) )
+ else if( cellExists(*pDoc, rCellPos) )
{
rXMLImport.GetStylesImportHelper()->AddCell(rCellPos);
SetContentValidation( rCellPos );
@@ -1345,7 +1347,7 @@ void ScXMLTableRowCellContext::AddNonFormulaCell( const ScAddress& rCellPos )
void ScXMLTableRowCellContext::PutFormulaCell( const ScAddress& rCellPos )
{
ScDocument* pDoc = rXMLImport.GetDocument();
- ScDocumentImport& rDoc = rXMLImport.GetDoc();
+ ScDocumentImport& rDocImport = rXMLImport.GetDoc();
OUString aText = maFormula->first;
@@ -1380,19 +1382,20 @@ void ScXMLTableRowCellContext::PutFormulaCell( const ScAddress& rCellPos )
if( eGrammar != formula::FormulaGrammar::GRAM_EXTERNAL )
aFormulaNmsp.clear();
pCode->AssignXMLString( aText, aFormulaNmsp );
- rDoc.getDoc().IncXMLImportedFormulaCount( aText.getLength() );
+ rDocImport.getDoc().IncXMLImportedFormulaCount( aText.getLength() );
}
}
ScFormulaCell* pNewCell = new ScFormulaCell(pDoc, rCellPos, std::move(pCode), eGrammar, ScMatrixMode::NONE);
SetFormulaCell(pNewCell);
- rDoc.setFormulaCell(rCellPos, pNewCell);
+ rDocImport.setFormulaCell(rCellPos, pNewCell);
}
}
void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos )
{
- if( cellExists(rCellPos) )
+ ScDocument* pDoc = rXMLImport.GetDocument();
+ if( cellExists(*pDoc, rCellPos) )
{
SetContentValidation( rCellPos );
SAL_WARN_IF((nColsRepeated != 1) || (nRepeatedRows != 1), "sc", "repeated cells with formula not possible now");
@@ -1407,14 +1410,14 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos )
//value/text of each matrix cell later
rXMLImport.GetTables().AddMatrixRange(
rCellPos.Col(), rCellPos.Row(),
- std::min<SCCOL>(rCellPos.Col() + nMatrixCols - 1, MAXCOL),
- std::min<SCROW>(rCellPos.Row() + nMatrixRows - 1, MAXROW),
+ std::min<SCCOL>(rCellPos.Col() + nMatrixCols - 1, pDoc->MaxCol()),
+ std::min<SCROW>(rCellPos.Row() + nMatrixRows - 1, pDoc->MaxRow()),
maFormula->first, maFormula->second, eGrammar);
// Set the value/text of the top-left matrix position in its
// cached result. For import, we only need to set the correct
// matrix geometry and the value type of the top-left element.
- ScFormulaCell* pFCell = rXMLImport.GetDocument()->GetFormulaCell(rCellPos);
+ ScFormulaCell* pFCell = pDoc->GetFormulaCell(rCellPos);
if (pFCell)
{
ScMatrixRef pMat(new ScMatrix(nMatrixCols, nMatrixRows));
@@ -1424,7 +1427,7 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos )
{
pFCell->SetResultMatrix(
nMatrixCols, nMatrixRows, pMat, new formula::FormulaStringToken(
- rXMLImport.GetDocument()->GetSharedStringPool().intern( *maStringValue)));
+ pDoc->GetSharedStringPool().intern( *maStringValue)));
pFCell->ResetDirty();
}
}
@@ -1447,7 +1450,7 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos )
}
else
{
- if (rCellPos.Row() > MAXROW)
+ if (rCellPos.Row() > pDoc->MaxRow())
rXMLImport.SetRangeOverflowType(SCWARN_IMPORT_ROW_OVERFLOW);
else
rXMLImport.SetRangeOverflowType(SCWARN_IMPORT_COLUMN_OVERFLOW);
diff --git a/sc/source/filter/xml/xmlcoli.cxx b/sc/source/filter/xml/xmlcoli.cxx
index 6602e6ad9c62..1d4d0966d707 100644
--- a/sc/source/filter/xml/xmlcoli.cxx
+++ b/sc/source/filter/xml/xmlcoli.cxx
@@ -88,16 +88,17 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLTableColContext::c
void SAL_CALL ScXMLTableColContext::endFastElement( sal_Int32 /*nElement*/ )
{
ScXMLImport& rXMLImport = GetScImport();
+ ScDocument* pDoc = rXMLImport.GetDocument();
SCTAB nSheet = rXMLImport.GetTables().GetCurrentSheet();
sal_Int32 nCurrentColumn = rXMLImport.GetTables().GetCurrentColCount();
uno::Reference<sheet::XSpreadsheet> xSheet(rXMLImport.GetTables().GetCurrentXSheet());
if(xSheet.is())
{
sal_Int32 nLastColumn(nCurrentColumn + nColCount - 1);
- if (nLastColumn > MAXCOL)
- nLastColumn = MAXCOL;
- if (nCurrentColumn > MAXCOL)
- nCurrentColumn = MAXCOL;
+ if (nLastColumn > pDoc->MaxCol())
+ nLastColumn = pDoc->MaxCol();
+ if (nCurrentColumn > pDoc->MaxCol())
+ nCurrentColumn = pDoc->MaxCol();
uno::Reference<table::XColumnRowRange> xColumnRowRange (xSheet->getCellRangeByPosition(nCurrentColumn, 0, nLastColumn, 0), uno::UNO_QUERY);
if (xColumnRowRange.is())
{
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 6d91fae22f76..fc12af17c4b1 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -1574,6 +1574,7 @@ void ScXMLExport::ExportFormatRanges(const sal_Int32 nStartCol, const sal_Int32
{
pCellStyles->GetFormatRanges(0, pSharedData->GetLastColumn(nSheet), nStartRow + nRows, nSheet, pRowFormatRanges.get());
sal_Int32 nMaxRows = pRowFormatRanges->GetMaxRows();
+ OSL_ENSURE(nMaxRows, "something went wrong");
if (nMaxRows >= nTotalRows - nRows)
{
OpenRow(nSheet, nStartRow + nRows, nTotalRows - nRows, aRowAttr);
@@ -2260,7 +2261,7 @@ void ScXMLExport::collectAutoStyles()
SCTAB nTabCount = pDoc->GetTableCount();
for (SCTAB nTab=0; nTab<nTabCount; ++nTab)
if (pDoc->IsStreamValid(nTab))
- pDoc->InterpretDirtyCells(ScRange(0, 0, nTab, MAXCOL, MAXROW, nTab));
+ pDoc->InterpretDirtyCells(ScRange(0, 0, nTab, pDoc->MaxCol(), pDoc->MaxRow(), nTab));
// stored cell styles
const std::vector<ScCellStyleEntry>& rCellEntries = pSheetData->GetCellStyles();
@@ -2558,7 +2559,7 @@ void ScXMLExport::collectAutoStyles()
else
pColumnStyles->AddNewTable(nTable, nColumns);
sal_Int32 nColumn = 0;
- while (nColumn <= MAXCOL)
+ while (nColumn <= pDoc->MaxCol())
{
sal_Int32 nIndex(-1);
bool bIsVisible(true);
@@ -2587,9 +2588,9 @@ void ScXMLExport::collectAutoStyles()
sal_Int32 nRows(pDoc->GetLastChangedRow(sal::static_int_cast<SCTAB>(nTable)));
pSharedData->SetLastRow(nTable, nRows);
- pRowStyles->AddNewTable(nTable, MAXROW);
+ pRowStyles->AddNewTable(nTable, pDoc->MaxRow());
sal_Int32 nRow = 0;
- while (nRow <= MAXROW)
+ while (nRow <= pDoc->MaxRow())
{
sal_Int32 nIndex = 0;
uno::Reference <beans::XPropertySet> xRowProperties(xTableRows->getByIndex(nRow), uno::UNO_QUERY);
diff --git a/sc/source/filter/xml/xmlrowi.cxx b/sc/source/filter/xml/xmlrowi.cxx
index 8491d94f8397..9f28b2bacad0 100644
--- a/sc/source/filter/xml/xmlrowi.cxx
+++ b/sc/source/filter/xml/xmlrowi.cxx
@@ -136,6 +136,7 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
void SAL_CALL ScXMLTableRowContext::endFastElement(sal_Int32 /*nElement*/)
{
ScXMLImport& rXMLImport(GetScImport());
+ ScDocument* pDoc(rXMLImport.GetDocument());
if (!bHasCell && nRepeatedRows > 1)
{
for (sal_Int32 i = 0; i < nRepeatedRows - 1; ++i) //one row is always added
@@ -148,10 +149,10 @@ void SAL_CALL ScXMLTableRowContext::endFastElement(sal_Int32 /*nElement*/)
if(xSheet.is())
{
sal_Int32 nFirstRow(nCurrentRow - nRepeatedRows + 1);
- if (nFirstRow > MAXROW)
- nFirstRow = MAXROW;
- if (nCurrentRow > MAXROW)
- nCurrentRow = MAXROW;
+ if (nFirstRow > pDoc->MaxRow())
+ nFirstRow = pDoc->MaxRow();
+ if (nCurrentRow > pDoc->MaxRow())
+ nCurrentRow = pDoc->MaxRow();
uno::Reference <table::XCellRange> xCellRange(xSheet->getCellRangeByPosition(0, nFirstRow, 0, nCurrentRow));
if (xCellRange.is())
{
diff --git a/sc/source/filter/xml/xmlsubti.cxx b/sc/source/filter/xml/xmlsubti.cxx
index 86292f18406a..dfb058cd2580 100644
--- a/sc/source/filter/xml/xmlsubti.cxx
+++ b/sc/source/filter/xml/xmlsubti.cxx
@@ -284,4 +284,9 @@ bool ScMyTables::IsPartOfMatrix(const ScAddress& rScAddress) const
return false;
}
+SCCOL ScMyTables::GetCurrentColCount() const
+{
+ return std::min<sal_Int32>(nCurrentColCount, rImport.GetDocument()->MaxCol());
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/xml/xmlsubti.hxx b/sc/source/filter/xml/xmlsubti.hxx
index 97f7812ce776..6af4568fbe7e 100644
--- a/sc/source/filter/xml/xmlsubti.hxx
+++ b/sc/source/filter/xml/xmlsubti.hxx
@@ -83,7 +83,7 @@ public:
ScXMLTabProtectionData& GetCurrentProtectionData() { return maProtectionData; }
const OUString& GetCurrentSheetName() const { return sCurrentSheetName; }
SCTAB GetCurrentSheet() const { return (maCurrentCellPos.Tab() >= 0) ? maCurrentCellPos.Tab() : 0; }
- SCCOL GetCurrentColCount() const { return std::min<sal_Int32>(nCurrentColCount, MAXCOL); }
+ SCCOL GetCurrentColCount() const;
SCROW GetCurrentRow() const { return (maCurrentCellPos.Row() >= 0) ? maCurrentCellPos.Row() : 0; }
const css::uno::Reference< css::sheet::XSpreadsheet >&
GetCurrentXSheet() const { return xCurrentSheet; }
More information about the Libreoffice-commits
mailing list