sc/inc/column.hxx | 3 -- sc/inc/rowheightcontext.hxx | 6 ++++ sc/source/core/data/column.cxx | 19 +++++++++++--- sc/source/core/data/column2.cxx | 24 +++++++++--------- sc/source/core/data/rowheightcontext.cxx | 5 +++ sc/source/core/data/table1.cxx | 41 +++++++++++++++---------------- 6 files changed, 60 insertions(+), 38 deletions(-)
New commits: commit 452d65ff7ee1dc8be16b9262a13ce9be17243f68 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Fri Sep 26 16:21:12 2014 -0400 Annotate FindEditCellsHandler. Change-Id: Ib49a7a3eccee62e5496f7f19824631866e072b6a diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index d6152dd..e49d765 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -2833,17 +2833,21 @@ class FindEditCellsHandler sc::CellStoreType::iterator miCellPos; public: - FindEditCellsHandler(ScColumn& rColumn, sc::CellTextAttrStoreType& rAttrs, - const sc::CellStoreType::iterator& rCellItr) : - mrColumn(rColumn), miAttrPos(rAttrs.begin()), miCellPos(rCellItr) {} + FindEditCellsHandler(ScColumn& rCol) : + mrColumn(rCol), + miAttrPos(rCol.GetCellAttrStore().begin()), + miCellPos(rCol.GetCellStore().begin()) {} bool operator() (size_t, const EditTextObject*) { + // This is definitely an edit text cell. return true; } bool operator() (size_t nRow, const ScFormulaCell* p) { + // With a formula cell, it's considered an edit text cell when either + // the result is multi-line or it has more than one script types. sal_uInt8 nScriptType = mrColumn.GetRangeScriptType(miAttrPos, nRow, nRow, miCellPos); if (IsAmbiguousScriptNonZero(nScriptType)) return true; @@ -2851,13 +2855,19 @@ public: return const_cast<ScFormulaCell*>(p)->IsMultilineResult(); } + /** + * Callback for a block of other types. + */ std::pair<size_t,bool> operator() (const sc::CellStoreType::value_type& node, size_t nOffset, size_t nDataSize) { typedef std::pair<size_t,bool> RetType; if (node.type == sc::element_type_empty) + // Ignore empty blocks. return RetType(0, false); + // Check the script type of a non-empty element and see if it has + // multiple script types. for (size_t i = 0; i < nDataSize; ++i) { SCROW nRow = node.position + i + nOffset; @@ -2867,6 +2877,7 @@ public: return RetType(i+nOffset, true); } + // No edit text cell found. return RetType(0, false); } }; @@ -3232,7 +3243,7 @@ bool ScColumn::HasEditCells(SCROW nStartRow, SCROW nEndRow, SCROW& rFirst) { // used in GetOptimalHeight - ambiguous script type counts as edit cell - FindEditCellsHandler aFunc(*this, maCellTextAttrs, maCells.begin()); + FindEditCellsHandler aFunc(*this); std::pair<sc::CellStoreType::const_iterator,size_t> aPos = sc::FindFormulaEditText(maCells, nStartRow, nEndRow, aFunc); commit 3c23ec10b4b1a881b011d1ce16cc4012415c0f7a Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Fri Sep 26 15:39:50 2014 -0400 Store height array to RowHeightContext and reduce function arg counts. Change-Id: I09b79bc76ffc55e25c24bbfa8f000f4a46df0a1c diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 893ef13..7b189e0 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -461,8 +461,7 @@ public: bool bFormula, sal_uInt16 nOldWidth, const ScMarkData* pMarkData, const ScColWidthParam* pParam) const; void GetOptimalHeight( - sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, sal_uInt16* pHeight, - sal_uInt16 nMinHeight, SCROW nMinStart ); + sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, sal_uInt16 nMinHeight, SCROW nMinStart ); /// Including current, may return -1 SCsROW GetNextUnprotected( SCROW nRow, bool bUp ) const; diff --git a/sc/inc/rowheightcontext.hxx b/sc/inc/rowheightcontext.hxx index a334554..a077bd0 100644 --- a/sc/inc/rowheightcontext.hxx +++ b/sc/inc/rowheightcontext.hxx @@ -14,12 +14,16 @@ #include <tools/fract.hxx> +#include <vector> + class OutputDevice; namespace sc { class SC_DLLPUBLIC RowHeightContext { + std::vector<sal_uInt16> maHeights; + double mfPPTX; double mfPPTY; Fraction maZoomX; @@ -48,6 +52,8 @@ public: void setForceAutoSize( bool b ); bool isForceAutoSize() const { return mbForceAutoSize;} + + std::vector<sal_uInt16>& getHeightArray(); }; } diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 13cdee8..e038da3b 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -772,9 +772,9 @@ static sal_uInt16 lcl_GetAttribHeight( const ScPatternAttr& rPattern, sal_uInt16 // (is only evaluated with bStdAllowed) void ScColumn::GetOptimalHeight( - sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, sal_uInt16* pHeight, - sal_uInt16 nMinHeight, SCROW nMinStart ) + sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, sal_uInt16 nMinHeight, SCROW nMinStart ) { + std::vector<sal_uInt16>& rHeights = rCxt.getHeightArray(); ScAttrIterator aIter( pAttrArray, nStartRow, nEndRow ); SCROW nStart = -1; @@ -865,8 +865,8 @@ void ScColumn::GetOptimalHeight( nStdEnd = (nMinStart>0) ? nMinStart-1 : 0; for (SCROW nRow = nStart; nRow <= nStdEnd; ++nRow) - if (nDefHeight > pHeight[nRow-nStartRow]) - pHeight[nRow-nStartRow] = nDefHeight; + if (nDefHeight > rHeights[nRow-nStartRow]) + rHeights[nRow-nStartRow] = nDefHeight; if ( bStdOnly ) { @@ -887,22 +887,22 @@ void ScColumn::GetOptimalHeight( { if ( nCjkHeight == 0 ) nCjkHeight = lcl_GetAttribHeight( *pPattern, ATTR_CJK_FONT_HEIGHT ); - if (nCjkHeight > pHeight[nRow-nStartRow]) - pHeight[nRow-nStartRow] = nCjkHeight; + if (nCjkHeight > rHeights[nRow-nStartRow]) + rHeights[nRow-nStartRow] = nCjkHeight; } else if ( nScript == SCRIPTTYPE_COMPLEX ) { if ( nCtlHeight == 0 ) nCtlHeight = lcl_GetAttribHeight( *pPattern, ATTR_CTL_FONT_HEIGHT ); - if (nCtlHeight > pHeight[nRow-nStartRow]) - pHeight[nRow-nStartRow] = nCtlHeight; + if (nCtlHeight > rHeights[nRow-nStartRow]) + rHeights[nRow-nStartRow] = nCtlHeight; } else { if ( nLatHeight == 0 ) nLatHeight = lcl_GetAttribHeight( *pPattern, ATTR_FONT_HEIGHT ); - if (nLatHeight > pHeight[nRow-nStartRow]) - pHeight[nRow-nStartRow] = nLatHeight; + if (nLatHeight > rHeights[nRow-nStartRow]) + rHeights[nRow-nStartRow] = nLatHeight; } } } @@ -928,8 +928,8 @@ void ScColumn::GetOptimalHeight( ( GetNeededSize( nRow, rCxt.getOutputDevice(), rCxt.getPPTX(), rCxt.getPPTY(), rCxt.getZoomX(), rCxt.getZoomY(), false, aOptions, &pPattern) / rCxt.getPPTY() ); - if (nHeight > pHeight[nRow-nStartRow]) - pHeight[nRow-nStartRow] = nHeight; + if (nHeight > rHeights[nRow-nStartRow]) + rHeights[nRow-nStartRow] = nHeight; // Pattern changed due to calculation? => sync. if (pPattern != pOldPattern) { diff --git a/sc/source/core/data/rowheightcontext.cxx b/sc/source/core/data/rowheightcontext.cxx index 5f51dfa..46f3c6d 100644 --- a/sc/source/core/data/rowheightcontext.cxx +++ b/sc/source/core/data/rowheightcontext.cxx @@ -32,6 +32,11 @@ void RowHeightContext::setForceAutoSize( bool b ) mbForceAutoSize = b; } +std::vector<sal_uInt16>& RowHeightContext::getHeightArray() +{ + return maHeights; +} + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 88631d5..24fa77d 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -82,7 +82,7 @@ ScProgress* GetProgressBar( void GetOptimalHeightsInColumn( sc::RowHeightContext& rCxt, ScColumn* pCol, SCROW nStartRow, SCROW nEndRow, - vector<sal_uInt16>& aHeights, ScProgress* pProgress, sal_uInt32 nProgressStart ) + ScProgress* pProgress, sal_uInt32 nProgressStart ) { SCSIZE nCount = static_cast<SCSIZE>(nEndRow-nStartRow+1); @@ -90,20 +90,22 @@ void GetOptimalHeightsInColumn( // (mit der letzten Spalte in der Hoffnung, dass die am ehesten noch auf // Standard formatiert ist) - pCol[MAXCOL].GetOptimalHeight(rCxt, nStartRow, nEndRow, &aHeights[0], 0, 0); + std::vector<sal_uInt16>& rHeights = rCxt.getHeightArray(); + + pCol[MAXCOL].GetOptimalHeight(rCxt, nStartRow, nEndRow, 0, 0); // daraus Standardhoehe suchen, die im unteren Bereich gilt - sal_uInt16 nMinHeight = aHeights[nCount-1]; + sal_uInt16 nMinHeight = rHeights[nCount-1]; SCSIZE nPos = nCount-1; - while ( nPos && aHeights[nPos-1] >= nMinHeight ) + while ( nPos && rHeights[nPos-1] >= nMinHeight ) --nPos; SCROW nMinStart = nStartRow + nPos; sal_uLong nWeightedCount = 0; for (SCCOL nCol=0; nCol<MAXCOL; nCol++) // MAXCOL schon oben { - pCol[nCol].GetOptimalHeight(rCxt, nStartRow, nEndRow, &aHeights[0], nMinHeight, nMinStart); + pCol[nCol].GetOptimalHeight(rCxt, nStartRow, nEndRow, nMinHeight, nMinStart); if (pProgress) { @@ -155,9 +157,10 @@ struct SetRowHeightRangeFunc : public OptimalHeightsFuncObjBase } }; -bool SetOptimalHeightsToRows(OptimalHeightsFuncObjBase& rFuncObj, - ScBitMaskCompressedArray<SCROW, sal_uInt8>* pRowFlags, SCROW nStartRow, SCROW nEndRow, sal_uInt16 nExtra, - const vector<sal_uInt16>& aHeights, bool bForce) +bool SetOptimalHeightsToRows( + sc::RowHeightContext& rCxt, + OptimalHeightsFuncObjBase& rFuncObj, + ScBitMaskCompressedArray<SCROW, sal_uInt8>* pRowFlags, SCROW nStartRow, SCROW nEndRow ) { SCSIZE nCount = static_cast<SCSIZE>(nEndRow-nStartRow+1); bool bChanged = false; @@ -174,9 +177,9 @@ bool SetOptimalHeightsToRows(OptimalHeightsFuncObjBase& rFuncObj, SCSIZE nMoreRows = nRegionEndRow - ( nStartRow+i ); // additional equal rows after first bool bAutoSize = ((nRowFlag & CR_MANUALSIZE) == 0); - if ( bAutoSize || bForce ) + if (bAutoSize || rCxt.isForceAutoSize()) { - if (nExtra) + if (rCxt.getExtraHeight()) { if (bAutoSize) pRowFlags->SetValue( nStartRow+i, nRegionEndRow, nRowFlag | CR_MANUALSIZE); @@ -188,7 +191,7 @@ bool SetOptimalHeightsToRows(OptimalHeightsFuncObjBase& rFuncObj, { if (nLast) { - if (aHeights[nInner]+nExtra == nLast) + if (rCxt.getHeightArray()[nInner] + rCxt.getExtraHeight() == nLast) nRngEnd = nStartRow+nInner; else { @@ -198,7 +201,7 @@ bool SetOptimalHeightsToRows(OptimalHeightsFuncObjBase& rFuncObj, } if (!nLast) { - nLast = aHeights[nInner]+nExtra; + nLast = rCxt.getHeightArray()[nInner] + rCxt.getExtraHeight(); nRngStart = nStartRow+nInner; nRngEnd = nStartRow+nInner; } @@ -465,13 +468,12 @@ bool ScTable::SetOptimalHeight( ScProgress* pProgress = GetProgressBar(nCount, GetWeightedCount(), pOuterProgress, pDocument); - vector<sal_uInt16> aHeights(nCount, 0); + rCxt.getHeightArray().resize(nCount, 0); - GetOptimalHeightsInColumn(rCxt, aCol, nStartRow, nEndRow, aHeights, pProgress, nProgressStart); + GetOptimalHeightsInColumn(rCxt, aCol, nStartRow, nEndRow, pProgress, nProgressStart); SetRowHeightRangeFunc aFunc(this, rCxt.getPPTX(), rCxt.getPPTY()); - bool bChanged = SetOptimalHeightsToRows( - aFunc, pRowFlags, nStartRow, nEndRow, rCxt.getExtraHeight(), aHeights, rCxt.isForceAutoSize()); + bool bChanged = SetOptimalHeightsToRows(rCxt, aFunc, pRowFlags, nStartRow, nEndRow); if ( pProgress != pOuterProgress ) delete pProgress; @@ -493,13 +495,12 @@ void ScTable::SetOptimalHeightOnly( ScProgress* pProgress = GetProgressBar(nCount, GetWeightedCount(), pOuterProgress, pDocument); - vector<sal_uInt16> aHeights(nCount, 0); + rCxt.getHeightArray().resize(nCount, 0); - GetOptimalHeightsInColumn(rCxt, aCol, nStartRow, nEndRow, aHeights, pProgress, nProgressStart); + GetOptimalHeightsInColumn(rCxt, aCol, nStartRow, nEndRow, pProgress, nProgressStart); SetRowHeightOnlyFunc aFunc(this); - SetOptimalHeightsToRows( - aFunc, pRowFlags, nStartRow, nEndRow, rCxt.getExtraHeight(), aHeights, rCxt.isForceAutoSize()); + SetOptimalHeightsToRows(rCxt, aFunc, pRowFlags, nStartRow, nEndRow); if ( pProgress != pOuterProgress ) delete pProgress; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits