diff options
author | Noel Power <noel.power@suse.com> | 2013-01-29 13:50:05 +0000 |
---|---|---|
committer | Noel Power <noel.power@suse.com> | 2013-01-30 18:01:45 +0000 |
commit | 9327467a2c5537613fa59013258532028da9c43b (patch) | |
tree | 280430e35a7222c4ec00569ccdfc96bc7d5bb9a3 | |
parent | bd2c4e8dc42c04eb05adfa32a0d5ce9c72bcfd5d (diff) |
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
-rw-r--r-- | sc/source/filter/excel/xetable.cxx | 34 | ||||
-rw-r--r-- | sc/source/filter/inc/xetable.hxx | 3 |
2 files changed, 35 insertions, 2 deletions
diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index ec54e15a4630..178acd9c998f 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -1708,6 +1708,7 @@ XclExpRow::XclExpRow( const XclExpRoot& rRoot, sal_uInt32 nXclRow, mnFlags( EXC_ROW_DEFAULTFLAGS ), mnXFIndex( EXC_XF_DEFAULTCELL ), mnOutlineLevel( 0 ), + mnXclRowRpt( 1 ), mbAlwaysEmpty( bAlwaysEmpty ), mbEnabled( true ) { @@ -2002,7 +2003,7 @@ void XclExpRowBuffer::AppendCell( XclExpCellRef xCell, bool bIsMergedBase ) void XclExpRowBuffer::CreateRows( SCROW nFirstFreeScRow ) { 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 ) @@ -2023,6 +2024,9 @@ void XclExpRowBuffer::Finalize( XclExpDefaultRowData& rDefRowData, const ScfUInt XclExpDefaultRowData aMaxDefData; size_t nMaxDefCount = 0; // 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) { const RowRef& rRow = itr->second; @@ -2037,11 +2041,37 @@ void XclExpRowBuffer::Finalize( XclExpDefaultRowData& rDefRowData, const ScfUInt 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 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 *** --------------------- sal_uInt16 nFirstUsedXclCol = SAL_MAX_UINT16; diff --git a/sc/source/filter/inc/xetable.hxx b/sc/source/filter/inc/xetable.hxx index 41ec24b22266..0138fe2a8221 100644 --- a/sc/source/filter/inc/xetable.hxx +++ b/sc/source/filter/inc/xetable.hxx @@ -917,6 +917,8 @@ public: virtual void Save( XclExpStream& rStrm ); virtual void SaveXml( XclExpXmlStream& rStrm ); + inline sal_uInt32 GetXclRowRpt() const { return mnXclRowRpt; } + inline void SetXclRowRpt( sal_uInt32 nRpt ){ mnXclRowRpt = nRpt; } private: /** Initializes the record data. Called from constructors. */ void Init( sal_uInt16 nXclRow, XclExpRowOutlineBuffer* pOutlineBfr ); @@ -935,6 +937,7 @@ private: sal_uInt16 mnFlags; /// Flags for the ROW record. sal_uInt16 mnXFIndex; /// Default row formatting. sal_uInt16 mnOutlineLevel; /// Outline Level (for OOXML) + sal_uInt32 mnXclRowRpt; bool mbAlwaysEmpty; /// true = Do not add blank cells in Finalize(). bool mbEnabled; /// true = Write this ROW record. }; |