diff -Nru libreoffice-4.2.7~rc2/debian/changelog libreoffice-4.2.7~rc2/debian/changelog --- libreoffice-4.2.7~rc2/debian/changelog 2014-10-18 04:32:56.000000000 -0700 +++ libreoffice-4.2.7~rc2/debian/changelog 2014-10-19 08:05:51.000000000 -0700 @@ -1,3 +1,13 @@ +libreoffice (1:4.2.7~rc2-0ubuntu3) trusty; urgency=medium + + * Optimize performance after replaceall & searchall (LP: #1342175) + - upstream 1cf19ea84794ca065749667b480dfed2d27d47b7 + - upstream 1e721077b43de84edab2a3ed2f316ddcbec6e3ec + - upstream 91502a72c12c559442e8bf77c27a516b49c2a68d + - related code + + -- Seyeong Kim Sun, 19 Oct 2014 08:04:28 -0700 + libreoffice (1:4.2.7~rc2-0ubuntu2) trusty; urgency=medium * bump version to upstream 4.2.7~rc2 diff -Nru libreoffice-4.2.7~rc2/debian/patches/optimize_performance_after_replaceall_searchall libreoffice-4.2.7~rc2/debian/patches/optimize_performance_after_replaceall_searchall --- libreoffice-4.2.7~rc2/debian/patches/optimize_performance_after_replaceall_searchall 1969-12-31 16:00:00.000000000 -0800 +++ libreoffice-4.2.7~rc2/debian/patches/optimize_performance_after_replaceall_searchall 2014-10-19 08:04:06.000000000 -0700 @@ -0,0 +1,268 @@ +Index: libreoffice-4.2.7~rc2/sc/inc/column.hxx +=================================================================== +--- libreoffice-4.2.7~rc2.orig/sc/inc/column.hxx 2014-10-19 08:04:04.821232197 -0700 ++++ libreoffice-4.2.7~rc2/sc/inc/column.hxx 2014-10-19 08:04:04.813232197 -0700 +@@ -24,6 +24,7 @@ + #include "global.hxx" + #include "address.hxx" + #include "rangenam.hxx" ++#include "rangelst.hxx" + #include "types.hxx" + #include "mtvelements.hxx" + #include "formula/types.hxx" +@@ -255,7 +256,7 @@ + ScAttrIterator* CreateAttrIterator( SCROW nStartRow, SCROW nEndRow ) const; + + void UpdateSelectionFunction( +- const ScMarkData& rMark, ScFunctionData& rData, ScFlatBoolRowSegments& rHiddenRows ); ++ const ScRangeList& rRanges, ScFunctionData& rData, ScFlatBoolRowSegments& rHiddenRows ); + + void CopyToColumn( + sc::CopyToDocContext& rCxt, SCROW nRow1, SCROW nRow2, sal_uInt16 nFlags, bool bMarked, +Index: libreoffice-4.2.7~rc2/sc/inc/columnspanset.hxx +=================================================================== +--- libreoffice-4.2.7~rc2.orig/sc/inc/columnspanset.hxx 2014-10-19 08:04:04.821232197 -0700 ++++ libreoffice-4.2.7~rc2/sc/inc/columnspanset.hxx 2014-10-19 08:04:04.813232197 -0700 +@@ -20,6 +20,7 @@ + class ScColumn; + class ScMarkData; + class ScRange; ++class ScRangeList; + + namespace sc { + +@@ -33,6 +34,15 @@ + RowSpan(SCROW nRow1, SCROW nRow2); + }; + ++struct SC_DLLPUBLIC ColRowSpan ++{ ++ SCCOLROW mnStart; ++ SCCOLROW mnEnd; ++ ++ ColRowSpan(SCCOLROW nStart, SCCOLROW nEnd); ++}; ++ ++ + /** + * Structure that stores segments of boolean flags per column, and perform + * custom action on those segments. +@@ -124,6 +134,8 @@ + */ + void scan(const ScMarkData& rMark, SCTAB nTab, SCCOL nCol); + ++ void scan(const ScRangeList& rRanges, SCTAB nTab, SCCOL nCol); ++ + void set(SCROW nRow1, SCROW nRow2, bool bVal); + + void getRows(std::vector &rRows) const; +Index: libreoffice-4.2.7~rc2/sc/source/core/data/column2.cxx +=================================================================== +--- libreoffice-4.2.7~rc2.orig/sc/source/core/data/column2.cxx 2014-10-19 08:04:04.821232197 -0700 ++++ libreoffice-4.2.7~rc2/sc/source/core/data/column2.cxx 2014-10-19 08:04:04.817232197 -0700 +@@ -3352,10 +3352,10 @@ + + // multiple selections: + void ScColumn::UpdateSelectionFunction( +- const ScMarkData& rMark, ScFunctionData& rData, ScFlatBoolRowSegments& rHiddenRows ) ++ const ScRangeList& rRanges, ScFunctionData& rData, ScFlatBoolRowSegments& rHiddenRows ) + { + sc::SingleColumnSpanSet aSpanSet; +- aSpanSet.scan(rMark, nTab, nCol); // mark all selected rows. ++ aSpanSet.scan(rRanges, nTab, nCol); // mark all selected rows. + + // Exclude all hidden rows. + ScFlatBoolRowSegments::RangeData aRange; +Index: libreoffice-4.2.7~rc2/sc/source/core/data/columnspanset.cxx +=================================================================== +--- libreoffice-4.2.7~rc2.orig/sc/source/core/data/columnspanset.cxx 2014-10-19 08:04:04.821232197 -0700 ++++ libreoffice-4.2.7~rc2/sc/source/core/data/columnspanset.cxx 2014-10-19 08:04:04.817232197 -0700 +@@ -45,6 +45,8 @@ + + RowSpan::RowSpan(SCROW nRow1, SCROW nRow2) : mnRow1(nRow1), mnRow2(nRow2) {} + ++ColRowSpan::ColRowSpan(SCCOLROW nStart, SCCOLROW nEnd) : mnStart(nStart), mnEnd(nEnd) {} ++ + ColumnSpanSet::ColumnType::ColumnType(SCROW nStart, SCROW nEnd, bool bInit) : + maSpans(nStart, nEnd+1, bInit), miPos(maSpans.begin()) {} + +@@ -275,9 +277,17 @@ + return; + + ScRangeList aRanges = rMark.GetMarkedRanges(); +- for (size_t i = 0, n = aRanges.size(); i < n; ++i) ++ scan(aRanges, nTab, nCol); ++} ++ ++void SingleColumnSpanSet::scan(const ScRangeList& rRanges, SCTAB nTab, SCCOL nCol) ++{ ++ for (size_t i = 0, n = rRanges.size(); i < n; ++i) + { +- const ScRange* p = aRanges[i]; ++ const ScRange* p = rRanges[i]; ++ if (nTab < p->aStart.Tab() || p->aEnd.Tab() < nTab) ++ continue; ++ + if (nCol < p->aStart.Col() || p->aEnd.Col() < nCol) + // This column is not in this range. Skip it. + continue; +Index: libreoffice-4.2.7~rc2/sc/source/core/data/table2.cxx +=================================================================== +--- libreoffice-4.2.7~rc2.orig/sc/source/core/data/table2.cxx 2014-10-19 08:04:04.821232197 -0700 ++++ libreoffice-4.2.7~rc2/sc/source/core/data/table2.cxx 2014-10-19 08:04:04.817232197 -0700 +@@ -49,6 +49,7 @@ + #include "mtvcellfunc.hxx" + #include "refupdatecontext.hxx" + #include "scopetools.hxx" ++#include "columnspanset.hxx" + #include + + #include "scitems.hxx" +@@ -1897,10 +1898,17 @@ + + bool ScTable::HasAttribSelection( const ScMarkData& rMark, sal_uInt16 nMask ) const + { +- bool bFound = false; +- for (SCCOL i=0; i<=MAXCOL && !bFound; i++) +- bFound |= aCol[i].HasAttribSelection( rMark, nMask ); +- return bFound; ++ std::vector aSpans = rMark.GetMarkedColSpans(); ++ ++ for (size_t i = 0; i < aSpans.size(); ++i) ++ { ++ for (SCCOLROW j = aSpans[i].mnStart; j < aSpans[i].mnEnd; ++j) ++ { ++ if (aCol[j].HasAttribSelection(rMark, nMask)) ++ return true; ++ } ++ } ++ return false; + } + + +@@ -2171,10 +2179,17 @@ + + bool ScTable::HasSelectionMatrixFragment( const ScMarkData& rMark ) const + { +- bool bFound = false; +- for (SCCOL i=0; i<=MAXCOL && !bFound; i++) +- bFound |= aCol[i].HasSelectionMatrixFragment(rMark); +- return bFound; ++ std::vector aSpans = rMark.GetMarkedColSpans(); ++ ++ for ( size_t i=0; i + #include + #include ++#include "rangelst.hxx" + + #include "svl/sharedstringpool.hxx" + +@@ -2999,12 +3000,13 @@ + + void ScTable::UpdateSelectionFunction( ScFunctionData& rData, const ScMarkData& rMark ) + { ++ ScRangeList aRanges = rMark.GetMarkedRanges(); + for (SCCOL nCol = 0; nCol <= MAXCOL && !rData.bError; ++nCol) + { + if (pColFlags && ColHidden(nCol)) + continue; + +- aCol[nCol].UpdateSelectionFunction(rMark, rData, *mpHiddenRows); ++ aCol[nCol].UpdateSelectionFunction(aRanges, rData, *mpHiddenRows); + } + } + +Index: libreoffice-4.2.7~rc2/sc/inc/markdata.hxx +=================================================================== +--- libreoffice-4.2.7~rc2.orig/sc/inc/markdata.hxx 2014-10-19 08:04:04.821232197 -0700 ++++ libreoffice-4.2.7~rc2/sc/inc/markdata.hxx 2014-10-19 08:04:04.817232197 -0700 +@@ -29,6 +29,7 @@ + namespace sc { + + struct RowSpan; ++struct ColRowSpan; + + } + +@@ -106,6 +107,9 @@ + + void MarkFromRangeList( const ScRangeList& rList, bool bReset ); + ++ std::vector GetMarkedRowSpans() const; ++ std::vector GetMarkedColSpans() const; ++ + SCCOLROW GetMarkColumnRanges( SCCOLROW* pRanges ); + SCCOLROW GetMarkRowRanges( SCCOLROW* pRanges ); + +Index: libreoffice-4.2.7~rc2/sc/source/core/data/markdata.cxx +=================================================================== +--- libreoffice-4.2.7~rc2.orig/sc/source/core/data/markdata.cxx 2014-10-19 08:04:04.821232197 -0700 ++++ libreoffice-4.2.7~rc2/sc/source/core/data/markdata.cxx 2014-10-19 08:04:04.817232197 -0700 +@@ -21,6 +21,9 @@ + #include "markarr.hxx" + #include "rangelst.hxx" + #include ++#include ++ ++#include + + // STATIC DATA ----------------------------------------------------------- + +@@ -434,6 +437,40 @@ + return aRet; + } + ++std::vector ScMarkData::GetMarkedRowSpans() const ++{ ++ typedef mdds::flat_segment_tree SpansType; ++ ++ ScRangeList aRanges = GetMarkedRanges(); ++ SpansType aSpans(0, MAXROW+1, false); ++ SpansType::const_iterator itPos = aSpans.begin(); ++ ++ for (size_t i = 0, n = aRanges.size(); i < n; ++i) ++ { ++ const ScRange& r = *aRanges[i]; ++ itPos = aSpans.insert(itPos, r.aStart.Row(), r.aEnd.Row()+1, true).first; ++ } ++ ++ return sc::toSpanArray(aSpans); ++} ++ ++std::vector ScMarkData::GetMarkedColSpans() const ++{ ++ typedef mdds::flat_segment_tree SpansType; ++ ++ ScRangeList aRanges = GetMarkedRanges(); ++ SpansType aSpans(0, MAXCOL+1, false); ++ SpansType::const_iterator itPos = aSpans.begin(); ++ ++ for (size_t i = 0, n = aRanges.size(); i < n; ++i) ++ { ++ const ScRange& r = *aRanges[i]; ++ itPos = aSpans.insert(itPos, r.aStart.Col(), r.aEnd.Col()+1, true).first; ++ } ++ ++ return sc::toSpanArray(aSpans); ++} ++ + SCCOLROW ScMarkData::GetMarkColumnRanges( SCCOLROW* pRanges ) + { + if (bMarked) diff -Nru libreoffice-4.2.7~rc2/debian/patches/series libreoffice-4.2.7~rc2/debian/patches/series --- libreoffice-4.2.7~rc2/debian/patches/series 2014-10-18 04:32:56.000000000 -0700 +++ libreoffice-4.2.7~rc2/debian/patches/series 2014-10-19 08:03:44.000000000 -0700 @@ -33,3 +33,5 @@ lp-1253620-prefer-gio.diff lp-753627-readd-updated-Ubuntu-brand-palette-colors.diff lp-1296715.diff +optimize_performance_after_replaceall.diff +optimize_performance_after_replaceall_searchall