summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/source/ui/dlg/directsql.cxx55
-rw-r--r--dbaccess/source/ui/dlg/directsql.hrc3
-rw-r--r--dbaccess/source/ui/dlg/directsql.src41
-rw-r--r--dbaccess/source/ui/inc/directsql.hxx8
4 files changed, 95 insertions, 12 deletions
diff --git a/dbaccess/source/ui/dlg/directsql.cxx b/dbaccess/source/ui/dlg/directsql.cxx
index 9fbce8060d68..6fdbc0567a84 100644
--- a/dbaccess/source/ui/dlg/directsql.cxx
+++ b/dbaccess/source/ui/dlg/directsql.cxx
@@ -27,6 +27,7 @@
#include <osl/mutex.hxx>
#include <tools/diagnose_ex.h>
#include <rtl/strbuf.hxx>
+#include <com/sun/star/sdbc/XRow.hpp>
//........................................................................
namespace dbaui
@@ -82,6 +83,9 @@ DBG_NAME(DirectSQLDialog)
,m_pSQLHistory(new LargeEntryListBox(this, ModuleRes(LB_HISTORY)))
,m_aStatusFrame (this, ModuleRes(FL_STATUS))
,m_aStatus (this, ModuleRes(ME_STATUS))
+ ,m_pShowOutput(new CheckBox(this, ModuleRes(CB_SHOWOUTPUT)))
+ ,m_aOutputFrame (this, ModuleRes(FL_OUTPUT))
+ ,m_aOutput (this, ModuleRes(ME_OUTPUT))
,m_aButtonSeparator (this, ModuleRes(FL_BUTTONS))
,m_aHelp (this, ModuleRes(PB_HELP))
,m_aClose (this, ModuleRes(PB_CLOSE))
@@ -214,15 +218,51 @@ DBG_NAME(DirectSQLDialog)
::osl::MutexGuard aGuard(m_aMutex);
String sStatus;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > xResultSet;
try
{
// create a statement
Reference< XStatement > xStatement = m_xConnection->createStatement();
OSL_ENSURE(xStatement.is(), "DirectSQLDialog::implExecuteStatement: no statement returned by the connection!");
- // execute it
+ // clear the output box
+ m_aOutput.SetText(String::CreateFromAscii(""));
if (xStatement.is())
- xStatement->execute(_rStatement);
+ {
+ if (::rtl::OUString(_rStatement).toAsciiUpperCase().compareTo(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT")),6)==0 && m_pShowOutput->IsChecked())
+ {
+ // execute it as a query
+ xResultSet = xStatement->executeQuery(_rStatement);
+ // get a handle for the rows
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow > xRow( xResultSet, ::com::sun::star::uno::UNO_QUERY );
+ // work through each of the rows
+ while (xResultSet->next())
+ {
+ // initialise the output line for each row
+ String out = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(""));
+ // work along the columns until that are none left
+ int i = 1;
+ try
+ {
+ for (;;)
+ {
+ // be dumb, treat everything as a string
+ out += xRow->getString(i) + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(","));
+ i++;
+ }
+ }
+ // trap for when we fall off the end of the row
+ catch (const SQLException& e)
+ {
+ }
+ // report the output
+ addOutputText(::rtl::OUString(out));
+ }
+ } else {
+ // execute it
+ xStatement->execute(_rStatement);
+ }
+ }
// successfull
sStatus = String(ModuleRes(STR_COMMAND_EXECUTED_SUCCESSFULLY));
@@ -259,6 +299,17 @@ DBG_NAME(DirectSQLDialog)
}
//--------------------------------------------------------------------
+ void DirectSQLDialog::addOutputText(const String& _rMessage)
+ {
+ String sAppendMessage = _rMessage;
+ sAppendMessage += String::CreateFromAscii("\n");
+
+ String sCompleteMessage = m_aOutput.GetText();
+ sCompleteMessage += sAppendMessage;
+ m_aOutput.SetText(sCompleteMessage);
+ }
+
+ //--------------------------------------------------------------------
void DirectSQLDialog::executeCurrent()
{
CHECK_INVARIANTS("DirectSQLDialog::executeCurrent");
diff --git a/dbaccess/source/ui/dlg/directsql.hrc b/dbaccess/source/ui/dlg/directsql.hrc
index f30717e29017..d590632ace95 100644
--- a/dbaccess/source/ui/dlg/directsql.hrc
+++ b/dbaccess/source/ui/dlg/directsql.hrc
@@ -30,5 +30,8 @@
#define FL_BUTTONS 9
#define PB_HELP 10
#define PB_CLOSE 11
+#define CB_SHOWOUTPUT 12
+#define FL_OUTPUT 13
+#define ME_OUTPUT 14
#endif // _DBACCESS_UI_DIRECTSQL_HRC_
diff --git a/dbaccess/source/ui/dlg/directsql.src b/dbaccess/source/ui/dlg/directsql.src
index 1f200b0bcda3..cb7d50f3c211 100644
--- a/dbaccess/source/ui/dlg/directsql.src
+++ b/dbaccess/source/ui/dlg/directsql.src
@@ -27,7 +27,7 @@
#define BUTTON_SIZE_Y 14
#define WINDOW_SIZE_X 200
-#define WINDOW_SIZE_Y 210 + BUTTON_SIZE_Y + BUTTON_SIZE_Y
+#define WINDOW_SIZE_Y 255 + BUTTON_SIZE_Y + BUTTON_SIZE_Y
ModalDialog DLG_DIRECTSQL
{
@@ -54,30 +54,36 @@ ModalDialog DLG_DIRECTSQL
{
HelpID = "dbaccess:MultiLineEdit:DLG_DIRECTSQL:ME_SQL";
Pos = MAP_APPFONT( 7, 26 );
- Size = MAP_APPFONT( WINDOW_SIZE_X - 14, 80 );
+ Size = MAP_APPFONT( WINDOW_SIZE_X - 14, 60 );
SVLook = TRUE;
Border = TRUE;
TabStop = TRUE;
IgnoreTab = TRUE;
};
+ CheckBox CB_SHOWOUTPUT
+ {
+ Pos = MAP_APPFONT( 7, 89 );
+ Size = MAP_APPFONT( 120, 10 );
+ Text [ en-US ] = "Show output of \"select\" statements";
+ };
PushButton PB_EXECUTE
{
HelpID = "dbaccess:PushButton:DLG_DIRECTSQL:PB_EXECUTE";
- Pos = MAP_APPFONT( WINDOW_SIZE_X - BUTTON_SIZE_X - 7, 109 );
+ Pos = MAP_APPFONT( WINDOW_SIZE_X - BUTTON_SIZE_X - 7, 89 );
Size = MAP_APPFONT( BUTTON_SIZE_X, BUTTON_SIZE_Y );
Text [ en-US ] = "Execute";
DefButton = TRUE;
};
FixedText FT_HISTORY
{
- Pos = MAP_APPFONT( 7, 110 + BUTTON_SIZE_Y + 3 );
+ Pos = MAP_APPFONT( 7, 85 + BUTTON_SIZE_Y + 3 );
Size = MAP_APPFONT( WINDOW_SIZE_X - 14, 8 );
Text [ en-US ] = "Previous commands";
};
ListBox LB_HISTORY
{
HelpID = "dbaccess:ListBox:DLG_DIRECTSQL:LB_HISTORY";
- Pos = MAP_APPFONT( 7, 121 + BUTTON_SIZE_Y + 3 );
+ Pos = MAP_APPFONT( 7, 96 + BUTTON_SIZE_Y + 3 );
Size = MAP_APPFONT( WINDOW_SIZE_X - 14, 14 );
SvLook = TRUE;
DropDown = TRUE;
@@ -85,33 +91,48 @@ ModalDialog DLG_DIRECTSQL
};
FixedLine FL_STATUS
{
- Pos = MAP_APPFONT( 4, 138 + BUTTON_SIZE_Y + 4 );
+ Pos = MAP_APPFONT( 4, 113 + BUTTON_SIZE_Y + 4 );
Size = MAP_APPFONT( WINDOW_SIZE_X - 8, 8 );
Text [ en-US ] = "Status";
};
MultiLineEdit ME_STATUS
{
HelpID = "dbaccess:MultiLineEdit:DLG_DIRECTSQL:ME_STATUS";
- Pos = MAP_APPFONT( 7, 153 + BUTTON_SIZE_Y );
+ Pos = MAP_APPFONT( 7, 128 + BUTTON_SIZE_Y );
Size = MAP_APPFONT( WINDOW_SIZE_X - 14, 41 );
Border = TRUE;
ReadOnly = TRUE;
VScroll = TRUE;
};
+ FixedLine FL_OUTPUT
+ {
+ Pos = MAP_APPFONT( 4, 173 + BUTTON_SIZE_Y + 4 );
+ Size = MAP_APPFONT( WINDOW_SIZE_X - 8, 8 );
+ Text [ en-US ] = "Output";
+ };
+ MultiLineEdit ME_OUTPUT
+ {
+ Pos = MAP_APPFONT( 7, 188 + BUTTON_SIZE_Y );
+ Size = MAP_APPFONT( WINDOW_SIZE_X - 14, 51 );
+ Border = TRUE;
+ ReadOnly = TRUE;
+ VScroll = TRUE;
+ HScroll = TRUE;
+ };
FixedLine FL_BUTTONS
{
- Pos = MAP_APPFONT( 4, 193 + BUTTON_SIZE_Y + 4 );
+ Pos = MAP_APPFONT( 4, 238 + BUTTON_SIZE_Y + 4 );
Size = MAP_APPFONT( WINDOW_SIZE_X - 8, 8 );
};
HelpButton PB_HELP
{
- Pos = MAP_APPFONT( WINDOW_SIZE_X - 7 - BUTTON_SIZE_X - 3 - BUTTON_SIZE_X, 207 + BUTTON_SIZE_Y );
+ Pos = MAP_APPFONT( WINDOW_SIZE_X - 7 - BUTTON_SIZE_X - 3 - BUTTON_SIZE_X, 252 + BUTTON_SIZE_Y );
Size = MAP_APPFONT( BUTTON_SIZE_X, BUTTON_SIZE_Y );
};
PushButton PB_CLOSE
{
HelpID = "dbaccess:PushButton:DLG_DIRECTSQL:PB_CLOSE";
- Pos = MAP_APPFONT( WINDOW_SIZE_X - 7 - BUTTON_SIZE_X, 207 + BUTTON_SIZE_Y );
+ Pos = MAP_APPFONT( WINDOW_SIZE_X - 7 - BUTTON_SIZE_X, 252 + BUTTON_SIZE_Y );
Size = MAP_APPFONT( BUTTON_SIZE_X, BUTTON_SIZE_Y );
Text [ en-US ] = "Close";
};
diff --git a/dbaccess/source/ui/inc/directsql.hxx b/dbaccess/source/ui/inc/directsql.hxx
index e37335fadef9..73258413b52e 100644
--- a/dbaccess/source/ui/inc/directsql.hxx
+++ b/dbaccess/source/ui/inc/directsql.hxx
@@ -33,6 +33,8 @@
#include "moduledbu.hxx"
#include <osl/mutex.hxx>
+#include <svtools/editbrowsebox.hxx>
+
//........................................................................
namespace dbaui
{
@@ -57,6 +59,9 @@ namespace dbaui
ListBox* m_pSQLHistory;
FixedLine m_aStatusFrame;
MultiLineEdit m_aStatus;
+ CheckBox* m_pShowOutput;
+ FixedLine m_aOutputFrame;
+ MultiLineEdit m_aOutput;
FixedLine m_aButtonSeparator;
HelpButton m_aHelp;
PushButton m_aClose;
@@ -106,6 +111,9 @@ namespace dbaui
/// adds a status text to the status list
void addStatusText(const String& _rMessage);
+ /// adds a status text to the output list
+ void addOutputText(const String& _rMessage);
+
#ifdef DBG_UTIL
const sal_Char* impl_CheckInvariants() const;
#endif