summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorOcke Janssen [oj] <Ocke.Janssen@sun.com>2009-11-25 13:48:21 +0100
committerOcke Janssen [oj] <Ocke.Janssen@sun.com>2009-11-25 13:48:21 +0100
commit9bc02eaf9c7df1cf4408a2af37e9fe9c67acecb1 (patch)
tree25d0cc9d8d7ae2fce5535d9a90195515b17c7d7e /dbaccess
parenta441a0d3f2fdf2507574502612d1565f7752a17a (diff)
dba33d: #i104869# use the interaction handler to delegate UI
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/qa/complex/dbaccess/dbaccess.sce2
-rw-r--r--dbaccess/source/ui/inc/WCopyTable.hxx40
-rw-r--r--dbaccess/source/ui/inc/dbu_misc.hrc4
-rw-r--r--dbaccess/source/ui/inc/dbu_resource.hrc4
-rw-r--r--dbaccess/source/ui/misc/WCPage.cxx17
-rw-r--r--dbaccess/source/ui/misc/WColumnSelect.cxx1
-rw-r--r--dbaccess/source/ui/misc/WCopyTable.cxx101
-rw-r--r--dbaccess/source/ui/misc/WTypeSelect.cxx2
-rw-r--r--dbaccess/source/ui/misc/WizardPages.src10
-rw-r--r--dbaccess/source/ui/uno/copytablewizard.cxx3
10 files changed, 104 insertions, 80 deletions
diff --git a/dbaccess/qa/complex/dbaccess/dbaccess.sce b/dbaccess/qa/complex/dbaccess/dbaccess.sce
index 47387e459ae9..c5fa408ff273 100644
--- a/dbaccess/qa/complex/dbaccess/dbaccess.sce
+++ b/dbaccess/qa/complex/dbaccess/dbaccess.sce
@@ -7,6 +7,6 @@
-o complex.dbaccess.DataSource
-o complex.dbaccess.Parser
-o complex.dbaccess.ApplicationController
-#-o complex.dbaccess.CopyTableWizard
+-o complex.dbaccess.CopyTableWizard
-o complex.dbaccess.UISettings
-o complex.dbaccess.Beamer
diff --git a/dbaccess/source/ui/inc/WCopyTable.hxx b/dbaccess/source/ui/inc/WCopyTable.hxx
index 37d0d870f538..741e6f67e590 100644
--- a/dbaccess/source/ui/inc/WCopyTable.hxx
+++ b/dbaccess/source/ui/inc/WCopyTable.hxx
@@ -31,55 +31,23 @@
#ifndef DBAUI_WIZ_COPYTABLEDIALOG_HXX
#define DBAUI_WIZ_COPYTABLEDIALOG_HXX
-#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
#include <com/sun/star/container/XNameAccess.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
#include <com/sun/star/sdbc/XConnection.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
#include <com/sun/star/sdbc/XResultSet.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATA_HPP_
#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
-#endif
-#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
#include <com/sun/star/beans/XPropertySet.hpp>
-#endif
-#ifndef _COMPHELPER_STLTYPES_HXX_
#include <comphelper/stl_types.hxx>
-#endif
-#ifndef DBAUI_TYPEINFO_HXX
#include "TypeInfo.hxx"
-#endif
-#ifndef _SV_BUTTON_HXX
#include <vcl/button.hxx>
-#endif
-#ifndef _SVT_WIZDLG_HXX
#include <svtools/wizdlg.hxx>
-#endif
-#ifndef DBAUI_DATABASEEXPORT_HXX
#include "DExport.hxx"
-#endif
-#ifndef DBAUI_WIZ_TABBPAGE_HXX
#include "WTabPage.hxx"
-#endif
-#ifndef DBAUI_FIELDDESCRIPTIONS_HXX
#include "FieldDescriptions.hxx"
-#endif
-#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_
#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
-#endif
-#ifndef _SV_LSTBOX_HXX
+#include <com/sun/star/task/XInteractionHandler.hpp>
#include <vcl/lstbox.hxx>
-#endif
-
#include <functional>
namespace dbaui
@@ -299,6 +267,7 @@ namespace dbaui
::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xFormatter;
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xFactory;
+ ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler> m_xInteractionHandler;
String m_sTypeNames; // these type names are the ones out of the resource file
sal_uInt32 m_nPageCount;
@@ -343,7 +312,8 @@ namespace dbaui
const ICopyTableSourceObject& _rSourceObject,
const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xSourceConnection,
const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler>& _xInteractionHandler
);
// used for importing rtf/html sources
@@ -445,6 +415,8 @@ namespace dbaui
void showColumnTypeNotSupported(const ::rtl::OUString& _rColumnName);
void removeColumnNameFromNameMap(const ::rtl::OUString& _sName);
+ void showError(const ::rtl::OUString& _sErrorMesage);
+ void showError(const ::com::sun::star::uno::Any& _aError);
};
}
diff --git a/dbaccess/source/ui/inc/dbu_misc.hrc b/dbaccess/source/ui/inc/dbu_misc.hrc
index 0ee803edec10..6aeb5b1331ab 100644
--- a/dbaccess/source/ui/inc/dbu_misc.hrc
+++ b/dbaccess/source/ui/inc/dbu_misc.hrc
@@ -50,10 +50,12 @@
#define STR_FILE_DOES_NOT_EXIST RID_STR_MISC_START + 13
#define STR_WARNINGS_DURING_CONNECT RID_STR_MISC_START + 14
#define STR_NAMED_OBJECT_ALREADY_EXISTS RID_STR_MISC_START + 15
+#define STR_INVALID_TABLE_NAME RID_STR_MISC_START + 16
+#define STR_INVALID_TABLE_NAME_LENGTH RID_STR_MISC_START + 17
// please adjust checking before insert new strings
-#if STR_NAMED_OBJECT_ALREADY_EXISTS > RID_STR_MISC_END
+#if STR_INVALID_TABLE_NAME_LENGTH > RID_STR_MISC_END
#error Resource-Id Ueberlauf in #file, #line
#endif
diff --git a/dbaccess/source/ui/inc/dbu_resource.hrc b/dbaccess/source/ui/inc/dbu_resource.hrc
index 4686b540e936..76fc76d0abdc 100644
--- a/dbaccess/source/ui/inc/dbu_resource.hrc
+++ b/dbaccess/source/ui/inc/dbu_resource.hrc
@@ -182,13 +182,13 @@
// error boxes
#define ERR_NOREGISTEREDDATASOURCES RID_ERRORBOX_START + 0
-#define ERROR_INVALID_TABLE_NAME_LENGTH RID_ERRORBOX_START + 1
+// free
#define ERR_QRY_CRITERIA_ON_ASTERISK RID_ERRORBOX_START + 2
#define ERR_QRY_ORDERBY_ON_ASTERISK RID_ERRORBOX_START + 3
#define ERR_QRY_AMB_FIELD RID_ERRORBOX_START + 4
// FREE
#define ERR_INVALID_LISTBOX_ENTRY RID_ERRORBOX_START + 6
-#define ERROR_INVALID_TABLE_NAME RID_ERRORBOX_START + 7
+// FREE
#define ERR_NEED_INDEX_FIELDS RID_ERRORBOX_START + 8
#define ERR_QRY_NOSTATEMENT RID_ERRORBOX_START + 9
#define ERR_QRY_NOCRITERIA RID_ERRORBOX_START + 10
diff --git a/dbaccess/source/ui/misc/WCPage.cxx b/dbaccess/source/ui/misc/WCPage.cxx
index 63a910929836..85804dec9d0c 100644
--- a/dbaccess/source/ui/misc/WCPage.cxx
+++ b/dbaccess/source/ui/misc/WCPage.cxx
@@ -227,7 +227,8 @@ sal_Bool OCopyTable::LeavePage()
if ( !aNameCheck.isNameValid( m_edTableName.GetText(), aErrorInfo ) )
{
aErrorInfo.append( SQLExceptionInfo::SQL_CONTEXT, String( ModuleRes( STR_SUGGEST_APPEND_TABLE_DATA ) ) );
- ::dbaui::showError( aErrorInfo, m_pParent, m_pParent->m_xFactory );
+ m_pParent->showError(aErrorInfo.get());
+
return sal_False;
}
@@ -245,7 +246,8 @@ sal_Bool OCopyTable::LeavePage()
sal_Int32 nMaxLength = xMeta->getMaxTableNameLength();
if ( nMaxLength && sTable.getLength() > nMaxLength )
{
- ErrorBox(this, ModuleRes(ERROR_INVALID_TABLE_NAME_LENGTH)).Execute();
+ String sError(ModuleRes(STR_INVALID_TABLE_NAME_LENGTH));
+ m_pParent->showError(sError);
return sal_False;
}
@@ -256,8 +258,7 @@ sal_Bool OCopyTable::LeavePage()
String aInfoString( ModuleRes(STR_WIZ_PKEY_ALREADY_DEFINED) );
aInfoString += String(' ');
aInfoString += String(m_pParent->m_aKeyName);
- InfoBox aNameInfoBox( this, aInfoString );
- aNameInfoBox.Execute();
+ m_pParent->showError(aInfoString);
return sal_False;
}
}
@@ -288,7 +289,8 @@ sal_Bool OCopyTable::LeavePage()
if(!m_pParent->m_sName.getLength())
{
- ErrorBox(this, ModuleRes(ERROR_INVALID_TABLE_NAME)).Execute();
+ String sError(ModuleRes(STR_INVALID_TABLE_NAME));
+ m_pParent->showError(sError);
return sal_False;
}
@@ -367,9 +369,8 @@ sal_Bool OCopyTable::checkAppendData()
if ( !xTable.is() )
{
- ErrorBox( this, ModuleRes( ERROR_INVALID_TABLE_NAME ) ).Execute();
- // TODO: shouldn't this be some kind of showError? In case of the UNO service for this wizard,
- // shouldn't this even be a usage of the service's interaction handler?
+ String sError(ModuleRes(STR_INVALID_TABLE_NAME));
+ m_pParent->showError(sError);
return sal_False;
}
return sal_True;
diff --git a/dbaccess/source/ui/misc/WColumnSelect.cxx b/dbaccess/source/ui/misc/WColumnSelect.cxx
index 69d5c3bad4fd..12173965f739 100644
--- a/dbaccess/source/ui/misc/WColumnSelect.cxx
+++ b/dbaccess/source/ui/misc/WColumnSelect.cxx
@@ -140,6 +140,7 @@ void OWizColumnSelect::Reset()
clearListBox(m_lbOrgColumnNames);
clearListBox(m_lbNewColumnNames);
+ m_pParent->m_mNameMapping.clear();
// insert the source columns in the left listbox
const ODatabaseExport::TColumnVector* pSrcColumns = m_pParent->getSrcVector();
diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx
index 2b664c02f7e2..dd31e3b87cee 100644
--- a/dbaccess/source/ui/misc/WCopyTable.cxx
+++ b/dbaccess/source/ui/misc/WCopyTable.cxx
@@ -46,6 +46,7 @@
/** === begin UNO includes === **/
#include <com/sun/star/sdb/application/CopyTableOperation.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
#include <com/sun/star/sdbc/ColumnValue.hpp>
#include <com/sun/star/sdbc/DataType.hpp>
#include <com/sun/star/sdbc/XResultSet.hpp>
@@ -62,8 +63,10 @@
#include <comphelper/extract.hxx>
#include <comphelper/types.hxx>
+#include <comphelper/interaction.hxx>
#include <connectivity/dbtools.hxx>
#include <connectivity/dbmetadata.hxx>
+#include <connectivity/dbexception.hxx>
#include <rtl/logfile.hxx>
#include <rtl/ustrbuf.hxx>
@@ -80,9 +83,12 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::sdb;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::task;
+using namespace dbtools;
namespace CopyTableOperation = ::com::sun::star::sdb::application::CopyTableOperation;
@@ -566,7 +572,8 @@ namespace
//------------------------------------------------------------------------
OCopyTableWizard::OCopyTableWizard( Window * pParent, const ::rtl::OUString& _rDefaultName, sal_Int16 _nOperation,
const ICopyTableSourceObject& _rSourceObject, const Reference< XConnection >& _xSourceConnection,
- const Reference< XConnection >& _xConnection, const Reference< XMultiServiceFactory >& _rxORB )
+ const Reference< XConnection >& _xConnection, const Reference< XMultiServiceFactory >& _rxORB,
+ const Reference< XInteractionHandler>& _xInteractionHandler)
: WizardDialog( pParent, ModuleRes(WIZ_RTFCOPYTABLE))
,m_pbHelp( this , ModuleRes(PB_HELP))
,m_pbCancel( this , ModuleRes(PB_CANCEL))
@@ -578,6 +585,7 @@ OCopyTableWizard::OCopyTableWizard( Window * pParent, const ::rtl::OUString& _rD
,m_rSourceObject( _rSourceObject )
,m_xFormatter( getNumberFormatter( _xConnection, _rxORB ) )
,m_xFactory(_rxORB)
+ ,m_xInteractionHandler(_xInteractionHandler)
,m_sTypeNames(ModuleRes(STR_TABLEDESIGN_DBFIELDTYPES))
,m_nPageCount(0)
,m_bDeleteSourceColumns(sal_True)
@@ -924,6 +932,7 @@ IMPL_LINK( OCopyTableWizard, ImplOKHdl, OKButton*, EMPTYARG )
OWizTypeSelect* pPage = static_cast<OWizTypeSelect*>(GetPage(3));
if ( pPage )
{
+ m_mNameMapping.clear();
pPage->setDisplayRow(nBreakPos);
ShowPage(3);
return 0;
@@ -935,33 +944,37 @@ IMPL_LINK( OCopyTableWizard, ImplOKHdl, OKButton*, EMPTYARG )
{
ODatabaseExport::TColumns::iterator aFind = ::std::find_if(m_vDestColumns.begin(),m_vDestColumns.end()
,::std::compose1(::std::mem_fun(&OFieldDescription::IsPrimaryKey),::std::select2nd<ODatabaseExport::TColumns::value_type>()));
- if ( aFind == m_vDestColumns.end() )
+ if ( aFind == m_vDestColumns.end() && m_xInteractionHandler.is() )
{
+
String sTitle(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY_HEAD));
String sMsg(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY));
- OSQLMessageBox aBox(this, sTitle,sMsg, WB_YES_NO_CANCEL | WB_DEF_YES);
-
- INT16 nReturn = aBox.Execute();
-
- switch(nReturn )
+ SQLContext aError;
+ aError.Message = sMsg;
+ ::rtl::Reference< ::comphelper::OInteractionRequest > xRequest( new ::comphelper::OInteractionRequest( makeAny( aError ) ) );
+ ::rtl::Reference< ::comphelper::OInteractionApprove > xYes = new ::comphelper::OInteractionApprove;
+ xRequest->addContinuation( xYes.get() );
+ xRequest->addContinuation( new ::comphelper::OInteractionDisapprove );
+ ::rtl::Reference< ::comphelper::OInteractionAbort > xAbort = new ::comphelper::OInteractionAbort;
+ xRequest->addContinuation( xAbort.get() );
+
+ m_xInteractionHandler->handle( xRequest.get() );
+
+ if ( xYes->wasSelected() )
{
- case RET_YES:
- {
- OCopyTable* pPage = static_cast<OCopyTable*>(GetPage(0));
- m_bCreatePrimaryKeyColumn = sal_True;
- m_aKeyName = pPage->GetKeyName();
- if ( !m_aKeyName.getLength() )
- m_aKeyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ID" ) );
- m_aKeyName = createUniqueName( m_aKeyName );
- sal_Int32 nBreakPos2 = 0;
- CheckColumns(nBreakPos2);
- break;
- }
- case RET_CANCEL:
- ShowPage(3);
- return 0;
- default:
- ;
+ OCopyTable* pPage = static_cast<OCopyTable*>(GetPage(0));
+ m_bCreatePrimaryKeyColumn = sal_True;
+ m_aKeyName = pPage->GetKeyName();
+ if ( !m_aKeyName.getLength() )
+ m_aKeyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ID" ) );
+ m_aKeyName = createUniqueName( m_aKeyName );
+ sal_Int32 nBreakPos2 = 0;
+ CheckColumns(nBreakPos2);
+ }
+ else if ( xAbort->wasSelected() )
+ {
+ ShowPage(3);
+ return 0;
}
}
}
@@ -1601,6 +1614,22 @@ TOTypeInfoSP OCopyTableWizard::convertType(const TOTypeInfoSP& _pType,sal_Bool&
if ( supportsType(DataType::CLOB,nDefaultType) )
break;
break;
+ case DataType::BINARY:
+ if ( supportsType(DataType::VARBINARY,nDefaultType) )
+ break;
+ break;
+ case DataType::VARBINARY:
+ if ( supportsType(DataType::LONGVARBINARY,nDefaultType) )
+ break;
+ break;
+ case DataType::LONGVARBINARY:
+ if ( supportsType(DataType::BLOB,nDefaultType) )
+ break;
+ if ( supportsType(DataType::LONGVARCHAR,nDefaultType) )
+ break;
+ if ( supportsType(DataType::CLOB,nDefaultType) )
+ break;
+ break;
default:
nDefaultType = DataType::VARCHAR;
}
@@ -1646,7 +1675,27 @@ void OCopyTableWizard::showColumnTypeNotSupported(const ::rtl::OUString& _rColum
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::showColumnTypeNotSupported" );
String sMessage( ModuleRes( STR_UNKNOWN_TYPE_FOUND ) );
sMessage.SearchAndReplaceAscii("#1",_rColumnName);
-
- OSQLWarningBox( this, sMessage ).Execute();
+ showError(sMessage);
}
//-------------------------------------------------------------------------------
+void OCopyTableWizard::showError(const ::rtl::OUString& _sErrorMesage)
+{
+ SQLExceptionInfo aInfo(_sErrorMesage);
+ showError(aInfo.get());
+}
+//-------------------------------------------------------------------------------
+void OCopyTableWizard::showError(const Any& _aError)
+{
+ if ( _aError.hasValue() && m_xInteractionHandler.is() )
+ {
+ try
+ {
+ ::rtl::Reference< ::comphelper::OInteractionRequest > xRequest( new ::comphelper::OInteractionRequest( _aError ) );
+ m_xInteractionHandler->handle( xRequest.get() );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+} \ No newline at end of file
diff --git a/dbaccess/source/ui/misc/WTypeSelect.cxx b/dbaccess/source/ui/misc/WTypeSelect.cxx
index ceeb058528df..a964b0e13d38 100644
--- a/dbaccess/source/ui/misc/WTypeSelect.cxx
+++ b/dbaccess/source/ui/misc/WTypeSelect.cxx
@@ -178,7 +178,7 @@ void OWizTypeSelectControl::CellModified(long nRow, sal_uInt16 nColId )
{
String strMessage = String(ModuleRes(STR_TABLEDESIGN_DUPLICATE_NAME));
strMessage.SearchAndReplaceAscii("$column$", sNewName);
- OSQLWarningBox( this, strMessage ).Execute();
+ pWiz->showError(strMessage);
pCurFieldDescr->SetName(sName);
DisplayData(pCurFieldDescr);
static_cast<OWizTypeSelect*>(GetParent())->setDuplicateName(sal_True);
diff --git a/dbaccess/source/ui/misc/WizardPages.src b/dbaccess/source/ui/misc/WizardPages.src
index 638feb92e54c..329f08b222d9 100644
--- a/dbaccess/source/ui/misc/WizardPages.src
+++ b/dbaccess/source/ui/misc/WizardPages.src
@@ -552,20 +552,18 @@ String STR_COPYTABLE_TITLE_COPY
Text [ en-US ] = "Copy table" ;
};
-ErrorBox ERROR_INVALID_TABLE_NAME
+String STR_INVALID_TABLE_NAME
{
- Buttons = WB_OK;
- Message [ en-US ] = "This table name is not valid in the current database.";
+ Text [ en-US ] = "This table name is not valid in the current database.";
};
String STR_SUGGEST_APPEND_TABLE_DATA
{
Text [ en-US ] = "Choose the option 'Append data' on the first page to append data to an existing table.";
};
-ErrorBox ERROR_INVALID_TABLE_NAME_LENGTH
+String STR_INVALID_TABLE_NAME_LENGTH
{
- Buttons = WB_OK;
- Message [ en-US ] = "Please change the table name. It is too long.";
+ Text [ en-US ] = "Please change the table name. It is too long.";
};
Image IMG_SORTUP_H
diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx
index ce79281f0cac..159d447ae554 100644
--- a/dbaccess/source/ui/uno/copytablewizard.cxx
+++ b/dbaccess/source/ui/uno/copytablewizard.cxx
@@ -1578,7 +1578,8 @@ Dialog* CopyTableWizard::createDialog( Window* _pParent )
*m_pSourceObject,
m_xSourceConnection.getTyped(),
m_xDestConnection.getTyped(),
- m_aContext.getLegacyServiceFactory()
+ m_aContext.getLegacyServiceFactory(),
+ m_xInteractionHandler
);
impl_attributesToDialog_nothrow( *pWizard );