[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 2 commits - sc/source
sc/source/core/tool/sharedformula.cxx | 36 ++ 1 file changed, 24 insertions(+), 12 deletions(-) New commits: commit 478868c419491dd5ad0921fe8b4e7f71d946dd10 Author: Kohei Yoshida Date: Mon Aug 12 16:42:53 2013 -0400 Ungroup a cell when the group length becomes 1. Change-Id: Ic656d4837ab1fc5feb4b19765ae427371dfdfe10 diff --git a/sc/source/core/tool/sharedformula.cxx b/sc/source/core/tool/sharedformula.cxx index 07d9029..6583ac9 100644 --- a/sc/source/core/tool/sharedformula.cxx +++ b/sc/source/core/tool/sharedformula.cxx @@ -38,13 +38,25 @@ void SharedFormulaUtil::splitFormulaCellGroup(const CellStoreType::position_type ScFormulaCellGroupRef xGroup = rTop.GetCellGroup(); -ScFormulaCellGroupRef xGroup2(new ScFormulaCellGroup); -xGroup2->mbInvariant = xGroup->mbInvariant; -xGroup2->mnStart = nRow; -xGroup2->mnLength = xGroup->mnStart + xGroup->mnLength - nRow; -xGroup2->mpCode = xGroup->mpCode->Clone(); +SCROW nLength2 = xGroup->mnStart + xGroup->mnLength - nRow; +ScFormulaCellGroupRef xGroup2; +if (nLength2 > 1) +{ +xGroup2.reset(new ScFormulaCellGroup); +xGroup2->mbInvariant = xGroup->mbInvariant; +xGroup2->mnStart = nRow; +xGroup2->mnLength = nLength2; +xGroup2->mpCode = xGroup->mpCode->Clone(); +} xGroup->mnLength = nRow - xGroup->mnStart; +if (xGroup->mnLength == 1) +{ +// The top group consists of only one cell. Ungroup this. +ScFormulaCellGroupRef xNone; +ScFormulaCell& rPrev = *sc::formula_block::at(*aPos.first->data, aPos.second-1); +rPrev.SetCellGroup(xNone); +} // Apply the lower group object to the lower cells. #if DEBUG_COLUMN_STORAGE @@ -56,7 +68,7 @@ void SharedFormulaUtil::splitFormulaCellGroup(const CellStoreType::position_type } #endif sc::formula_block::iterator itEnd = it; -std::advance(itEnd, xGroup2->mnLength); +std::advance(itEnd, nLength2); for (; it != itEnd; ++it) { ScFormulaCell& rCell = **it; commit 8da8c604a3715c9f1b1cd4e720649db52d6816c5 Author: Kohei Yoshida Date: Mon Aug 12 16:28:29 2013 -0400 Fix indentation. Change-Id: I2caebb42d92bf81e3ba8809a47f833a9379e769d diff --git a/sc/source/core/tool/sharedformula.cxx b/sc/source/core/tool/sharedformula.cxx index 9299e33..07d9029 100644 --- a/sc/source/core/tool/sharedformula.cxx +++ b/sc/source/core/tool/sharedformula.cxx @@ -48,12 +48,12 @@ void SharedFormulaUtil::splitFormulaCellGroup(const CellStoreType::position_type // Apply the lower group object to the lower cells. #if DEBUG_COLUMN_STORAGE -if (xGroup2->mnStart + xGroup2->mnLength > aPos.first->position + aPos.first->size) -{ -cerr << "ScColumn::SplitFormulaCellGroup: Shared formula region goes beyond the formula block. Not good." << endl; -cerr.flush(); -abort(); -} +if (xGroup2->mnStart + xGroup2->mnLength > aPos.first->position + aPos.first->size) +{ +cerr << "ScColumn::SplitFormulaCellGroup: Shared formula region goes beyond the formula block. Not good." << endl; +cerr.flush(); +abort(); +} #endif sc::formula_block::iterator itEnd = it; std::advance(itEnd, xGroup2->mnLength); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 2 commits - sc/source
sc/source/core/data/formulacell.cxx | 28 +--- sc/source/core/tool/token.cxx |3 +++ 2 files changed, 4 insertions(+), 27 deletions(-) New commits: commit 35624096f9f74472c88ef29f1e0cf8f169cff6b3 Author: Kohei Yoshida Date: Wed Aug 7 23:09:43 2013 -0400 Disable vectorization on named ranges for now. Change-Id: Ibc10d5eb9afff6062106c952aa2e7d3f9cb58100 diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 4a05c4c..fd103bc 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -3366,32 +3366,6 @@ public: mrGroupTokens.AddToken(aTok); } break; -case svIndex: -{ -// Named range. -ScRangeName* pNames = mrDoc.GetRangeName(); -if (!pNames) -// This should never fail. -return false; - -ScRangeData* pRange = pNames->findByIndex(p->GetIndex()); -if (!pRange) -// No named range exists by that index. -return false; - -ScTokenArray* pNamedTokens = pRange->GetCode(); -if (!pNamedTokens) -// This named range is empty. -return false; - -mrGroupTokens.AddOpCode(ocOpen); - -if (!convert(*pNamedTokens)) -return false; - -mrGroupTokens.AddOpCode(ocClose); -} -break; default: mrGroupTokens.AddToken(*pToken); } diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index d74182d..9f58380 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -1347,6 +1347,9 @@ void ScTokenArray::CheckToken( const FormulaToken& r ) ; } } + +if (eOp == ocName) +meVectorState = FormulaVectorDisabled; } bool ScTokenArray::ImplGetReference( ScRange& rRange, const ScAddress& rPos, bool bValidOnly ) const commit c167d9332761ee707eb5f631de03c05a6593e7c5 Author: Kohei Yoshida Date: Wed Aug 7 22:59:23 2013 -0400 Uncomment this. Change-Id: I628c826905d0c1074fbc5c12e821c0efd6489bbf diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index d6254c2..4a05c4c 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -3410,7 +3410,7 @@ bool ScFormulaCell::InterpretFormulaGroup() // Re-build formulae groups if necessary - ideally this is done at // import / insert / delete etc. and is integral to the data structures -// pDocument->RebuildFormulaGroups(); +pDocument->RebuildFormulaGroups(); if (!mxGroup || !pCode) return false; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 2 commits - sc/source
sc/source/core/data/formulacell.cxx | 91 +++- 1 file changed, 38 insertions(+), 53 deletions(-) New commits: commit 8444610c89407122cd16b5434516650f9fa82462 Author: Kohei Yoshida Date: Wed Jul 17 22:32:23 2013 -0400 No reference update in clip or undo documents. Make that up front. Change-Id: Ie2170bc1d183e6840d46c51910a4c150b83961ca diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 343ef0d..8e8ef5c 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -2229,7 +2229,6 @@ bool ScFormulaCell::UpdateReferenceOnShift( // Just in case... return false; -bool bCellStateChanged = false; const ScRange& rRange = rCxt.maRange; SCCOL nDx = rCxt.mnColDelta; SCROW nDy = rCxt.mnRowDelta; @@ -2247,28 +2246,24 @@ bool ScFormulaCell::UpdateReferenceOnShift( xGroup->mnStart += nDy; } -bool bHasRefs = false; +// Check presence of any references or column row names. +pCode->Reset(); +bool bHasRefs = (pCode->GetNextReferenceRPN() != NULL); bool bHasColRowNames = false; -bool bOnRefMove = false; -if ( !pDocument->IsClipOrUndo() ) +if (!bHasRefs) { -// Check presence of any references or column row names. pCode->Reset(); -bHasRefs = (pCode->GetNextReferenceRPN() != NULL); -if (!bHasRefs) -{ -pCode->Reset(); -bHasColRowNames = (pCode->GetNextColRowName() != NULL); -bHasRefs = bHasRefs || bHasColRowNames; -} -bOnRefMove = pCode->IsRecalcModeOnRefMove(); +bHasColRowNames = (pCode->GetNextColRowName() != NULL); +bHasRefs = bHasRefs || bHasColRowNames; } +bool bOnRefMove = pCode->IsRecalcModeOnRefMove(); if (!bHasRefs && !bOnRefMove) // This formula cell contains no references, nor needs recalculating // on reference update. Bail out. -return bCellStateChanged; +return false; +bool bCellStateChanged = false; boost::scoped_ptr pOldCode; if (pUndoDoc) pOldCode.reset(pCode->Clone()); @@ -2380,7 +2375,6 @@ bool ScFormulaCell::UpdateReferenceOnMove( if (rCxt.meMode != URM_MOVE) return false; -bool bCellStateChanged = false; const ScRange& rRange = rCxt.maRange; SCCOL nDx = rCxt.mnColDelta; SCROW nDy = rCxt.mnRowDelta; @@ -2402,28 +2396,25 @@ bool ScFormulaCell::UpdateReferenceOnMove( aOldPos.Set( nCol - nDx, nRow - nDy, nTab - nDz ); } -bool bHasRefs = false; + +// Check presence of any references or column row names. +pCode->Reset(); +bool bHasRefs = (pCode->GetNextReferenceRPN() != NULL); bool bHasColRowNames = false; -bool bOnRefMove = false; -if ( !pDocument->IsClipOrUndo() ) +if (!bHasRefs) { -// Check presence of any references or column row names. pCode->Reset(); -bHasRefs = (pCode->GetNextReferenceRPN() != NULL); -if (!bHasRefs) -{ -pCode->Reset(); -bHasColRowNames = (pCode->GetNextColRowName() != NULL); -bHasRefs = bHasRefs || bHasColRowNames; -} -bOnRefMove = pCode->IsRecalcModeOnRefMove(); +bHasColRowNames = (pCode->GetNextColRowName() != NULL); +bHasRefs = bHasRefs || bHasColRowNames; } +bool bOnRefMove = pCode->IsRecalcModeOnRefMove(); if (!bHasRefs && !bOnRefMove) // This formula cell contains no references, nor needs recalculating // on reference update. Bail out. -return bCellStateChanged; +return false; +bool bCellStateChanged = false; boost::scoped_ptr pOldCode; if (pUndoDoc) pOldCode.reset(pCode->Clone()); @@ -2536,7 +2527,6 @@ bool ScFormulaCell::UpdateReferenceOnCopy( if (rCxt.meMode != URM_COPY) return false; -bool bCellStateChanged = false; const ScRange& rRange = rCxt.maRange; SCCOL nDx = rCxt.mnColDelta; SCROW nDy = rCxt.mnRowDelta; @@ -2558,25 +2548,20 @@ bool ScFormulaCell::UpdateReferenceOnCopy( aOldPos.Set( nCol - nDx, nRow - nDy, nTab - nDz ); } -bool bHasRefs = false; -bool bHasColRowNames = false; -bool bOnRefMove = false; -if ( !pDocument->IsClipOrUndo() ) -{ -// Check presence of any references or column row names. -pCode->Reset(); -bHasRefs = (pCode->GetNextReferenceRPN() != NULL); -pCode->Reset(); -bHasColRowNames = (pCode->GetNextColRowName() != NULL); -bHasRefs = bHasRefs || bHasColRowNames; -bOnRefMove = pCode->IsRecalcModeOnRefMove(); -} +// Check presence of any references or column row names. +pCode->Reset(); +bool bHasRefs = (pCode->GetNextReferenceRPN() != NULL); +pCode->Reset(); +bool bHasColRowNames = (pCode->GetNextColRowName() != NULL); +bHasRefs = bHasRefs ||
[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 2 commits - sc/source
sc/source/core/tool/formulagroup.cxx | 37 +-- 1 file changed, 27 insertions(+), 10 deletions(-) New commits: commit 04b8fbe686cd4cb34c24ec0d33614a59908dc323 Author: Kohei Yoshida Date: Fri Jul 12 11:40:54 2013 -0400 Cache select converted tokens to avoid unnecessary token duplication. Change-Id: I3a63d5cbbc1cdc37d681ffd41ec22ff65e56cc0d diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx index 6573d15..4ac4b6b 100644 --- a/sc/source/core/tool/formulagroup.cxx +++ b/sc/source/core/tool/formulagroup.cxx @@ -19,6 +19,7 @@ #include "formula/vectortoken.hxx" #include +#include #define USE_DUMMY_INTERPRETER 1 @@ -37,6 +38,8 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres const ScFormulaCellGroupRef& xGroup, ScTokenArray& rCode) { +typedef boost::unordered_map CachedTokensType; + // Decompose the group into individual cells and calculate them individually. // The caller must ensure that the top position is the start position of @@ -45,11 +48,21 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres ScAddress aTmpPos = rTopPos; std::vector aResults; aResults.reserve(xGroup->mnLength); +CachedTokensType aCachedTokens; + for (SCROW i = 0; i < xGroup->mnLength; ++i, aTmpPos.IncRow()) { ScTokenArray aCode2; for (const formula::FormulaToken* p = rCode.First(); p; p = rCode.Next()) { +CachedTokensType::iterator it = aCachedTokens.find(p); +if (it != aCachedTokens.end()) +{ +// This token is cached. Use the cached one. +aCode2.AddToken(*it->second); +continue; +} + switch (p->GetType()) { case formula::svSingleVectorRef: @@ -77,8 +90,18 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres pMat->PutDouble(pArray, nRowSize, nCol, 0); } -ScMatrixToken aTok(pMat); -aCode2.AddToken(aTok); +if (p2->IsStartFixed() && p2->IsEndFixed()) +{ +// Cached the converted token for absolute range referene. +formula::FormulaTokenRef xTok(new ScMatrixToken(pMat)); +aCachedTokens.insert(CachedTokensType::value_type(p, xTok)); +aCode2.AddToken(*xTok); +} +else +{ +ScMatrixToken aTok(pMat); +aCode2.AddToken(aTok); +} } break; default: commit 2e5fbad1ce8c97f0c9201cdfb4eba49ef72da66f Author: Kohei Yoshida Date: Fri Jul 12 11:09:38 2013 -0400 Set an array of doubles in one step, rather than individually in loops. The latter is massively slow, apparently. Change-Id: I689643330e1b04eff7d9665de5d6e423906517e1 diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx index 5a23511..6573d15 100644 --- a/sc/source/core/tool/formulagroup.cxx +++ b/sc/source/core/tool/formulagroup.cxx @@ -73,14 +73,8 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres for (size_t nCol = 0; nCol < nColSize; ++nCol) { const double* pArray = rArrays[nCol]; -for (size_t nRow = 0; nRow < nRowSize; ++nRow) -{ -if (nRowStart + nRow < p2->GetArrayLength()) -{ -double fVal = pArray[nRowStart+nRow]; -pMat->PutDouble(fVal, nCol, nRow); -} -} +pArray += nRowStart; +pMat->PutDouble(pArray, nRowSize, nCol, 0); } ScMatrixToken aTok(pMat); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 2 commits - sc/source
sc/source/core/data/column.cxx | 18 ++ 1 file changed, 14 insertions(+), 4 deletions(-) New commits: commit b13723d30ab9b87bfe9b724ed80454434bba9908 Author: Kohei Yoshida Date: Tue Jul 9 23:43:37 2013 -0400 Check formula cell group boundaries to optionally merge. Just in case... Change-Id: If1feac9f144a8ab7d53823a0625560a499d57b68 diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 68795f4..ad51473 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -1373,9 +1373,22 @@ public: // Group the cloned formula cells. groupFormulaCells(aCloned); -maDestPos.miCellPos = mrDestCol.GetCellStore().set( +sc::CellStoreType& rDestCells = mrDestCol.GetCellStore(); +maDestPos.miCellPos = rDestCells.set( maDestPos.miCellPos, nTopRow, aCloned.begin(), aCloned.end()); +// Merge adjacent formula cell groups (if applicable). +sc::CellStoreType::position_type aPos = +rDestCells.position(maDestPos.miCellPos, nTopRow); +maDestPos.miCellPos = aPos.first; +mrDestCol.JoinFormulaCellAbove(aPos); +size_t nLastRow = nTopRow + nDataSize; +if (nLastRow < static_cast(MAXROW)) +{ +aPos = rDestCells.position(maDestPos.miCellPos, nLastRow+1); +mrDestCol.JoinFormulaCellAbove(aPos); +} + setDefaultAttrsToDest(nTopRow, nDataSize); } break; commit 61abe70995d5a4fa46345740b0fe41da04e394c8 Author: Kohei Yoshida Date: Tue Jul 9 23:27:37 2013 -0400 Formula cell grouping in CopyUpdated should already be done. Since it uses the same function object CopyToClipHandler which I added grouping support to earlier. Change-Id: I8964f95041b5170ca1c7fbe073f85fcf77367c9f diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index ae463b7..68795f4 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -1994,10 +1994,7 @@ void ScColumn::CopyUpdated( const ScColumn& rPosCol, ScColumn& rDestCol ) const sc::CellStoreType::const_iterator itPos = maCells.begin(); sc::SingleColumnSpanSet::SpansType::const_iterator it = aRanges.begin(), itEnd = aRanges.end(); for (; it != itEnd; ++it) -{ itPos = sc::ParseBlock(itPos, maCells, aFunc, it->mnRow1, it->mnRow2); -rDestCol.RegroupFormulaCells(it->mnRow1, it->mnRow2); -} rDestCol.CellStorageModified(); } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 2 commits - sc/source
sc/source/filter/oox/pagesettings.cxx | 65 -- 1 file changed, 31 insertions(+), 34 deletions(-) New commits: commit 7425efdfcc09e9d41d6f3ab026b6e96ebd94d3f1 Author: Kohei Yoshida Date: Wed May 8 14:31:54 2013 -0400 Set page style name to the sheet directly via ScDocument, not UNO API. This alone saves about 20 or more seconds during import of large xlsx document. Change-Id: I267236afbd0284f56d4fd079042a71936db0c3e3 diff --git a/sc/source/filter/oox/pagesettings.cxx b/sc/source/filter/oox/pagesettings.cxx index 2123056..00b5d5a 100644 --- a/sc/source/filter/oox/pagesettings.cxx +++ b/sc/source/filter/oox/pagesettings.cxx @@ -31,6 +31,7 @@ #include #include #include +#include #include "oox/core/xmlfilterbase.hxx" #include "oox/helper/attributelist.hxx" #include "oox/helper/graphichelper.hxx" @@ -40,7 +41,7 @@ #include "excelhandlers.hxx" #include "stylesbuffer.hxx" #include "unitconverter.hxx" -#include +#include "document.hxx" namespace oox { namespace xls { @@ -329,8 +330,9 @@ void PageSettings::finalizeImport() PropertySet aStyleProps( xStyle ); getPageSettingsConverter().writePageSettingsProperties( aStyleProps, maModel, getSheetType() ); -PropertySet aSheetProps( getSheet() ); -aSheetProps.setProperty( PROP_PageStyle, aStyleName ); +// Set page style name to the sheet. +SCTAB nTab = getSheetIndex(); +getScDocument().SetPageStyle(nTab, aStyleName); } void PageSettings::importPictureData( const Relations& rRelations, const OUString& rRelId ) commit 1ff4298cd2a79b0082b68ac855588e4d47834982 Author: Kohei Yoshida Date: Wed May 8 14:26:32 2013 -0400 Remove using namespace statements that may cause naming clashes. Change-Id: Ibf695f7ddaac8fa44e1d6d4ed69aea37743d1c9b diff --git a/sc/source/filter/oox/pagesettings.cxx b/sc/source/filter/oox/pagesettings.cxx index 5cf3172..2123056 100644 --- a/sc/source/filter/oox/pagesettings.cxx +++ b/sc/source/filter/oox/pagesettings.cxx @@ -48,12 +48,7 @@ namespace xls { // using namespace ::com::sun::star; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::container; using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::sheet; -using namespace ::com::sun::star::style; -using namespace ::com::sun::star::text; using namespace ::com::sun::star::uno; using ::oox::core::Relations; @@ -323,14 +318,14 @@ void PageSettings::setFitToPagesMode( bool bFitToPages ) void PageSettings::finalizeImport() { OUStringBuffer aStyleNameBuffer( "PageStyle_" ); -Reference< XNamed > xSheetName( getSheet(), UNO_QUERY ); +Reference xSheetName(getSheet(), UNO_QUERY); if( xSheetName.is() ) aStyleNameBuffer.append( xSheetName->getName() ); else aStyleNameBuffer.append( static_cast< sal_Int32 >( getSheetIndex() + 1 ) ); OUString aStyleName = aStyleNameBuffer.makeStringAndClear(); -Reference< XStyle > xStyle = createStyleObject( aStyleName, true ); +Reference xStyle = createStyleObject(aStyleName, true); PropertySet aStyleProps( xStyle ); getPageSettingsConverter().writePageSettingsProperties( aStyleProps, maModel, getSheetType() ); @@ -360,16 +355,16 @@ enum HFPortionId struct HFPortionInfo { -Reference< XText > mxText; /// XText interface of this portion. -Reference< XTextCursor > mxStart; /// Start position of current text range for formatting. -Reference< XTextCursor > mxEnd; /// End position of current text range for formatting. +Reference mxText; /// XText interface of this portion. +Reference mxStart; /// Start position of current text range for formatting. +Reference mxEnd; /// End position of current text range for formatting. double mfTotalHeight; /// Sum of heights of previous lines in points. double mfCurrHeight; /// Height of the current text line in points. -boolinitialize( const Reference< XText >& rxText ); +boolinitialize( const Reference& rxText ); }; -bool HFPortionInfo::initialize( const Reference< XText >& rxText ) +bool HFPortionInfo::initialize( const Reference& rxText ) { mfTotalHeight = mfCurrHeight = 0.0; mxText = rxText; @@ -393,16 +388,16 @@ public: /** Parses the passed string and creates the header/footer contents. @returns The total height of the converted header or footer in points. */ double parse( -const Reference< XHeaderFooterContent >& rxContext, +const Reference& rxContext, const OUString& rData ); private: /** Returns the current edit engine text object. */ inline HFPortionIn
[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 2 commits - sc/source
sc/source/ui/unoobj/cellsuno.cxx | 111 ++- 1 file changed, 53 insertions(+), 58 deletions(-) New commits: commit dd47fc6b2d3ed79868721826ad77d6ad415ca4ac Author: Kohei Yoshida Date: Wed Mar 27 17:38:51 2013 -0400 Remove a bit more use of ScEditCell and ScBaseCell. Change-Id: Ib01eaef7e3a612048d2ed3f714ed178f4076e689 diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index df8d3ce..e74f249 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -1394,18 +1394,18 @@ static OUString lcl_GetInputString( ScDocument* pDoc, const ScAddress& rPos, sal if (!pDoc) return EMPTY_OUSTRING; - -ScBaseCell* pCell = pDoc->GetCell(rPos); -if (!pCell || pCell->GetCellType() == CELLTYPE_NOTE) +ScRefCellValue aCell; +aCell.assign(*pDoc, rPos); +if (aCell.isEmpty()) return EMPTY_OUSTRING; OUString aVal; -CellType eType = pCell->GetCellType(); +CellType eType = aCell.meType; if (eType == CELLTYPE_FORMULA) { -ScFormulaCell* pForm = (ScFormulaCell*)pCell; -pForm->GetFormula( aVal,formula::FormulaGrammar::mapAPItoGrammar( bEnglish, false)); +ScFormulaCell* pForm = aCell.mpFormula; +pForm->GetFormula( aVal, formula::FormulaGrammar::mapAPItoGrammar( bEnglish, false)); return aVal; } @@ -1416,24 +1416,20 @@ static OUString lcl_GetInputString( ScDocument* pDoc, const ScAddress& rPos, sal // we don't have to query. sal_uInt32 nNumFmt = bEnglish ? 0 : pDoc->GetNumberFormat(rPos); -if ( eType == CELLTYPE_EDIT ) +if (eType == CELLTYPE_EDIT) { // GetString an der EditCell macht Leerzeichen aus Umbruechen, // hier werden die Umbrueche aber gebraucht -const EditTextObject* pData = ((ScEditCell*)pCell)->GetData(); +const EditTextObject* pData = aCell.mpEditText; if (pData) { EditEngine& rEngine = pDoc->GetEditEngine(); -rEngine.SetText( *pData ); -aVal = rEngine.GetText( LINEEND_LF ); +rEngine.SetText(*pData); +aVal = rEngine.GetText(LINEEND_LF); } } else -{ -ScRefCellValue aCell; -aCell.assign(*pCell); ScCellFormat::GetInputString(aCell, nNumFmt, aVal, *pFormatter); -} // ggf. ein ' davorhaengen wie in ScTabViewShell::UpdateInputHandler if ( eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT ) commit 9c72cc05735d3e2dc16c6ef4f8765cb34ce5bfbc Author: Kohei Yoshida Date: Wed Mar 27 17:34:02 2013 -0400 Reduce indentation by early bail-out. Change-Id: I5965a38fdd4e80e22136905881a39eb38ffb7798 diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 45e41da..df8d3ce 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -1389,69 +1389,68 @@ static sal_Bool lcl_PutFormulaArray( ScDocShell& rDocShell, const ScRange& rRang } // used in ScCellRangeObj::getFormulaArray and ScCellObj::GetInputString_Impl -static String lcl_GetInputString( ScDocument* pDoc, const ScAddress& rPosition, sal_Bool bEnglish ) +static OUString lcl_GetInputString( ScDocument* pDoc, const ScAddress& rPos, sal_Bool bEnglish ) { -rtl::OUString aVal; -if ( pDoc ) +if (!pDoc) +return EMPTY_OUSTRING; + + +ScBaseCell* pCell = pDoc->GetCell(rPos); +if (!pCell || pCell->GetCellType() == CELLTYPE_NOTE) +return EMPTY_OUSTRING; + +OUString aVal; + +CellType eType = pCell->GetCellType(); +if (eType == CELLTYPE_FORMULA) { -ScBaseCell* pCell = pDoc->GetCell( rPosition ); -if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE ) +ScFormulaCell* pForm = (ScFormulaCell*)pCell; +pForm->GetFormula( aVal,formula::FormulaGrammar::mapAPItoGrammar( bEnglish, false)); +return aVal; +} + +SvNumberFormatter* pFormatter = bEnglish ? ScGlobal::GetEnglishFormatter() : +pDoc->GetFormatTable(); +// Since the English formatter was constructed with +// LANGUAGE_ENGLISH_US the "General" format has index key 0, +// we don't have to query. +sal_uInt32 nNumFmt = bEnglish ? 0 : pDoc->GetNumberFormat(rPos); + +if ( eType == CELLTYPE_EDIT ) +{ +// GetString an der EditCell macht Leerzeichen aus Umbruechen, +// hier werden die Umbrueche aber gebraucht +const EditTextObject* pData = ((ScEditCell*)pCell)->GetData(); +if (pData) { -CellType eType = pCell->GetCellType(); -if ( eType == CELLTYPE_FORMULA ) -{ -ScFormulaCell* pForm = (ScFormulaCell*)pCell; -pForm->GetFormula( aVal,formula::FormulaGrammar::mapAPItoGrammar( bEnglish, false)); -} -else -{ -SvNumberFormatt
[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 2 commits - sc/source
sc/source/ui/docshell/docfunc.cxx |2 sc/source/ui/inc/undocell.hxx | 67 ++--- sc/source/ui/undo/undocell.cxx| 148 ++ 3 files changed, 146 insertions(+), 71 deletions(-) New commits: commit 34f8a35237f15098d4e1c0d1bb0f59a1c571dfdc Author: Kohei Yoshida Date: Thu Mar 21 17:25:37 2013 -0400 Add assign() and commit() methods to make it easier to use this class. Change-Id: Ia9c2fe3fea3dfeef0410e8c430d5953a66b0cba1 diff --git a/sc/source/ui/inc/undocell.hxx b/sc/source/ui/inc/undocell.hxx index 2f5e370..a9ff3f1 100644 --- a/sc/source/ui/inc/undocell.hxx +++ b/sc/source/ui/inc/undocell.hxx @@ -34,7 +34,11 @@ class SdrUndoAction; class ScDetOpList; class ScDetOpData; class ScRangeName; +class ScDocument; +/** + * Store arbitrary cell value of any kind for undo objects. + */ struct ScUndoCellValue { CellType meType; @@ -52,6 +56,18 @@ struct ScUndoCellValue ScUndoCellValue( const ScFormulaCell& rFormula ); ScUndoCellValue( const ScUndoCellValue& r ); ~ScUndoCellValue(); + +void clear(); + +/** + * Take cell value from specified position in specified document. + */ +void assign( const ScDocument& rDoc, const ScAddress& rPos ); + +/** + * Set cell value at specified position in specified document. + */ +void commit( ScDocument& rDoc, const ScAddress& rPos ); }; class ScUndoCursorAttr: public ScSimpleUndo @@ -94,6 +110,8 @@ private: class ScUndoEnterData: public ScSimpleUndo { public: +TYPEINFO(); + struct Value { SCTAB mnTab; @@ -106,7 +124,6 @@ public: typedef std::vector ValuesType; -TYPEINFO(); ScUndoEnterData( ScDocShell* pNewDocShell, const ScAddress& rPos, ValuesType& rOldValues, const OUString& rNewStr, EditTextObject* pObj = NULL ); diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx index 7715624..171a758 100644 --- a/sc/source/ui/undo/undocell.cxx +++ b/sc/source/ui/undo/undocell.cxx @@ -71,6 +71,11 @@ ScUndoCellValue::ScUndoCellValue( const ScUndoCellValue& r ) : meType(r.meType), ScUndoCellValue::~ScUndoCellValue() { +clear(); +} + +void ScUndoCellValue::clear() +{ switch (meType) { case CELLTYPE_STRING: @@ -85,6 +90,59 @@ ScUndoCellValue::~ScUndoCellValue() default: ; } + +// Reset to empty value. +meType = CELLTYPE_NONE; +mfValue = 0.0; +} + +void ScUndoCellValue::assign( const ScDocument& rDoc, const ScAddress& rPos ) +{ +clear(); + +meType = rDoc.GetCellType(rPos); +switch (meType) +{ +case CELLTYPE_STRING: +mpString = new OUString(rDoc.GetString(rPos)); +break; +case CELLTYPE_EDIT: +mpEditText = rDoc.GetEditText(rPos)->Clone(); +break; +case CELLTYPE_VALUE: +mfValue = rDoc.GetValue(rPos); +break; +case CELLTYPE_FORMULA: +mpFormula = rDoc.GetFormulaCell(rPos)->Clone(); +break; +default: +meType = CELLTYPE_NONE; // reset to empty. +} +} + +void ScUndoCellValue::commit( ScDocument& rDoc, const ScAddress& rPos ) +{ +switch (meType) +{ +case CELLTYPE_STRING: +{ +ScSetStringParam aParam; +aParam.setTextInput(); +rDoc.SetString(rPos, *mpString, &aParam); +} +break; +case CELLTYPE_EDIT: +rDoc.SetEditText(rPos, mpEditText->Clone()); +break; +case CELLTYPE_VALUE: +rDoc.SetValue(rPos, mfValue); +break; +case CELLTYPE_FORMULA: +rDoc.SetFormulaCell(rPos, mpFormula->Clone()); +break; +default: +rDoc.SetEmptyCell(rPos); +} } TYPEINIT1(ScUndoCursorAttr, ScSimpleUndo); commit 0cb01e5532cd824e56a1e5b3829677acd623936a Author: Kohei Yoshida Date: Thu Mar 21 17:11:39 2013 -0400 ScUndoSetCell::Value to ScUndoCellValue in global scope. I could use this in other undo classes. Change-Id: I721ab2b67810af21ddbbb711c268783b73904e48 diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index c1caa2e..d3061e1 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -809,7 +809,7 @@ sal_Bool ScDocFunc::SetNormalString( bool& o_rbNumFmtSet, const ScAddress& rPos, namespace { -void pushUndoSetCell( ScDocShell& rDocShell, ScDocument* pDoc, const ScAddress& rPos, const ScUndoSetCell::Value& rNewVal ) +void pushUndoSetCell( ScDocShell& rDocShell, ScDocument* pDoc, const ScAddress& rPos, const ScUndoCellValue& rNewVal ) { svl::IUndoManager* pUndoMgr = rDocShell.GetUndoManager(); switch (pDoc->GetCellType(rPos)) diff --git a/sc/source/ui/inc/undocell.hxx b/sc/source/ui/inc/undocell.hxx index 76d9032..2f5e370 100644 --- a/sc/source/ui/inc/undocell.hxx +++ b/sc/source/ui/inc/undoc
[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 2 commits - sc/source
sc/source/ui/undo/undocell.cxx |7 +++ 1 file changed, 7 insertions(+) New commits: commit c8620e606c8cf4f1b185f7c027dc313202118664 Author: Kohei Yoshida Date: Thu Mar 21 00:29:23 2013 -0400 I think I need to add these just like all the other undo classes do. Change-Id: Ia5dc41027c144b771a4071a35b7ed699ea00cfb0 diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx index 76fa36e..b7dfef5 100644 --- a/sc/source/ui/undo/undocell.cxx +++ b/sc/source/ui/undo/undocell.cxx @@ -550,12 +550,16 @@ ScUndoSetCell::~ScUndoSetCell() {} void ScUndoSetCell::Undo() { +BeginUndo(); SetValue(maOldValue); +EndUndo(); } void ScUndoSetCell::Redo() { +BeginRedo(); SetValue(maNewValue); +EndRedo(); } void ScUndoSetCell::Repeat( SfxRepeatTarget& /*rTarget*/ ) commit a5965179515479518e9586f2d68fae893b2e044f Author: Kohei Yoshida Date: Thu Mar 21 00:20:52 2013 -0400 Forgot to add break here... Change-Id: I4350c05bdf72c9b582da3b156dc398ea407efa24 diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx index 878a077..76fa36e 100644 --- a/sc/source/ui/undo/undocell.cxx +++ b/sc/source/ui/undo/undocell.cxx @@ -516,6 +516,7 @@ ScUndoSetCell::Value::Value( const Value& r ) : meType(r.meType), mfValue(r.mfVa break; case CELLTYPE_FORMULA: mpFormula = r.mpFormula->Clone(); +break; default: ; } @@ -530,8 +531,10 @@ ScUndoSetCell::Value::~Value() break; case CELLTYPE_EDIT: delete mpEditText; +break; case CELLTYPE_FORMULA: mpFormula->Delete(); +break; default: ; } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 2 commits - sc/source
sc/source/core/tool/stringutil.cxx |1 sc/source/ui/unoobj/cellsuno.cxx | 81 +++-- 2 files changed, 53 insertions(+), 29 deletions(-) New commits: commit d9570aef923b30f8bffad24efd39a50f9fe9 Author: Kohei Yoshida Date: Wed Mar 20 19:41:42 2013 -0400 Reduce indentation levels by early bail-out. Change-Id: Ief345d48750250150836097af2072fb030aa4505 diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 184c859..dde15a6 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -6342,66 +6342,65 @@ void ScCellObj::InputEnglishString( const ::rtl::OUString& rText ) // but all parsing is in English. ScDocShell* pDocSh = GetDocShell(); -if ( pDocSh ) +if (!pDocSh) +return; + +String aString(rText); +ScDocument* pDoc = pDocSh->GetDocument(); +SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); +sal_uInt32 nOldFormat = pDoc->GetNumberFormat( aCellPos ); +if (pFormatter->GetType(nOldFormat) == NUMBERFORMAT_TEXT) { -String aString(rText); -ScDocument* pDoc = pDocSh->GetDocument(); -SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); -sal_uInt32 nOldFormat = pDoc->GetNumberFormat( aCellPos ); -if ( pFormatter->GetType( nOldFormat ) == NUMBERFORMAT_TEXT ) -{ -SetString_Impl(aString, false, false); // text cell -} -else -{ -ScDocFunc &rFunc = pDocSh->GetDocFunc(); +SetString_Impl(aString, false, false); // text cell +return; +} + +ScDocFunc &rFunc = pDocSh->GetDocFunc(); -ScInputStringType aRes = -ScStringUtil::parseInputString(*pFormatter, aString, LANGUAGE_ENGLISH_US); +ScInputStringType aRes = +ScStringUtil::parseInputString(*pFormatter, aString, LANGUAGE_ENGLISH_US); -if (aRes.meType != ScInputStringType::Unknown) +if (aRes.meType != ScInputStringType::Unknown) +{ +if ((nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 && aRes.mnFormatType) +{ +// apply a format for the recognized type and the old format's language +sal_uInt32 nNewFormat = ScGlobal::GetStandardFormat(*pFormatter, nOldFormat, aRes.mnFormatType); +if (nNewFormat != nOldFormat) { -if ((nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 && aRes.mnFormatType) -{ -// apply a format for the recognized type and the old format's language -sal_uInt32 nNewFormat = ScGlobal::GetStandardFormat(*pFormatter, nOldFormat, aRes.mnFormatType); -if (nNewFormat != nOldFormat) -{ -ScPatternAttr aPattern( pDoc->GetPool() ); -aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) ); -// ATTR_LANGUAGE_FORMAT remains unchanged -rFunc.ApplyAttributes( *GetMarkData(), aPattern, true, true ); -} -} +ScPatternAttr aPattern( pDoc->GetPool() ); +aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) ); +// ATTR_LANGUAGE_FORMAT remains unchanged +rFunc.ApplyAttributes( *GetMarkData(), aPattern, true, true ); } -switch (aRes.meType) +} +} +switch (aRes.meType) +{ +case ScInputStringType::Formula: +rFunc.SetFormulaCell( +aCellPos, +new ScFormulaCell(pDoc, aCellPos, aRes.maText, formula::FormulaGrammar::GRAM_PODF_A1), +false); +break; +case ScInputStringType::Number: +rFunc.SetValueCell(aCellPos, aRes.mfValue, false); +break; +case ScInputStringType::Text: +{ +if (ScStringUtil::isMultiline(aRes.maText)) { -case ScInputStringType::Formula: -rFunc.SetFormulaCell( -aCellPos, -new ScFormulaCell(pDoc, aCellPos, aRes.maText, formula::FormulaGrammar::GRAM_PODF_A1), -false); -break; -case ScInputStringType::Number: -rFunc.SetValueCell(aCellPos, aRes.mfValue, false); -break; -case ScInputStringType::Text: -{ -if (ScStringUtil::isMultiline(aRes.maText)) -{ -ScFieldEditEngine& rEngine = pDoc->GetEditEngine(); -rEngine.SetText(aRes.maText); -boost::scoped_ptr pEditText(rEngine.CreateTextObject()); -rFunc.SetEditCell(aCellPos, *pEditText, false); -} -
[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 2 commits - sc/source
sc/source/ui/docshell/docfunc.cxx | 19 +-- sc/source/ui/inc/docfunc.hxx |6 +++--- 2 files changed, 12 insertions(+), 13 deletions(-) New commits: commit e3daeea29fe5d5d757ceeabff87ce370241b2848 Author: Kohei Yoshida Date: Wed Mar 20 18:07:17 2013 -0400 This shouldn't be virtual. Change-Id: Ic15f96a71b7c315ab94ceed808c348cd6fe535df diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx index dfb4ab0..9053b4b 100644 --- a/sc/source/ui/inc/docfunc.hxx +++ b/sc/source/ui/inc/docfunc.hxx @@ -107,9 +107,9 @@ public: const formula::FormulaGrammar::Grammar eGrammar ); // creates a new cell for use with PutCell -virtual ScBaseCell* InterpretEnglishString( const ScAddress& rPos, const String& rText, -const String& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar, -short* pRetFormatType = NULL ); +ScBaseCell* InterpretEnglishString( const ScAddress& rPos, const String& rText, +const String& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar, +short* pRetFormatType = NULL ); virtual boolShowNote( const ScAddress& rPos, bool bShow = true ); inline bool HideNote( const ScAddress& rPos ) { return ShowNote( rPos, false ); } commit 0ab1ac5f63e4e51a32e451dd02d2f937d44857cb Author: Kohei Yoshida Date: Wed Mar 20 17:47:41 2013 -0400 Reorganize SetCellText() to avoid PulCell() at the very end. Change-Id: Ib5244cbbb81a1dbc20fbf4a63679a862ede525ff diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index efec66a..bb59dd3 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -1219,7 +1219,7 @@ sal_Bool ScDocFunc::SetCellText( const ScAddress& rPos, const String& rText, // SetCellText ruft PutCell oder SetNormalString ScDocument* pDoc = rDocShell.GetDocument(); -ScBaseCell* pNewCell = NULL; + if ( bInterpret ) { if ( bEnglish ) @@ -1231,23 +1231,22 @@ sal_Bool ScDocFunc::SetCellText( const ScAddress& rPos, const String& rText, // code moved to own method InterpretEnglishString because it is also used in // ScCellRangeObj::setFormulaArray -pNewCell = InterpretEnglishString( rPos, rText, rFormulaNmsp, eGrammar ); +ScBaseCell* pNewCell = InterpretEnglishString( rPos, rText, rFormulaNmsp, eGrammar ); +if (pNewCell) +return PutCell( rPos, pNewCell, bApi ); } // sonst Null behalten -> SetString mit lokalen Formeln/Zahlformat } else if ( rText.Len() ) { OSL_ENSURE( rFormulaNmsp.Len() == 0, "ScDocFunc::SetCellText - formula namespace, but do not interpret?" ); -pNewCell = ScBaseCell::CreateTextCell( rText, pDoc ); // immer Text +ScBaseCell* pNewCell = ScBaseCell::CreateTextCell( rText, pDoc ); // immer Text +if (pNewCell) +return PutCell( rPos, pNewCell, bApi ); } -if (pNewCell) -return PutCell( rPos, pNewCell, bApi ); -else -{ -bool bNumFmtSet = false; -return SetNormalString( bNumFmtSet, rPos, rText, bApi ); -} +bool bNumFmtSet = false; +return SetNormalString( bNumFmtSet, rPos, rText, bApi ); } // ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 2 commits - sc/source
sc/source/core/data/column2.cxx | 26 +- sc/source/core/data/column3.cxx |9 + 2 files changed, 34 insertions(+), 1 deletion(-) New commits: commit c03d6f6e0a202e6a1d01f956e12f299b8fc29b5e Author: Kohei Yoshida Date: Fri Mar 15 10:57:42 2013 -0400 Better consistency checking. Change-Id: I096282ebb9a10d212affbab32aaa49ca1815b1a7 diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 19e5e9c..f96515a 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -1392,18 +1392,42 @@ SCROW ScColumn::FindNextVisibleRowWithContent(SCROW nRow, bool bForward) const void ScColumn::CellStorageModified() { #if DEBUG_COLUMN_STORAGE +if (maItems.empty()) +{ +if (maTextWidths.empty()) +{ +cout << "ScColumn::CellStorageModified: Text width array is empty, but shouldn't." << endl; +abort(); +} + +if (maTextWidths.block_size() != 1 || maTextWidths.begin()->type != mdds::mtv::element_type_empty) +{ +cout << "ScColumn::CellStorageModified: When the cell array is empty, the text with array should consist of one empty block." << endl; +abort(); +} + +return; +} + +cout << "-- begin" << endl; +std::vector::const_iterator it = maItems.begin(), itEnd = maItems.end(); +for (; it != itEnd; ++it) +cout << "ScColumn::CellStorageModified: entry: row = " << it->nRow << "; cell = " << it->pCell << endl; + ScColumnTextWidthIterator aIter(*this, 0, MAXROW); for (; aIter.hasCell(); aIter.next()) { SCROW nRow = aIter.getPos(); ScBaseCell* pCell = GetCell(nRow); +cout << "ScColumn::CellStorageModified: row = " << nRow << "; cell = " << pCell << endl; if (!pCell) { -cout << "Cell and text width storages are out of sync!" << endl; +cout << "ScColumn::CellStorageModified: Cell and text width storages are out of sync!" << endl; cout.flush(); abort(); } } +cout << "-- end" << endl; #endif } commit 819384d0e2a3152492c8b4e5ed7bd1a3d77254d1 Author: Kohei Yoshida Date: Fri Mar 15 10:55:40 2013 -0400 Fix the text width array going out of sync when shifting row positions. Change-Id: I7b9c5554e38a25dd4ff6980e6ae0d1eff241a746 diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 6116780..62f0135 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -200,7 +200,9 @@ void ScColumn::FreeAll() maItems[i].pCell->Delete(); maItems.clear(); +// Text width should keep a logical empty range of 0-MAXROW when the cell array is empty. maTextWidths.clear(); +maTextWidths.resize(MAXROW); CellStorageModified(); } @@ -257,6 +259,12 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize ) else i = nFirstIndex; +// There are cells below the deletion point. Shift their row positions. + +// Shift the text width array too (before the broadcast). +maTextWidths.erase(nStartRow, nSize); +maTextWidths.resize(MAXROW); + ScAddress aAdr( nCol, 0, nTab ); ScHint aHint( SC_HINT_DATACHANGED, aAdr, NULL ); // only areas (ScBaseCell* == NULL) ScAddress& rAddress = aHint.GetAddress(); @@ -300,6 +308,7 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize ) pDocument->AreaBroadcastInRange( aRange, aHint ); } +CellStorageModified(); pDocument->SetAutoCalc( bOldAutoCalc ); } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 2 commits - sc/source
sc/source/core/data/documen8.cxx | 205 +++ 1 file changed, 100 insertions(+), 105 deletions(-) New commits: commit 763d8dad024d8b4307fb21e81b87d46f78346f06 Author: Kohei Yoshida Date: Wed Mar 13 15:48:08 2013 -0400 Reduce scope level. Change-Id: I28db9130864ac3408398834bfbbdeb904ca4948e diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx index 9ac10a7..6b50d12 100644 --- a/sc/source/core/data/documen8.cxx +++ b/sc/source/core/data/documen8.cxx @@ -549,131 +549,133 @@ bool ScDocument::IdleCalcTextWidth()// true = demnaechst wieder vers ScStyleSheet* pStyle = (ScStyleSheet*)aScope.getStylePool()->Find(pTable->aPageStyle, SFX_STYLE_FAMILY_PAGE); OSL_ENSURE( pStyle, "Missing StyleSheet :-/" ); -if (pStyle && 0 == getScaleValue(*pStyle, ATTR_PAGE_SCALETOPAGES)) +if (!pStyle || getScaleValue(*pStyle, ATTR_PAGE_SCALETOPAGES) == 0) { -sal_uInt16 nRestart = 0; -sal_uInt16 nCount = 0; -ScBaseCell* pCell = NULL; +// Move to the next sheet as the current one has scale-to-pages set, +// and bail out. +aScope.incTab(); +return false; +} -sal_uInt16 nZoom = getScaleValue(*pStyle, ATTR_PAGE_SCALE); -Fraction aZoomFract( nZoom, 100 ); +sal_uInt16 nZoom = getScaleValue(*pStyle, ATTR_PAGE_SCALE); +Fraction aZoomFract(nZoom, 100); -// Start at specified cell position (nCol, nRow, nTab). -ScColumn* pColumn = &pTable->aCol[aScope.Col()]; -boost::scoped_ptr pColIter( -new ScColumnIterator(pColumn, aScope.Row(), MAXROW)); +// Start at specified cell position (nCol, nRow, nTab). +ScColumn* pColumn = &pTable->aCol[aScope.Col()]; +boost::scoped_ptr pColIter( +new ScColumnIterator(pColumn, aScope.Row(), MAXROW)); -OutputDevice* pDev = NULL; -while ( (nZoom > 0) && (nCount < CALCMAX) && (nRestart < 2) ) +OutputDevice* pDev = NULL; +sal_uInt16 nRestart = 0; +sal_uInt16 nCount = 0; +while ( (nZoom > 0) && (nCount < CALCMAX) && (nRestart < 2) ) +{ +SCROW nRow; +ScBaseCell* pCell = NULL; +if ( pColIter->Next(nRow, pCell) ) { -SCROW nRow; -if ( pColIter->Next(nRow, pCell) ) -{ -// More cell in this column. -aScope.setRow(nRow); +// More cell in this column. +aScope.setRow(nRow); -if ( TEXTWIDTH_DIRTY == pCell->GetTextWidth() ) +if ( TEXTWIDTH_DIRTY == pCell->GetTextWidth() ) +{ +// Calculate text width for this cell. +double nPPTX = 0.0; +double nPPTY = 0.0; +if ( !pDev ) { -// Calculate text width for this cell. -double nPPTX = 0.0; -double nPPTY = 0.0; -if ( !pDev ) -{ -pDev = GetPrinter(); -aScope.setOldMapMode(pDev->GetMapMode()); -pDev->SetMapMode( MAP_PIXEL ); // wichtig fuer GetNeededSize +pDev = GetPrinter(); +aScope.setOldMapMode(pDev->GetMapMode()); +pDev->SetMapMode( MAP_PIXEL ); // wichtig fuer GetNeededSize -Point aPix1000 = pDev->LogicToPixel( Point(1000,1000), MAP_TWIP ); -nPPTX = aPix1000.X() / 1000.0; -nPPTY = aPix1000.Y() / 1000.0; -} +Point aPix1000 = pDev->LogicToPixel( Point(1000,1000), MAP_TWIP ); +nPPTX = aPix1000.X() / 1000.0; +nPPTY = aPix1000.Y() / 1000.0; +} -if (!aScope.hasProgressBar() && pCell->GetCellType() == CELLTYPE_FORMULA -&& ((ScFormulaCell*)pCell)->GetDirty()) -{ -aScope.createProgressBar(); -} +if (!aScope.hasProgressBar() && pCell->GetCellType() == CELLTYPE_FORMULA +&& ((ScFormulaCell*)pCell)->GetDirty()) +{ +aScope.createProgressBar(); +} -sal_uInt16 nNewWidth = (sal_uInt16)GetNeededSize( -aScope.Col(), aScope.Row(), aScope.Tab(), -pDev, nPPTX, nPPTY, aZoomFract,aZoomFract, true, true); // bTotalSize +sal_uInt16 nNewWidth = (sal_uInt16)GetNeededSize( +aScope.Col(), aScope.Row(), aScope.Tab(), +pDev, nPPTX, nPPTY, aZoomFract,aZoomFract, true, true); // bTotalSize -pCell->SetTextWidth( nNewWidth ); -aScope.setNeedMore(true); -} +pCell->SetTextWidth( nNewW