[Libreoffice-commits] .: 3 commits - sc/source sw/qa
sc/source/core/data/table2.cxx | 116 - sw/qa/core/filters-test.cxx| 51 -- 2 files changed, 82 insertions(+), 85 deletions(-) New commits: commit 58272b98319c5da2d433c0bc5e520a12ab73c71c Author: Markus Mohrhard markus.mohrh...@googlemail.com Date: Thu Mar 1 11:07:16 2012 +0100 fix some iterator misuse in the new notes handling diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 1af4b49..9f24b47 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -175,18 +175,31 @@ void ScTable::InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE aCol[j].InsertRow( nStartRow, nSize ); ScNotes aNotes(pDocument); -for ( ScNotes::iterator itr = maNotes.begin(); itr != maNotes.end(); ++itr) +ScNotes::iterator itr = maNotes.begin(); +while( itr != maNotes.end() ) { -if (itr-first.second = nStartRow) +SCCOL nCol = itr-first.first; +SCROW nRow = itr-first.second; +ScPostIt* pPostIt = itr-second; +++itr; + +if (nCol = nStartRow) { -aNotes.insert(itr-first.first, itr-first.second + nSize, itr-second); -maNotes.ReleaseNote(itr-first.first, itr-first.second); +aNotes.insert(nCol, nRow + nSize, pPostIt); +maNotes.ReleaseNote(nCol, nRow); } } -for ( ScNotes::iterator itr = aNotes.begin(); itr != aNotes.end(); ++itr) + +itr = aNotes.begin(); +while( itr != aNotes.end() ) { -maNotes.insert( itr-first.first, itr-first.second, itr-second); -aNotes.ReleaseNote(itr-first.first, itr-first.second); +SCCOL nCol = itr-first.first; +SCROW nRow = itr-first.second; +ScPostIt* pPostIt = itr-second; +++itr; + +maNotes.insert( nCol, nRow, pPostIt); +aNotes.ReleaseNote( nCol, nRow); } DecRecalcLevel( false ); @@ -242,18 +255,31 @@ void ScTable::DeleteRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE } ScNotes aNotes(pDocument); -for ( ScNotes::iterator itr = maNotes.begin(); itr != maNotes.end(); ++itr) +ScNotes::iterator itr = maNotes.begin(); +while( itr != maNotes.end() ) { -if (itr-first.second = nStartRow) +SCCOL nCol = itr-first.first; +SCROW nRow = itr-first.second; +ScPostIt* pPostIt = itr-second; +++itr; + +if (nCol = nStartRow) { -aNotes.insert(itr-first.first, itr-first.second - nSize, itr-second); -maNotes.ReleaseNote(itr-first.first, itr-first.second); +aNotes.insert(nCol, nRow - nSize, pPostIt); +maNotes.ReleaseNote(nCol, nRow); } } -for ( ScNotes::iterator itr = aNotes.begin(); itr != aNotes.end(); ++itr) + +itr = aNotes.begin(); +while( itr != aNotes.end() ) { -maNotes.insert( itr-first.first, itr-first.second, itr-second); -aNotes.ReleaseNote(itr-first.first, itr-first.second); +SCCOL nCol = itr-first.first; +SCROW nRow = itr-first.second; +ScPostIt* pPostIt = itr-second; +++itr; + +maNotes.insert( nCol, nRow, pPostIt); +aNotes.ReleaseNote( nCol, nRow); } { // scope for bulk broadcast @@ -339,20 +365,31 @@ void ScTable::InsertCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE } ScNotes aNotes(pDocument); -for ( ScNotes::iterator itr = maNotes.begin(); itr != maNotes.end(); ++itr) +ScNotes::iterator itr = maNotes.begin(); +while( itr != maNotes.end() ) { -if (itr-first.first nStartCol) +SCCOL nCol = itr-first.first; +SCROW nRow = itr-first.second; +ScPostIt* pPostIt = itr-second; +++itr; + +if (nCol = nStartRow) { -aNotes.insert(itr-first.first + nSize, itr-first.second, itr-second); -maNotes.ReleaseNote(itr-first.first, itr-first.second); +aNotes.insert(nCol + nSize, nRow, pPostIt); +maNotes.ReleaseNote(nCol, nRow); } -else -aNotes.insert( itr-first.first, itr-first.second, itr-second); } -for ( ScNotes::iterator itr = aNotes.begin(); itr != aNotes.end(); ++itr) + +itr = aNotes.begin(); +while( itr != aNotes.end() ) { -maNotes.insert( itr-first.first, itr-first.second, itr-second); -aNotes.ReleaseNote(itr-first.first, itr-first.second); +SCCOL nCol = itr-first.first; +SCROW nRow = itr-first.second; +ScPostIt* pPostIt = itr-second; +++itr; + +maNotes.insert( nCol, nRow, pPostIt); +aNotes.ReleaseNote( nCol, nRow); } if (nStartCol0)// copy old attributes @@ -437,20 +474,31 @@ void ScTable::DeleteCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE } ScNotes aNotes(pDocument); -
[Libreoffice-commits] .: 3 commits - sc/source sw/qa
sc/source/ui/inc/namemgrtable.hxx | 13 +++- sc/source/ui/namedlg/namemgrtable.cxx | 54 ++ sc/source/ui/src/namedefdlg.src |2 - sw/qa/core/macros-test.cxx| 34 +++-- 4 files changed, 67 insertions(+), 36 deletions(-) New commits: commit 792fb5b96f1008804ab51dc0ebf4f07a07ad9537 Author: Markus Mohrhard markus.mohrh...@googlemail.com Date: Tue Nov 29 10:39:01 2011 +0100 ManageNames: only calculate formula for visible range names diff --git a/sc/source/ui/inc/namemgrtable.hxx b/sc/source/ui/inc/namemgrtable.hxx index b95002e..bbbcab6 100644 --- a/sc/source/ui/inc/namemgrtable.hxx +++ b/sc/source/ui/inc/namemgrtable.hxx @@ -36,6 +36,7 @@ #include boost/ptr_container/ptr_map.hpp class ScRangeName; +class ScRangeData; struct ScRangeNameLine { @@ -64,8 +65,17 @@ private: HeaderBar maHeaderBar; rtl::OUString maGlobalString; +// should be const because we should not modify it here +const boost::ptr_maprtl::OUString, ScRangeName mrRangeMap; +// for performance, save which entries already have the formula entry +// otherwise opening the dialog with a lot of range names is extremelly slow because +// we would calculate all formula strings during opening +std::mapSvLBoxEntry*, bool maCalculatedFormulaEntries; + void GetLine(ScRangeNameLine aLine, SvLBoxEntry* pEntry); -void Init( const boost::ptr_maprtl::OUString, ScRangeName rRangeMap ); +void Init(); +void CheckForFormulaString(); +const ScRangeData* findRangeData(const ScRangeNameLine rLine); public: ScRangeManagerTable( Window* pParent, boost::ptr_maprtl::OUString, ScRangeName aTabRangeNames ); @@ -78,6 +88,7 @@ public: bool IsMultiSelection(); std::vectorScRangeNameLine GetSelectedEntries(); +DECL_LINK( ScrollHdl, void*); DECL_LINK( HeaderEndDragHdl, void*); }; diff --git a/sc/source/ui/namedlg/namemgrtable.cxx b/sc/source/ui/namedlg/namemgrtable.cxx index d471c74..de9e386 100644 --- a/sc/source/ui/namedlg/namemgrtable.cxx +++ b/sc/source/ui/namedlg/namemgrtable.cxx @@ -60,7 +60,8 @@ String createEntryString(const ScRangeNameLine rLine) ScRangeManagerTable::ScRangeManagerTable( Window* pWindow, boost::ptr_maprtl::OUString, ScRangeName rRangeMap ): SvTabListBox( pWindow, WB_SORT | WB_HSCROLL | WB_CLIPCHILDREN | WB_TABSTOP ), maHeaderBar( pWindow, WB_BUTTONSTYLE | WB_BOTTOMBORDER ), -maGlobalString( ScGlobal::GetRscString(STR_GLOBAL_SCOPE)) +maGlobalString( ScGlobal::GetRscString(STR_GLOBAL_SCOPE)), +mrRangeMap( rRangeMap ) { Size aBoxSize( pWindow-GetOutputSizePixel() ); @@ -84,12 +85,16 @@ ScRangeManagerTable::ScRangeManagerTable( Window* pWindow, boost::ptr_maprtl::O maHeaderBar.SetEndDragHdl( LINK( this, ScRangeManagerTable, HeaderEndDragHdl ) ); +Init(); Show(); maHeaderBar.Show(); SetSelectionMode(MULTIPLE_SELECTION); -Init(rRangeMap); if (GetEntryCount()) +{ SetCurEntry(GetEntryOnPos(0)); +CheckForFormulaString(); +} +SetScrolledHdl( LINK( this, ScRangeManagerTable, ScrollHdl ) ); } ScRangeManagerTable::~ScRangeManagerTable() @@ -116,11 +121,11 @@ void ScRangeManagerTable::GetLine(ScRangeNameLine rLine, SvLBoxEntry* pEntry) rLine.aScope = GetEntryText(pEntry, 2); } -void ScRangeManagerTable::Init(const boost::ptr_maprtl::OUString, ScRangeName rRangeMap) +void ScRangeManagerTable::Init() { Clear(); -for (boost::ptr_maprtl::OUString, ScRangeName::const_iterator itr = rRangeMap.begin(); -itr != rRangeMap.end(); ++itr) +for (boost::ptr_maprtl::OUString, ScRangeName::const_iterator itr = mrRangeMap.begin(); +itr != mrRangeMap.end(); ++itr) { const ScRangeName* pLocalRangeName = itr-second; ScRangeNameLine aLine; @@ -134,13 +139,44 @@ void ScRangeManagerTable::Init(const boost::ptr_maprtl::OUString, ScRangeName if (!it-second-HasType(RT_DATABASE) !it-second-HasType(RT_SHARED)) { aLine.aName = it-second-GetName(); -it-second-GetSymbol(aLine.aExpression); addEntry(aLine); } } } } +const ScRangeData* ScRangeManagerTable::findRangeData(const ScRangeNameLine rLine) +{ +const ScRangeName* pRangeName; +if (rLine.aScope == maGlobalString) +pRangeName = mrRangeMap.find(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_GLOBAL_RANGE_NAME)))-second; +else +pRangeName = mrRangeMap.find(rLine.aScope)-second; + +return pRangeName-findByUpperName(ScGlobal::pCharClass-upper(rLine.aName)); +} + + + +void ScRangeManagerTable::CheckForFormulaString() +{ +for (SvLBoxEntry* pEntry = GetFirstEntryInView(); pEntry ; pEntry = GetNextEntryInView(pEntry)) +{ +std::mapSvLBoxEntry*, bool::const_iterator itr = maCalculatedFormulaEntries.find(pEntry); +if (itr ==