dbaccess/source/ui/browser/unodatbr.cxx         |    2 +-
 dbaccess/source/ui/tabledesign/TEditControl.cxx |   10 +++++-----
 include/tools/multisel.hxx                      |    2 +-
 reportdesign/source/ui/dlg/GroupsSorting.cxx    |    6 +++---
 4 files changed, 10 insertions(+), 10 deletions(-)

New commits:
commit 0973e1f4e727a3204c843398bcb0e6a411b1a02d
Author: Noel Grandin <noel.gran...@collabora.co.uk>
Date:   Mon Apr 16 08:28:16 2018 +0200

    follow on for tdf#116981
    
    the previous commit 235d61890512894e27f4f81e38a325eee3c67b30, fixed just
    exactly the problem reported in tdf#116981.
    
    This commit fixes similar issues that may exist elsewhere.
    
    To recap, this started as a regression from
            commit  433fc2214c980abd82fa6240f45e634a53a3c61c (patch)
            sal_uIntPtr->sal_Int32 in MultiSelection
    
    Previously, MultiSelection stored it's values internally as sal_uIntPtr,
    but returned them as long in FirstSelected(), NextSelected(),
    and SFX_ENDOFSELECTION was defined to be ULONG_MAX.
    On 64-bit Linux, sal_uIntPtr is typedefed to sal_uInt64, and ULONG_MAX
    is 2^64, which means that previously, the SFX_ENDOFSELECTION value was
    being converted from 2^64 to -2^63 when it was returned, which was why
    these loop worked.
    
    So convert SFX_ENDOFSELECTION to SAL_MIN_INT32, so we get a large
    negative value which can never be a valid index, and which works more
    like it did before the regression.
    Also fix as many loops as I can find, to check against
    SFX_ENDOFSELECTION explicitly.
    
    Change-Id: I947d43dbe23a08105be3d849e33d7e774a8a19fa
    Reviewed-on: https://gerrit.libreoffice.org/52934
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/dbaccess/source/ui/browser/unodatbr.cxx 
b/dbaccess/source/ui/browser/unodatbr.cxx
index aff8900255e6..ade472fe704a 100644
--- a/dbaccess/source/ui/browser/unodatbr.cxx
+++ b/dbaccess/source/ui/browser/unodatbr.cxx
@@ -1915,7 +1915,7 @@ void SbaTableQueryBrowser::Execute(sal_uInt16 nId, const 
Sequence< PropertyValue
                             aSelection.realloc(pSelection->GetSelectCount());
                             long nIdx = pSelection->FirstSelected();
                             Any* pSelectionNos = aSelection.getArray();
-                            while (nIdx >= 0)
+                            while (nIdx != SFX_ENDOFSELECTION)
                             {
                                 *pSelectionNos++ <<= 
static_cast<sal_Int32>(nIdx + 1);
                                 nIdx = pSelection->NextSelected();
diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx 
b/dbaccess/source/ui/tabledesign/TEditControl.cxx
index f47a308e3db4..f68fc597d516 100644
--- a/dbaccess/source/ui/tabledesign/TEditControl.cxx
+++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx
@@ -715,7 +715,7 @@ void OTableEditorCtrl::CopyRows()
     std::vector< std::shared_ptr<OTableRow> > vClipboardList;
     vClipboardList.reserve(GetSelectRowCount());
 
-    for( long nIndex=FirstSelectedRow(); nIndex >= 0 && nIndex < 
static_cast<long>(m_pRowList->size()); nIndex=NextSelectedRow() )
+    for( long nIndex=FirstSelectedRow(); nIndex != SFX_ENDOFSELECTION; 
nIndex=NextSelectedRow() )
     {
         pRow = (*m_pRowList)[nIndex];
         OSL_ENSURE(pRow,"OTableEditorCtrl::CopyRows: Row is NULL!");
@@ -814,7 +814,7 @@ void OTableEditorCtrl::DeleteRows()
     long nIndex = FirstSelectedRow();
     nOldDataPos = nIndex;
 
-    while( nIndex >= 0 && nIndex < static_cast<long>(m_pRowList->size()) )
+    while( nIndex != SFX_ENDOFSELECTION )
     {
         // Remove rows
         m_pRowList->erase( m_pRowList->begin()+nIndex );
@@ -1120,7 +1120,7 @@ bool OTableEditorCtrl::IsCopyAllowed()
         // If one of the selected rows is empty, Copy is not possible
          std::shared_ptr<OTableRow>  pRow;
         long nIndex = FirstSelectedRow();
-        while( nIndex >= 0 && nIndex < static_cast<long>(m_pRowList->size()) )
+        while( nIndex != SFX_ENDOFSELECTION )
         {
             pRow = (*m_pRowList)[nIndex];
             if( !pRow->GetActFieldDescr() )
@@ -1278,7 +1278,7 @@ bool OTableEditorCtrl::IsPrimaryKeyAllowed( long /*nRow*/ 
)
     // - DROP is not permitted (see above) and the column is not Required (not 
null flag is not set).
     long nIndex = FirstSelectedRow();
      std::shared_ptr<OTableRow>  pRow;
-    while( nIndex >= 0 && nIndex < static_cast<long>(m_pRowList->size()) )
+    while( nIndex != SFX_ENDOFSELECTION )
     {
         pRow = (*m_pRowList)[nIndex];
         OFieldDescription* pFieldDescr = pRow->GetActFieldDescr();
@@ -1513,7 +1513,7 @@ void OTableEditorCtrl::SetPrimaryKey( bool bSet )
     if( bSet )
     {
         long nIndex = FirstSelectedRow();
-        while( nIndex >= 0 && nIndex < static_cast<long>(m_pRowList->size()) )
+        while( nIndex != SFX_ENDOFSELECTION )
         {
             // Set the key
              std::shared_ptr<OTableRow>  pRow = (*m_pRowList)[nIndex];
diff --git a/include/tools/multisel.hxx b/include/tools/multisel.hxx
index adb6a998fe98..323ab4b355ee 100644
--- a/include/tools/multisel.hxx
+++ b/include/tools/multisel.hxx
@@ -26,7 +26,7 @@
 #include <vector>
 #include <set>
 
-#define SFX_ENDOFSELECTION      SAL_MAX_INT32
+#define SFX_ENDOFSELECTION      SAL_MIN_INT32
 
 class SAL_WARN_UNUSED TOOLS_DLLPUBLIC MultiSelection
 {
diff --git a/reportdesign/source/ui/dlg/GroupsSorting.cxx 
b/reportdesign/source/ui/dlg/GroupsSorting.cxx
index abf80c764880..afd90c6d54be 100644
--- a/reportdesign/source/ui/dlg/GroupsSorting.cxx
+++ b/reportdesign/source/ui/dlg/GroupsSorting.cxx
@@ -231,7 +231,7 @@ uno::Sequence<uno::Any> 
OFieldExpressionControl::fillSelectedGroups()
     sal_Int32 nCount = xGroups->getCount();
     if ( nCount >= 1 )
     {
-        for( long nIndex=FirstSelectedRow(); nIndex >= 0 ; 
nIndex=NextSelectedRow() )
+        for( long nIndex=FirstSelectedRow(); nIndex != SFX_ENDOFSELECTION; 
nIndex=NextSelectedRow() )
         {
             try
             {
@@ -701,7 +701,7 @@ void OFieldExpressionControl::Command(const CommandEvent& 
rEvt)
             {
                 bool bEnable = false;
                 long nIndex = FirstSelectedRow();
-                while( nIndex >= 0 && !bEnable )
+                while( nIndex != SFX_ENDOFSELECTION && !bEnable )
                 {
                     if ( m_aGroupPositions[nIndex] != NO_GROUP )
                         bEnable = true;
@@ -734,7 +734,7 @@ void OFieldExpressionControl::DeleteRows()
         DeactivateCell();
     }
     long nIndex = FirstSelectedRow();
-    if (nIndex == -1)
+    if (nIndex == SFX_ENDOFSELECTION)
     {
         nIndex = GetCurRow();
     }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to