officecfg/registry/schema/org/openoffice/Office/Calc.xcs | 10 + sc/inc/document.hxx | 5 sc/inc/inputopt.hxx | 3 sc/inc/sc.hrc | 1 sc/inc/sortparam.hxx | 1 sc/inc/table.hxx | 8 - sc/qa/unit/ucalc.cxx | 49 +++++- sc/source/core/data/documen3.cxx | 5 sc/source/core/data/table3.cxx | 115 ++++++++------- sc/source/core/tool/inputopt.cxx | 34 ++-- sc/source/ui/app/scmod.cxx | 9 + sc/source/ui/docshell/dbdocfun.cxx | 5 sc/source/ui/inc/tpview.hxx | 1 sc/source/ui/optdlg/tpview.cxx | 11 + sc/source/ui/undo/undosort.cxx | 2 sc/uiconfig/scalc/ui/scgeneralpage.ui | 92 +++++++----- 16 files changed, 246 insertions(+), 105 deletions(-)
New commits: commit 34580851065fc04af25e9c83a1106d1478f159e0 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Wed Sep 3 20:37:29 2014 +0200 fdo#81633: Write test for this. Change-Id: Ifb9c6229573584edc03c504cb94bb4e49a2309d4 diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index cd14262..fd11810 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -5519,6 +5519,43 @@ void Test::testSortRefUpdate() if (!checkFormula(*m_pDoc, ScAddress(2,1,0), "R[2]C[-2]")) CPPUNIT_FAIL("Wrong formula in C2!"); + // Undo again. + pUndoMgr->Undo(); + + // Formulas in column C should all be "RC[-2]" again. + for (size_t i = 0; i < nCount; ++i) + m_pDoc->SetString(ScAddress(2,1+i,0), "=RC[-2]"); + + // Turn off reference update on sort. + ScInputOptions aInputOption = SC_MOD()->GetInputOptions(); + aInputOption.SetSortRefUpdate(false); + + bSorted = aFunc.Sort(0, aSortData, true, true, true); + CPPUNIT_ASSERT(bSorted); + + // Check the sort result again. + CPPUNIT_ASSERT_EQUAL(OUString("Header"), m_pDoc->GetString(ScAddress(0,0,0))); + for (size_t i = 0; i < nCount; ++i) + { + double fCheck = aSorted[i]; + CPPUNIT_ASSERT_EQUAL(fCheck, m_pDoc->GetValue(ScAddress(0,i+1,0))); + } + + // Formulas in column C should all remain "RC[-2]". + for (size_t i = 0; i < nCount; ++i) + m_pDoc->SetString(ScAddress(2,1+i,0), "=RC[-2]"); + + // The values in column C should now be the same as sorted values in column A. + m_pDoc->CalcAll(); // just in case... + for (size_t i = 0; i < nCount; ++i) + { + double fCheck = aSorted[i]; + CPPUNIT_ASSERT_EQUAL(fCheck, m_pDoc->GetValue(ScAddress(2,i+1,0))); // column C + } + + // Turn it back on. + aInputOption.SetSortRefUpdate(true); + m_pDoc->DeleteTab(0); } commit 8c18ffbf9bb250fd49c5fc7ae89cc74155c768c6 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Tue Sep 2 17:51:58 2014 +0200 fdo#81633: Add a new configuration option to toggle ref update on sort. The new option is in Calc -> General and is labeled "Update references when sorting range of cells" Change-Id: I5ac686e96742df40f7d8ba5ffec23806db2988a6 diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs index d2b9692..85fb9f9 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs @@ -678,6 +678,16 @@ </info> <value>false</value> </prop> + <prop oor:name="UpdateReferenceOnSort" oor:type="xs:boolean" oor:nillable="false"> + <!-- OldPath: Calc/Input --> + <!-- OldLocation: Soffice.cfg --> + <!-- UIHints: Tools - Options -Spreadsheets - Input - [Section] Input --> + <info> + <desc>Specifies whether references get updated when performing sort on a range of cells.</desc> + <label>Update references when sorting range of cells</label> + </info> + <value>true</value> + </prop> <prop oor:name="HighlightSelection" oor:type="xs:boolean" oor:nillable="false"> <!-- OldPath: Calc/Input --> <!-- OldLocation: Soffice.cfg --> diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index fb03521..ad99322 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -1676,7 +1676,10 @@ public: SC_DLLPUBLIC SvNumberFormatter* GetFormatTable() const; SC_DLLPUBLIC SvNumberFormatter* CreateFormatTable() const; - void Sort( SCTAB nTab, const ScSortParam& rSortParam, bool bKeepQuery, ScProgress* pProgress, sc::ReorderParam* pUndo ); + void Sort( + SCTAB nTab, const ScSortParam& rSortParam, bool bKeepQuery, bool bUpdateRefs, + ScProgress* pProgress, sc::ReorderParam* pUndo ); + void Reorder( const sc::ReorderParam& rParam, ScProgress* pProgress ); SCSIZE Query( SCTAB nTab, const ScQueryParam& rQueryParam, bool bKeepSub ); diff --git a/sc/inc/inputopt.hxx b/sc/inc/inputopt.hxx index bc25992..37bfbc4 100644 --- a/sc/inc/inputopt.hxx +++ b/sc/inc/inputopt.hxx @@ -31,6 +31,7 @@ private: bool bExtendFormat; bool bRangeFinder; bool bExpandRefs; + bool mbSortRefUpdate; bool bMarkHeader; bool bUseTabCol; bool bTextWysiwyg; @@ -56,6 +57,8 @@ public: bool GetRangeFinder() const { return bRangeFinder; } void SetExpandRefs(bool bSet) { bExpandRefs = bSet; } bool GetExpandRefs() const { return bExpandRefs; } + void SetSortRefUpdate(bool bSet) { mbSortRefUpdate = bSet; } + bool GetSortRefUpdate() const { return mbSortRefUpdate; } void SetMarkHeader(bool bSet) { bMarkHeader = bSet; } bool GetMarkHeader() const { return bMarkHeader; } void SetUseTabCol(bool bSet) { bUseTabCol = bSet; } diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc index 228cda8..db71dbe 100644 --- a/sc/inc/sc.hrc +++ b/sc/inc/sc.hrc @@ -86,6 +86,7 @@ // TabPage entry - Legacy selection #define SID_SC_INPUT_LEGACY_CELL_SELECTION (SC_VIEW_START + 15) +#define SID_SC_OPT_SORT_REF_UPDATE (SC_VIEW_START + 16) // Format options #define SID_SCFORMULAOPTIONS (SC_VIEW_START + 20) diff --git a/sc/inc/sortparam.hxx b/sc/inc/sortparam.hxx index ab26d10..4d80a07 100644 --- a/sc/inc/sortparam.hxx +++ b/sc/inc/sortparam.hxx @@ -96,6 +96,7 @@ struct SC_DLLPUBLIC ReorderParam bool mbByRow; bool mbPattern; bool mbHiddenFiltered; + bool mbUpdateRefs; /** * Reorder the position indices such that it can be used to undo the diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 9806a47..6e581ed 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -826,7 +826,9 @@ public: void ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 ); void Sort( - const ScSortParam& rSortParam, bool bKeepQuery, ScProgress* pProgress, sc::ReorderParam* pUndo ); + const ScSortParam& rSortParam, bool bKeepQuery, bool bUpdateRefs, + ScProgress* pProgress, sc::ReorderParam* pUndo ); + void Reorder( const sc::ReorderParam& rParam, ScProgress* pProgress ); bool ValidQuery( @@ -1023,7 +1025,9 @@ private: short Compare(SCCOLROW nIndex1, SCCOLROW nIndex2) const; short Compare( ScSortInfoArray*, SCCOLROW nIndex1, SCCOLROW nIndex2) const; ScSortInfoArray* CreateSortInfoArray( const sc::ReorderParam& rParam ); - ScSortInfoArray* CreateSortInfoArray( const ScSortParam& rSortParam, SCCOLROW nInd1, SCCOLROW nInd2, bool bKeepQuery ); + ScSortInfoArray* CreateSortInfoArray( + const ScSortParam& rSortParam, SCCOLROW nInd1, SCCOLROW nInd2, + bool bKeepQuery, bool bUpdateRefs ); void QuickSort( ScSortInfoArray*, SCsCOLROW nLo, SCsCOLROW nHi); void SortReorderByColumn( ScSortInfoArray* pArray, SCROW nRow1, SCROW nRow2, bool bPattern, ScProgress* pProgress ); void SortReorderByRow( ScSortInfoArray* pArray, SCCOL nCol1, SCCOL nCol2, ScProgress* pProgress ); diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 1ec809e..cd14262 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -4868,7 +4868,7 @@ void Test::testSortWithFormulaRefs() aSortData.maKeyState[0].bDoSort = true; aSortData.maKeyState[0].nField = 0; - m_pDoc->Sort(0, aSortData, false, NULL, NULL); + m_pDoc->Sort(0, aSortData, false, true, NULL, NULL); for (size_t i = 0; i < SAL_N_ELEMENTS(aResults); ++i) { @@ -4903,7 +4903,7 @@ void Test::testSortWithStrings() aParam.maKeyState[0].bAscending = true; aParam.maKeyState[0].nField = 1; - m_pDoc->Sort(0, aParam, false, NULL, NULL); + m_pDoc->Sort(0, aParam, false, true, NULL, NULL); CPPUNIT_ASSERT_EQUAL(OUString("Header"), m_pDoc->GetString(ScAddress(1,1,0))); CPPUNIT_ASSERT_EQUAL(OUString("Val1"), m_pDoc->GetString(ScAddress(1,2,0))); @@ -4911,7 +4911,7 @@ void Test::testSortWithStrings() aParam.maKeyState[0].bAscending = false; - m_pDoc->Sort(0, aParam, false, NULL, NULL); + m_pDoc->Sort(0, aParam, false, true, NULL, NULL); CPPUNIT_ASSERT_EQUAL(OUString("Header"), m_pDoc->GetString(ScAddress(1,1,0))); CPPUNIT_ASSERT_EQUAL(OUString("Val2"), m_pDoc->GetString(ScAddress(1,2,0))); @@ -4954,7 +4954,7 @@ void Test::testSort() aSortData.maKeyState[0].nField = 1; aSortData.maKeyState[0].bAscending = true; - m_pDoc->Sort(0, aSortData, false, NULL, NULL); + m_pDoc->Sort(0, aSortData, false, true, NULL, NULL); double nVal = m_pDoc->GetValue(1,0,0); ASSERT_DOUBLES_EQUAL(nVal, 1.0); @@ -4987,7 +4987,7 @@ void Test::testSort() aSortData.nRow2 = aDataRange.aEnd.Row(); aSortData.bHasHeader = true; aSortData.maKeyState[0].nField = 0; - m_pDoc->Sort(0, aSortData, false, NULL, NULL); + m_pDoc->Sort(0, aSortData, false, true, NULL, NULL); // Title should stay at the top, numbers should be sorted numerically, // numbers always come before strings, and empty cells always occur at the @@ -5208,7 +5208,7 @@ void Test::testSortInFormulaGroup() aSortData.maKeyState[0].nField = 0; aSortData.maKeyState[0].bAscending = true; - m_pDoc->Sort(0, aSortData, false, NULL, NULL); + m_pDoc->Sort(0, aSortData, false, true, NULL, NULL); static struct { SCCOL nCol; diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index 61ac5f8..1838d13 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -1341,13 +1341,14 @@ bool ScDocument::UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, b } void ScDocument::Sort( - SCTAB nTab, const ScSortParam& rSortParam, bool bKeepQuery, ScProgress* pProgress, sc::ReorderParam* pUndo ) + SCTAB nTab, const ScSortParam& rSortParam, bool bKeepQuery, bool bUpdateRefs, + ScProgress* pProgress, sc::ReorderParam* pUndo ) { if ( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] ) { bool bOldEnableIdle = IsIdleEnabled(); EnableIdle(false); - maTabs[nTab]->Sort(rSortParam, bKeepQuery, pProgress, pUndo); + maTabs[nTab]->Sort(rSortParam, bKeepQuery, bUpdateRefs, pProgress, pUndo); EnableIdle(bOldEnableIdle); } } diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index 3fe5f7e..2bfa71e 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -261,6 +261,7 @@ private: std::vector<SCCOLROW> maOrderIndices; bool mbKeepQuery; + bool mbUpdateRefs; public: ScSortInfoArray( sal_uInt16 nSorts, SCCOLROW nInd1, SCCOLROW nInd2 ) : @@ -308,6 +309,10 @@ public: bool IsKeepQuery() const { return mbKeepQuery; } + void SetUpdateRefs( bool b ) { mbUpdateRefs = b; } + + bool IsUpdateRefs() const { return mbUpdateRefs; } + /** * Call this only during normal sorting, not from reordering. */ @@ -470,6 +475,7 @@ ScSortInfoArray* ScTable::CreateSortInfoArray( const sc::ReorderParam& rParam ) pArray = new ScSortInfoArray(0, nRow1, nRow2); pArray->SetKeepQuery(rParam.mbHiddenFiltered); + pArray->SetUpdateRefs(rParam.mbUpdateRefs); initDataRows( *pArray, *this, aCol, nCol1, nRow1, nCol2, nRow2, @@ -482,19 +488,22 @@ ScSortInfoArray* ScTable::CreateSortInfoArray( const sc::ReorderParam& rParam ) pArray = new ScSortInfoArray(0, nCol1, nCol2); pArray->SetKeepQuery(rParam.mbHiddenFiltered); + pArray->SetUpdateRefs(rParam.mbUpdateRefs); } return pArray; } ScSortInfoArray* ScTable::CreateSortInfoArray( - const ScSortParam& rSortParam, SCCOLROW nInd1, SCCOLROW nInd2, bool bKeepQuery ) + const ScSortParam& rSortParam, SCCOLROW nInd1, SCCOLROW nInd2, + bool bKeepQuery, bool bUpdateRefs ) { sal_uInt16 nUsedSorts = 1; while ( nUsedSorts < rSortParam.GetSortKeyCount() && rSortParam.maKeyState[nUsedSorts].bDoSort ) nUsedSorts++; ScSortInfoArray* pArray = new ScSortInfoArray( nUsedSorts, nInd1, nInd2 ); pArray->SetKeepQuery(bKeepQuery); + pArray->SetUpdateRefs(bUpdateRefs); if ( rSortParam.bByRow ) { @@ -734,16 +743,19 @@ void ScTable::SortReorderByColumn( } } - for (SCCOL nCol = nStart; nCol <= nLast; ++nCol) - aCol[nCol].CollectListeners(aListeners, nRow1, nRow2); + if (pArray->IsUpdateRefs()) + { + for (SCCOL nCol = nStart; nCol <= nLast; ++nCol) + aCol[nCol].CollectListeners(aListeners, nRow1, nRow2); - // Remove any duplicate listener entries and notify all listeners - // afterward. We must ensure that we notify each unique listener only - // once. - std::sort(aListeners.begin(), aListeners.end()); - aListeners.erase(std::unique(aListeners.begin(), aListeners.end()), aListeners.end()); - ColReorderNotifier aFunc(aColMap, nTab, nRow1, nRow2); - std::for_each(aListeners.begin(), aListeners.end(), aFunc); + // Remove any duplicate listener entries and notify all listeners + // afterward. We must ensure that we notify each unique listener only + // once. + std::sort(aListeners.begin(), aListeners.end()); + aListeners.erase(std::unique(aListeners.begin(), aListeners.end()), aListeners.end()); + ColReorderNotifier aFunc(aColMap, nTab, nRow1, nRow2); + std::for_each(aListeners.begin(), aListeners.end(), aFunc); + } // Re-start area listeners on the reordered columns. { @@ -997,39 +1009,51 @@ void ScTable::SortReorderByRow( } } - // Collect listeners of cell broadcasters. - for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol) - aCol[nCol].CollectListeners(aListeners, nRow1, nRow2); + if (pArray->IsUpdateRefs()) + { + // Collect listeners of cell broadcasters. + for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol) + aCol[nCol].CollectListeners(aListeners, nRow1, nRow2); - // Remove any duplicate listener entries. We must ensure that we notify - // each unique listener only once. - std::sort(aListeners.begin(), aListeners.end()); - aListeners.erase(std::unique(aListeners.begin(), aListeners.end()), aListeners.end()); + // Remove any duplicate listener entries. We must ensure that we notify + // each unique listener only once. + std::sort(aListeners.begin(), aListeners.end()); + aListeners.erase(std::unique(aListeners.begin(), aListeners.end()), aListeners.end()); - // Collect positions of all shared formula cells outside the sorted range, - // and make them unshared before notifying them. - sc::RefQueryFormulaGroup aFormulaGroupPos; - aFormulaGroupPos.setSkipRange(ScRange(nCol1, nRow1, nTab, nCol2, nRow2, nTab)); + // Collect positions of all shared formula cells outside the sorted range, + // and make them unshared before notifying them. + sc::RefQueryFormulaGroup aFormulaGroupPos; + aFormulaGroupPos.setSkipRange(ScRange(nCol1, nRow1, nTab, nCol2, nRow2, nTab)); - std::for_each(aListeners.begin(), aListeners.end(), FormulaGroupPosCollector(aFormulaGroupPos)); - const sc::RefQueryFormulaGroup::TabsType& rGroupTabs = aFormulaGroupPos.getAllPositions(); - sc::RefQueryFormulaGroup::TabsType::const_iterator itGroupTab = rGroupTabs.begin(), itGroupTabEnd = rGroupTabs.end(); - for (; itGroupTab != itGroupTabEnd; ++itGroupTab) - { - const sc::RefQueryFormulaGroup::ColsType& rCols = itGroupTab->second; - sc::RefQueryFormulaGroup::ColsType::const_iterator itCol = rCols.begin(), itColEnd = rCols.end(); - for (; itCol != itColEnd; ++itCol) + std::for_each(aListeners.begin(), aListeners.end(), FormulaGroupPosCollector(aFormulaGroupPos)); + const sc::RefQueryFormulaGroup::TabsType& rGroupTabs = aFormulaGroupPos.getAllPositions(); + sc::RefQueryFormulaGroup::TabsType::const_iterator itGroupTab = rGroupTabs.begin(), itGroupTabEnd = rGroupTabs.end(); + for (; itGroupTab != itGroupTabEnd; ++itGroupTab) + { + const sc::RefQueryFormulaGroup::ColsType& rCols = itGroupTab->second; + sc::RefQueryFormulaGroup::ColsType::const_iterator itCol = rCols.begin(), itColEnd = rCols.end(); + for (; itCol != itColEnd; ++itCol) + { + const sc::RefQueryFormulaGroup::ColType& rCol = itCol->second; + std::vector<SCROW> aBounds(rCol); + pDocument->UnshareFormulaCells(itGroupTab->first, itCol->first, aBounds); + } + } + + // Notify the listeners. + RowReorderNotifier aFunc(aRowMap, nTab, nCol1, nCol2); + std::for_each(aListeners.begin(), aListeners.end(), aFunc); + + // Re-group formulas in affected columns. + for (itGroupTab = rGroupTabs.begin(); itGroupTab != itGroupTabEnd; ++itGroupTab) { - const sc::RefQueryFormulaGroup::ColType& rCol = itCol->second; - std::vector<SCROW> aBounds(rCol); - pDocument->UnshareFormulaCells(itGroupTab->first, itCol->first, aBounds); + const sc::RefQueryFormulaGroup::ColsType& rCols = itGroupTab->second; + sc::RefQueryFormulaGroup::ColsType::const_iterator itCol = rCols.begin(), itColEnd = rCols.end(); + for (; itCol != itColEnd; ++itCol) + pDocument->RegroupFormulaCells(itGroupTab->first, itCol->first); } } - // Notify the listeners. - RowReorderNotifier aFunc(aRowMap, nTab, nCol1, nCol2); - std::for_each(aListeners.begin(), aListeners.end(), aFunc); - // Re-start area listeners on the reordered rows. { std::vector<sc::AreaListener>::iterator it = aAreaListeners.begin(), itEnd = aAreaListeners.end(); @@ -1046,15 +1070,6 @@ void ScTable::SortReorderByRow( } } - // Re-group formulas in affected columns. - for (itGroupTab = rGroupTabs.begin(); itGroupTab != itGroupTabEnd; ++itGroupTab) - { - const sc::RefQueryFormulaGroup::ColsType& rCols = itGroupTab->second; - sc::RefQueryFormulaGroup::ColsType::const_iterator itCol = rCols.begin(), itColEnd = rCols.end(); - for (; itCol != itColEnd; ++itCol) - pDocument->RegroupFormulaCells(itGroupTab->first, itCol->first); - } - // Re-group columns in the sorted range too. for (SCCOL i = nCol1; i <= nCol2; ++i) aCol[i].RegroupFormulaCells(); @@ -1277,7 +1292,8 @@ void ScTable::DecoladeRow( ScSortInfoArray* pArray, SCROW nRow1, SCROW nRow2 ) } void ScTable::Sort( - const ScSortParam& rSortParam, bool bKeepQuery, ScProgress* pProgress, sc::ReorderParam* pUndo ) + const ScSortParam& rSortParam, bool bKeepQuery, bool bUpdateRefs, + ScProgress* pProgress, sc::ReorderParam* pUndo ) { aSortParam = rSortParam; InitSortCollator( rSortParam ); @@ -1289,6 +1305,7 @@ void ScTable::Sort( pUndo->mbByRow = rSortParam.bByRow; pUndo->mbPattern = rSortParam.bIncludePattern; pUndo->mbHiddenFiltered = bKeepQuery; + pUndo->mbUpdateRefs = bUpdateRefs; } if (rSortParam.bByRow) @@ -1304,7 +1321,7 @@ void ScTable::Sort( if(pProgress) pProgress->SetState( 0, nLastRow-nRow1 ); - boost::scoped_ptr<ScSortInfoArray> pArray(CreateSortInfoArray(aSortParam, nRow1, nLastRow, bKeepQuery)); + boost::scoped_ptr<ScSortInfoArray> pArray(CreateSortInfoArray(aSortParam, nRow1, nLastRow, bKeepQuery, bUpdateRefs)); if ( nLastRow - nRow1 > 255 ) DecoladeRow(pArray.get(), nRow1, nLastRow); @@ -1333,7 +1350,7 @@ void ScTable::Sort( if(pProgress) pProgress->SetState( 0, nLastCol-nCol1 ); - boost::scoped_ptr<ScSortInfoArray> pArray(CreateSortInfoArray(aSortParam, nCol1, nLastCol, bKeepQuery)); + boost::scoped_ptr<ScSortInfoArray> pArray(CreateSortInfoArray(aSortParam, nCol1, nLastCol, bKeepQuery, bUpdateRefs)); QuickSort(pArray.get(), nCol1, nLastCol); SortReorderByColumn(pArray.get(), aSortParam.nRow1, aSortParam.nRow2, aSortParam.bIncludePattern, pProgress); @@ -2364,7 +2381,7 @@ void ScTable::TopTenQuery( ScQueryParam& rParam ) bSortCollatorInitialized = true; InitSortCollator( aLocalSortParam ); } - boost::scoped_ptr<ScSortInfoArray> pArray(CreateSortInfoArray(aSortParam, nRow1, rParam.nRow2, bGlobalKeepQuery)); + boost::scoped_ptr<ScSortInfoArray> pArray(CreateSortInfoArray(aSortParam, nRow1, rParam.nRow2, bGlobalKeepQuery, false)); DecoladeRow( pArray.get(), nRow1, rParam.nRow2 ); QuickSort( pArray.get(), nRow1, rParam.nRow2 ); ScSortInfo** ppInfo = pArray->GetFirstArray(); diff --git a/sc/source/core/tool/inputopt.cxx b/sc/source/core/tool/inputopt.cxx index ccedff6..27c9fb8 100644 --- a/sc/source/core/tool/inputopt.cxx +++ b/sc/source/core/tool/inputopt.cxx @@ -55,6 +55,7 @@ void ScInputOptions::SetDefaults() bExtendFormat = false; bRangeFinder = true; bExpandRefs = false; + mbSortRefUpdate = true; bMarkHeader = true; bUseTabCol = false; bTextWysiwyg = false; @@ -70,6 +71,7 @@ const ScInputOptions& ScInputOptions::operator=( const ScInputOptions& rCpy ) bExtendFormat = rCpy.bExtendFormat; bRangeFinder = rCpy.bRangeFinder; bExpandRefs = rCpy.bExpandRefs; + mbSortRefUpdate = rCpy.mbSortRefUpdate; bMarkHeader = rCpy.bMarkHeader; bUseTabCol = rCpy.bUseTabCol; bTextWysiwyg = rCpy.bTextWysiwyg; @@ -83,18 +85,19 @@ const ScInputOptions& ScInputOptions::operator=( const ScInputOptions& rCpy ) #define CFGPATH_INPUT "Office.Calc/Input" -#define SCINPUTOPT_MOVEDIR 0 -#define SCINPUTOPT_MOVESEL 1 -#define SCINPUTOPT_EDTEREDIT 2 -#define SCINPUTOPT_EXTENDFMT 3 -#define SCINPUTOPT_RANGEFIND 4 -#define SCINPUTOPT_EXPANDREFS 5 -#define SCINPUTOPT_MARKHEADER 6 -#define SCINPUTOPT_USETABCOL 7 -#define SCINPUTOPT_TEXTWYSIWYG 8 -#define SCINPUTOPT_REPLCELLSWARN 9 -#define SCINPUTOPT_LEGACY_CELL_SELECTION 10 -#define SCINPUTOPT_COUNT 11 +#define SCINPUTOPT_MOVEDIR 0 +#define SCINPUTOPT_MOVESEL 1 +#define SCINPUTOPT_EDTEREDIT 2 +#define SCINPUTOPT_EXTENDFMT 3 +#define SCINPUTOPT_RANGEFIND 4 +#define SCINPUTOPT_EXPANDREFS 5 +#define SCINPUTOPT_SORT_REF_UPDATE 6 +#define SCINPUTOPT_MARKHEADER 7 +#define SCINPUTOPT_USETABCOL 8 +#define SCINPUTOPT_TEXTWYSIWYG 9 +#define SCINPUTOPT_REPLCELLSWARN 10 +#define SCINPUTOPT_LEGACY_CELL_SELECTION 11 +#define SCINPUTOPT_COUNT 12 Sequence<OUString> ScInputCfg::GetPropertyNames() { @@ -106,6 +109,7 @@ Sequence<OUString> ScInputCfg::GetPropertyNames() "ExpandFormatting", // SCINPUTOPT_EXTENDFMT "ShowReference", // SCINPUTOPT_RANGEFIND "ExpandReference", // SCINPUTOPT_EXPANDREFS + "UpdateReferenceOnSort", // SCINPUTOPT_SORT_REF_UPDATE "HighlightSelection", // SCINPUTOPT_MARKHEADER "UseTabCol", // SCINPUTOPT_USETABCOL "UsePrinterMetrics", // SCINPUTOPT_TEXTWYSIWYG @@ -157,6 +161,9 @@ ScInputCfg::ScInputCfg() : case SCINPUTOPT_EXPANDREFS: SetExpandRefs( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) ); break; + case SCINPUTOPT_SORT_REF_UPDATE: + SetSortRefUpdate(ScUnoHelpFunctions::GetBoolFromAny(pValues[nProp])); + break; case SCINPUTOPT_MARKHEADER: SetMarkHeader( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) ); break; @@ -206,6 +213,9 @@ void ScInputCfg::Commit() case SCINPUTOPT_EXPANDREFS: ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetExpandRefs() ); break; + case SCINPUTOPT_SORT_REF_UPDATE: + ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetSortRefUpdate() ); + break; case SCINPUTOPT_MARKHEADER: ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetMarkHeader() ); break; diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index 040e16e..72ccfbd 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -1220,6 +1220,12 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet ) pInputCfg->SetExpandRefs( ((const SfxBoolItem*)pItem)->GetValue() ); bSaveInputOptions = true; } + if (rOptSet.HasItem(SID_SC_OPT_SORT_REF_UPDATE, &pItem)) + { + pInputCfg->SetSortRefUpdate(static_cast<const SfxBoolItem*>(pItem)->GetValue()); + bSaveInputOptions = true; + } + if ( rOptSet.HasItem(SID_SC_INPUT_MARK_HEADER,&pItem) ) { pInputCfg->SetMarkHeader( ((const SfxBoolItem*)pItem)->GetValue() ); @@ -1970,7 +1976,7 @@ SfxItemSet* ScModule::CreateItemSet( sal_uInt16 nId ) SID_SC_INPUT_SELECTION,SID_SC_INPUT_MARK_HEADER, SID_SC_INPUT_TEXTWYSIWYG,SID_SC_INPUT_TEXTWYSIWYG, SID_SC_INPUT_REPLCELLSWARN,SID_SC_INPUT_REPLCELLSWARN, - SID_SC_INPUT_LEGACY_CELL_SELECTION,SID_SC_INPUT_LEGACY_CELL_SELECTION, + SID_SC_INPUT_LEGACY_CELL_SELECTION,SID_SC_OPT_SORT_REF_UPDATE, // TP_USERLISTS: SCITEM_USERLIST, SCITEM_USERLIST, // TP_PRINT: @@ -2033,6 +2039,7 @@ SfxItemSet* ScModule::CreateItemSet( sal_uInt16 nId ) rInpOpt.GetRangeFinder() ) ); pRet->Put( SfxBoolItem( SID_SC_INPUT_REF_EXPAND, rInpOpt.GetExpandRefs() ) ); + pRet->Put( SfxBoolItem(SID_SC_OPT_SORT_REF_UPDATE, rInpOpt.GetSortRefUpdate())); pRet->Put( SfxBoolItem( SID_SC_INPUT_MARK_HEADER, rInpOpt.GetMarkHeader() ) ); pRet->Put( SfxBoolItem( SID_SC_INPUT_TEXTWYSIWYG, diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx index d22ce07..7f30a02 100644 --- a/sc/source/ui/docshell/dbdocfun.cxx +++ b/sc/source/ui/docshell/dbdocfun.cxx @@ -48,6 +48,7 @@ #include "markdata.hxx" #include "progress.hxx" #include <undosort.hxx> +#include <inputopt.hxx> #include <set> #include <memory> @@ -551,8 +552,10 @@ bool ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam& rSortParam, // don't call ScDocument::Sort with an empty SortParam (may be empty here if bCopy is set) if (aLocalParam.GetSortKeyCount() && aLocalParam.maKeyState[0].bDoSort) { + ScInputOptions aInputOption = SC_MOD()->GetInputOptions(); + bool bUpdateRefs = aInputOption.GetSortRefUpdate(); ScProgress aProgress(&rDocShell, ScGlobal::GetRscString(STR_PROGRESS_SORTING), 0); - rDoc.Sort(nTab, aLocalParam, bRepeatQuery, &aProgress, &aUndoParam); + rDoc.Sort(nTab, aLocalParam, bRepeatQuery, bUpdateRefs, &aProgress, &aUndoParam); } if (bRecord) diff --git a/sc/source/ui/inc/tpview.hxx b/sc/source/ui/inc/tpview.hxx index b5560e2..49c8e81 100644 --- a/sc/source/ui/inc/tpview.hxx +++ b/sc/source/ui/inc/tpview.hxx @@ -95,6 +95,7 @@ class ScTpLayoutOptions : public SfxTabPage CheckBox* m_pEditModeCB; CheckBox* m_pFormatCB; CheckBox* m_pExpRefCB; + CheckBox* m_pSortRefUpdateCB; CheckBox* m_pMarkHdrCB; CheckBox* m_pTextFmtCB; CheckBox* m_pReplWarnCB; diff --git a/sc/source/ui/optdlg/tpview.cxx b/sc/source/ui/optdlg/tpview.cxx index 8e50d5d..3293770 100644 --- a/sc/source/ui/optdlg/tpview.cxx +++ b/sc/source/ui/optdlg/tpview.cxx @@ -365,6 +365,7 @@ ScTpLayoutOptions::ScTpLayoutOptions( Window* pParent, get( m_pEditModeCB, "editmodecb"); get( m_pFormatCB, "formatcb"); get( m_pExpRefCB, "exprefcb"); + get( m_pSortRefUpdateCB, "sortrefupdatecb"); get( m_pMarkHdrCB, "markhdrcb"); get( m_pTextFmtCB, "textfmtcb"); get( m_pReplWarnCB, "replwarncb"); @@ -488,6 +489,12 @@ bool ScTpLayoutOptions::FillItemSet( SfxItemSet* rCoreSet ) bRet = true; } + if (m_pSortRefUpdateCB->IsValueChangedFromSaved()) + { + rCoreSet->Put(SfxBoolItem(SID_SC_OPT_SORT_REF_UPDATE, m_pSortRefUpdateCB->IsChecked())); + bRet = true; + } + if(m_pMarkHdrCB->IsValueChangedFromSaved()) { rCoreSet->Put(SfxBoolItem(SID_SC_INPUT_MARK_HEADER, m_pMarkHdrCB->IsChecked())); @@ -581,6 +588,9 @@ void ScTpLayoutOptions::Reset( const SfxItemSet* rCoreSet ) if(SFX_ITEM_SET == rCoreSet->GetItemState(SID_SC_INPUT_REF_EXPAND, false, &pItem)) m_pExpRefCB->Check(((const SfxBoolItem*)pItem)->GetValue()); + if (rCoreSet->HasItem(SID_SC_OPT_SORT_REF_UPDATE, &pItem)) + m_pSortRefUpdateCB->Check(static_cast<const SfxBoolItem*>(pItem)->GetValue()); + if(SFX_ITEM_SET == rCoreSet->GetItemState(SID_SC_INPUT_MARK_HEADER, false, &pItem)) m_pMarkHdrCB->Check(((const SfxBoolItem*)pItem)->GetValue()); @@ -599,6 +609,7 @@ void ScTpLayoutOptions::Reset( const SfxItemSet* rCoreSet ) m_pFormatCB ->SaveValue(); m_pExpRefCB ->SaveValue(); + m_pSortRefUpdateCB->SaveValue(); m_pMarkHdrCB ->SaveValue(); m_pTextFmtCB ->SaveValue(); m_pReplWarnCB ->SaveValue(); diff --git a/sc/source/ui/undo/undosort.cxx b/sc/source/ui/undo/undosort.cxx index d138491..fbd10ae 100644 --- a/sc/source/ui/undo/undosort.cxx +++ b/sc/source/ui/undo/undosort.cxx @@ -48,6 +48,8 @@ void UndoSort::Execute( bool bUndo ) pDocShell->PostPaint(maParam.maSortRange, PAINT_GRID); pDocShell->PostDataChanged(); + if (!aParam.mbUpdateRefs) + rDoc.BroadcastCells(aParam.maSortRange, SC_HINT_DATACHANGED); } } diff --git a/sc/uiconfig/scalc/ui/scgeneralpage.ui b/sc/uiconfig/scalc/ui/scgeneralpage.ui index 458e022..38bed5e 100644 --- a/sc/uiconfig/scalc/ui/scgeneralpage.ui +++ b/sc/uiconfig/scalc/ui/scgeneralpage.ui @@ -1,5 +1,4 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.16.0 on Wed Jan 8 17:08:51 2014 --> <interface> <!-- interface-requires gtk+ 3.0 --> <object class="GtkAdjustment" id="adjustment1"> @@ -324,8 +323,28 @@ </packing> </child> <child> - <object class="GtkCheckButton" id="markhdrcb"> - <property name="label" translatable="yes">Highlight sele_ction in column/row headers</property> + <object class="GtkComboBoxText" id="alignlb"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">end</property> + <property name="hexpand">True</property> + <items> + <item translatable="yes">Down</item> + <item translatable="yes">Right</item> + <item translatable="yes">Up</item> + <item translatable="yes">Left</item> + </items> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="aligncb"> + <property name="label" translatable="yes">Press Enter to _move selection</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> @@ -335,24 +354,25 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">4</property> - <property name="width">2</property> + <property name="top_attach">0</property> + <property name="width">1</property> <property name="height">1</property> </packing> </child> <child> - <object class="GtkCheckButton" id="textfmtcb"> - <property name="label" translatable="yes">Use printer metrics for text formatting</property> + <object class="GtkCheckButton" id="legacy_cell_selection_cb"> + <property name="label" translatable="yes">Use legacy cursor movement behavior when selecting</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> + <property name="use_underline">True</property> <property name="xalign">0</property> <property name="draw_indicator">True</property> </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">5</property> - <property name="width">2</property> + <property name="top_attach">8</property> + <property name="width">1</property> <property name="height">1</property> </packing> </child> @@ -368,34 +388,30 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">6</property> - <property name="width">2</property> + <property name="top_attach">7</property> + <property name="width">1</property> <property name="height">1</property> </packing> </child> <child> - <object class="GtkComboBoxText" id="alignlb"> + <object class="GtkCheckButton" id="textfmtcb"> + <property name="label" translatable="yes">Use printer metrics for text formatting</property> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="halign">end</property> - <property name="hexpand">True</property> - <items> - <item translatable="yes">Down</item> - <item translatable="yes">Right</item> - <item translatable="yes">Up</item> - <item translatable="yes">Left</item> - </items> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> </object> <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> + <property name="left_attach">0</property> + <property name="top_attach">6</property> <property name="width">1</property> <property name="height">1</property> </packing> </child> <child> - <object class="GtkCheckButton" id="aligncb"> - <property name="label" translatable="yes">Press Enter to _move selection</property> + <object class="GtkCheckButton" id="markhdrcb"> + <property name="label" translatable="yes">Highlight sele_ction in column/row headers</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> @@ -405,28 +421,42 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">0</property> + <property name="top_attach">5</property> <property name="width">1</property> <property name="height">1</property> </packing> </child> <child> - <object class="GtkCheckButton" id="legacy_cell_selection_cb"> - <property name="label" translatable="yes">Use legacy cursor movement behavior when selecting</property> + <object class="GtkCheckButton" id="sortrefupdatecb"> + <property name="label" translatable="yes">Update references when sorting range of cells</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> - <property name="use_underline">True</property> <property name="xalign">0</property> <property name="draw_indicator">True</property> </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">7</property> - <property name="width">2</property> + <property name="top_attach">4</property> + <property name="width">1</property> <property name="height">1</property> </packing> </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> </object> </child> </object> _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits