[Libreoffice-commits] core.git: 2 commits - sw/source vcl/workben

Caolán McNamara caolanm at redhat.com
Wed Dec 3 07:42:51 PST 2014


 sw/source/filter/ww8/ww8par2.cxx |   22 ++++++++++++++++++----
 vcl/workben/vcldemo.cxx          |    5 +++--
 2 files changed, 21 insertions(+), 6 deletions(-)

New commits:
commit 9ddadaa5c0e2429c2d6d6a5661e945fd03012518
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Dec 3 14:30:01 2014 +0000

    when parking pams, park into nearest txtnode
    
    i.e. avoid assert of ooo67620-2.doc
    
    Change-Id: Idea4ca1cef764608c55bba6a540bde57b7b19d08

diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index 8fe310b..bbea4c0 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -2635,9 +2635,17 @@ void WW8TabDesc::ParkPaM()
         return;
     }
 
-    if (pIo->pPaM->GetPoint()->nNode != pTabBox2->GetSttIdx() + 1)
+    sal_uLong nSttNd = pTabBox2->GetSttIdx() + 1,
+              nEndNd = pTabBox2->GetSttNd()->EndOfSectionIndex();
+
+    if (pIo->pPaM->GetPoint()->nNode != nSttNd)
     {
-        pIo->pPaM->GetPoint()->nNode = pTabBox2->GetSttIdx() + 1;
+        do
+        {
+            pIo->pPaM->GetPoint()->nNode = nSttNd;
+        }
+        while (pIo->pPaM->GetNode().GetNodeType() != ND_TEXTNODE && ++nSttNd < nEndNd);
+
         pIo->pPaM->GetPoint()->nContent.Assign(pIo->pPaM->GetCntntNode(), 0);
         pIo->rDoc.SetTxtFmtColl(*pIo->pPaM, (SwTxtFmtColl*)pIo->pDfltTxtFmtColl);
     }
@@ -2869,9 +2877,15 @@ bool WW8TabDesc::SetPamInCell(short nWwCol, bool bPam)
         //or not so that we can collect paragraph proproties over
         //all the cells, but in that case on the valid cell we do not
         //want to reset the fmt properties
-        if (pIo->pPaM->GetPoint()->nNode != pTabBox->GetSttIdx() + 1)
+        sal_uLong nSttNd = pTabBox->GetSttIdx() + 1,
+                  nEndNd = pTabBox->GetSttNd()->EndOfSectionIndex();
+        if (pIo->pPaM->GetPoint()->nNode != nSttNd)
         {
-            pIo->pPaM->GetPoint()->nNode = pTabBox->GetSttIdx() + 1;
+            do
+            {
+                pIo->pPaM->GetPoint()->nNode = nSttNd;
+            }
+            while (pIo->pPaM->GetNode().GetNodeType() != ND_TEXTNODE && ++nSttNd < nEndNd);
             pIo->pPaM->GetPoint()->nContent.Assign(pIo->pPaM->GetCntntNode(), 0);
             // Precautionally set now, otherwise the style is not set for cells
             // that are inserted for margin balancing.
commit 80a6351f7794cc730e89ef6b0d5e49e2f4d9b1f2
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Dec 3 14:59:23 2014 +0000

    coverity#1256310 Don't call rand
    
    Change-Id: I0a8f21fd03cf110b321906c0b1b88a8edc225b5a

diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index 95329f3..6423b0b 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -8,6 +8,7 @@
  */
 
 #include <comphelper/processfactory.hxx>
+#include <comphelper/random.hxx>
 #include <cppuhelper/bootstrap.hxx>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
@@ -31,7 +32,7 @@
 #include <vcl/bmpacc.hxx>
 #include <basegfx/numeric/ftools.hxx>
 #include <basegfx/matrix/b2dhommatrix.hxx>
-
+#include <boost/math/special_functions/next.hpp>
 #include <vcldemo-debug.hxx>
 
 #include <rtl/math.hxx>
@@ -316,7 +317,7 @@ public:
             for (int i = 0; i < PRINT_N_TEXT; i++) {
                 rDev.SetTextColor(Color(nCols[i % SAL_N_ELEMENTS(nCols)]));
                 // random font size to avoid buffering
-                vcl::Font aFont(maFontNames[i % maFontNames.size()], Size(0, 1 + i * (0.9 + (double)rand()/10/RAND_MAX) * (r.Top() - r.Bottom())/PRINT_N_TEXT));
+                vcl::Font aFont(maFontNames[i % maFontNames.size()], Size(0, 1 + i * (0.9 + comphelper::rng::uniform_real_distribution(0.0, boost::math::nextafter(0.1, DBL_MAX))) * (r.Top() - r.Bottom())/PRINT_N_TEXT));
                 rDev.SetFont(aFont);
                 rDev.DrawText(r, aText.copy(0, 4 + (aText.getLength() - 4) * (PRINT_N_TEXT - i)/PRINT_N_TEXT));
             }


More information about the Libreoffice-commits mailing list