Kaydet (Commit) eb9bf904 authored tarafından Noel Power's avatar Noel Power

Revert "improve cell style xls[x|m] import performance"

This reverts commit 4190fd92.
üst cd689259
......@@ -35,8 +35,6 @@
#include "stlsheet.hxx"
#include <editeng/svxenum.hxx>
#include <editeng/frmdir.hxx>
#include "attarray.hxx"
#include <list>
class ScMarkData;
namespace com { namespace sun { namespace star {
......@@ -721,8 +719,6 @@ public:
inline const Protection& getProtection() const { return maProtection; }
void writeToMarkData( ::ScMarkData& rMarkData, sal_Int32 nNumFmtId );
void applyPatternToAttrList( ::std::list<ScAttrEntry>& rAttrs, SCROW nRow1, SCROW nRow2,
sal_uInt32 nForceScNumFmt );
/** Writes all formatting attributes to the passed property map. */
void writeToPropertyMap( PropertyMap& rPropMap ) const;
/** Writes all formatting attributes to the passed property set. */
......
......@@ -361,50 +361,6 @@ void SheetDataBuffer::finalizeImport()
// write default formatting of remaining row range
maXfIdRowRangeList[ maXfIdRowRange.mnXfId ].push_back( maXfIdRowRange.maRowRange );
typedef ::std::pair< sal_Int32, sal_Int32 > RowRange;
struct RowRangeStyle
{
sal_Int32 mnStartRow;
sal_Int32 mnEndRow;
XfIdNumFmtKey mnNumFmt;
};
struct StyleRowRangeComp
{
bool operator() (const RowRangeStyle& lhs, const RowRangeStyle& rhs) const
{
return lhs.mnEndRow<rhs.mnStartRow;
}
};
typedef ::std::set< RowRangeStyle, StyleRowRangeComp > RowStyles;
typedef ::std::map< sal_Int32, RowStyles > ColStyles;
ColStyles aStylesPerColumn;
StylesBuffer& rStyles = getStyles();
std::map< std::pair< sal_Int32, sal_Int32 >, ApiCellRangeList > rangeStyleListMap;
for( XfIdRangeListMap::const_iterator aIt = maXfIdRangeLists.begin(), aEnd = maXfIdRangeLists.end(); aIt != aEnd; ++aIt )
addIfNotInMyMap( getStyles(), rangeStyleListMap, aIt->first.first, aIt->first.second, aIt->second );
// gather all ranges that have the same style and apply them in bulk
for ( std::map< std::pair< sal_Int32, sal_Int32 >, ApiCellRangeList >::iterator it = rangeStyleListMap.begin(), it_end = rangeStyleListMap.end(); it != it_end; ++it )
{
const ApiCellRangeList& rRanges( it->second );
for ( ApiCellRangeList::const_iterator it_range = rRanges.begin(), it_rangeend = rRanges.end(); it_range!=it_rangeend; ++it_range )
{
RowRangeStyle aStyleRows;
aStyleRows.mnNumFmt.first = it->first.first;
aStyleRows.mnNumFmt.second = it->first.second;
aStyleRows.mnStartRow = it_range->StartRow;
aStyleRows.mnEndRow = it_range->EndRow;
for ( sal_Int32 nCol = it_range->StartColumn; nCol <= it_range->EndColumn; ++nCol )
aStylesPerColumn[ nCol ].insert( aStyleRows );
}
}
// process row ranges for each column, don't overwrite any existing row entries for a column
for ( std::map< sal_Int32, std::vector< ValueRange > >::iterator it = maXfIdRowRangeList.begin(), it_end = maXfIdRowRangeList.end(); it != it_end; ++it )
{
ApiCellRangeList rangeList;
......@@ -412,91 +368,27 @@ void SheetDataBuffer::finalizeImport()
// get all row ranges for id
for ( std::vector< ValueRange >::iterator rangeIter = it->second.begin(), rangeIter_end = it->second.end(); rangeIter != rangeIter_end; ++rangeIter )
{
RowRangeStyle aStyleRows;
aStyleRows.mnNumFmt.first = it->first;
if ( aStyleRows.mnNumFmt.first == -1 ) // dud
continue;
aStyleRows.mnNumFmt.second = -1;
aStyleRows.mnStartRow = rangeIter->mnFirst;
aStyleRows.mnEndRow = rangeIter->mnLast;
for ( sal_Int32 nCol = 0; nCol <= rAddrConv.getMaxApiAddress().Column; ++nCol )
{
RowStyles& rRowStyles = aStylesPerColumn[ nCol ];
// If the rowrange style includes rows already
// allocated to a style then we need to split
// the range style Rows into sections ( to
// occupy only rows that have no style definition )
// We dont want to set any rowstyle 'rows'
// for rows where there is an existing 'style' )
std::vector< RowRangeStyle > aRangeRowsSplits;
RowStyles::iterator rows_it = rRowStyles.begin();
RowStyles::iterator rows_end = rRowStyles.end();
bool bAddRange = true;
for ( ; rows_it != rows_end; ++rows_it )
{
const RowRangeStyle& r = *rows_it;
// if row is completely within existing style, discard it
if ( aStyleRows.mnStartRow >= r.mnStartRow && aStyleRows.mnEndRow <= r.mnEndRow )
bAddRange = false;
else if ( aStyleRows.mnStartRow <= r.mnStartRow )
{
// not intersecting at all?, if so finish as none left
// to check ( row ranges are in ascending order
if ( aStyleRows.mnEndRow < r.mnStartRow )
break;
else if ( aStyleRows.mnEndRow <= r.mnEndRow )
{
aStyleRows.mnEndRow = r.mnStartRow - 1;
break;
}
if ( aStyleRows.mnStartRow < r.mnStartRow )
{
RowRangeStyle aSplit = aStyleRows;
aSplit.mnEndRow = r.mnStartRow - 1;
aRangeRowsSplits.push_back( aSplit );
}
}
}
std::vector< RowRangeStyle >::iterator splits_it = aRangeRowsSplits.begin();
std::vector< RowRangeStyle >::iterator splits_end = aRangeRowsSplits.end();
for ( ; splits_it != splits_end; ++splits_it )
rRowStyles.insert( *splits_it );
if ( bAddRange )
rRowStyles.insert( aStyleRows );
}
}
}
ScDocument& rDoc = getScDocument();
for ( ColStyles::iterator col = aStylesPerColumn.begin(), col_end = aStylesPerColumn.end(); col != col_end; ++col )
{
RowStyles& rRowStyles = col->second;
std::list<ScAttrEntry> aAttrs;
SCCOL nScCol = static_cast< SCCOL >( col->first );
for ( RowStyles::iterator rRows = rRowStyles.begin(), rRows_end = rRowStyles.end(); rRows != rRows_end; ++rRows )
{
Xf* pXf = rStyles.getCellXf( rRows->mnNumFmt.first ).get();
if ( pXf )
pXf->applyPatternToAttrList( aAttrs, rRows->mnStartRow, rRows->mnEndRow, rRows->mnNumFmt.second );
CellRangeAddress aRange( getSheetIndex(), 0, rangeIter->mnFirst, rAddrConv.getMaxApiAddress().Column, rangeIter->mnLast );
rangeList.push_back( aRange );
}
if (aAttrs.empty() || aAttrs.back().nRow != MAXROW)
ScRangeList aList;
for ( ApiCellRangeList::const_iterator itRange = rangeList.begin(), itRange_end = rangeList.end(); itRange!=itRange_end; ++itRange )
{
ScAttrEntry aEntry;
aEntry.nRow = MAXROW;
aEntry.pPattern = rDoc.GetDefPattern();
aAttrs.push_back(aEntry);
ScRange* pRange = new ScRange();
ScUnoConversion::FillScRange( *pRange, *itRange );
aList.push_back( pRange );
}
ScMarkData aMark;
aMark.MarkFromRangeList( aList, false );
size_t nAttrSize = aAttrs.size();
ScAttrEntry* pData = new ScAttrEntry[nAttrSize];
std::list<ScAttrEntry>::const_iterator itr = aAttrs.begin(), itrEnd = aAttrs.end();
for (size_t i = 0; itr != itrEnd; ++itr, ++i)
pData[i] = *itr;
rDoc.SetAttrEntries(nScCol, getSheetIndex(), pData, static_cast<SCSIZE>(nAttrSize));
getStyles().writeCellXfToMarkData( aMark, it->first, -1 );
}
std::map< std::pair< sal_Int32, sal_Int32 >, ApiCellRangeList > rangeStyleListMap;
// gather all ranges that have the same style and apply them in bulk
for( XfIdRangeListMap::const_iterator aIt = maXfIdRangeLists.begin(), aEnd = maXfIdRangeLists.end(); aIt != aEnd; ++aIt )
addIfNotInMyMap( getStyles(), rangeStyleListMap, aIt->first.first, aIt->first.second, aIt->second );
for ( std::map< std::pair< sal_Int32, sal_Int32 >, ApiCellRangeList >::iterator it = rangeStyleListMap.begin(), it_end = rangeStyleListMap.end(); it != it_end; ++it )
writeXfIdRangeListProperties( it->first.first, it->first.second, it->second );
// merge all cached merged ranges and update right/bottom cell borders
for( MergedRangeList::iterator aIt = maMergedRanges.begin(), aEnd = maMergedRanges.end(); aIt != aEnd; ++aIt )
applyCellMerging( aIt->maRange );
......
......@@ -2281,70 +2281,6 @@ FontRef Xf::getFont() const
return getStyles().getFont( maModel.mnFontId );
}
void Xf::applyPatternToAttrList( ::std::list<ScAttrEntry>& rAttrs, SCROW nRow1, SCROW nRow2,
sal_uInt32 nNumFmtId )
{
createPattern();
ScPatternAttr& rPat = *mpPattern;
ScDocument& rDoc = getScDocument();
if ( isCellXf() )
{
StylesBuffer& rStyles = getStyles();
rStyles.createCellStyle( maModel.mnStyleXfId );
mpStyleSheet = rStyles.getCellStyleSheet( maModel.mnStyleXfId );
if ( mpStyleSheet )
{
//rDoc.ApplySelectionStyle( static_cast<ScStyleSheet&>(*mpStyleSheet), rMarkData );
rPat.SetStyleSheet(mpStyleSheet, false);
}
else
{
ScStyleSheetPool* pStylePool = rDoc.GetStyleSheetPool();
if (pStylePool)
{
ScStyleSheet* pStyleSheet = static_cast<ScStyleSheet*>(
pStylePool->Find(
ScGlobal::GetRscString(STR_STYLENAME_STANDARD), SFX_STYLE_FAMILY_PARA));
if (pStyleSheet)
rPat.SetStyleSheet( pStyleSheet, false );
}
}
}
if ( nNumFmtId >= 0 )
{
ScPatternAttr aNumPat(rDoc.GetPool());
getStyles().writeNumFmtToItemSet( aNumPat.GetItemSet(), nNumFmtId );
rPat.GetItemSet().Put(aNumPat.GetItemSet());
}
if (rPat.GetStyleName())
{
// Check for a gap between the last entry and this one.
bool bHasGap = false;
if (rAttrs.empty() && nRow1 > 0)
// First attribute range doesn't start at row 0.
bHasGap = true;
if (!rAttrs.empty() && rAttrs.back().nRow + 1 < nRow1)
bHasGap = true;
if (bHasGap)
{
// Fill this gap with the default pattern.
ScAttrEntry aEntry;
aEntry.nRow = nRow1 - 1;
aEntry.pPattern = rDoc.GetDefPattern();
rAttrs.push_back(aEntry);
}
ScAttrEntry aEntry;
aEntry.nRow = nRow2;
aEntry.pPattern = static_cast<const ScPatternAttr*>(&rDoc.GetPool()->Put(rPat));
rAttrs.push_back(aEntry);
}
}
void Xf::writeToMarkData( ::ScMarkData& rMarkData, sal_Int32 nNumFmtId )
{
createPattern();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment