Kaydet (Commit) 529e9b61 authored tarafından Katarina Behrens's avatar Katarina Behrens

tdf#89597: Resize formula buffers after adding a dummy sheet

for pivot table cache records.

Regression from commit d17a83fa. On loading pivot table
cache records, a dummy sheet is created to store them. Formula buffers
are now vectors, not maps and need to be resized in such case.

Change-Id: Ib6abeac1b139ffb74579712017eed2194cff592b
üst abae860f
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <oox/helper/refmap.hxx> #include <oox/helper/refmap.hxx>
#include <oox/helper/refvector.hxx> #include <oox/helper/refvector.hxx>
#include "workbookhelper.hxx" #include "workbookhelper.hxx"
#include "documentimport.hxx"
namespace com { namespace sun { namespace star { namespace com { namespace sun { namespace star {
namespace i18n { class XCharacterClassification; } namespace i18n { class XCharacterClassification; }
...@@ -65,6 +66,8 @@ public: ...@@ -65,6 +66,8 @@ public:
/** Returns the number of original sheets contained in the workbook. */ /** Returns the number of original sheets contained in the workbook. */
sal_Int32 getWorksheetCount() const; sal_Int32 getWorksheetCount() const;
/** Returns the number of all sheets, workbook + dummy ones (pivot table cache records ) */
sal_Int32 getAllSheetCount() const;
/** Returns the OOXML relation identifier of the specified worksheet. */ /** Returns the OOXML relation identifier of the specified worksheet. */
OUString getWorksheetRelId( sal_Int32 nWorksheet ) const; OUString getWorksheetRelId( sal_Int32 nWorksheet ) const;
......
...@@ -23,7 +23,9 @@ ...@@ -23,7 +23,9 @@
#include <oox/helper/attributelist.hxx> #include <oox/helper/attributelist.hxx>
#include "addressconverter.hxx" #include "addressconverter.hxx"
#include "biffinputstream.hxx" #include "biffinputstream.hxx"
#include "formulabuffer.hxx"
#include "pivotcachebuffer.hxx" #include "pivotcachebuffer.hxx"
#include "worksheetbuffer.hxx"
namespace oox { namespace oox {
namespace xls { namespace xls {
...@@ -210,8 +212,12 @@ PivotCacheRecordsFragment::PivotCacheRecordsFragment( const WorksheetHelper& rHe ...@@ -210,8 +212,12 @@ PivotCacheRecordsFragment::PivotCacheRecordsFragment( const WorksheetHelper& rHe
mnRowIdx( 0 ), mnRowIdx( 0 ),
mbInRecord( false ) mbInRecord( false )
{ {
sal_Int32 nSheetCount = rPivotCache.getWorksheets().getAllSheetCount();
// prepare sheet: insert column header names into top row // prepare sheet: insert column header names into top row
rPivotCache.writeSourceHeaderCells( *this ); rPivotCache.writeSourceHeaderCells( *this );
// resize formula buffers since we've added a new dummy sheet
rHelper.getFormulaBuffer().SetSheetCount( nSheetCount );
} }
ContextHandlerRef PivotCacheRecordsFragment::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) ContextHandlerRef PivotCacheRecordsFragment::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
......
...@@ -86,6 +86,12 @@ sal_Int32 WorksheetBuffer::getWorksheetCount() const ...@@ -86,6 +86,12 @@ sal_Int32 WorksheetBuffer::getWorksheetCount() const
return static_cast< sal_Int32 >( maSheetInfos.size() ); return static_cast< sal_Int32 >( maSheetInfos.size() );
} }
sal_Int32 WorksheetBuffer::getAllSheetCount() const
{
const ScDocumentImport& rDoc = getDocImport();
return rDoc.getSheetCount();
}
OUString WorksheetBuffer::getWorksheetRelId( sal_Int32 nWorksheet ) const OUString WorksheetBuffer::getWorksheetRelId( sal_Int32 nWorksheet ) const
{ {
const SheetInfo* pSheetInfo = maSheetInfos.get( nWorksheet ).get(); const SheetInfo* pSheetInfo = maSheetInfos.get( nWorksheet ).get();
...@@ -166,6 +172,7 @@ WorksheetBuffer::SheetInfo::SheetInfo( const SheetInfoModel& rModel, sal_Int16 n ...@@ -166,6 +172,7 @@ WorksheetBuffer::SheetInfo::SheetInfo( const SheetInfoModel& rModel, sal_Int16 n
WorksheetBuffer::IndexNamePair WorksheetBuffer::createSheet( const OUString& rPreferredName, sal_Int32 nSheetPos, bool bVisible ) WorksheetBuffer::IndexNamePair WorksheetBuffer::createSheet( const OUString& rPreferredName, sal_Int32 nSheetPos, bool bVisible )
{ {
//FIXME: Rewrite this block using ScDocument[Import] instead of UNO
try try
{ {
Reference< XSpreadsheets > xSheets( getDocument()->getSheets(), UNO_QUERY_THROW ); Reference< XSpreadsheets > xSheets( getDocument()->getSheets(), UNO_QUERY_THROW );
......
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