summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2016-09-20 11:25:01 +0200
committerMichael Stahl <mstahl@redhat.com>2016-09-20 14:30:19 +0200
commitbb0e9dd57e7ca0f346ac1102139edaec4e6b3790 (patch)
treeaee3ff6e70b1e47250bbe1b5ffd110cd27097173
parent984790f15d935f986fd0f5ed92f6a63c17eace35 (diff)
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
-rw-r--r--sw/source/ui/dbui/dbinsdlg.cxx35
1 files changed, 29 insertions, 6 deletions
diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx
index c0214de39aec..b9bbe1c3a90d 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>
@@ -994,6 +995,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
{
@@ -1071,9 +1080,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();
@@ -1264,9 +1280,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();