sc: rowcol: tdf#50916 convert filter/excel for the most part

Change-Id: I8ae255de6fcd9d7fd379a48fb7e84adcbf7fa4ff
TODO: pieces in frmbase.cxx, xestream.cxx and xistyle.cxx
Reviewed-on: https://gerrit.libreoffice.org/81486
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Aron Budea
2019-10-25 12:43:11 +02:00
committed by Noel Grandin
parent c8067df2fe
commit 1bca91f086
11 changed files with 55 additions and 51 deletions
+12 -11
View File
@@ -64,12 +64,13 @@ void XclImpColRowSettings::SetDefWidth( sal_uInt16 nDefWidth, bool bStdWidthRec
void XclImpColRowSettings::SetWidthRange( SCCOL nCol1, SCCOL nCol2, sal_uInt16 nWidth )
{
nCol2 = ::std::min( nCol2, MAXCOL );
ScDocument& rDoc = GetDoc();
nCol2 = ::std::min( nCol2, rDoc.MaxCol() );
if (nCol2 == 256)
// In BIFF8, the column range is 0-255, and the use of 256 probably
// means the range should extend to the max column if the loading app
// support columns beyond 255.
nCol2 = MAXCOL;
nCol2 = rDoc.MaxCol();
nCol1 = ::std::min( nCol1, nCol2 );
maColWidths.insert_back(nCol1, nCol2+1, nWidth);
@@ -89,7 +90,7 @@ void XclImpColRowSettings::HideCol( SCCOL nCol )
void XclImpColRowSettings::HideColRange( SCCOL nCol1, SCCOL nCol2 )
{
nCol2 = ::std::min( nCol2, MAXCOL );
nCol2 = ::std::min( nCol2, GetDoc().MaxCol() );
nCol1 = ::std::min( nCol1, nCol2 );
for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
@@ -167,7 +168,7 @@ void XclImpColRowSettings::SetDefaultXF( SCCOL nCol1, SCCOL nCol2, sal_uInt16 nX
/* assign the default column formatting here to ensure that
explicit cell formatting is not overwritten. */
OSL_ENSURE( (nCol1 <= nCol2) && ValidCol( nCol2 ), "XclImpColRowSettings::SetDefaultXF - invalid column index" );
nCol2 = ::std::min( nCol2, MAXCOL );
nCol2 = ::std::min( nCol2, GetDoc().MaxCol() );
nCol1 = ::std::min( nCol1, nCol2 );
XclImpXFRangeBuffer& rXFRangeBuffer = GetXFRangeBuffer();
for( SCCOL nCol = nCol1; nCol <= nCol2; ++nCol )
@@ -184,7 +185,7 @@ void XclImpColRowSettings::Convert( SCTAB nScTab )
// column widths ----------------------------------------------------------
maColWidths.build_tree();
for (SCCOL nCol = 0; nCol <= MAXCOL; ++nCol)
for (SCCOL nCol = 0; nCol <= rDoc.MaxCol(); ++nCol)
{
sal_uInt16 nWidth = mnDefWidth;
if (GetColFlag(nCol, ExcColRowFlags::Used))
@@ -208,10 +209,10 @@ void XclImpColRowSettings::Convert( SCTAB nScTab )
// row heights ------------------------------------------------------------
// #i54252# set default row height
rDoc.SetRowHeightOnly( 0, MAXROW, nScTab, mnDefHeight );
rDoc.SetRowHeightOnly( 0, rDoc.MaxRow(), nScTab, mnDefHeight );
if( ::get_flag( mnDefRowFlags, EXC_DEFROW_UNSYNCED ) )
// first access to row flags, do not ask for old flags
rDoc.SetRowFlags( 0, MAXROW, nScTab, CRFlags::ManualSize );
rDoc.SetRowFlags( 0, rDoc.MaxRow(), nScTab, CRFlags::ManualSize );
maRowHeights.build_tree();
if (!maRowHeights.is_tree_valid())
@@ -273,7 +274,7 @@ void XclImpColRowSettings::ConvertHiddenFlags( SCTAB nScTab )
ScDocument& rDoc = GetDoc();
// hide the columns
for( SCCOL nCol : rDoc.GetColumnsRange(nScTab, 0, MAXCOL) )
for( SCCOL nCol : rDoc.GetColumnsRange(nScTab, 0, rDoc.MaxCol()) )
if (GetColFlag(nCol, ExcColRowFlags::Hidden))
rDoc.ShowCol( nCol, nScTab, false );
@@ -294,7 +295,7 @@ void XclImpColRowSettings::ConvertHiddenFlags( SCTAB nScTab )
// In case the excel row limit is lower than calc's, use the visibility of
// the last row and extend it to calc's last row.
SCROW nLastXLRow = GetRoot().GetXclMaxPos().Row();
if (nLastXLRow < MAXROW)
if (nLastXLRow < rDoc.MaxRow())
{
bool bHidden = false;
if (!maHiddenRows.search(nLastXLRow, bHidden).second)
@@ -326,8 +327,8 @@ void XclImpColRowSettings::ConvertHiddenFlags( SCTAB nScTab )
}
// #i47438# if default row format is hidden, hide remaining rows
if( ::get_flag( mnDefRowFlags, EXC_DEFROW_HIDDEN ) && (mnLastScRow < MAXROW) )
rDoc.ShowRows( mnLastScRow + 1, MAXROW, nScTab, false );
if( ::get_flag( mnDefRowFlags, EXC_DEFROW_HIDDEN ) && (mnLastScRow < rDoc.MaxRow()) )
rDoc.ShowRows( mnLastScRow + 1, rDoc.MaxRow(), nScTab, false );
}
void XclImpColRowSettings::ApplyColFlag(SCCOL nCol, ExcColRowFlags nNewVal)
+6 -4
View File
@@ -1745,19 +1745,21 @@ void ExcelToSc::SetError( ScFormulaCell &rCell, const ConvErr eErr )
void ExcelToSc::SetComplCol( ScComplexRefData &rCRD )
{
ScSingleRefData &rSRD = rCRD.Ref2;
ScDocument& rDoc = GetDocImport().getDoc();
if( rSRD.IsColRel() )
rSRD.SetRelCol(MAXCOL - aEingPos.Col());
rSRD.SetRelCol(rDoc.MaxCol() - aEingPos.Col());
else
rSRD.SetAbsCol(MAXCOL);
rSRD.SetAbsCol(rDoc.MaxCol());
}
void ExcelToSc::SetComplRow( ScComplexRefData &rCRD )
{
ScSingleRefData &rSRD = rCRD.Ref2;
ScDocument& rDoc = GetDocImport().getDoc();
if( rSRD.IsRowRel() )
rSRD.SetRelRow(MAXROW - aEingPos.Row());
rSRD.SetRelRow(rDoc.MaxRow() - aEingPos.Row());
else
rSRD.SetAbsRow(MAXROW);
rSRD.SetAbsRow(rDoc.MaxRow());
}
void ExcelToSc::ReadExtensionArray( unsigned int n, XclImpStream& aIn )
+1 -1
View File
@@ -1466,7 +1466,7 @@ void ExcelToSc8::ExcRelToScRel8( sal_uInt16 nRow, sal_uInt16 nC, ScSingleRefData
rSRD.SetRelRow(nRelRow);
}
else
rSRD.SetAbsRow(std::min( static_cast<SCROW>(nRow), MAXROW));
rSRD.SetAbsRow(std::min( static_cast<SCROW>(nRow), GetDoc().MaxRow()));
}
else
{
+10 -10
View File
@@ -481,8 +481,8 @@ void ImportExcel::Columndefault()
nColMac--;
if( nColMac > MAXCOL )
nColMac = static_cast<sal_uInt16>(MAXCOL);
if( nColMac > pD->MaxCol() )
nColMac = static_cast<sal_uInt16>(pD->MaxCol());
for( sal_uInt16 nCol = nColMic ; nCol <= nColMac ; nCol++ )
{
@@ -583,8 +583,8 @@ void ImportExcel::Colwidth()
nColWidth = aIn.ReaduInt16();
//TODO: add a check for the unlikely case of changed MAXCOL (-> XclImpAddressConverter)
// if( nColLast > MAXCOL )
// nColLast = static_cast<sal_uInt16>(MAXCOL);
// if( nColLast > pD->MaxCol() )
// nColLast = static_cast<sal_uInt16>(pD->MaxCol());
sal_uInt16 nScWidth = XclTools::GetScColumnWidth( nColWidth, GetCharWidth() );
pColRowBuff->SetWidthRange( nColFirst, nColLast, nScWidth );
@@ -662,11 +662,11 @@ void ImportExcel::Colinfo()
nXF = aIn.ReaduInt16();
nOpt = aIn.ReaduInt16();
if( nColFirst > MAXCOL )
if( nColFirst > pD->MaxCol() )
return;
if( nColLast > MAXCOL )
nColLast = static_cast<sal_uInt16>(MAXCOL);
if( nColLast > pD->MaxCol() )
nColLast = static_cast<sal_uInt16>(pD->MaxCol());
bool bHidden = ::get_flag( nOpt, EXC_COLINFO_HIDDEN );
bool bCollapsed = ::get_flag( nOpt, EXC_COLINFO_COLLAPSED );
@@ -1131,7 +1131,7 @@ void ImportExcel::TableOp()
else
{
bTabTruncated = true;
GetTracer().TraceInvalidRow(nLastRow, MAXROW);
GetTracer().TraceInvalidRow(nLastRow, pD->MaxRow());
}
}
@@ -1332,13 +1332,13 @@ void ImportExcel::PostDocLoad()
while( p )
{
if( p->aStart.Col() == 0 && p->aEnd.Col() == MAXCOL && bRowVirgin )
if( p->aStart.Col() == 0 && p->aEnd.Col() == pD->MaxCol() && bRowVirgin )
{
pD->SetRepeatRowRange( n, std::unique_ptr<ScRange>(new ScRange(*p)) );
bRowVirgin = false;
}
if( p->aStart.Row() == 0 && p->aEnd.Row() == MAXROW && bColVirgin )
if( p->aStart.Row() == 0 && p->aEnd.Row() == pD->MaxRow() && bColVirgin )
{
pD->SetRepeatColRange( n, std::unique_ptr<ScRange>(new ScRange(*p)) );
bColVirgin = false;
+1 -1
View File
@@ -596,7 +596,7 @@ void XclExpFmlaCompImpl::Init( XclFormulaType eType, const ScTokenArray& rScTokA
{
// clone the passed token array, convert references relative to current cell position
mxData->mxOwnScTokArr = rScTokArr.Clone();
ScCompiler::MoveRelWrap( *mxData->mxOwnScTokArr, &GetDocRef(), *pScBasePos, MAXCOL, MAXROW );
ScCompiler::MoveRelWrap( *mxData->mxOwnScTokArr, &GetDocRef(), *pScBasePos, GetDocRef().MaxCol(), GetDocRef().MaxRow() );
// don't remember pScBasePos in mxData->mpScBasePos, shared formulas use real relative refs
}
break;
+4 -4
View File
@@ -448,10 +448,10 @@ void XclImpLabelranges::ReadLabelranges( XclImpStream& rStrm )
{
const ScRange & rScRange = aRowScRanges[ i ];
ScRange aDataRange( rScRange );
if( aDataRange.aEnd.Col() < MAXCOL )
if( aDataRange.aEnd.Col() < rDoc.MaxCol() )
{
aDataRange.aStart.SetCol( aDataRange.aEnd.Col() + 1 );
aDataRange.aEnd.SetCol( MAXCOL );
aDataRange.aEnd.SetCol( rDoc.MaxCol() );
}
else if( aDataRange.aStart.Col() > 0 )
{
@@ -470,10 +470,10 @@ void XclImpLabelranges::ReadLabelranges( XclImpStream& rStrm )
{
const ScRange & rScRange = aColScRanges[ i ];
ScRange aDataRange( rScRange );
if( aDataRange.aEnd.Row() < MAXROW )
if( aDataRange.aEnd.Row() < rDoc.MaxRow() )
{
aDataRange.aStart.SetRow( aDataRange.aEnd.Row() + 1 );
aDataRange.aEnd.SetRow( MAXROW );
aDataRange.aEnd.SetRow( rDoc.MaxRow() );
}
else if( aDataRange.aStart.Row() > 0 )
{
+2 -2
View File
@@ -375,14 +375,14 @@ void XclImpPageSettings::Finalize()
for( const auto& rHorPageBreak : maData.maHorPageBreaks )
{
SCROW nScRow = static_cast< SCROW >( rHorPageBreak );
if( nScRow <= MAXROW )
if( nScRow <= rDoc.MaxRow() )
rDoc.SetRowBreak(nScRow, nScTab, false, true);
}
for( const auto& rVerPageBreak : maData.maVerPageBreaks )
{
SCCOL nScCol = static_cast< SCCOL >( rVerPageBreak );
if( nScCol <= MAXCOL )
if( nScCol <= rDoc.MaxCol() )
rDoc.SetColBreak(nScCol, nScTab, false, true);
}
}
+4 -4
View File
@@ -755,7 +755,7 @@ void XclImpPivotCache::ReadPivotCacheStream( const XclImpStream& rStrm )
else
aOrigFields.push_back( xCurrField );
// insert field name into generated source data, field remembers its column index
if( bGenerateSource && (nFieldScCol <= MAXCOL) )
if( bGenerateSource && (nFieldScCol <= rDoc.MaxCol()) )
xCurrField->WriteFieldNameToSource( nFieldScCol++, nScTab );
}
// do not read items into invalid/postponed fields
@@ -767,7 +767,7 @@ void XclImpPivotCache::ReadPivotCacheStream( const XclImpStream& rStrm )
case EXC_ID_SXINDEXLIST:
// read index list and insert all items into generated source data
if( bGenerateSource && (nItemScRow <= MAXROW) && (++nItemScRow <= MAXROW) )
if( bGenerateSource && (nItemScRow <= rDoc.MaxRow()) && (++nItemScRow <= rDoc.MaxRow()) )
{
for( const auto& rxOrigField : aOrigFields )
{
@@ -794,12 +794,12 @@ void XclImpPivotCache::ReadPivotCacheStream( const XclImpStream& rStrm )
// read postponed item
aPostpFields[ nPostpIdx ]->ReadItem( aPCStrm );
// write item to source
if( bGenerateSource && (nItemScRow <= MAXROW) )
if( bGenerateSource && (nItemScRow <= rDoc.MaxRow()) )
{
// start new row, if there are only postponed fields
if( aOrigFields.empty() && (nPostpIdx == 0) )
++nItemScRow;
if( nItemScRow <= MAXROW )
if( nItemScRow <= rDoc.MaxRow() )
aPostpFields[ nPostpIdx ]->WriteLastOrigItemToSource( nItemScRow, nScTab );
}
// get index of next postponed field
+10 -9
View File
@@ -1976,7 +1976,8 @@ void XclImpXFRangeBuffer::SetMerge( SCCOL nScCol1, SCROW nScRow1, SCCOL nScCol2,
void XclImpXFRangeBuffer::Finalize()
{
ScDocumentImport& rDoc = GetDocImport();
ScDocumentImport& rDocImport = GetDocImport();
ScDocument& rDoc = rDocImport.getDoc();
SCTAB nScTab = GetCurrScTab();
// apply patterns
@@ -2005,11 +2006,11 @@ void XclImpXFRangeBuffer::Finalize()
pXF->ApplyPatternToAttrVector(aAttrs, rStyle.mnScRow1, rStyle.mnScRow2, nForceScNumFmt);
}
if (aAttrs.empty() || aAttrs.back().nEndRow != MAXROW)
if (aAttrs.empty() || aAttrs.back().nEndRow != rDoc.MaxRow())
{
ScAttrEntry aEntry;
aEntry.nEndRow = MAXROW;
aEntry.pPattern = rDoc.getDoc().GetDefPattern();
aEntry.nEndRow = rDoc.MaxRow();
aEntry.pPattern = rDoc.GetDefPattern();
aAttrs.push_back(aEntry);
}
@@ -2018,7 +2019,7 @@ void XclImpXFRangeBuffer::Finalize()
ScDocumentImport::Attrs aAttrParam;
aAttrParam.mvData.swap(aAttrs);
aAttrParam.mbLatinNumFmtOnly = false; // when unsure, set it to false.
rDoc.setAttrEntries(nScTab, nScCol, std::move(aAttrParam));
rDocImport.setAttrEntries(nScTab, nScCol, std::move(aAttrParam));
}
++nScCol;
}
@@ -2043,13 +2044,13 @@ void XclImpXFRangeBuffer::Finalize()
SetBorderLine( rRange, nScTab, SvxBoxItemLine::BOTTOM );
// do merge
if( bMultiCol || bMultiRow )
rDoc.getDoc().DoMerge( nScTab, rStart.Col(), rStart.Row(), rEnd.Col(), rEnd.Row() );
rDoc.DoMerge( nScTab, rStart.Col(), rStart.Row(), rEnd.Col(), rEnd.Row() );
// #i93609# merged range in a single row: test if manual row height is needed
if( !bMultiRow )
{
bool bTextWrap = rDoc.getDoc().GetAttr( rStart, ATTR_LINEBREAK )->GetValue();
if( !bTextWrap && (rDoc.getDoc().GetCellType( rStart ) == CELLTYPE_EDIT) )
if (const EditTextObject* pEditObj = rDoc.getDoc().GetEditText(rStart))
bool bTextWrap = rDoc.GetAttr( rStart, ATTR_LINEBREAK )->GetValue();
if( !bTextWrap && (rDoc.GetCellType( rStart ) == CELLTYPE_EDIT) )
if (const EditTextObject* pEditObj = rDoc.GetEditText(rStart))
bTextWrap = pEditObj->GetParagraphCount() > 1;
if( bTextWrap )
GetOldRoot().pColRowBuff->SetManualRowHeight( rStart.Row() );
+4 -4
View File
@@ -144,10 +144,10 @@ tools::Rectangle XclObjAnchor::GetRect( const XclRoot& rRoot, SCTAB nScTab, MapU
ScDocument& rDoc = rRoot.GetDoc();
double fScale = lclGetTwipsScale( eMapUnit );
tools::Rectangle aRect(
lclGetXFromCol(rDoc, nScTab, std::min<SCCOL>(maFirst.mnCol, MAXCOL), mnLX, fScale),
lclGetYFromRow(rDoc, nScTab, std::min<SCROW>(maFirst.mnRow, MAXROW), mnTY, fScale),
lclGetXFromCol(rDoc, nScTab, std::min<SCCOL>(maLast.mnCol, MAXCOL), mnRX + 1, fScale),
lclGetYFromRow(rDoc, nScTab, std::min<SCROW>(maLast.mnRow, MAXROW), mnBY, fScale));
lclGetXFromCol(rDoc, nScTab, std::min<SCCOL>(maFirst.mnCol, rDoc.MaxCol()), mnLX, fScale),
lclGetYFromRow(rDoc, nScTab, std::min<SCROW>(maFirst.mnRow, rDoc.MaxRow()), mnTY, fScale),
lclGetXFromCol(rDoc, nScTab, std::min<SCCOL>(maLast.mnCol, rDoc.MaxCol()), mnRX + 1, fScale),
lclGetYFromRow(rDoc, nScTab, std::min<SCROW>(maLast.mnRow, rDoc.MaxRow()), mnBY, fScale));
// adjust coordinates in mirrored sheets
if( rDoc.IsLayoutRTL( nScTab ) )
+1 -1
View File
@@ -92,7 +92,7 @@ XclRootData::XclRootData( XclBiff eBiff, SfxMedium& rMedium,
meDocLang( Application::GetSettings().GetLanguageTag().getLanguageType() ),
meUILang( Application::GetSettings().GetUILanguageTag().getLanguageType() ),
mnDefApiScript( ApiScriptType::LATIN ),
maScMaxPos( MAXCOL, MAXROW, MAXTAB ),
maScMaxPos( mrDoc.MaxCol(), mrDoc.MaxRow(), MAXTAB ),
maXclMaxPos( EXC_MAXCOL2, EXC_MAXROW2, EXC_MAXTAB2 ),
maMaxPos( EXC_MAXCOL2, EXC_MAXROW2, EXC_MAXTAB2 ),
mxFontPropSetHlp( new XclFontPropSetHelper ),