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

better default row detection ( associated with fdo#55621 )

previous patch associated with fdo#55621 compared single instances of row
heights to determine the default height, it didn't take into account though
repeated rows. Additionally the limit of rows heights ( where rows were empty )
considered when exporting xlsx was the old 65535 limit.

Change-Id: I3772829fe88fe28c4a24061e77470c8a126ff419
üst bd2c4e8d
...@@ -1708,6 +1708,7 @@ XclExpRow::XclExpRow( const XclExpRoot& rRoot, sal_uInt32 nXclRow, ...@@ -1708,6 +1708,7 @@ XclExpRow::XclExpRow( const XclExpRoot& rRoot, sal_uInt32 nXclRow,
mnFlags( EXC_ROW_DEFAULTFLAGS ), mnFlags( EXC_ROW_DEFAULTFLAGS ),
mnXFIndex( EXC_XF_DEFAULTCELL ), mnXFIndex( EXC_XF_DEFAULTCELL ),
mnOutlineLevel( 0 ), mnOutlineLevel( 0 ),
mnXclRowRpt( 1 ),
mbAlwaysEmpty( bAlwaysEmpty ), mbAlwaysEmpty( bAlwaysEmpty ),
mbEnabled( true ) mbEnabled( true )
{ {
...@@ -2002,7 +2003,7 @@ void XclExpRowBuffer::AppendCell( XclExpCellRef xCell, bool bIsMergedBase ) ...@@ -2002,7 +2003,7 @@ void XclExpRowBuffer::AppendCell( XclExpCellRef xCell, bool bIsMergedBase )
void XclExpRowBuffer::CreateRows( SCROW nFirstFreeScRow ) void XclExpRowBuffer::CreateRows( SCROW nFirstFreeScRow )
{ {
if( nFirstFreeScRow > 0 ) if( nFirstFreeScRow > 0 )
GetOrCreateRow( static_cast< sal_uInt16 >( nFirstFreeScRow - 1 ), true ); GetOrCreateRow( ::std::max ( nFirstFreeScRow - 1, GetMaxPos().Row() ), true );
} }
void XclExpRowBuffer::Finalize( XclExpDefaultRowData& rDefRowData, const ScfUInt16Vec& rColXFIndexes ) void XclExpRowBuffer::Finalize( XclExpDefaultRowData& rDefRowData, const ScfUInt16Vec& rColXFIndexes )
...@@ -2023,6 +2024,9 @@ void XclExpRowBuffer::Finalize( XclExpDefaultRowData& rDefRowData, const ScfUInt ...@@ -2023,6 +2024,9 @@ void XclExpRowBuffer::Finalize( XclExpDefaultRowData& rDefRowData, const ScfUInt
XclExpDefaultRowData aMaxDefData; XclExpDefaultRowData aMaxDefData;
size_t nMaxDefCount = 0; size_t nMaxDefCount = 0;
// only look for default format in existing rows, if there are more than unused // only look for default format in existing rows, if there are more than unused
XclExpRow* pPrev = NULL;
typedef std::vector< XclExpRow* > XclRepeatedRows;
XclRepeatedRows aRepeated;
for (itr = itrBeg; itr != itrEnd; ++itr) for (itr = itrBeg; itr != itrEnd; ++itr)
{ {
const RowRef& rRow = itr->second; const RowRef& rRow = itr->second;
...@@ -2037,11 +2041,37 @@ void XclExpRowBuffer::Finalize( XclExpDefaultRowData& rDefRowData, const ScfUInt ...@@ -2037,11 +2041,37 @@ void XclExpRowBuffer::Finalize( XclExpDefaultRowData& rDefRowData, const ScfUInt
aMaxDefData = aDefData; aMaxDefData = aDefData;
} }
} }
if ( pPrev )
{
sal_uInt32 nRpt = rRow->GetXclRow() - pPrev->GetXclRow();
pPrev->SetXclRowRpt( nRpt );
if ( nRpt > 1 )
aRepeated.push_back( pPrev );
if ( pPrev->IsDefaultable())
{
XclExpDefaultRowData aDefData( *pPrev );
size_t& rnDefCount = aDefRowMap[ aDefData ];
rnDefCount += ( pPrev->GetXclRowRpt() - 1 );
if( rnDefCount > nMaxDefCount )
{
nMaxDefCount = rnDefCount;
aMaxDefData = aDefData;
}
}
}
pPrev = rRow.get();
} }
// return the default row format to caller // return the default row format to caller
rDefRowData = aMaxDefData; rDefRowData = aMaxDefData;
// now disable repeating extra (empty) rows that are equal to
// default row height
for ( XclRepeatedRows::iterator it = aRepeated.begin(), it_end = aRepeated.end(); it != it_end; ++it)
{
if ( (*it)->GetXclRowRpt() > 1 && (*it)->GetHeight() == rDefRowData.mnHeight )
(*it)->SetXclRowRpt( 1 );
}
// *** Disable unused ROW records, find used area *** --------------------- // *** Disable unused ROW records, find used area *** ---------------------
sal_uInt16 nFirstUsedXclCol = SAL_MAX_UINT16; sal_uInt16 nFirstUsedXclCol = SAL_MAX_UINT16;
......
...@@ -917,6 +917,8 @@ public: ...@@ -917,6 +917,8 @@ public:
virtual void Save( XclExpStream& rStrm ); virtual void Save( XclExpStream& rStrm );
virtual void SaveXml( XclExpXmlStream& rStrm ); virtual void SaveXml( XclExpXmlStream& rStrm );
inline sal_uInt32 GetXclRowRpt() const { return mnXclRowRpt; }
inline void SetXclRowRpt( sal_uInt32 nRpt ){ mnXclRowRpt = nRpt; }
private: private:
/** Initializes the record data. Called from constructors. */ /** Initializes the record data. Called from constructors. */
void Init( sal_uInt16 nXclRow, XclExpRowOutlineBuffer* pOutlineBfr ); void Init( sal_uInt16 nXclRow, XclExpRowOutlineBuffer* pOutlineBfr );
...@@ -935,6 +937,7 @@ private: ...@@ -935,6 +937,7 @@ private:
sal_uInt16 mnFlags; /// Flags for the ROW record. sal_uInt16 mnFlags; /// Flags for the ROW record.
sal_uInt16 mnXFIndex; /// Default row formatting. sal_uInt16 mnXFIndex; /// Default row formatting.
sal_uInt16 mnOutlineLevel; /// Outline Level (for OOXML) sal_uInt16 mnOutlineLevel; /// Outline Level (for OOXML)
sal_uInt32 mnXclRowRpt;
bool mbAlwaysEmpty; /// true = Do not add blank cells in Finalize(). bool mbAlwaysEmpty; /// true = Do not add blank cells in Finalize().
bool mbEnabled; /// true = Write this ROW record. bool mbEnabled; /// true = Write this ROW record.
}; };
......
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