[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.1' - 2 commits - libreofficekit/source sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Wed Sep 21 06:30:22 UTC 2016


 libreofficekit/source/gtk/lokdocview.cxx |   12 ++++++++++--
 sw/qa/extras/uiwriter/uiwriter.cxx       |   31 +++++++++++++++++++++++++++++++
 sw/source/core/doc/docredln.cxx          |    1 -
 3 files changed, 41 insertions(+), 3 deletions(-)

New commits:
commit ab2da32b380e068bb131bca6f28c62c0bb9c9fdb
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 20 17:04:50 2016 +0200

    lokdocview: guard against int overflow
    
    If a too large rectangle is parsed, the width or the height may be
    larger than std::numeric_limits<int>::max(), in that case just set
    width/height to that max value, instead of allowing an overflow.
    
    Change-Id: Ic01319b01a3f9286501c346ea765868be57466a1
    (cherry picked from commit 28447258fb6d9b8246f2a96d1a86945ef255d110)

diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index d3c4974..786d827 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1019,13 +1019,21 @@ payloadToRectangle (LOKDocView* pDocView, const char* pPayload)
     ++ppCoordinate;
     if (!*ppCoordinate)
         return aRet;
-    aRet.width = atoi(*ppCoordinate);
+    long l = atol(*ppCoordinate);
+    if (l > std::numeric_limits<int>::max())
+        aRet.width = std::numeric_limits<int>::max();
+    else
+        aRet.width = l;
     if (aRet.x + aRet.width > priv->m_nDocumentWidthTwips)
         aRet.width = priv->m_nDocumentWidthTwips - aRet.x;
     ++ppCoordinate;
     if (!*ppCoordinate)
         return aRet;
-    aRet.height = atoi(*ppCoordinate);
+    l = atol(*ppCoordinate);
+    if (l > std::numeric_limits<int>::max())
+        aRet.height = std::numeric_limits<int>::max();
+    else
+        aRet.height = l;
     if (aRet.y + aRet.height > priv->m_nDocumentHeightTwips)
         aRet.height = priv->m_nDocumentHeightTwips - aRet.y;
     g_strfreev(ppCoordinates);
commit b9b7d4ee4ded28f59997ce7f30488e049af917a1
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 20 12:23:04 2016 +0200

    tdf#102308 sw: improve redline timestamp precision
    
    It's not clear why it was like this since the initial import, but at
    least not clearing seconds is already an improvement.
    
    (cherry picked from commit d9dca1eef91faa710112ffd20a2b2d36b48a9287)
    
    Conflicts:
    	sw/qa/extras/uiwriter/uiwriter.cxx
    
    Change-Id: Ic452256d4ab47e6779ec71fe6576eacb5b74fb43

diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index d63b3fc..ad97db7 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -190,6 +190,7 @@ public:
     void testClassificationPaste();
     void testRedlineParam();
     void testRedlineViewAuthor();
+    void testRedlineTimestamp();
 
     CPPUNIT_TEST_SUITE(SwUiWriterTest);
     CPPUNIT_TEST(testReplaceForward);
@@ -285,6 +286,7 @@ public:
     CPPUNIT_TEST(testClassificationPaste);
     CPPUNIT_TEST(testRedlineParam);
     CPPUNIT_TEST(testRedlineViewAuthor);
+    CPPUNIT_TEST(testRedlineTimestamp);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -3357,6 +3359,35 @@ void SwUiWriterTest::testRedlineViewAuthor()
     CPPUNIT_ASSERT_EQUAL(aAuthor, xField->getPropertyValue("Author").get<OUString>());
 }
 
+void SwUiWriterTest::testRedlineTimestamp()
+{
+    // Test that a redline timestamp's second is not always 0.
+
+    // Create a document with minimal content.
+    SwDoc* pDoc = createDoc();
+    SwDocShell* pDocShell = pDoc->GetDocShell();
+    SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+    pWrtShell->Insert("middle");
+
+    // Turn on track changes, and add changes to the start and to the end of
+    // the document.
+    uno::Reference<beans::XPropertySet> xPropertySet(mxComponent, uno::UNO_QUERY);
+    xPropertySet->setPropertyValue("RecordChanges", uno::makeAny(true));
+    pWrtShell->SttDoc();
+    pWrtShell->Insert("aaa");
+    osl::Thread::wait(std::chrono::seconds(1));
+    pWrtShell->EndDoc();
+    pWrtShell->Insert("zzz");
+
+    // Now assert that at least one of the the seconds are not 0.
+    const SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rTable.size());
+    sal_uInt16 nSec1 = rTable[0]->GetRedlineData().GetTimeStamp().GetSec();
+    sal_uInt16 nSec2 = rTable[0]->GetRedlineData().GetTimeStamp().GetSec();
+    // This failed, seconds was always 0.
+    CPPUNIT_ASSERT(nSec1 != 0 || nSec2 != 0);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 99cd566..afbb653 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -853,7 +853,6 @@ SwRedlineData::SwRedlineData( RedlineType_t eT, sal_uInt16 nAut )
     aStamp( DateTime::SYSTEM ),
     eType( eT ), nAuthor( nAut ), nSeqNo( 0 )
 {
-    aStamp.SetSec( 0 );
     aStamp.SetNanoSec( 0 );
 }
 


More information about the Libreoffice-commits mailing list