[Libreoffice-commits] .: 3 commits - sc/source sw/qa

Markus Mohrhard mmohrhard at kemper.freedesktop.org
Thu Mar 1 02:16:43 PST 2012


 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.mohrhard at 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 (nStartCol>0)                        // copy old attributes
@@ -437,20 +474,31 @@ void ScTable::DeleteCol( 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);
     }
 
     DecRecalcLevel();
commit 373394c887f237cdf202cecefa74b5a9828d69f9
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Mar 1 01:14:27 2012 +0100

    only delete notes if correct flag is passed

diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 371f123..1af4b49 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -488,7 +488,7 @@ void ScTable::DeleteArea(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, sal
         }
     }
 
-    if (nDelFlag & IDF_CONTENTS)
+    if (nDelFlag & IDF_NOTE)
         maNotes.erase( nCol1, nRow1, nCol2, nRow2);
 
     if (IsStreamValid())
@@ -512,7 +512,7 @@ void ScTable::DeleteSelection( sal_uInt16 nDelFlag, const ScMarkData& rMark )
     for (size_t i = 0; i < aRangeList.size(); ++i)
     {
         ScRange* pRange = aRangeList[i];
-        if (nDelFlag & IDF_CONTENTS && pRange)
+        if (nDelFlag & IDF_NOTE && pRange)
             maNotes.erase(pRange->aStart.Col(), pRange->aStart.Row(), pRange->aEnd.Col(), pRange->aEnd.Row());
     }
 
commit 247be4c2e6e31e73396cf7b9ce6abf37c617a2e2
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Mar 1 01:11:28 2012 +0100

    clean-up sw's filters-test
    
    filters-test does not initialize vcl, for these sort of tests use
    macros_test

diff --git a/sw/qa/core/filters-test.cxx b/sw/qa/core/filters-test.cxx
index a8682bd..9929271 100644
--- a/sw/qa/core/filters-test.cxx
+++ b/sw/qa/core/filters-test.cxx
@@ -32,9 +32,6 @@
 
 #include <cppuhelper/implbase1.hxx>
 
-#include <com/sun/star/document/XDocumentEventListener.hpp>
-#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
-
 #include <comphelper/processfactory.hxx>
 
 #include <sfx2/app.hxx>
@@ -54,29 +51,6 @@ SO2_IMPL_REF(SwDocShell)
 
 using namespace ::com::sun::star;
 
-
-class EventListener
-    : public ::cppu::WeakImplHelper1<document::XDocumentEventListener>
-{
-public:
-    bool m_bLayoutFinished;
-    explicit EventListener() : m_bLayoutFinished(false) { }
-    virtual void SAL_CALL documentEventOccured(
-            document::DocumentEvent const& rEvent)
-        throw (uno::RuntimeException)
-    {
-//        fprintf(stderr, "EVENT: %s\n", ::rtl::OUStringToOString(rEvent.EventName, RTL_TEXTENCODING_UTF8).getStr());
-        if (rEvent.EventName.equalsAscii("OnLayoutFinished"))
-        {
-            m_bLayoutFinished = true;
-        }
-    }
-    virtual void SAL_CALL disposing(lang::EventObject const&)
-        throw (uno::RuntimeException)
-    {
-    }
-};
-
 /* Implementation of Filters test */
 
 class SwFiltersTest
@@ -101,18 +75,6 @@ private:
 bool SwFiltersTest::load(const rtl::OUString &rFilter, const rtl::OUString &rURL,
     const rtl::OUString &rUserData)
 {
-    ::rtl::Reference<EventListener> xListener;
-    if (false) // does not work: missing ViewShell, no VCL timers, or both
-    {
-        xListener.set(new EventListener);
-        uno::Reference<document::XDocumentEventBroadcaster> xGEB;
-        xGEB.set(::comphelper::getProcessServiceFactory()->createInstance(
-                ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
-                    "com.sun.star.frame.GlobalEventBroadcaster"))),
-            uno::UNO_QUERY_THROW);
-        xGEB->addDocumentEventListener(
-            uno::Reference<document::XDocumentEventListener>(xListener.get()));
-    }
     SfxFilter* pFilter = new SfxFilter(
         rFilter,
         rtl::OUString(), 0, 0, rtl::OUString(), 0, rtl::OUString(),
@@ -122,19 +84,6 @@ bool SwFiltersTest::load(const rtl::OUString &rFilter, const rtl::OUString &rURL
     SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ, true);
     pSrcMed->SetFilter(pFilter);
     bool bLoaded = xDocShRef->DoLoad(pSrcMed);
-    if (bLoaded && xListener.is())
-    {
-        TimeValue delay = {0, 100000000};
-        int tries(0);
-        while (!xListener->m_bLayoutFinished) {
-            osl_waitThread(& delay);
-            ++tries;
-            if (tries >= 300) {
-                fprintf(stderr, "timed out: no OnLayoutFinished received\n");
-                break;
-            }
-        }
-    }
     if (xDocShRef.Is())
         xDocShRef->DoClose();
     return bLoaded;


More information about the Libreoffice-commits mailing list