Line
Link Here
|
0 |
-- a/main/oox/inc/oox/xls/pivotcachebuffer.hxx |
0 |
++ b/main/oox/inc/oox/xls/pivotcachebuffer.hxx |
Lines 466-474
private:
Link Here
|
466 |
PCDefinitionModel maDefModel; /// Global pivot cache settings. |
466 |
PCDefinitionModel maDefModel; /// Global pivot cache settings. |
467 |
PCSourceModel maSourceModel; /// Pivot cache source settings. |
467 |
PCSourceModel maSourceModel; /// Pivot cache source settings. |
468 |
PCWorksheetSourceModel maSheetSrcModel; /// Sheet source data if cache type is sheet. |
468 |
PCWorksheetSourceModel maSheetSrcModel; /// Sheet source data if cache type is sheet. |
469 |
ValueRangeSet maColSpans; /// Column spans used by SheetDataBuffer for optimized cell import. |
|
|
470 |
::rtl::OUString maTargetUrl; /// URL of an external source document. |
469 |
::rtl::OUString maTargetUrl; /// URL of an external source document. |
471 |
mutable sal_Int32 mnCurrRow; /// Current row index in dummy sheet. |
|
|
472 |
bool mbValidSource; /// True = pivot cache is based on supported data source. |
470 |
bool mbValidSource; /// True = pivot cache is based on supported data source. |
473 |
bool mbDummySheet; /// True = pivot cache is based on a dummy sheet. |
471 |
bool mbDummySheet; /// True = pivot cache is based on a dummy sheet. |
474 |
}; |
472 |
}; |
475 |
-- a/main/oox/inc/oox/xls/sheetdatabuffer.hxx |
473 |
++ b/main/oox/inc/oox/xls/sheetdatabuffer.hxx |
Lines 86-180
struct DataTableModel
Link Here
|
86 |
|
86 |
|
87 |
// ============================================================================ |
87 |
// ============================================================================ |
88 |
|
88 |
|
89 |
/** Stores position and contents of a range of cells for optimized import. */ |
|
|
90 |
class CellBlock : public WorksheetHelper |
91 |
{ |
92 |
public: |
93 |
explicit CellBlock( const WorksheetHelper& rHelper, const ValueRange& rColSpan, sal_Int32 nRow ); |
94 |
|
95 |
/** Returns true, if the end index of the passed colspan is greater than |
96 |
the own column end index, or if the passed range has the same end index |
97 |
but the start indexes do not match. */ |
98 |
bool isBefore( const ValueRange& rColSpan ) const; |
99 |
/** Returns true, if the cell block can be expanded with the passed colspan. */ |
100 |
bool isExpandable( const ValueRange& rColSpan ) const; |
101 |
/** Returns true, if the own colspan contains the passed column. */ |
102 |
bool contains( sal_Int32 nCol ) const; |
103 |
|
104 |
/** Returns the specified cell from the last row in the cell buffer array. */ |
105 |
::com::sun::star::uno::Any& getCellAny( sal_Int32 nCol ); |
106 |
/** Inserts a rich-string into the cell block. */ |
107 |
void insertRichString( |
108 |
const ::com::sun::star::table::CellAddress& rAddress, |
109 |
const RichStringRef& rxString, |
110 |
const Font* pFirstPortionFont ); |
111 |
|
112 |
/** Appends a new row to the cell buffer array. */ |
113 |
void startNextRow(); |
114 |
/** Writes all buffered cells into the Calc sheet. */ |
115 |
void finalizeImport(); |
116 |
|
117 |
private: |
118 |
/** Fills unused cells before passed index with empty strings. */ |
119 |
void fillUnusedCells( sal_Int32 nIndex ); |
120 |
|
121 |
private: |
122 |
/** Stores position and string data of a rich-string cell. */ |
123 |
struct RichStringCell |
124 |
{ |
125 |
::com::sun::star::table::CellAddress |
126 |
maCellAddr; /// The address of the rich-string cell. |
127 |
RichStringRef mxString; /// The string with rich formatting. |
128 |
const Font* mpFirstPortionFont; /// Font information from cell for first text portion. |
129 |
|
130 |
explicit RichStringCell( |
131 |
const ::com::sun::star::table::CellAddress& rCellAddr, |
132 |
const RichStringRef& rxString, |
133 |
const Font* pFirstPortionFont ); |
134 |
}; |
135 |
typedef ::std::list< RichStringCell > RichStringCellList; |
136 |
|
137 |
::com::sun::star::table::CellRangeAddress |
138 |
maRange; /// Cell range covered by this cell block. |
139 |
RichStringCellList maRichStrings; /// Cached rich-string cells. |
140 |
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > > |
141 |
maCellArray; /// The array of cells of this cell block. |
142 |
::com::sun::star::uno::Any* |
143 |
mpCurrCellRow; /// Pointer to first cell of current row (last row in maCellArray). |
144 |
const sal_Int32 mnRowLength; /// Number of cells covered by row of this cell block. |
145 |
sal_Int32 mnFirstFreeIndex; /// Relative index of first unused cell in current row. |
146 |
}; |
147 |
|
148 |
// ============================================================================ |
149 |
|
150 |
/** Manages all cell blocks currently in use. */ |
151 |
class CellBlockBuffer : public WorksheetHelper |
152 |
{ |
153 |
public: |
154 |
explicit CellBlockBuffer( const WorksheetHelper& rHelper ); |
155 |
|
156 |
/** Sets column span information for a row. */ |
157 |
void setColSpans( sal_Int32 nRow, const ValueRangeSet& rColSpans ); |
158 |
|
159 |
/** Tries to find a cell block. Recalculates the map of cell blocks, if the |
160 |
passed cell address is located in another row than the last cell. */ |
161 |
CellBlock* getCellBlock( const ::com::sun::star::table::CellAddress& rCellAddr ); |
162 |
|
163 |
/** Inserts all cells of all open cell blocks into the Calc document. */ |
164 |
void finalizeImport(); |
165 |
|
166 |
private: |
167 |
typedef ::std::map< sal_Int32, ValueRangeVector > ColSpanVectorMap; |
168 |
typedef RefMap< sal_Int32, CellBlock > CellBlockMap; |
169 |
|
170 |
ColSpanVectorMap maColSpans; /// Buffereed column spans, mapped by row index. |
171 |
CellBlockMap maCellBlocks; /// All open cell blocks, mapped by last (!) column of the block span. |
172 |
CellBlockMap::iterator maCellBlockIt; /// Pointer to cell block currently in use. |
173 |
sal_Int32 mnCurrRow; /// Current row index used for buffered cell import. |
174 |
}; |
175 |
|
176 |
// ============================================================================ |
177 |
|
178 |
/** Manages the cell contents and cell formatting of a sheet. |
89 |
/** Manages the cell contents and cell formatting of a sheet. |
179 |
*/ |
90 |
*/ |
180 |
class SheetDataBuffer : public WorksheetHelper |
91 |
class SheetDataBuffer : public WorksheetHelper |
Lines 328-334
private:
Link Here
|
328 |
}; |
239 |
}; |
329 |
typedef ::std::list< MergedRange > MergedRangeList; |
240 |
typedef ::std::list< MergedRange > MergedRangeList; |
330 |
|
241 |
|
331 |
CellBlockBuffer maCellBlocks; /// Manages all open cell blocks. |
|
|
332 |
ArrayFormulaList maArrayFormulas; /// All array formulas in the sheet. |
242 |
ArrayFormulaList maArrayFormulas; /// All array formulas in the sheet. |
333 |
TableOperationList maTableOperations; /// All table operations in the sheet. |
243 |
TableOperationList maTableOperations; /// All table operations in the sheet. |
334 |
SharedFormulaMap maSharedFormulas; /// Maps shared formula base address to defined name token index. |
244 |
SharedFormulaMap maSharedFormulas; /// Maps shared formula base address to defined name token index. |
335 |
-- a/main/oox/source/xls/pivotcachebuffer.cxx |
245 |
++ b/main/oox/source/xls/pivotcachebuffer.cxx |
Lines 1042-1048
PCWorksheetSourceModel::PCWorksheetSourceModel()
Link Here
|
1042 |
|
1042 |
|
1043 |
PivotCache::PivotCache( const WorkbookHelper& rHelper ) : |
1043 |
PivotCache::PivotCache( const WorkbookHelper& rHelper ) : |
1044 |
WorkbookHelper( rHelper ), |
1044 |
WorkbookHelper( rHelper ), |
1045 |
mnCurrRow( -1 ), |
|
|
1046 |
mbValidSource( false ), |
1045 |
mbValidSource( false ), |
1047 |
mbDummySheet( false ) |
1046 |
mbDummySheet( false ) |
1048 |
{ |
1047 |
{ |
Lines 1275-1282
void PivotCache::writeSourceHeaderCells( WorksheetHelper& rSheetHelper ) const
Link Here
|
1275 |
sal_Int32 nCol = maSheetSrcModel.maRange.StartColumn; |
1274 |
sal_Int32 nCol = maSheetSrcModel.maRange.StartColumn; |
1276 |
sal_Int32 nMaxCol = getAddressConverter().getMaxApiAddress().Column; |
1275 |
sal_Int32 nMaxCol = getAddressConverter().getMaxApiAddress().Column; |
1277 |
sal_Int32 nRow = maSheetSrcModel.maRange.StartRow; |
1276 |
sal_Int32 nRow = maSheetSrcModel.maRange.StartRow; |
1278 |
mnCurrRow = -1; |
|
|
1279 |
updateSourceDataRow( rSheetHelper, nRow ); |
1280 |
for( PivotCacheFieldVector::const_iterator aIt = maDatabaseFields.begin(), aEnd = maDatabaseFields.end(); (aIt != aEnd) && (nCol <= nMaxCol); ++aIt, ++nCol ) |
1277 |
for( PivotCacheFieldVector::const_iterator aIt = maDatabaseFields.begin(), aEnd = maDatabaseFields.end(); (aIt != aEnd) && (nCol <= nMaxCol); ++aIt, ++nCol ) |
1281 |
(*aIt)->writeSourceHeaderCell( rSheetHelper, nCol, nRow ); |
1278 |
(*aIt)->writeSourceHeaderCell( rSheetHelper, nCol, nRow ); |
1282 |
} |
1279 |
} |
Lines 1287-1293
void PivotCache::writeSourceDataCell( WorksheetHelper& rSheetHelper, sal_Int32 n
Link Here
|
1287 |
OSL_ENSURE( (maSheetSrcModel.maRange.StartColumn <= nCol) && (nCol <= maSheetSrcModel.maRange.EndColumn), "PivotCache::writeSourceDataCell - invalid column index" ); |
1284 |
OSL_ENSURE( (maSheetSrcModel.maRange.StartColumn <= nCol) && (nCol <= maSheetSrcModel.maRange.EndColumn), "PivotCache::writeSourceDataCell - invalid column index" ); |
1288 |
sal_Int32 nRow = maSheetSrcModel.maRange.StartRow + nRowIdx; |
1285 |
sal_Int32 nRow = maSheetSrcModel.maRange.StartRow + nRowIdx; |
1289 |
OSL_ENSURE( (maSheetSrcModel.maRange.StartRow < nRow) && (nRow <= maSheetSrcModel.maRange.EndRow), "PivotCache::writeSourceDataCell - invalid row index" ); |
1286 |
OSL_ENSURE( (maSheetSrcModel.maRange.StartRow < nRow) && (nRow <= maSheetSrcModel.maRange.EndRow), "PivotCache::writeSourceDataCell - invalid row index" ); |
1290 |
updateSourceDataRow( rSheetHelper, nRow ); |
|
|
1291 |
if( const PivotCacheField* pCacheField = maDatabaseFields.get( nColIdx ).get() ) |
1287 |
if( const PivotCacheField* pCacheField = maDatabaseFields.get( nColIdx ).get() ) |
1292 |
pCacheField->writeSourceDataCell( rSheetHelper, nCol, nRow, rItem ); |
1288 |
pCacheField->writeSourceDataCell( rSheetHelper, nCol, nRow, rItem ); |
1293 |
} |
1289 |
} |
Lines 1430-1451
void PivotCache::prepareSourceDataSheet()
Link Here
|
1430 |
// check range location, do not allow ranges that overflow the sheet partly |
1426 |
// check range location, do not allow ranges that overflow the sheet partly |
1431 |
if( getAddressConverter().checkCellRange( rRange, false, true ) ) |
1427 |
if( getAddressConverter().checkCellRange( rRange, false, true ) ) |
1432 |
{ |
1428 |
{ |
1433 |
maColSpans.insert( ValueRange( rRange.StartColumn, rRange.EndColumn ) ); |
|
|
1434 |
OUString aSheetName = CREATE_OUSTRING( "DPCache_" ) + maSheetSrcModel.maSheet; |
1429 |
OUString aSheetName = CREATE_OUSTRING( "DPCache_" ) + maSheetSrcModel.maSheet; |
1435 |
rRange.Sheet = getWorksheets().insertEmptySheet( aSheetName, false ); |
1430 |
rRange.Sheet = getWorksheets().insertEmptySheet( aSheetName, false ); |
1436 |
mbValidSource = mbDummySheet = rRange.Sheet >= 0; |
1431 |
mbValidSource = mbDummySheet = rRange.Sheet >= 0; |
1437 |
} |
1432 |
} |
1438 |
} |
1433 |
} |
1439 |
|
1434 |
|
1440 |
void PivotCache::updateSourceDataRow( WorksheetHelper& rSheetHelper, sal_Int32 nRow ) const |
|
|
1441 |
{ |
1442 |
if( mnCurrRow != nRow ) |
1443 |
{ |
1444 |
rSheetHelper.getSheetData().setColSpans( nRow, maColSpans ); |
1445 |
mnCurrRow = nRow; |
1446 |
} |
1447 |
} |
1448 |
|
1449 |
// ============================================================================ |
1435 |
// ============================================================================ |
1450 |
|
1436 |
|
1451 |
PivotCacheBuffer::PivotCacheBuffer( const WorkbookHelper& rHelper ) : |
1437 |
PivotCacheBuffer::PivotCacheBuffer( const WorkbookHelper& rHelper ) : |
1452 |
-- a/main/oox/source/xls/sheetdatabuffer.cxx |
1438 |
++ b/main/oox/source/xls/sheetdatabuffer.cxx |
Lines 107-329
DataTableModel::DataTableModel() :
Link Here
|
107 |
|
107 |
|
108 |
// ============================================================================ |
108 |
// ============================================================================ |
109 |
|
109 |
|
110 |
namespace { |
|
|
111 |
|
112 |
const sal_Int32 CELLBLOCK_MAXROWS = 16; /// Number of rows in a cell block. |
113 |
|
114 |
} // namespace |
115 |
|
116 |
CellBlock::CellBlock( const WorksheetHelper& rHelper, const ValueRange& rColSpan, sal_Int32 nRow ) : |
117 |
WorksheetHelper( rHelper ), |
118 |
maRange( rHelper.getSheetIndex(), rColSpan.mnFirst, nRow, rColSpan.mnLast, nRow ), |
119 |
mnRowLength( rColSpan.mnLast - rColSpan.mnFirst + 1 ), |
120 |
mnFirstFreeIndex( 0 ) |
121 |
{ |
122 |
maCellArray.realloc( 1 ); |
123 |
maCellArray[ 0 ].realloc( mnRowLength ); |
124 |
mpCurrCellRow = maCellArray[ 0 ].getArray(); |
125 |
} |
126 |
|
127 |
bool CellBlock::isExpandable( const ValueRange& rColSpan ) const |
128 |
{ |
129 |
return (maRange.StartColumn == rColSpan.mnFirst) && (maRange.EndColumn == rColSpan.mnLast); |
130 |
} |
131 |
|
132 |
bool CellBlock::isBefore( const ValueRange& rColSpan ) const |
133 |
{ |
134 |
return (maRange.EndColumn < rColSpan.mnLast) || |
135 |
((maRange.EndColumn == rColSpan.mnLast) && (maRange.StartColumn != rColSpan.mnFirst)); |
136 |
} |
137 |
|
138 |
bool CellBlock::contains( sal_Int32 nCol ) const |
139 |
{ |
140 |
return (maRange.StartColumn <= nCol) && (nCol <= maRange.EndColumn); |
141 |
} |
142 |
|
143 |
void CellBlock::insertRichString( const CellAddress& rAddress, const RichStringRef& rxString, const Font* pFirstPortionFont ) |
144 |
{ |
145 |
maRichStrings.push_back( RichStringCell( rAddress, rxString, pFirstPortionFont ) ); |
146 |
} |
147 |
|
148 |
void CellBlock::startNextRow() |
149 |
{ |
150 |
// fill last cells in current row with empty strings (placeholder for empty cells) |
151 |
fillUnusedCells( mnRowLength ); |
152 |
// flush if the cell block reaches maximum size |
153 |
if( maCellArray.getLength() == CELLBLOCK_MAXROWS ) |
154 |
{ |
155 |
finalizeImport(); |
156 |
maRange.StartRow = ++maRange.EndRow; |
157 |
maCellArray.realloc( 1 ); |
158 |
mpCurrCellRow = maCellArray[ 0 ].getArray(); |
159 |
} |
160 |
else |
161 |
{ |
162 |
// prepare next row |
163 |
++maRange.EndRow; |
164 |
sal_Int32 nRowCount = maCellArray.getLength(); |
165 |
maCellArray.realloc( nRowCount + 1 ); |
166 |
maCellArray[ nRowCount ].realloc( mnRowLength ); |
167 |
mpCurrCellRow = maCellArray[ nRowCount ].getArray(); |
168 |
} |
169 |
mnFirstFreeIndex = 0; |
170 |
} |
171 |
|
172 |
Any& CellBlock::getCellAny( sal_Int32 nCol ) |
173 |
{ |
174 |
OSL_ENSURE( contains( nCol ), "CellBlock::getCellAny - invalid column" ); |
175 |
// fill cells before passed column with empty strings (the placeholder for empty cells) |
176 |
sal_Int32 nIndex = nCol - maRange.StartColumn; |
177 |
fillUnusedCells( nIndex ); |
178 |
mnFirstFreeIndex = nIndex + 1; |
179 |
return mpCurrCellRow[ nIndex ]; |
180 |
} |
181 |
|
182 |
void CellBlock::finalizeImport() |
183 |
{ |
184 |
// fill last cells in last row with empty strings (placeholder for empty cells) |
185 |
fillUnusedCells( mnRowLength ); |
186 |
// insert all buffered cells into the Calc sheet |
187 |
try |
188 |
{ |
189 |
Reference< XCellRangeData > xRangeData( getCellRange( maRange ), UNO_QUERY_THROW ); |
190 |
xRangeData->setDataArray( maCellArray ); |
191 |
} |
192 |
catch( Exception& ) |
193 |
{ |
194 |
} |
195 |
// insert uncacheable cells separately |
196 |
for( RichStringCellList::const_iterator aIt = maRichStrings.begin(), aEnd = maRichStrings.end(); aIt != aEnd; ++aIt ) |
197 |
putRichString( aIt->maCellAddr, *aIt->mxString, aIt->mpFirstPortionFont ); |
198 |
} |
199 |
|
200 |
// private -------------------------------------------------------------------- |
201 |
|
202 |
CellBlock::RichStringCell::RichStringCell( const CellAddress& rCellAddr, const RichStringRef& rxString, const Font* pFirstPortionFont ) : |
203 |
maCellAddr( rCellAddr ), |
204 |
mxString( rxString ), |
205 |
mpFirstPortionFont( pFirstPortionFont ) |
206 |
{ |
207 |
} |
208 |
|
209 |
void CellBlock::fillUnusedCells( sal_Int32 nIndex ) |
210 |
{ |
211 |
if( mnFirstFreeIndex < nIndex ) |
212 |
{ |
213 |
Any* pCellEnd = mpCurrCellRow + nIndex; |
214 |
for( Any* pCell = mpCurrCellRow + mnFirstFreeIndex; pCell < pCellEnd; ++pCell ) |
215 |
*pCell <<= OUString(); |
216 |
} |
217 |
} |
218 |
|
219 |
// ============================================================================ |
220 |
|
221 |
CellBlockBuffer::CellBlockBuffer( const WorksheetHelper& rHelper ) : |
222 |
WorksheetHelper( rHelper ), |
223 |
mnCurrRow( -1 ) |
224 |
{ |
225 |
maCellBlockIt = maCellBlocks.end(); |
226 |
} |
227 |
|
228 |
void CellBlockBuffer::setColSpans( sal_Int32 nRow, const ValueRangeSet& rColSpans ) |
229 |
{ |
230 |
OSL_ENSURE( maColSpans.count( nRow ) == 0, "CellBlockBuffer::setColSpans - multiple column spans for the same row" ); |
231 |
OSL_ENSURE( (mnCurrRow < nRow) && (maColSpans.empty() || (maColSpans.rbegin()->first < nRow)), "CellBlockBuffer::setColSpans - rows are unsorted" ); |
232 |
if( (mnCurrRow < nRow) && (maColSpans.count( nRow ) == 0) ) |
233 |
maColSpans[ nRow ] = rColSpans.getRanges(); |
234 |
} |
235 |
|
236 |
CellBlock* CellBlockBuffer::getCellBlock( const CellAddress& rCellAddr ) |
237 |
{ |
238 |
OSL_ENSURE( rCellAddr.Row >= mnCurrRow, "CellBlockBuffer::getCellBlock - passed row out of order" ); |
239 |
// prepare cell blocks, if row changes |
240 |
if( rCellAddr.Row != mnCurrRow ) |
241 |
{ |
242 |
// find colspans for the new row |
243 |
ColSpanVectorMap::iterator aIt = maColSpans.find( rCellAddr.Row ); |
244 |
|
245 |
/* Gap between rows, or rows out of order, or no colspan |
246 |
information for the new row found: flush all open cell blocks. */ |
247 |
if( (aIt == maColSpans.end()) || (rCellAddr.Row != mnCurrRow + 1) ) |
248 |
{ |
249 |
finalizeImport(); |
250 |
maCellBlocks.clear(); |
251 |
maCellBlockIt = maCellBlocks.end(); |
252 |
} |
253 |
|
254 |
/* Prepare matching cell blocks, create new cell blocks, finalize |
255 |
unmatching cell blocks, if colspan information is available. */ |
256 |
if( aIt != maColSpans.end() ) |
257 |
{ |
258 |
/* The colspan vector aIt points to is sorted by columns, as well |
259 |
as the cell block map. In the folloing, this vector and the |
260 |
list of cell blocks can be iterated simultanously. */ |
261 |
CellBlockMap::iterator aMIt = maCellBlocks.begin(); |
262 |
const ValueRangeVector& rColRanges = aIt->second; |
263 |
for( ValueRangeVector::const_iterator aVIt = rColRanges.begin(), aVEnd = rColRanges.end(); aVIt != aVEnd; ++aVIt, ++aMIt ) |
264 |
{ |
265 |
const ValueRange& rColSpan = *aVIt; |
266 |
/* Finalize and remove all cell blocks up to end of the column |
267 |
range (cell blocks are keyed by end column index). |
268 |
CellBlock::isBefore() returns true, if the end index of the |
269 |
passed colspan is greater than the column end index of the |
270 |
cell block, or if the passed range has the same end index |
271 |
but the start indexes do not match. */ |
272 |
while( (aMIt != maCellBlocks.end()) && aMIt->second->isBefore( rColSpan ) ) |
273 |
{ |
274 |
aMIt->second->finalizeImport(); |
275 |
maCellBlocks.erase( aMIt++ ); |
276 |
} |
277 |
/* If the current cell block (aMIt) fits to the colspan, start |
278 |
a new row there, otherwise create and insert a new cell block. */ |
279 |
if( (aMIt != maCellBlocks.end()) && aMIt->second->isExpandable( rColSpan ) ) |
280 |
aMIt->second->startNextRow(); |
281 |
else |
282 |
aMIt = maCellBlocks.insert( aMIt, CellBlockMap::value_type( rColSpan.mnLast, |
283 |
CellBlockMap::mapped_type( new CellBlock( *this, rColSpan, rCellAddr.Row ) ) ) ); |
284 |
} |
285 |
// finalize and remove all remaining cell blocks |
286 |
CellBlockMap::iterator aMEnd = maCellBlocks.end(); |
287 |
for( CellBlockMap::iterator aMIt2 = aMIt; aMIt2 != aMEnd; ++aMIt2 ) |
288 |
aMIt2->second->finalizeImport(); |
289 |
maCellBlocks.erase( aMIt, aMEnd ); |
290 |
|
291 |
// remove cached colspan information (including current one aIt points to) |
292 |
maColSpans.erase( maColSpans.begin(), ++aIt ); |
293 |
} |
294 |
maCellBlockIt = maCellBlocks.begin(); |
295 |
mnCurrRow = rCellAddr.Row; |
296 |
} |
297 |
|
298 |
// try to find a valid cell block (update maCellBlockIt) |
299 |
if( ((maCellBlockIt != maCellBlocks.end()) && maCellBlockIt->second->contains( rCellAddr.Column )) || |
300 |
(((maCellBlockIt = maCellBlocks.lower_bound( rCellAddr.Column )) != maCellBlocks.end()) && maCellBlockIt->second->contains( rCellAddr.Column )) ) |
301 |
{ |
302 |
// maCellBlockIt points to valid cell block |
303 |
return maCellBlockIt->second.get(); |
304 |
} |
305 |
|
306 |
// no valid cell block found |
307 |
return 0; |
308 |
} |
309 |
|
310 |
void CellBlockBuffer::finalizeImport() |
311 |
{ |
312 |
maCellBlocks.forEachMem( &CellBlock::finalizeImport ); |
313 |
} |
314 |
|
315 |
// ============================================================================ |
316 |
|
317 |
SheetDataBuffer::SheetDataBuffer( const WorksheetHelper& rHelper ) : |
110 |
SheetDataBuffer::SheetDataBuffer( const WorksheetHelper& rHelper ) : |
318 |
WorksheetHelper( rHelper ), |
111 |
WorksheetHelper( rHelper ), |
319 |
maCellBlocks( rHelper ), |
|
|
320 |
mbPendingSharedFmla( false ) |
112 |
mbPendingSharedFmla( false ) |
321 |
{ |
113 |
{ |
322 |
} |
114 |
} |
323 |
|
115 |
|
324 |
void SheetDataBuffer::setColSpans( sal_Int32 nRow, const ValueRangeSet& rColSpans ) |
116 |
void SheetDataBuffer::setColSpans( sal_Int32 nRow, const ValueRangeSet& rColSpans ) |
325 |
{ |
117 |
{ |
|
|
118 |
#if 0 // the CellBlock cache is no longer used |
326 |
maCellBlocks.setColSpans( nRow, rColSpans ); |
119 |
maCellBlocks.setColSpans( nRow, rColSpans ); |
|
|
120 |
#else |
121 |
(void)nRow; |
122 |
(void)rColSpans; |
123 |
#endif |
327 |
} |
124 |
} |
328 |
|
125 |
|
329 |
void SheetDataBuffer::setBlankCell( const CellModel& rModel ) |
126 |
void SheetDataBuffer::setBlankCell( const CellModel& rModel ) |
Lines 333-351
void SheetDataBuffer::setBlankCell( const CellModel& rModel )
Link Here
|
333 |
|
130 |
|
334 |
void SheetDataBuffer::setValueCell( const CellModel& rModel, double fValue ) |
131 |
void SheetDataBuffer::setValueCell( const CellModel& rModel, double fValue ) |
335 |
{ |
132 |
{ |
336 |
if( CellBlock* pCellBlock = maCellBlocks.getCellBlock( rModel.maCellAddr ) ) |
133 |
putValue( rModel.maCellAddr, fValue ); |
337 |
pCellBlock->getCellAny( rModel.maCellAddr.Column ) <<= fValue; |
|
|
338 |
else |
339 |
putValue( rModel.maCellAddr, fValue ); |
340 |
setCellFormat( rModel ); |
134 |
setCellFormat( rModel ); |
341 |
} |
135 |
} |
342 |
|
136 |
|
343 |
void SheetDataBuffer::setStringCell( const CellModel& rModel, const OUString& rText ) |
137 |
void SheetDataBuffer::setStringCell( const CellModel& rModel, const OUString& rText ) |
344 |
{ |
138 |
{ |
345 |
if( CellBlock* pCellBlock = maCellBlocks.getCellBlock( rModel.maCellAddr ) ) |
139 |
putString( rModel.maCellAddr, rText ); |
346 |
pCellBlock->getCellAny( rModel.maCellAddr.Column ) <<= rText; |
|
|
347 |
else |
348 |
putString( rModel.maCellAddr, rText ); |
349 |
setCellFormat( rModel ); |
140 |
setCellFormat( rModel ); |
350 |
} |
141 |
} |
351 |
|
142 |
|
Lines 360-369
void SheetDataBuffer::setStringCell( const CellModel& rModel, const RichStringRe
Link Here
|
360 |
} |
151 |
} |
361 |
else |
152 |
else |
362 |
{ |
153 |
{ |
363 |
if( CellBlock* pCellBlock = maCellBlocks.getCellBlock( rModel.maCellAddr ) ) |
154 |
putRichString( rModel.maCellAddr, *rxString, pFirstPortionFont ); |
364 |
pCellBlock->insertRichString( rModel.maCellAddr, rxString, pFirstPortionFont ); |
|
|
365 |
else |
366 |
putRichString( rModel.maCellAddr, *rxString, pFirstPortionFont ); |
367 |
setCellFormat( rModel ); |
155 |
setCellFormat( rModel ); |
368 |
} |
156 |
} |
369 |
} |
157 |
} |
Lines 528-536
void SheetDataBuffer::setStandardNumFmt( const CellAddress& rCellAddr, sal_Int16
Link Here
|
528 |
|
316 |
|
529 |
void SheetDataBuffer::finalizeImport() |
317 |
void SheetDataBuffer::finalizeImport() |
530 |
{ |
318 |
{ |
531 |
// insert all cells of all open cell blocks |
|
|
532 |
maCellBlocks.finalizeImport(); |
533 |
|
534 |
// create all array formulas |
319 |
// create all array formulas |
535 |
for( ArrayFormulaList::iterator aIt = maArrayFormulas.begin(), aEnd = maArrayFormulas.end(); aIt != aEnd; ++aIt ) |
320 |
for( ArrayFormulaList::iterator aIt = maArrayFormulas.begin(), aEnd = maArrayFormulas.end(); aIt != aEnd; ++aIt ) |
536 |
finalizeArrayFormula( aIt->first, aIt->second ); |
321 |
finalizeArrayFormula( aIt->first, aIt->second ); |
Lines 658-667
void SheetDataBuffer::setCellFormula( const CellAddress& rCellAddr, const ApiTok
Link Here
|
658 |
{ |
443 |
{ |
659 |
if( rTokens.hasElements() ) |
444 |
if( rTokens.hasElements() ) |
660 |
{ |
445 |
{ |
661 |
if( CellBlock* pCellBlock = maCellBlocks.getCellBlock( rCellAddr ) ) |
446 |
putFormulaTokens( rCellAddr, rTokens ); |
662 |
pCellBlock->getCellAny( rCellAddr.Column ) <<= rTokens; |
|
|
663 |
else |
664 |
putFormulaTokens( rCellAddr, rTokens ); |
665 |
} |
447 |
} |
666 |
} |
448 |
} |
667 |
|
449 |
|