[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - sw/source

Michael Stahl mstahl at redhat.com
Thu Sep 22 10:32:05 UTC 2016


 sw/source/ui/dbui/dbinsdlg.cxx |   35 +++++++++++++++++++++++++++++------
 1 file changed, 29 insertions(+), 6 deletions(-)

New commits:
commit 2a439e641890d81a6bb960ccc27135c040e3e991
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Sep 20 11:25:01 2016 +0200

    tdf#101164 sw: Insert Database Columns dialog: expect selection
    
    ... as bookmarks, not raw row indexes.  Bookmarks is what
    FmXGridPeer::getSelection() / FmGridControl::getSelectionBookmarks()
    always produce, and it's unclear to me if there even is a case where
    something other than a bookmark ends up pasted into Writer.
    
    The only case where dbaccess creates a selection that doesn't contain
    bookmarks is in SbaGridControl::implTransferSelectedRows() if no rows
    are selected but i haven't figured out how to reach that state.
    
    (regression in OOo 3.3)
    
    Change-Id: Ib45787bc002447338df775102790843f2cb1dd3b
    (cherry picked from commit bb0e9dd57e7ca0f346ac1102139edaec4e6b3790)
    Reviewed-on: https://gerrit.libreoffice.org/29090
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Lionel Elie Mamane <lionel at mamane.lu>

diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx
index 2ccd096..c487cb1 100644
--- a/sw/source/ui/dbui/dbinsdlg.cxx
+++ b/sw/source/ui/dbui/dbinsdlg.cxx
@@ -28,6 +28,7 @@
 #include <com/sun/star/sdbc/XRow.hpp>
 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
 #include <com/sun/star/sdb/XQueriesSupplier.hpp>
 #include <com/sun/star/sdb/CommandType.hpp>
 #include <com/sun/star/sdb/XColumn.hpp>
@@ -989,6 +990,14 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection,
     Reference< XColumnsSupplier > xColsSupp( xResultSet, UNO_QUERY );
     Reference <XNameAccess> xCols = xColsSupp->getColumns();
 
+    static bool isSelectionBookmarks = true; // TODO is this always true here?
+    uno::Reference<sdbcx::XRowLocate> xRowLocate;
+    if (isSelectionBookmarks)
+    {
+        xRowLocate.set(xResultSet, uno::UNO_QUERY);
+        assert(xRowLocate.is());
+    }
+
     do{                                 // middle checked loop!!
     if( bAsTable )          // Daten als Tabelle einfuegen
     {
@@ -1066,9 +1075,16 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection,
             {
                 if(pSelection)
                 {
-                    sal_Int32 nPos = 0;
-                    pSelection[i] >>= nPos;
-                    bBreak = !xResultSet->absolute(nPos);
+                    if (isSelectionBookmarks)
+                    {
+                        bBreak = !xRowLocate->moveToBookmark(pSelection[i]);
+                    }
+                    else
+                    {
+                        sal_Int32 nPos = 0;
+                        pSelection[i] >>= nPos;
+                        bBreak = !xResultSet->absolute(nPos);
+                    }
                 }
                 else if(!i)
                     bBreak = !xResultSet->first();
@@ -1259,9 +1275,16 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection,
                 {
                     if(pSelection)
                     {
-                        sal_Int32 nPos = 0;
-                        pSelection[i] >>= nPos;
-                        bBreak = !xResultSet->absolute(nPos);
+                        if (isSelectionBookmarks)
+                        {
+                            bBreak = !xRowLocate->moveToBookmark(pSelection[i]);
+                        }
+                        else
+                        {
+                            sal_Int32 nPos = 0;
+                            pSelection[i] >>= nPos;
+                            bBreak = !xResultSet->absolute(nPos);
+                        }
                     }
                     else if(!i)
                         bBreak = !xResultSet->first();


More information about the Libreoffice-commits mailing list