diff options
Diffstat (limited to 'dbaccess/source/ui/dlg')
114 files changed, 30765 insertions, 0 deletions
diff --git a/dbaccess/source/ui/dlg/AdabasPage.hrc b/dbaccess/source/ui/dlg/AdabasPage.hrc new file mode 100644 index 000000000000..a36dbb25da27 --- /dev/null +++ b/dbaccess/source/ui/dlg/AdabasPage.hrc @@ -0,0 +1,50 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef DBAUI_ADABASPAGE_HRC +#define DBAUI_ADABASPAGE_HRC + +#define FT_CACHE_SIZE 1 +#define FT_DATA_INCREMENT 2 +#define FT_CTRLPASSWORD 3 +#define FT_CTRLUSERNAME 4 + + +#define NF_DATA_INCREMENT 1 +#define NF_CACHE_SIZE 2 + +#define CB_SHUTDB 1 + +#define FL_1 1 + +#define PB_STAT 1 + +#define ET_CTRLPASSWORD 1 +#define ET_CTRLUSERNAME 2 + +#endif // DBAUI_ADABASPAGE_HRC + + diff --git a/dbaccess/source/ui/dlg/AdabasStat.cxx b/dbaccess/source/ui/dlg/AdabasStat.cxx new file mode 100644 index 000000000000..a17de64c5891 --- /dev/null +++ b/dbaccess/source/ui/dlg/AdabasStat.cxx @@ -0,0 +1,333 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif +#ifndef _CPPUHELPER_EXC_HLP_HXX_ +#include <cppuhelper/exc_hlp.hxx> +#endif +#ifndef TOOLS_DIAGNOSE_EX_H +#include <tools/diagnose_ex.h> +#endif +#ifndef _DBAUI_ADASTAT_HXX_ +#include "AdabasStat.hxx" +#endif +#ifndef _COMPHELPER_TYPES_HXX_ +#include <comphelper/types.hxx> +#endif +#ifndef _COM_SUN_STAR_SDBC_XSTATEMENT_HPP_ +#include <com/sun/star/sdbc/XStatement.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef DBAUI_ADABASSTAT_HRC +#include "AdabasStat.hrc" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef DBAUI_TOOLS_HXX +#include "UITools.hxx" +#endif +#ifndef _CONNECTIVITY_DBTOOLS_HXX_ +#include <connectivity/dbtools.hxx> +#endif +#ifndef _DBAUI_SQLMESSAGE_HXX_ +#include "sqlmessage.hxx" +#endif + +using namespace dbaui; +DBG_NAME(OAdabasStatistics) +namespace dbaui +{ + using namespace dbtools; + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::beans; + using namespace ::com::sun::star::sdbc; + using namespace ::com::sun::star::lang; + + + +OAdabasStatistics::OAdabasStatistics( Window* pParent, + const ::rtl::OUString& _rUser, + const Reference< ::com::sun::star::sdbc::XConnection >& _xCurrentConnection, + const Reference< XMultiServiceFactory >& _xFactory) + : ModalDialog( pParent, ModuleRes(DLG_ADABASSTAT) ) + ,m_FL_FILES( this , ModuleRes(FL_FILES)) + ,m_FT_SYSDEVSPACE( this , ModuleRes(FT_SYSDEVSPACE)) + ,m_ET_SYSDEVSPACE( this , STR_ADABAS_HELP_SYSDEVSPACE,ModuleRes(ET_SYSDEVSPACE)) + ,m_FT_TRANSACTIONLOG( this , ModuleRes(FT_TRANSACTIONLOG)) + ,m_ET_TRANSACTIONLOG( this , STR_ADABAS_HELP_TRANSACT,ModuleRes(ET_TRANSACTIONLOG)) + ,m_FT_DATADEVSPACE( this , ModuleRes(FT_DATADEVSPACE)) + ,m_LB_DATADEVS( this , STR_ADABAS_HELP_DATADEVSPACES,ModuleRes(LB_DATADEVS)) + ,m_FL_SIZES( this , ModuleRes(FL_SIZES)) + ,m_FT_SIZE( this , ModuleRes(FT_SIZE)) + ,m_ET_SIZE( this , STR_ADABAS_HELP_SIZE,ModuleRes(ET_SIZE)) + ,m_FT_FREESIZE( this , ModuleRes(FT_FREESIZE)) + ,m_ET_FREESIZE( this , STR_ADABAS_HELP_FREESIZE,ModuleRes(ET_FREESIZE)) + ,m_FT_MEMORYUSING( this , ModuleRes(FT_MEMORYUSING)) + ,m_ET_MEMORYUSING( this , STR_ADABAS_HELP_MEMORYUSING,ModuleRes(ET_MEMORYUSING)) + ,m_PB_OK( this , ModuleRes(PB_OK)) + ,m_xConnection(_xCurrentConnection) + ,m_bErrorShown(sal_False) +{ + DBG_CTOR(OAdabasStatistics,NULL); + + FreeResource(); + + DBG_ASSERT(m_xConnection.is(),"No connection"); + if(m_xConnection.is()) + { + Reference<XStatement> xStmt; + Reference<XResultSet> xRes; + + sal_Bool bCanSelect = sal_False; + ::rtl::OUString aStmt; + ::rtl::OUString sSchema = _rUser.toAsciiUpperCase(); + + Reference<XDatabaseMetaData> xMetaData; + // first read the sizes + try + { + xMetaData = m_xConnection->getMetaData(); + bCanSelect = checkSystemTable(::rtl::OUString::createFromAscii("SERVERDBSTATISTICS"),sSchema); + + if(bCanSelect) + { + aStmt = ::rtl::OUString::createFromAscii("SELECT SERVERDBSIZE, UNUSEDPAGES FROM "); + + aStmt += ::dbtools::quoteTableName(xMetaData,sSchema,::dbtools::eInDataManipulation); + aStmt += ::rtl::OUString::createFromAscii(".\"SERVERDBSTATISTICS\""); + + xStmt = m_xConnection->createStatement(); + xRes = xStmt->executeQuery(aStmt); + + + Reference<XRow> xRow(xRes,UNO_QUERY); + // first the db sizes + if(xRes.is() && xRes->next()) + { + double nUsedPages = xRow->getInt(1) / 256; + double nFreePages = xRow->getInt(2) / 256; + + m_ET_SIZE.SetText(::rtl::OUString::valueOf((INT32)nUsedPages)); + m_ET_FREESIZE.SetText(::rtl::OUString::valueOf((INT32)nFreePages)); + m_ET_MEMORYUSING.SetValue(static_cast<sal_Int32>(((nUsedPages-nFreePages)/nUsedPages)*100)); + } + else + showError(); + + xRow = NULL; + } + else + showError(); + } + catch(const SQLException& ) + { + ::dbaui::showError( SQLExceptionInfo( ::cppu::getCaughtException() ), pParent, _xFactory ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + try + { + ::comphelper::disposeComponent(xStmt); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + // now fill the datadev spaces + if(bCanSelect) + { + try + { + bCanSelect = checkSystemTable(::rtl::OUString::createFromAscii("DATADEVSPACES"),sSchema); + + if(bCanSelect) + { + // then the db files + aStmt = ::rtl::OUString::createFromAscii("SELECT DEVSPACENAME FROM "); + aStmt += ::dbtools::quoteTableName(xMetaData,sSchema,::dbtools::eInDataManipulation); + aStmt += ::rtl::OUString::createFromAscii(".\"DATADEVSPACES\""); + xStmt = m_xConnection->createStatement(); + xRes = xStmt->executeQuery(aStmt); + + Reference<XRow> xRow(xRes,UNO_QUERY); + while(xRes.is() && xRes->next()) + { + m_LB_DATADEVS.InsertEntry(xRow->getString(1)); + } + if(!m_LB_DATADEVS.GetEntryCount()) + showError(); + } + else + showError(); + } + catch(const SQLException& e) + { + ::dbaui::showError(SQLExceptionInfo(e),pParent,_xFactory); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + try + { + ::comphelper::disposeComponent(xStmt); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + // now fill the sysdatadev spaces + if(bCanSelect) + { + try + { + bCanSelect = checkSystemTable(::rtl::OUString::createFromAscii("CONFIGURATION"),sSchema); + + if(bCanSelect) + { + aStmt = ::rtl::OUString::createFromAscii("SELECT * FROM "); + aStmt += ::dbtools::quoteTableName(xMetaData,sSchema,::dbtools::eInDataManipulation); + aStmt += ::rtl::OUString::createFromAscii(".CONFIGURATION WHERE DESCRIPTION LIKE 'SYS%DEVSPACE%NAME'"); + xStmt = m_xConnection->createStatement(); + xRes = xStmt->executeQuery(aStmt); + if(xRes.is() && xRes->next()) + { + Reference<XRow> xRow(xRes,UNO_QUERY); + m_ET_SYSDEVSPACE.SetText(xRow->getString(2)); + } + else + showError(); + + aStmt = ::rtl::OUString::createFromAscii("SELECT * FROM "); + aStmt += ::dbtools::quoteTableName(xMetaData,sSchema,::dbtools::eInDataManipulation); + aStmt += ::rtl::OUString::createFromAscii(".CONFIGURATION WHERE DESCRIPTION = 'TRANSACTION LOG NAME'"); + xRes = xStmt->executeQuery(aStmt); + if(xRes.is() && xRes->next()) + { + Reference<XRow> xRow(xRes,UNO_QUERY); + m_ET_TRANSACTIONLOG.SetText(xRow->getString(2)); + } + else + showError(); + } + else + showError(); + } + catch(const SQLException& e) + { + ::dbaui::showError(SQLExceptionInfo(e),pParent,_xFactory); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + try + { + ::comphelper::disposeComponent(xStmt); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + } + } + + m_ET_SYSDEVSPACE.SetSpecialReadOnly(sal_True); + m_ET_TRANSACTIONLOG.SetSpecialReadOnly(sal_True); + m_LB_DATADEVS.SetSpecialReadOnly(sal_True); + m_ET_SIZE.SetSpecialReadOnly(sal_True); + m_ET_FREESIZE.SetSpecialReadOnly(sal_True); + m_ET_MEMORYUSING.SetSpecialReadOnly(sal_True); +} +//------------------------------------------------------------------------ +OAdabasStatistics::~OAdabasStatistics() +{ + DBG_DTOR(OAdabasStatistics,NULL); +} +// ----------------------------------------------------------------------------- +sal_Bool OAdabasStatistics::checkSystemTable(const ::rtl::OUString& _rsSystemTable, ::rtl::OUString& _rsSchemaName ) +{ + sal_Bool bCanSelect = sal_False; + Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData(); + if ( xMeta.is() ) + { + Reference<XResultSet> xRes = xMeta->getTablePrivileges(Any(),::rtl::OUString::createFromAscii("%"), _rsSystemTable); + if(xRes.is()) + { + Reference<XRow> xRow(xRes,UNO_QUERY); + static const ::rtl::OUString sSelect = ::rtl::OUString::createFromAscii("SELECT"); + // first the db sizes + while( xRow.is() && xRes->next() ) + { + _rsSchemaName = xRow->getString(2); + if(sSelect == xRow->getString(6) && !xRow->wasNull()) + { + bCanSelect = sal_True; + break; + } + } + ::comphelper::disposeComponent(xRes); + } + } + + return bCanSelect; +} +// ----------------------------------------------------------------------------- +void OAdabasStatistics::showError() +{ + if(!m_bErrorShown) + { + OSQLMessageBox aMsg(GetParent(),GetText(),String(ModuleRes(STR_ADABAS_ERROR_SYSTEMTABLES))); + aMsg.Execute(); + m_bErrorShown = sal_True; + } +} +// ----------------------------------------------------------------------------- +} + diff --git a/dbaccess/source/ui/dlg/AdabasStat.hrc b/dbaccess/source/ui/dlg/AdabasStat.hrc new file mode 100644 index 000000000000..32734ea9075a --- /dev/null +++ b/dbaccess/source/ui/dlg/AdabasStat.hrc @@ -0,0 +1,52 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef DBAUI_ADABASSTAT_HRC +#define DBAUI_ADABASSTAT_HRC + + +#define FT_SYSDEVSPACE 1 +#define FT_TRANSACTIONLOG 2 +#define FT_DATADEVSPACE 3 +#define FT_SIZE 4 +#define FT_FREESIZE 5 +#define FT_MEMORYUSING 6 + +#define ET_SYSDEVSPACE 1 +#define ET_TRANSACTIONLOG 2 +#define ET_MEMORYUSING 3 +#define ET_SIZE 4 +#define ET_FREESIZE 5 + +#define LB_DATADEVS 1 + +#define PB_OK 1 + +#define FL_FILES 1 +#define FL_SIZES 2 + + +#endif // DBAUI_ADABASSTAT_HRC diff --git a/dbaccess/source/ui/dlg/AdabasStat.hxx b/dbaccess/source/ui/dlg/AdabasStat.hxx new file mode 100644 index 000000000000..2f222462d4df --- /dev/null +++ b/dbaccess/source/ui/dlg/AdabasStat.hxx @@ -0,0 +1,98 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _DBAUI_ADASTAT_HXX_ +#define _DBAUI_ADASTAT_HXX_ + +#ifndef _SV_FIXED_HXX +#include <vcl/fixed.hxx> +#endif +#ifndef _SV_BUTTON_HXX +#include <vcl/button.hxx> +#endif +#ifndef _SV_DIALOG_HXX +#include <vcl/dialog.hxx> +#endif +#ifndef DBAUI_FIELDCONTROLS_HXX +#include "FieldControls.hxx" +#endif +#ifndef _PRGSBAR_HXX +#include <svtools/prgsbar.hxx> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ +#include <com/sun/star/sdbc/XConnection.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif + + +namespace dbaui +{ + //======================================================================== + // shows some statistics + //======================================================================== + class OAdabasStatistics : public ModalDialog + { + protected: + + FixedLine m_FL_FILES; + FixedText m_FT_SYSDEVSPACE; + OPropEditCtrl m_ET_SYSDEVSPACE; + FixedText m_FT_TRANSACTIONLOG; + OPropEditCtrl m_ET_TRANSACTIONLOG; + FixedText m_FT_DATADEVSPACE; + OPropListBoxCtrl m_LB_DATADEVS; + FixedLine m_FL_SIZES; + FixedText m_FT_SIZE; + OPropEditCtrl m_ET_SIZE; + FixedText m_FT_FREESIZE; + OPropEditCtrl m_ET_FREESIZE; + FixedText m_FT_MEMORYUSING; + OPropNumericEditCtrl m_ET_MEMORYUSING; + + OKButton m_PB_OK; + + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > + m_xConnection; /// valid as long as the page is active + sal_Bool m_bErrorShown; // true when we shown already the error + + // check if the given table is accessable by the connected user + sal_Bool checkSystemTable(const ::rtl::OUString& _rsSystemTable, ::rtl::OUString& _rsSchemaName ); + void showError(); + + public: + OAdabasStatistics( Window* pParent, + const ::rtl::OUString& _rUser, + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xCurrentConnection, + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory); + ~OAdabasStatistics(); + + }; +} +#endif //_DBAUI_ADASTAT_HXX_ + + diff --git a/dbaccess/source/ui/dlg/AdabasStat.src b/dbaccess/source/ui/dlg/AdabasStat.src new file mode 100644 index 000000000000..ff29ac12383d --- /dev/null +++ b/dbaccess/source/ui/dlg/AdabasStat.src @@ -0,0 +1,231 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBAUI_ADABASSTAT_HRC +#include "AdabasStat.hrc" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif + +#define WINDOW_SIZE_X 260 +#define WINDOW_SIZE_Y 190 + +ModalDialog DLG_ADABASSTAT +{ + OutputSize = TRUE ; + Moveable = TRUE ; + Closeable = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ; + + FixedLine FL_FILES + { + Pos = MAP_APPFONT ( 6 , 3 ) ; + Size = MAP_APPFONT ( WINDOW_SIZE_X - 12, 8 ) ; + Text [ en-US ] = "Database files"; + }; + + FixedText FT_SYSDEVSPACE + { + Pos = MAP_APPFONT ( 12 , 14 ) ; + Size = MAP_APPFONT ( 102 , 10 ) ; + Text [ en-US ] = "S~YSDEVSPACE:"; + }; + + Edit ET_SYSDEVSPACE + { + Border = TRUE ; + Pos = MAP_APPFONT ( 120 , 14 ) ; + Size = MAP_APPFONT ( 128 , 12 ) ; + TabStop = TRUE ; + ReadOnly = TRUE; + }; + + FixedText FT_TRANSACTIONLOG + { + Pos = MAP_APPFONT ( 12 , 32 ) ; + Size = MAP_APPFONT ( 102 , 10 ) ; + Text [ en-US ] = "~TRANSACTIONLOG:"; + }; + + Edit ET_TRANSACTIONLOG + { + Border = TRUE ; + Pos = MAP_APPFONT ( 120 , 31 ) ; + Size = MAP_APPFONT ( 128 , 12 ) ; + TabStop = TRUE ; + ReadOnly = TRUE; + }; + + FixedText FT_DATADEVSPACE + { + Pos = MAP_APPFONT ( 12 , 49 ) ; + Size = MAP_APPFONT ( 102 , 10 ) ; + Text [ en-US ] = "DATAD~EVSPACE:"; + }; + + ListBox LB_DATADEVS + { + Border = TRUE ; + Pos = MAP_APPFONT ( 120 , 48 ) ; + Size = MAP_APPFONT ( 128 , 42 ) ; + TabStop = TRUE; + AutoHScroll = TRUE; + VScroll = TRUE; + HScroll = TRUE; + }; + FixedLine FL_SIZES + { + Pos = MAP_APPFONT ( 6 , 99 ) ; + Size = MAP_APPFONT ( WINDOW_SIZE_X - 12 , 8 ) ; + Text [ en-US ] = "Database sizes"; + }; + + FixedText FT_SIZE + { + Pos = MAP_APPFONT ( 12 , 110 ) ; + Size = MAP_APPFONT ( 102 , 10 ) ; + Text [ en-US ] = "S~ize (MB):"; + }; + + Edit ET_SIZE + { + Border = TRUE ; + Pos = MAP_APPFONT ( 120 , 109 ) ; + Size = MAP_APPFONT ( 60 , 12 ) ; + TabStop = TRUE ; + ReadOnly = TRUE; + }; + + FixedText FT_FREESIZE + { + Pos = MAP_APPFONT ( 12 , 127 ) ; + Size = MAP_APPFONT ( 102 , 10 ) ; + Text [ en-US ] = "~Free memory space (MB):"; + }; + + Edit ET_FREESIZE + { + Border = TRUE ; + Pos = MAP_APPFONT ( 120 , 126 ) ; + Size = MAP_APPFONT ( 60 , 12 ) ; + TabStop = TRUE ; + ReadOnly = TRUE; + }; + + FixedText FT_MEMORYUSING + { + Pos = MAP_APPFONT ( 12 , 144 ) ; + Size = MAP_APPFONT ( 102 , 10 ) ; + Text [ en-US ] = "~Memory utilization (in %):"; + }; + + NumericField ET_MEMORYUSING + { + Border = TRUE ; + Pos = MAP_APPFONT ( 120 , 144 ) ; + Size = MAP_APPFONT ( 60 , 12 ) ; + TabStop = TRUE ; + ReadOnly = TRUE; + }; + + OKButton PB_OK + { + Pos = MAP_APPFONT ( WINDOW_SIZE_X - 56,WINDOW_SIZE_Y - 20 ) ; + Size = MAP_APPFONT ( 50, 14 ) ; + TabStop = TRUE ; + DefButton = TRUE ; + }; + + Text [ en-US ] = "Database Statistics"; +}; + +String STR_ADABAS_HELP_SYSDEVSPACE +{ + Text [ en-US ] = "Contains the system tables"; +}; + +String STR_ADABAS_HELP_TRANSACT +{ + Text [ en-US ] = "Contains information about transaction"; +}; + +String STR_ADABAS_HELP_DATADEVSPACES +{ + Text [ en-US ] = "Contains all data files"; +}; + +String STR_ADABAS_HELP_SIZE +{ + Text [ en-US ] = "Total size of the database files"; +}; + +String STR_ADABAS_HELP_FREESIZE +{ + Text [ en-US ] = "Currently available space before a new datadev file is created."; +}; + +String STR_ADABAS_HELP_MEMORYUSING +{ + Text [ en-US ] = "Currently used memory"; +}; + +String STR_ADABAS_ERROR_SYSTEMTABLES +{ + Text [ en-US ] = "No information could be displayed because no access rights exist for the required system tables."; +}; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dbaccess/source/ui/dlg/AutoControls.src b/dbaccess/source/ui/dlg/AutoControls.src new file mode 100644 index 000000000000..1bfe3c0233a9 --- /dev/null +++ b/dbaccess/source/ui/dlg/AutoControls.src @@ -0,0 +1,102 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBAUI_AUTOCONTROLS_HRC_ +#include "AutoControls.hrc" +#endif + +String STR_DBASE_PATH_OR_FILE +{ + Text[ en-US ] = "Path to the dBASE files"; +}; + +String STR_FLAT_PATH_OR_FILE +{ + Text[ en-US ] = "Path to the text files"; +}; + +String STR_CALC_PATH_OR_FILE +{ + Text[ en-US ] = "Path to the spreadsheet document"; +}; + +String STR_NAME_OF_ODBC_DATASOURCE +{ + Text[ en-US ] = "Name of the ODBC data source on your system"; +}; + +String STR_MYSQL_DATABASE_NAME +{ + Text[ en-US ] = "Name of the MySQL database"; +}; + +String STR_ORACLE_DATABASE_NAME +{ + Text[ en-US ] = "Name of the Oracle database"; +}; + +String STR_ADABAS_DATABASE_NAME +{ + Text[ en-US ] = "Name of the Adabas D database"; +}; + +String STR_MSACCESS_MDB_FILE +{ + Text[ en-US ] = "Microsoft Access database file"; +}; + + +String STR_NO_ADDITIONAL_SETTINGS +{ + Text[ en-US ] = "No more settings are necessary. To verify that the connection is working, click the '%test' button."; +}; + + +String STR_COMMONURL +{ + Text [ en-US ] = "Datasource URL" ; +}; + +String STR_HOSTNAME +{ + Text[ en-US ] = "~Host name"; +}; +String STR_MOZILLA_PROFILE_NAME +{ + Text[ en-US ] = "~Mozilla profile name"; +}; +String STR_THUNDERBIRD_PROFILE_NAME +{ + Text[ en-US ] = "~Thunderbird profile name"; +}; + + +// ------------------------------------------------------------------------------------------------- + + + + diff --git a/dbaccess/source/ui/dlg/AutoControls_tmpl.hrc b/dbaccess/source/ui/dlg/AutoControls_tmpl.hrc new file mode 100644 index 000000000000..425e713094f3 --- /dev/null +++ b/dbaccess/source/ui/dlg/AutoControls_tmpl.hrc @@ -0,0 +1,516 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifndef _DBAUI_AUTOCONTROLS_HRC_ +#define _DBAUI_AUTOCONTROLS_HRC_ + + +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif + +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif + +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif + + +#define CHECKBOX_HEIGHT 8 +#define FIXEDTEXT_HEIGHT 8 +#define RELATED_CONTROLS 4 +#define UNRELATED_CONTROLS 7 +#define EDIT_HEIGHT 12 +#define EDIT_X 101 + +#define FT_AUTOJDBCDRIVERCLASS 80 +#define FT_AUTOFIELDSEPARATOR 81 +#define FT_AUTOTEXTSEPARATOR 82 +#define FT_AUTODECIMALSEPARATOR 83 +#define FT_AUTOTHOUSANDSSEPARATOR 84 +#define FT_AUTOPORTNUMBER 85 +#define FT_AUTOPORTNUMBERDEFAULT 86 +#define FT_AUTOBASEDN 87 +#define FT_AUTOHOSTNAME 88 +#define FT_AUTOBROWSEURL 89 +#define FT_AUTODATABASENAME 90 +#define FT_AUTOWIZARDHELPTEXT 91 +#define FT_AUTOWIZARDHEADER 92 +#define FT_AUTOEXTENSIONHEADER 93 +#define FT_AUTOOWNEXTENSIONAPPENDIX 94 +#define FT_CHARSET 95 +#define FT_SOCKET 96 + +#define FL_AUTOSEPARATOR2 80 +#define FL_DATACONVERT 81 +#define FL_SEPARATOR1 82 + +#define CB_AUTOHEADER 80 + +#define PB_AUTOTESTDRIVERCLASS 80 +#define PB_AUTOBROWSEURL 81 + +#define CM_AUTOFIELDSEPARATOR 80 +#define CM_AUTOTEXTSEPARATOR 81 +#define CM_AUTODECIMALSEPARATOR 82 +#define CM_AUTOTHOUSANDSSEPARATOR 83 + +#define NF_AUTOPORTNUMBER 80 + +#define ET_AUTOBASEDN 80 +#define ET_AUTOHOSTNAME 81 +#define ET_AUTODATABASENAME 82 +#define ET_AUTOBROWSEURL 83 +#define ET_AUTOJDBCDRIVERCLASS 84 +#define ET_AUTOOWNEXTENSION 85 +#define ET_SOCKET 86 + +#define RB_AUTOACCESSCTEXTFILES 80 +#define RB_AUTOACCESSCCSVFILES 81 +#define RB_AUTOACCESSOTHERS 82 + +#define LB_CHARSET 80 + +#define STR_AUTOFIELDSEPARATORLIST 100 +#define STR_AUTOTEXTSEPARATORLIST 101 +#define STR_AUTOTEXT_FIELD_SEP_NONE 102 +#define STR_AUTODELIMITER_MISSING 103 +#define STR_AUTODELIMITER_MUST_DIFFER 104 +#define STR_AUTONO_WILDCARDS 105 + + +#define AUTO_WIZARDHELPTEXT( AUTO_LINECOUNT ) \ + FixedText FT_AUTOWIZARDHEADER \ + { \ + Pos = MAP_APPFONT ( START_X , 8 ) ; \ + Size = MAP_APPFONT ( (WIZARD_PAGE_X - START_X) - 12 , 2 * FIXEDTEXT_HEIGHT ) ; \ + Text[ en-US ] = ""; \ + WordBreak = TRUE; \ + }; \ + \ + FixedText FT_AUTOWIZARDHELPTEXT \ + { \ + Pos = MAP_APPFONT ( START_X , INIT_Y ) ; \ + Size = MAP_APPFONT ( WIZARD_PAGE_X - START_X - 6 , AUTO_LINECOUNT * FIXEDTEXT_HEIGHT ) ; \ + Text[ en-US ] = ""; \ + WordBreak = TRUE; \ + }; + +// ------------------------------------------------------------------------------------------------- + + +#define AUTO_BROWSECONTROLGROUP( AUTO_X, AUTO_Y, AUTOPAGE_X, AUTO_HID) \ + FixedText FT_AUTOBROWSEURL { \ + Pos = MAP_APPFONT ( AUTO_X , AUTO_Y ) ; \ + Size = MAP_APPFONT ( AUTOPAGE_X - AUTO_X - 6 , FIXEDTEXT_HEIGHT ) ; \ + Text[ en-US ] = ""; \ + }; \ + \ + \ + Edit ET_AUTOBROWSEURL \ + { \ + Pos = MAP_APPFONT ( AUTO_X , AUTO_Y + FIXEDTEXT_HEIGHT + 3) ; \ + Size = MAP_APPFONT ( AUTOPAGE_X - AUTO_X - 6 - 3 - BUTTON_WIDTH , EDIT_HEIGHT ) ; \ + HelpId = AUTO_HID; \ + TabStop = TRUE ; \ + Border = TRUE ; \ + }; \ + \ + PushButton PB_AUTOBROWSEURL \ + { \ + Pos = MAP_APPFONT ( AUTOPAGE_X - BUTTON_WIDTH - 6 , AUTO_Y + FIXEDTEXT_HEIGHT + 2 ) ; \ + Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ; \ + HelpId = (AUTO_HID + 1); \ + TabStop = TRUE ; \ + Text[ en-US ] = "Browse"; \ + }; + +// -------------------------------------------------------------------------------------------------- + + +#define AUTO_NAMECONTROLGROUP(AUTO_Y, AUTO_HID) \ + FixedText FT_AUTODATABASENAME \ + { \ + Pos = MAP_APPFONT ( START_X , AUTO_Y + 2) ; \ + Size = MAP_APPFONT ( EDIT_X - START_X - UNRELATED_CONTROLS , FIXEDTEXT_HEIGHT ) ; \ + Text[ en-US ] = "Database name"; \ + }; \ + \ + Edit ET_AUTODATABASENAME \ + { \ + Pos = MAP_APPFONT ( EDIT_X, AUTO_Y) ; \ + Size = MAP_APPFONT ( 97, EDIT_HEIGHT ) ; \ + HelpId = AUTO_HID; \ + TabStop = TRUE ; \ + Border = TRUE ; \ + }; + +// -------------------------------------------------------------------------------------------------- + + +#define AUTO_HOSTCONTROLGROUP(AUTO_Y, AUTO_HID) \ + FixedText FT_AUTOHOSTNAME \ + { \ + Pos = MAP_APPFONT (START_X , AUTO_Y + 2 ) ; \ + Size = MAP_APPFONT ( EDIT_X - START_X - UNRELATED_CONTROLS , FIXEDTEXT_HEIGHT ); \ + Text [ en-US ] = "Server" ; \ + }; \ + \ + Edit ET_AUTOHOSTNAME \ + { \ + Pos = MAP_APPFONT (EDIT_X, AUTO_Y ) ; \ + Size = MAP_APPFONT ( 60, EDIT_HEIGHT ) ; \ + HelpId = AUTO_HID; \ + TabStop = TRUE ; \ + Border = TRUE ; \ + }; + +// -------------------------------------------------------------------------------------------------- + + +#define AUTO_BASEDNCONTROLGROUP(AUTO_Y, AUTO_HID) \ + FixedText FT_AUTOBASEDN \ + { \ + Pos = MAP_APPFONT (START_X , AUTO_Y + 2 ) ; \ + Size = MAP_APPFONT ( EDIT_X - START_X - UNRELATED_CONTROLS , FIXEDTEXT_HEIGHT ) ; \ + Text [ en-US ] = "Base ~DN" ; \ + }; \ + \ + Edit ET_AUTOBASEDN \ + { \ + HelpId = AUTO_HID ; \ + Pos = MAP_APPFONT (EDIT_X, AUTO_Y ) ; \ + Size = MAP_APPFONT ( 60, EDIT_HEIGHT ) ; \ + TabStop = TRUE ; \ + Border = TRUE ; \ + }; \ + +// -------------------------------------------------------------------------------------------------- + + +#define AUTO_PORTCONTROLGROUP(AUTO_Y, AUTO_HID) \ + FixedText FT_AUTOPORTNUMBER \ + { \ + Pos = MAP_APPFONT (START_X , AUTO_Y +2) ; \ + Size = MAP_APPFONT ( EDIT_X - START_X - UNRELATED_CONTROLS , FIXEDTEXT_HEIGHT ) ; \ + Text [ en-US ] = "~Port number" ; \ + }; \ + \ + NumericField NF_AUTOPORTNUMBER \ + { \ + HelpId = AUTO_HID ; \ + Pos = MAP_APPFONT (EDIT_X, AUTO_Y ) ; \ + Size = MAP_APPFONT ( 22 , EDIT_HEIGHT ) ; \ + TabStop = TRUE ; \ + Border = TRUE ; \ + NoThousandSep = TRUE; \ + }; \ + \ + FixedText FT_AUTOPORTNUMBERDEFAULT \ + { \ + HelpId = AUTO_HID + 1 ; \ + Pos = MAP_APPFONT (EDIT_X + 22 + UNRELATED_CONTROLS, AUTO_Y +2) ; \ + Size = MAP_APPFONT ( WIZARD_PAGE_X - EDIT_X - 22 - UNRELATED_CONTROLS , FIXEDTEXT_HEIGHT ) ; \ + Text[ en-US ] = "" ; \ + }; + +//------------------------------------------------------------------------- + +#define AUTO_CHARSET( AUTO_Y, AUTOPAGE_X ) \ + FixedLine FL_DATACONVERT \ + { \ + Pos = MAP_APPFONT ( 4 , AUTO_Y ) ; \ + Size = MAP_APPFONT ( AUTOPAGE_X - 2*RELATED_CONTROLS , FIXEDTEXT_HEIGHT ) ; \ + Text [ en-US ] = "Data conversion"; \ + }; \ + FixedText FT_CHARSET \ + { \ + Pos = MAP_APPFONT ( 6 , AUTO_Y + RELATED_CONTROLS + FIXEDTEXT_HEIGHT ) ; \ + Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; \ + Text [ en-US ] = "~Character set" ; \ + }; \ + ListBox LB_CHARSET \ + { \ + Border = TRUE ; \ + Pos = MAP_APPFONT ( EDIT_X , AUTO_Y + RELATED_CONTROLS + FIXEDTEXT_HEIGHT -1 ) ; \ + Size = MAP_APPFONT ( AUTOPAGE_X - EDIT_X - 6 , 60 ) ; \ + TabStop = TRUE ; \ + HelpId = HID_DSADMIN_CHARSET; \ + DropDown = TRUE ; \ + CurPos = 0 ; \ + }; \ + +// -------------------------------------------------------------------------------------------------- +#define AUTO_SEPARATORCONTROLGROUP(AUTO_Y,AUTOPAGE_X) \ + \ + FixedText FT_AUTOEXTENSIONHEADER \ + { \ + Pos = MAP_APPFONT ( START_X , AUTO_Y) ; \ + Size = MAP_APPFONT ( AUTOPAGE_X - 2*START_X , FIXEDTEXT_HEIGHT ) ; \ + Text[ en-US ] = "Specify the type of files you want to access" ; \ + }; \ + \ + RadioButton RB_AUTOACCESSCTEXTFILES \ + { \ + HelpId = HID_PAGE_DBWIZARD_TEXT_RB_ACCESSTXTFILES; \ + Pos = MAP_APPFONT (START_X + 6 , AUTO_Y + FIXEDTEXT_HEIGHT + RELATED_CONTROLS); \ + Size = MAP_APPFONT ( AUTOPAGE_X - 12 , FIXEDTEXT_HEIGHT ) ; \ + Text[ en-US ] = "Plain text files (*.txt)" ; \ + }; \ + \ + RadioButton RB_AUTOACCESSCCSVFILES \ + { \ + HelpId = HID_PAGE_DBWIZARD_TEXT_RB_ACCESSCSVFILES; \ + Pos = MAP_APPFONT (START_X + 6 , AUTO_Y + 2*FIXEDTEXT_HEIGHT + 2*RELATED_CONTROLS); \ + Size = MAP_APPFONT ( AUTOPAGE_X - 12 , FIXEDTEXT_HEIGHT ) ; \ + Text[ en-US ] = "'Comma separated value' files (*.csv)" ; \ + }; \ + \ + RadioButton RB_AUTOACCESSOTHERS \ + { \ + HelpId = HID_PAGE_DBWIZARD_TEXT_RB_ACCESSOTHERFILES; \ + Pos = MAP_APPFONT (START_X + 6 , AUTO_Y + 3*FIXEDTEXT_HEIGHT + 3*RELATED_CONTROLS); \ + Size = MAP_APPFONT ( 50 , FIXEDTEXT_HEIGHT ) ; \ + Text[ en-US ] = "Custom:" ; \ + }; \ + \ + Edit ET_AUTOOWNEXTENSION \ + { \ + HelpId = HID_PAGE_DBWIZARD_TEXT_ET_OWNEXTENSION; \ + Pos = MAP_APPFONT (START_X + 66, AUTO_Y + 3*FIXEDTEXT_HEIGHT + 3*RELATED_CONTROLS - 2 ) ; \ + Size = MAP_APPFONT ( 60, EDIT_HEIGHT ) ; \ + TabStop = TRUE ; \ + Border = TRUE ; \ + }; \ + \ + FIXEDTEXT FT_AUTOOWNEXTENSIONAPPENDIX \ + { \ + Pos = MAP_APPFONT (START_X + 130 , AUTO_Y + 3 * ( FIXEDTEXT_HEIGHT + RELATED_CONTROLS ) ); \ + Size = MAP_APPFONT ( AUTOPAGE_X - 6 -(START_X + 130), FIXEDTEXT_HEIGHT ) ; \ + Text[ en-US ] = "Custom: *.abc" ; \ + }; \ + \ + FixedLine FL_AUTOSEPARATOR2 \ + { \ + Pos = MAP_APPFONT ( START_X , AUTO_Y + 50) ; \ + Size = MAP_APPFONT ( AUTOPAGE_X - 2 * START_X , FIXEDTEXT_HEIGHT ) ; \ + Text[ en-US ] = "Row Format"; \ + }; \ + \ + FixedText FT_AUTOFIELDSEPARATOR \ + { \ + Pos = MAP_APPFONT ( START_X + INDENTED_X , AUTO_Y + 50 + UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT ) ; \ + Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; \ + Text[ en-US ] = "Field separator" ; \ + }; \ + ComboBox CM_AUTOFIELDSEPARATOR \ + { \ + Pos = MAP_APPFONT ( EDIT_X , AUTO_Y + 50 + UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT - 2 ) ; \ + Size = MAP_APPFONT ( 32 , 60 ) ; \ + Text = ";" ; \ + TabStop = TRUE ; \ + DropDown = TRUE ; \ + HelpId = HID_DSADMIN_FIELD_SEPARATOR; \ + }; \ + \ + FixedText FT_AUTOTEXTSEPARATOR \ + { \ + Pos = MAP_APPFONT ( START_X + INDENTED_X, AUTO_Y + 50 + UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + RELATED_CONTROLS + EDIT_HEIGHT ) ; \ + Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; \ + Text[ en-US ] = "Text separator" ; \ + }; \ + ComboBox CM_AUTOTEXTSEPARATOR \ + { \ + Pos = MAP_APPFONT ( EDIT_X , AUTO_Y + 50 + UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + RELATED_CONTROLS + EDIT_HEIGHT - 2 ) ; \ + Size = MAP_APPFONT ( 32 , 60 ) ; \ + Text = "\"" ; \ + TabStop = TRUE ; \ + DropDown = TRUE ; \ + HelpId = HID_DSADMIN_TEXT_SEPARATOR; \ + }; \ + FixedText FT_AUTODECIMALSEPARATOR \ + { \ + Pos = MAP_APPFONT ( START_X + INDENTED_X, AUTO_Y + 50 + UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + 2*RELATED_CONTROLS + 2*EDIT_HEIGHT ) ; \ + Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; \ + Text[ en-US ] = "Decimal separator" ; \ + }; \ + ComboBox CM_AUTODECIMALSEPARATOR \ + { \ + Pos = MAP_APPFONT ( EDIT_X , AUTO_Y + 50 + UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + 2*RELATED_CONTROLS + 2*EDIT_HEIGHT - 2 ) ; \ + Size = MAP_APPFONT ( 32 , 60 ) ; \ + TabStop = TRUE ; \ + MaxTextLength = 1 ; \ + DropDown = TRUE ; \ + StringList = \ + { \ + "." ; \ + "," ; \ + ";" ; \ + ":" ; \ + }; \ + HelpId = HID_DSADMIN_DECIMAL_SEPARATOR; \ + }; \ + FixedText FT_AUTOTHOUSANDSSEPARATOR \ + { \ + Pos = MAP_APPFONT ( START_X + INDENTED_X, AUTO_Y + 50 + UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + 3*RELATED_CONTROLS + 3*EDIT_HEIGHT ) ; \ + Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; \ + Text[ en-US ] = "Thousands separator" ; \ + }; \ + ComboBox CM_AUTOTHOUSANDSSEPARATOR \ + { \ + Pos = MAP_APPFONT ( EDIT_X , AUTO_Y + 50 + UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + 3*RELATED_CONTROLS + 3*EDIT_HEIGHT - 2 ) ; \ + Size = MAP_APPFONT ( 32 , 44 ) ; \ + Text = "." ; \ + TabStop = TRUE ; \ + MaxTextLength = 1 ; \ + DropDown = TRUE ; \ + StringList = \ + { \ + "," ; \ + "." ; \ + }; \ + HelpId = HID_DSADMIN_THOUSANDS_SEPARATOR; \ + }; \ + \ + CheckBox CB_AUTOHEADER \ + { \ + TabStop = TRUE ; \ + Pos = MAP_APPFONT ( START_X + INDENTED_X, AUTO_Y + 50 + UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + 4*RELATED_CONTROLS + 4*EDIT_HEIGHT ) ; \ + Size = MAP_APPFONT ( 150 , CHECKBOX_HEIGHT ) ; \ + HelpId = HID_DSADMIN_TEXT_HEADER; \ + Text [ en-US ] = "~Text contains headers" ; \ + }; \ + \ + AUTO_CHARSET( AUTO_Y + 50 + UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + 4*RELATED_CONTROLS + 4*EDIT_HEIGHT + CHECKBOX_HEIGHT + UNRELATED_CONTROLS, AUTOPAGE_X ) \ + \ + String STR_AUTOTEXT_FIELD_SEP_NONE \ + { \ + Text[ en-US ] = "{None}"; \ + }; \ + \ + String STR_AUTOTEXTSEPARATORLIST \ + { \ + Text = "\"\t34\t'\t39" ; \ + }; \ + \ + String STR_AUTOFIELDSEPARATORLIST \ + { \ + Text [ x-comment ] = "EM Dec 2002: \'Space\' refers to what you get when you hit the space bar on your keyboard."; \ + Text [ en-US ] = ";\t59\t,\t44\t:\t58\t{Tab}\t9\t{Space}\t32" ; \ + }; \ + \ + String STR_AUTODELIMITER_MISSING \ + { \ + Text[ en-US ] = "#1 must be set." ; \ + }; \ + String STR_AUTODELIMITER_MUST_DIFFER \ + { \ + Text[ en-US ] = "#1 and #2 must be different." ; \ + }; \ + String STR_AUTONO_WILDCARDS \ + { \ + Text[ en-US ] = "Wildcards such as ?,* are not allowed in #1." ; \ + }; + + +#define NAMECONTROLGROUP_HEIGHT (FIXEDTEXT_HEIGHT + 2 + EDIT_HEIGHT) +#define BROWSECONTROLGROUP_HEIGHT ( FIXEDTEXT_HEIGHT + 2 + BUTTON_HEIGHT) + +// -------------------------------------------------------------------------------------------------- + +#define AUTO_HELP_BROWSECONTROLGROUP(AUTO_LINECOUNT, AUTO_HID) \ + AUTO_WIZARDHELPTEXT(AUTO_LINECOUNT) \ + AUTO_BROWSECONTROLGROUP(START_X, INIT_Y + AUTO_LINECOUNT * FIXEDTEXT_HEIGHT + 2, WIZARD_PAGE_X, AUTO_HID) + + +// -------------------------------------------------------------------------------------------------- + + +// -------------------------------------------------------------------------------------------------- + +#define AUTO_JDBCDRIVERCLASSGROUP(AUTO_Y, AUTO_HID) \ + \ + FixedText FT_AUTOJDBCDRIVERCLASS \ + { \ + Pos = MAP_APPFONT ( 6 , AUTO_Y) ; \ + Size = MAP_APPFONT ( PAGE_X - 12 , FIXEDTEXT_HEIGHT ) ; \ + Text [ en-US ] = "JDBC d~river class"; \ + }; \ + \ + Edit ET_AUTOJDBCDRIVERCLASS \ + { \ + Pos = MAP_APPFONT ( START_X, AUTO_Y + FIXEDTEXT_HEIGHT + RELATED_CONTROLS ) ; \ + Size = MAP_APPFONT ( WIZARD_PAGE_X - START_X - BUTTON_WIDTH - RELATED_CONTROLS - UNRELATED_CONTROLS , EDIT_HEIGHT ) ; \ + TabStop = TRUE ; \ + Border = TRUE ; \ + HelpId = AUTO_HID; \ + }; \ + \ + PushButton PB_AUTOTESTDRIVERCLASS \ + { \ + TabStop = TRUE ; \ + Pos = MAP_APPFONT ( WIZARD_PAGE_X - BUTTON_WIDTH - UNRELATED_CONTROLS , AUTO_Y + FIXEDTEXT_HEIGHT + 2) ; \ + Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ; \ + Size = MAP_APPFONT (50, 14); \ + HelpId = AUTO_HID + 1; \ + Text[ en-US ] = "Test class" ; \ + }; + +// -------------------------------------------------------------------------------------------------- + +#define AUTO_SOCKETCONTROLGROUP(AUTO_Y) \ + FixedText FT_SOCKET \ + { \ + Pos = MAP_APPFONT (START_X , AUTO_Y +2) ; \ + Size = MAP_APPFONT ( EDIT_X - START_X - UNRELATED_CONTROLS , FIXEDTEXT_HEIGHT ) ; \ + Text [ en-US ] = "Socket" ; \ + }; \ + \ + Edit ET_SOCKET \ + { \ + Pos = MAP_APPFONT (EDIT_X, AUTO_Y ) ; \ + Size = MAP_APPFONT ( 97, EDIT_HEIGHT ) ; \ + TabStop = TRUE ; \ + Border = TRUE ; \ + }; + + +#define AUTOHELP_JDBCCONTROLGROUP( AUTO_HID ) \ + AUTO_WIZARDHELPTEXT( 6 ) \ + AUTO_NAMECONTROLGROUP( INIT_Y + 6 * FIXEDTEXT_HEIGHT + 2, AUTO_HID ) \ + AUTO_HOSTCONTROLGROUP(96, AUTO_HID + 1) \ + AUTO_PORTCONTROLGROUP(113, AUTO_HID + 2 ) \ + AUTO_SOCKETCONTROLGROUP(129) \ + AUTO_JDBCDRIVERCLASSGROUP(146, AUTO_HID + 3) + + +// -------------------------------------------------------------------------------------------------- + +#endif diff --git a/dbaccess/source/ui/dlg/CollectionView.cxx b/dbaccess/source/ui/dlg/CollectionView.cxx new file mode 100644 index 000000000000..f9762833641e --- /dev/null +++ b/dbaccess/source/ui/dlg/CollectionView.cxx @@ -0,0 +1,397 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" +#ifndef DBAUI_COLLECTIONVIEW_HXX +#include "CollectionView.hxx" +#endif +#ifndef DBAUI_COLLECTIONVIEW_HRC +#include "CollectionView.hrc" +#endif +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif +#ifndef TOOLS_DIAGNOSE_EX_H +#include <tools/diagnose_ex.h> +#endif +#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "moduledbu.hxx" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef _COMPHELPER_INTERACTION_HXX_ +#include <comphelper/interaction.hxx> +#endif +#ifndef _CPPUHELPER_EXC_HLP_HXX_ +#include <cppuhelper/exc_hlp.hxx> +#endif +#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ +#include <toolkit/helper/vclunohelper.hxx> +#endif +#ifndef SVT_QUERYFOLDER_HXX +#include <svtools/QueryFolderName.hxx> +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include <com/sun/star/lang/XInitialization.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_ +#include <com/sun/star/container/XChild.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ +#include <com/sun/star/container/XNameContainer.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ +#include <com/sun/star/beans/PropertyValue.hpp> +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef DBAUI_TOOLS_HXX +#include "UITools.hxx" +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMECONTAINER_HPP_ +#include <com/sun/star/container/XHierarchicalNameContainer.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_INTERACTIVEAUGMENTEDIOEXCEPTION_HPP_ +#include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_IOERRORCODE_HPP_ +#include <com/sun/star/ucb/IOErrorCode.hpp> +#endif +#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_ +#include <com/sun/star/task/XInteractionHandler.hpp> +#endif +#ifndef _COM_SUN_STAR_TASK_INTERACTIONCLASSIFICATION_HPP_ +#include <com/sun/star/task/InteractionClassification.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_SQLEXCEPTION_HPP_ +#include <com/sun/star/sdbc/SQLException.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_ +#include <com/sun/star/awt/XWindow.hpp> +#endif +#ifndef INCLUDED_SVTOOLS_VIEWOPTIONS_HXX +#include <unotools/viewoptions.hxx> +#endif +#ifndef _OSL_THREAD_H_ +#include <osl/thread.h> +#endif +#ifndef _DBHELPER_DBEXCEPTION_HXX_ +#include <connectivity/dbexception.hxx> +#endif + +#define FILEDIALOG_DEF_IMAGEBORDER 10 +//......................................................................... +namespace dbaui +{ +//......................................................................... + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::ucb; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::ucb; +using namespace ::com::sun::star::task; +using namespace ::com::sun::star::sdbc; +using namespace comphelper; +// ----------------------------------------------------------------------------- +DBG_NAME(OCollectionView) +OCollectionView::OCollectionView( Window * pParent + ,const Reference< XContent>& _xContent + ,const ::rtl::OUString& _sDefaultName + ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB) + : ModalDialog( pParent, ModuleRes(DLG_COLLECTION_VIEW)) + , m_aFTCurrentPath( this, ModuleRes( FT_EXPLORERFILE_CURRENTPATH ) ) + , m_aNewFolder( this, ModuleRes( BTN_EXPLORERFILE_NEWFOLDER ) ) + , m_aUp( this, ModuleRes( BTN_EXPLORERFILE_UP ) ) + , m_aView( this, ModuleRes( CTRL_VIEW ) ,FILEVIEW_SHOW_TITLE ) + , m_aFTName( this, ModuleRes( FT_EXPLORERFILE_FILENAME ) ) + , m_aName( this, ModuleRes( ED_EXPLORERFILE_FILENAME ) ) + , m_aFL( this, ModuleRes( FL_1 ) ) + , m_aPB_OK( this, ModuleRes( BTN_EXPLORERFILE_SAVE ) ) + , m_aPB_CANCEL( this, ModuleRes( PB_CANCEL ) ) + , m_aPB_HELP( this, ModuleRes( PB_HELP ) ) + , m_sPath( ModuleRes( STR_PATHNAME ) ) + , m_xContent(_xContent) + , m_xORB(_xORB) + , m_bCreateForm(sal_True) +{ + DBG_CTOR(OCollectionView,NULL); + FreeResource(); + + OSL_ENSURE(m_xContent.is(),"No valid content!"); + m_aView.Initialize(m_xContent,String()); + m_aFTCurrentPath.SetStyle( m_aFTCurrentPath.GetStyle() | WB_PATHELLIPSIS ); + initCurrentPath(); + + m_aName.SetText(_sDefaultName); + m_aName.GrabFocus(); + + m_aNewFolder.SetStyle( m_aNewFolder.GetStyle() | WB_NOPOINTERFOCUS ); + m_aUp.SetModeImage(ModuleRes(IMG_NAVIGATION_BTN_UP_SC)); + m_aUp.SetModeImage(ModuleRes(IMG_NAVIGATION_BTN_UP_SCH),BMP_COLOR_HIGHCONTRAST); + m_aNewFolder.SetModeImage(ModuleRes(IMG_NAVIGATION_CREATEFOLDER_SC)); + m_aNewFolder.SetModeImage(ModuleRes(IMG_NAVIGATION_CREATEFOLDER_SCH),BMP_COLOR_HIGHCONTRAST); + + m_aView.SetDoubleClickHdl( LINK( this, OCollectionView, Dbl_Click_FileView ) ); + m_aView.EnableAutoResize(); + m_aUp.SetClickHdl( LINK( this, OCollectionView, Up_Click ) ); + m_aNewFolder.SetClickHdl( LINK( this, OCollectionView, NewFolder_Click ) ); + m_aPB_OK.SetClickHdl( LINK( this, OCollectionView, Save_Click ) ); +} +// ----------------------------------------------------------------------------- +OCollectionView::~OCollectionView( ) +{ + DBG_DTOR(OCollectionView,NULL); +} +// ----------------------------------------------------------------------------- +Reference< XContent> OCollectionView::getSelectedFolder() const +{ + return m_xContent; +} +// ----------------------------------------------------------------------------- +IMPL_LINK( OCollectionView, Save_Click, PushButton*, EMPTYARG ) +{ + ::rtl::OUString sName = m_aName.GetText(); + if ( !sName.getLength() ) + return 0; + try + { + ::rtl::OUString sSubFolder = m_aView.GetCurrentURL(); + sal_Int32 nIndex = sName.lastIndexOf('/') + 1; + if ( nIndex ) + { + if ( nIndex == 1 ) // special handling for root + { + Reference<XChild> xChild(m_xContent,UNO_QUERY); + Reference<XNameAccess> xNameAccess(xChild,UNO_QUERY); + while( xNameAccess.is() ) + { + xNameAccess.set(xChild->getParent(),UNO_QUERY); + if ( xNameAccess.is() ) + { + m_xContent.set(xNameAccess,UNO_QUERY); + xChild.set(m_xContent,UNO_QUERY); + } + } + m_aView.Initialize(m_xContent,String()); + initCurrentPath(); + } + sSubFolder = sName.copy(0,nIndex-1); + sName = sName.copy(nIndex); + Reference<XHierarchicalNameContainer> xHier(m_xContent,UNO_QUERY); + OSL_ENSURE(xHier.is(),"XHierarchicalNameContainer not supported!"); + if ( sSubFolder.getLength() && xHier.is() ) + { + if ( xHier->hasByHierarchicalName(sSubFolder) ) + { + m_xContent.set(xHier->getByHierarchicalName(sSubFolder),UNO_QUERY); + } + else // sub folder doesn't exist + { + Sequence< Any > aValues(2); + PropertyValue aValue; + aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ResourceName")); + aValue.Value <<= sSubFolder; + aValues[0] <<= aValue; + + aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ResourceType")); + aValue.Value <<= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("folder")); + aValues[1] <<= aValue; + + InteractionClassification eClass = InteractionClassification_ERROR; + ::com::sun::star::ucb::IOErrorCode eError = IOErrorCode_NOT_EXISTING_PATH; + ::rtl::OUString sTemp; + InteractiveAugmentedIOException aException(sTemp,Reference<XInterface>(),eClass,eError,aValues); + + + Reference<XInitialization> xIni(m_xORB->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.task.InteractionHandler"))),UNO_QUERY); + if ( xIni.is() ) + { + aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Parent")); + aValue.Value <<= VCLUnoHelper::GetInterface( this ); + Sequence< Any > aArgs(1); + aArgs[0] <<= makeAny(aValue); + xIni->initialize(aArgs); + OInteractionRequest* pRequest = new OInteractionRequest(makeAny(aException)); + Reference< XInteractionRequest > xRequest(pRequest); + + OInteractionApprove* pApprove = new OInteractionApprove; + pRequest->addContinuation(pApprove); + + Reference< XInteractionHandler > xHandler(xIni,UNO_QUERY); + xHandler->handle(xRequest); + } + return 0; + } + } + } + Reference<XNameContainer> xNameContainer(m_xContent,UNO_QUERY); + if ( xNameContainer.is() ) + { + Reference< XContent> xContent; + if ( xNameContainer->hasByName(sName) ) + { + QueryBox aBox( this, WB_YES_NO, ModuleRes( STR_ALREADYEXISTOVERWRITE ) ); + if ( aBox.Execute() != RET_YES ) + return 0; + // xNameContainer->removeByName(sName); + } + m_aName.SetText(sName); + EndDialog( TRUE ); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return 0; +} +// ----------------------------------------------------------------------------- +IMPL_LINK( OCollectionView, NewFolder_Click, PushButton*, EMPTYARG ) +{ + try + { + Reference<XHierarchicalNameContainer> xNameContainer(m_xContent,UNO_QUERY); + if ( dbaui::insertHierachyElement(this,m_xORB,xNameContainer,String(),m_bCreateForm) ) + m_aView.Initialize(m_xContent,String()); + } + catch( const SQLException& ) + { + showError( ::dbtools::SQLExceptionInfo( ::cppu::getCaughtException() ), this, m_xORB ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return 0; +} +// ----------------------------------------------------------------------------- +IMPL_LINK( OCollectionView, Up_Click, PushButton*, EMPTYARG ) +{ + try + { + Reference<XChild> xChild(m_xContent,UNO_QUERY); + if ( xChild.is() ) + { + Reference<XNameAccess> xNameAccess(xChild->getParent(),UNO_QUERY); + if ( xNameAccess.is() ) + { + m_xContent.set(xNameAccess,UNO_QUERY); + m_aView.Initialize(m_xContent,String()); + initCurrentPath(); + } + else + m_aUp.Disable(); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return 0; +} +// ----------------------------------------------------------------------------- +IMPL_LINK( OCollectionView, Dbl_Click_FileView, SvtFileView*, EMPTYARG ) +{ + try + { + Reference<XNameAccess> xNameAccess(m_xContent,UNO_QUERY); + if ( xNameAccess.is() ) + { + ::rtl::OUString sSubFolder = m_aView.GetCurrentURL(); + sal_Int32 nIndex = sSubFolder.lastIndexOf('/') + 1; + sSubFolder = sSubFolder.getToken(0,'/',nIndex); + if ( sSubFolder.getLength() ) + { + Reference< XContent> xContent; + if ( xNameAccess->hasByName(sSubFolder) ) + xContent.set(xNameAccess->getByName(sSubFolder),UNO_QUERY); + if ( xContent.is() ) + { + m_xContent = xContent; + m_aView.Initialize(m_xContent,String()); + initCurrentPath(); + } + } + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return 0; +} +// ----------------------------------------------------------------------------- +void OCollectionView::initCurrentPath() +{ + BOOL bEnable = FALSE; + try + { + if ( m_xContent.is() ) + { + const ::rtl::OUString sCID = m_xContent->getIdentifier()->getContentIdentifier(); + const static ::rtl::OUString s_sFormsCID(RTL_CONSTASCII_USTRINGPARAM("private:forms")); + const static ::rtl::OUString s_sReportsCID(RTL_CONSTASCII_USTRINGPARAM("private:reports")); + m_bCreateForm = s_sFormsCID.compareTo(sCID) == 0; + ::rtl::OUString sPath(RTL_CONSTASCII_USTRINGPARAM("/")); + if ( m_bCreateForm && sCID.getLength() != s_sFormsCID.getLength()) + sPath = sCID.copy(s_sFormsCID.getLength()); + else if ( !m_bCreateForm && sCID.getLength() != s_sReportsCID.getLength() ) + sPath = sCID.copy(s_sReportsCID.getLength()); + + m_aFTCurrentPath.SetText(sPath); + Reference<XChild> xChild(m_xContent,UNO_QUERY); + bEnable = xChild.is() && Reference<XNameAccess>(xChild->getParent(),UNO_QUERY).is(); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + m_aUp.Enable(bEnable); +} +// ----------------------------------------------------------------------------- +::rtl::OUString OCollectionView::getName() const +{ + return m_aName.GetText(); +} +// ----------------------------------------------------------------------------- +//......................................................................... +} // namespace dbaui +//......................................................................... + + diff --git a/dbaccess/source/ui/dlg/CollectionView.hrc b/dbaccess/source/ui/dlg/CollectionView.hrc new file mode 100644 index 000000000000..0a385ff7f23c --- /dev/null +++ b/dbaccess/source/ui/dlg/CollectionView.hrc @@ -0,0 +1,50 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBAUI_COLLECTIONVIEW_HRC +#define DBAUI_COLLECTIONVIEW_HRC + +#define CTRL_VIEW 1 + +#define PB_CANCEL 1 +#define PB_HELP 1 + +#define ED_EXPLORERFILE_FILENAME 1 + +#define FT_EXPLORERFILE_CURRENTPATH 1 +#define FT_EXPLORERFILE_FILENAME 2 + +#define BTN_EXPLORERFILE_NEWFOLDER 1 +#define BTN_EXPLORERFILE_UP 2 +#define BTN_EXPLORERFILE_SAVE 3 + +#define STR_PATHNAME 1 + +#define FL_1 1 + +#endif //DBAUI_COLLECTIONVIEW_HRC + diff --git a/dbaccess/source/ui/dlg/CollectionView.src b/dbaccess/source/ui/dlg/CollectionView.src new file mode 100644 index 000000000000..018893384dab --- /dev/null +++ b/dbaccess/source/ui/dlg/CollectionView.src @@ -0,0 +1,167 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#include "dbaccess_helpid.hrc" +#include "CollectionView.hrc" + +#define WIN_X 200 +#define WIN_Y 192 + +#define CHECKBOX_HEIGHT 8 +#define FIXEDTEXT_HEIGHT 8 +#define RELATED_CONTROLS 4 +#define UNRELATED_CONTROLS 7 +#define EDIT_HEIGHT 12 +#define BUTTON_HEIGHT 14 +#define FIXEDLINE_HEIGHT 1 +#define IMG_SIZE 15 + + +ModalDialog DLG_COLLECTION_VIEW +{ + OutputSize = TRUE ; + SVLook = TRUE ; + Moveable = TRUE ; + Closeable = TRUE ; + //Sizeable = TRUE; + HelpId = HID_EXPLORERDLG_COLLECTION ; + + Size = MAP_APPFONT ( WIN_X , WIN_Y ) ; + Text [ en-US ] = "Save" ; + + FixedText FT_EXPLORERFILE_CURRENTPATH + { + Pos = MAP_APPFONT ( UNRELATED_CONTROLS , UNRELATED_CONTROLS ) ; + Size = MAP_APPFONT ( 100 , FIXEDTEXT_HEIGHT ) ; + NoLabel = TRUE ; + }; + ImageButton BTN_EXPLORERFILE_NEWFOLDER + { + TabStop = FALSE ; + Pos = MAP_APPFONT ( WIN_X - UNRELATED_CONTROLS - RELATED_CONTROLS - 2*IMG_SIZE, UNRELATED_CONTROLS ) ; + Size = MAP_APPFONT ( IMG_SIZE , IMG_SIZE ) ; + QuickHelpText [ en-US ] = "Create New Directory" ; + }; + ImageButton BTN_EXPLORERFILE_UP + { + TabStop = TRUE ; + Pos = MAP_APPFONT ( WIN_X - UNRELATED_CONTROLS - IMG_SIZE, UNRELATED_CONTROLS ) ; + Size = MAP_APPFONT ( IMG_SIZE , IMG_SIZE ) ; + QuickHelpText [ en-US ] = "Up One Level" ; + }; + + Control CTRL_VIEW + { + TabStop = TRUE ; + Pos = MAP_APPFONT ( UNRELATED_CONTROLS , 2*UNRELATED_CONTROLS + IMG_SIZE) ; + Size = MAP_APPFONT ( WIN_X - 2*UNRELATED_CONTROLS , WIN_Y - 6*UNRELATED_CONTROLS - BUTTON_HEIGHT - IMG_SIZE - EDIT_HEIGHT - FIXEDTEXT_HEIGHT) ; + Border = TRUE ; + }; + + FixedText FT_EXPLORERFILE_FILENAME + { + Pos = MAP_APPFONT ( UNRELATED_CONTROLS , WIN_Y - 3*UNRELATED_CONTROLS - BUTTON_HEIGHT - FIXEDLINE_HEIGHT - EDIT_HEIGHT ) ; + Size = MAP_APPFONT ( 50 , FIXEDTEXT_HEIGHT ) ; + Text [ en-US ] = "File ~name:" ; + }; + Edit ED_EXPLORERFILE_FILENAME + { + Pos = MAP_APPFONT ( RELATED_CONTROLS + UNRELATED_CONTROLS + 50 , WIN_Y - 3*UNRELATED_CONTROLS - BUTTON_HEIGHT - FIXEDLINE_HEIGHT - EDIT_HEIGHT) ; + Size = MAP_APPFONT ( WIN_X - RELATED_CONTROLS - 2*UNRELATED_CONTROLS - 50 , EDIT_HEIGHT ) ; + Border = TRUE ; + TabStop = TRUE ; + }; + + FixedLine FL_1 + { + Pos = MAP_APPFONT ( 0 , WIN_Y - 2*UNRELATED_CONTROLS - BUTTON_HEIGHT - FIXEDLINE_HEIGHT) ; + Size = MAP_APPFONT ( WIN_X , FIXEDLINE_HEIGHT ) ; + }; + + PushButton BTN_EXPLORERFILE_SAVE + { + Pos = MAP_APPFONT ( WIN_X - 2*UNRELATED_CONTROLS - RELATED_CONTROLS - 150, WIN_Y - UNRELATED_CONTROLS - BUTTON_HEIGHT ) ; + Size = MAP_APPFONT ( 50 , BUTTON_HEIGHT ) ; + DefButton = TRUE ; + TabStop = TRUE ; + Text [ en-US ] = "Save" ; + }; + + CancelButton PB_CANCEL + { + TabStop = TRUE ; + Pos = MAP_APPFONT ( WIN_X - 2*UNRELATED_CONTROLS - 100, WIN_Y - UNRELATED_CONTROLS - BUTTON_HEIGHT ) ; + Size = MAP_APPFONT ( 50 , BUTTON_HEIGHT ) ; + }; + + HelpButton PB_HELP + { + TabStop = TRUE ; + Pos = MAP_APPFONT ( WIN_X - UNRELATED_CONTROLS - 50, WIN_Y - UNRELATED_CONTROLS - BUTTON_HEIGHT ) ; + Size = MAP_APPFONT ( 50 , BUTTON_HEIGHT ) ; + }; + + + String STR_PATHNAME + { + Text [ en-US ] = "~Path:" ; + }; +}; + +String STR_NEW_FOLDER +{ + Text [ en-US ] = "Folder" ; +}; +Image IMG_NAVIGATION_BTN_UP_SC +{ + ImageBitmap = Bitmap { File = "fp010"; }; + MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; }; +}; +Image IMG_NAVIGATION_BTN_UP_SCH +{ + ImageBitmap = Bitmap { File = "fph010"; }; + MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; }; +}; +Image IMG_NAVIGATION_CREATEFOLDER_SC +{ + ImageBitmap = Bitmap { File = "fp015"; }; + MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; }; +}; +Image IMG_NAVIGATION_CREATEFOLDER_SCH +{ + ImageBitmap = Bitmap { File = "fph015"; }; + MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; }; +}; + +String STR_ALREADYEXISTOVERWRITE +{ + Text [ en-US ] = "The file already exists. Overwrite?" ; +}; + diff --git a/dbaccess/source/ui/dlg/ConnectionHelper.cxx b/dbaccess/source/ui/dlg/ConnectionHelper.cxx new file mode 100644 index 000000000000..1d1277f49301 --- /dev/null +++ b/dbaccess/source/ui/dlg/ConnectionHelper.cxx @@ -0,0 +1,994 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#include "dsnItem.hxx" +#ifndef DBAUI_CONNECTIONHELPER_HXX +#include "ConnectionHelper.hxx" +#endif +#ifndef _DBAUI_AUTOCONTROLS_HRC_ +#include "AutoControls.hrc" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef _DBU_MISC_HRC_ +#include "dbu_misc.hrc" +#endif +#ifndef _SFXITEMSET_HXX +#include <svl/itemset.hxx> +#endif +#ifndef INCLUDED_SVTOOLS_MODULEOPTIONS_HXX +#include <unotools/moduleoptions.hxx> +#endif +#ifndef _SFX_FCONTNR_HXX +#include <sfx2/fcontnr.hxx> +#endif +#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX +#include <unotools/pathoptions.hxx> +#endif +#ifndef _SFXSTRITEM_HXX +#include <svl/stritem.hxx> +#endif +#ifndef _SFXENUMITEM_HXX +#include <svl/eitem.hxx> +#endif +#ifndef _SFXINTITEM_HXX +#include <svl/intitem.hxx> +#endif +#ifndef _DBAUI_DATASOURCEITEMS_HXX_ +#include "dsitems.hxx" +#endif +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif +#ifndef _DBAUI_LOCALRESACCESS_HXX_ +#include "localresaccess.hxx" +#endif +#ifndef _OSL_PROCESS_H_ +#include <osl/process.h> +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif +#ifndef _FILEDLGHELPER_HXX +#include <sfx2/filedlghelper.hxx> +#endif +#ifndef _DBAUI_DBADMIN_HXX_ +#include "dbadmin.hxx" +#endif +#ifndef _COMPHELPER_TYPES_HXX_ +#include <comphelper/types.hxx> +#endif +#ifndef _VCL_STDTEXT_HXX +#include <vcl/stdtext.hxx> +#endif +#ifndef _DBAUI_SQLMESSAGE_HXX_ +#include "sqlmessage.hxx" +#endif +#ifndef _DBAUI_ODBC_CONFIG_HXX_ +#include "odbcconfig.hxx" +#endif +#ifndef _DBAUI_DSSELECT_HXX_ +#include "dsselect.hxx" +#endif +#ifndef SVTOOLS_FILENOTATION_HXX_ +#include <svl/filenotation.hxx> +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef _COM_SUN_STAR_UI_DIALOGS_XFOLDERPICKER_HPP_ +#include <com/sun/star/ui/dialogs/XFolderPicker.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_ +#include <com/sun/star/awt/XWindow.hpp> +#endif +// #106016# ------------------------------------ +#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_ +#include <com/sun/star/task/XInteractionHandler.hpp> +#endif +#ifndef _COM_SUN_STAR_TASK_XPROGRESSHANDLER_HPP_ +#include <com/sun/star/ucb/XProgressHandler.hpp> +#endif +#ifndef DBAUI_TOOLS_HXX +#include "UITools.hxx" +#endif +#ifndef _UNOTOOLS_LOCALFILEHELPER_HXX +#include <unotools/localfilehelper.hxx> +#endif +#ifndef _UNOTOOLS_UCBHELPER_HXX +#include <unotools/ucbhelper.hxx> +#endif +#ifndef _UCBHELPER_COMMANDENVIRONMENT_HXX +#include <ucbhelper/commandenvironment.hxx> +#endif +#ifndef DBAUI_FILEPICKER_INTERACTION_HXX +#include "finteraction.hxx" +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include <connectivity/CommonTools.hxx> +#endif +#ifndef _URLOBJ_HXX +#include <tools/urlobj.hxx> +#endif +#ifndef TOOLS_DIAGNOSE_EX_H +#include <tools/diagnose_ex.h> +#endif +#ifndef _SFX_DOCFILT_HACK_HXX +#include <sfx2/docfilt.hxx> +#endif +#if !defined(WINDOWS_VISTA_PSDK) && (defined(WIN) || defined(WNT)) +#define _ADO_DATALINK_BROWSE_ +#endif + +#ifdef _ADO_DATALINK_BROWSE_ +#if defined( WNT ) + #include <tools/prewin.h> + #include <windows.h> + #include <tools/postwin.h> +#endif +#ifndef _SV_SYSDATA_HXX +#include <vcl/sysdata.hxx> +#endif +#ifndef _DBAUI_ADO_DATALINK_HXX_ +#include "adodatalinks.hxx" +#endif +#endif //_ADO_DATALINK_BROWSE_ + +#ifndef _COM_SUN_STAR_MOZILLA_XMOZILLABOOTSTRAP_HPP_ +#include <com/sun/star/mozilla/XMozillaBootstrap.hpp> +#endif +#include <unotools/processfactory.hxx> + + + +//......................................................................... +namespace dbaui +{ +//......................................................................... + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::ucb; + using namespace ::com::sun::star::ui::dialogs; + using namespace ::com::sun::star::sdbc; + using namespace ::com::sun::star::beans; + using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::container; + using namespace ::com::sun::star::mozilla; + using namespace ::dbtools; + using namespace ::svt; + + +DBG_NAME(OConnectionHelper) + + OConnectionHelper::OConnectionHelper( Window* pParent, const ResId& _rId, const SfxItemSet& _rCoreAttrs) + :OGenericAdministrationPage(pParent, _rId, _rCoreAttrs) + ,m_aFT_Connection ( this, ResId( FT_AUTOBROWSEURL, *_rId.GetResMgr() ) ) + ,m_aConnectionURL ( this, ResId( ET_AUTOBROWSEURL, *_rId.GetResMgr() ) ) + ,m_aPB_Connection ( this, ResId( PB_AUTOBROWSEURL, *_rId.GetResMgr() ) ) + { + DBG_CTOR(OConnectionHelper,NULL); + + // extract the datasource type collection from the item set + DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _rCoreAttrs.GetItem(DSID_TYPECOLLECTION)); + if (pCollectionItem) + m_pCollection = pCollectionItem->getCollection(); + m_aPB_Connection.SetClickHdl(LINK(this, OConnectionHelper, OnBrowseConnections)); + DBG_ASSERT(m_pCollection, "OConnectionHelper::OConnectionHelper : really need a DSN type collection !"); + m_aConnectionURL.SetTypeCollection(m_pCollection); + } + + + OConnectionHelper::~OConnectionHelper() + { + + DBG_DTOR(OConnectionHelper,NULL); + } + + + // ----------------------------------------------------------------------- + void OConnectionHelper::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) + { + // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) + sal_Bool bValid, bReadonly; + getFlags(_rSet, bValid, bReadonly); + + m_aFT_Connection.Show(); + m_aConnectionURL.Show(); + m_aConnectionURL.ShowPrefix( ::dbaccess::DST_JDBC == m_pCollection->determineType(m_eType) ); + + BOOL bEnableBrowseButton = m_pCollection->supportsBrowsing( m_eType ); + m_aPB_Connection.Show( bEnableBrowseButton ); + + SFX_ITEMSET_GET(_rSet, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True); + + // forward the values to the controls + if ( bValid ) + { + String sUrl = pUrlItem->GetValue(); + setURL( sUrl ); + + checkTestConnection(); + m_aConnectionURL.ClearModifyFlag(); + } + + OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue); + } + + // ----------------------------------------------------------------------- + void OConnectionHelper::implUpdateURLDependentStates() const + { + OSL_PRECOND( m_pAdminDialog, "OConnectionHelper::implUpdateURLDependentStates: no admin dialog!" ); + if ( !m_pAdminDialog ) + return; + + if ( m_pCollection->isFileSystemBased(m_eType) ) + m_pAdminDialog->enableConfirmSettings( getURLNoPrefix().Len() > 0 ); + } + + // ----------------------------------------------------------------------- + IMPL_LINK(OConnectionHelper, OnBrowseConnections, PushButton*, /*_pButton*/) + { + OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF"); + const ::dbaccess::DATASOURCE_TYPE eType = m_pCollection->determineType(m_eType); + switch ( eType ) + { + case ::dbaccess::DST_DBASE: + case ::dbaccess::DST_FLAT: + { + try + { + ::rtl::OUString sFolderPickerService = ::rtl::OUString::createFromAscii(SERVICE_UI_FOLDERPICKER); + Reference< XFolderPicker > xFolderPicker(m_xORB->createInstance(sFolderPickerService), UNO_QUERY); + if (!xFolderPicker.is()) + { + ShowServiceNotAvailableError(GetParent(), sFolderPickerService, sal_True); + break; + } + + sal_Bool bDoBrowse = sal_False; + String sOldPath = getURLNoPrefix(); + do + { + if (sOldPath.Len()) + xFolderPicker->setDisplayDirectory(sOldPath); + if (0 == xFolderPicker->execute()) + // cancelled by the user + return 0L; + + sOldPath = xFolderPicker->getDirectory(); + switch (checkPathExistence(sOldPath)) + { + case RET_RETRY: + bDoBrowse = sal_True; + break; + case RET_CANCEL: + return 0L; + default: + break; + } + } + while (bDoBrowse); + + String sSelectedDirectory = xFolderPicker->getDirectory(); + INetURLObject aSelectedDirectory( sSelectedDirectory, INetURLObject::WAS_ENCODED, RTL_TEXTENCODING_UTF8 ); + + // for UI purpose, we don't want to have the path encoded + sSelectedDirectory = aSelectedDirectory.GetMainURL( INetURLObject::DECODE_WITH_CHARSET, RTL_TEXTENCODING_UTF8 ); + + setURLNoPrefix( sSelectedDirectory ); + SetRoadmapStateValue(sal_True); + callModifiedHdl(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + break; + case ::dbaccess::DST_CALC: + { + SvtModuleOptions aModule; + ::sfx2::FileDialogHelper aFileDlg(WB_3DLOOK | WB_STDMODAL | WB_OPEN + ,aModule.GetFactoryEmptyDocumentURL(SvtModuleOptions::E_CALC) + ,SFX_FILTER_IMPORT); + askForFileName(aFileDlg); + } + break; + case ::dbaccess::DST_MSACCESS: + { + const ::rtl::OUString sExt(RTL_CONSTASCII_USTRINGPARAM("*.mdb")); + String sFilterName(ModuleRes (STR_MSACCESS_FILTERNAME)); + ::sfx2::FileDialogHelper aFileDlg(WB_3DLOOK | WB_STDMODAL | WB_OPEN); + aFileDlg.AddFilter(sFilterName,sExt); + aFileDlg.SetCurrentFilter(sFilterName); + askForFileName(aFileDlg); + } + break; + case ::dbaccess::DST_MSACCESS_2007: + { + const ::rtl::OUString sAccdb(RTL_CONSTASCII_USTRINGPARAM("*.accdb")); + String sFilterName2(ModuleRes (STR_MSACCESS_2007_FILTERNAME)); + ::sfx2::FileDialogHelper aFileDlg(WB_3DLOOK | WB_STDMODAL | WB_OPEN); + aFileDlg.AddFilter(sFilterName2,sAccdb); + aFileDlg.SetCurrentFilter(sFilterName2); + askForFileName(aFileDlg); + } + break; + case ::dbaccess::DST_ADABAS: + { + // collect all names from the config dir + // and all dir's of the DBWORK/wrk or DBROOT/wrk dir + // compare the names + + // collect the names of the installed databases + StringBag aInstalledDBs; + ::rtl::OUString sAdabasConfigDir,sAdabasWorkDir,sRootDir; + ::rtl::OUString sEnvVarName(RTL_CONSTASCII_USTRINGPARAM("DBWORK")); + rtl_uString* pDbVar = NULL; + if(osl_getEnvironment(sEnvVarName.pData,&pDbVar) == osl_Process_E_None && pDbVar) + { + sAdabasWorkDir = pDbVar; + String sURL; + utl::LocalFileHelper::ConvertPhysicalNameToURL(sAdabasWorkDir,sURL); + sAdabasWorkDir = sURL; + rtl_uString_release(pDbVar); + pDbVar = NULL; + } + + sEnvVarName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DBCONFIG")); + if(osl_getEnvironment(sEnvVarName.pData,&pDbVar) == osl_Process_E_None && pDbVar) + { + sAdabasConfigDir = pDbVar; + String sURL; + utl::LocalFileHelper::ConvertPhysicalNameToURL(sAdabasConfigDir,sURL); + sAdabasConfigDir = sURL; + rtl_uString_release(pDbVar); + pDbVar = NULL; + } + + sEnvVarName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DBROOT")); + if(osl_getEnvironment(sEnvVarName.pData,&pDbVar) == osl_Process_E_None && pDbVar) + { + sRootDir = pDbVar; + String sURL; + utl::LocalFileHelper::ConvertPhysicalNameToURL(sRootDir,sURL); + sRootDir = sURL; + rtl_uString_release(pDbVar); + pDbVar = NULL; + } + + sal_Bool bOldFashion = sAdabasConfigDir.getLength() && sAdabasWorkDir.getLength(); + + if(!bOldFashion) // we have a normal adabas installation + { // so we check the local database names in $DBROOT/config + sAdabasConfigDir = sRootDir; + sAdabasWorkDir = sRootDir; + } + + if(sAdabasConfigDir.getLength() && sAdabasWorkDir.getLength() && sRootDir.getLength()) + { + + aInstalledDBs = getInstalledAdabasDBs(sAdabasConfigDir,sAdabasWorkDir); + + if(!aInstalledDBs.size() && bOldFashion) + { + sAdabasConfigDir = sRootDir; + sAdabasWorkDir = sRootDir; + aInstalledDBs = getInstalledAdabasDBs(sAdabasConfigDir,sAdabasWorkDir); + } + + ODatasourceSelectDialog aSelector(GetParent(), aInstalledDBs, true,m_pItemSetHelper->getWriteOutputSet()); + if (RET_OK == aSelector.Execute()) + { + setURLNoPrefix(aSelector.GetSelected()); + // checkCreateDatabase( ::dbaccess::DST_ADABAS); + SetRoadmapStateValue(sal_True); + callModifiedHdl(); + } + } + else + { + LocalResourceAccess aLocRes( PAGE_CONNECTION, RSC_TABPAGE ); + String sError = String(ModuleRes(STR_NO_ADABASE_DATASOURCES)); + ErrorBox aBox(this, WB_OK, sError); + aBox.Execute(); + } + } + break; + case ::dbaccess::DST_MYSQL_ODBC: + case ::dbaccess::DST_ODBC: + { + // collect all ODBC data source names + ::rtl::OUString sCurrDatasource = getURLNoPrefix(); + ::rtl::OUString sDataSource; + if ( getSelectedDataSource(sDataSource,sCurrDatasource) && sDataSource.getLength() ) + { + setURLNoPrefix(sDataSource); + SetRoadmapStateValue(sal_True); + callModifiedHdl(); + } + else + return 1L; + } + break; +#ifdef _ADO_DATALINK_BROWSE_ + case ::dbaccess::DST_ADO: + { + ::rtl::OUString sOldDataSource=getURLNoPrefix(); + ::rtl::OUString sNewDataSource; + HWND hWnd = GetParent()->GetSystemData()->hWnd; + sNewDataSource = getAdoDatalink((long)hWnd,sOldDataSource); + if ( sNewDataSource.getLength() ) + { + setURLNoPrefix(sNewDataSource); + SetRoadmapStateValue(sal_True); + callModifiedHdl(); + } + else + return 1L; + } + break; +#endif + case ::dbaccess::DST_MOZILLA: + case ::dbaccess::DST_THUNDERBIRD: + { + MozillaProductType profileType = MozillaProductType_Mozilla; + if (eType == ::dbaccess::DST_THUNDERBIRD) + profileType = MozillaProductType_Thunderbird; + + Reference<XMultiServiceFactory> xFactory = ::comphelper::getProcessServiceFactory(); + OSL_ENSURE( xFactory.is(), "can't get service factory" ); + + Reference<XInterface> xInstance = xFactory->createInstance(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap")) ); + OSL_ENSURE( xInstance.is(), "failed to create instance" ); + Reference<XMozillaBootstrap> xMozillaBootstrap = Reference<XMozillaBootstrap>(xInstance,UNO_QUERY); + OSL_ENSURE( xMozillaBootstrap.is(), "failed to create instance" ); + + if (xMozillaBootstrap.is()) + { + // collect all Mozilla Profiles + ::com::sun::star::uno::Sequence< ::rtl::OUString > list; + + xMozillaBootstrap->getProfileList( profileType, list ); + const ::rtl::OUString * pArray = list.getConstArray(); + + sal_Int32 count = list.getLength(); + + StringBag aProfiles; + for (sal_Int32 index=0; index < count; index++) + aProfiles.insert(pArray[index]); + + + // excute the select dialog + ODatasourceSelectDialog aSelector(GetParent(), aProfiles, eType); + ::rtl::OUString sOldProfile=getURLNoPrefix(); + + if (sOldProfile.getLength()) + aSelector.Select(sOldProfile); + else + aSelector.Select(xMozillaBootstrap->getDefaultProfile(profileType)); + + if ( RET_OK == aSelector.Execute() ) + setURLNoPrefix(aSelector.GetSelected()); + break; + } + } + default: + break; + } + + checkTestConnection(); + + return 0L; + } + + //------------------------------------------------------------------------- + + bool OConnectionHelper::checkTestConnection() + { + return true; + } + + //------------------------------------------------------------------------- + void OConnectionHelper::impl_setURL( const String& _rURL, sal_Bool _bPrefix ) + { + String sURL( _rURL ); + DBG_ASSERT( m_pCollection, "OConnectionHelper::impl_setURL: have no interpreter for the URLs!" ); + + if ( m_pCollection && sURL.Len() ) + { + if ( m_pCollection->isFileSystemBased( m_eType ) ) + { + // get the tow parts: prefix and file URL + String sTypePrefix, sFileURLEncoded; + if ( _bPrefix ) + { + sTypePrefix = m_pCollection->getPrefix( m_eType ); + sFileURLEncoded = m_pCollection->cutPrefix( sURL ); + } + else + { + sFileURLEncoded = sURL; + } + + // substitute any variables + sFileURLEncoded = SvtPathOptions().SubstituteVariable( sFileURLEncoded ); + + // decode the URL + sURL = sTypePrefix; + if ( sFileURLEncoded.Len() ) + { + OFileNotation aFileNotation(sFileURLEncoded); + // set this decoded URL as text + sURL += String(aFileNotation.get(OFileNotation::N_SYSTEM)); + } + } + } + + if ( _bPrefix ) + m_aConnectionURL.SetText( sURL ); + else + m_aConnectionURL.SetTextNoPrefix( sURL ); + + implUpdateURLDependentStates(); + } + + //------------------------------------------------------------------------- + String OConnectionHelper::impl_getURL( sal_Bool _bPrefix ) const + { + // get the pure text + String sURL = _bPrefix ? m_aConnectionURL.GetText() : m_aConnectionURL.GetTextNoPrefix(); + + DBG_ASSERT( m_pCollection, "OConnectionHelper::impl_getURL: have no interpreter for the URLs!" ); + + if ( m_pCollection && sURL.Len() ) + { + if ( m_pCollection->isFileSystemBased( m_eType ) ) + { + // get the tow parts: prefix and file URL + String sTypePrefix, sFileURLDecoded; + if ( _bPrefix ) + { + sTypePrefix = m_pCollection->getPrefix( m_eType ); + sFileURLDecoded = m_pCollection->cutPrefix( sURL ); + } + else + { + sFileURLDecoded = sURL; + } + + sURL = sTypePrefix; + if ( sFileURLDecoded.Len() ) + { + OFileNotation aFileNotation( sFileURLDecoded, OFileNotation::N_SYSTEM ); + sURL += String( aFileNotation.get( OFileNotation::N_URL ) ); + } + + // encode the URL + INetURLObject aFileURL( sFileURLDecoded, INetURLObject::ENCODE_ALL, RTL_TEXTENCODING_UTF8 ); + sFileURLDecoded = aFileURL.GetMainURL( INetURLObject::NO_DECODE ); + } + } + return sURL; + } + + //------------------------------------------------------------------------- + void OConnectionHelper::setURL( const String& _rURL ) + { + impl_setURL( _rURL, sal_True ); + } + + //------------------------------------------------------------------------- + String OConnectionHelper::getURLNoPrefix( ) const + { + return impl_getURL( sal_False ); + } + + //------------------------------------------------------------------------- + void OConnectionHelper::setURLNoPrefix( const String& _rURL ) + { + impl_setURL( _rURL, sal_False ); + } + + //------------------------------------------------------------------------- + sal_Int32 OConnectionHelper::checkPathExistence(const String& _rURL) + { + IS_PATH_EXIST e_exists = pathExists(_rURL, sal_False); + if (( e_exists == PATH_NOT_EXIST) || ( e_exists == PATH_NOT_KNOWN)) + { + String sQuery(ModuleRes(STR_ASK_FOR_DIRECTORY_CREATION)); + OFileNotation aTransformer(_rURL); + sQuery.SearchAndReplaceAscii("$path$", aTransformer.get(OFileNotation::N_SYSTEM)); + + m_bUserGrabFocus = sal_False; + QueryBox aQuery(GetParent(), WB_YES_NO | WB_DEF_YES, sQuery); + sal_Int32 nQueryResult = aQuery.Execute(); + m_bUserGrabFocus = sal_True; + + switch (nQueryResult) + { + case RET_YES: + { + sal_Bool bTryCreate = sal_False; + do + { + if ( !createDirectoryDeep(_rURL) ) + { // could not create the directory + sQuery = String(ModuleRes(STR_COULD_NOT_CREATE_DIRECTORY)); + sQuery.SearchAndReplaceAscii("$name$", aTransformer.get(OFileNotation::N_SYSTEM)); + + m_bUserGrabFocus = sal_False; + QueryBox aWhatToDo(GetParent(), WB_RETRY_CANCEL | WB_DEF_RETRY, sQuery); + nQueryResult = aWhatToDo.Execute(); + m_bUserGrabFocus = sal_True; + + if (RET_RETRY == nQueryResult) + bTryCreate = sal_True; + else + { + SetRoadmapStateValue(sal_False); + callModifiedHdl(); + return RET_RETRY; + } + } + } + while (bTryCreate); + } + break; + + case RET_NO: + // SetRoadmapStateValue(sal_False); + callModifiedHdl(); + return RET_OK; + + default: + // cancelled + SetRoadmapStateValue(sal_False); + callModifiedHdl(); + return RET_CANCEL; + } + } +/* else + { + // TODO: error msg + return RET_CANCEL; + } */ + SetRoadmapStateValue(sal_True); + callModifiedHdl(); + return RET_OK; + } + + + //------------------------------------------------------------------------- + StringBag OConnectionHelper::getInstalledAdabasDBDirs(const String& _rPath,const ::ucbhelper::ResultSetInclude& _reResultSetInclude) + { + INetURLObject aNormalizer; + aNormalizer.SetSmartProtocol(INET_PROT_FILE); + aNormalizer.SetSmartURL(_rPath); + String sAdabasConfigDir = aNormalizer.GetMainURL(INetURLObject::NO_DECODE); + + ::ucbhelper::Content aAdabasConfigDir; + try + { + aAdabasConfigDir = ::ucbhelper::Content(sAdabasConfigDir, Reference< ::com::sun::star::ucb::XCommandEnvironment >()); + } + catch(::com::sun::star::ucb::ContentCreationException&) + { + return StringBag(); + } + + StringBag aInstalledDBs; + sal_Bool bIsFolder = sal_False; + try + { + bIsFolder = aAdabasConfigDir.isFolder(); + } + catch(Exception&) // the exception is thrown when the path doesn't exists + { + } + if (bIsFolder && aAdabasConfigDir.get().is()) + { // we have a content for the directory, loop through all entries + Sequence< ::rtl::OUString > aProperties(1); + aProperties[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Title")); + + try + { + Reference< XResultSet > xFiles = aAdabasConfigDir.createCursor(aProperties, _reResultSetInclude); + Reference< XRow > xRow(xFiles, UNO_QUERY); + xFiles->beforeFirst(); + while (xFiles->next()) + { +#ifdef DBG_UTIL + ::rtl::OUString sName = xRow->getString(1); +#endif + aInstalledDBs.insert(xRow->getString(1)); + } + } + catch(Exception&) + { + DBG_ERROR("OConnectionHelper::getInstalledAdabasDBDirs: could not enumerate the adabas config files!"); + } + } + + + return aInstalledDBs; + } + // ----------------------------------------------------------------------------- + StringBag OConnectionHelper::getInstalledAdabasDBs(const String &_rConfigDir,const String &_rWorkDir) + { + String sAdabasConfigDir(_rConfigDir),sAdabasWorkDir(_rWorkDir); + + if (sAdabasConfigDir.Len() && ('/' == sAdabasConfigDir.GetBuffer()[sAdabasConfigDir.Len() - 1])) + sAdabasConfigDir.AppendAscii("config"); + else + sAdabasConfigDir.AppendAscii("/config"); + + if (sAdabasWorkDir.Len() && ('/' == sAdabasWorkDir.GetBuffer()[sAdabasWorkDir.Len() - 1])) + sAdabasWorkDir.AppendAscii("wrk"); + else + sAdabasWorkDir.AppendAscii("/wrk"); + // collect the names of the installed databases + StringBag aInstalledDBs; + // collect the names of the installed databases + StringBag aConfigDBs,aWrkDBs; + aConfigDBs = getInstalledAdabasDBDirs(sAdabasConfigDir,::ucbhelper::INCLUDE_DOCUMENTS_ONLY); + aWrkDBs = getInstalledAdabasDBDirs(sAdabasWorkDir,::ucbhelper::INCLUDE_FOLDERS_ONLY); + ConstStringBagIterator aOuter = aConfigDBs.begin(); + ConstStringBagIterator aOuterEnd = aConfigDBs.end(); + for(;aOuter != aOuterEnd;++aOuter) + { + ConstStringBagIterator aInner = aWrkDBs.begin(); + ConstStringBagIterator aInnerEnd = aWrkDBs.end(); + for (;aInner != aInnerEnd; ++aInner) + { + if (aInner->equalsIgnoreAsciiCase(*aOuter)) + { + aInstalledDBs.insert(*aInner); + break; + } + } + } + return aInstalledDBs; + } + // #106016# ------------------------------------------------------------------- + IS_PATH_EXIST OConnectionHelper::pathExists(const ::rtl::OUString& _rURL, sal_Bool bIsFile) const + { + ::ucbhelper::Content aCheckExistence; + sal_Bool bExists = sal_False; + IS_PATH_EXIST eExists = PATH_NOT_EXIST; + Reference< ::com::sun::star::task::XInteractionHandler > xInteractionHandler = Reference< ::com::sun::star::task::XInteractionHandler >( + m_xORB->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.task.InteractionHandler") ) ), UNO_QUERY ); + OFilePickerInteractionHandler* pHandler = new OFilePickerInteractionHandler(xInteractionHandler); + xInteractionHandler = pHandler; + + Reference< XCommandEnvironment > xCmdEnv = new ::ucbhelper::CommandEnvironment( xInteractionHandler, Reference< XProgressHandler >() ); + try + { + aCheckExistence = ::ucbhelper::Content(_rURL, xCmdEnv ); + bExists = bIsFile? aCheckExistence.isDocument(): aCheckExistence.isFolder(); + eExists = bExists? PATH_EXIST: PATH_NOT_EXIST; + } + catch(const Exception&) + { + eExists = ( pHandler && pHandler->isDoesNotExist() ) ? PATH_NOT_EXIST: (bIsFile ? PATH_NOT_EXIST : PATH_NOT_KNOWN); + } + return eExists; + } + //------------------------------------------------------------------------- + long OConnectionHelper::PreNotify( NotifyEvent& _rNEvt ) + { + if ( m_pCollection->isFileSystemBased(m_eType) ) + { + switch (_rNEvt.GetType()) + { + case EVENT_GETFOCUS: + if (m_aConnectionURL.IsWindowOrChild(_rNEvt.GetWindow()) && m_bUserGrabFocus) + { // a descendant of the URL edit field got the focus + m_aConnectionURL.SaveValueNoPrefix(); + } + break; + + case EVENT_LOSEFOCUS: + if (m_aConnectionURL.IsWindowOrChild(_rNEvt.GetWindow()) && m_bUserGrabFocus) + { // a descendant of the URL edit field lost the focus + if (!commitURL()) + return 1L; // handled + } + break; + } // switch (_rNEvt.GetType()) + } + + return OGenericAdministrationPage::PreNotify( _rNEvt ); + } + + //------------------------------------------------------------------------- + + sal_Bool OConnectionHelper::createDirectoryDeep(const String& _rPathURL) + { + ::rtl::OUString sPath(_rPathURL); + + // get an URL object analyzing the URL for us ... + INetURLObject aParser; + aParser.SetURL(_rPathURL); + + INetProtocol eProtocol = aParser.GetProtocol(); + + ::std::vector< ::rtl::OUString > aToBeCreated; // the to-be-created levels + + // search a level which exists + // #106016# --------------------- + IS_PATH_EXIST eParentExists = PATH_NOT_EXIST; + while ( eParentExists == PATH_NOT_EXIST && aParser.getSegmentCount()) + { + aToBeCreated.push_back(aParser.getName()); // remember the local name for creation + aParser.removeSegment(); // cut the local name + eParentExists = pathExists(aParser.GetMainURL(INetURLObject::NO_DECODE), sal_False); + } + + if (!aParser.getSegmentCount()) + return sal_False; + + // create all the missing levels + try + { + // the parent content + Reference< XCommandEnvironment > xEmptyEnv; + ::ucbhelper::Content aParent(aParser.GetMainURL(INetURLObject::NO_DECODE), xEmptyEnv); + + ::rtl::OUString sContentType; + if ( INET_PROT_FILE == eProtocol ) + { + sContentType = ::rtl::OUString::createFromAscii( "application/vnd.sun.staroffice.fsys-folder" ); + // the file UCP currently does not support the ContentType property + } + else + { + Any aContentType = aParent.getPropertyValue( ::rtl::OUString::createFromAscii( "ContentType" ) ); + aContentType >>= sContentType; + } + + // the properties which need to be set on the new content + Sequence< ::rtl::OUString > aNewDirectoryProperties(1); + aNewDirectoryProperties[0] = ::rtl::OUString::createFromAscii("Title"); + + // the values to be set + Sequence< Any > aNewDirectoryAttributes(1); + + // loop + for ( ::std::vector< ::rtl::OUString >::reverse_iterator aLocalName = aToBeCreated.rbegin(); + aLocalName != aToBeCreated.rend(); + ++aLocalName + ) + { + aNewDirectoryAttributes[0] <<= *aLocalName; + if (!aParent.insertNewContent(sContentType, aNewDirectoryProperties, aNewDirectoryAttributes, aParent)) + return sal_False; + } + } + catch ( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + return sal_False; + } + + return sal_True; + } + + + // ----------------------------------------------------------------------- + void OConnectionHelper::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) + { + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFT_Connection)); + _rControlList.push_back(new ODisableWrapper<PushButton>(&m_aPB_Connection)); + } + + + // ----------------------------------------------------------------------- + void OConnectionHelper::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) + { + _rControlList.push_back( new OSaveValueWrapper<Edit>( &m_aConnectionURL ) ); + } + + //------------------------------------------------------------------------- + sal_Bool OConnectionHelper::commitURL() + { + String sURL; + String sOldPath; + sOldPath = m_aConnectionURL.GetSavedValueNoPrefix(); + sURL = m_aConnectionURL.GetTextNoPrefix(); + + if ( m_pCollection->isFileSystemBased(m_eType) ) + { + if ( ( sURL != sOldPath ) && ( 0 != sURL.Len() ) ) + { // the text changed since entering the control + + // the path may be in system notation .... + OFileNotation aTransformer(sURL); + sURL = aTransformer.get(OFileNotation::N_URL); + + const ::dbaccess::DATASOURCE_TYPE eType = m_pCollection->determineType(m_eType); + + if ( ( ::dbaccess::DST_CALC == eType) || ( ::dbaccess::DST_MSACCESS == eType) || ( ::dbaccess::DST_MSACCESS_2007 == eType) ) + { // #106016# -------------------------- + if( pathExists(sURL, sal_True) == PATH_NOT_EXIST ) + { + String sFile = String( ModuleRes( STR_FILE_DOES_NOT_EXIST ) ); + sFile.SearchAndReplaceAscii("$file$", aTransformer.get(OFileNotation::N_SYSTEM)); + OSQLWarningBox( this, sFile ).Execute(); + setURLNoPrefix(sOldPath); + SetRoadmapStateValue(sal_False); + callModifiedHdl(); + return sal_False; + } + } + else + { + switch (checkPathExistence(sURL)) + { + case RET_RETRY: + m_bUserGrabFocus = sal_False; + m_aConnectionURL.GrabFocus(); + m_bUserGrabFocus = sal_True; + return sal_False; + + case RET_CANCEL: + setURLNoPrefix(sOldPath); + return sal_False; + } + } + } + } + + setURLNoPrefix(sURL); + m_aConnectionURL.SaveValueNoPrefix(); + return sal_True; + } + //------------------------------------------------------------------------- + void OConnectionHelper::askForFileName(::sfx2::FileDialogHelper& _aFileOpen) + { + String sOldPath = getURLNoPrefix(); + if ( sOldPath.Len() ) + _aFileOpen.SetDisplayDirectory(sOldPath); + else + _aFileOpen.SetDisplayDirectory( SvtPathOptions().GetWorkPath() ); + if (0 == _aFileOpen.Execute()) + { + setURLNoPrefix(_aFileOpen.GetPath()); + SetRoadmapStateValue(checkTestConnection()); + callModifiedHdl(); + } + } + +//......................................................................... +} // namespace dbaui +//......................................................................... diff --git a/dbaccess/source/ui/dlg/ConnectionHelper.hxx b/dbaccess/source/ui/dlg/ConnectionHelper.hxx new file mode 100644 index 000000000000..94c2678f9714 --- /dev/null +++ b/dbaccess/source/ui/dlg/ConnectionHelper.hxx @@ -0,0 +1,140 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBAUI_CONNECTIONHELPER_HXX +#define DBAUI_CONNECTIONHELPER_HXX + +#ifndef _DBAUI_ADMINPAGES_HXX_ +#include "adminpages.hxx" +#endif +#ifndef _UCBHELPER_CONTENT_HXX +#include <ucbhelper/content.hxx> +#endif +#ifndef _DBAUI_CURLEDIT_HXX_ +#include "curledit.hxx" +#endif +#ifndef _SFX_FILEDLGHELPER_HXX +#include <sfx2/filedlghelper.hxx> +#endif + + +#define FILL_STRING_ITEM(editcontrol, itemset, itemid, modifiedflag) \ + if (editcontrol.GetText() != editcontrol.GetSavedValue()) \ + { \ + itemset.Put(SfxStringItem(itemid, editcontrol.GetText())); \ + modifiedflag = sal_True; \ + } + +//......................................................................... +namespace dbaui +{ +//......................................................................... + + // #106016# -------------- + enum IS_PATH_EXIST + { + PATH_NOT_EXIST = 0, + PATH_EXIST, + PATH_NOT_KNOWN + }; + + class IDatabaseSettingsDialog; + + class OConnectionHelper : public OGenericAdministrationPage + { + sal_Bool m_bUserGrabFocus : 1; + + public: + OConnectionHelper( Window* pParent, const ResId& _rId, const SfxItemSet& _rCoreAttrs); + virtual ~OConnectionHelper(); + FixedText m_aFT_Connection; + OConnectionURLEdit m_aConnectionURL; + PushButton m_aPB_Connection; + ::rtl::OUString m_eType; // the type can't be changed in this class, so we hold it as member. + + public: + + // setting/retrieving the current connection URL + // necessary because for some types, the URL must be decoded for display purposes + ::dbaccess::ODsnTypeCollection* m_pCollection; /// the DSN type collection instance + virtual long PreNotify( NotifyEvent& _rNEvt ); + + // <method>OGenericAdministrationPage::fillControls</method> + virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList); + // <method>OGenericAdministrationPage::fillWindows</method> + virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList); + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + + + // setting/retrieving the current connection URL + // necessary because for some types, the URL must be decoded for display purposes + //String getURL( OConnectionURLEdit* _m_pConnection ) const; + //void setURL( const String& _rURL, OConnectionURLEdit* _m_pConnection ); + + String getURLNoPrefix( ) const; + void setURLNoPrefix( const String& _rURL ); + + /** checks if the path is existence + @param _rURL + The URL to check. + */ + sal_Int32 checkPathExistence(const String& _rURL); + + + IS_PATH_EXIST pathExists(const ::rtl::OUString& _rURL, sal_Bool bIsFile) const; + sal_Bool createDirectoryDeep(const String& _rPathNormalized); + sal_Bool commitURL(); + + /** opens the FileOpen dialog and asks for a FileName + @param _aFileOpen + Executes the file open dialog, which must be filled from caller. + */ + void askForFileName(::sfx2::FileDialogHelper& _aFileOpen); + + virtual void SetServiceFactory(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxORB) + { + OGenericAdministrationPage::SetServiceFactory(_rxORB); + } + + protected: + void setURL( const String& _rURL ); + virtual bool checkTestConnection(); + + private: + DECL_LINK(OnBrowseConnections, PushButton*); + StringBag getInstalledAdabasDBDirs(const String &_rPath,const ::ucbhelper::ResultSetInclude& _reResultSetInclude); + StringBag getInstalledAdabasDBs(const String &_rConfigDir,const String &_rWorkDir); + String impl_getURL( sal_Bool _bPrefix ) const; + void impl_setURL( const String& _rURL, sal_Bool _bPrefix ); + void implUpdateURLDependentStates() const; + }; + +//......................................................................... +} // namespace dbaui +//......................................................................... + +#endif // DBAUI_CONNECTIONHELPER_HXX diff --git a/dbaccess/source/ui/dlg/ConnectionPage.cxx b/dbaccess/source/ui/dlg/ConnectionPage.cxx new file mode 100644 index 000000000000..dac80070a640 --- /dev/null +++ b/dbaccess/source/ui/dlg/ConnectionPage.cxx @@ -0,0 +1,466 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#ifndef DBAUI_CONNECTIONPAGE_HXX +#include "ConnectionPage.hxx" +#endif +#ifndef DBAUI_CONNECTIONPAGE_HRC +#include "ConnectionPage.hrc" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef DBACCESS_DSMETA_HXX +#include "dsmeta.hxx" +#endif +#ifndef _SFXITEMSET_HXX +#include <svl/itemset.hxx> +#endif +#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX +#include <unotools/pathoptions.hxx> +#endif +#ifndef _SFXSTRITEM_HXX +#include <svl/stritem.hxx> +#endif +#ifndef _SFXENUMITEM_HXX +#include <svl/eitem.hxx> +#endif +#ifndef _SFXINTITEM_HXX +#include <svl/intitem.hxx> +#endif +#ifndef INCLUDED_SVTOOLS_MODULEOPTIONS_HXX +#include <unotools/moduleoptions.hxx> +#endif +#ifndef _DBAUI_DATASOURCEITEMS_HXX_ +#include "dsitems.hxx" +#endif +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif +#ifndef _DBAUI_LOCALRESACCESS_HXX_ +#include "localresaccess.hxx" +#endif +#ifndef _OSL_PROCESS_H_ +#include <osl/process.h> +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif +#ifndef _FILEDLGHELPER_HXX +#include <sfx2/filedlghelper.hxx> +#endif +#ifndef _DBAUI_DBADMIN_HXX_ +#include "dbadmin.hxx" +#endif +#ifndef _COMPHELPER_TYPES_HXX_ +#include <comphelper/types.hxx> +#endif +#ifndef _VCL_STDTEXT_HXX +#include <vcl/stdtext.hxx> +#endif +#ifndef _DBAUI_SQLMESSAGE_HXX_ +#include "sqlmessage.hxx" +#endif +#ifndef _DBAUI_ODBC_CONFIG_HXX_ +#include "odbcconfig.hxx" +#endif +#ifndef _DBAUI_DSSELECT_HXX_ +#include "dsselect.hxx" +#endif +#ifndef SVTOOLS_FILENOTATION_HXX_ +#include <svl/filenotation.hxx> +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef _COM_SUN_STAR_UI_DIALOGS_XFOLDERPICKER_HPP_ +#include <com/sun/star/ui/dialogs/XFolderPicker.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_ +#include <com/sun/star/awt/XWindow.hpp> +#endif +// #106016# ------------------------------------ +#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_ +#include <com/sun/star/task/XInteractionHandler.hpp> +#endif +#ifndef _COM_SUN_STAR_TASK_XPROGRESSHANDLER_HPP_ +#include <com/sun/star/ucb/XProgressHandler.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ +#include <com/sun/star/sdbc/XConnection.hpp> +#endif +#ifndef _COM_SUN_STAR_UI_DIALOGS_EXTENDEDFILEPICKERELEMENTIDS_HPP_ +#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> +#endif +#ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPICKERCONTROLACCESS_HPP_ +#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPICKER_HPP_ +#include <com/sun/star/ui/dialogs/XFilePicker.hpp> +#endif +#ifndef DBAUI_TOOLS_HXX +#include "UITools.hxx" +#endif +#ifndef _UNOTOOLS_LOCALFILEHELPER_HXX +#include <unotools/localfilehelper.hxx> +#endif +#ifndef _UNOTOOLS_UCBHELPER_HXX +#include <unotools/ucbhelper.hxx> +#endif +#ifndef _UCBHELPER_COMMANDENVIRONMENT_HXX +#include <ucbhelper/commandenvironment.hxx> +#endif +#ifndef DBAUI_FILEPICKER_INTERACTION_HXX +#include "finteraction.hxx" +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include <connectivity/CommonTools.hxx> +#endif +#ifndef _URLOBJ_HXX +#include <tools/urlobj.hxx> +#endif +#ifndef _SFX_DOCFILT_HACK_HXX +#include <sfx2/docfilt.hxx> +#endif +#include "dsnItem.hxx" +#if defined(WIN) || defined(WNT) +#define _ADO_DATALINK_BROWSE_ +#endif + +#ifdef _ADO_DATALINK_BROWSE_ +#if defined( WNT ) + #include <tools/prewin.h> + #include <windows.h> + #include <tools/postwin.h> +#endif +#ifndef _SV_SYSDATA_HXX +#include <vcl/sysdata.hxx> +#endif +#ifndef _DBAUI_ADO_DATALINK_HXX_ +#include "adodatalinks.hxx" +#endif +#endif //_ADO_DATALINK_BROWSE_ + +#include "AutoControls.hrc" + +//......................................................................... +namespace dbaui +{ +//......................................................................... + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::ucb; + using namespace ::com::sun::star::ui::dialogs; + using namespace ::com::sun::star::sdbc; + using namespace ::com::sun::star::beans; + using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::container; + using namespace ::dbtools; + using namespace ::svt; + + SfxTabPage* OConnectionTabPage::Create( Window* pParent, const SfxItemSet& _rAttrSet ) + { + return ( new OConnectionTabPage( pParent, _rAttrSet ) ); + } + //======================================================================== + //= OConnectionTabPage + //======================================================================== + DBG_NAME(OConnectionTabPage) + OConnectionTabPage::OConnectionTabPage(Window* pParent, const SfxItemSet& _rCoreAttrs) + :OConnectionHelper(pParent, ModuleRes(PAGE_CONNECTION), _rCoreAttrs) + ,m_bUserGrabFocus(sal_True) + ,m_aFL1(this, ModuleRes(FL_SEPARATOR1)) + ,m_aFL2(this, ModuleRes(FL_SEPARATOR2)) + ,m_aUserNameLabel(this, ModuleRes(FT_USERNAME)) + ,m_aUserName(this, ModuleRes(ET_USERNAME)) + ,m_aPasswordRequired(this, ModuleRes(CB_PASSWORD_REQUIRED)) + ,m_aFL3(this, ModuleRes(FL_SEPARATOR3)) + ,m_aJavaDriverLabel(this, ModuleRes(FT_JDBCDRIVERCLASS)) + ,m_aJavaDriver(this, ModuleRes(ET_JDBCDRIVERCLASS)) + ,m_aTestJavaDriver(this, ModuleRes(PB_TESTDRIVERCLASS)) + ,m_aTestConnection(this, ModuleRes(PB_TESTCONNECTION)) + { + DBG_CTOR(OConnectionTabPage,NULL); + m_aConnectionURL.SetModifyHdl(LINK(this, OConnectionTabPage, OnEditModified)); + m_aJavaDriver.SetModifyHdl(getControlModifiedLink()); + m_aJavaDriver.SetModifyHdl(LINK(this, OConnectionTabPage, OnEditModified)); + m_aUserName.SetModifyHdl(getControlModifiedLink()); + m_aPasswordRequired.SetClickHdl(getControlModifiedLink()); + + m_aTestConnection.SetClickHdl(LINK(this,OGenericAdministrationPage,OnTestConnectionClickHdl)); + m_aTestJavaDriver.SetClickHdl(LINK(this,OConnectionTabPage,OnTestJavaClickHdl)); + + FreeResource(); + } + + // ----------------------------------------------------------------------- + OConnectionTabPage::~OConnectionTabPage() + { + DBG_DTOR(OConnectionTabPage,NULL); + } + + // ----------------------------------------------------------------------- + void OConnectionTabPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) + { + // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) + sal_Bool bValid, bReadonly; + getFlags(_rSet, bValid, bReadonly); + + m_eType = m_pAdminDialog->getDatasourceType(_rSet); + OConnectionHelper::implInitControls( _rSet, _bSaveValue); + + LocalResourceAccess aLocRes( PAGE_CONNECTION, RSC_TABPAGE ); + ::dbaccess::DATASOURCE_TYPE eType = m_pCollection->determineType(m_eType); + switch( eType ) + { + case ::dbaccess::DST_DBASE: + m_aFT_Connection.SetText(String(ModuleRes(STR_DBASE_PATH_OR_FILE))); + m_aConnectionURL.SetHelpId(HID_DSADMIN_DBASE_PATH); + break; + case ::dbaccess::DST_FLAT: + m_aFT_Connection.SetText(String(ModuleRes(STR_FLAT_PATH_OR_FILE))); + m_aConnectionURL.SetHelpId(HID_DSADMIN_FLAT_PATH); + break; + case ::dbaccess::DST_CALC: + m_aFT_Connection.SetText(String(ModuleRes(STR_CALC_PATH_OR_FILE))); + m_aConnectionURL.SetHelpId(HID_DSADMIN_CALC_PATH); + break; + case ::dbaccess::DST_ADABAS: + m_aFT_Connection.SetText(String(ModuleRes(STR_ADABAS_DATABASE_NAME))); + m_aConnectionURL.SetHelpId(HID_DSADMIN_ADABAS_DATABASE); + break; + case ::dbaccess::DST_ADO: + m_aFT_Connection.SetText(String(ModuleRes(STR_COMMONURL))); + break; + case ::dbaccess::DST_MSACCESS: + case ::dbaccess::DST_MSACCESS_2007: + m_aFT_Connection.SetText(String(ModuleRes(STR_MSACCESS_MDB_FILE))); + m_aConnectionURL.SetHelpId(HID_DSADMIN_MSACCESS_MDB_FILE); + break; + case ::dbaccess::DST_MYSQL_NATIVE: + case ::dbaccess::DST_MYSQL_JDBC: + m_aFT_Connection.SetText(String(ModuleRes(STR_MYSQL_DATABASE_NAME))); + m_aConnectionURL.SetHelpId( HID_DSADMIN_MYSQL_DATABASE ); + break; + case ::dbaccess::DST_ORACLE_JDBC: + m_aFT_Connection.SetText(String(ModuleRes(STR_ORACLE_DATABASE_NAME))); + m_aConnectionURL.SetHelpId(HID_DSADMIN_ORACLE_DATABASE); + break; + case ::dbaccess::DST_MYSQL_ODBC: + case ::dbaccess::DST_ODBC: + m_aFT_Connection.SetText(String(ModuleRes(STR_NAME_OF_ODBC_DATASOURCE))); + m_aConnectionURL.SetHelpId( eType == ::dbaccess::DST_MYSQL_ODBC ? HID_DSADMIN_MYSQL_ODBC_DATASOURCE : HID_DSADMIN_ODBC_DATASOURCE); + break; + case ::dbaccess::DST_LDAP: + m_aFT_Connection.SetText(String(ModuleRes(STR_HOSTNAME))); + m_aConnectionURL.SetHelpId( HID_DSADMIN_LDAP_HOSTNAME ); + break; + case ::dbaccess::DST_MOZILLA: + m_aFT_Connection.SetText(String(ModuleRes(STR_MOZILLA_PROFILE_NAME))); + m_aConnectionURL.SetHelpId( HID_DSADMIN_MOZILLA_PROFILE_NAME ); + break; + case ::dbaccess::DST_THUNDERBIRD: + m_aFT_Connection.SetText(String(ModuleRes(STR_THUNDERBIRD_PROFILE_NAME))); + m_aConnectionURL.SetHelpId( HID_DSADMIN_THUNDERBIRD_PROFILE_NAME ); + break; + case ::dbaccess::DST_OUTLOOK: + case ::dbaccess::DST_OUTLOOKEXP: + case ::dbaccess::DST_EVOLUTION: + case ::dbaccess::DST_EVOLUTION_GROUPWISE: + case ::dbaccess::DST_EVOLUTION_LDAP: + case ::dbaccess::DST_KAB: + case ::dbaccess::DST_MACAB: + m_aFT_Connection.SetText(String(ModuleRes(STR_NO_ADDITIONAL_SETTINGS))); + { + String sText = m_aFT_Connection.GetText(); + sText.SearchAndReplaceAscii("%test",m_aTestConnection.GetText()); + String sTemp; + sText.SearchAndReplaceAscii("~",sTemp); + m_aFT_Connection.SetText(sText); + } + m_aConnectionURL.Hide(); + break; + case ::dbaccess::DST_JDBC: + default: + m_aFT_Connection.SetText(String(ModuleRes(STR_COMMONURL))); + break; + } + + ; + AuthenticationMode eAuthMode( DataSourceMetaData::getAuthentication( m_eType ) ); + bool bShowUserAuthenfication = ( eAuthMode != AuthNone ); + bool bShowUser = ( eAuthMode == AuthUserPwd ); + + m_aPB_Connection.SetHelpId(HID_DSADMIN_BROWSECONN); + m_aFL2.Show( bShowUserAuthenfication ); + m_aUserNameLabel.Show( bShowUser && bShowUserAuthenfication ); + m_aUserName.Show( bShowUser && bShowUserAuthenfication ); + m_aPasswordRequired.Show( bShowUserAuthenfication ); + if ( !bShowUser && bShowUserAuthenfication ) + m_aPasswordRequired.SetPosPixel(m_aUserNameLabel.GetPosPixel()); + + // collect the items + SFX_ITEMSET_GET(_rSet, pUidItem, SfxStringItem, DSID_USER, sal_True); + + SFX_ITEMSET_GET(_rSet, pJdbcDrvItem, SfxStringItem, DSID_JDBCDRIVERCLASS, sal_True); + SFX_ITEMSET_GET(_rSet, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True); + SFX_ITEMSET_GET(_rSet, pAllowEmptyPwd, SfxBoolItem, DSID_PASSWORDREQUIRED, sal_True); + + // forward the values to the controls + if ( bValid ) + { + m_aUserName.SetText(pUidItem->GetValue()); + m_aPasswordRequired.Check(pAllowEmptyPwd->GetValue()); + + String sUrl = pUrlItem->GetValue(); + setURL( sUrl ); + + const BOOL bEnableJDBC = m_pCollection->determineType(m_eType) == ::dbaccess::DST_JDBC; + if ( !pJdbcDrvItem->GetValue().Len() ) + { + String sDefaultJdbcDriverName = m_pCollection->getJavaDriverClass(m_eType); + if ( sDefaultJdbcDriverName.Len() ) + { + m_aJavaDriver.SetText(sDefaultJdbcDriverName); + m_aJavaDriver.SetModifyFlag(); + } + } // if ( !pJdbcDrvItem->GetValue().Len() ) + else + m_aJavaDriver.SetText(pJdbcDrvItem->GetValue()); + + m_aJavaDriverLabel.Show(bEnableJDBC); + m_aJavaDriver.Show(bEnableJDBC); + m_aTestJavaDriver.Show(bEnableJDBC); + m_aTestJavaDriver.Enable( m_aJavaDriver.GetText().Len() != 0); + m_aFL3.Show(bEnableJDBC); + + checkTestConnection(); + + m_aUserName.ClearModifyFlag(); + m_aConnectionURL.ClearModifyFlag(); + m_aJavaDriver.ClearModifyFlag(); + } + } + // ----------------------------------------------------------------------- + void OConnectionTabPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) + { + _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL1)); + + _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL2)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aJavaDriverLabel)); + _rControlList.push_back(new ODisableWrapper<PushButton>(&m_aTestJavaDriver)); + + _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL3)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aUserNameLabel)); + _rControlList.push_back(new ODisableWrapper<PushButton>(&m_aTestConnection)); + OConnectionHelper::fillWindows(_rControlList); + + } + // ----------------------------------------------------------------------- + void OConnectionTabPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) + { + _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aJavaDriver)); + _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aUserName)); + _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aPasswordRequired)); + OConnectionHelper::fillControls(_rControlList); + } + + // ----------------------------------------------------------------------- + sal_Bool OConnectionTabPage::FillItemSet(SfxItemSet& _rSet) + { + sal_Bool bChangedSomething = sal_False; + + if (m_aUserName.GetText() != m_aUserName.GetSavedValue()) + { + _rSet.Put(SfxStringItem(DSID_USER, m_aUserName.GetText())); + _rSet.Put(SfxStringItem(DSID_PASSWORD, String())); + bChangedSomething = sal_True; + } + + fillBool(_rSet,&m_aPasswordRequired,DSID_PASSWORDREQUIRED,bChangedSomething); + + if ( m_pCollection->determineType(m_eType) == ::dbaccess::DST_JDBC ) + { + fillString(_rSet,&m_aJavaDriver, DSID_JDBCDRIVERCLASS, bChangedSomething); + } + + fillString(_rSet,&m_aConnectionURL, DSID_CONNECTURL, bChangedSomething); + + return bChangedSomething; + } + // ----------------------------------------------------------------------- + IMPL_LINK(OConnectionTabPage, OnTestJavaClickHdl, PushButton*, /*_pButton*/) + { + OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF"); + sal_Bool bSuccess = sal_False; + try + { + if ( m_aJavaDriver.GetText().Len() ) + { + ::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM(m_pAdminDialog->getORB()); + bSuccess = ::connectivity::existsJavaClassByName(xJVM,m_aJavaDriver.GetText()); + } + } + catch(Exception&) + { + } + + USHORT nMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS; + OSQLMessageBox aMsg( this, String( ModuleRes( nMessage ) ), String() ); + aMsg.Execute(); + return 0L; + } + // ----------------------------------------------------------------------- + bool OConnectionTabPage::checkTestConnection() + { + OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF"); + BOOL bEnableTestConnection = !m_aConnectionURL.IsVisible() || (m_aConnectionURL.GetTextNoPrefix().Len() != 0); + if ( m_pCollection->determineType(m_eType) == ::dbaccess::DST_JDBC ) + bEnableTestConnection = bEnableTestConnection && (m_aJavaDriver.GetText().Len() != 0); + m_aTestConnection.Enable(bEnableTestConnection); + return true; + } + // ----------------------------------------------------------------------- + IMPL_LINK(OConnectionTabPage, OnEditModified, Edit*, _pEdit) + { + if ( _pEdit == &m_aJavaDriver ) + m_aTestJavaDriver.Enable( m_aJavaDriver.GetText().Len() != 0 ); + + checkTestConnection(); + // tell the listener we were modified + callModifiedHdl(); + return 0L; + } +//......................................................................... +} // namespace dbaui +//......................................................................... + diff --git a/dbaccess/source/ui/dlg/ConnectionPage.hrc b/dbaccess/source/ui/dlg/ConnectionPage.hrc new file mode 100644 index 000000000000..347b0f0bac28 --- /dev/null +++ b/dbaccess/source/ui/dlg/ConnectionPage.hrc @@ -0,0 +1,59 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBAUI_CONNECTIONPAGE_HRC +#define DBAUI_CONNECTIONPAGE_HRC + +//======================================================================== +// control ids + +#define FT_USERNAME 1 +#define FT_JDBCDRIVERCLASS 2 +#define FT_DBASE_PATH_OR_FILE 3 +#define FT_NAME_OF_ODBC_DATASOURCE 4 +#define FT_MYSQL_DATABASE_NAME 5 +#define FT_MSACCESS_MDB_FILE 6 +#define FT_FLAT_PATH_OR_FILE 7 +#define FT_CALC_PATH_OR_FILE 8 +#define FT_ADABAS_DATABASE_NAME 9 +#define FT_NO_ADDITIONAL_SETTINGS 10 +#define FT_HOSTNAME 11 +#define FT_ORACLE_DATABASE_NAME 12 + +#define ET_USERNAME 1 +#define ET_JDBCDRIVERCLASS 2 + +#define PB_TESTDRIVERCLASS 1 +#define PB_TESTCONNECTION 2 + +#define CB_PASSWORD_REQUIRED 1 + +#define FL_SEPARATOR2 1 +#define FL_SEPARATOR3 2 + +#endif // DBAUI_CONNECTIONPAGE_HRC + diff --git a/dbaccess/source/ui/dlg/ConnectionPage.hxx b/dbaccess/source/ui/dlg/ConnectionPage.hxx new file mode 100644 index 000000000000..2d6fef74c598 --- /dev/null +++ b/dbaccess/source/ui/dlg/ConnectionPage.hxx @@ -0,0 +1,114 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBAUI_CONNECTIONPAGE_HXX +#define DBAUI_CONNECTIONPAGE_HXX + +#ifndef DBAUI_CONNECTIONHELPER_HXX +#include "ConnectionHelper.hxx" +#endif +#ifndef _DBAUI_ADMINPAGES_HXX_ +#include "adminpages.hxx" +#endif +#ifndef _UCBHELPER_CONTENT_HXX +#include <ucbhelper/content.hxx> +#endif +#ifndef _DBAUI_CURLEDIT_HXX_ +#include "curledit.hxx" +#endif + +//......................................................................... +namespace dbaui +{ +//......................................................................... + + class IDatabaseSettingsDialog; + //========================================================================= + //= OConnectionTabPage + //========================================================================= + + /** implements the connection page of teh data source properties dialog. + */ + class OConnectionTabPage : public OConnectionHelper + { + sal_Bool m_bUserGrabFocus : 1; + protected: + // connection + FixedLine m_aFL1; + // user authentification + FixedLine m_aFL2; + FixedText m_aUserNameLabel; + Edit m_aUserName; + CheckBox m_aPasswordRequired; + + // jdbc driver + FixedLine m_aFL3; + FixedText m_aJavaDriverLabel; + Edit m_aJavaDriver; + PushButton m_aTestJavaDriver; + + // connection test + PushButton m_aTestConnection; + + + // called when the test connection button was clicked + DECL_LINK(OnTestJavaClickHdl,PushButton*); + DECL_LINK(OnEditModified,Edit*); + + public: + static SfxTabPage* Create( Window* pParent, const SfxItemSet& _rAttrSet ); + virtual BOOL FillItemSet (SfxItemSet& _rCoreAttrs); + + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + + inline void enableConnectionURL() { m_aConnectionURL.SetReadOnly(sal_False); } + inline void disableConnectionURL() { m_aConnectionURL.SetReadOnly(); } + + /** changes the connection URL. + <p>The new URL must be of the type which is currently selected, only the parts which do not + affect the type may be changed (compared to the previous URL).</p> + */ + private: + OConnectionTabPage(Window* pParent, const SfxItemSet& _rCoreAttrs); + // nControlFlags ist eine Kombination der CBTP_xxx-Konstanten + virtual ~OConnectionTabPage(); + + // <method>OGenericAdministrationPage::fillControls</method> + virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList); + // <method>OGenericAdministrationPage::fillWindows</method> + virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList); + + private: + /** enables the test connection button, if allowed + */ + virtual bool checkTestConnection(); + }; +//......................................................................... +} // namespace dbaui +//......................................................................... + +#endif // _DBAUI_DETAILPAGES_HXX_ diff --git a/dbaccess/source/ui/dlg/ConnectionPage.src b/dbaccess/source/ui/dlg/ConnectionPage.src new file mode 100644 index 000000000000..8ead374bdef4 --- /dev/null +++ b/dbaccess/source/ui/dlg/ConnectionPage.src @@ -0,0 +1,187 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef DBAUI_CONNECTIONPAGE_HRC +#include "ConnectionPage.hrc" +#endif +#ifndef _DBAUI_AUTOCONTROLS_HRC_ +#include "AutoControls.hrc" +#endif + + +//......................................................................... +TabPage PAGE_CONNECTION +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( PAGE_X , PAGE_Y ) ; + Hide = TRUE; + + FixedLine FL_SEPARATOR1 + { + Pos = MAP_APPFONT ( 4 , UNRELATED_CONTROLS ) ; + Size = MAP_APPFONT ( PAGE_X - 8 , FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "General"; + }; + + + AUTO_BROWSECONTROLGROUP( 6, UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + RELATED_CONTROLS, PAGE_X, HID_DSADMIN_URL_GENERAL) + + + FixedText FT_NO_ADDITIONAL_SETTINGS + { + Hide = TRUE; + WordBreak = TRUE; + Pos = MAP_APPFONT ( 6 , UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + RELATED_CONTROLS ) ; + Size = MAP_APPFONT ( PAGE_X - 12 , 3*FIXEDTEXT_HEIGHT ) ; + }; + + + FixedText FT_HOSTNAME + { + Hide = TRUE; + Pos = MAP_APPFONT ( 6 , UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + RELATED_CONTROLS ) ; + Size = MAP_APPFONT ( PAGE_X - 12 , FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "~Host name"; + }; + + + FixedLine FL_SEPARATOR2 + { + Pos = MAP_APPFONT ( 4 , 3*FIXEDTEXT_HEIGHT + 3*UNRELATED_CONTROLS + RELATED_CONTROLS ) ; + Size = MAP_APPFONT ( PAGE_X - 8 , FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "User authentication"; + }; + + FixedText FT_USERNAME + { + Pos = MAP_APPFONT ( 6 , 3*UNRELATED_CONTROLS + 4*FIXEDTEXT_HEIGHT + 2*RELATED_CONTROLS ) ; + Size = MAP_APPFONT ( 90 - 12 , FIXEDTEXT_HEIGHT ) ; + Text [ en-US ] = "~User name" ; + }; + Edit ET_USERNAME + { + Border = TRUE ; + Pos = MAP_APPFONT ( 90 , 3*UNRELATED_CONTROLS + 4*FIXEDTEXT_HEIGHT + 2*RELATED_CONTROLS -1 ) ; + Size = MAP_APPFONT ( 105 , EDIT_HEIGHT ) ; + TabStop = TRUE ; + }; + CheckBox CB_PASSWORD_REQUIRED + { + Pos = MAP_APPFONT ( 90 , 4*UNRELATED_CONTROLS + 5*FIXEDTEXT_HEIGHT + 2*RELATED_CONTROLS ) ; + Size = MAP_APPFONT ( 105 , CHECKBOX_HEIGHT ) ; + Text [ en-US ] = "Password required"; + }; + + FixedLine FL_SEPARATOR3 + { + Pos = MAP_APPFONT ( 4 , 5*UNRELATED_CONTROLS + 5*FIXEDTEXT_HEIGHT + 2*RELATED_CONTROLS + CHECKBOX_HEIGHT) ; + + Size = MAP_APPFONT ( PAGE_X - 8 , FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "JDBC properties"; + }; + + FixedText FT_JDBCDRIVERCLASS + { + Pos = MAP_APPFONT ( 6 , 5*UNRELATED_CONTROLS + 6*FIXEDTEXT_HEIGHT + 3*RELATED_CONTROLS + CHECKBOX_HEIGHT) ; + + Size = MAP_APPFONT ( 90 - 12 , FIXEDTEXT_HEIGHT ) ; + Text [ en-US ] = "~JDBC driver class" ; + }; + Edit ET_JDBCDRIVERCLASS + { + Border = TRUE ; + Pos = MAP_APPFONT ( 90 , 5*UNRELATED_CONTROLS + 6*FIXEDTEXT_HEIGHT + 3*RELATED_CONTROLS + CHECKBOX_HEIGHT -1) ; + Size = MAP_APPFONT ( 105 , EDIT_HEIGHT ) ; + TabStop = TRUE ; + HelpId = HID_DSADMIN_DRIVERCLASS; + }; + + PushButton PB_TESTDRIVERCLASS + { + TabStop = TRUE ; + Pos = MAP_APPFONT ( PAGE_X - BUTTON_WIDTH - UNRELATED_CONTROLS , 5*UNRELATED_CONTROLS + 6*FIXEDTEXT_HEIGHT + 3*RELATED_CONTROLS + CHECKBOX_HEIGHT -2 ) ; + Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ; + Text [ en-US ] = "Test Class" ; + }; + + PushButton PB_TESTCONNECTION + { + Pos = MAP_APPFONT ( PAGE_X - 75 - UNRELATED_CONTROLS, PAGE_Y - BUTTON_HEIGHT - UNRELATED_CONTROLS) ; + Size = MAP_APPFONT ( 75 , BUTTON_HEIGHT ) ; + TabStop = TRUE ; + Text [ en-US ] = "Test Connection"; + }; + +}; + +String STR_NO_ADABASE_DATASOURCES +{ + Text [ en-US ] = "No Adabas D data sources were found on your system."; +}; + +String STR_CONNECTION_TEST +{ + Text [ en-US ] = "Connection Test"; +}; + +String STR_CONNECTION_SUCCESS +{ + Text [ en-US ] = "The connection was established successfully."; +}; + +String STR_CONNECTION_NO_SUCCESS +{ + Text [ en-US ] = "The connection could not be established."; +}; + +String STR_JDBCDRIVER_SUCCESS +{ + Text [ en-US ] = "The JDBC driver was loaded successfully."; +}; + +String STR_JDBCDRIVER_NO_SUCCESS +{ + Text [ en-US ] = "The JDBC driver could not be loaded."; +}; + +String STR_MSACCESS_FILTERNAME +{ + Text [ en-US ] = "MS Access file"; +}; + +String STR_MSACCESS_2007_FILTERNAME +{ + Text [ en-US ] = "MS Access 2007 file"; +}; + diff --git a/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx b/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx new file mode 100644 index 000000000000..f53054d37339 --- /dev/null +++ b/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx @@ -0,0 +1,321 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#ifndef DBAUI_CONNECTIONPAGESETUP_HXX +#include "ConnectionPageSetup.hxx" +#endif +#ifndef _DBAUI_AUTOCONTROLS_HRC_ +#include "AutoControls.hrc" +#endif +#ifndef _DBAUI_DBADMINSETUP_HRC_ +#include "dbadminsetup.hrc" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef _SFXITEMSET_HXX +#include <svl/itemset.hxx> +#endif +#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX +#include <unotools/pathoptions.hxx> +#endif +#ifndef _SFXSTRITEM_HXX +#include <svl/stritem.hxx> +#endif +#ifndef _SFXENUMITEM_HXX +#include <svl/eitem.hxx> +#endif +#ifndef _SFXINTITEM_HXX +#include <svl/intitem.hxx> +#endif +#ifndef _DBAUI_DATASOURCEITEMS_HXX_ +#include "dsitems.hxx" +#endif +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif +#ifndef _DBAUI_LOCALRESACCESS_HXX_ +#include "localresaccess.hxx" +#endif +#ifndef _OSL_PROCESS_H_ +#include <osl/process.h> +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif +#ifndef _FILEDLGHELPER_HXX +#include <sfx2/filedlghelper.hxx> +#endif +#ifndef _DBAUI_DBADMIN_HXX_ +#include "dbadmin.hxx" +#endif +#ifndef _DBAUI_DBADMIN_HRC_ +#include "dbadmin.hrc" +#endif +#ifndef _COMPHELPER_TYPES_HXX_ +#include <comphelper/types.hxx> +#endif +#ifndef _VCL_STDTEXT_HXX +#include <vcl/stdtext.hxx> +#endif +#ifndef _DBAUI_SQLMESSAGE_HXX_ +#include "sqlmessage.hxx" +#endif +#ifndef _DBAUI_ODBC_CONFIG_HXX_ +#include "odbcconfig.hxx" +#endif +#ifndef _DBAUI_DSSELECT_HXX_ +#include "dsselect.hxx" +#endif +#ifndef SVTOOLS_FILENOTATION_HXX_ +#include <svl/filenotation.hxx> +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef _COM_SUN_STAR_UI_DIALOGS_XFOLDERPICKER_HPP_ +#include <com/sun/star/ui/dialogs/XFolderPicker.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_ +#include <com/sun/star/awt/XWindow.hpp> +#endif +// #106016# ------------------------------------ +#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_ +#include <com/sun/star/task/XInteractionHandler.hpp> +#endif +#ifndef _COM_SUN_STAR_TASK_XPROGRESSHANDLER_HPP_ +#include <com/sun/star/ucb/XProgressHandler.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ +#include <com/sun/star/sdbc/XConnection.hpp> +#endif +#ifndef DBAUI_TOOLS_HXX +#include "UITools.hxx" +#endif +#ifndef _UNOTOOLS_LOCALFILEHELPER_HXX +#include <unotools/localfilehelper.hxx> +#endif +#ifndef _UNOTOOLS_UCBHELPER_HXX +#include <unotools/ucbhelper.hxx> +#endif +#ifndef _UCBHELPER_COMMANDENVIRONMENT_HXX +#include <ucbhelper/commandenvironment.hxx> +#endif +#ifndef DBAUI_FILEPICKER_INTERACTION_HXX +#include "finteraction.hxx" +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include <connectivity/CommonTools.hxx> +#endif +#ifndef _URLOBJ_HXX +#include <tools/urlobj.hxx> +#endif +#ifndef _SFX_DOCFILT_HACK_HXX +#include <sfx2/docfilt.hxx> +#endif +#ifndef _SV_MNEMONIC_HXX +#include <vcl/mnemonic.hxx> +#endif + +//......................................................................... +namespace dbaui +{ +//......................................................................... + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::ucb; + using namespace ::com::sun::star::ui::dialogs; + using namespace ::com::sun::star::sdbc; + using namespace ::com::sun::star::beans; + using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::container; + using namespace ::dbtools; + using namespace ::svt; + + + + OGenericAdministrationPage* OConnectionTabPageSetup::CreateDbaseTabPage( Window* pParent, const SfxItemSet& _rAttrSet ) + { + OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_DBASE, _rAttrSet, STR_DBASE_HELPTEXT, STR_DBASE_HEADERTEXT, STR_DBASE_PATH_OR_FILE); + oDBWizardPage->FreeResource(); + return oDBWizardPage; + } + + + OGenericAdministrationPage* OConnectionTabPageSetup::CreateMSAccessTabPage( Window* pParent, const SfxItemSet& _rAttrSet ) + { + OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_MSACCESS, _rAttrSet, STR_MSACCESS_HELPTEXT, STR_MSACCESS_HEADERTEXT, STR_MSACCESS_MDB_FILE); + oDBWizardPage->FreeResource(); + return oDBWizardPage; + } + + OGenericAdministrationPage* OConnectionTabPageSetup::CreateAdabasTabPage( Window* pParent, const SfxItemSet& _rAttrSet ) + { + OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_ADABAS, _rAttrSet, STR_ADABAS_HELPTEXT, STR_ADABAS_HEADERTEXT, STR_ADABAS_DATABASE_NAME); + oDBWizardPage->FreeResource(); + return oDBWizardPage; + } + + OGenericAdministrationPage* OConnectionTabPageSetup::CreateADOTabPage( Window* pParent, const SfxItemSet& _rAttrSet ) + { + OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_ADO, _rAttrSet, STR_ADO_HELPTEXT, STR_ADO_HEADERTEXT, STR_COMMONURL); + oDBWizardPage->FreeResource(); + return oDBWizardPage; + } + + OGenericAdministrationPage* OConnectionTabPageSetup::CreateODBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet ) + { + OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_ODBC, _rAttrSet, STR_ODBC_HELPTEXT, STR_ODBC_HEADERTEXT, STR_NAME_OF_ODBC_DATASOURCE); + oDBWizardPage->FreeResource(); + return oDBWizardPage; + } + + OGenericAdministrationPage* OConnectionTabPageSetup::CreateUserDefinedTabPage( Window* pParent, const SfxItemSet& _rAttrSet ) + { + OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_USERDEFINED, _rAttrSet, USHRT_MAX, USHRT_MAX, STR_COMMONURL); + oDBWizardPage->FreeResource(); + return oDBWizardPage; + } + + + //======================================================================== + //= OConnectionTabPageSetup + //======================================================================== + DBG_NAME(OConnectionTabPageSetup) + OConnectionTabPageSetup::OConnectionTabPageSetup(Window* pParent, USHORT _rId, const SfxItemSet& _rCoreAttrs, USHORT _nHelpTextResId, USHORT _nHeaderResId, USHORT _nUrlResId) + :OConnectionHelper(pParent, ModuleRes(_rId), _rCoreAttrs) + ,m_bUserGrabFocus(sal_True) + ,m_aFT_HelpText(this, ModuleRes(FT_AUTOWIZARDHELPTEXT)) + { + DBG_CTOR(OConnectionTabPageSetup, NULL); + + if ( USHRT_MAX != _nHelpTextResId ) + { + String sHelpText = String(ModuleRes(_nHelpTextResId)); + m_aFT_HelpText.SetText(sHelpText); + } + else + m_aFT_HelpText.Hide(); + + + if ( USHRT_MAX != _nHeaderResId ) + SetHeaderText(FT_AUTOWIZARDHEADER, _nHeaderResId); + + if ( USHRT_MAX != _nUrlResId ) + { + String sLabelText = String(ModuleRes(_nUrlResId)); + m_aFT_Connection.SetText(sLabelText); + if ( USHRT_MAX == _nHelpTextResId ) + { + Point aPos = m_aFT_HelpText.GetPosPixel(); + Point aFTPos = m_aFT_Connection.GetPosPixel(); + Point aEDPos = m_aConnectionURL.GetPosPixel(); + Point aPBPos = m_aPB_Connection.GetPosPixel(); + + aEDPos.Y() = aPos.Y() + aEDPos.Y() - aFTPos.Y(); + aPBPos.Y() = aPos.Y() + aPBPos.Y() - aFTPos.Y(); + aFTPos.Y() = aPos.Y(); + m_aFT_Connection.SetPosPixel(aFTPos); + m_aConnectionURL.SetPosPixel(aEDPos); + m_aPB_Connection.SetPosPixel(aPBPos); + } + } + else + m_aFT_Connection.Hide(); + + m_aConnectionURL.SetModifyHdl(LINK(this, OConnectionTabPageSetup, OnEditModified)); + + SetRoadmapStateValue(sal_False); + } + + // ----------------------------------------------------------------------- + OConnectionTabPageSetup::~OConnectionTabPageSetup() + { + DBG_DTOR(OConnectionTabPageSetup,NULL); + } + + // ----------------------------------------------------------------------- + void OConnectionTabPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) + { + m_eType = m_pAdminDialog->getDatasourceType(_rSet); + // special handling for oracle, this can only happen + // if the user enters the same url as used for Oracle and we are on the JDBC path + //! TODO + //if ( ::dbaccess::DST_ORACLE_JDBC == m_eType ) + // m_eType = ::dbaccess::DST_JDBC; + + OConnectionHelper::implInitControls(_rSet, _bSaveValue); + + //! TODO + //if ( m_eType >= ::dbaccess::DST_USERDEFINE1 ) + //{ + // String sDisplayName = m_pCollection->getTypeDisplayName(m_eType); + // FixedText* ppTextControls[] ={&m_aFT_Connection}; + // for (size_t i = 0; i < sizeof(ppTextControls)/sizeof(ppTextControls[0]); ++i) + // { + // ppTextControls[i]->SetText(sDisplayName); + // } + //} + + callModifiedHdl(); + } + // ----------------------------------------------------------------------- + sal_Bool OConnectionTabPageSetup::commitPage( ::svt::WizardTypes::CommitPageReason /*_eReason*/ ) + { + return commitURL(); + } + + // ----------------------------------------------------------------------- + sal_Bool OConnectionTabPageSetup::FillItemSet(SfxItemSet& _rSet) + { + sal_Bool bChangedSomething = sal_False; + fillString(_rSet,&m_aConnectionURL, DSID_CONNECTURL, bChangedSomething); + return bChangedSomething; + } + // ----------------------------------------------------------------------- + bool OConnectionTabPageSetup::checkTestConnection() + { + return !m_aConnectionURL.IsVisible() || (m_aConnectionURL.GetTextNoPrefix().Len() != 0); + } + + // ----------------------------------------------------------------------- + IMPL_LINK(OConnectionTabPageSetup, OnEditModified, Edit*, /*_pEdit*/) + { + SetRoadmapStateValue(checkTestConnection()); + callModifiedHdl(); + return 0L; + } +//......................................................................... +} // namespace dbaui +//......................................................................... + + diff --git a/dbaccess/source/ui/dlg/ConnectionPageSetup.hxx b/dbaccess/source/ui/dlg/ConnectionPageSetup.hxx new file mode 100644 index 000000000000..79a16c880c54 --- /dev/null +++ b/dbaccess/source/ui/dlg/ConnectionPageSetup.hxx @@ -0,0 +1,117 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifndef DBAUI_CONNECTIONPAGESETUP_HXX +#define DBAUI_CONNECTIONPAGESETUP_HXX +#ifndef DBAUI_CONNECTIONHELPER_HXX +#include "ConnectionHelper.hxx" +#endif + +#ifndef _DBAUI_ADMINPAGES_HXX_ +#include "adminpages.hxx" +#endif +#ifndef _UCBHELPER_CONTENT_HXX +#include <ucbhelper/content.hxx> +#endif +#ifndef _DBAUI_CURLEDIT_HXX_ +#include "curledit.hxx" +#endif + +#ifndef _SV_FIELD_HXX +#include <vcl/field.hxx> +#endif + + +//......................................................................... +namespace dbaui +{ +//......................................................................... +/* // #106016# -------------- + enum IS_PATH_EXIST + { + PATH_NOT_EXIST = 0, + PATH_EXIST, + PATH_NOT_KNOWN + }; + */ + + class IDatabaseSettingsDialog; + //========================================================================= + //= OConnectionTabPageSetup + //========================================================================= + + /** implements the connection page of the data source properties dialog. + */ + class OConnectionTabPageSetup : public OConnectionHelper + { + sal_Bool m_bUserGrabFocus : 1; + protected: + + FixedText m_aFT_HelpText; + + // called when the test connection button was clicked + DECL_LINK(OnEditModified,Edit*); + + public: + static OGenericAdministrationPage* CreateDbaseTabPage( Window* pParent, const SfxItemSet& _rAttrSet ); + static OGenericAdministrationPage* CreateMSAccessTabPage( Window* pParent, const SfxItemSet& _rAttrSet ); + static OGenericAdministrationPage* CreateAdabasTabPage( Window* pParent, const SfxItemSet& _rAttrSet ); + static OGenericAdministrationPage* CreateADOTabPage( Window* pParent, const SfxItemSet& _rAttrSet ); + static OGenericAdministrationPage* CreateODBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet ); + static OGenericAdministrationPage* CreateUserDefinedTabPage( Window* pParent, const SfxItemSet& _rAttrSet ); + + + virtual BOOL FillItemSet (SfxItemSet& _rCoreAttrs); + + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ); + + + inline void enableConnectionURL() { m_aConnectionURL.SetReadOnly(sal_False); } + inline void disableConnectionURL() { m_aConnectionURL.SetReadOnly(); } + + /** changes the connection URL. + <p>The new URL must be of the type which is currently selected, only the parts which do not + affect the type may be changed (compared to the previous URL).</p> + */ + void changeConnectionURL( const String& _rNewDSN ); + String getConnectionURL( ) const; + + + protected: + OConnectionTabPageSetup(Window* pParent, USHORT _rId, const SfxItemSet& _rCoreAttrs, USHORT _nHelpTextResId, USHORT _nHeaderResId, USHORT _nUrlResId); + virtual bool checkTestConnection(); + // nControlFlags ist eine Kombination der CBTP_xxx-Konstanten + virtual ~OConnectionTabPageSetup(); + }; + +//......................................................................... +} // namespace dbaui +//......................................................................... + +#endif diff --git a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx new file mode 100644 index 000000000000..c340e3576f34 --- /dev/null +++ b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx @@ -0,0 +1,1027 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" +#ifndef DBAUI_DBSETUPCONNECTIONPAGES_HXX +#include "DBSetupConnectionPages.hxx" +#endif +#ifndef _DBAUI_SQLMESSAGE_HXX_ +#include "sqlmessage.hxx" +#endif +#ifndef _DBU_RESOURCE_HRC_ +#include "dbu_resource.hrc" +#endif +#ifndef _DBAUI_AUTOCONTROLS_HRC_ +#include "AutoControls.hrc" +#endif +#ifndef _DBAUI_DBADMINSETUP_HRC_ +#include "dbadminsetup.hrc" +#endif +#ifndef _SFXITEMSET_HXX +#include <svl/itemset.hxx> +#endif +#ifndef _SFXSTRITEM_HXX +#include <svl/stritem.hxx> +#endif +#ifndef _SFXENUMITEM_HXX +#include <svl/eitem.hxx> +#endif +#ifndef _SFXINTITEM_HXX +#include <svl/intitem.hxx> +#endif +#ifndef _DBAUI_DATASOURCEITEMS_HXX_ +#include "dsitems.hxx" +#endif +#include "dsnItem.hxx" +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif +#ifndef _DBAUI_LOCALRESACCESS_HXX_ +#include "localresaccess.hxx" +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif +#ifndef _SV_MNEMONIC_HXX +#include <vcl/mnemonic.hxx> +#endif +#ifndef _SVTOOLS_CJKOPTIONS_HXX +#include <svl/cjkoptions.hxx> +#endif +#include <jvmaccess/virtualmachine.hxx> +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include <connectivity/CommonTools.hxx> +#endif +#ifndef DBAUI_DRIVERSETTINGS_HXX +#include "DriverSettings.hxx" +#endif +#ifndef _DBAUI_DBADMIN_HXX_ +#include "dbadmin.hxx" +#endif +#ifndef _COMPHELPER_TYPES_HXX_ +#include <comphelper/types.hxx> +#endif + +#ifndef _COM_SUN_STAR_UI_DIALOGS_XFOLDERPICKER_HPP_ +#include <com/sun/star/ui/dialogs/XFolderPicker.hpp> +#endif +// #106016# ------------------------------------ +#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_ +#include <com/sun/star/task/XInteractionHandler.hpp> +#endif +#include <com/sun/star/sdbc/XDriverAccess.hpp> +#include "dbustrings.hrc" +#ifndef SVTOOLS_FILENOTATION_HXX_ +#include <svl/filenotation.hxx> +#endif + +#include <unotools/localfilehelper.hxx> +#include <unotools/ucbhelper.hxx> +#include <ucbhelper/commandenvironment.hxx> +#include "finteraction.hxx" +#include <connectivity/CommonTools.hxx> +#include "dbaccess_helpid.hrc" +#include <unotools/pathoptions.hxx> +#include <svtools/roadmapwizard.hxx> +#include "TextConnectionHelper.hxx" + + +//......................................................................... +namespace dbaui +{ +//......................................................................... +using namespace ::com::sun::star; +// using namespace ::com::sun::star::ucb; +// using namespace ::com::sun::star::ui::dialogs; +// using namespace ::com::sun::star::sdbc; +// using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::lang; +// using namespace ::com::sun::star::container; +// using namespace ::dbtools; +// using namespace ::svt; + + OGenericAdministrationPage* OTextConnectionPageSetup::CreateTextTabPage( Window* pParent, const SfxItemSet& _rAttrSet ) + { + return ( new OTextConnectionPageSetup( pParent, _rAttrSet ) ); + } + + + //======================================================================== + //= OTextConnectionPageSetup + //======================================================================== +DBG_NAME(OTextConnectionPageSetup) +//------------------------------------------------------------------------ + OTextConnectionPageSetup::OTextConnectionPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs ) + :OConnectionTabPageSetup(pParent, PAGE_DBWIZARD_TEXT, _rCoreAttrs, STR_TEXT_HELPTEXT, STR_TEXT_HEADERTEXT, STR_TEXT_PATH_OR_FILE) + { + DBG_CTOR(OTextConnectionPageSetup,NULL); + + m_pTextConnectionHelper = new OTextConnectionHelper( this, TC_EXTENSION | TC_SEPARATORS ); + m_pTextConnectionHelper->SetClickHandler(LINK( this, OTextConnectionPageSetup, ImplGetExtensionHdl ) ); + + FreeResource(); + } + + + // ----------------------------------------------------------------------- + OTextConnectionPageSetup::~OTextConnectionPageSetup() + { + DELETEZ(m_pTextConnectionHelper); + + DBG_DTOR(OTextConnectionPageSetup,NULL); + } + + IMPL_LINK(OTextConnectionPageSetup, ImplGetExtensionHdl, OTextConnectionHelper*, /*_pTextConnectionHelper*/) + { + SetRoadmapStateValue((m_pTextConnectionHelper->GetExtension().Len() > 0) && OConnectionTabPageSetup::checkTestConnection()); + callModifiedHdl(); + return sal_True; + } + + + bool OTextConnectionPageSetup::checkTestConnection() + { + bool bDoEnable = OConnectionTabPageSetup::checkTestConnection(); + bDoEnable = (m_pTextConnectionHelper->GetExtension().Len() > 0) && bDoEnable; + return bDoEnable; + } + + // ----------------------------------------------------------------------- + void OTextConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) + { + OConnectionTabPageSetup::fillControls(_rControlList); + m_pTextConnectionHelper->fillControls(_rControlList); + } + // ----------------------------------------------------------------------- + void OTextConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) + { + OConnectionTabPageSetup::fillWindows(_rControlList); + m_pTextConnectionHelper->fillWindows(_rControlList); + } + // ----------------------------------------------------------------------- + void OTextConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) + { + // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) + sal_Bool bValid, bReadonly; + getFlags(_rSet, bValid, bReadonly); + OConnectionTabPageSetup::implInitControls( _rSet, _bSaveValue); + m_pTextConnectionHelper->implInitControls(_rSet, bValid); + } + + + // ----------------------------------------------------------------------- + sal_Bool OTextConnectionPageSetup::FillItemSet( SfxItemSet& _rSet ) + { + sal_Bool bChangedSomething = OConnectionTabPageSetup::FillItemSet(_rSet); + bChangedSomething = m_pTextConnectionHelper->FillItemSet(_rSet, bChangedSomething); + return bChangedSomething; + } + + + sal_Bool OTextConnectionPageSetup::prepareLeave(){ + return m_pTextConnectionHelper->prepareLeave(); + } + + + OGenericAdministrationPage* OLDAPConnectionPageSetup::CreateLDAPTabPage( Window* pParent, const SfxItemSet& _rAttrSet ) + { + return ( new OLDAPConnectionPageSetup( pParent, _rAttrSet ) ); + } + + + //======================================================================== + //= OLDAPPageSetup + //======================================================================== + OLDAPConnectionPageSetup::OLDAPConnectionPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs ) + :OGenericAdministrationPage(pParent, ModuleRes(PAGE_DBWIZARD_LDAP), _rCoreAttrs) + ,m_aFTHeaderText (this, ModuleRes(FT_LDAP_HEADERTEXT)) + ,m_aFTHelpText (this, ModuleRes(FT_LDAP_HELPTEXT)) + ,m_aFTHostServer (this, ModuleRes(FT_AUTOHOSTNAME)) + ,m_aETHostServer (this, ModuleRes(ET_AUTOHOSTNAME)) + ,m_aFTBaseDN (this, ModuleRes(FT_AUTOBASEDN)) + ,m_aETBaseDN (this, ModuleRes(ET_AUTOBASEDN)) + ,m_aFTPortNumber (this, ModuleRes(FT_AUTOPORTNUMBER)) + ,m_aNFPortNumber (this, ModuleRes(NF_AUTOPORTNUMBER)) + ,m_aFTDefaultPortNumber (this, ModuleRes(FT_AUTOPORTNUMBERDEFAULT)) + ,m_aCBUseSSL (this, ModuleRes(CB_WIZ_USESSL)) + { + SetControlFontWeight(&m_aFTHeaderText); + m_aFTDefaultPortNumber.SetText(String(ModuleRes(STR_LDAP_DEFAULT))); + m_aETHostServer.SetModifyHdl(getControlModifiedLink()); + m_aETBaseDN.SetModifyHdl(getControlModifiedLink()); + m_aNFPortNumber.SetModifyHdl(getControlModifiedLink()); + m_aCBUseSSL.SetToggleHdl(getControlModifiedLink()); + SetRoadmapStateValue(sal_False); + FreeResource(); + } + + // ----------------------------------------------------------------------- + sal_Bool OLDAPConnectionPageSetup::FillItemSet( SfxItemSet& _rSet ) + { + sal_Bool bChangedSomething = sal_False; + fillString(_rSet,&m_aETBaseDN,DSID_CONN_LDAP_BASEDN, bChangedSomething); + fillInt32(_rSet,&m_aNFPortNumber,DSID_CONN_LDAP_PORTNUMBER,bChangedSomething); + + if ( m_aETHostServer.GetText() != m_aETHostServer.GetSavedValue() ) + { + DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _rSet.GetItem(DSID_TYPECOLLECTION)); + ::dbaccess::ODsnTypeCollection* pCollection = NULL; + if (pCollectionItem) + pCollection = pCollectionItem->getCollection(); + DBG_ASSERT(pCollection, "OLDAPConnectionPageSetup::FillItemSet : really need a DSN type collection !"); + + String sUrl = pCollection->getPrefix( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:address:ldap:"))); + sUrl += m_aETHostServer.GetText(); + _rSet.Put(SfxStringItem(DSID_CONNECTURL, sUrl)); + bChangedSomething = sal_True; + } + + // fillString(_rSet,&m_aETHostServer, DSID_CONNECTURL, bChangedSomething); + fillBool(_rSet,&m_aCBUseSSL,DSID_CONN_LDAP_USESSL,bChangedSomething); + return bChangedSomething; + } + // ----------------------------------------------------------------------- + void OLDAPConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) + { + _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETHostServer)); + _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETBaseDN)); + _rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_aNFPortNumber)); + _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aCBUseSSL)); + } + // ----------------------------------------------------------------------- + void OLDAPConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) + { + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHelpText)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHostServer)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTBaseDN)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTPortNumber)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDefaultPortNumber)); + } + // ----------------------------------------------------------------------- + void OLDAPConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) + { + // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) + sal_Bool bValid, bReadonly; + getFlags(_rSet, bValid, bReadonly); + + + SFX_ITEMSET_GET(_rSet, pBaseDN, SfxStringItem, DSID_CONN_LDAP_BASEDN, sal_True); + SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, DSID_CONN_LDAP_PORTNUMBER, sal_True); + + if ( bValid ) + { + m_aETBaseDN.SetText(pBaseDN->GetValue()); + m_aNFPortNumber.SetValue(pPortNumber->GetValue()); + } + OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue); + callModifiedHdl(); + } + + // ----------------------------------------------------------------------- + IMPL_LINK(OLDAPConnectionPageSetup, OnEditModified, Edit*, /*_pEdit*/) + { + sal_Bool bRoadmapState = ((m_aETHostServer.GetText().Len() != 0 ) && ( m_aETBaseDN.GetText().Len() != 0 ) && (m_aFTPortNumber.GetText().Len() != 0 )); + SetRoadmapStateValue(bRoadmapState); + callModifiedHdl(); + return 0L; + } + + + // ----------------------------------------------------------------------- //OGenericAdministrationPage* + OMySQLIntroPageSetup* OMySQLIntroPageSetup::CreateMySQLIntroTabPage( Window* _pParent, const SfxItemSet& _rAttrSet ) + { + return ( new OMySQLIntroPageSetup( _pParent, _rAttrSet) ); + } + +DBG_NAME(OMySQLIntroPageSetup) + + OMySQLIntroPageSetup::OMySQLIntroPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs ) + :OGenericAdministrationPage(pParent, ModuleRes(PAGE_DBWIZARD_MYSQL_INTRO), _rCoreAttrs) + ,m_aRB_ODBCDatabase(this, ModuleRes(RB_CONNECTVIAODBC)) + ,m_aRB_JDBCDatabase(this, ModuleRes(RB_CONNECTVIAJDBC)) + ,m_aRB_NATIVEDatabase(this, ModuleRes(RB_CONNECTVIANATIVE)) + ,m_aFT_ConnectionMode(this, ModuleRes(FT_MYSQLCONNECTIONMODE)) + ,m_aFT_Helptext(this, ModuleRes(FT_MYSQL_HELPTEXT)) + ,m_aFT_Headertext(this, ModuleRes(FT_MYSQL_HEADERTEXT)) + { + DBG_CTOR(OMySQLIntroPageSetup,NULL); + + SetControlFontWeight(&m_aFT_Headertext); + m_aRB_ODBCDatabase.SetToggleHdl(LINK(this, OMySQLIntroPageSetup, OnSetupModeSelected)); + m_aRB_JDBCDatabase.SetToggleHdl(LINK(this, OMySQLIntroPageSetup, OnSetupModeSelected)); + m_aRB_NATIVEDatabase.SetToggleHdl(LINK(this, OMySQLIntroPageSetup, OnSetupModeSelected)); + FreeResource(); + } + + IMPL_LINK(OMySQLIntroPageSetup, OnSetupModeSelected, RadioButton*, /*_pBox*/) + { + maClickHdl.Call( this ); + return true; + } + + // ----------------------------------------------------------------------- + OMySQLIntroPageSetup::~OMySQLIntroPageSetup() + { + + DBG_DTOR(OMySQLIntroPageSetup,NULL); + } + + + // ----------------------------------------------------------------------- + void OMySQLIntroPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool /*_bSaveValue*/) + { + // show the "Connect directly" option only if the driver is installed + DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _rSet.GetItem(DSID_TYPECOLLECTION)); + bool bHasMySQLNative = ( pCollectionItem != NULL ) && pCollectionItem->getCollection()->hasDriver( "sdbc:mysqlc:" ); + if ( bHasMySQLNative ) + m_aRB_NATIVEDatabase.Show(); + + // if any of the options is checked, then there's nothing to do + if ( m_aRB_ODBCDatabase.IsChecked() || m_aRB_JDBCDatabase.IsChecked() || m_aRB_NATIVEDatabase.IsChecked() ) + return; + + // prefer "native" or "JDBC" + if ( bHasMySQLNative ) + m_aRB_NATIVEDatabase.Check(); + else + m_aRB_JDBCDatabase.Check(); + } + + + // ----------------------------------------------------------------------- + void OMySQLIntroPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& /*_rControlList*/) + { + } + + // ----------------------------------------------------------------------- + void OMySQLIntroPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& /*_rControlList*/) + { + } + + + // ----------------------------------------------------------------------- + BOOL OMySQLIntroPageSetup::FillItemSet(SfxItemSet& /*_rSet*/) + { + OSL_ENSURE(sal_False,"Who called me?! Please ask oj for more information."); + return sal_True; + } + + + OMySQLIntroPageSetup::ConnectionType OMySQLIntroPageSetup::getMySQLMode() + { + if (m_aRB_JDBCDatabase.IsChecked()) + return VIA_JDBC; + else if (m_aRB_NATIVEDatabase.IsChecked()) + return VIA_NATIVE; + else + return VIA_ODBC; + } + + // ======================================================================= + // = MySQLNativeSetupPage + // ======================================================================= + // ----------------------------------------------------------------------- + MySQLNativeSetupPage::MySQLNativeSetupPage( Window* _pParent, const SfxItemSet& _rCoreAttrs ) + :OGenericAdministrationPage( _pParent, ModuleRes( PAGE_DBWIZARD_MYSQL_NATIVE ), _rCoreAttrs ) + ,m_aHeader ( this, ModuleRes( FT_SETUP_WIZARD_HEADER ) ) + ,m_aHelpText ( this, ModuleRes( FT_SETUP_WIZARD_HELP ) ) + ,m_aMySQLSettings ( *this, getControlModifiedLink() ) + { + SetControlFontWeight( &m_aHeader ); + + LayoutHelper::positionBelow( m_aHelpText, m_aMySQLSettings, UnrelatedControls, 0 ); + m_aMySQLSettings.Show(); + + SetRoadmapStateValue(sal_False); + FreeResource(); + } + + // ----------------------------------------------------------------------- + OGenericAdministrationPage* MySQLNativeSetupPage::Create( Window* pParent, const SfxItemSet& _rAttrSet ) + { + return new MySQLNativeSetupPage( pParent, _rAttrSet ); + } + + // ----------------------------------------------------------------------- + void MySQLNativeSetupPage::fillControls( ::std::vector< ISaveValueWrapper* >& _rControlList ) + { + m_aMySQLSettings.fillControls( _rControlList ); + } + + // ----------------------------------------------------------------------- + void MySQLNativeSetupPage::fillWindows( ::std::vector< ISaveValueWrapper* >& _rControlList ) + { + _rControlList.push_back( new ODisableWrapper< FixedText >( &m_aHelpText ) ); + m_aMySQLSettings.fillWindows( _rControlList ); + } + + // ----------------------------------------------------------------------- + sal_Bool MySQLNativeSetupPage::FillItemSet( SfxItemSet& _rSet ) + { + return m_aMySQLSettings.FillItemSet( _rSet ); + } + + // ----------------------------------------------------------------------- + void MySQLNativeSetupPage::implInitControls( const SfxItemSet& _rSet, sal_Bool _bSaveValue ) + { + m_aMySQLSettings.implInitControls( _rSet ); + + OGenericAdministrationPage::implInitControls( _rSet, _bSaveValue ); + + OnModified( NULL ); + } + + // ----------------------------------------------------------------------- + Link MySQLNativeSetupPage::getControlModifiedLink() + { + return LINK( this, MySQLNativeSetupPage, OnModified ); + } + + // ----------------------------------------------------------------------- + IMPL_LINK( MySQLNativeSetupPage, OnModified, Edit*, _pEdit ) + { + SetRoadmapStateValue( m_aMySQLSettings.canAdvance() ); + + return OGenericAdministrationPage::getControlModifiedLink().Call( _pEdit ); + } + + //======================================================================== + //= OMySQLJDBCConnectionPageSetup + //======================================================================== + OGeneralSpecialJDBCConnectionPageSetup::OGeneralSpecialJDBCConnectionPageSetup( Window* pParent,USHORT _nResId, const SfxItemSet& _rCoreAttrs ,USHORT _nPortId, USHORT _nDefaultPortResId, USHORT _nHelpTextResId, USHORT _nHeaderTextResId, USHORT _nDriverClassId) + :OGenericAdministrationPage(pParent, ModuleRes(_nResId), _rCoreAttrs) + ,m_aFTHelpText (this, ModuleRes(FT_AUTOWIZARDHELPTEXT)) + ,m_aFTDatabasename (this, ModuleRes(FT_AUTODATABASENAME)) + ,m_aETDatabasename (this, ModuleRes(ET_AUTODATABASENAME)) + ,m_aFTHostname (this, ModuleRes(FT_AUTOHOSTNAME)) + ,m_aETHostname (this, ModuleRes(ET_AUTOHOSTNAME)) + ,m_aFTPortNumber (this, ModuleRes(FT_AUTOPORTNUMBER)) + ,m_aFTDefaultPortNumber (this, ModuleRes(FT_AUTOPORTNUMBERDEFAULT)) + ,m_aNFPortNumber (this, ModuleRes(NF_AUTOPORTNUMBER)) + ,m_aFTDriverClass (this, ModuleRes(FT_AUTOJDBCDRIVERCLASS)) + ,m_aETDriverClass (this, ModuleRes(ET_AUTOJDBCDRIVERCLASS)) + ,m_aPBTestJavaDriver (this, ModuleRes(PB_AUTOTESTDRIVERCLASS)) + ,m_nPortId(_nPortId) + { + m_aFTDriverClass.SetText(String(ModuleRes(_nDriverClassId))); + + m_aFTDefaultPortNumber.SetText(String(ModuleRes(_nDefaultPortResId))); + String sHelpText = String(ModuleRes(_nHelpTextResId)); + m_aFTHelpText.SetText(sHelpText); + //TODO this code snippet is redundant + SetHeaderText(FT_AUTOWIZARDHEADER, _nHeaderTextResId); + + m_aETDatabasename.SetModifyHdl(getControlModifiedLink()); + m_aETHostname.SetModifyHdl(getControlModifiedLink()); + m_aNFPortNumber.SetModifyHdl(getControlModifiedLink()); + + m_aETDriverClass.SetModifyHdl(LINK(this, OGeneralSpecialJDBCConnectionPageSetup, OnEditModified)); + m_aPBTestJavaDriver.SetClickHdl(LINK(this,OGeneralSpecialJDBCConnectionPageSetup,OnTestJavaClickHdl)); + + SFX_ITEMSET_GET(_rCoreAttrs, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True); + SFX_ITEMSET_GET(_rCoreAttrs, pTypesItem, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True); + ::dbaccess::ODsnTypeCollection* pTypeCollection = pTypesItem ? pTypesItem->getCollection() : NULL; + if (pTypeCollection && pUrlItem && pUrlItem->GetValue().Len() ) + { + m_sDefaultJdbcDriverName = pTypeCollection->getJavaDriverClass(pUrlItem->GetValue()); + } + + SetRoadmapStateValue(sal_False); + FreeResource(); + } + + + // ----------------------------------------------------------------------- + OGenericAdministrationPage* OGeneralSpecialJDBCConnectionPageSetup::CreateMySQLJDBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet ) + { + return ( new OGeneralSpecialJDBCConnectionPageSetup( pParent, + PAGE_DBWIZARD_MYSQL_JDBC, + _rAttrSet, + DSID_MYSQL_PORTNUMBER , + STR_MYSQL_DEFAULT, + STR_MYSQLJDBC_HELPTEXT, + STR_MYSQLJDBC_HEADERTEXT, + STR_MYSQL_DRIVERCLASSTEXT) ); + } + + // ----------------------------------------------------------------------- + OGenericAdministrationPage* OGeneralSpecialJDBCConnectionPageSetup::CreateOracleJDBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet ) + { + return ( new OGeneralSpecialJDBCConnectionPageSetup( pParent, + PAGE_DBWIZARD_ORACLE, + _rAttrSet, + DSID_ORACLE_PORTNUMBER, + STR_ORACLE_DEFAULT, + STR_ORACLE_HELPTEXT, + STR_ORACLE_HEADERTEXT, + STR_ORACLE_DRIVERCLASSTEXT) ); + } + + // ----------------------------------------------------------------------- + void OGeneralSpecialJDBCConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) + { + _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETDatabasename)); + _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETDriverClass)); + _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETHostname)); + _rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_aNFPortNumber)); + } + // ----------------------------------------------------------------------- + void OGeneralSpecialJDBCConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) + { + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHelpText)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDatabasename)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHostname)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTPortNumber)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDefaultPortNumber)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDriverClass)); + } + + // ----------------------------------------------------------------------- + sal_Bool OGeneralSpecialJDBCConnectionPageSetup::FillItemSet( SfxItemSet& _rSet ) + { + sal_Bool bChangedSomething = sal_False; + fillString(_rSet,&m_aETDriverClass,DSID_JDBCDRIVERCLASS,bChangedSomething); + fillString(_rSet,&m_aETHostname,DSID_CONN_HOSTNAME,bChangedSomething); + fillString(_rSet,&m_aETDatabasename,DSID_DATABASENAME,bChangedSomething); + fillInt32(_rSet,&m_aNFPortNumber,m_nPortId,bChangedSomething ); + return bChangedSomething; + } + + // ----------------------------------------------------------------------- + void OGeneralSpecialJDBCConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) + { + // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) + sal_Bool bValid, bReadonly; + getFlags(_rSet, bValid, bReadonly); + + SFX_ITEMSET_GET(_rSet, pDatabaseName, SfxStringItem, DSID_DATABASENAME, sal_True); + SFX_ITEMSET_GET(_rSet, pDrvItem, SfxStringItem, DSID_JDBCDRIVERCLASS, sal_True); + SFX_ITEMSET_GET(_rSet, pHostName, SfxStringItem, DSID_CONN_HOSTNAME, sal_True); + SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, m_nPortId, sal_True); + + if ( bValid ) + { + m_aETDatabasename.SetText(pDatabaseName->GetValue()); + m_aETDatabasename.ClearModifyFlag(); + + m_aETDriverClass.SetText(pDrvItem->GetValue()); + m_aETDriverClass.ClearModifyFlag(); + + m_aETHostname.SetText(pHostName->GetValue()); + m_aETHostname.ClearModifyFlag(); + + m_aNFPortNumber.SetValue(pPortNumber->GetValue()); + m_aNFPortNumber.ClearModifyFlag(); + } + OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue); + + // to get the correct value when saveValue was called by base class + if ( !m_aETDriverClass.GetText().Len() ) + { + m_aETDriverClass.SetText(m_sDefaultJdbcDriverName); + m_aETDriverClass.SetModifyFlag(); + } + callModifiedHdl(); + + sal_Bool bRoadmapState = ((m_aETDatabasename.GetText().Len() != 0 ) && ( m_aETHostname.GetText().Len() != 0 ) && (m_aNFPortNumber.GetText().Len() != 0 ) && ( m_aETDriverClass.GetText().Len() != 0 )); + SetRoadmapStateValue(bRoadmapState); + } + + // ----------------------------------------------------------------------- + IMPL_LINK(OGeneralSpecialJDBCConnectionPageSetup, OnTestJavaClickHdl, PushButton*, /*_pButton*/) + { + OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF"); + + sal_Bool bSuccess = sal_False; + try + { + if ( m_aETDriverClass.GetText().Len() ) + { +// TODO chage jvmaccess + ::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM(m_pAdminDialog->getORB()); + bSuccess = ::connectivity::existsJavaClassByName(xJVM,m_aETDriverClass.GetText()); + } + } + catch(::com::sun::star::uno::Exception&) + { + } + + USHORT nMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS; + OSQLMessageBox aMsg( this, String( ModuleRes( nMessage ) ), String() ); + aMsg.Execute(); + return 0L; + } + + // ----------------------------------------------------------------------- + IMPL_LINK(OGeneralSpecialJDBCConnectionPageSetup, OnEditModified, Edit*, _pEdit) + { + if ( _pEdit == &m_aETDriverClass ) + m_aPBTestJavaDriver.Enable( m_aETDriverClass.GetText().Len() != 0 ); + sal_Bool bRoadmapState = ((m_aETDatabasename.GetText().Len() != 0 ) && ( m_aETHostname.GetText().Len() != 0 ) && (m_aNFPortNumber.GetText().Len() != 0 ) && ( m_aETDriverClass.GetText().Len() != 0 )); + SetRoadmapStateValue(bRoadmapState); + callModifiedHdl(); + return 0L; + } + + // ----------------------------------------------------------------------- + OGenericAdministrationPage* OJDBCConnectionPageSetup::CreateJDBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet ) + { + return ( new OJDBCConnectionPageSetup( pParent, _rAttrSet)); + } + + + //======================================================================== + //= OMySQLJDBCConnectionPageSetup + //======================================================================== + OJDBCConnectionPageSetup::OJDBCConnectionPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs) + :OConnectionTabPageSetup(pParent, PAGE_DBWIZARD_JDBC, _rCoreAttrs, STR_JDBC_HELPTEXT, STR_JDBC_HEADERTEXT, STR_COMMONURL) + ,m_aFTDriverClass (this, ModuleRes(FT_AUTOJDBCDRIVERCLASS)) + ,m_aETDriverClass (this, ModuleRes(ET_AUTOJDBCDRIVERCLASS)) + ,m_aPBTestJavaDriver (this, ModuleRes(PB_AUTOTESTDRIVERCLASS)) + { + m_aETDriverClass.SetModifyHdl(LINK(this, OJDBCConnectionPageSetup, OnEditModified)); + m_aPBTestJavaDriver.SetClickHdl(LINK(this,OJDBCConnectionPageSetup,OnTestJavaClickHdl)); + FreeResource(); + } + + // ----------------------------------------------------------------------- + void OJDBCConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) + { + _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETDriverClass)); + } + + // ----------------------------------------------------------------------- + void OJDBCConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) + { + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDriverClass)); + } + + // ----------------------------------------------------------------------- + sal_Bool OJDBCConnectionPageSetup::FillItemSet( SfxItemSet& _rSet ) + { + sal_Bool bChangedSomething = OConnectionTabPageSetup::FillItemSet(_rSet); + fillString(_rSet,&m_aETDriverClass,DSID_JDBCDRIVERCLASS,bChangedSomething); + return bChangedSomething; + } + + // ----------------------------------------------------------------------- + void OJDBCConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) + { + // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) + sal_Bool bValid, bReadonly; + getFlags(_rSet, bValid, bReadonly); + + SFX_ITEMSET_GET(_rSet, pDrvItem, SfxStringItem, DSID_JDBCDRIVERCLASS, sal_True); + + if ( bValid ) + { + if ( !pDrvItem->GetValue().Len() ) + { + String sDefaultJdbcDriverName = m_pCollection->getJavaDriverClass(m_eType); + if ( sDefaultJdbcDriverName.Len() ) + { + m_aETDriverClass.SetText(sDefaultJdbcDriverName); + m_aETDriverClass.SetModifyFlag(); + } // if ( sDefaultJdbcDriverName.Len() ) + } // if ( !pJdbcDrvItem->GetValue().Len() ) + else + { + m_aETDriverClass.SetText(pDrvItem->GetValue()); + m_aETDriverClass.ClearModifyFlag(); + } + } + sal_Bool bEnable = pDrvItem->GetValue().Len() != 0; + m_aPBTestJavaDriver.Enable(bEnable); + OConnectionTabPageSetup::implInitControls(_rSet, _bSaveValue); + + SetRoadmapStateValue(checkTestConnection()); + } + + + bool OJDBCConnectionPageSetup::checkTestConnection() + { + OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF"); + BOOL bEnableTestConnection = !m_aConnectionURL.IsVisible() || (m_aConnectionURL.GetTextNoPrefix().Len() != 0); + bEnableTestConnection = bEnableTestConnection && (m_aETDriverClass.GetText().Len() != 0); + return bEnableTestConnection; +// m_aTestConnection.Enable(bEnableTestConnection); + } + + + // ----------------------------------------------------------------------- + IMPL_LINK(OJDBCConnectionPageSetup, OnTestJavaClickHdl, PushButton*, /*_pButton*/) + { + OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF"); + sal_Bool bSuccess = sal_False; + try + { + if ( m_aETDriverClass.GetText().Len() ) + { +// TODO chage jvmaccess + ::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM(m_pAdminDialog->getORB()); + bSuccess = xJVM.is() && ::connectivity::existsJavaClassByName(xJVM,m_aETDriverClass.GetText()); + } + } + catch(::com::sun::star::uno::Exception&) + { + } + + USHORT nMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS; + OSQLMessageBox aMsg( this, String( ModuleRes( nMessage ) ), String() ); + aMsg.Execute(); + return 0L; + } + + // ----------------------------------------------------------------------- + IMPL_LINK(OJDBCConnectionPageSetup, OnEditModified, Edit*, _pEdit) + { + if ( _pEdit == &m_aETDriverClass ) + m_aPBTestJavaDriver.Enable( m_aETDriverClass.GetText().Len() != 0 ); + SetRoadmapStateValue(checkTestConnection()); + // tell the listener we were modified + callModifiedHdl(); + return 0L; + } + + + OGenericAdministrationPage* OSpreadSheetConnectionPageSetup::CreateSpreadSheetTabPage( Window* pParent, const SfxItemSet& _rAttrSet ) + { + return ( new OSpreadSheetConnectionPageSetup( pParent, _rAttrSet ) ); + } + +DBG_NAME(OSpreadSheetConnectionPageSetup) + + OSpreadSheetConnectionPageSetup::OSpreadSheetConnectionPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs ) + :OConnectionTabPageSetup(pParent, PAGE_DBWIZARD_SPREADSHEET, _rCoreAttrs, STR_SPREADSHEET_HELPTEXT, STR_SPREADSHEET_HEADERTEXT, STR_SPREADSHEETPATH) + , m_aCBPasswordrequired(this, ModuleRes(CB_SPREADSHEETPASSWORDREQUIRED)) + { + DBG_CTOR(OSpreadSheetConnectionPageSetup,NULL); + + m_aCBPasswordrequired.SetToggleHdl(getControlModifiedLink()); + FreeResource(); + } + + + // ----------------------------------------------------------------------- + OSpreadSheetConnectionPageSetup::~OSpreadSheetConnectionPageSetup() + { + + DBG_DTOR(OSpreadSheetConnectionPageSetup,NULL); + } + + + void OSpreadSheetConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& /*_rControlList*/) + { + } + + // ----------------------------------------------------------------------- + void OSpreadSheetConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) + { + OConnectionTabPageSetup::fillControls(_rControlList); + _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aCBPasswordrequired)); + + } + + // ----------------------------------------------------------------------- + void OSpreadSheetConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) + { + OConnectionTabPageSetup::implInitControls(_rSet, _bSaveValue); + } + + // ----------------------------------------------------------------------- + sal_Bool OSpreadSheetConnectionPageSetup::FillItemSet( SfxItemSet& _rSet ) + { + sal_Bool bChangedSomething = OConnectionTabPageSetup::FillItemSet(_rSet); + fillBool(_rSet,&m_aCBPasswordrequired,DSID_PASSWORDREQUIRED,bChangedSomething); + return bChangedSomething; + } + + OGenericAdministrationPage* OAuthentificationPageSetup::CreateAuthentificationTabPage( Window* pParent, const SfxItemSet& _rAttrSet ) + { + return ( new OAuthentificationPageSetup( pParent, _rAttrSet) ); + } + +DBG_NAME(OAuthentificationPageSetup) + + OAuthentificationPageSetup::OAuthentificationPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs ) + :OGenericAdministrationPage(pParent, ModuleRes(PAGE_DBWIZARD_AUTHENTIFICATION), _rCoreAttrs ) + , m_aFTHelpText (this, ModuleRes(FT_AUTHENTIFICATIONHELPTEXT)) + , m_aFTHeaderText (this, ModuleRes(FT_AUTHENTIFICATIONHEADERTEXT)) + , m_aFTUserName (this, ModuleRes(FT_GENERALUSERNAME)) + , m_aETUserName (this, ModuleRes(ET_GENERALUSERNAME)) + , m_aCBPasswordRequired (this, ModuleRes(CB_GENERALPASSWORDREQUIRED)) + , m_aPBTestConnection (this, ModuleRes(PB_TESTCONNECTION)) + { + DBG_CTOR(OAuthentificationPageSetup,NULL); + + SetControlFontWeight(&m_aFTHeaderText); + m_aETUserName.SetModifyHdl(getControlModifiedLink()); + m_aCBPasswordRequired.SetClickHdl(getControlModifiedLink()); + m_aPBTestConnection.SetClickHdl(LINK(this,OGenericAdministrationPage,OnTestConnectionClickHdl)); + FreeResource(); + } + + + // ----------------------------------------------------------------------- + OAuthentificationPageSetup::~OAuthentificationPageSetup() + { + + DBG_DTOR(OAuthentificationPageSetup,NULL); + } + + + void OAuthentificationPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) + { + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHelpText)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTUserName)); + _rControlList.push_back(new ODisableWrapper<PushButton>(&m_aPBTestConnection)); + } + + // ----------------------------------------------------------------------- + void OAuthentificationPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) + { + _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETUserName)); + _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aCBPasswordRequired)); + } + + // ----------------------------------------------------------------------- + void OAuthentificationPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool /*_bSaveValue*/) + { + // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) + sal_Bool bValid, bReadonly; + getFlags(_rSet, bValid, bReadonly); + SFX_ITEMSET_GET(_rSet, pUidItem, SfxStringItem, DSID_USER, sal_True); + SFX_ITEMSET_GET(_rSet, pAllowEmptyPwd, SfxBoolItem, DSID_PASSWORDREQUIRED, sal_True); + + m_aETUserName.SetText(pUidItem->GetValue()); + m_aCBPasswordRequired.Check(pAllowEmptyPwd->GetValue()); + + m_aETUserName.ClearModifyFlag(); + } + + // ----------------------------------------------------------------------- + sal_Bool OAuthentificationPageSetup::FillItemSet( SfxItemSet& _rSet ) + { + sal_Bool bChangedSomething = sal_False; + + if (m_aETUserName.GetText() != m_aETUserName.GetSavedValue()) + { + _rSet.Put(SfxStringItem(DSID_USER, m_aETUserName.GetText())); + _rSet.Put(SfxStringItem(DSID_PASSWORD, String())); + bChangedSomething = sal_True; + } + fillBool(_rSet,&m_aCBPasswordRequired,DSID_PASSWORDREQUIRED,bChangedSomething); + return bChangedSomething; + } + + + OGenericAdministrationPage* OFinalDBPageSetup::CreateFinalDBTabPageSetup( Window* pParent, const SfxItemSet& _rAttrSet) + { + return ( new OFinalDBPageSetup( pParent, _rAttrSet) ); + } + +DBG_NAME(OFinalDBPageSetup) + + OFinalDBPageSetup::OFinalDBPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs ) + :OGenericAdministrationPage(pParent, ModuleRes(PAGE_DBWIZARD_FINAL), _rCoreAttrs ) + , m_aFTFinalHeader (this, ModuleRes(FT_FINALHEADER)) + , m_aFTFinalHelpText (this, ModuleRes(FT_FINALHELPTEXT)) + , m_aRBRegisterDataSource (this, ModuleRes(RB_REGISTERDATASOURCE)) + , m_aRBDontregisterDataSource (this, ModuleRes(RB_DONTREGISTERDATASOURCE)) + , m_aFTAdditionalSettings (this, ModuleRes(FT_ADDITIONALSETTINGS)) + , m_aCBOpenAfterwards (this, ModuleRes(CB_OPENAFTERWARDS)) + , m_aCBStartTableWizard (this, ModuleRes(CB_STARTTABLEWIZARD)) + , m_aFTFinalText (this, ModuleRes(FT_FINALTEXT)) + { + DBG_CTOR(OFinalDBPageSetup,NULL); + + String stext = m_aFTFinalHeader.GetText(); + SetControlFontWeight(&m_aFTFinalHeader); + m_aCBOpenAfterwards.SetClickHdl(LINK(this, OFinalDBPageSetup, OnOpenSelected)); + m_aCBStartTableWizard.SetClickHdl(getControlModifiedLink()); + m_aRBRegisterDataSource.SetState(sal_True); + FreeResource(); + + sal_Int32 nUnrelatedHeight = LogicToPixel( Size( 0, UNRELATED_CONTROLS ), MAP_APPFONT ).Height(); + sal_Int32 nRelatedHeight = LogicToPixel( Size( 0, RELATED_CONTROLS ), MAP_APPFONT ).Height(); + + ::std::pair<Window*,sal_Int32> pWindows[] = { + ::std::pair<Window*,sal_Int32>(&m_aFTFinalHelpText,nRelatedHeight) + ,::std::pair<Window*,sal_Int32>(&m_aRBRegisterDataSource,nRelatedHeight) + ,::std::pair<Window*,sal_Int32>(&m_aRBDontregisterDataSource,nUnrelatedHeight) + ,::std::pair<Window*,sal_Int32>(&m_aFTAdditionalSettings,nRelatedHeight) + ,::std::pair<Window*,sal_Int32>(&m_aCBOpenAfterwards,nRelatedHeight) + ,::std::pair<Window*,sal_Int32>(&m_aCBStartTableWizard,nUnrelatedHeight) + ,::std::pair<Window*,sal_Int32>(&m_aFTFinalText,nUnrelatedHeight) + }; + + Point aPos(m_aFTFinalHeader.GetPosPixel()); + Size aStart(m_aFTFinalHeader.GetSizePixel()); + aPos.Y() += aStart.Height() + nUnrelatedHeight; + sal_Int32 nCount = sizeof(pWindows) / sizeof(pWindows[0]); + for (sal_Int32 i=0; i < nCount; ++i) + { + aPos.X() = pWindows[i].first->GetPosPixel().X(); + Size aSize = pWindows[i].first->GetSizePixel(); + FixedText* pText = dynamic_cast<FixedText*>(pWindows[i].first); + if ( pText ) + aSize = pText->CalcMinimumSize(aSize.Width()); + pWindows[i].first->SetPosSizePixel(aPos,aSize); + aPos.Y() += aSize.Height() + pWindows[i].second; + } + } + + + // ----------------------------------------------------------------------- + OFinalDBPageSetup::~OFinalDBPageSetup() + { + + DBG_DTOR(OFinalDBPageSetup,NULL); + } + + sal_Bool OFinalDBPageSetup::IsDatabaseDocumentToBeRegistered() + { + return m_aRBRegisterDataSource.IsChecked() && m_aRBRegisterDataSource.IsEnabled(); + } + + sal_Bool OFinalDBPageSetup::IsDatabaseDocumentToBeOpened() + { + return m_aCBOpenAfterwards.IsChecked() && m_aCBOpenAfterwards.IsEnabled(); + } + + sal_Bool OFinalDBPageSetup::IsTableWizardToBeStarted() + { + return m_aCBStartTableWizard.IsChecked() && m_aCBStartTableWizard.IsEnabled(); + } + + + void OFinalDBPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) + { + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTFinalHeader)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTFinalHelpText)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTAdditionalSettings)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTFinalText)); + } + + // ----------------------------------------------------------------------- + void OFinalDBPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) + { + _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aCBOpenAfterwards)); + _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aCBStartTableWizard)); + _rControlList.push_back(new OSaveValueWrapper<RadioButton>(&m_aRBRegisterDataSource)); + _rControlList.push_back(new OSaveValueWrapper<RadioButton>(&m_aRBDontregisterDataSource)); + } + + // ----------------------------------------------------------------------- + void OFinalDBPageSetup::implInitControls(const SfxItemSet& /*_rSet*/, sal_Bool /*_bSaveValue*/) + { + m_aCBOpenAfterwards.Check(); + } + + void OFinalDBPageSetup::enableTableWizardCheckBox( sal_Bool _bSupportsTableCreation) + { + m_aCBStartTableWizard.Enable(_bSupportsTableCreation); + } + + // ----------------------------------------------------------------------- + sal_Bool OFinalDBPageSetup::FillItemSet( SfxItemSet& /*_rSet*/ ) + { + return sal_True; + } + // ----------------------------------------------------------------------------- + IMPL_LINK(OFinalDBPageSetup, OnOpenSelected, CheckBox*, _pBox) + { + m_aCBStartTableWizard.Enable( _pBox->IsEnabled() && _pBox->IsChecked() ); + callModifiedHdl(); + // outta here + return 0L; + } +//......................................................................... +} +// namespace dbaui +//......................................................................... diff --git a/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx b/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx new file mode 100644 index 000000000000..1ba67e19b9e2 --- /dev/null +++ b/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx @@ -0,0 +1,344 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBAUI_DBSETUPCONNECTIONPAGES_HXX +#define DBAUI_DBSETUPCONNECTIONPAGES_HXX + +#ifndef DBAUI_CONNECTIONPAGESETUP_HXX +#include "ConnectionPageSetup.hxx" +#endif + +#include "adminpages.hxx" +#include "admincontrols.hxx" +#include "curledit.hxx" +#include "TextConnectionHelper.hxx" + +#include <svtools/roadmapwizard.hxx> +#include <ucbhelper/content.hxx> +#include <vcl/field.hxx> + + +//......................................................................... +namespace dbaui + +{ +//......................................................................... + + class IDatabaseSettingsDialog; +// static OGenericAdministrationPage* CreateDbaseTabPage( Window* pParent, const SfxItemSet& _rAttrSet ); + + + //======================================================================== + //= OSpreadSheetConnectionPageSetup + //======================================================================== + class OSpreadSheetConnectionPageSetup : public OConnectionTabPageSetup + { + public: + virtual BOOL FillItemSet ( SfxItemSet& _rCoreAttrs ); + static OGenericAdministrationPage* CreateSpreadSheetTabPage( Window* pParent, const SfxItemSet& _rAttrSet ); + OSpreadSheetConnectionPageSetup(Window* pParent, const SfxItemSet& _rCoreAttrs); + + protected: + CheckBox m_aCBPasswordrequired; + virtual ~OSpreadSheetConnectionPageSetup(); + + protected: + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList); + virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList); + + }; + + //======================================================================== + //= OTextConnectionPage + //======================================================================== + class OTextConnectionPageSetup : public OConnectionTabPageSetup + { + public: + virtual BOOL FillItemSet ( SfxItemSet& _rCoreAttrs ); + static OGenericAdministrationPage* CreateTextTabPage( Window* pParent, const SfxItemSet& _rAttrSet ); + OTextConnectionPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs ); + OTextConnectionHelper* m_pTextConnectionHelper; + private: + + protected: + virtual ~OTextConnectionPageSetup(); + virtual sal_Bool prepareLeave(); + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList); + virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList); + bool checkTestConnection(); + + private: + DECL_LINK(ImplGetExtensionHdl, OTextConnectionHelper*); + }; + + //======================================================================== + //= OLDAPConnectionPageSetup + //======================================================================== + class OLDAPConnectionPageSetup : public OGenericAdministrationPage + { + public: + virtual BOOL FillItemSet ( SfxItemSet& _rCoreAttrs ); + static OGenericAdministrationPage* CreateLDAPTabPage( Window* pParent, const SfxItemSet& _rAttrSet ); + OLDAPConnectionPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs ); + virtual Link getControlModifiedLink() { return LINK(this, OLDAPConnectionPageSetup, OnEditModified); } + + protected: + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList); + virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList); + DECL_LINK(OnEditModified,Edit*); + + private: + FixedText m_aFTHeaderText; + FixedText m_aFTHelpText; + FixedText m_aFTHostServer; + Edit m_aETHostServer; + FixedText m_aFTBaseDN; + Edit m_aETBaseDN; + FixedText m_aFTPortNumber; + NumericField m_aNFPortNumber; + FixedText m_aFTDefaultPortNumber; + CheckBox m_aCBUseSSL; + }; + + //======================================================================== + //= MySQLNativeSetupPage + //======================================================================== + class MySQLNativeSetupPage : public OGenericAdministrationPage + { + private: + FixedText m_aHeader; + FixedText m_aHelpText; + MySQLNativeSettings m_aMySQLSettings; + + public: + MySQLNativeSetupPage( Window* _pParent, const SfxItemSet& _rCoreAttrs ); + + static OGenericAdministrationPage* Create( Window* pParent, const SfxItemSet& _rAttrSet ); + + protected: + virtual void fillControls( ::std::vector< ISaveValueWrapper* >& _rControlList ); + virtual void fillWindows( ::std::vector< ISaveValueWrapper* >& _rControlList ); + + virtual BOOL FillItemSet( SfxItemSet& _rCoreAttrs ); + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + + virtual Link getControlModifiedLink(); + + private: + DECL_LINK( OnModified, Edit* ); + }; + + //======================================================================== + //= OGeneralSpecialJDBCConnectionPageSetup + //======================================================================== + class OGeneralSpecialJDBCConnectionPageSetup : public OGenericAdministrationPage + { + public: + OGeneralSpecialJDBCConnectionPageSetup( Window* pParent + , USHORT _nResId + , const SfxItemSet& _rCoreAttrs + , USHORT _nPortId + , USHORT _nDefaultPortResId + , USHORT _nHelpTextResId + , USHORT _nHeaderTextResId + , USHORT _nDriverClassId ); + static OGenericAdministrationPage* CreateMySQLJDBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet ); + static OGenericAdministrationPage* CreateOracleJDBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet ); + + protected: + virtual BOOL FillItemSet( SfxItemSet& _rCoreAttrs ); + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList); + virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList); + virtual Link getControlModifiedLink() { return LINK(this, OGeneralSpecialJDBCConnectionPageSetup, OnEditModified); } + + DECL_LINK(OnTestJavaClickHdl,PushButton*); + DECL_LINK(OnEditModified,Edit*); + FixedText m_aFTHelpText; + FixedText m_aFTDatabasename; + Edit m_aETDatabasename; + FixedText m_aFTHostname; + Edit m_aETHostname; + FixedText m_aFTPortNumber; + FixedText m_aFTDefaultPortNumber; + NumericField m_aNFPortNumber; + + + FixedText m_aFTDriverClass; + Edit m_aETDriverClass; + PushButton m_aPBTestJavaDriver; + + String m_sDefaultJdbcDriverName; + USHORT m_nPortId; + }; + + + //======================================================================== + //= OJDBCConnectionPageSetup + //======================================================================== + class OJDBCConnectionPageSetup : public OConnectionTabPageSetup + { + public: + OJDBCConnectionPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs ); + static OGenericAdministrationPage* CreateJDBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet ); + + protected: + virtual bool checkTestConnection(); + + virtual BOOL FillItemSet( SfxItemSet& _rCoreAttrs ); + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList); + virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList); + + DECL_LINK(OnTestJavaClickHdl,PushButton*); + DECL_LINK(OnEditModified,Edit*); + FixedText m_aFTDriverClass; + Edit m_aETDriverClass; + PushButton m_aPBTestJavaDriver; + }; + + + + //======================================================================== + //= OJDBCConnectionPageSetup + //======================================================================== + class OMySQLIntroPageSetup : public OGenericAdministrationPage + { + public: + enum ConnectionType + { + VIA_ODBC, + VIA_JDBC, + VIA_NATIVE + }; + + OMySQLIntroPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs); + + static OMySQLIntroPageSetup* CreateMySQLIntroTabPage( Window* _pParent, const SfxItemSet& _rAttrSet ); + ConnectionType getMySQLMode(); + Link maClickHdl; + void SetClickHdl( const Link& rLink ) { maClickHdl = rLink; } + const Link& GetClickHdl() const { return maClickHdl; } + DECL_LINK(ImplClickHdl, OMySQLIntroPageSetup*); + + + + + protected: + virtual BOOL FillItemSet(SfxItemSet& _rSet); + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList); + virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList); + virtual ~OMySQLIntroPageSetup(); + + private: + RadioButton m_aRB_ODBCDatabase; + RadioButton m_aRB_JDBCDatabase; + RadioButton m_aRB_NATIVEDatabase; + FixedText m_aFT_ConnectionMode; + FixedText m_aFT_Helptext; + FixedText m_aFT_Headertext; + + DECL_LINK(OnSetupModeSelected, RadioButton*); + + }; + + + + + //======================================================================== + //= OAuthentificationPageSetup + //======================================================================== + class OAuthentificationPageSetup : public OGenericAdministrationPage + { + public: + virtual BOOL FillItemSet ( SfxItemSet& _rCoreAttrs ); + static OGenericAdministrationPage* CreateAuthentificationTabPage( Window* pParent, const SfxItemSet& _rAttrSet ); + OAuthentificationPageSetup(Window* pParent, const SfxItemSet& _rCoreAttrs); + + protected: + FixedText m_aFTHelpText; + FixedText m_aFTHeaderText; + FixedText m_aFTUserName; + Edit m_aETUserName; + CheckBox m_aCBPasswordRequired; + PushButton m_aPBTestConnection; + virtual ~OAuthentificationPageSetup(); + + protected: + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList); + virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList); + }; + + + + //======================================================================== + //= OFinalDBPageSetup + //======================================================================== + class OFinalDBPageSetup : public OGenericAdministrationPage + { + public: + virtual BOOL FillItemSet ( SfxItemSet& _rCoreAttrs ); + static OGenericAdministrationPage* CreateFinalDBTabPageSetup( Window* pParent, const SfxItemSet& _rAttrSet); + + FixedText m_aFTFinalHeader; + FixedText m_aFTFinalHelpText; + RadioButton m_aRBRegisterDataSource; + RadioButton m_aRBDontregisterDataSource; + FixedText m_aFTAdditionalSettings; + CheckBox m_aCBOpenAfterwards; + CheckBox m_aCBStartTableWizard; + FixedText m_aFTFinalText; + + OFinalDBPageSetup(Window* pParent, const SfxItemSet& _rCoreAttrs); + sal_Bool IsDatabaseDocumentToBeRegistered(); + sal_Bool IsDatabaseDocumentToBeOpened(); + sal_Bool IsTableWizardToBeStarted(); + void enableTableWizardCheckBox( sal_Bool _bSupportsTableCreation); + + /// may be used in SetXXXHdl calls to controls, is a link to <method>OnControlModified</method> + Link getControlModifiedLink() { return LINK(this, OGenericAdministrationPage, OnControlModified); } + + DECL_LINK(OnOpenSelected, CheckBox*); + protected: + virtual ~OFinalDBPageSetup(); + + protected: + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList); + virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList); + }; + +//......................................................................... +} // namespace dbaui +//......................................................................... + +#endif diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.cxx b/dbaccess/source/ui/dlg/DbAdminImpl.cxx new file mode 100755 index 000000000000..797cb73eb021 --- /dev/null +++ b/dbaccess/source/ui/dlg/DbAdminImpl.cxx @@ -0,0 +1,1219 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#include "DbAdminImpl.hxx" +#include "dsmeta.hxx" + +#include <svl/poolitem.hxx> +#include <svl/itempool.hxx> +#include <svl/stritem.hxx> +#include <svl/intitem.hxx> +#include <svl/eitem.hxx> +#include "DriverSettings.hxx" +#include "IItemSetHelper.hxx" +#include "UITools.hxx" +#include "dbu_dlg.hrc" +#include "dbustrings.hrc" +#include "dsitems.hxx" +#include "dsnItem.hxx" +#include "moduledbu.hxx" +#include "optionalboolitem.hxx" +#include "propertysetitem.hxx" +#include "stringlistitem.hxx" +#include "OAuthenticationContinuation.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/sdb/SQLContext.hpp> +#include <com/sun/star/sdbc/XDriver.hpp> +#include <com/sun/star/sdbc/XDriverAccess.hpp> +#include <com/sun/star/task/XInteractionHandler.hpp> +#include <com/sun/star/task/XInteractionRequest.hpp> +#include <com/sun/star/ucb/XInteractionSupplyAuthentication2.hpp> +#include <com/sun/star/ucb/AuthenticationRequest.hpp> +/** === end UNO includes === **/ + +#include <comphelper/interaction.hxx> +#include <comphelper/property.hxx> +#include <comphelper/sequence.hxx> +#include <comphelper/guarding.hxx> +#include <connectivity/DriversConfig.hxx> +#include <connectivity/dbexception.hxx> +#include <osl/file.hxx> +#include <svl/eitem.hxx> +#include <svl/intitem.hxx> +#include <svl/itempool.hxx> +#include <svl/poolitem.hxx> +#include <svl/stritem.hxx> +#include <tools/urlobj.hxx> +#include <tools/diagnose_ex.h> +#include <typelib/typedescription.hxx> +#include <vcl/svapp.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/stdtext.hxx> +#include <vcl/waitobj.hxx> +#include <vos/mutex.hxx> + +#include <algorithm> +#include <functional> +//......................................................................... +namespace dbaui +{ +//......................................................................... +using namespace ::dbtools; +using namespace com::sun::star::uno; +using namespace com::sun::star; +using namespace com::sun::star::ucb; +using namespace com::sun::star::task; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::sdb; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::util; +using namespace com::sun::star::container; +using namespace com::sun::star::frame; + +//------------------------------------------------------------------------- +namespace +{ + sal_Bool implCheckItemType( SfxItemSet& _rSet, const USHORT _nId, const TypeId _nExpectedItemType ) + { + sal_Bool bCorrectType = sal_False; + + SfxItemPool* pPool = _rSet.GetPool(); + DBG_ASSERT( pPool, "implCheckItemType: invalid item pool!" ); + if ( pPool ) + { + const SfxPoolItem& rDefItem = pPool->GetDefaultItem( _nId ); + bCorrectType = rDefItem.IsA( _nExpectedItemType ); + } + return bCorrectType; + } + + void lcl_putProperty(const Reference< XPropertySet >& _rxSet, const ::rtl::OUString& _rName, const Any& _rValue) + { + try + { + if ( _rxSet.is() ) + _rxSet->setPropertyValue(_rName, _rValue); + } + catch(Exception&) + { + #ifdef DBG_UTIL + ::rtl::OString sMessage("ODbAdminDialog::implTranslateProperty: could not set the property "); + sMessage += ::rtl::OString(_rName.getStr(), _rName.getLength(), RTL_TEXTENCODING_ASCII_US); + sMessage += ::rtl::OString("!"); + DBG_ERROR(sMessage.getStr()); + #endif + } + + } + + String lcl_createHostWithPort(const SfxStringItem* _pHostName,const SfxInt32Item* _pPortNumber) + { + String sNewUrl; + + if ( _pHostName && _pHostName->GetValue().Len() ) + sNewUrl = _pHostName->GetValue(); + + if ( _pPortNumber ) + { + sNewUrl += String::CreateFromAscii(":"); + sNewUrl += String::CreateFromInt32(_pPortNumber->GetValue()); + } + + return sNewUrl; + } +} + + //======================================================================== + //= ODbDataSourceAdministrationHelper + //======================================================================== +ODbDataSourceAdministrationHelper::ODbDataSourceAdministrationHelper(const Reference< XMultiServiceFactory >& _xORB,Window* _pParent,IItemSetHelper* _pItemSetHelper) + : m_xORB(_xORB) + , m_pParent(_pParent) + , m_pItemSetHelper(_pItemSetHelper) +{ + /// initialize the property translation map + // direct properties of a data source + m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_CONNECTURL, PROPERTY_URL)); + m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_NAME, PROPERTY_NAME)); + m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_USER, PROPERTY_USER)); + m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_PASSWORD, PROPERTY_PASSWORD)); + m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_PASSWORDREQUIRED, PROPERTY_ISPASSWORDREQUIRED)); + m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_TABLEFILTER, PROPERTY_TABLEFILTER)); + m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_READONLY, PROPERTY_ISREADONLY)); + m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_SUPPRESSVERSIONCL, PROPERTY_SUPPRESSVERSIONCL)); + + // implicit properties, to be found in the direct property "Info" + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_JDBCDRIVERCLASS, INFO_JDBCDRIVERCLASS)); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_TEXTFILEEXTENSION, INFO_TEXTFILEEXTENSION)); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CHARSET, INFO_CHARSET)); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_TEXTFILEHEADER, INFO_TEXTFILEHEADER)); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_FIELDDELIMITER, INFO_FIELDDELIMITER)); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_TEXTDELIMITER, INFO_TEXTDELIMITER)); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_DECIMALDELIMITER, INFO_DECIMALDELIMITER)); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_THOUSANDSDELIMITER, INFO_THOUSANDSDELIMITER)); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_SHOWDELETEDROWS, INFO_SHOWDELETEDROWS)); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_ALLOWLONGTABLENAMES, INFO_ALLOWLONGTABLENAMES)); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_ADDITIONALOPTIONS, INFO_ADDITIONALOPTIONS)); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_SQL92CHECK, PROPERTY_ENABLESQL92CHECK)); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_AUTOINCREMENTVALUE, PROPERTY_AUTOINCREMENTCREATION)); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_AUTORETRIEVEVALUE, INFO_AUTORETRIEVEVALUE)); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_AUTORETRIEVEENABLED, INFO_AUTORETRIEVEENABLED)); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_APPEND_TABLE_ALIAS, INFO_APPEND_TABLE_ALIAS)); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_AS_BEFORE_CORRNAME, INFO_AS_BEFORE_CORRELATION_NAME ) ); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CHECK_REQUIRED_FIELDS, INFO_FORMS_CHECK_REQUIRED_FIELDS ) ); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_ESCAPE_DATETIME, INFO_ESCAPE_DATETIME ) ); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_PRIMARY_KEY_SUPPORT, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrimaryKeySupport" ) ) ) ); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_PARAMETERNAMESUBST, INFO_PARAMETERNAMESUBST)); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_IGNOREDRIVER_PRIV, INFO_IGNOREDRIVER_PRIV)); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_BOOLEANCOMPARISON, PROPERTY_BOOLEANCOMPARISONMODE)); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_ENABLEOUTERJOIN, PROPERTY_ENABLEOUTERJOIN)); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CATALOG, PROPERTY_USECATALOGINSELECT)); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_SCHEMA, PROPERTY_USESCHEMAINSELECT)); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_INDEXAPPENDIX, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AddIndexAppendix")))); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_DOSLINEENDS, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PreferDosLikeLineEnds" ) ) ) ); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_SOCKET, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LocalSocket" ) ) ) ); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_NAMED_PIPE, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NamedPipe" ) ) ) ); + + // special settings for adabas + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_SHUTSERVICE, ::rtl::OUString::createFromAscii("ShutdownDatabase"))); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_DATAINC, ::rtl::OUString::createFromAscii("DataCacheSizeIncrement"))); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_CACHESIZE, ::rtl::OUString::createFromAscii("DataCacheSize"))); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_CTRLUSER, ::rtl::OUString::createFromAscii("ControlUser"))); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_CTRLPWD, ::rtl::OUString::createFromAscii("ControlPassword"))); + + // extra settings for odbc + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_USECATALOG, INFO_USECATALOG)); + // extra settings for a ldap address book + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_LDAP_BASEDN, INFO_CONN_LDAP_BASEDN)); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_LDAP_ROWCOUNT, INFO_CONN_LDAP_ROWCOUNT)); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_LDAP_USESSL, ::rtl::OUString::createFromAscii("UseSSL"))); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_DOCUMENT_URL, PROPERTY_URL)); + + // oracle + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_IGNORECURRENCY, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IgnoreCurrency")))); + + try + { + m_xDatabaseContext = Reference< XNameAccess >(m_xORB->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY); + m_xDynamicContext.set(m_xDatabaseContext,UNO_QUERY); + } + catch(Exception&) + { + } + + if ( !m_xDatabaseContext.is() ) + { + ShowServiceNotAvailableError(_pParent->GetParent(), String(SERVICE_SDB_DATABASECONTEXT), sal_True); + } + + DBG_ASSERT(m_xDynamicContext.is(), "ODbAdminDialog::ODbAdminDialog : no XNamingService interface !"); +} + //------------------------------------------------------------------------- +sal_Bool ODbDataSourceAdministrationHelper::getCurrentSettings(Sequence< PropertyValue >& _rDriverParam) +{ + DBG_ASSERT(m_pItemSetHelper->getOutputSet(), "ODbDataSourceAdministrationHelper::getCurrentSettings : not to be called without an example set!"); + if (!m_pItemSetHelper->getOutputSet()) + return sal_False; + + ::std::vector< PropertyValue > aReturn; + // collecting this in a vector because it has a push_back, in opposite to sequences + + // user: DSID_USER -> "user" + SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pUser, SfxStringItem, DSID_USER, sal_True); + if (pUser && pUser->GetValue().Len()) + aReturn.push_back( + PropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user")), 0, + makeAny(::rtl::OUString(pUser->GetValue())), PropertyState_DIRECT_VALUE)); + + // check if the connection type requires a password + if (hasAuthentication(*m_pItemSetHelper->getOutputSet())) + { + // password: DSID_PASSWORD -> "password" + SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pPassword, SfxStringItem, DSID_PASSWORD, sal_True); + String sPassword = pPassword ? pPassword->GetValue() : String(); + SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pPasswordRequired, SfxBoolItem, DSID_PASSWORDREQUIRED, sal_True); + // if the set does not contain a password, but the item set says it requires one, ask the user + if ((!pPassword || !pPassword->GetValue().Len()) && (pPasswordRequired && pPasswordRequired->GetValue())) + { + SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pName, SfxStringItem, DSID_NAME, sal_True); + + Reference< XModel > xModel( getDataSourceOrModel( m_xDatasource ), UNO_QUERY_THROW ); + ::comphelper::NamedValueCollection aArgs( xModel->getArgs() ); + Reference< XInteractionHandler > xHandler( aArgs.getOrDefault( "InteractionHandler", Reference< XInteractionHandler >() ) ); + + if ( !xHandler.is() ) + { + // instantiate the default SDB interaction handler + xHandler = Reference< XInteractionHandler >( m_xORB->createInstance( SERVICE_TASK_INTERACTION_HANDLER ), UNO_QUERY ); + if ( !xHandler.is() ) + ShowServiceNotAvailableError(m_pParent->GetParent(), String(SERVICE_TASK_INTERACTION_HANDLER), sal_True); + } + + String sName = pName ? pName->GetValue() : String(); + String sLoginRequest(ModuleRes(STR_ENTER_CONNECTION_PASSWORD)); + ::rtl::OUString sTemp = sName; + sName = ::dbaui::getStrippedDatabaseName(NULL,sTemp); + if ( sName.Len() ) + sLoginRequest.SearchAndReplaceAscii("$name$", sName); + else + { + sLoginRequest.SearchAndReplaceAscii("\"$name$\"", String()); + sLoginRequest.SearchAndReplaceAscii("$name$", String()); // just to be sure that in other languages the string will be deleted + } + + // the request + AuthenticationRequest aRequest; + aRequest.ServerName = sName; + aRequest.Diagnostic = sLoginRequest; + aRequest.HasRealm = aRequest.HasAccount = sal_False; + // aRequest.Realm + aRequest.HasUserName = pUser != 0; + aRequest.UserName = pUser ? rtl::OUString(pUser->GetValue()) : ::rtl::OUString(); + aRequest.HasPassword = sal_True; + //aRequest.Password + aRequest.HasAccount = sal_False; + // aRequest.Account + + comphelper::OInteractionRequest* pRequest = new comphelper::OInteractionRequest(makeAny(aRequest)); + uno::Reference< XInteractionRequest > xRequest(pRequest); + + // build an interaction request + // two continuations (Ok and Cancel) + ::rtl::Reference< comphelper::OInteractionAbort > pAbort = new comphelper::OInteractionAbort; + ::rtl::Reference< dbaccess::OAuthenticationContinuation > pAuthenticate = new dbaccess::OAuthenticationContinuation; + pAuthenticate->setCanChangeUserName( sal_False ); + pAuthenticate->setRememberPassword( RememberAuthentication_SESSION ); + + // some knittings + pRequest->addContinuation(pAbort.get()); + pRequest->addContinuation(pAuthenticate.get()); + + // handle the request + try + { + ::vos::OGuard aSolarGuard(Application::GetSolarMutex()); + // release the mutex when calling the handler, it may need to lock the SolarMutex + xHandler->handle(xRequest); + } + catch(Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + if (!pAuthenticate->wasSelected()) + return sal_False; + + sPassword = pAuthenticate->getPassword(); + if (pAuthenticate->getRememberPassword()) + m_pItemSetHelper->getWriteOutputSet()->Put(SfxStringItem(DSID_PASSWORD, sPassword)); + } + + if (sPassword.Len()) + aReturn.push_back( + PropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("password")), 0, + makeAny(::rtl::OUString(sPassword)), PropertyState_DIRECT_VALUE)); + } + + if ( !aReturn.empty() ) + _rDriverParam = Sequence< PropertyValue >(&(*aReturn.begin()), aReturn.size()); + + // append all the other stuff (charset etc.) + fillDatasourceInfo(*m_pItemSetHelper->getOutputSet(), _rDriverParam); + + return sal_True; +} +//------------------------------------------------------------------------- +void ODbDataSourceAdministrationHelper::successfullyConnected() +{ + DBG_ASSERT(m_pItemSetHelper->getOutputSet(), "ODbDataSourceAdministrationHelper::successfullyConnected: not to be called without an example set!"); + if (!m_pItemSetHelper->getOutputSet()) + return; + + if (hasAuthentication(*m_pItemSetHelper->getOutputSet())) + { + SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pPassword, SfxStringItem, DSID_PASSWORD, sal_True); + if (pPassword && (0 != pPassword->GetValue().Len())) + { + ::rtl::OUString sPassword = pPassword->GetValue(); + + Reference< XPropertySet > xCurrentDatasource = getCurrentDataSource(); + lcl_putProperty(xCurrentDatasource,m_aDirectPropTranslator[DSID_PASSWORD], makeAny(sPassword)); + } + } +} +//------------------------------------------------------------------------- +void ODbDataSourceAdministrationHelper::clearPassword() +{ + if (m_pItemSetHelper->getWriteOutputSet()) + m_pItemSetHelper->getWriteOutputSet()->ClearItem(DSID_PASSWORD); +} +// ----------------------------------------------------------------------------- +::std::pair< Reference<XConnection>,sal_Bool> ODbDataSourceAdministrationHelper::createConnection() +{ + ::std::pair< Reference<XConnection>,sal_Bool> aRet; + aRet.second = sal_False; + Sequence< PropertyValue > aConnectionParams; + if ( getCurrentSettings(aConnectionParams) ) + { + // the current DSN + // fill the table list with this connection information + SQLExceptionInfo aErrorInfo; + try + { + WaitObject aWaitCursor(m_pParent); + aRet.first = getDriver()->connect(getConnectionURL(), aConnectionParams); + aRet.second = sal_True; + } + catch (SQLContext& e) { aErrorInfo = SQLExceptionInfo(e); } + catch (SQLWarning& e) { aErrorInfo = SQLExceptionInfo(e); } + catch (SQLException& e) { aErrorInfo = SQLExceptionInfo(e); } + + showError(aErrorInfo,m_pParent,getORB()); + } + if ( aRet.first.is() ) + successfullyConnected();// notify the admindlg to save the password + + return aRet; +} +// ----------------------------------------------------------------------------- +Reference< XDriver > ODbDataSourceAdministrationHelper::getDriver() +{ + return getDriver(getConnectionURL()); +} +// ----------------------------------------------------------------------------- +Reference< XDriver > ODbDataSourceAdministrationHelper::getDriver(const ::rtl::OUString& _sURL) +{ + // get the global DriverManager + Reference< XDriverAccess > xDriverManager; + String sCurrentActionError = String(ModuleRes(STR_COULDNOTCREATE_DRIVERMANAGER)); + // in case an error occures + sCurrentActionError.SearchAndReplaceAscii("#servicename#", (::rtl::OUString)SERVICE_SDBC_CONNECTIONPOOL); + try + { + xDriverManager = Reference< XDriverAccess >(getORB()->createInstance(SERVICE_SDBC_CONNECTIONPOOL), UNO_QUERY); + DBG_ASSERT(xDriverManager.is(), "ODbDataSourceAdministrationHelper::getDriver: could not instantiate the driver manager, or it does not provide the necessary interface!"); + } + catch (Exception& e) + { + // wrap the exception into an SQLException + SQLException aSQLWrapper(e.Message, getORB(), ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")), 0, Any()); + throw SQLException(sCurrentActionError, getORB(), ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")), 0, makeAny(aSQLWrapper)); + } + if (!xDriverManager.is()) + throw SQLException(sCurrentActionError, getORB(), ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")), 0, Any()); + + + Reference< XDriver > xDriver = xDriverManager->getDriverByURL(_sURL); + if (!xDriver.is()) + { + sCurrentActionError = String(ModuleRes(STR_NOREGISTEREDDRIVER)); + sCurrentActionError.SearchAndReplaceAscii("#connurl#", _sURL); + // will be caught and translated into an SQLContext exception + throw SQLException(sCurrentActionError, getORB(), ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")), 0, Any()); + } + return xDriver; +} + +// ----------------------------------------------------------------------------- +Reference< XPropertySet > ODbDataSourceAdministrationHelper::getCurrentDataSource() +{ + if ( !m_xDatasource.is() ) + { + Reference<XInterface> xIn(m_aDataSourceOrName,UNO_QUERY); + if ( !xIn.is() ) + { + ::rtl::OUString sCurrentDatasource; + m_aDataSourceOrName >>= sCurrentDatasource; + OSL_ENSURE(sCurrentDatasource.getLength(),"No datasource name given!"); + try + { + if ( m_xDatabaseContext.is() ) + m_xDatasource.set(m_xDatabaseContext->getByName(sCurrentDatasource),UNO_QUERY); + xIn = m_xDatasource; + } + catch(const Exception&) + { + } + } + m_xModel.set(getDataSourceOrModel(xIn),UNO_QUERY); + if ( m_xModel.is() ) + m_xDatasource.set(xIn,UNO_QUERY); + else + { + m_xDatasource.set(getDataSourceOrModel(xIn),UNO_QUERY); + m_xModel.set(xIn,UNO_QUERY); + } + } + + + DBG_ASSERT(m_xDatasource.is(), "ODbDataSourceAdministrationHelper::getCurrentDataSource: no data source!"); + return m_xDatasource; +} +//------------------------------------------------------------------------- +::rtl::OUString ODbDataSourceAdministrationHelper::getDatasourceType( const SfxItemSet& _rSet ) +{ + SFX_ITEMSET_GET( _rSet, pConnectURL, SfxStringItem, DSID_CONNECTURL, sal_True ); + DBG_ASSERT( pConnectURL , "ODbDataSourceAdministrationHelper::getDatasourceType: invalid items in the source set!" ); + SFX_ITEMSET_GET(_rSet, pTypeCollection, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True); + DBG_ASSERT(pTypeCollection, "ODbDataSourceAdministrationHelper::getDatasourceType: invalid items in the source set!"); + ::dbaccess::ODsnTypeCollection* pCollection = pTypeCollection->getCollection(); + return pCollection->getType(pConnectURL->GetValue()); +} + +//------------------------------------------------------------------------- +sal_Bool ODbDataSourceAdministrationHelper::hasAuthentication(const SfxItemSet& _rSet) const +{ + return DataSourceMetaData::getAuthentication( getDatasourceType( _rSet ) ) != AuthNone; +} +// ----------------------------------------------------------------------------- +String ODbDataSourceAdministrationHelper::getConnectionURL() const +{ + String sNewUrl; + + ::rtl::OUString eType = getDatasourceType(*m_pItemSetHelper->getOutputSet()); + + SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True); + SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pTypeCollection, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True); + + OSL_ENSURE(pUrlItem,"Connection URL is NULL. -> GPF!"); + DBG_ASSERT(pTypeCollection, "ODbDataSourceAdministrationHelper::getDatasourceType: invalid items in the source set!"); + ::dbaccess::ODsnTypeCollection* pCollection = pTypeCollection->getCollection(); + DBG_ASSERT(pCollection, "ODbDataSourceAdministrationHelper::getDatasourceType: invalid type collection!"); + + switch( pCollection->determineType(eType) ) + { + case ::dbaccess::DST_DBASE: + case ::dbaccess::DST_FLAT: + case ::dbaccess::DST_CALC: + break; + case ::dbaccess::DST_ADABAS: + { + SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pHostName, SfxStringItem, DSID_CONN_HOSTNAME, sal_True); + sNewUrl = lcl_createHostWithPort(pHostName,NULL); + String sUrl = pCollection->cutPrefix(pUrlItem->GetValue()); + if ( sUrl.GetTokenCount(':') == 1 ) + sNewUrl += String::CreateFromAscii(":"); + + sNewUrl += sUrl; + } + break; + case ::dbaccess::DST_MSACCESS: + case ::dbaccess::DST_MSACCESS_2007: + { + ::rtl::OUString sFileName = pCollection->cutPrefix(pUrlItem->GetValue()); + ::rtl::OUString sNewFileName; + if ( ::osl::FileBase::getSystemPathFromFileURL( sFileName, sNewFileName ) == ::osl::FileBase::E_None ) + { + sNewUrl += String(sNewFileName); + } + } + break; + case ::dbaccess::DST_MYSQL_NATIVE: + case ::dbaccess::DST_MYSQL_JDBC: + { + SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pHostName, SfxStringItem, DSID_CONN_HOSTNAME, sal_True); + SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pPortNumber, SfxInt32Item, DSID_MYSQL_PORTNUMBER, sal_True); + SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pDatabaseName, SfxStringItem, DSID_DATABASENAME, sal_True); + sNewUrl = lcl_createHostWithPort(pHostName,pPortNumber); + String sDatabaseName = pDatabaseName ? pDatabaseName->GetValue() : String(); + if ( !sDatabaseName.Len() && pUrlItem ) + sDatabaseName = pCollection->cutPrefix( pUrlItem->GetValue() ); + // TODO: what's that? Why is the database name transported via the URL Item? + // Huh? Anybody there? + // OJ: It is needed when the connection properties are changed. There the URL is used for every type. + + if ( sDatabaseName.Len() ) + { + sNewUrl += String::CreateFromAscii("/"); + sNewUrl += sDatabaseName; + } + } + break; + case ::dbaccess::DST_ORACLE_JDBC: + { + SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pHostName, SfxStringItem, DSID_CONN_HOSTNAME, sal_True); + SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pPortNumber, SfxInt32Item, DSID_ORACLE_PORTNUMBER, sal_True); + SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pDatabaseName, SfxStringItem, DSID_DATABASENAME, sal_True); + if ( pHostName && pHostName->GetValue().Len() ) + { + sNewUrl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("@")); + sNewUrl += lcl_createHostWithPort(pHostName,pPortNumber); + String sDatabaseName = pDatabaseName ? pDatabaseName->GetValue() : String(); + if ( !sDatabaseName.Len() && pUrlItem ) + sDatabaseName = pCollection->cutPrefix( pUrlItem->GetValue() ); + if ( sDatabaseName.Len() ) + { + sNewUrl += String::CreateFromAscii(":"); + sNewUrl += sDatabaseName; + } + } + else + { // here someone entered a JDBC url which looks like oracle, so we have to use the url property + + } + } + break; + case ::dbaccess::DST_LDAP: + { + // SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pHostName, SfxStringItem, DSID_CONN_HOSTNAME, sal_True); + SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pPortNumber, SfxInt32Item, DSID_CONN_LDAP_PORTNUMBER, sal_True); + sNewUrl = pCollection->cutPrefix(pUrlItem->GetValue()); + sNewUrl += lcl_createHostWithPort(NULL,pPortNumber); + } + break; + case ::dbaccess::DST_JDBC: + // run through + default: + break; + } + if ( sNewUrl.Len() ) + { + String sUrl = pCollection->getPrefix(eType); + sUrl += sNewUrl; + sNewUrl = sUrl; + } + else + sNewUrl = pUrlItem->GetValue(); + + return sNewUrl; +} +//------------------------------------------------------------------------- +struct PropertyValueLess +{ + bool operator() (const PropertyValue& x, const PropertyValue& y) const + { return x.Name < y.Name ? true : false; } // construct prevents a MSVC6 warning +}; +DECLARE_STL_SET( PropertyValue, PropertyValueLess, PropertyValueSet); + +//........................................................................ +void ODbDataSourceAdministrationHelper::translateProperties(const Reference< XPropertySet >& _rxSource, SfxItemSet& _rDest) +{ + ::rtl::OUString sNewConnectURL, sName, sUid, sPwd; + Sequence< ::rtl::OUString > aTableFitler; + + if (_rxSource.is()) + { + for ( ConstMapInt2StringIterator aDirect = m_aDirectPropTranslator.begin(); + aDirect != m_aDirectPropTranslator.end(); + ++aDirect + ) + { + // get the property value + Any aValue; + try + { + aValue = _rxSource->getPropertyValue(aDirect->second); + } + catch(Exception&) + { +#ifdef DBG_UTIL + ::rtl::OString aMessage("ODbDataSourceAdministrationHelper::translateProperties: could not extract the property "); + aMessage += ::rtl::OString(aDirect->second.getStr(), aDirect->second.getLength(), RTL_TEXTENCODING_ASCII_US); + aMessage += ::rtl::OString("!"); + DBG_ERROR(aMessage.getStr()); +#endif + } + // transfer it into an item + implTranslateProperty(_rDest, aDirect->first, aValue); + } + + // get the additional informations + Sequence< PropertyValue > aAdditionalInfo; + try + { + _rxSource->getPropertyValue(PROPERTY_INFO) >>= aAdditionalInfo; + } + catch(Exception&) { } + + // collect the names of the additional settings + const PropertyValue* pAdditionalInfo = aAdditionalInfo.getConstArray(); + PropertyValueSet aInfos; + for (sal_Int32 i=0; i<aAdditionalInfo.getLength(); ++i, ++pAdditionalInfo) + { + if (0 == pAdditionalInfo->Name.compareToAscii("JDBCDRV")) + { // compatibility + PropertyValue aCompatibility(*pAdditionalInfo); + aCompatibility.Name = ::rtl::OUString::createFromAscii("JavaDriverClass"); + aInfos.insert(aCompatibility); + } + else + aInfos.insert(*pAdditionalInfo); + } + + // go through all known translations and check if we have such a setting + if ( !aInfos.empty() ) + { + PropertyValue aSearchFor; + ConstMapInt2StringIterator aEnd = m_aIndirectPropTranslator.end(); + for ( ConstMapInt2StringIterator aIndirect = m_aIndirectPropTranslator.begin(); + aIndirect != aEnd; + ++aIndirect) + { + aSearchFor.Name = aIndirect->second; + ConstPropertyValueSetIterator aInfoPos = aInfos.find(aSearchFor); + if (aInfos.end() != aInfoPos) + // the property is contained in the info sequence + // -> transfer it into an item + implTranslateProperty(_rDest, aIndirect->first, aInfoPos->Value); + } + } + + convertUrl(_rDest); + } + + try + { + _rDest.Put(OPropertySetItem(DSID_DATASOURCE_UNO, _rxSource)); + Reference<XStorable> xStore(getDataSourceOrModel(_rxSource),UNO_QUERY); + _rDest.Put(SfxBoolItem(DSID_READONLY, !xStore.is() || xStore->isReadonly() )); + } + catch(Exception&) + { + OSL_ENSURE(0,"IsReadOnly throws an exception!"); + } +} + +//------------------------------------------------------------------------- +void ODbDataSourceAdministrationHelper::translateProperties(const SfxItemSet& _rSource, const Reference< XPropertySet >& _rxDest) +{ + DBG_ASSERT(_rxDest.is(), "ODbDataSourceAdministrationHelper::translateProperties: invalid property set!"); + if (!_rxDest.is()) + return; + + // the property set info + Reference< XPropertySetInfo > xInfo; + try { xInfo = _rxDest->getPropertySetInfo(); } + catch(Exception&) { } + + const ::rtl::OUString sUrlProp(RTL_CONSTASCII_USTRINGPARAM("URL")); + // ----------------------------- + // transfer the direct properties + for ( ConstMapInt2StringIterator aDirect = m_aDirectPropTranslator.begin(); + aDirect != m_aDirectPropTranslator.end(); + ++aDirect + ) + { + const SfxPoolItem* pCurrentItem = _rSource.GetItem((USHORT)aDirect->first); + if (pCurrentItem) + { + sal_Int16 nAttributes = PropertyAttribute::READONLY; + if (xInfo.is()) + { + try { nAttributes = xInfo->getPropertyByName(aDirect->second).Attributes; } + catch(Exception&) { } + } + if ((nAttributes & PropertyAttribute::READONLY) == 0) + { + if ( sUrlProp == aDirect->second ) + { + Any aValue(makeAny(::rtl::OUString(getConnectionURL()))); + // aValue <<= ::rtl::OUString(); + lcl_putProperty(_rxDest, aDirect->second,aValue); + } + else + implTranslateProperty(_rxDest, aDirect->second, pCurrentItem); + } + } + } + + // ------------------------------- + // now for the indirect properties + + Sequence< PropertyValue > aInfo; + // the original properties + try + { + _rxDest->getPropertyValue(PROPERTY_INFO) >>= aInfo; + } + catch(Exception&) { } + + // overwrite and extend them + fillDatasourceInfo(_rSource, aInfo); + // and propagate the (newly composed) sequence to the set + lcl_putProperty(_rxDest,PROPERTY_INFO, makeAny(aInfo)); +} + + +//------------------------------------------------------------------------- +void ODbDataSourceAdministrationHelper::fillDatasourceInfo(const SfxItemSet& _rSource, Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo) +{ + // within the current "Info" sequence, replace the ones we can examine from the item set + // (we don't just fill a completely new sequence with our own items, but we preserve any properties unknown to + // us) + + // first determine which of all the items are relevant for the data source (depends on the connection url) + ::rtl::OUString eType = getDatasourceType(_rSource); + ::std::vector< sal_Int32> aDetailIds; + ODriversSettings::getSupportedIndirectSettings(eType,getORB(),aDetailIds); + + // collect the translated property values for the relevant items + PropertyValueSet aRelevantSettings; + ConstMapInt2StringIterator aTranslation; + ::std::vector< sal_Int32>::iterator aDetailsEnd = aDetailIds.end(); + for (::std::vector< sal_Int32>::iterator aIter = aDetailIds.begin();aIter != aDetailsEnd ; ++aIter) + { + const SfxPoolItem* pCurrent = _rSource.GetItem((USHORT)*aIter); + aTranslation = m_aIndirectPropTranslator.find(*aIter); + if ( pCurrent && (m_aIndirectPropTranslator.end() != aTranslation) ) + { + if ( aTranslation->second == INFO_CHARSET ) + { + ::rtl::OUString sCharSet; + implTranslateProperty(pCurrent) >>= sCharSet; + if ( sCharSet.getLength() ) + aRelevantSettings.insert(PropertyValue(aTranslation->second, 0, makeAny(sCharSet), PropertyState_DIRECT_VALUE)); + } + else + aRelevantSettings.insert(PropertyValue(aTranslation->second, 0, implTranslateProperty(pCurrent), PropertyState_DIRECT_VALUE)); + } + } + + // settings to preserve + MapInt2String aPreservedSettings; + + // now aRelevantSettings contains all the property values relevant for the current data source type, + // check the original sequence if it already contains any of these values (which have to be overwritten, then) + PropertyValue* pInfo = _rInfo.getArray(); + PropertyValue aSearchFor; + sal_Int32 nObsoleteSetting = -1; + sal_Int32 nCount = _rInfo.getLength(); + for (sal_Int32 i = 0; i < nCount; ++i, ++pInfo) + { + aSearchFor.Name = pInfo->Name; + PropertyValueSetIterator aOverwrittenSetting = aRelevantSettings.find(aSearchFor); + if (aRelevantSettings.end() != aOverwrittenSetting) + { // the setting was present in the original sequence, and it is to be overwritten -> replace it + if ( !::comphelper::compare(pInfo->Value,aOverwrittenSetting->Value) ) + *pInfo = *aOverwrittenSetting; + aRelevantSettings.erase(aOverwrittenSetting); + } + else if (0 == pInfo->Name.compareToAscii("JDBCDRV")) + { // this is a compatibility setting, remove it from the sequence (it's replaced by JavaDriverClass) + nObsoleteSetting = i; + } + else + aPreservedSettings[i] = pInfo->Name; + } + if (-1 != nObsoleteSetting) + ::comphelper::removeElementAt(_rInfo, nObsoleteSetting); + + if ( !aPreservedSettings.empty() ) + { // check if there are settings which + // * are known as indirect properties + // * but not relevant for the current data source type + // These settings have to be removed: If they're not relevant, we have no UI for changing them. + // 25.06.2001 - 88004/87182 - frank.schoenheit@sun.com + + // for this, we need a string-controlled quick access to m_aIndirectPropTranslator + StringSet aIndirectProps; + ::std::transform(m_aIndirectPropTranslator.begin(), + m_aIndirectPropTranslator.end(), + ::std::insert_iterator<StringSet>(aIndirectProps,aIndirectProps.begin()), + ::std::select2nd<MapInt2String::value_type>()); + + // now check the to-be-preserved props + ::std::vector< sal_Int32 > aRemoveIndexes; + sal_Int32 nPositionCorrector = 0; + ConstMapInt2StringIterator aPreservedEnd = aPreservedSettings.end(); + for ( ConstMapInt2StringIterator aPreserved = aPreservedSettings.begin(); + aPreserved != aPreservedEnd; + ++aPreserved + ) + { + if (aIndirectProps.end() != aIndirectProps.find(aPreserved->second)) + { +#ifdef DBG_UTIL + const ::rtl::OUString sName = aPreserved->second; +#endif + aRemoveIndexes.push_back(aPreserved->first - nPositionCorrector); + ++nPositionCorrector; + } + } + // now finally remove all such props + ::std::vector< sal_Int32 >::const_iterator aRemoveEnd = aRemoveIndexes.end(); + for ( ::std::vector< sal_Int32 >::const_iterator aRemoveIndex = aRemoveIndexes.begin(); + aRemoveIndex != aRemoveEnd; + ++aRemoveIndex + ) + ::comphelper::removeElementAt(_rInfo, *aRemoveIndex); +#ifdef DBG_UTIL + const PropertyValue* pWhatsLeft = _rInfo.getConstArray(); + const PropertyValue* pWhatsLeftEnd = pWhatsLeft + _rInfo.getLength(); + for (; pWhatsLeft != pWhatsLeftEnd; ++pWhatsLeft) + { + ::rtl::OUString sLookAtIt = pWhatsLeft->Name; + } +#endif + } + + ::connectivity::DriversConfig aDriverConfig(getORB()); + const ::comphelper::NamedValueCollection& aProperties = aDriverConfig.getProperties(eType); + Sequence< Any> aTypeSettings; + aTypeSettings = aProperties.getOrDefault("TypeInfoSettings",aTypeSettings); + // here we have a special entry for types from oracle + if ( aTypeSettings.getLength() ) + { + aRelevantSettings.insert(PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TypeInfoSettings")), 0, makeAny(aTypeSettings), PropertyState_DIRECT_VALUE)); + } + + // check which values are still left ('cause they were not present in the original sequence, but are to be set) + if ( !aRelevantSettings.empty() ) + { + sal_Int32 nOldLength = _rInfo.getLength(); + _rInfo.realloc(nOldLength + aRelevantSettings.size()); + PropertyValue* pAppendValues = _rInfo.getArray() + nOldLength; + ConstPropertyValueSetIterator aRelevantEnd = aRelevantSettings.end(); + for ( ConstPropertyValueSetIterator aLoop = aRelevantSettings.begin(); + aLoop != aRelevantEnd; + ++aLoop, ++pAppendValues + ) + { + if ( aLoop->Name == INFO_CHARSET ) + { + ::rtl::OUString sCharSet; + aLoop->Value >>= sCharSet; + if ( sCharSet.getLength() ) + *pAppendValues = *aLoop; + } + else + *pAppendValues = *aLoop; + } + } +} +//------------------------------------------------------------------------- +Any ODbDataSourceAdministrationHelper::implTranslateProperty(const SfxPoolItem* _pItem) +{ + // translate the SfxPoolItem + Any aValue; + + const SfxStringItem* pStringItem = PTR_CAST( SfxStringItem, _pItem ); + const SfxBoolItem* pBoolItem = PTR_CAST( SfxBoolItem, _pItem ); + const OptionalBoolItem* pOptBoolItem = PTR_CAST( OptionalBoolItem, _pItem ); + const SfxInt32Item* pInt32Item = PTR_CAST( SfxInt32Item, _pItem ); + const OStringListItem* pStringListItem = PTR_CAST( OStringListItem, _pItem ); + + if ( pStringItem ) + { + aValue <<= ::rtl::OUString( pStringItem->GetValue().GetBuffer() ); + } + else if ( pBoolItem ) + { + aValue <<= pBoolItem->GetValue(); + } + else if ( pOptBoolItem ) + { + if ( !pOptBoolItem->HasValue() ) + aValue.clear(); + else + aValue <<= (sal_Bool)pOptBoolItem->GetValue(); + } + else if ( pInt32Item ) + { + aValue <<= pInt32Item->GetValue(); + } + else if ( pStringListItem ) + { + aValue <<= pStringListItem->getList(); + } + else + { + DBG_ERROR("ODbDataSourceAdministrationHelper::implTranslateProperty: unsupported item type!"); + return aValue; + } + + return aValue; +} +//------------------------------------------------------------------------- +void ODbDataSourceAdministrationHelper::implTranslateProperty(const Reference< XPropertySet >& _rxSet, const ::rtl::OUString& _rName, const SfxPoolItem* _pItem) +{ + Any aValue = implTranslateProperty(_pItem); + lcl_putProperty(_rxSet, _rName,aValue); +} +#ifdef DBG_UTIL +//------------------------------------------------------------------------- +::rtl::OString ODbDataSourceAdministrationHelper::translatePropertyId( sal_Int32 _nId ) +{ + ::rtl::OUString aString; + + MapInt2String::const_iterator aPos = m_aDirectPropTranslator.find( _nId ); + if ( m_aDirectPropTranslator.end() != aPos ) + { + aString = aPos->second; + } + else + { + MapInt2String::const_iterator indirectPos = m_aIndirectPropTranslator.find( _nId ); + if ( m_aIndirectPropTranslator.end() != indirectPos ) + aString = indirectPos->second; + } + + ::rtl::OString aReturn( aString.getStr(), aString.getLength(), RTL_TEXTENCODING_ASCII_US ); + return aReturn; +} +#endif + +//------------------------------------------------------------------------- +void ODbDataSourceAdministrationHelper::implTranslateProperty( SfxItemSet& _rSet, sal_Int32 _nId, const Any& _rValue ) +{ + switch ( _rValue.getValueType().getTypeClass() ) + { + case TypeClass_STRING: + if ( implCheckItemType( _rSet, _nId, SfxStringItem::StaticType() ) ) + { + ::rtl::OUString sValue; + _rValue >>= sValue; + _rSet.Put(SfxStringItem(_nId, sValue.getStr())); + } + else { + DBG_ERROR( + ( ::rtl::OString( "ODbDataSourceAdministrationHelper::implTranslateProperty: invalid property value (" ) + += ::rtl::OString( translatePropertyId( _nId ) ) + += ::rtl::OString( " should be no string)!" ) + ).getStr() + ); + } + break; + + case TypeClass_BOOLEAN: + if ( implCheckItemType( _rSet, _nId, SfxBoolItem::StaticType() ) ) + { + sal_Bool bVal = sal_False; + _rValue >>= bVal; + _rSet.Put(SfxBoolItem(_nId, bVal)); + } + else if ( implCheckItemType( _rSet, _nId, OptionalBoolItem::StaticType() ) ) + { + OptionalBoolItem aItem( _nId ); + if ( _rValue.hasValue() ) + { + sal_Bool bValue = sal_False; + _rValue >>= bValue; + aItem.SetValue( bValue ); + } + else + aItem.ClearValue(); + _rSet.Put( aItem ); + } + else { + DBG_ERROR( + ( ::rtl::OString( "ODbDataSourceAdministrationHelper::implTranslateProperty: invalid property value (" ) + += ::rtl::OString( translatePropertyId( _nId ) ) + += ::rtl::OString( " should be no boolean)!" ) + ).getStr() + ); + } + break; + + case TypeClass_LONG: + if ( implCheckItemType( _rSet, _nId, SfxInt32Item::StaticType() ) ) + { + sal_Int32 nValue = 0; + _rValue >>= nValue; + _rSet.Put( SfxInt32Item( _nId, nValue ) ); + } + else { + DBG_ERROR( + ( ::rtl::OString( "ODbDataSourceAdministrationHelper::implTranslateProperty: invalid property value (" ) + += ::rtl::OString( translatePropertyId( _nId ) ) + += ::rtl::OString( " should be no int)!" ) + ).getStr() + ); + } + break; + + case TypeClass_SEQUENCE: + if ( implCheckItemType( _rSet, _nId, OStringListItem::StaticType() ) ) + { + // determine the element type + TypeDescription aTD(_rValue.getValueType()); + typelib_IndirectTypeDescription* pSequenceTD = + reinterpret_cast< typelib_IndirectTypeDescription* >(aTD.get()); + DBG_ASSERT(pSequenceTD && pSequenceTD->pType, "ODbDataSourceAdministrationHelper::implTranslateProperty: invalid sequence type!"); + + Type aElementType(pSequenceTD->pType); + switch (aElementType.getTypeClass()) + { + case TypeClass_STRING: + { + Sequence< ::rtl::OUString > aStringList; + _rValue >>= aStringList; + _rSet.Put(OStringListItem(_nId, aStringList)); + } + break; + default: + DBG_ERROR("ODbDataSourceAdministrationHelper::implTranslateProperty: unsupported property value type!"); + } + } + else { + DBG_ERROR( + ( ::rtl::OString( "ODbDataSourceAdministrationHelper::implTranslateProperty: invalid property value (" ) + += ::rtl::OString( translatePropertyId( _nId ) ) + += ::rtl::OString( " should be no string sequence)!" ) + ).getStr() + ); + } + break; + + case TypeClass_VOID: + _rSet.ClearItem(_nId); + break; + + default: + DBG_ERROR("ODbDataSourceAdministrationHelper::implTranslateProperty: unsupported property value type!"); + } +} + + +String ODbDataSourceAdministrationHelper::getDocumentUrl(SfxItemSet& _rDest) +{ + SFX_ITEMSET_GET(_rDest, pUrlItem, SfxStringItem, DSID_DOCUMENT_URL, sal_True); + OSL_ENSURE(pUrlItem,"Document URL is NULL. -> GPF!"); + return pUrlItem->GetValue(); +} + + +// ----------------------------------------------------------------------------- +void ODbDataSourceAdministrationHelper::convertUrl(SfxItemSet& _rDest) +{ + ::rtl::OUString eType = getDatasourceType(_rDest); + + SFX_ITEMSET_GET(_rDest, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True); + SFX_ITEMSET_GET(_rDest, pTypeCollection, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True); + + OSL_ENSURE(pUrlItem,"Connection URL is NULL. -> GPF!"); + DBG_ASSERT(pTypeCollection, "ODbAdminDialog::getDatasourceType: invalid items in the source set!"); + ::dbaccess::ODsnTypeCollection* pCollection = pTypeCollection->getCollection(); + DBG_ASSERT(pCollection, "ODbAdminDialog::getDatasourceType: invalid type collection!"); + + USHORT nPortNumberId = 0; + sal_Int32 nPortNumber = -1; + String sNewHostName; + //String sUrl = pCollection->cutPrefix(pUrlItem->GetValue()); + String sUrlPart; + + pCollection->extractHostNamePort(pUrlItem->GetValue(),sUrlPart,sNewHostName,nPortNumber); + const ::dbaccess::DATASOURCE_TYPE eTy = pCollection->determineType(eType); + + switch( eTy ) + { + case ::dbaccess::DST_MYSQL_NATIVE: + case ::dbaccess::DST_MYSQL_JDBC: + nPortNumberId = DSID_MYSQL_PORTNUMBER; + break; + case ::dbaccess::DST_ORACLE_JDBC: + nPortNumberId = DSID_ORACLE_PORTNUMBER; + break; + case ::dbaccess::DST_LDAP: + nPortNumberId = DSID_CONN_LDAP_PORTNUMBER; + break; + default: + break; + } + + if ( sUrlPart.Len() ) + { + if ( eTy == ::dbaccess::DST_MYSQL_NATIVE ) + { + _rDest.Put( SfxStringItem( DSID_DATABASENAME, sUrlPart ) ); + } + else + { + String sNewUrl = pCollection->getPrefix(eType); + sNewUrl += sUrlPart; + _rDest.Put( SfxStringItem( DSID_CONNECTURL, sNewUrl ) ); + } + } + + if ( sNewHostName.Len() ) + _rDest.Put(SfxStringItem(DSID_CONN_HOSTNAME, sNewHostName)); + + if ( nPortNumber != -1 && nPortNumberId != 0 ) + _rDest.Put(SfxInt32Item(nPortNumberId, nPortNumber)); + +} +// ----------------------------------------------------------------------------- +sal_Bool ODbDataSourceAdministrationHelper::saveChanges(const SfxItemSet& _rSource) +{ + // put the remembered settings into the property set + Reference<XPropertySet> xDatasource = getCurrentDataSource(); + if ( !xDatasource.is() ) + return sal_False; + + translateProperties(_rSource,xDatasource ); + + return sal_True; +} +// ----------------------------------------------------------------------------- +void ODbDataSourceAdministrationHelper::setDataSourceOrName( const Any& _rDataSourceOrName ) +{ + DBG_ASSERT( !m_aDataSourceOrName.hasValue(), "ODbDataSourceAdministrationHelper::setDataSourceOrName: already have one!" ); + // hmm. We could reset m_xDatasource/m_xModel, probably, and continue working + m_aDataSourceOrName = _rDataSourceOrName; +} +//========================================================================= +//= DbuTypeCollectionItem +//========================================================================= +TYPEINIT1(DbuTypeCollectionItem, SfxPoolItem); +//------------------------------------------------------------------------- +DbuTypeCollectionItem::DbuTypeCollectionItem(sal_Int16 _nWhich, ::dbaccess::ODsnTypeCollection* _pCollection) + :SfxPoolItem(_nWhich) + ,m_pCollection(_pCollection) +{ +} + +//------------------------------------------------------------------------- +DbuTypeCollectionItem::DbuTypeCollectionItem(const DbuTypeCollectionItem& _rSource) + :SfxPoolItem(_rSource) + ,m_pCollection(_rSource.getCollection()) +{ +} + +//------------------------------------------------------------------------- +int DbuTypeCollectionItem::operator==(const SfxPoolItem& _rItem) const +{ + DbuTypeCollectionItem* pCompare = PTR_CAST(DbuTypeCollectionItem, &_rItem); + return pCompare && (pCompare->getCollection() == getCollection()); +} + +//------------------------------------------------------------------------- +SfxPoolItem* DbuTypeCollectionItem::Clone(SfxItemPool* /*_pPool*/) const +{ + return new DbuTypeCollectionItem(*this); +} + +//......................................................................... +} // namespace dbaui +//......................................................................... + + + diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.hxx b/dbaccess/source/ui/dlg/DbAdminImpl.hxx new file mode 100644 index 000000000000..4ed86867618e --- /dev/null +++ b/dbaccess/source/ui/dlg/DbAdminImpl.hxx @@ -0,0 +1,216 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBAUI_DBADMINIMPL_HXX_ +#define _DBAUI_DBADMINIMPL_HXX_ + +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_UNO_XNAMINGSERVICE_HPP_ +#include <com/sun/star/uno/XNamingService.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ +#include <com/sun/star/beans/PropertyValue.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ +#include <com/sun/star/sdbc/XConnection.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XDRIVER_HPP_ +#include <com/sun/star/sdbc/XDriver.hpp> +#endif +#ifndef _COMPHELPER_STLTYPES_HXX_ +#include <comphelper/stl_types.hxx> +#endif +#ifndef _DBAUI_DSNTYPES_HXX_ +#include "dsntypes.hxx" +#endif +#ifndef _SFXITEMSET_HXX +#include <svl/itemset.hxx> +#endif +#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_ +#include <com/sun/star/frame/XModel.hpp> +#endif +#include <svl/poolitem.hxx> + +class Window; +//......................................................................... +namespace dbaui +{ +//......................................................................... + class DataSourceInfoConverter + { + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory; + public: + DataSourceInfoConverter(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory) + :m_xFactory(_xFactory) + { + } + void convert(const ::dbaccess::ODsnTypeCollection* _pCollection,const ::rtl::OUString& _sOldURLPrefix,const ::rtl::OUString& _sNewURLPrefix,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDatasource); + }; + class IItemSetHelper; + //======================================================================== + //= ODbDataSourceAdministrationHelper + //======================================================================== + class ODbDataSourceAdministrationHelper + { + public: + DECLARE_STL_MAP(sal_Int32, ::rtl::OUString, ::std::less< sal_Int32 >, MapInt2String); + + private: + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > + m_xORB; /// service factory + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > + m_xDatabaseContext; /// database context we're working in + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XNamingService > + m_xDynamicContext; /// just another interface of the context ... + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xDatasource; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModel; + + ::com::sun::star::uno::Any m_aDataSourceOrName; + typedef ::std::set< ::rtl::OUString > StringSet; + typedef StringSet::const_iterator ConstStringSetIterator; + + + MapInt2String m_aDirectPropTranslator; /// translating property id's into names (direct properties of a data source) + MapInt2String m_aIndirectPropTranslator; /// translating property id's into names (indirect properties of a data source) + Window* m_pParent; + IItemSetHelper* m_pItemSetHelper; + public: + + ODbDataSourceAdministrationHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB + ,Window* _pParent + ,IItemSetHelper* _pItemSetHelper); + + /** translate the current dialog SfxItems into driver relevant PropertyValues + @see successfullyConnected + */ + sal_Bool getCurrentSettings(::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rDriverParams); + + /** to be called if the settings got from getCurrentSettings have been used for successfully connecting + @see getCurrentSettings + */ + void successfullyConnected(); + + /// clear the password in the current data source's item set + void clearPassword(); + + inline ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const { return m_xORB; } + + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > getDatabaseContext() const { return m_xDatabaseContext; } + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XNamingService > getDynamicContext() const { return m_xDynamicContext; } + + /** creates a new connection. The caller is responsible to dispose it !!!! + */ + ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >,sal_Bool> createConnection(); + + /** return the corresponding driver for the selected URL + */ + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > getDriver(); + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > getDriver(const ::rtl::OUString& _sURL); + + /** returns the data source the dialog is currently working with + */ + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getCurrentDataSource(); + // returns the Url of a database document + String getDocumentUrl(SfxItemSet& _rDest); + + void setDataSourceOrName( const ::com::sun::star::uno::Any& _rDataSourceOrName ); + + /** extracts the connection type from the given set<p/> + The connection type is determined by the value of the DSN item, analyzed by the TypeCollection item. + */ + static ::rtl::OUString getDatasourceType( const SfxItemSet& _rSet ); + + /** returns the connection URL + @return + The connection URL + */ + String getConnectionURL() const; + + /// fill the nescessary information from the url line + void convertUrl(SfxItemSet& _rDest); + + const MapInt2String& getIndirectProperties() const { return m_aIndirectPropTranslator; } + + /** translates properties of an UNO data source into SfxItems + @param _rxSource + The data source + @param _rDest + The item set to fill. + */ + void translateProperties( + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSource, + SfxItemSet& _rDest); + + /** translate SfxItems into properties of an UNO data source + @param _rSource + The item set to read from. + @param _rxDest + The data source to fill. + */ + void translateProperties( + const SfxItemSet& _rSource, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDest); + + sal_Bool saveChanges(const SfxItemSet& _rSource); + protected: + /** fill a data source info array with the settings from a given item set + */ + void fillDatasourceInfo(const SfxItemSet& _rSource, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo); + + /// translate the given value into an SfxPoolItem, put this into the given set under the given id + void implTranslateProperty(SfxItemSet& _rSet, sal_Int32 _nId, const ::com::sun::star::uno::Any& _rValue); + + /// translate the given SfxPoolItem into an <type scope="com.sun.star.Any">uno</type> + ::com::sun::star::uno::Any implTranslateProperty(const SfxPoolItem* _pItem); + + /// translate the given SfxPoolItem into an <type scope="com.sun.star.Any">uno</type>, set it (under the given name) on the given property set + void implTranslateProperty(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSet, const ::rtl::OUString& _rName, const SfxPoolItem* _pItem); + + /** check if the data source described by the given set needs authentication<p/> + The return value depends on the data source type only. + */ + sal_Bool hasAuthentication(const SfxItemSet& _rSet) const; + +#ifdef DBG_UTIL + ::rtl::OString translatePropertyId( sal_Int32 _nId ); +#endif + }; + +//......................................................................... +} // namespace dbaui +//......................................................................... + +#endif // _DBAUI_DBADMINIMPL_HXX_ + diff --git a/dbaccess/source/ui/dlg/DriverSettings.cxx b/dbaccess/source/ui/dlg/DriverSettings.cxx new file mode 100644 index 000000000000..cecdc49aff8e --- /dev/null +++ b/dbaccess/source/ui/dlg/DriverSettings.cxx @@ -0,0 +1,116 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#include "DriverSettings.hxx" +#include "dsmeta.hxx" + +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/beans/NamedValue.hpp> + +#include <connectivity/DriversConfig.hxx> + +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::beans::NamedValue; + +using namespace dbaui; +void ODriversSettings::getSupportedIndirectSettings( const ::rtl::OUString& _sURLPrefix,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory, ::std::vector< sal_Int32>& _out_rDetailsIds ) +{ + // for a number of settings, we do not need to use hard-coded here, but can ask a + // central DataSourceUI instance. + DataSourceMetaData aMeta( _sURLPrefix ); + const FeatureSet& rFeatures( aMeta.getFeatureSet() ); + for ( FeatureSet::const_iterator feature = rFeatures.begin(); + feature != rFeatures.end(); + ++feature + ) + { + _out_rDetailsIds.push_back( *feature ); + } + + // the rest is configuration-based + // TODO: that's not really true: *everything* is configuration-based nowadays, even the FeatureSet obtained + // from the DataSourceMetaData has been initialized from the configuration. So in fact, we could consolidate + // the two blocks. + // The best approach would be to extend the FeatureSet to contain *all* known data source features, not only + // the ones from the "Advanced settings" UI. + + ::connectivity::DriversConfig aDriverConfig(_xFactory); + const ::comphelper::NamedValueCollection& aProperties = aDriverConfig.getProperties(_sURLPrefix); +#if OSL_DEBUG_LEVEL > 0 + { + Sequence< NamedValue > aNamedValues; + aProperties >>= aNamedValues; + for ( const NamedValue* loop = aNamedValues.getConstArray(); + loop != aNamedValues.getConstArray() + aNamedValues.getLength(); + ++loop + ) + { + int dummy = 0; + (void)dummy; + } + } +#endif + typedef ::std::pair<USHORT, ::rtl::OUString> TProperties; + TProperties aProps[] = { TProperties(DSID_SHOWDELETEDROWS,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowDeleted"))) + ,TProperties(DSID_CHARSET,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharSet"))) + ,TProperties(DSID_FIELDDELIMITER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FieldDelimiter"))) + ,TProperties(DSID_TEXTDELIMITER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StringDelimiter"))) + ,TProperties(DSID_DECIMALDELIMITER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DecimalDelimiter"))) + ,TProperties(DSID_THOUSANDSDELIMITER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ThousandDelimiter"))) + ,TProperties(DSID_TEXTFILEEXTENSION,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Extension"))) + ,TProperties(DSID_TEXTFILEHEADER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HeaderLine"))) + ,TProperties(DSID_ADDITIONALOPTIONS,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SystemDriverSettings"))) + ,TProperties(DSID_CONN_SHUTSERVICE,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShutdownDatabase"))) + ,TProperties(DSID_CONN_DATAINC,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataCacheSizeIncrement"))) + ,TProperties(DSID_CONN_CACHESIZE,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataCacheSize"))) + ,TProperties(DSID_CONN_CTRLUSER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlUser"))) + ,TProperties(DSID_CONN_CTRLPWD,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlPassword"))) + ,TProperties(DSID_USECATALOG,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseCatalog"))) + ,TProperties(DSID_CONN_SOCKET,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LocalSocket"))) + ,TProperties(DSID_NAMED_PIPE,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NamedPipe"))) + ,TProperties(DSID_JDBCDRIVERCLASS,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JavaDriverClass"))) + ,TProperties(DSID_CONN_LDAP_BASEDN,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BaseDN"))) + ,TProperties(DSID_CONN_LDAP_ROWCOUNT,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MaxRowCount"))) + ,TProperties(DSID_CONN_LDAP_USESSL,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseSSL"))) + ,TProperties(DSID_IGNORECURRENCY,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IgnoreCurrency"))) + ,TProperties(0,::rtl::OUString()) + }; + // TODO: This mapping between IDs and property names already exists - in ODbDataSourceAdministrationHelper::ODbDataSourceAdministrationHelper. + // Another mapping (which is also duplicated in ODbDataSourceAdministrationHelper) exists in dsmeta.cxx. We should + // consolidate those three places into one. + // However, care has to be taken: We need to distinguish between "features" and "properties" of a data source (resp. driver). + // That is, a driver can support a certain property, but not allow to change it in the UI, which means it would + // not have the respective "feature". + for ( TProperties* pProps = aProps; pProps->first; ++pProps ) + { + if ( aProperties.has(pProps->second) ) + _out_rDetailsIds.push_back(pProps->first); + } +} diff --git a/dbaccess/source/ui/dlg/DriverSettings.hxx b/dbaccess/source/ui/dlg/DriverSettings.hxx new file mode 100644 index 000000000000..c09977f276a7 --- /dev/null +++ b/dbaccess/source/ui/dlg/DriverSettings.hxx @@ -0,0 +1,112 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef DBAUI_DRIVERSETTINGS_HXX +#define DBAUI_DRIVERSETTINGS_HXX + +#ifndef _DBAUI_DSNTYPES_HXX_ +#include "dsntypes.hxx" +#endif +#include <svl/poolitem.hxx> +#include <vector> + +class SfxTabPage; +class Window; +namespace dbaui +{ + /// a collection class for all details a driver needs + class ODriversSettings + { + public: + + /** filles the IDs of the settings which are reflected in indirect data source properties + (aka properties in the css.sdb.DataSource.Info sequence) + + @param _eType + The Type of the data source. + @param _out_rDetailsIds + Will be filled. + */ + static void getSupportedIndirectSettings( const ::rtl::OUString& _sURLPrefix,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory,::std::vector< sal_Int32>& _out_rDetailsIds ); + + /** Creates the detail page for Dbase + */ + static SfxTabPage* CreateDbase2( Window* _pParent, const SfxItemSet& _rAttrSet ); + + /** Creates the detail page for ado + */ + static SfxTabPage* CreateDbase( Window* _pParent, const SfxItemSet& _rAttrSet ); + + /** Creates the detail page for ado + */ + static SfxTabPage* CreateAdo( Window* _pParent, const SfxItemSet& _rAttrSet ); + + /** Creates the detail page for ODBC + */ + static SfxTabPage* CreateODBC( Window* _pParent, const SfxItemSet& _rAttrSet ); + + /** Creates the detail page for user + */ + static SfxTabPage* CreateUser( Window* _pParent, const SfxItemSet& _rAttrSet ); + + /** Creates the detail page for MySQLODBC + */ + static SfxTabPage* CreateMySQLODBC( Window* _pParent, const SfxItemSet& _rAttrSet ); + + /** Creates the detail page for MySQLJDBC + */ + static SfxTabPage* CreateMySQLJDBC( Window* _pParent, const SfxItemSet& _rAttrSet ); + + /** Creates the detail page for MySQLNATIVE + */ + static SfxTabPage* CreateMySQLNATIVE( Window* _pParent, const SfxItemSet& _rAttrSet ); + + /** Creates the detail page for Oracle JDBC + */ + static SfxTabPage* CreateOracleJDBC( Window* pParent, const SfxItemSet& _rAttrSet ); + + /** Creates the detail page for Adabas + */ + static SfxTabPage* CreateAdabas( Window* _pParent, const SfxItemSet& _rAttrSet ); + + /** Creates the detail page for LDAP + */ + static SfxTabPage* CreateLDAP( Window* _pParent, const SfxItemSet& _rAttrSet ); + + /// Creates the detail page for Text + static SfxTabPage* CreateText( Window* _pParent, const SfxItemSet& _rAttrSet ); + + + /// creates the GeneratedValues page + static SfxTabPage* CreateGeneratedValuesPage( Window* _pParent, const SfxItemSet& _rAttrSet ); + + /// creates the "Special Settings" page of the "Advanced Settings" dialog + static SfxTabPage* CreateSpecialSettingsPage( Window* _pParent, const SfxItemSet& _rAttrSet ); + }; +} + +#endif // DBAUI_DRIVERSETTINGS_HXX + diff --git a/dbaccess/source/ui/dlg/ExtensionNotPresent.cxx b/dbaccess/source/ui/dlg/ExtensionNotPresent.cxx new file mode 100644 index 000000000000..49d4182d9ef8 --- /dev/null +++ b/dbaccess/source/ui/dlg/ExtensionNotPresent.cxx @@ -0,0 +1,218 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "precompiled_dbaccess.hxx" + +#include "dbaccess_helpid.hrc" +#include "dbu_resource.hrc" +#include "ExtensionNotPresent.hrc" +#include "ExtensionNotPresent.hxx" +#include "moduledbu.hxx" +#include "UITools.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/lang/XMultiComponentFactory.hpp> +#include <com/sun/star/system/SystemShellExecuteFlags.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +/** === end UNO includes === **/ + +#include <connectivity/dbconversion.hxx> +#include <unotools/syslocale.hxx> +#include <svx/globlmn.hrc> +#include <svx/svxids.hrc> +#include <tools/debug.hxx> +#include <tools/diagnose_ex.h> +#include <unotools/confignode.hxx> +#include <vcl/msgbox.hxx> + + +namespace dbaui +{ +using namespace ::com::sun::star; +using namespace ::comphelper; + +#define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) + +DBG_NAME( dbu_OExtensionNotPresentDialog ) +//======================================================================== +// class OExtensionNotPresentDialog +//======================================================================== + OExtensionNotPresentDialog::OExtensionNotPresentDialog( Window* _pParent, uno::Reference< lang::XMultiServiceFactory > _xORB) + : ModalDialog( _pParent, ModuleRes(RID_EXTENSION_NOT_PRESENT_DLG) ) + ,m_aFI_WARNING(this, ModuleRes(FI_WARNING)) + ,m_aFT_TEXT(this, ModuleRes(FT_TEXT ) ) + ,m_aPB_DOWNLOAD(this, ModuleRes(PB_DOWNLOAD)) + ,m_aPB_CANCEL(this, ModuleRes(PB_CANCEL)) + ,m_xMultiServiceFactory(_xORB) +{ + DBG_CTOR( dbu_OExtensionNotPresentDialog, NULL); + + try + { + SvtSysLocale aSysLocale; + m_nLocale = aSysLocale.GetLocaleData().getLocale(); + } + catch(uno::Exception&) + { + } + + // set a ClickHandler for the 'Download' button + m_aPB_DOWNLOAD.SetClickHdl( LINK( this, OExtensionNotPresentDialog, Download_Click ) ); + + // get message string out of the resource + String sText = String( ModuleRes( RID_STR_EXTENSION_NOT_PRESENT ) ); + // String sExtensionName = String( ModuleRes( RID_STR_EXTENSION_NAME ) ); + String sExtensionName = getFromConfigurationExtension("Name"); + sText.SearchAndReplaceAscii("%RPT_EXTENSION_NAME", sExtensionName); + + m_aFT_TEXT.SetText(sText); + + // calulate the size of the text field + Rectangle aPrimaryRect( Point(0,0), m_aFT_TEXT.GetSizePixel() ); + Rectangle aSuggestedRect( GetTextRect( aPrimaryRect, sText, TEXT_DRAW_MULTILINE | TEXT_DRAW_LEFT ) ); + + Size aTempSize = LogicToPixel( Size(LEFT_PADDING + RIGHT_PADDING, 1), MAP_APPFONT); // real pixel size of LEFT and RIGHT_PADDING + sal_Int32 nWidthWithoutFixedText = aTempSize.getWidth() ; + sal_Int32 nHeightWithoutFixedText = GetSizePixel().getHeight() - m_aFT_TEXT.GetSizePixel().getHeight(); + + Size aNewSize = aSuggestedRect.GetSize(); + m_aFT_TEXT.SetSizePixel( aNewSize ); + sal_Int32 nNewWidth = nWidthWithoutFixedText + aSuggestedRect.GetWidth(); + sal_Int32 nNewHeight = nHeightWithoutFixedText + aSuggestedRect.GetHeight(); + + // set new window width & height + Size aDialogWindowSize = GetSizePixel(); + aDialogWindowSize.setWidth( nNewWidth ); + aDialogWindowSize.setHeight( nNewHeight ); + SetSizePixel(aDialogWindowSize); + + // move Action items + sal_Int32 nWindowWidth = GetSizePixel().getWidth(); + sal_Int32 nWindowHeight = GetSizePixel().getHeight(); + + Size aButtonSize = LogicToPixel( Size(BUTTON_WIDTH, BUTTON_HEIGHT), MAP_APPFONT); // real pixel size of a button + + Point aNewPos = m_aPB_DOWNLOAD.GetPosPixel(); + aNewPos.setX(nWindowWidth / 2 - m_aPB_DOWNLOAD.GetSizePixel().getWidth() - 8); + aNewPos.setY(nWindowHeight - aButtonSize.getHeight() - 5); + m_aPB_DOWNLOAD.SetPosPixel(aNewPos ); + + aNewPos = m_aPB_CANCEL.GetPosPixel(); + aNewPos.setX(nWindowWidth / 2 + 8); + aNewPos.setY(nWindowHeight - aButtonSize.getHeight() - 5); + m_aPB_CANCEL.SetPosPixel(aNewPos ); + + m_aFI_WARNING.SetImage(WarningBox::GetStandardImage()); + + // set an image in high contrast + // m_aFI_WARNING.SetModeImage(Image(BMP_EXCEPTION_WARNING_SCH), BMP_COLOR_HIGHCONTRAST); + + // to resize images + // WinBits aBits = m_aFI_WARNING.GetStyle(); + // aBits |= WB_SCALE; + // m_aFI_WARNING.SetStyle(aBits); + // + // Size aImageSize = m_aFI_WARNING.GetSizePixel(); + // (void) aImageSize; + // m_aFI_WARNING.Resize(); + + + Resize(); + FreeResource(); +} + +//------------------------------------------------------------------------ +OExtensionNotPresentDialog::~OExtensionNotPresentDialog() +{ + DBG_DTOR( dbu_OExtensionNotPresentDialog, NULL); +} +// ----------------------------------------------------------------------------- +short OExtensionNotPresentDialog::Execute() +{ + DBG_CHKTHIS( dbu_OExtensionNotPresentDialog,NULL); + short nRet = ModalDialog::Execute(); + // RET_OK + // RET_NO + return nRet; +} + +//------------------------------------------------------------------------------ + +uno::Reference< com::sun::star::system::XSystemShellExecute > OExtensionNotPresentDialog::getShellExecuter() const +{ + uno::Reference<com::sun::star::system::XSystemShellExecute> xExecuter( m_xMultiServiceFactory->createInstance( UNISTRING( "com.sun.star.system.SystemShellExecute" )), uno::UNO_QUERY_THROW); + return xExecuter; +} +// ----------------------------------------------------------------------------- +rtl::OUString OExtensionNotPresentDialog::getFromConfigurationExtension(rtl::OUString const& _sPropertyName) const +{ + // get the URL to open in a browser from Configuration + static const ::rtl::OUString sConfigName( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.ReportDesign/Extension" ) ); + + ::utl::OConfigurationTreeRoot aConfiguration( ::utl::OConfigurationTreeRoot::createWithServiceFactory( m_xMultiServiceFactory, sConfigName ) ); + + rtl::OUString aValue; + aConfiguration.getNodeValue( _sPropertyName ) >>= aValue; + return aValue; +} + +// ----------------------------------------------------------------------------- +rtl::OUString OExtensionNotPresentDialog::getFromConfigurationExtension(rtl::OString const& _sPropertyName) const +{ + return getFromConfigurationExtension(rtl::OStringToOUString( _sPropertyName, RTL_TEXTENCODING_UTF8) ); +} + +// ----------------------------------------------------------------------------- +// handle the click on the download button +IMPL_LINK( OExtensionNotPresentDialog, Download_Click, PushButton*, EMPTYARG ) +{ + try + { + EndDialog( TRUE ); + + rtl::OUString suDownloadURL = getFromConfigurationExtension("DownloadURL"); + if (suDownloadURL.getLength() == 0) + { + // fallback + suDownloadURL = UNISTRING("http://extensions.services.openoffice.org"); + } + + // open such URL in a browser + uno::Reference< com::sun::star::system::XSystemShellExecute > xShellExecute( getShellExecuter() ); + xShellExecute->execute( suDownloadURL, ::rtl::OUString(), com::sun::star::system::SystemShellExecuteFlags::DEFAULTS ); + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return 0; +} + +// ============================================================================= +} // rptui +// ============================================================================= + diff --git a/dbaccess/source/ui/dlg/ExtensionNotPresent.hrc b/dbaccess/source/ui/dlg/ExtensionNotPresent.hrc new file mode 100644 index 000000000000..69794e3a76bc --- /dev/null +++ b/dbaccess/source/ui/dlg/ExtensionNotPresent.hrc @@ -0,0 +1,48 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef DBU_EXTENSIONNOTPRESENT_HRC +#define DBU_EXTENSIONNOTPRESENT_HRC + +#define FT_TEXT (1) +#define FI_WARNING (2) +#define PB_DOWNLOAD (10) +#define PB_CANCEL (11) + +#define FIXEDTEXT_HEIGHT 8 +#define CELL_PADDING 8 +#define BUTTON_HEIGHT 14 +#define BUTTON_WIDTH 55 +#define BROWSER_HEIGHT 75 +// #define PAGE_WIDTH ( CELL_PADDING + BUTTON_WIDTH + CELL_PADDING + BUTTON_WIDTH + CELL_PADDING) +#define LEFT_PADDING 32 /* size for the icon */ +#define RIGHT_PADDING 16 +#define DLG_WIDTH ( 250 ) +#define ACTION_LINE_START (CELL_PADDING + ( 3 * FIXEDTEXT_HEIGHT ) + 2 * CELL_PADDING + 1 ) +#define DLG_HEIGHT (ACTION_LINE_START + BUTTON_HEIGHT + CELL_PADDING) + + +#endif /* DBU_EXTENSIONNOTPRESENT_HRC */ diff --git a/dbaccess/source/ui/dlg/ExtensionNotPresent.src b/dbaccess/source/ui/dlg/ExtensionNotPresent.src new file mode 100644 index 000000000000..9507c4256360 --- /dev/null +++ b/dbaccess/source/ui/dlg/ExtensionNotPresent.src @@ -0,0 +1,89 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "ExtensionNotPresent.hrc" +#include "dbaccess_helpid.hrc" +#include "dbu_resource.hrc" +#include <svx/globlmn.hrc> +#include <svx/svxids.hrc> + + +String RID_STR_EXTENSION_NOT_PRESENT +{ + // #i96130# use hard coded name + Text [ en-US ] = "To open a report you require the extension Sunâ„¢ Report Builder.\n\nClick 'Download...' to download and install the extension."; + // OLD: Text [ en-US ] = "To open a report you require the extension %RPT_EXTENSION_NAME.\n\nClick 'Download...' to download and install the extension."; +}; +// To open a report you require the extension Sun Report Designer weiss der Geier Hauptsache extra langer Name +// String RID_STR_EXTENSION_NAME +// { +// Text = "Sun(TM) Report Builder"; +// }; + +ModalDialog RID_EXTENSION_NOT_PRESENT_DLG +{ + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( DLG_WIDTH , DLG_HEIGHT ) ; + Text [ en-US ] = "%PRODUCTNAME %PRODUCTVERSION" ; + HelpId = HID_EXTENSION_NOT_PRESENT_DLG; + Moveable = TRUE ; + Closeable = TRUE ; + + // most of the calulated values here are overridden by the ExtensionNotPresent ctor itself. + FixedImage FI_WARNING + { + Pos = MAP_APPFONT (CELL_PADDING / 2, CELL_PADDING) ; + Size = (32, 32); + Fixed=BMP_EXCEPTION_WARNING; + }; + + + FixedText FT_TEXT + { + Pos = MAP_APPFONT ( 32 , CELL_PADDING ) ; + Size = MAP_APPFONT ( DLG_WIDTH - LEFT_PADDING - RIGHT_PADDING , 3 * (FIXEDTEXT_HEIGHT + 2) ) ; + // Border = TRUE ; + // Text will set outside from RID_STR_EXTENSION_NOT_PRESENT + }; + + PushButton PB_DOWNLOAD + { + Pos = MAP_APPFONT ( DLG_WIDTH / 2 - (CELL_PADDING/2) - BUTTON_WIDTH, ACTION_LINE_START ) ; + Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ; + DefButton = TRUE ; + TabStop = TRUE ; + Text [ en-US ] = "~Download..." ; + }; + + CancelButton PB_CANCEL + { + Pos = MAP_APPFONT ( DLG_WIDTH / 2 + (CELL_PADDING/2), ACTION_LINE_START) ; + Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ; + TabStop = TRUE ; + }; +}; + diff --git a/dbaccess/source/ui/dlg/RelationDlg.cxx b/dbaccess/source/ui/dlg/RelationDlg.cxx new file mode 100644 index 000000000000..d24a1d87dee1 --- /dev/null +++ b/dbaccess/source/ui/dlg/RelationDlg.cxx @@ -0,0 +1,303 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" +//#ifndef _SVX_TABWIN_HXX +//#include "tabwin.hxx" +//#endif +#ifndef DBAUI_RELATIONDIALOG_HRC +#include "RelationDlg.hrc" +#endif +#ifndef DBAUI_RELATIONDIALOG_HXX +#include "RelationDlg.hxx" +#endif + +#ifndef _WRKWIN_HXX //autogen +#include <vcl/wrkwin.hxx> +#endif + +#ifndef _SV_SVAPP_HXX //autogen +#include <vcl/svapp.hxx> +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif +#ifndef _COM_SUN_STAR_SDBC_KEYRULE_HPP_ +#include <com/sun/star/sdbc/KeyRule.hpp> +#endif + +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif +#ifndef TOOLS_DIAGNOSE_EX_H +#include <tools/diagnose_ex.h> +#endif +#ifndef DBAUI_TOOLS_HXX +#include "UITools.hxx" +#endif +#ifndef DBAUI_JOINDESIGNVIEW_HXX +#include "JoinDesignView.hxx" +#endif +#ifndef DBAUI_JOINCONTROLLER_HXX +#include "JoinController.hxx" +#endif +#ifndef _DBHELPER_DBEXCEPTION_HXX_ +#include <connectivity/dbexception.hxx> +#endif +#ifndef DBAUI_RTABLECONNECTIONDATA_HXX +#include "RTableConnectionData.hxx" +#endif +#ifndef DBAUI_RELATIONCONTROL_HXX +#include "RelationControl.hxx" +#endif +#ifndef _CPPUHELPER_EXC_HLP_HXX_ +#include <cppuhelper/exc_hlp.hxx> +#endif + +#include <algorithm> + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::beans; +using namespace ::dbaui; +using namespace ::dbtools; + +//======================================================================== +// class ORelationDialog +DBG_NAME(ORelationDialog) +//======================================================================== +ORelationDialog::ORelationDialog( OJoinTableView* pParent, + const TTableConnectionData::value_type& pConnectionData, + BOOL bAllowTableSelect ) + :ModalDialog( pParent, ModuleRes(DLG_REL_PROPERTIES) ) + ,m_pTableMap(pParent->GetTabWinMap()) + + ,aFL_CascUpd( this, ModuleRes(FL_CASC_UPD) ) + ,aRB_NoCascUpd( this, ModuleRes(RB_NO_CASC_UPD) ) + ,aRB_CascUpd( this, ModuleRes(RB_CASC_UPD) ) + ,aRB_CascUpdNull( this, ModuleRes(RB_CASC_UPD_NULL) ) + ,aRB_CascUpdDefault( this, ModuleRes(RB_CASC_UPD_DEFAULT) ) + ,aFL_CascDel( this, ModuleRes(FL_CASC_DEL) ) + ,aRB_NoCascDel( this, ModuleRes(RB_NO_CASC_DEL) ) + ,aRB_CascDel( this, ModuleRes(RB_CASC_DEL) ) + ,aRB_CascDelNull( this, ModuleRes(RB_CASC_DEL_NULL) ) + ,aRB_CascDelDefault( this, ModuleRes(RB_CASC_DEL_DEFAULT) ) + + ,aPB_OK( this, ModuleRes( PB_OK ) ) + ,aPB_CANCEL( this, ModuleRes( PB_CANCEL ) ) + ,aPB_HELP( this, ModuleRes( PB_HELP ) ) + + ,m_pOrigConnData( pConnectionData ) + ,m_bTriedOneUpdate(FALSE) +{ + DBG_CTOR(ORelationDialog,NULL); + + m_xConnection = pParent->getDesignView()->getController().getConnection(); + + ////////////////////////////////////////////////////////////////////// + // Connection kopieren + m_pConnData.reset( static_cast<ORelationTableConnectionData*>(pConnectionData->NewInstance()) ); + m_pConnData->CopyFrom( *pConnectionData ); + + Init(m_pConnData); + m_pTableControl.reset( new OTableListBoxControl(this,ModuleRes(WND_CONTROL),m_pTableMap,this) ); + + aPB_OK.SetClickHdl( LINK(this, ORelationDialog, OKClickHdl) ); + + m_pTableControl->Init( m_pConnData ); + if ( bAllowTableSelect ) + m_pTableControl->fillListBoxes(); + else + m_pTableControl->fillAndDisable(pConnectionData); + + m_pTableControl->lateInit(); + + m_pTableControl->NotifyCellChange(); + + FreeResource(); +} + +//------------------------------------------------------------------------ +void ORelationDialog::Init(const TTableConnectionData::value_type& _pConnectionData) +{ + ORelationTableConnectionData* pConnData = static_cast<ORelationTableConnectionData*>(_pConnectionData.get()); + // Update Rules + switch (pConnData->GetUpdateRules()) + { + case KeyRule::NO_ACTION: + case KeyRule::RESTRICT: + aRB_NoCascUpd.Check( TRUE ); + break; + + case KeyRule::CASCADE: + aRB_CascUpd.Check( TRUE ); + break; + + case KeyRule::SET_NULL: + aRB_CascUpdNull.Check( TRUE ); + break; + case KeyRule::SET_DEFAULT: + aRB_CascUpdDefault.Check( TRUE ); + break; + } + + // Delete Rules + switch (pConnData->GetDeleteRules()) + { + case KeyRule::NO_ACTION: + case KeyRule::RESTRICT: + aRB_NoCascDel.Check( TRUE ); + break; + + case KeyRule::CASCADE: + aRB_CascDel.Check( TRUE ); + break; + + case KeyRule::SET_NULL: + aRB_CascDelNull.Check( TRUE ); + break; + case KeyRule::SET_DEFAULT: + aRB_CascDelDefault.Check( TRUE ); + break; + } +} + +//------------------------------------------------------------------------ +ORelationDialog::~ORelationDialog() +{ + DBG_DTOR(ORelationDialog,NULL); +} + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ +IMPL_LINK( ORelationDialog, OKClickHdl, Button*, /*pButton*/ ) +{ + ////////////////////////////////////////////////////////////////////// + // RadioButtons auslesen + UINT16 nAttrib = 0; + + // Delete Rules + if( aRB_NoCascDel.IsChecked() ) + nAttrib |= KeyRule::NO_ACTION; + if( aRB_CascDel.IsChecked() ) + nAttrib |= KeyRule::CASCADE; + if( aRB_CascDelNull.IsChecked() ) + nAttrib |= KeyRule::SET_NULL; + if( aRB_CascDelDefault.IsChecked() ) + nAttrib |= KeyRule::SET_DEFAULT; + + ORelationTableConnectionData* pConnData = static_cast<ORelationTableConnectionData*>(m_pConnData.get()); + pConnData->SetDeleteRules( nAttrib ); + + // Update Rules + nAttrib = 0; + if( aRB_NoCascUpd.IsChecked() ) + nAttrib |= KeyRule::NO_ACTION; + if( aRB_CascUpd.IsChecked() ) + nAttrib |= KeyRule::CASCADE; + if( aRB_CascUpdNull.IsChecked() ) + nAttrib |= KeyRule::SET_NULL; + if( aRB_CascUpdDefault.IsChecked() ) + nAttrib |= KeyRule::SET_DEFAULT; + pConnData->SetUpdateRules( nAttrib ); + + m_pTableControl->SaveModified(); + + //// wenn die ComboBoxen fuer die Tabellenauswahl enabled sind (Constructor mit bAllowTableSelect==TRUE), dann muss ich in die + //// Connection auch die Tabellennamen stecken + //m_pConnData->SetSourceWinName(m_pTableControl->getSourceWinName()); + //m_pConnData->SetDestWinName(m_pTableControl->getDestWinName()); + + // try to create the relation + try + { + ORelationTableConnectionData* pOrigConnData = static_cast<ORelationTableConnectionData*>(m_pOrigConnData.get()); + if ( *pConnData == *pOrigConnData || pConnData->Update()) + { + m_pOrigConnData->CopyFrom( *m_pConnData ); + EndDialog( RET_OK ); + return 0L; + } + } + catch( const SQLException& ) + { + ::dbaui::showError( SQLExceptionInfo( ::cppu::getCaughtException() ), + this, + static_cast<OJoinTableView*>(GetParent())->getDesignView()->getController().getORB()); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + m_bTriedOneUpdate = TRUE; + // this means that the original connection may be lost (if m_pConnData was not a newly created but an + // existent conn to be modified), which we reflect by returning RET_NO (see ::Execute) + + // try again + Init(m_pConnData); + m_pTableControl->Init( m_pConnData ); + m_pTableControl->lateInit(); + + return 0; +} + + +//------------------------------------------------------------------------ +short ORelationDialog::Execute() +{ + short nResult = ModalDialog::Execute(); + if ((nResult != RET_OK) && m_bTriedOneUpdate) + return RET_NO; + + return nResult; +} +// ----------------------------------------------------------------------------- +TTableConnectionData::value_type ORelationDialog::getConnectionData() const +{ + return m_pConnData; +} +// ----------------------------------------------------------------------------- +void ORelationDialog::setValid(sal_Bool _bValid) +{ + aPB_OK.Enable(_bValid); +} +// ----------------------------------------------------------------------------- +void ORelationDialog::notifyConnectionChange() +{ + Init(m_pConnData); +} +// ----------------------------------------------------------------------------- + + diff --git a/dbaccess/source/ui/dlg/RelationDlg.hrc b/dbaccess/source/ui/dlg/RelationDlg.hrc new file mode 100644 index 000000000000..b0d14aa6d93a --- /dev/null +++ b/dbaccess/source/ui/dlg/RelationDlg.hrc @@ -0,0 +1,54 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef DBAUI_RELATIONDIALOG_HRC +#define DBAUI_RELATIONDIALOG_HRC + +#ifndef DBACCESS_SOURCE_UI_INC_RELATIONCONTROL_HRC +#include "RelationControl.hrc" +#endif + +#define FL_CASC_DEL 3 +#define FL_CASC_UPD 4 + +#define RB_NO_CASC_DEL 1 +#define RB_NO_CASC_UPD 2 +#define RB_CASC_DEL 3 +#define RB_CASC_UPD 4 +#define RB_CASC_DEL_NULL 5 +#define RB_CASC_DEL_DEFAULT 6 +#define RB_CASC_UPD_NULL 7 +#define RB_CASC_UPD_DEFAULT 8 + +#define PB_OK 1 +#define PB_CANCEL 2 +#define PB_HELP 3 + +#define WND_CONTROL 1 + +#endif // DBAUI_RELATIONDIALOG_HRC + + diff --git a/dbaccess/source/ui/dlg/RelationDlg.src b/dbaccess/source/ui/dlg/RelationDlg.src new file mode 100644 index 000000000000..68399ca52619 --- /dev/null +++ b/dbaccess/source/ui/dlg/RelationDlg.src @@ -0,0 +1,185 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBAUI_RELATIONDIALOG_HRC +#include "RelationDlg.hrc" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#include "dbaccess_helpid.hrc" + + +ModalDialog DLG_REL_PROPERTIES +{ + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 186 , 205 ) ; + Text [ en-US ] = "Relations" ; + Moveable = TRUE ; + Closeable = TRUE ; + + + Window WND_CONTROL + { + Pos = MAP_APPFONT( 0, 0 ); + Size = MAP_APPFONT( 186, 113 ); + DialogControl = TRUE; + HelpId = HID_DLG_QRY_WINDOW_CONTROL ; + + FixedLine FL_INVOLVED_TABLES + { + Pos = MAP_APPFONT ( 6 , 3 ) ; + Size = MAP_APPFONT ( 174 , 8 ) ; + Text [ en-US ] = "Tables involved"; + }; + + ListBox LB_LEFT_TABLE + { + Border = TRUE; + Pos = MAP_APPFONT( 12, 14 ); + Size = MAP_APPFONT( 78, 60 ); + HelpId = HID_DLG_QRY_LEFT_TABLE ; + DropDown = TRUE; + TabStop = TRUE; + }; + + ListBox LB_RIGHT_TABLE + { + Border = TRUE; + Pos = MAP_APPFONT( 96, 14 ); + Size = MAP_APPFONT( 78, 60 ); + HelpId = HID_DLG_QRY_RIGHT_TABLE ; + DropDown = TRUE; + TabStop = TRUE; + }; + + FixedLine FL_INVOLVED_FIELDS + { + Pos = MAP_APPFONT ( 6 , 29 ) ; + Size = MAP_APPFONT ( 174 , 8 ) ; + Text [ en-US ] = "Fields involved"; + }; + }; + + + + + FixedLine FL_CASC_UPD + { + Pos = MAP_APPFONT ( 6 , 114 ) ; + Size = MAP_APPFONT ( 84 , 8 ) ; + Text [ en-US ] = "Update options" ; + }; + RadioButton RB_NO_CASC_UPD + { + Pos = MAP_APPFONT ( 12 , 125 ) ; + Size = MAP_APPFONT ( 72 , 10 ) ; + TabStop = TRUE ; + HelpId = HID_DLG_REL_NO_CASC_UPD; + Text [ en-US ] = "~No action" ; + }; + RadioButton RB_CASC_UPD + { + Pos = MAP_APPFONT ( 12 , 139 ) ; + Size = MAP_APPFONT ( 72 , 10 ) ; + HelpId = HID_DLG_REL_CASC_UPD ; + Text [ en-US ] = "~Update cascade" ; + }; + RadioButton RB_CASC_UPD_NULL + { + Pos = MAP_APPFONT ( 12 , 153 ) ; + Size = MAP_APPFONT ( 72 , 10 ) ; + HelpId = HID_DLG_REL_CASC_UPD_NULL ; + Text [ en-US ] = "~Set null" ; + }; + RadioButton RB_CASC_UPD_DEFAULT + { + Pos = MAP_APPFONT ( 12 , 167 ) ; + Size = MAP_APPFONT ( 72 , 10 ) ; + HelpId = HID_DLG_REL_CASC_UPD_DEFAULT ; + Text [ en-US ] = "Set ~default" ; + }; +// zweite FixedLine + FixedLine FL_CASC_DEL + { + Pos = MAP_APPFONT ( 96 , 114 ) ; + Size = MAP_APPFONT ( 84 , 8 ) ; + Text [ en-US ] = "Delete options" ; + }; + RadioButton RB_NO_CASC_DEL + { + Pos = MAP_APPFONT ( 102 , 125 ) ; + Size = MAP_APPFONT ( 72 , 10 ) ; + TabStop = TRUE ; + HelpId = HID_DLG_REL_NO_CASC_DEL ; + Text [ en-US ] = "~No action" ; + }; + RadioButton RB_CASC_DEL + { + Pos = MAP_APPFONT ( 102 , 139 ) ; + Size = MAP_APPFONT ( 72 , 10 ) ; + HelpId = HID_DLG_REL_CASC_DEL ; + Text [ en-US ] = "Delete ~cascade" ; + }; + RadioButton RB_CASC_DEL_NULL + { + Pos = MAP_APPFONT ( 102 , 153 ) ; + Size = MAP_APPFONT ( 72 , 10 ) ; + HelpId = HID_DLG_REL_CASC_DEL_NULL ; + Text [ en-US ] = "~Set null" ; + }; + RadioButton RB_CASC_DEL_DEFAULT + { + Pos = MAP_APPFONT ( 102 , 167 ) ; + Size = MAP_APPFONT ( 72 , 10 ) ; + HelpId = HID_DLG_REL_CASC_DEL_DEFAULT ; + Text [ en-US ] = "Set ~default" ; + }; + + OKButton PB_OK + { + Pos = MAP_APPFONT ( 6 , 184 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + DefButton = TRUE ; + }; + CancelButton PB_CANCEL + { + Pos = MAP_APPFONT ( 59 , 184 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + HelpButton PB_HELP + { + Pos = MAP_APPFONT ( 115 , 184 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + +}; + diff --git a/dbaccess/source/ui/dlg/TablesSingleDlg.cxx b/dbaccess/source/ui/dlg/TablesSingleDlg.cxx new file mode 100644 index 000000000000..4a12a0dd13ea --- /dev/null +++ b/dbaccess/source/ui/dlg/TablesSingleDlg.cxx @@ -0,0 +1,151 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#ifndef _DBAUI_TABLESSINGLEDLG_HXX_ +#include "TablesSingleDlg.hxx" +#endif +#ifndef _DBAUI_DBADMINIMPL_HXX_ +#include "DbAdminImpl.hxx" +#endif +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif +#ifndef _DBAUI_TABLESPAGE_HXX_ +#include "tablespage.hxx" +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif +#ifndef _DBAUI_DATASOURCEITEMS_HXX_ +#include "dsitems.hxx" +#endif + +#ifndef _DBAUI_PROPERTYSETITEM_HXX_ +#include "propertysetitem.hxx" +#endif + +//......................................................................... +namespace dbaui +{ +//......................................................................... +using namespace com::sun::star::uno; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::container; + +DBG_NAME(OTableSubscriptionDialog) + //======================================================================== + //= OTableSubscriptionDialog + //======================================================================== +OTableSubscriptionDialog::OTableSubscriptionDialog(Window* pParent + ,SfxItemSet* _pItems + ,const Reference< XMultiServiceFactory >& _rxORB + ,const ::com::sun::star::uno::Any& _aDataSourceName) + :SfxSingleTabDialog(pParent,UID_DLG_TABLE_FILTER,_pItems) + ,m_pImpl( new ODbDataSourceAdministrationHelper( _rxORB, pParent, this ) ) + ,m_bStopExecution(sal_False) + ,m_pOutSet(_pItems) +{ + DBG_CTOR(OTableSubscriptionDialog,NULL); + m_pImpl->setDataSourceOrName(_aDataSourceName); + Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource(); + m_pOutSet = new SfxItemSet( *_pItems ); + + m_pImpl->translateProperties(xDatasource, *m_pOutSet); + SetInputSet(m_pOutSet); + + OTableSubscriptionPage* pTabPage = new OTableSubscriptionPage(this,*m_pOutSet,this); + pTabPage->SetServiceFactory(_rxORB); + SetTabPage(pTabPage); +} +// ----------------------------------------------------------------------------- +OTableSubscriptionDialog::~OTableSubscriptionDialog() +{ + DBG_DTOR(OTableSubscriptionDialog,NULL); + delete m_pOutSet; +} +// ----------------------------------------------------------------------------- +short OTableSubscriptionDialog::Execute() +{ + short nRet = RET_CANCEL; + if ( !m_bStopExecution ) + { + nRet = SfxSingleTabDialog::Execute(); + if ( nRet == RET_OK ) + { + m_pOutSet->Put(*GetOutputItemSet()); + m_pImpl->saveChanges(*m_pOutSet); + } + } + return nRet; +} +// ----------------------------------------------------------------------------- +sal_Bool OTableSubscriptionDialog::getCurrentSettings(Sequence< PropertyValue >& _rDriverParams) +{ + return m_pImpl->getCurrentSettings(_rDriverParams); +} +// ----------------------------------------------------------------------------- +void OTableSubscriptionDialog::successfullyConnected() +{ + m_pImpl->successfullyConnected(); +} +// ----------------------------------------------------------------------------- +void OTableSubscriptionDialog::clearPassword() +{ + m_pImpl->clearPassword(); +} +// ----------------------------------------------------------------------------- +String OTableSubscriptionDialog::getConnectionURL() const +{ + return m_pImpl->getConnectionURL(); +} +// ----------------------------------------------------------------------------- +Reference< XPropertySet > OTableSubscriptionDialog::getCurrentDataSource() +{ + return m_pImpl->getCurrentDataSource(); +} +// ----------------------------------------------------------------------------- +const SfxItemSet* OTableSubscriptionDialog::getOutputSet() const +{ + return m_pOutSet; +} +// ----------------------------------------------------------------------------- +SfxItemSet* OTableSubscriptionDialog::getWriteOutputSet() +{ + return m_pOutSet; +} +// ----------------------------------------------------------------------------- +//......................................................................... +} // namespace dbaui +//......................................................................... + + + diff --git a/dbaccess/source/ui/dlg/TextConnectionHelper.cxx b/dbaccess/source/ui/dlg/TextConnectionHelper.cxx new file mode 100644 index 000000000000..e7847e48ef89 --- /dev/null +++ b/dbaccess/source/ui/dlg/TextConnectionHelper.cxx @@ -0,0 +1,617 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" +#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "moduledbu.hxx" +#endif + +#ifndef DBAUI_TEXTCONNECTIONHELPER_HXX +#include "TextConnectionHelper.hxx" +#endif + +#ifndef _DBAUI_SQLMESSAGE_HXX_ +#include "sqlmessage.hxx" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef _DBU_RESOURCE_HRC_ +#include "dbu_resource.hrc" +#endif +#ifndef _DBAUI_AUTOCONTROLS_HRC_ +#include "AutoControls.hrc" +#endif + +#ifndef _SFXITEMSET_HXX +#include <svl/itemset.hxx> +#endif +#ifndef _SFXSTRITEM_HXX +#include <svl/stritem.hxx> +#endif +#ifndef _SFXENUMITEM_HXX +#include <svl/eitem.hxx> +#endif +#ifndef _SFXINTITEM_HXX +#include <svl/intitem.hxx> +#endif +#ifndef _DBAUI_DATASOURCEITEMS_HXX_ +#include "dsitems.hxx" +#endif +#ifndef _DBAUI_DBFINDEX_HXX_ +#include "dbfindex.hxx" +#endif +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif +#ifndef _DBAUI_LOCALRESACCESS_HXX_ +#include "localresaccess.hxx" +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif +#ifndef _SV_MNEMONIC_HXX +#include <vcl/mnemonic.hxx> +#endif +#ifndef _SVTOOLS_CJKOPTIONS_HXX +#include <svl/cjkoptions.hxx> +#endif +#include <jvmaccess/virtualmachine.hxx> +#ifndef _DBAUI_ADASTAT_HXX_ +#include "AdabasStat.hxx" +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include <connectivity/CommonTools.hxx> +#endif +#ifndef DBAUI_DRIVERSETTINGS_HXX +#include "DriverSettings.hxx" +#endif +#ifndef _DBAUI_DBADMIN_HXX_ +#include "dbadmin.hxx" +#endif +#ifndef _COMPHELPER_TYPES_HXX_ +#include <comphelper/types.hxx> +#endif + +#ifndef _COM_SUN_STAR_UI_DIALOGS_XFOLDERPICKER_HPP_ +#include <com/sun/star/ui/dialogs/XFolderPicker.hpp> +#endif +// #106016# ------------------------------------ +#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_ +#include <com/sun/star/task/XInteractionHandler.hpp> +#endif + +#ifndef SVTOOLS_FILENOTATION_HXX_ +#include <svl/filenotation.hxx> +#endif + +#ifndef _UNOTOOLS_LOCALFILEHELPER_HXX +#include <unotools/localfilehelper.hxx> +#endif +#ifndef _UNOTOOLS_UCBHELPER_HXX +#include <unotools/ucbhelper.hxx> +#endif +#ifndef _UCBHELPER_COMMANDENVIRONMENT_HXX +#include <ucbhelper/commandenvironment.hxx> +#endif +#ifndef DBAUI_FILEPICKER_INTERACTION_HXX +#include "finteraction.hxx" +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include <connectivity/CommonTools.hxx> +#endif + +#ifndef DBAUI_DBSETUPCONNECTIONPAGES_HXX +#include "DBSetupConnectionPages.hxx" +#endif + +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif + +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif + +#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX +#include <unotools/pathoptions.hxx> +#endif + +#ifndef SVTOOLS_INC_ROADMAPWIZARD_HXX +#include <svtools/roadmapwizard.hxx> +#endif + + +namespace dbaui +{ + + //======================================================================== + //= OTextConnectionPageSetup + //======================================================================== +DBG_NAME(OTextConnectionHelper) +//------------------------------------------------------------------------ + OTextConnectionHelper::OTextConnectionHelper( Window* pParent, const short _nAvailableSections ) + :Control( pParent, WB_DIALOGCONTROL ) + ,m_aFTExtensionHeader (this, ModuleRes(FT_AUTOEXTENSIONHEADER)) + ,m_aRBAccessTextFiles (this, ModuleRes(RB_AUTOACCESSCTEXTFILES)) + ,m_aRBAccessCSVFiles (this, ModuleRes(RB_AUTOACCESSCCSVFILES)) + ,m_aRBAccessOtherFiles (this, ModuleRes(RB_AUTOACCESSOTHERS)) + ,m_aETOwnExtension (this, ModuleRes(ET_AUTOOWNEXTENSION)) + ,m_aFTExtensionExample (this, ModuleRes(FT_AUTOOWNEXTENSIONAPPENDIX)) + ,m_aLineFormat (this, ModuleRes(FL_AUTOSEPARATOR2)) + ,m_aFieldSeparatorLabel (this, ModuleRes(FT_AUTOFIELDSEPARATOR)) + ,m_aFieldSeparator (this, ModuleRes(CM_AUTOFIELDSEPARATOR)) + ,m_aTextSeparatorLabel (this, ModuleRes(FT_AUTOTEXTSEPARATOR)) + ,m_aTextSeparator (this, ModuleRes(CM_AUTOTEXTSEPARATOR)) + ,m_aDecimalSeparatorLabel (this, ModuleRes(FT_AUTODECIMALSEPARATOR)) + ,m_aDecimalSeparator (this, ModuleRes(CM_AUTODECIMALSEPARATOR)) + ,m_aThousandsSeparatorLabel (this, ModuleRes(FT_AUTOTHOUSANDSSEPARATOR)) + ,m_aThousandsSeparator (this, ModuleRes(CM_AUTOTHOUSANDSSEPARATOR)) + ,m_aRowHeader (this, ModuleRes(CB_AUTOHEADER)) + ,m_aCharSetHeader (this, ModuleRes(FL_DATACONVERT)) + ,m_aCharSetLabel (this, ModuleRes(FT_CHARSET)) + ,m_aCharSet (this, ModuleRes(LB_CHARSET)) + ,m_aFieldSeparatorList (ModuleRes(STR_AUTOFIELDSEPARATORLIST)) + ,m_aTextSeparatorList (ModuleRes(STR_AUTOTEXTSEPARATORLIST)) + ,m_aTextNone (ModuleRes(STR_AUTOTEXT_FIELD_SEP_NONE)) + ,m_nAvailableSections( _nAvailableSections ) + { + DBG_CTOR(OTextConnectionHelper,NULL); + + xub_StrLen nCnt = m_aFieldSeparatorList.GetTokenCount( '\t' ); + xub_StrLen i; + + for( i = 0 ; i < nCnt ; i += 2 ) + m_aFieldSeparator.InsertEntry( m_aFieldSeparatorList.GetToken( i, '\t' ) ); + + nCnt = m_aTextSeparatorList.GetTokenCount( '\t' ); + for( i=0 ; i<nCnt ; i+=2 ) + m_aTextSeparator.InsertEntry( m_aTextSeparatorList.GetToken( i, '\t' ) ); + m_aTextSeparator.InsertEntry(m_aTextNone); + + // set the modify handlers + m_aFieldSeparator.SetUpdateDataHdl(getControlModifiedLink()); + m_aFieldSeparator.SetSelectHdl(getControlModifiedLink()); + m_aTextSeparator.SetUpdateDataHdl(getControlModifiedLink()); + m_aTextSeparator.SetSelectHdl(getControlModifiedLink()); + m_aCharSet.SetSelectHdl(getControlModifiedLink()); + + m_aFieldSeparator.SetModifyHdl(getControlModifiedLink()); + m_aTextSeparator.SetModifyHdl(getControlModifiedLink()); + m_aDecimalSeparator.SetModifyHdl(getControlModifiedLink()); + m_aThousandsSeparator.SetModifyHdl(getControlModifiedLink()); + m_aETOwnExtension.SetModifyHdl(LINK(this, OTextConnectionHelper, OnEditModified)); + m_aRBAccessTextFiles.SetToggleHdl(LINK(this, OTextConnectionHelper, OnSetExtensionHdl)); + m_aRBAccessCSVFiles.SetToggleHdl(LINK(this, OTextConnectionHelper, OnSetExtensionHdl)); + m_aRBAccessOtherFiles.SetToggleHdl(LINK(this, OTextConnectionHelper, OnSetExtensionHdl)); + m_aRBAccessCSVFiles.Check(sal_True); + + struct SectionDescriptor + { + short nFlag; + Window* pFirstControl; + } aSections[] = { + { TC_EXTENSION, &m_aFTExtensionHeader }, + { TC_SEPARATORS, &m_aLineFormat }, + { TC_HEADER, &m_aRowHeader }, + { TC_CHARSET, &m_aCharSetHeader }, + { 0, NULL } + }; + + for ( size_t section=0; section < sizeof( aSections ) / sizeof( aSections[0] ) - 1; ++section ) + { + if ( ( m_nAvailableSections & aSections[section].nFlag ) != 0 ) + { + // the section is visible, no need to do anything here + continue; + } + + Window* pThisSection = aSections[section].pFirstControl; + Window* pNextSection = aSections[section+1].pFirstControl; + + // hide all elements from this section + Window* pControl = pThisSection; + while ( ( pControl != pNextSection ) && pControl ) + { + Window* pRealWindow = pControl->GetWindow( WINDOW_CLIENT ); + #if OSL_DEBUG_LEVEL > 0 + String sWindowText( pRealWindow->GetText() ); + (void)sWindowText; + #endif + pRealWindow->Hide(); + pControl = pControl->GetWindow( WINDOW_NEXT ); + } + + // move all controls in following sections up + if ( !pNextSection ) + continue; + const long nThisSectionStart = pThisSection->GetPosPixel().Y(); + const long nNextSectionStart = pNextSection->GetPosPixel().Y(); + const long nMoveOffset( nThisSectionStart - nNextSectionStart ); + while ( pControl ) + { + Point aPos = pControl->GetPosPixel(); + aPos.Move( 0, nMoveOffset ); + pControl->SetPosPixel( aPos ); + pControl = pControl->GetWindow( WINDOW_NEXT ); + } + } + + Rectangle aControlRectUnion; + for ( Window* pControl = aSections[0].pFirstControl; + pControl != NULL; + pControl = pControl->GetWindow( WINDOW_NEXT ) + ) + { + aControlRectUnion = aControlRectUnion.Union( Rectangle( pControl->GetPosPixel(), pControl->GetSizePixel() ) ); + } + + // need some adjustments to the positions, since the resource-specified + // positions for the control were relative to *our* parent, while by now + // the controls have |this| as parent. + + // first, move ourself to the upper left of the area occupied by all controls + SetPosPixel( aControlRectUnion.TopLeft() ); + + // then, compensate in the control positions, by moving them the up/left + for ( Window* pControl = aSections[0].pFirstControl; + pControl != NULL; + pControl = pControl->GetWindow( WINDOW_NEXT ) + ) + { + Point aPos( pControl->GetPosPixel() ); + aPos.Move( -aControlRectUnion.Left(), -aControlRectUnion.Top() ); + pControl->SetPosPixel( aPos ); + + // while we are here ... the controls should not have an own background + // (this would not be needed when our outer dialog were also the parent + // of the controls) + pControl->SetBackground(); + } + + // now, change our own size so all controls fit + SetSizePixel( aControlRectUnion.GetSize() ); + + SetBackground(); + Show(); + } + + // ----------------------------------------------------------------------- + OTextConnectionHelper::~OTextConnectionHelper() + { + + DBG_DTOR(OTextConnectionHelper,NULL); + } + + + // ----------------------------------------------------------------------- + IMPL_LINK(OTextConnectionHelper, OnControlModified, Control*, /*EMPTYARG*/) + { + callModifiedHdl(); + return 0L; + } + + // ----------------------------------------------------------------------- + IMPL_LINK(OTextConnectionHelper, OnEditModified, Edit*, /*_pEdit*/) + { + m_aGetExtensionHandler.Call(this); + return 0L; + } + + + IMPL_LINK(OTextConnectionHelper, OnSetExtensionHdl, RadioButton*, /*_pRadioButton*/) + { + sal_Bool bDoEnable = m_aRBAccessOtherFiles.IsChecked(); + m_aETOwnExtension.Enable(bDoEnable); + m_aFTExtensionExample.Enable(bDoEnable); + m_aGetExtensionHandler.Call(this); + return 0L; + } + + + // ----------------------------------------------------------------------- + void OTextConnectionHelper::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) + { + _rControlList.push_back(new OSaveValueWrapper<ComboBox>(&m_aFieldSeparator)); + _rControlList.push_back(new OSaveValueWrapper<ComboBox>(&m_aTextSeparator)); + _rControlList.push_back(new OSaveValueWrapper<ComboBox>(&m_aDecimalSeparator)); + _rControlList.push_back(new OSaveValueWrapper<ComboBox>(&m_aThousandsSeparator)); + _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aRowHeader)); + _rControlList.push_back(new OSaveValueWrapper<ListBox>(&m_aCharSet)); + } + // ----------------------------------------------------------------------- + void OTextConnectionHelper::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) + { + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFieldSeparatorLabel)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aTextSeparatorLabel)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aDecimalSeparatorLabel)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aThousandsSeparatorLabel)); + _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aCharSetHeader)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aCharSetLabel)); + _rControlList.push_back(new ODisableWrapper<ListBox>(&m_aCharSet)); + } + + // ----------------------------------------------------------------------- + void OTextConnectionHelper::implInitControls(const SfxItemSet& _rSet, sal_Bool _bValid) + { + if ( !_bValid ) + return; + + SFX_ITEMSET_GET( _rSet, pDelItem, SfxStringItem, DSID_FIELDDELIMITER, sal_True ); + SFX_ITEMSET_GET( _rSet, pStrItem, SfxStringItem, DSID_TEXTDELIMITER, sal_True ); + SFX_ITEMSET_GET( _rSet, pDecdelItem, SfxStringItem, DSID_DECIMALDELIMITER, sal_True ); + SFX_ITEMSET_GET( _rSet, pThodelItem, SfxStringItem, DSID_THOUSANDSDELIMITER, sal_True ); + SFX_ITEMSET_GET( _rSet, pExtensionItem, SfxStringItem, DSID_TEXTFILEEXTENSION, sal_True ); + SFX_ITEMSET_GET( _rSet, pCharsetItem, SfxStringItem, DSID_CHARSET, sal_True ); + + if ( ( m_nAvailableSections & TC_EXTENSION ) != 0 ) + { + m_aOldExtension = pExtensionItem->GetValue(); + SetExtension( m_aOldExtension ); + } + + if ( ( m_nAvailableSections & TC_HEADER ) != 0 ) + { + SFX_ITEMSET_GET( _rSet, pHdrItem, SfxBoolItem, DSID_TEXTFILEHEADER, sal_True ); + m_aRowHeader.Check( pHdrItem->GetValue() ); + } + + if ( ( m_nAvailableSections & TC_SEPARATORS ) != 0 ) + { + SetSeparator( m_aFieldSeparator, m_aFieldSeparatorList, pDelItem->GetValue() ); + SetSeparator( m_aTextSeparator, m_aTextSeparatorList, pStrItem->GetValue() ); + m_aDecimalSeparator.SetText( pDecdelItem->GetValue() ); + m_aThousandsSeparator.SetText( pThodelItem->GetValue() ); + } + + if ( ( m_nAvailableSections & TC_CHARSET ) != 0 ) + { + m_aCharSet.SelectEntryByIanaName( pCharsetItem->GetValue() ); + } + } + + + + // ----------------------------------------------------------------------- + sal_Bool OTextConnectionHelper::prepareLeave() + { + LocalResourceAccess aStringResAccess(PAGE_TEXT, RSC_TABPAGE); + // for accessing the strings which are local to our own resource block + String sExtension = GetExtension(); + String aErrorText; + Control* pErrorWin = NULL; + // if (!m_aFieldSeparator.GetText().Len()) + // bug (#42168) if this line is compiled under OS2 (in a product environent) + // -> use a temporary variable + String aDelText(m_aFieldSeparator.GetText()); + if(!aDelText.Len()) + { // Kein FeldTrenner + aErrorText = String(ModuleRes(STR_AUTODELIMITER_MISSING)); + aErrorText.SearchAndReplaceAscii("#1",m_aFieldSeparatorLabel.GetText()); + pErrorWin = &m_aFieldSeparator; + } + else if (!m_aDecimalSeparator.GetText().Len()) + { // kein Decimaltrenner + aErrorText = String(ModuleRes(STR_AUTODELIMITER_MISSING)); + aErrorText.SearchAndReplaceAscii("#1",m_aDecimalSeparatorLabel.GetText()); + pErrorWin = &m_aDecimalSeparator; + } + else if (m_aTextSeparator.GetText() == m_aFieldSeparator.GetText()) + { // Feld und TextTrenner duerfen nicht gleich sein + aErrorText = String(ModuleRes(STR_AUTODELIMITER_MUST_DIFFER)); + aErrorText.SearchAndReplaceAscii("#1",m_aTextSeparatorLabel.GetText()); + aErrorText.SearchAndReplaceAscii("#2",m_aFieldSeparatorLabel.GetText()); + pErrorWin = &m_aTextSeparator; + } + else if (m_aDecimalSeparator.GetText() == m_aThousandsSeparator.GetText()) + { // Tausender und DecimalTrenner duerfen nicht gleich sein + aErrorText = String(ModuleRes(STR_AUTODELIMITER_MUST_DIFFER)); + aErrorText.SearchAndReplaceAscii("#1",m_aDecimalSeparatorLabel.GetText()); + aErrorText.SearchAndReplaceAscii("#2",m_aThousandsSeparatorLabel.GetText()); + pErrorWin = &m_aDecimalSeparator; + } + else if (m_aFieldSeparator.GetText() == m_aThousandsSeparator.GetText()) + { // Tausender und FeldTrenner duerfen nicht gleich sein + aErrorText = String(ModuleRes(STR_AUTODELIMITER_MUST_DIFFER)); + aErrorText.SearchAndReplaceAscii("#1",m_aFieldSeparatorLabel.GetText()); + aErrorText.SearchAndReplaceAscii("#2",m_aThousandsSeparatorLabel.GetText()); + pErrorWin = &m_aFieldSeparator; + } + else if (m_aFieldSeparator.GetText() == m_aDecimalSeparator.GetText()) + { // Zehner und FeldTrenner duerfen nicht gleich sein + aErrorText = String(ModuleRes(STR_AUTODELIMITER_MUST_DIFFER)); + aErrorText.SearchAndReplaceAscii("#1",m_aFieldSeparatorLabel.GetText()); + aErrorText.SearchAndReplaceAscii("#2",m_aDecimalSeparatorLabel.GetText()); + pErrorWin = &m_aFieldSeparator; + } + else if (m_aTextSeparator.GetText() == m_aThousandsSeparator.GetText()) + { // Tausender und TextTrenner duerfen nicht gleich sein + aErrorText = String(ModuleRes(STR_AUTODELIMITER_MUST_DIFFER)); + aErrorText.SearchAndReplaceAscii("#1",m_aTextSeparatorLabel.GetText()); + aErrorText.SearchAndReplaceAscii("#2",m_aThousandsSeparatorLabel.GetText()); + pErrorWin = &m_aTextSeparator; + } + else if (m_aTextSeparator.GetText() == m_aDecimalSeparator.GetText()) + { // Zehner und TextTrenner duerfen nicht gleich sein + aErrorText = String(ModuleRes(STR_AUTODELIMITER_MUST_DIFFER)); + aErrorText.SearchAndReplaceAscii("#1",m_aTextSeparatorLabel.GetText()); + aErrorText.SearchAndReplaceAscii("#2",m_aDecimalSeparatorLabel.GetText()); + pErrorWin = &m_aTextSeparator; + } + else if ((sExtension.Search('*') != STRING_NOTFOUND) || (sExtension.Search('?') != STRING_NOTFOUND)) + { + aErrorText = String(ModuleRes(STR_AUTONO_WILDCARDS)); + aErrorText.SearchAndReplaceAscii("#1",sExtension); + pErrorWin = &m_aETOwnExtension; + } + else + return sal_True; + ErrorBox(NULL, WB_OK, MnemonicGenerator::EraseAllMnemonicChars( aErrorText)).Execute(); + pErrorWin->GrabFocus(); + return 0; + } + + + // ----------------------------------------------------------------------- + sal_Bool OTextConnectionHelper::FillItemSet( SfxItemSet& rSet, const sal_Bool _bChangedSomething ) + { + sal_Bool bChangedSomething = _bChangedSomething; + + if ( ( m_nAvailableSections & TC_EXTENSION ) != 0 ) + { + String sExtension = GetExtension(); + if( !m_aOldExtension.Equals( sExtension ) ) + { + rSet.Put( SfxStringItem( DSID_TEXTFILEEXTENSION, sExtension ) ); + bChangedSomething = sal_True; + } + } + + if ( ( m_nAvailableSections & TC_HEADER ) != 0 ) + { + if( (m_aRowHeader.GetState() != m_aRowHeader.GetSavedValue()) ) + { + rSet.Put(SfxBoolItem(DSID_TEXTFILEHEADER, m_aRowHeader.IsChecked())); + bChangedSomething = sal_True; + } + } + + if ( ( m_nAvailableSections & TC_SEPARATORS ) != 0 ) + { + if( m_aFieldSeparator.GetText() != m_aFieldSeparator.GetSavedValue() ) + { + rSet.Put( SfxStringItem(DSID_FIELDDELIMITER, GetSeparator( m_aFieldSeparator, m_aFieldSeparatorList) ) ); + bChangedSomething = sal_True; + } + if( m_aTextSeparator.GetText() != m_aTextSeparator.GetSavedValue() ) + { + rSet.Put( SfxStringItem(DSID_TEXTDELIMITER, GetSeparator( m_aTextSeparator, m_aTextSeparatorList) ) ); + bChangedSomething = sal_True; + } + + if( m_aDecimalSeparator.GetText() != m_aDecimalSeparator.GetSavedValue() ) + { + rSet.Put( SfxStringItem(DSID_DECIMALDELIMITER, m_aDecimalSeparator.GetText().Copy(0, 1) ) ); + bChangedSomething = sal_True; + } + if( m_aThousandsSeparator.GetText() != m_aThousandsSeparator.GetSavedValue() ) + { + rSet.Put( SfxStringItem(DSID_THOUSANDSDELIMITER, m_aThousandsSeparator.GetText().Copy(0,1) ) ); + bChangedSomething = sal_True; + } + } + + if ( ( m_nAvailableSections & TC_CHARSET ) != 0 ) + { + if ( m_aCharSet.StoreSelectedCharSet( rSet, DSID_CHARSET ) ) + bChangedSomething = sal_True; + } + + return bChangedSomething; + } + + + void OTextConnectionHelper::SetExtension(const String& _rVal) + { + if (_rVal.EqualsAscii("txt")) + m_aRBAccessTextFiles.Check(sal_True); + else if (_rVal.EqualsAscii( "csv" )) + m_aRBAccessCSVFiles.Check(sal_True); + else + { + m_aRBAccessOtherFiles.Check(sal_True); + m_aFTExtensionExample.SetText(_rVal); + } + } + + + String OTextConnectionHelper::GetExtension() + { + String sExtension; + if (m_aRBAccessTextFiles.IsChecked()) + sExtension = String::CreateFromAscii("txt"); + else if (m_aRBAccessCSVFiles.IsChecked()) + sExtension = String::CreateFromAscii("csv"); + else + { + sExtension = m_aETOwnExtension.GetText(); + if ( sExtension.GetToken(0,'.').Equals('*') ) + sExtension.Erase(0,2); + } + return sExtension; + } + + + //------------------------------------------------------------------------ + String OTextConnectionHelper::GetSeparator( const ComboBox& rBox, const String& rList ) + { + sal_Unicode nTok = '\t'; + xub_StrLen nPos(rBox.GetEntryPos( rBox.GetText() )); + + if( nPos == COMBOBOX_ENTRY_NOTFOUND ) + return rBox.GetText().Copy(0); + + if ( !( &m_aTextSeparator == &rBox && nPos == (rBox.GetEntryCount()-1) ) ) + return String( + static_cast< sal_Unicode >( + rList.GetToken(((nPos*2)+1), nTok ).ToInt32())); + // somewhat strange ... translates for instance an "32" into " " + return String(); + } + + //------------------------------------------------------------------------ + void OTextConnectionHelper::SetSeparator( ComboBox& rBox, const String& rList, const String& rVal ) + { + char nTok = '\t'; + xub_StrLen nCnt(rList.GetTokenCount( nTok )); + xub_StrLen i; + + for( i=0 ; i<nCnt ; i+=2 ) + { + String sTVal( + static_cast< sal_Unicode >( + rList.GetToken( (i+1), nTok ).ToInt32())); + + if( sTVal == rVal ) + { + rBox.SetText( rList.GetToken( i, nTok ) ); + break; + } + } + + if ( i >= nCnt ) + { + if ( &m_aTextSeparator == &rBox && !rVal.Len() ) + rBox.SetText(m_aTextNone); + else + rBox.SetText( rVal.Copy(0, 1) ); + } + } + +//......................................................................... +} // namespace dbaui +//......................................................................... diff --git a/dbaccess/source/ui/dlg/TextConnectionHelper.hxx b/dbaccess/source/ui/dlg/TextConnectionHelper.hxx new file mode 100644 index 000000000000..911994553a4c --- /dev/null +++ b/dbaccess/source/ui/dlg/TextConnectionHelper.hxx @@ -0,0 +1,140 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBAUI_TEXTCONNECTIONHELPER_HXX +#define DBAUI_TEXTCONNECTIONHELPER_HXX + +#ifndef DBAUI_CONNECTIONPAGESETUP_HXX +#include "ConnectionPageSetup.hxx" +#endif +#ifndef _DBAUI_ADMINPAGES_HXX_ +#include "adminpages.hxx" +#endif +#ifndef CHARSETLISTBOX_HXX +#include "charsetlistbox.hxx" +#endif +#ifndef _UCBHELPER_CONTENT_HXX +#include <ucbhelper/content.hxx> +#endif +#ifndef _DBAUI_CURLEDIT_HXX_ +#include "curledit.hxx" +#endif +#ifndef SVTOOLS_INC_ROADMAPWIZARD_HXX +#include <svtools/roadmapwizard.hxx> +#endif +#ifndef _SV_FIELD_HXX +#include <vcl/field.hxx> +#endif +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif +#ifndef _SV_LSTBOX_HXX +#include <vcl/lstbox.hxx> +#endif + + +//......................................................................... +namespace dbaui + +{ +//......................................................................... + + #define TC_EXTENSION ((short)0x01) // a section specifying the extension of the files to connect to + #define TC_SEPARATORS ((short)0x02) // a section specifying the various separators + #define TC_HEADER ((short)0x04) // a section containing the "Text contains header" check box only + #define TC_CHARSET ((short)0x08) // not yet implemented + + //======================================================================== + //= OTextConnectionPage + //======================================================================== + class OTextConnectionHelper : public Control + { + OTextConnectionHelper(); + + Link m_aModifiedHandler; /// to be called if something on the page has been modified + + public: + OTextConnectionHelper( Window* pParent, const short _nAvailableSections ); + virtual ~OTextConnectionHelper(); + + private: + FixedText m_aFTExtensionHeader; + RadioButton m_aRBAccessTextFiles; + RadioButton m_aRBAccessCSVFiles; + RadioButton m_aRBAccessOtherFiles; + Edit m_aETOwnExtension; + FixedText m_aFTExtensionExample; + FixedLine m_aLineFormat; + FixedText m_aFieldSeparatorLabel; + ComboBox m_aFieldSeparator; + FixedText m_aTextSeparatorLabel; + ComboBox m_aTextSeparator; + FixedText m_aDecimalSeparatorLabel; + ComboBox m_aDecimalSeparator; + FixedText m_aThousandsSeparatorLabel; + ComboBox m_aThousandsSeparator; + CheckBox m_aRowHeader; + FixedLine m_aCharSetHeader; + FixedText m_aCharSetLabel; + CharSetListBox m_aCharSet; + String m_aFieldSeparatorList; + String m_aTextSeparatorList; + String m_aTextNone; + String m_aOldExtension; + Link m_aGetExtensionHandler; /// to be called if a new type is selected + + short m_nAvailableSections; + + protected: + void callModifiedHdl() const { if (m_aModifiedHandler.IsSet()) m_aModifiedHandler.Call((void*)this); } + Link getControlModifiedLink() { return LINK(this, OTextConnectionHelper, OnControlModified); } + DECL_LINK(OnSetExtensionHdl,RadioButton*); + DECL_LINK(OnControlModified,Control*); + DECL_LINK(OnEditModified,Edit*); + + private: + String GetSeparator( const ComboBox& rBox, const String& rList ); + void SetSeparator( ComboBox& rBox, const String& rList, const String& rVal ); + void SetExtension(const String& _rVal); + + + public: + void implInitControls(const SfxItemSet& _rSet, sal_Bool _bValid); + void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList); + void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList); + void SetClickHandler(const Link& _rHandler) { m_aGetExtensionHandler = _rHandler; } + String GetExtension(); + sal_Bool FillItemSet( SfxItemSet& rSet, const sal_Bool bChangedSomething ); + sal_Bool prepareLeave(); + }; + +//......................................................................... +} // namespace dbaui +//......................................................................... + +#endif // DBAUI_DBWIZ2_HXX + diff --git a/dbaccess/source/ui/dlg/UserAdmin.cxx b/dbaccess/source/ui/dlg/UserAdmin.cxx new file mode 100644 index 000000000000..0d9254f74390 --- /dev/null +++ b/dbaccess/source/ui/dlg/UserAdmin.cxx @@ -0,0 +1,393 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#ifndef DBAUI_USERADMIN_HXX +#include "UserAdmin.hxx" +#endif +#ifndef DBAUI_USERADMIN_HRC +#include "UserAdmin.hrc" +#endif +#ifndef DBAUI_TOOLS_HXX +#include "UITools.hxx" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef _COMPHELPER_TYPES_HXX_ +#include <comphelper/types.hxx> +#endif +#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XDATADEFINITIONSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XUSERSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XUsersSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_ +#include <com/sun/star/sdbcx/XDrop.hpp> +#endif +#ifndef _UCBHELPER_INTERATIONREQUEST_HXX +#include <ucbhelper/interactionrequest.hxx> +#endif +#ifndef _UCBHELPER_SIMPLEAUTHENTICATIONREQUEST_HXX +#include <ucbhelper/simpleauthenticationrequest.hxx> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_ +#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XUSER_HPP_ +#include <com/sun/star/sdbcx/XUser.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_ +#include <com/sun/star/sdbcx/XAppend.hpp> +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif +#ifndef _DBAUI_DBADMIN_HXX_ +#include "dbadmin.hxx" +#endif +#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "moduledbu.hxx" +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif +#ifndef _SFX_PASSWD_HXX +#include <sfx2/passwd.hxx> +#endif + +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::task; +using namespace dbaui; +using namespace ucbhelper; +using namespace comphelper; + + +class OPasswordDialog : public ModalDialog +{ + FixedLine aFLUser; + FixedText aFTOldPassword; + Edit aEDOldPassword; + FixedText aFTPassword; + Edit aEDPassword; + FixedText aFTPasswordRepeat; + Edit aEDPasswordRepeat; + OKButton aOKBtn; + CancelButton aCancelBtn; + HelpButton aHelpBtn; + + + DECL_LINK( OKHdl_Impl, OKButton * ); + DECL_LINK( ModifiedHdl, Edit * ); + +public: + OPasswordDialog( Window* pParent,const String& _sUserName); + + String GetOldPassword() const { return aEDOldPassword.GetText(); } + String GetNewPassword() const { return aEDPassword.GetText(); } +}; + +OPasswordDialog::OPasswordDialog(Window* _pParent,const String& _sUserName) : + + ModalDialog( _pParent, ModuleRes( DLG_PASSWORD) ), + + aFLUser ( this, ModuleRes( FL_USER ) ), + aFTOldPassword ( this, ModuleRes( FT_OLDPASSWORD ) ), + aEDOldPassword ( this, ModuleRes( ED_OLDPASSWORD ) ), + aFTPassword ( this, ModuleRes( FT_PASSWORD ) ), + aEDPassword ( this, ModuleRes( ED_PASSWORD ) ), + aFTPasswordRepeat ( this, ModuleRes( FT_PASSWORD_REPEAT ) ), + aEDPasswordRepeat ( this, ModuleRes( ED_PASSWORD_REPEAT ) ), + aOKBtn ( this, ModuleRes( BTN_PASSWORD_OK ) ), + aCancelBtn ( this, ModuleRes( BTN_PASSWORD_CANCEL ) ), + aHelpBtn ( this, ModuleRes( BTN_PASSWORD_HELP ) ) +{ + // hide until a help is avalable + aHelpBtn.Hide(); + + FreeResource(); + String sUser = aFLUser.GetText(); + sUser.SearchAndReplaceAscii("$name$: $",_sUserName); + aFLUser.SetText(sUser); + aOKBtn.Disable(); + + aOKBtn.SetClickHdl( LINK( this, OPasswordDialog, OKHdl_Impl ) ); + aEDOldPassword.SetModifyHdl( LINK( this, OPasswordDialog, ModifiedHdl ) ); +} +// ----------------------------------------------------------------------------- +IMPL_LINK( OPasswordDialog, OKHdl_Impl, OKButton *, EMPTYARG ) +{ + if( aEDPassword.GetText() == aEDPasswordRepeat.GetText() ) + EndDialog( RET_OK ); + else + { + String aErrorMsg( ModuleRes( STR_ERROR_PASSWORDS_NOT_IDENTICAL)); + ErrorBox aErrorBox( this, WB_OK, aErrorMsg ); + aErrorBox.Execute(); + aEDPassword.SetText( String() ); + aEDPasswordRepeat.SetText( String() ); + aEDPassword.GrabFocus(); + } + return 0; +} +// ----------------------------------------------------------------------------- +IMPL_LINK( OPasswordDialog, ModifiedHdl, Edit *, pEdit ) +{ + aOKBtn.Enable(pEdit->GetText().Len() != 0); + return 0; +} + +DBG_NAME(OUserAdmin); +//================================================================================ +// OUserAdmin +//================================================================================ +OUserAdmin::OUserAdmin(Window* pParent,const SfxItemSet& _rAttrSet) + : OGenericAdministrationPage( pParent, ModuleRes(TAB_PAGE_USERADMIN), _rAttrSet) + ,m_FL_USER( this , ModuleRes(FL_USER)) + ,m_FT_USER( this , ModuleRes(FT_USER)) + ,m_LB_USER( this , ModuleRes(LB_USER)) + ,m_PB_NEWUSER( this , ModuleRes(PB_NEWUSER)) + ,m_PB_CHANGEPWD( this , ModuleRes(PB_CHANGEPWD)) + ,m_PB_DELETEUSER( this , ModuleRes(PB_DELETEUSER)) + ,m_FL_TABLE_GRANTS( this , ModuleRes(FL_TABLE_GRANTS)) + ,m_TableCtrl( this , ModuleRes(CTRL_TABLE_GRANTS)) +{ + DBG_CTOR(OUserAdmin,NULL); + m_LB_USER.SetSelectHdl(LINK(this, OUserAdmin, ListDblClickHdl)); + + m_PB_NEWUSER.SetClickHdl(LINK(this, OUserAdmin, UserHdl)); + m_PB_CHANGEPWD.SetClickHdl(LINK(this, OUserAdmin, UserHdl)); + m_PB_DELETEUSER.SetClickHdl(LINK(this, OUserAdmin, UserHdl)); + + FreeResource(); +} +// ----------------------------------------------------------------------- +OUserAdmin::~OUserAdmin() +{ + DBG_DTOR(OUserAdmin,NULL); + m_xConnection = NULL; +} +// ----------------------------------------------------------------------- +void OUserAdmin::FillUserNames() +{ + if(m_xConnection.is()) + { + m_LB_USER.Clear(); + + Reference<XDatabaseMetaData> xMetaData = m_xConnection->getMetaData(); + + if ( xMetaData.is() ) + { + m_UserName = xMetaData->getUserName(); + + // first we need the users + if ( m_xUsers.is() ) + { + m_LB_USER.Clear(); + + m_aUserNames = m_xUsers->getElementNames(); + const ::rtl::OUString* pBegin = m_aUserNames.getConstArray(); + const ::rtl::OUString* pEnd = pBegin + m_aUserNames.getLength(); + ::rtl::OUString sUserName = m_UserName; + for(;pBegin != pEnd;++pBegin) + m_LB_USER.InsertEntry(*pBegin); + + m_LB_USER.SelectEntryPos(0); + if(m_xUsers->hasByName(m_UserName)) + { + Reference<XAuthorizable> xAuth; + m_xUsers->getByName(m_UserName) >>= xAuth; + m_TableCtrl.setGrantUser(xAuth); + } + + m_TableCtrl.setUserName(GetUser()); + m_TableCtrl.Init(); + } + } + } + + Reference<XAppend> xAppend(m_xUsers,UNO_QUERY); + m_PB_NEWUSER.Enable(xAppend.is()); + Reference<XDrop> xDrop(m_xUsers,UNO_QUERY); + m_PB_DELETEUSER.Enable(xDrop.is()); + + m_PB_CHANGEPWD.Enable(m_xUsers.is()); + m_TableCtrl.Enable(m_xUsers.is()); + +} +// ----------------------------------------------------------------------- +SfxTabPage* OUserAdmin::Create( Window* pParent, const SfxItemSet& _rAttrSet ) +{ + return ( new OUserAdmin( pParent, _rAttrSet ) ); +} +// ----------------------------------------------------------------------- +IMPL_LINK( OUserAdmin, UserHdl, PushButton *, pButton ) +{ + try + { + if(pButton == &m_PB_NEWUSER) + { + SfxPasswordDialog aPwdDlg(this); + aPwdDlg.ShowExtras(SHOWEXTRAS_ALL); + if(aPwdDlg.Execute()) + { + Reference<XDataDescriptorFactory> xUserFactory(m_xUsers,UNO_QUERY); + Reference<XPropertySet> xNewUser = xUserFactory->createDataDescriptor(); + if(xNewUser.is()) + { + xNewUser->setPropertyValue(PROPERTY_NAME,makeAny(rtl::OUString(aPwdDlg.GetUser()))); + xNewUser->setPropertyValue(PROPERTY_PASSWORD,makeAny(rtl::OUString(aPwdDlg.GetPassword()))); + Reference<XAppend> xAppend(m_xUsers,UNO_QUERY); + if(xAppend.is()) + xAppend->appendByDescriptor(xNewUser); + } + } + } + else if(pButton == &m_PB_CHANGEPWD) + { + String sName = GetUser(); + + if(m_xUsers->hasByName(sName)) + { + Reference<XUser> xUser; + m_xUsers->getByName(sName) >>= xUser; + if(xUser.is()) + { + ::rtl::OUString sNewPassword,sOldPassword; + OPasswordDialog aDlg(this,sName); + if(aDlg.Execute() == RET_OK) + { + sNewPassword = aDlg.GetNewPassword(); + sOldPassword = aDlg.GetOldPassword(); + + if(sNewPassword.getLength()) + xUser->changePassword(sOldPassword,sNewPassword); + } + } + } + } + else + {// delete user + if(m_xUsers.is() && m_xUsers->hasByName(GetUser())) + { + Reference<XDrop> xDrop(m_xUsers,UNO_QUERY); + if(xDrop.is()) + { + QueryBox aQry(this, ModuleRes(QUERY_USERADMIN_DELETE_USER)); + if(aQry.Execute() == RET_YES) + xDrop->dropByName(GetUser()); + } + } + } + FillUserNames(); + } + catch(SQLException& e) + { + ::dbaui::showError(::dbtools::SQLExceptionInfo(e),this,m_xORB); + return 0; + } + catch(Exception& ) + { + return 0; + } + + return 0; +} +// ----------------------------------------------------------------------- +IMPL_LINK( OUserAdmin, ListDblClickHdl, ListBox *, /*pListBox*/ ) +{ + m_TableCtrl.setUserName(GetUser()); + m_TableCtrl.UpdateTables(); + m_TableCtrl.DeactivateCell(); + m_TableCtrl.ActivateCell(m_TableCtrl.GetCurRow(),m_TableCtrl.GetCurColumnId()); + return 0; +} + +// ----------------------------------------------------------------------- +String OUserAdmin::GetUser() +{ + return m_LB_USER.GetSelectEntry(); +} +// ----------------------------------------------------------------------------- +void OUserAdmin::fillControls(::std::vector< ISaveValueWrapper* >& /*_rControlList*/) +{ +} +// ----------------------------------------------------------------------- +void OUserAdmin::fillWindows(::std::vector< ISaveValueWrapper* >& /*_rControlList*/) +{ +} +// ----------------------------------------------------------------------------- +void OUserAdmin::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) +{ + m_TableCtrl.setORB(m_xORB); + try + { + if ( !m_xConnection.is() && m_pAdminDialog ) + { + m_xConnection = m_pAdminDialog->createConnection().first; + Reference< XTablesSupplier > xTablesSup(m_xConnection,UNO_QUERY); + Reference<XUsersSupplier> xUsersSup(xTablesSup,UNO_QUERY); + if ( !xUsersSup.is() ) + { + Reference< XDataDefinitionSupplier > xDriver(m_pAdminDialog->getDriver(),UNO_QUERY); + if ( xDriver.is() ) + { + xUsersSup.set(xDriver->getDataDefinitionByConnection(m_xConnection),UNO_QUERY); + xTablesSup.set(xUsersSup,UNO_QUERY); + } + } + if ( xUsersSup.is() ) + { + m_TableCtrl.setTablesSupplier(xTablesSup); + m_xUsers = xUsersSup->getUsers(); + } + } + FillUserNames(); + } + catch(SQLException& e) + { + ::dbaui::showError(::dbtools::SQLExceptionInfo(e),this,m_xORB); + } + + OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue); +} diff --git a/dbaccess/source/ui/dlg/UserAdmin.hrc b/dbaccess/source/ui/dlg/UserAdmin.hrc new file mode 100644 index 000000000000..6a012724f49a --- /dev/null +++ b/dbaccess/source/ui/dlg/UserAdmin.hrc @@ -0,0 +1,59 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef DBAUI_USERADMIN_HRC +#define DBAUI_USERADMIN_HRC + +#define FT_USER 1 + +#define LB_USER 1 + +#define NF_TIMEOUT 1 + +#define FL_TABLE_GRANTS 1 +#define FL_USER 2 + +#define CTRL_TABLE_GRANTS 1 + +#define PB_NEWUSER 2 +#define PB_CHANGEPWD 3 +#define PB_DELETEUSER 4 + + + +#define FT_OLDPASSWORD 19 +#define ED_OLDPASSWORD 19 +#define FT_PASSWORD 20 +#define ED_PASSWORD 21 +#define FT_PASSWORD_REPEAT 22 +#define ED_PASSWORD_REPEAT 23 + +#define BTN_PASSWORD_OK 50 +#define BTN_PASSWORD_CANCEL 51 +#define BTN_PASSWORD_HELP 52 + + +#endif // DBAUI_USERADMIN_HRC diff --git a/dbaccess/source/ui/dlg/UserAdmin.hxx b/dbaccess/source/ui/dlg/UserAdmin.hxx new file mode 100644 index 000000000000..13700201a5c1 --- /dev/null +++ b/dbaccess/source/ui/dlg/UserAdmin.hxx @@ -0,0 +1,107 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef DBAUI_USERADMIN_HXX +#define DBAUI_USERADMIN_HXX + +#ifndef _SV_FIXED_HXX +#include <vcl/fixed.hxx> +#endif +#ifndef _SV_FIELD_HXX +#include <vcl/field.hxx> +#endif +#ifndef _SV_LSTBOX_HXX +#include <vcl/lstbox.hxx> +#endif +#ifndef _SV_BUTTON_HXX +#include <vcl/button.hxx> +#endif +#ifndef _SV_DIALOG_HXX +#include <vcl/dialog.hxx> +#endif +#ifndef _SV_GROUP_HXX +#include <vcl/group.hxx> +#endif +#ifndef DBAUI_TABLEGRANTCONTROL_HXX +#include "TableGrantCtrl.hxx" +#endif +#ifndef _DBAUI_ADMINPAGES_HXX_ +#include "adminpages.hxx" +#endif +#ifndef _COMPHELPER_UNO3_HXX_ +#include <comphelper/uno3.hxx> +#endif + +FORWARD_DECLARE_INTERFACE(beans,XPropertySet) +FORWARD_DECLARE_INTERFACE(sdbc,XConnection) +FORWARD_DECLARE_INTERFACE(lang,XMultiServiceFactory) + +namespace dbaui +{ + +class OUserAdmin : public OGenericAdministrationPage +{ +protected: + FixedLine m_FL_USER; + FixedText m_FT_USER; + ListBox m_LB_USER; + PushButton m_PB_NEWUSER; + PushButton m_PB_CHANGEPWD; + PushButton m_PB_DELETEUSER; + FixedLine m_FL_TABLE_GRANTS; + OTableGrantControl m_TableCtrl; // show the grant rights of one user + + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> m_xConnection; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xUsers; + ::com::sun::star::uno::Sequence< ::rtl::OUString> m_aUserNames; + + String m_UserName; + + // methods + DECL_LINK( ListDblClickHdl, ListBox * ); + DECL_LINK( CloseHdl, PushButton * ); + DECL_LINK( UserHdl, PushButton * ); + + void FillUserNames(); + + OUserAdmin( Window* pParent, const SfxItemSet& _rCoreAttrs); +public: + static SfxTabPage* Create( Window* pParent, const SfxItemSet& _rAttrSet ); + + ~OUserAdmin(); + String GetUser(); + + // must be overloaded by subclasses, but it isn't pure virtual + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + + // <method>OGenericAdministrationPage::fillControls</method> + virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList); + + // <method>OGenericAdministrationPage::fillWindows</method> + virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList); +}; +} +#endif // DBAUI_USERADMIN_HXX diff --git a/dbaccess/source/ui/dlg/UserAdmin.src b/dbaccess/source/ui/dlg/UserAdmin.src new file mode 100644 index 000000000000..2cab4f9e89f0 --- /dev/null +++ b/dbaccess/source/ui/dlg/UserAdmin.src @@ -0,0 +1,242 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBAUI_USERADMIN_HRC +#include "UserAdmin.hrc" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif + +#define WINDOW_SIZE_X 260 +#define WINDOW_SIZE_Y 185 + +TabPage TAB_PAGE_USERADMIN +{ + SVLook = TRUE ; + HelpId = HID_TAB_PAGE_USERADMIN ; + Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ; + Hide = TRUE; + + FixedLine FL_USER + { + Pos = MAP_APPFONT ( 6 , 3 ) ; + Size = MAP_APPFONT ( WINDOW_SIZE_X - 8, 8) ; + Text [ en-US ] = "User selection"; + }; + + FixedText FT_USER + { + Pos = MAP_APPFONT ( 12 , 14 ) ; + Size = MAP_APPFONT ( 90 , 10 ) ; + Text [ en-US ] = "Us~er:"; + }; + + ListBox LB_USER + { + Border = TRUE ; + Pos = MAP_APPFONT ( 108 , 13) ; + Size = MAP_APPFONT ( 105 , 97 ) ; + TabStop = TRUE ; + HScroll = TRUE ; + Sort = TRUE ; + DropDown = TRUE ; + HelpId = HID_TAB_PAGE_LBUSER ; + }; + + + PushButton PB_NEWUSER + { + Pos = MAP_APPFONT ( 12 , 29 ) ; + Size = MAP_APPFONT ( 70 , 14 ) ; + TabStop = TRUE ; + DefButton = TRUE ; + HelpId = HID_TAB_PAGE_PBUSER ; + Text [ en-US ] = "~Add User..."; + }; + + PushButton PB_CHANGEPWD + { + Pos = MAP_APPFONT ( 95 , 29 ) ; + Size = MAP_APPFONT ( 70 , 14 ) ; + TabStop = TRUE ; + DefButton = TRUE ; + HelpId = HID_TAB_PAGE_PBCHGPWD ; + Text [ en-US ] = "Change ~Password..."; + }; + + PushButton PB_DELETEUSER + { + Pos = MAP_APPFONT ( WINDOW_SIZE_X - 82 , 29 ) ; + Size = MAP_APPFONT ( 70 , 14 ) ; + TabStop = TRUE ; + DefButton = TRUE ; + HelpId = HID_TAB_PAGE_PBUSERDELETE ; + Text [ en-US ] = "~Delete User..."; + }; + + FixedLine FL_TABLE_GRANTS + { + Pos = MAP_APPFONT ( 6 , 52 ) ; + Size = MAP_APPFONT ( WINDOW_SIZE_X - 8, 8) ; + Text [ en-US ] = "Access rights for selected user"; + }; + + Control CTRL_TABLE_GRANTS + { + Pos = MAP_APPFONT ( 12 , 63 ) ; + Size = MAP_APPFONT ( WINDOW_SIZE_X - 22, WINDOW_SIZE_Y - 75 ); + Border = TRUE ; + TabStop = TRUE ; + HelpId = HID_TAB_PAGE_TBLGRANTS ; + }; +}; + +QueryBox QUERY_USERADMIN_DELETE_USER +{ + Buttons = WB_YES_NO ; + Message [ en-US ] = "Do you really want to delete the user?"; +}; + +String STR_USERADMIN_NOT_AVAILABLE +{ + Text [ en-US ] = "The database does not support user administration." ; +}; + +#define EDIT_SIZE_X 50 +#define FT_SIZE_X 90 +#define WIN_X 220 +#define WIN_Y 72 + +ModalDialog DLG_PASSWORD +{ + HelpId = HID_DLG_PASSWORD ; + Border = TRUE ; + Moveable = TRUE ; + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( WIN_X , WIN_Y ) ; + + FixedLine FL_USER + { + Pos = MAP_APPFONT ( 3 , 3 ) ; + Size = MAP_APPFONT ( WIN_X - 3 - 6 - 6 - 50 , 8 ) ; + Text [ en-US ] = "User \"$name$: $\""; + }; + + FixedText FT_OLDPASSWORD + { + Pos = MAP_APPFONT ( 6 , 17 ) ; + Size = MAP_APPFONT ( FT_SIZE_X , 10 ) ; + Text [ en-US ] = "Old p~assword"; + }; + Edit ED_OLDPASSWORD + { + Border = TRUE ; + Pos = MAP_APPFONT ( 12 + FT_SIZE_X , 16 ) ; + Size = MAP_APPFONT ( EDIT_SIZE_X , 12 ) ; + PassWord = TRUE ; + }; + + FixedText FT_PASSWORD + { + Pos = MAP_APPFONT ( 6 , 35 ) ; + Size = MAP_APPFONT ( FT_SIZE_X , 10 ) ; + Text [ en-US ] = "~Password"; + }; + Edit ED_PASSWORD + { + Border = TRUE ; + Pos = MAP_APPFONT ( 12 + FT_SIZE_X , 34 ) ; + Size = MAP_APPFONT ( EDIT_SIZE_X , 12 ) ; + PassWord = TRUE ; + }; + FixedText FT_PASSWORD_REPEAT + { + Pos = MAP_APPFONT ( 6 , 52 ) ; + Size = MAP_APPFONT ( FT_SIZE_X , 10 ) ; + Text [ en-US ] = "~Confirm password"; + }; + Edit ED_PASSWORD_REPEAT + { + Border = TRUE ; + Pos = MAP_APPFONT ( 12 + FT_SIZE_X , 51 ) ; + Size = MAP_APPFONT ( EDIT_SIZE_X , 12 ) ; + PassWord = TRUE ; + }; + + OKButton BTN_PASSWORD_OK + { + Pos = MAP_APPFONT ( WIN_X - 56 , 6 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + DefButton = TRUE ; + }; + CancelButton BTN_PASSWORD_CANCEL + { + Pos = MAP_APPFONT ( WIN_X - 56 , 23 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + }; + HelpButton BTN_PASSWORD_HELP + { + Pos = MAP_APPFONT ( WIN_X - 56 , 43 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + }; + Text [ en-US ] = "Change Password"; +}; + +String STR_ERROR_PASSWORDS_NOT_IDENTICAL +{ + Text [ en-US ] = "The passwords do not match. Please enter the password again."; +}; + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dbaccess/source/ui/dlg/UserAdminDlg.cxx b/dbaccess/source/ui/dlg/UserAdminDlg.cxx new file mode 100644 index 000000000000..37f28bcaa828 --- /dev/null +++ b/dbaccess/source/ui/dlg/UserAdminDlg.cxx @@ -0,0 +1,206 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#include "adminpages.hxx" +#include "DbAdminImpl.hxx" +#include "dbu_dlg.hrc" +#include "DriverSettings.hxx" +#include "dsitems.hxx" +#include "propertysetitem.hxx" +#include "UITools.hxx" +#include "UserAdmin.hxx" +#include "UserAdminDlg.hrc" +#include "UserAdminDlg.hxx" + +#include <comphelper/componentcontext.hxx> +#include <connectivity/dbmetadata.hxx> +#include <cppuhelper/exc_hlp.hxx> +#include <svl/eitem.hxx> +#include <svl/intitem.hxx> +#include <svl/stritem.hxx> +#include <tools/diagnose_ex.h> +#include <vcl/msgbox.hxx> +#include <vcl/stdtext.hxx> + +//......................................................................... +namespace dbaui +{ +//......................................................................... + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::beans; + using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::sdbc; + using namespace ::com::sun::star::sdbcx; + + //======================================================================== + //= OUserAdminDlg +DBG_NAME(OUserAdminDlg) +//======================================================================== + OUserAdminDlg::OUserAdminDlg(Window* _pParent + , SfxItemSet* _pItems + ,const Reference< XMultiServiceFactory >& _rxORB + ,const ::com::sun::star::uno::Any& _aDataSourceName + ,const Reference< XConnection >& _xConnection) + :SfxTabDialog(_pParent, ModuleRes(DLG_DATABASE_USERADMIN), _pItems) + ,m_pItemSet(_pItems) + ,m_xConnection(_xConnection) + ,m_bOwnConnection(!_xConnection.is()) + { + DBG_CTOR(OUserAdminDlg,NULL); + + m_pImpl = ::std::auto_ptr<ODbDataSourceAdministrationHelper>(new ODbDataSourceAdministrationHelper(_rxORB,_pParent,this)); + m_pImpl->setDataSourceOrName(_aDataSourceName); + Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource(); + m_pImpl->translateProperties(xDatasource, *_pItems); + SetInputSet(_pItems); + // propagate this set as our new input set and reset the example set + delete pExampleSet; + pExampleSet = new SfxItemSet(*GetInputSetImpl()); + + AddTabPage(TAB_PAGE_USERADMIN, String(ModuleRes(STR_PAGETITLE_USERADMIN)), OUserAdmin::Create,0, sal_False, 1); + + // remove the reset button - it's meaning is much too ambiguous in this dialog + RemoveResetButton(); + FreeResource(); + } + + // ----------------------------------------------------------------------- + OUserAdminDlg::~OUserAdminDlg() + { + if ( m_bOwnConnection ) + try + { + ::comphelper::disposeComponent(m_xConnection); + } + catch(Exception){} + + SetInputSet(NULL); + DELETEZ(pExampleSet); + + DBG_DTOR(OUserAdminDlg,NULL); + } + // ----------------------------------------------------------------------- + short OUserAdminDlg::Execute() + { + try + { + ::dbtools::DatabaseMetaData aMetaData( createConnection().first ); + if ( !aMetaData.supportsUserAdministration( ::comphelper::ComponentContext( getORB() ) ) ) + { + String sError(ModuleRes(STR_USERADMIN_NOT_AVAILABLE)); + throw SQLException(sError,NULL,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")) ,0,Any()); + } + } + catch(const SQLException& e) + { + ::dbaui::showError( ::dbtools::SQLExceptionInfo( ::cppu::getCaughtException() ), GetParent(), getORB() ); + return RET_CANCEL; + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + short nRet = SfxTabDialog::Execute(); + if ( nRet == RET_OK ) + m_pImpl->saveChanges(*GetOutputItemSet()); + return nRet; + } + //------------------------------------------------------------------------- + void OUserAdminDlg::PageCreated(USHORT _nId, SfxTabPage& _rPage) + { + // register ourself as modified listener + static_cast<OGenericAdministrationPage&>(_rPage).SetServiceFactory(m_pImpl->getORB()); + static_cast<OGenericAdministrationPage&>(_rPage).SetAdminDialog(this,this); + + AdjustLayout(); + Window *pWin = GetViewWindow(); + if(pWin) + pWin->Invalidate(); + + SfxTabDialog::PageCreated(_nId, _rPage); + } + // ----------------------------------------------------------------------------- + const SfxItemSet* OUserAdminDlg::getOutputSet() const + { + return m_pItemSet; + } + // ----------------------------------------------------------------------------- + SfxItemSet* OUserAdminDlg::getWriteOutputSet() + { + return m_pItemSet; + } + // ----------------------------------------------------------------------------- + ::std::pair< Reference<XConnection>,sal_Bool> OUserAdminDlg::createConnection() + { + if ( !m_xConnection.is() ) + { + m_xConnection = m_pImpl->createConnection().first; + m_bOwnConnection = m_xConnection.is(); + } + return ::std::pair< Reference<XConnection>,sal_Bool> (m_xConnection,sal_False); + } + // ----------------------------------------------------------------------------- + Reference< XMultiServiceFactory > OUserAdminDlg::getORB() const + { + return m_pImpl->getORB(); + } + // ----------------------------------------------------------------------------- + Reference< XDriver > OUserAdminDlg::getDriver() + { + return m_pImpl->getDriver(); + } + // ----------------------------------------------------------------------------- + ::rtl::OUString OUserAdminDlg::getDatasourceType(const SfxItemSet& _rSet) const + { + return m_pImpl->getDatasourceType(_rSet); + } + // ----------------------------------------------------------------------------- + void OUserAdminDlg::clearPassword() + { + m_pImpl->clearPassword(); + } + // ----------------------------------------------------------------------------- + void OUserAdminDlg::setTitle(const ::rtl::OUString& _sTitle) + { + SetText(_sTitle); + } + //------------------------------------------------------------------------- + void OUserAdminDlg::enableConfirmSettings( bool _bEnable ) + { + (void)_bEnable; + } + //------------------------------------------------------------------------- + sal_Bool OUserAdminDlg::saveDatasource() + { + return PrepareLeaveCurrentPage(); + } +//......................................................................... +} // namespace dbaui +//......................................................................... diff --git a/dbaccess/source/ui/dlg/UserAdminDlg.hrc b/dbaccess/source/ui/dlg/UserAdminDlg.hrc new file mode 100644 index 000000000000..c1e023cfc9b7 --- /dev/null +++ b/dbaccess/source/ui/dlg/UserAdminDlg.hrc @@ -0,0 +1,33 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef DBAUI_USERADMINDLG_HRC +#define DBAUI_USERADMINDLG_HRC + +#define STR_PAGETITLE_USERADMIN 1 + + +#endif // DBAUI_USERADMINDLG_HRC diff --git a/dbaccess/source/ui/dlg/UserAdminDlg.src b/dbaccess/source/ui/dlg/UserAdminDlg.src new file mode 100644 index 000000000000..faa7f33302d7 --- /dev/null +++ b/dbaccess/source/ui/dlg/UserAdminDlg.src @@ -0,0 +1,60 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif +#ifndef DBAUI_USERADMINDLG_HRC +#include "UserAdminDlg.hrc" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif + + +TabDialog DLG_DATABASE_USERADMIN +{ + OutputSize = TRUE ; + SVLook = TRUE ; + Moveable = TRUE ; + Closeable = TRUE ; + Hide = TRUE; + HelpId = HID_DSADMIN_USERADMIN; + + TabControl 1 + { + OutputSize = TRUE ; + HelpId = HID_DSADMIN_TABCONTROL; + SingleLine=TRUE; + }; + String STR_PAGETITLE_USERADMIN + { + Text[ en-US ] = "User Settings"; + }; + + Text [ en-US ] = "User administration" ; +}; diff --git a/dbaccess/source/ui/dlg/admincontrols.cxx b/dbaccess/source/ui/dlg/admincontrols.cxx new file mode 100755 index 000000000000..463358e179d5 --- /dev/null +++ b/dbaccess/source/ui/dlg/admincontrols.cxx @@ -0,0 +1,311 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#include "admincontrols.hxx" +#include "admincontrols.hrc" +#include "dbu_dlg.hrc" +#include "dsitems.hxx" +#include "moduledbu.hxx" + +#include <svl/eitem.hxx> +#include <svl/stritem.hxx> +#include <svl/intitem.hxx> + +//........................................................................ +namespace dbaui +{ +//........................................................................ + + //==================================================================== + //= TextResetOperatorEventFilter + //==================================================================== + class TextResetOperatorEventFilter : public ::svt::IWindowEventFilter + { + public: + TextResetOperatorEventFilter() + { + } + + // IWindowEventFilter + virtual bool payAttentionTo( const VclWindowEvent& _rEvent ) const + { + return ( _rEvent.GetId() == VCLEVENT_WINDOW_ENABLED ) + || ( _rEvent.GetId() == VCLEVENT_WINDOW_DISABLED ) + || ( _rEvent.GetId() == VCLEVENT_EDIT_MODIFY ); + } + }; + + //==================================================================== + //= TextResetOperator + //==================================================================== + class TextResetOperator :public ::svt::IWindowOperator + { + public: + TextResetOperator( const String& _rDisabledText ) + :m_sDisabledText( _rDisabledText ) + { + } + + // IWindowOperator + virtual void operateOn( const VclWindowEvent& _rTrigger, Window& _rOperateOn ) const; + + private: + const String m_sDisabledText; + String m_sUserText; + BOOL m_bLastKnownEnabledState; + }; + + //-------------------------------------------------------------------- + void TextResetOperator::operateOn( const VclWindowEvent& _rTrigger, Window& _rOperateOn ) const + { + OSL_ENSURE( _rTrigger.GetWindow() == &_rOperateOn, "TextResetOperator::operateOn: you're misusing this implementation!" ); + + switch ( _rTrigger.GetId() ) + { + case 0: + // initial call + const_cast< TextResetOperator* >( this )->m_sUserText = _rTrigger.GetWindow()->GetText(); + break; + + case VCLEVENT_EDIT_MODIFY: + if ( _rTrigger.GetWindow()->IsEnabled() ) + const_cast< TextResetOperator* >( this )->m_sUserText = _rTrigger.GetWindow()->GetText(); + break; + + case VCLEVENT_WINDOW_ENABLED: + _rOperateOn.SetText( m_sUserText ); + break; + + case VCLEVENT_WINDOW_DISABLED: + _rOperateOn.SetText( m_sDisabledText ); + break; + + default: + OSL_ENSURE( false, "TextResetOperator::operateOn: unexpected event ID!" ); + // all those IDs should have been filtered out by payAttentionTo + break; + } + } + + //==================================================================== + //= TextResetOperatorController + //==================================================================== + class TextResetOperatorController_Base + { + protected: + TextResetOperatorController_Base( const String& _rDisabledText ) + :m_pEventFilter( new TextResetOperatorEventFilter ) + ,m_pOperator( new TextResetOperator( _rDisabledText ) ) + { + } + + inline ::svt::PWindowEventFilter getEventFilter() const { return m_pEventFilter; } + inline ::svt::PWindowOperator getOperator() const { return m_pOperator; } + + private: + ::svt::PWindowEventFilter m_pEventFilter; + ::svt::PWindowOperator m_pOperator; + }; + + class TextResetOperatorController :public TextResetOperatorController_Base + ,public ::svt::DialogController + { + public: + TextResetOperatorController( Window& _rObservee, const String& _rDisabledText ) + :TextResetOperatorController_Base( _rDisabledText ) + ,::svt::DialogController( _rObservee, getEventFilter(), getOperator() ) + { + addDependentWindow( _rObservee ); + } + }; + + //==================================================================== + //= MySQLNativeSettings + //==================================================================== + //-------------------------------------------------------------------- + MySQLNativeSettings::MySQLNativeSettings( Window& _rParent, const Link& _rControlModificationLink ) + :Control( &_rParent, ModuleRes( RID_MYSQL_NATIVE_SETTINGS ).SetAutoRelease( FALSE ) ) + ,m_aDatabaseNameLabel ( this, ModuleRes( FT_MYSQL_DATABASE_NAME ) ) + ,m_aDatabaseName ( this, ModuleRes( ED_MYSQL_DATABASE_NAME ) ) + ,m_aHostPortRadio ( this, ModuleRes( RB_MYSQL_HOST_PORT ) ) + ,m_aSocketRadio ( this, ModuleRes( RB_MYSQL_SOCKET ) ) + ,m_aNamedPipeRadio ( this, ModuleRes( RB_MYSQL_NAMED_PIPE ) ) + ,m_aHostNameLabel ( this, ModuleRes( FT_COMMON_HOST_NAME ) ) + ,m_aHostName ( this, ModuleRes( ED_COMMON_HOST_NAME ) ) + ,m_aPortLabel ( this, ModuleRes( FT_COMMON_PORT ) ) + ,m_aPort ( this, ModuleRes( NF_COMMON_PORT ) ) + ,m_aDefaultPort ( this, ModuleRes( FT_COMMON_PORT_DEFAULT ) ) + ,m_aSocket ( this, ModuleRes( ED_MYSQL_SOCKET ) ) + ,m_aNamedPipe ( this, ModuleRes( ED_MYSQL_NAMED_PIPE ) ) + { + FreeResource(); + + m_aDatabaseName.SetModifyHdl( _rControlModificationLink ); + m_aHostName.SetModifyHdl( _rControlModificationLink ); + m_aPort.SetModifyHdl( _rControlModificationLink ); + m_aNamedPipe.SetModifyHdl( _rControlModificationLink ); + m_aSocketRadio.SetToggleHdl( _rControlModificationLink ); + m_aNamedPipeRadio.SetToggleHdl( _rControlModificationLink ); + + m_aControlDependencies.enableOnRadioCheck( m_aHostPortRadio, m_aHostNameLabel, m_aHostName, m_aPortLabel, m_aPort, m_aDefaultPort ); + m_aControlDependencies.enableOnRadioCheck( m_aSocketRadio, m_aSocket ); + m_aControlDependencies.enableOnRadioCheck( m_aNamedPipeRadio, m_aNamedPipe ); + + m_aControlDependencies.addController( ::svt::PDialogController( + new TextResetOperatorController( m_aHostName, String::CreateFromAscii( "localhost" ) ) + ) ); + + // sockets are available on Unix systems only, named pipes only on Windows +#ifdef UNX + m_aNamedPipeRadio.Hide(); + m_aNamedPipe.Hide(); +#else + m_aSocketRadio.Hide(); + m_aSocket.Hide(); +#endif + } + + //-------------------------------------------------------------------- + MySQLNativeSettings::~MySQLNativeSettings() + { + } + + //-------------------------------------------------------------------- + void MySQLNativeSettings::fillControls( ::std::vector< ISaveValueWrapper* >& _rControlList ) + { + _rControlList.push_back( new OSaveValueWrapper< Edit >( &m_aDatabaseName ) ); + _rControlList.push_back( new OSaveValueWrapper< Edit >( &m_aHostName ) ); + _rControlList.push_back( new OSaveValueWrapper< Edit >( &m_aPort ) ); + _rControlList.push_back( new OSaveValueWrapper< Edit >( &m_aSocket ) ); + _rControlList.push_back( new OSaveValueWrapper< Edit >( &m_aNamedPipe ) ); + } + + //-------------------------------------------------------------------- + void MySQLNativeSettings::fillWindows( ::std::vector< ISaveValueWrapper* >& _rControlList ) + { + _rControlList.push_back( new ODisableWrapper< FixedText >( &m_aDatabaseNameLabel ) ); + _rControlList.push_back( new ODisableWrapper< FixedText >( &m_aHostNameLabel ) ); + _rControlList.push_back( new ODisableWrapper< FixedText >( &m_aPortLabel ) ); + _rControlList.push_back( new ODisableWrapper< FixedText >( &m_aDefaultPort ) ); + _rControlList.push_back( new ODisableWrapper< RadioButton >( &m_aSocketRadio ) ); + _rControlList.push_back( new ODisableWrapper< RadioButton >( &m_aNamedPipeRadio ) ); + } + + //-------------------------------------------------------------------- + BOOL MySQLNativeSettings::FillItemSet( SfxItemSet& _rSet ) + { + sal_Bool bChangedSomething = sal_False; + + OGenericAdministrationPage::fillString( _rSet, &m_aHostName, DSID_CONN_HOSTNAME, bChangedSomething ); + OGenericAdministrationPage::fillString( _rSet, &m_aDatabaseName, DSID_DATABASENAME, bChangedSomething ); + OGenericAdministrationPage::fillInt32 ( _rSet, &m_aPort, DSID_MYSQL_PORTNUMBER, bChangedSomething ); +#ifdef UNX + OGenericAdministrationPage::fillString( _rSet, &m_aSocket, DSID_CONN_SOCKET, bChangedSomething ); +#else + OGenericAdministrationPage::fillString( _rSet, &m_aNamedPipe, DSID_NAMED_PIPE, bChangedSomething ); +#endif + + return bChangedSomething; + } + + //-------------------------------------------------------------------- + void MySQLNativeSettings::implInitControls(const SfxItemSet& _rSet ) + { + SFX_ITEMSET_GET( _rSet, pInvalid, SfxBoolItem, DSID_INVALID_SELECTION, sal_True ); + bool bValid = !pInvalid || !pInvalid->GetValue(); + if ( !bValid ) + return; + + SFX_ITEMSET_GET( _rSet, pDatabaseName, SfxStringItem, DSID_DATABASENAME, sal_True ); + SFX_ITEMSET_GET( _rSet, pHostName, SfxStringItem, DSID_CONN_HOSTNAME, sal_True ); + SFX_ITEMSET_GET( _rSet, pPortNumber, SfxInt32Item, DSID_MYSQL_PORTNUMBER, sal_True ); + SFX_ITEMSET_GET( _rSet, pSocket, SfxStringItem, DSID_CONN_SOCKET, sal_True ); + SFX_ITEMSET_GET( _rSet, pNamedPipe, SfxStringItem, DSID_NAMED_PIPE, sal_True ); + + m_aDatabaseName.SetText( pDatabaseName->GetValue() ); + m_aDatabaseName.ClearModifyFlag(); + + m_aHostName.SetText( pHostName->GetValue() ); + m_aHostName.ClearModifyFlag(); + + m_aPort.SetValue( pPortNumber->GetValue() ); + m_aPort.ClearModifyFlag(); + + m_aSocket.SetText( pSocket->GetValue() ); + m_aSocket.ClearModifyFlag(); + + m_aNamedPipe.SetText( pNamedPipe->GetValue() ); + m_aNamedPipe.ClearModifyFlag(); + + // if a socket (on Unix) or a pipe name (on Windows) is given, this is preferred over + // the port +#ifdef UNX + RadioButton& rSocketPipeRadio = m_aSocketRadio; + const SfxStringItem* pSocketPipeItem = pSocket; +#else + RadioButton& rSocketPipeRadio = m_aNamedPipeRadio; + const SfxStringItem* pSocketPipeItem = pNamedPipe; +#endif + String sSocketPipe( pSocketPipeItem->GetValue() ); + if ( sSocketPipe.Len() > 0 ) + rSocketPipeRadio.Check(); + else + m_aHostPortRadio.Check(); + } + + //-------------------------------------------------------------------- + bool MySQLNativeSettings::canAdvance() const + { + if ( m_aDatabaseName.GetText().Len() == 0 ) + return false; + + if ( m_aHostPortRadio.IsChecked() + && ( ( m_aHostName.GetText().Len() == 0 ) + || ( m_aPort.GetText().Len() == 0 ) + ) + ) + return false; + +#ifdef UNX + if ( ( m_aSocketRadio.IsChecked() ) + && ( m_aSocket.GetText().Len() == 0 ) + ) +#else + if ( ( m_aNamedPipeRadio.IsChecked() ) + && ( m_aNamedPipe.GetText().Len() == 0 ) + ) +#endif + return false; + + return true; + } + +//........................................................................ +} // namespace dbaui +//........................................................................ diff --git a/dbaccess/source/ui/dlg/admincontrols.hrc b/dbaccess/source/ui/dlg/admincontrols.hrc new file mode 100755 index 000000000000..8286bc7f8b25 --- /dev/null +++ b/dbaccess/source/ui/dlg/admincontrols.hrc @@ -0,0 +1,49 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef ADMINCONTROLS_HRC +#define ADMINCONTROLS_HRC + +#define FT_MYSQL_DATABASE_NAME 1 +#define FT_COMMON_HOST_NAME 2 +#define FT_COMMON_PORT_DEFAULT 3 +#define FT_COMMON_PORT 4 + + +#define RB_MYSQL_HOST_PORT 1 +#define RB_MYSQL_SOCKET 2 +#define RB_MYSQL_NAMED_PIPE 3 + + +#define ED_MYSQL_DATABASE_NAME 1 +#define ED_MYSQL_SOCKET 2 +#define ED_COMMON_HOST_NAME 3 +#define ED_MYSQL_NAMED_PIPE 4 + + +#define NF_COMMON_PORT 1 + +#endif // ADMINCONTROLS_HRC diff --git a/dbaccess/source/ui/dlg/admincontrols.hxx b/dbaccess/source/ui/dlg/admincontrols.hxx new file mode 100755 index 000000000000..e4526dffb8d2 --- /dev/null +++ b/dbaccess/source/ui/dlg/admincontrols.hxx @@ -0,0 +1,82 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef DBACCESS_ADMINCONTROLS_HXX +#define DBACCESS_ADMINCONTROLS_HXX + +#include "adminpages.hxx" + +#include <vcl/edit.hxx> +#include <vcl/field.hxx> +#include <vcl/fixed.hxx> + +#include <svtools/dialogcontrolling.hxx> + +//........................................................................ +namespace dbaui +{ +//........................................................................ + + //==================================================================== + //= MySQLNativeSettings + //==================================================================== + class MySQLNativeSettings : public Control + { + private: + FixedText m_aDatabaseNameLabel; + Edit m_aDatabaseName; + RadioButton m_aHostPortRadio; + RadioButton m_aSocketRadio; + RadioButton m_aNamedPipeRadio; + FixedText m_aHostNameLabel; + Edit m_aHostName; + FixedText m_aPortLabel; + NumericField m_aPort; + FixedText m_aDefaultPort; + Edit m_aSocket; + Edit m_aNamedPipe; + + ::svt::ControlDependencyManager + m_aControlDependencies; + + public: + MySQLNativeSettings( Window& _rParent, const Link& _rControlModificationLink ); + ~MySQLNativeSettings(); + + void fillControls( ::std::vector< ISaveValueWrapper* >& _rControlList ); + void fillWindows( ::std::vector< ISaveValueWrapper* >& _rControlList ); + + BOOL FillItemSet( SfxItemSet& _rCoreAttrs ); + void implInitControls( const SfxItemSet& _rSet ); + + bool canAdvance() const; + }; + +//........................................................................ +} // namespace dbaui +//........................................................................ + +#endif // DBACCESS_ADMINCONTROLS_HXX diff --git a/dbaccess/source/ui/dlg/admincontrols.src b/dbaccess/source/ui/dlg/admincontrols.src new file mode 100755 index 000000000000..8ce3bb4030dc --- /dev/null +++ b/dbaccess/source/ui/dlg/admincontrols.src @@ -0,0 +1,131 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#include "AutoControls.hrc" +#include "dbu_dlg.hrc" +#include "admincontrols.hrc" + +#define LINE_HEIGHT ( EDIT_HEIGHT + RELATED_CONTROLS ) +#define SETTINGS_CONTROL_WIDTH ( WIZARD_PAGE_X - 2 * START_X ) +#define COLUMN_WIDTH_1 80 +#define COLUMN_WIDTH_2 ( SETTINGS_CONTROL_WIDTH - COLUMN_WIDTH_1 ) + +Control RID_MYSQL_NATIVE_SETTINGS +{ + DialogControl = TRUE; + Size = MAP_APPFONT( SETTINGS_CONTROL_WIDTH, 5 * LINE_HEIGHT ); + Hide = FALSE; + + FixedText FT_MYSQL_DATABASE_NAME + { + Pos = MAP_APPFONT ( 0, 2 ); + Size = MAP_APPFONT ( COLUMN_WIDTH_1 - UNRELATED_CONTROLS, FIXEDTEXT_HEIGHT ); + Text[ en-US ] = "~Database name"; + }; + + Edit ED_MYSQL_DATABASE_NAME + { + Pos = MAP_APPFONT ( COLUMN_WIDTH_1, 0 ); + Size = MAP_APPFONT ( COLUMN_WIDTH_2, EDIT_HEIGHT ); + Border = TRUE; + }; + + RadioButton RB_MYSQL_HOST_PORT + { + Pos = MAP_APPFONT ( 0, LINE_HEIGHT ); + Size = MAP_APPFONT ( COLUMN_WIDTH_1, FIXEDTEXT_HEIGHT ) ; + Text [ en-US ] = "Se~rver / Port" ; + Group = TRUE; + }; + +#define OPTION_GROUP_START ( LINE_HEIGHT + FIXEDTEXT_HEIGHT + RELATED_CONTROLS ) + + FixedText FT_COMMON_HOST_NAME + { + Pos = MAP_APPFONT ( INDENT_BELOW_RADIO, OPTION_GROUP_START + 2 ); + Size = MAP_APPFONT ( COLUMN_WIDTH_1 - RELATED_CONTROLS - INDENT_BELOW_RADIO, FIXEDTEXT_HEIGHT ); + Text [ en-US ] = "~Server" ; + }; + + Edit ED_COMMON_HOST_NAME + { + Pos = MAP_APPFONT ( COLUMN_WIDTH_1, OPTION_GROUP_START ); + Size = MAP_APPFONT ( COLUMN_WIDTH_2, EDIT_HEIGHT ); + Border = TRUE; + }; + + FixedText FT_COMMON_PORT + { + Pos = MAP_APPFONT ( INDENT_BELOW_RADIO, OPTION_GROUP_START + LINE_HEIGHT + 2 ); + Size = MAP_APPFONT ( COLUMN_WIDTH_1 - RELATED_CONTROLS - INDENT_BELOW_RADIO, FIXEDTEXT_HEIGHT ) ; + Text [ en-US ] = "~Port" ; + Group = TRUE; + }; + + NumericField NF_COMMON_PORT + { + Pos = MAP_APPFONT ( COLUMN_WIDTH_1, OPTION_GROUP_START + LINE_HEIGHT ); + Size = MAP_APPFONT ( 25, EDIT_HEIGHT ); + Border = TRUE; + NoThousandSep = TRUE; + Value = 3306; + }; + + FixedText FT_COMMON_PORT_DEFAULT + { + Pos = MAP_APPFONT ( COLUMN_WIDTH_1 + 25 + RELATED_CONTROLS, OPTION_GROUP_START + LINE_HEIGHT + 2 ); + Size = MAP_APPFONT ( COLUMN_WIDTH_2 - 25 - RELATED_CONTROLS, FIXEDTEXT_HEIGHT ); + Text[ en-US ] = "Default: 3306"; + }; + + RadioButton RB_MYSQL_SOCKET + { + Pos = MAP_APPFONT ( 0, OPTION_GROUP_START + 2 * LINE_HEIGHT + 2 ); + Size = MAP_APPFONT ( COLUMN_WIDTH_1 - RELATED_CONTROLS, FIXEDTEXT_HEIGHT ); + Text [ en-US ] = "So~cket"; + }; + + Edit ED_MYSQL_SOCKET + { + Pos = MAP_APPFONT ( COLUMN_WIDTH_1, OPTION_GROUP_START + 2 * LINE_HEIGHT ); + Size = MAP_APPFONT ( COLUMN_WIDTH_2, EDIT_HEIGHT ); + Border = TRUE ; + }; + + RadioButton RB_MYSQL_NAMED_PIPE + { + Pos = MAP_APPFONT ( 0, OPTION_GROUP_START + 2 * LINE_HEIGHT + 2 ); + Size = MAP_APPFONT ( COLUMN_WIDTH_1 - RELATED_CONTROLS, FIXEDTEXT_HEIGHT ); + Text [ en-US ] = "Named p~ipe"; + }; + + Edit ED_MYSQL_NAMED_PIPE + { + Pos = MAP_APPFONT ( COLUMN_WIDTH_1, OPTION_GROUP_START + 2 * LINE_HEIGHT ); + Size = MAP_APPFONT ( COLUMN_WIDTH_2, EDIT_HEIGHT ); + Border = TRUE ; + }; +}; diff --git a/dbaccess/source/ui/dlg/adminpages.cxx b/dbaccess/source/ui/dlg/adminpages.cxx new file mode 100644 index 000000000000..8e5b61dc9076 --- /dev/null +++ b/dbaccess/source/ui/dlg/adminpages.cxx @@ -0,0 +1,337 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#include "adminpages.hxx" +#include "dbadmin.hrc" +#include "dbadmin.hxx" +#include "dbu_dlg.hrc" +#include <svl/stritem.hxx> +#include <svl/eitem.hxx> +#include <svl/intitem.hxx> +#include "dbustrings.hrc" +#include "dsitems.hxx" +#include "dsselect.hxx" +#include "localresaccess.hxx" +#include "odbcconfig.hxx" +#include "optionalboolitem.hxx" +#include "sqlmessage.hxx" + +#include <osl/file.hxx> +#include <svl/eitem.hxx> +#include <svl/intitem.hxx> +#include <svl/stritem.hxx> +#include <vcl/accel.hxx> +#include <vcl/button.hxx> +#include <vcl/edit.hxx> +#include <vcl/field.hxx> +#include <vcl/lstbox.hxx> +#include <vcl/msgbox.hxx> + +#include <algorithm> +#include <stdlib.h> + +//......................................................................... +namespace dbaui +{ +//......................................................................... + + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::sdbc; + using namespace ::com::sun::star::beans; + using namespace ::com::sun::star::lang; + using namespace ::dbtools; + using namespace ::svt; + + + //========================================================================= + //= OGenericAdministrationPage + //========================================================================= + DBG_NAME(OGenericAdministrationPage) + //------------------------------------------------------------------------- + OGenericAdministrationPage::OGenericAdministrationPage(Window* _pParent, const ResId& _rId, const SfxItemSet& _rAttrSet) + :SfxTabPage(_pParent, _rId, _rAttrSet) + ,m_abEnableRoadmap(sal_False) + ,m_pAdminDialog(NULL) + ,m_pItemSetHelper(NULL) + ,m_pFT_HeaderText(NULL) + { + DBG_CTOR(OGenericAdministrationPage,NULL); + + SetExchangeSupport(sal_True); + } + + //------------------------------------------------------------------------- + OGenericAdministrationPage::~OGenericAdministrationPage() + { + DELETEZ(m_pFT_HeaderText); + + DBG_DTOR(OGenericAdministrationPage,NULL); + } + + //------------------------------------------------------------------------- + int OGenericAdministrationPage::DeactivatePage(SfxItemSet* _pSet) + { + if (_pSet) + { + if (!prepareLeave()) + return KEEP_PAGE; + FillItemSet(*_pSet); + } + + return LEAVE_PAGE; + } + + //------------------------------------------------------------------------- + void OGenericAdministrationPage::Reset(const SfxItemSet& _rCoreAttrs) + { + implInitControls(_rCoreAttrs, sal_False); + } + //------------------------------------------------------------------------- + void OGenericAdministrationPage::ActivatePage() + { + TabPage::ActivatePage(); + OSL_ENSURE(m_pItemSetHelper,"NO ItemSetHelper set!"); + if ( m_pItemSetHelper ) + ActivatePage(*m_pItemSetHelper->getOutputSet()); + } + //------------------------------------------------------------------------- + void OGenericAdministrationPage::ActivatePage(const SfxItemSet& _rSet) + { + implInitControls(_rSet, sal_True); + } + + // ----------------------------------------------------------------------- + void OGenericAdministrationPage::getFlags(const SfxItemSet& _rSet, sal_Bool& _rValid, sal_Bool& _rReadonly) + { + SFX_ITEMSET_GET(_rSet, pInvalid, SfxBoolItem, DSID_INVALID_SELECTION, sal_True); + _rValid = !pInvalid || !pInvalid->GetValue(); + SFX_ITEMSET_GET(_rSet, pReadonly, SfxBoolItem, DSID_READONLY, sal_True); + _rReadonly = !_rValid || (pReadonly && pReadonly->GetValue()); + } + + + // ----------------------------------------------------------------------- + IMPL_LINK(OGenericAdministrationPage, OnControlModified, Control*, EMPTYARG) + { + callModifiedHdl(); + return 0L; + } + // ----------------------------------------------------------------------- + sal_Bool OGenericAdministrationPage::getSelectedDataSource(::rtl::OUString& _sReturn,::rtl::OUString& _sCurr) + { + // collect all ODBC data source names + StringBag aOdbcDatasources; + OOdbcEnumeration aEnumeration; + if (!aEnumeration.isLoaded()) + { + // show an error message + LocalResourceAccess aLocRes( PAGE_GENERAL, RSC_TABPAGE ); + String sError(ModuleRes(STR_COULDNOTLOAD_ODBCLIB)); + sError.SearchAndReplaceAscii("#lib#", aEnumeration.getLibraryName()); + ErrorBox aDialog(this, WB_OK, sError); + aDialog.Execute(); + return sal_False; + } + else + { + aEnumeration.getDatasourceNames(aOdbcDatasources); + // excute the select dialog + ODatasourceSelectDialog aSelector(GetParent(), aOdbcDatasources, false); + if (_sCurr.getLength()) + aSelector.Select(_sCurr); + if ( RET_OK == aSelector.Execute() ) + _sReturn = aSelector.GetSelected(); + } + return sal_True; + } + + // ----------------------------------------------------------------------- + void OGenericAdministrationPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) + { + // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) + sal_Bool bValid, bReadonly; + getFlags(_rSet, bValid, bReadonly); + + ::std::vector< ISaveValueWrapper* > aControlList; + if ( _bSaveValue ) + { + fillControls(aControlList); + ::std::for_each(aControlList.begin(),aControlList.end(),TSaveValueWrapperFunctor()); + } + + if ( bReadonly ) + { + fillWindows(aControlList); + ::std::for_each(aControlList.begin(),aControlList.end(),TDisableWrapperFunctor()); + } + + ::std::for_each(aControlList.begin(),aControlList.end(),TDeleteWrapperFunctor()); + aControlList.clear(); + } + + // ----------------------------------------------------------------------- + void OGenericAdministrationPage::initializePage() + { + OSL_ENSURE(m_pItemSetHelper,"NO ItemSetHelper set!"); + if ( m_pItemSetHelper ) + Reset(*m_pItemSetHelper->getOutputSet()); + } + // ----------------------------------------------------------------------- + sal_Bool OGenericAdministrationPage::commitPage( ::svt::WizardTypes::CommitPageReason ) + { + return sal_True; + } + // ----------------------------------------------------------------------- + bool OGenericAdministrationPage::canAdvance() const + { + return true; + } + // ----------------------------------------------------------------------- + void OGenericAdministrationPage::fillBool( SfxItemSet& _rSet, CheckBox* _pCheckBox, USHORT _nID, sal_Bool& _bChangedSomething, bool _bRevertValue ) + { + if ( (_pCheckBox != NULL ) && ( _pCheckBox->GetState() != _pCheckBox->GetSavedValue() ) ) + { + sal_Bool bValue = _pCheckBox->IsChecked(); + if ( _bRevertValue ) + bValue = !bValue; + + if ( _pCheckBox->IsTriStateEnabled() ) + { + OptionalBoolItem aValue( _nID ); + if ( _pCheckBox->GetState() != STATE_DONTKNOW ) + aValue.SetValue( bValue ); + _rSet.Put( aValue ); + } + else + _rSet.Put( SfxBoolItem( _nID, bValue ) ); + + _bChangedSomething = sal_True; + } + } + // ----------------------------------------------------------------------- + void OGenericAdministrationPage::fillInt32(SfxItemSet& _rSet,NumericField* _pEdit,USHORT _nID,sal_Bool& _bChangedSomething) + { + if( (_pEdit != NULL) && (_pEdit->GetValue() != _pEdit->GetSavedValue().ToInt32()) ) + { + _rSet.Put(SfxInt32Item(_nID, static_cast<INT32>(_pEdit->GetValue()))); + _bChangedSomething = sal_True; + } + } + // ----------------------------------------------------------------------- + void OGenericAdministrationPage::fillString(SfxItemSet& _rSet,Edit* _pEdit,USHORT _nID,sal_Bool& _bChangedSomething) + { + if( (_pEdit != NULL) && (_pEdit->GetText() != _pEdit->GetSavedValue()) ) + { + _rSet.Put(SfxStringItem(_nID, _pEdit->GetText())); + _bChangedSomething = sal_True; + } + } + + void OGenericAdministrationPage::SetControlFontWeight(Window* _pWindow, FontWeight _eWeight) + { + Font aFont = _pWindow->GetControlFont(); + aFont.SetWeight( _eWeight ); + _pWindow->SetControlFont( aFont ); + } + + // ----------------------------------------------------------------------- + IMPL_LINK(OGenericAdministrationPage, OnTestConnectionClickHdl, PushButton*, /*_pButton*/) + { + OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF"); + sal_Bool bSuccess = sal_False; + if ( m_pAdminDialog ) + { + m_pAdminDialog->saveDatasource(); + OGenericAdministrationPage::implInitControls(*m_pItemSetHelper->getOutputSet(), sal_True); + sal_Bool bShowMessage = sal_True; + try + { + ::std::pair< Reference<XConnection>,sal_Bool> xConnection = m_pAdminDialog->createConnection(); + bShowMessage = xConnection.second; + bSuccess = xConnection.first.is(); + ::comphelper::disposeComponent(xConnection.first); + } + catch(Exception&) + { + } + if ( bShowMessage ) + { + OSQLMessageBox::MessageType eImage = OSQLMessageBox::Info; + String aMessage,sTitle; + sTitle = String (ModuleRes(STR_CONNECTION_TEST)); + if ( bSuccess ) + { + aMessage = String(ModuleRes(STR_CONNECTION_SUCCESS)); + } + else + { + eImage = OSQLMessageBox::Error; + aMessage = String(ModuleRes(STR_CONNECTION_NO_SUCCESS)); + } + OSQLMessageBox aMsg( this, sTitle, aMessage, WB_OK, eImage ); + aMsg.Execute(); + } + if ( !bSuccess ) + m_pAdminDialog->clearPassword(); + } + return 0L; + } + + void OGenericAdministrationPage::SetHeaderText( USHORT _nFTResId, USHORT _StringResId) + { + delete(m_pFT_HeaderText); + m_pFT_HeaderText = new FixedText(this, ModuleRes(_nFTResId)); + String sHeaderText = String(ModuleRes(_StringResId)); + m_pFT_HeaderText->SetText(sHeaderText); + SetControlFontWeight(m_pFT_HeaderText); + } + + + //========================================================================= + //= LayoutHelper + //========================================================================= + //------------------------------------------------------------------------- + void LayoutHelper::positionBelow( const Control& _rReference, Control& _rControl, const ControlRelation _eRelation, + const long _nIndentAppFont ) + { + Point aReference = _rReference.GetPosPixel(); + aReference.Y() += _rReference.GetSizePixel().Height(); + + const Window* pConverter = _rControl.GetParent(); + Size aOffset = pConverter->LogicToPixel( Size( _nIndentAppFont, ( _eRelation == RelatedControls ? 3 : 6 ) ), MAP_APPFONT ); + + Point aControlPos( aReference.X() + aOffset.Width(), aReference.Y() + aOffset.Height() ); + _rControl.SetPosPixel( aControlPos ); + } + +//......................................................................... +} // namespace dbaui +//......................................................................... + diff --git a/dbaccess/source/ui/dlg/adminpages.hxx b/dbaccess/source/ui/dlg/adminpages.hxx new file mode 100644 index 000000000000..32ba0064a824 --- /dev/null +++ b/dbaccess/source/ui/dlg/adminpages.hxx @@ -0,0 +1,299 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBAUI_ADMINPAGES_HXX_ +#define _DBAUI_ADMINPAGES_HXX_ + +#ifndef _SFXTABDLG_HXX +#include <sfx2/tabdlg.hxx> +#endif +#ifndef _DBAUI_DSNTYPES_HXX_ +#include "dsntypes.hxx" +#endif +#ifndef _DBAUI_COMMON_TYPES_HXX_ +#include "commontypes.hxx" +#endif +#ifndef _SVTOOLS_WIZARDMACHINE_HXX_ +#include <svtools/wizardmachine.hxx> +#endif +#ifndef _SV_FIELD_HXX +#include <vcl/field.hxx> +#endif +#ifndef _SV_FIXED_HXX +#include <vcl/fixed.hxx> +#endif + + +class NumericField; +class Edit; +//......................................................................... +namespace dbaui +{ +//......................................................................... + /// helper class to wrap the savevalue and disable call + class SAL_NO_VTABLE ISaveValueWrapper + { + public: + virtual bool SaveValue() = 0; + virtual bool Disable() = 0; + }; + + template < class T > class OSaveValueWrapper : public ISaveValueWrapper + { + T* m_pSaveValue; + public: + OSaveValueWrapper(T* _pSaveValue) : m_pSaveValue(_pSaveValue) + { OSL_ENSURE(m_pSaveValue,"Illegal argument!"); } + + virtual bool SaveValue() { m_pSaveValue->SaveValue(); return true;} // bool return value only for stl + virtual bool Disable() { m_pSaveValue->Disable(); return true;} // bool return value only for stl + }; + + template < class T > class ODisableWrapper : public ISaveValueWrapper + { + T* m_pSaveValue; + public: + ODisableWrapper(T* _pSaveValue) : m_pSaveValue(_pSaveValue) + { OSL_ENSURE(m_pSaveValue,"Illegal argument!"); } + + virtual bool SaveValue() { return true;} // bool return value only for stl + virtual bool Disable() { m_pSaveValue->Disable(); return true;} // bool return value only for stl + }; + + struct TSaveValueWrapperFunctor : public ::std::unary_function< ISaveValueWrapper, bool> + { + bool operator() (ISaveValueWrapper* lhs) + { + return lhs->SaveValue(); + } + }; + struct TDisableWrapperFunctor : public ::std::unary_function< ISaveValueWrapper, bool> + { + bool operator() (ISaveValueWrapper* lhs) + { + return lhs->Disable(); + } + }; + + struct TDeleteWrapperFunctor : public ::std::unary_function< ISaveValueWrapper, bool> + { + bool operator() (ISaveValueWrapper* lhs) + { + delete lhs; + return true; + } + }; + + //========================================================================= + //= OGenericAdministrationPage + //========================================================================= + class IDatabaseSettingsDialog; + class IItemSetHelper; + class OGenericAdministrationPage :public SfxTabPage + ,public ::svt::IWizardPageController + { + private: + Link m_aModifiedHandler; /// to be called if something on the page has been modified + sal_Bool m_abEnableRoadmap; + protected: + IDatabaseSettingsDialog* m_pAdminDialog; + IItemSetHelper* m_pItemSetHelper; + FixedText* m_pFT_HeaderText; + + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > + m_xORB; + public: + OGenericAdministrationPage(Window* _pParent, const ResId& _rId, const SfxItemSet& _rAttrSet); + ~OGenericAdministrationPage(); + + /// set a handler which gets called every time something on the page has been modified + void SetModifiedHandler(const Link& _rHandler) { m_aModifiedHandler = _rHandler; } + + /** Sets the ParentDialog + @param _pAdminDialog + the ParentDialog + @param _pItemSetHelper + the itemset helper + */ + inline void SetAdminDialog(IDatabaseSettingsDialog* _pDialog,IItemSetHelper* _pItemSetHelper) + { + OSL_ENSURE(_pDialog && _pItemSetHelper,"Values are NULL!"); + m_pAdminDialog = _pDialog; + m_pItemSetHelper = _pItemSetHelper; + } + + /** Sets the ServiceFactory + @param _rxORB + The service factory. + */ + virtual void SetServiceFactory(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxORB) + { + m_xORB = _rxORB; + } + + /** opens a dialog filled with all data sources available for this type and + returns the selected on. + @param _eType + The type for which the data source dialog should be opened. + @param _sReturn + <OUT/> contains the selected name. + @return + <FALSE/> if an error occured, otherwise <TRUE/> + */ + sal_Bool getSelectedDataSource(::rtl::OUString& _sReturn,::rtl::OUString& _sCurr); + + // svt::IWizardPageController + virtual void initializePage(); + virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ); + virtual bool canAdvance() const; + + void SetRoadmapStateValue( sal_Bool _bDoEnable ) { m_abEnableRoadmap = _bDoEnable; } + bool GetRoadmapStateValue() const { return m_abEnableRoadmap; } + + protected: + /// default implementation: call FillItemSet, call prepareLeave, + virtual int DeactivatePage(SfxItemSet* pSet); + using SfxTabPage::DeactivatePage; + /// default implementation: call implInitControls with the given item set and _bSaveValue = sal_False + virtual void Reset(const SfxItemSet& _rCoreAttrs); + /// default implementation: call implInitControls with the given item set and _bSaveValue = sal_True + virtual void ActivatePage(const SfxItemSet& _rSet); + + // TabPage overridables + virtual void ActivatePage(); + + protected: + void callModifiedHdl() const { if (m_aModifiedHandler.IsSet()) m_aModifiedHandler.Call((void*)this); } + + /// called from within DeactivatePage. The page is allowed to be deactivated if this method returns sal_True + virtual sal_Bool prepareLeave() { return sal_True; } + + /** called from within Reset and ActivatePage, use to initialize the controls with the items from the given set + @param _bSaveValue if set to sal_True, the implementation should call SaveValue on all relevant controls + */ + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + + /// analyze the invalid and the readonly flag which may be present in the set + void getFlags(const SfxItemSet& _rSet, sal_Bool& _rValid, sal_Bool& _rReadonly); + + /** will be called inside <method>implInitControls</method> to save the value if necessary + @param _rControlList + The list must be filled with the controls. + It is not allowed to clear the list before pusching data into it. + */ + virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) = 0; + + /** will be called inside <method>implInitControls</method> to disable if necessary + @param _rControlList + The list must be filled with the controls. + It is not allowed to clear the list before pusching data into it. + */ + virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) = 0; + + public: + /** fills the Boolean value into the item set when the value changed. + @param _rSet + The item set where to put the new value into. + @param _pCheckBox + The check box which is checked. + @param _nID + The id in the itemset to set whith the new value. + @param _bChangedSomething + <TRUE/> if something changed otherwise <FALSE/> + @param _bRevertValue + set to <TRUE/> if the display value should be reverted before putting it into the set + */ + static void fillBool( SfxItemSet& _rSet, CheckBox* _pCheckBox, USHORT _nID, sal_Bool& _bChangedSomething, bool _bRevertValue = false); + + /** fills the int value into the item set when the value changed. + @param _rSet + The item set where to put the new value into. + @param _pEdit + The check box which is checked. + @param _nID + The id in the itemset to set whith the new value. + @param _bChangedSomething + <TRUE/> if something changed otherwise <FALSE/> + */ + static void fillInt32(SfxItemSet& _rSet,NumericField* _pEdit,USHORT _nID,sal_Bool& _bChangedSomething); + + /** fills the String value into the item set when the value changed. + @param _rSet + The item set where to put the new value into. + @param _pEdit + The check box which is checked. + @param _nID + The id in the itemset to set whith the new value. + @param _bChangedSomething + <TRUE/> if something changed otherwise <FALSE/> + */ + static void fillString(SfxItemSet& _rSet,Edit* _pEdit,USHORT _nID,sal_Bool& _bChangedSomething); + + protected: + // used to set the right Pane header of a wizard to bold + void SetControlFontWeight(Window* _pWindow, FontWeight _eWeight = WEIGHT_BOLD); + void SetHeaderText( USHORT _nFTResId, USHORT _StringResId); + + /** This link be used for controls where the tabpage does not need to take any special action when the control + is modified. The implementation just calls callModifiedHdl. + */ + DECL_LINK(OnControlModified, Control*); + DECL_LINK(OnTestConnectionClickHdl,PushButton*); + + /// may be used in SetXXXHdl calls to controls, is a link to <method>OnControlModified</method> + virtual Link getControlModifiedLink() { return LINK(this, OGenericAdministrationPage, OnControlModified); } + }; + + //========================================================================= + //= ControlRelation + //========================================================================= + enum ControlRelation + { + RelatedControls, UnrelatedControls + }; + + //========================================================================= + //= LayoutHelper + //========================================================================= + class LayoutHelper + { + public: + static void positionBelow( + const Control& _rReference, + Control& _rControl, + const ControlRelation _eRelation, + const long _nIndentAppFont + ); + }; + +//......................................................................... +} // namespace dbaui +//......................................................................... + +#endif // _DBAUI_ADMINPAGES_HXX_ + + diff --git a/dbaccess/source/ui/dlg/adodatalinks.cxx b/dbaccess/source/ui/dlg/adodatalinks.cxx new file mode 100644 index 000000000000..30dddc0bb793 --- /dev/null +++ b/dbaccess/source/ui/dlg/adodatalinks.cxx @@ -0,0 +1,211 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + + +#if defined(WIN) || defined(WNT) +#if defined _MSC_VER +#pragma warning(push, 1) +#pragma warning(disable: 4917) +#endif +#include "msdasc.h" // OLE DB Service Component header +#if defined _MSC_VER +#pragma warning(push, 1) +#endif +#include "stdio.h" + +#include <initguid.h> // Include only once in your application +#include <adoid.h> // needed for CLSID_CADOConnection +#include <adoint.h> // needed for ADOConnection + +#ifndef _DBAUI_ADO_DATALINK_HXX_ +#include "adodatalinks.hxx" +#endif + +BSTR PromptEdit(long hWnd,BSTR connstr); +BSTR PromptNew(long hWnd); + +::rtl::OUString getAdoDatalink(long hWnd,::rtl::OUString& oldLink) +{ + ::rtl::OUString dataLink; + if (oldLink.getLength()) + { + dataLink=reinterpret_cast<sal_Unicode *>(PromptEdit(hWnd,(BSTR)oldLink.getStr())); + } + else + dataLink=reinterpret_cast<sal_Unicode *>(PromptNew(hWnd)); + return dataLink; +} +BSTR PromptNew(long hWnd) +{ + BSTR connstr=NULL; + HRESULT hr; + IDataSourceLocator* dlPrompt = NULL; + ADOConnection* piTmpConnection = NULL; + BSTR _result=NULL; + + // Initialize COM + ::CoInitialize( NULL ); + + // Instantiate DataLinks object. + hr = CoCreateInstance( + CLSID_DataLinks, //clsid -- Data Links UI + NULL, //pUnkOuter + CLSCTX_INPROC_SERVER, //dwClsContext + IID_IDataSourceLocator, //riid + (void**)&dlPrompt //ppvObj + ); + if( FAILED( hr ) ) + { + piTmpConnection->Release( ); + dlPrompt->Release( ); + return connstr; + } + + dlPrompt->put_hWnd(hWnd); + if( FAILED( hr ) ) + { + piTmpConnection->Release( ); + dlPrompt->Release( ); + return connstr; + } + + // Prompt for connection information. + hr = dlPrompt->PromptNew((IDispatch **)&piTmpConnection); + + if( FAILED( hr ) || !piTmpConnection ) + { + dlPrompt->Release( ); + return connstr; + } + + hr = piTmpConnection->get_ConnectionString(&_result); + if( FAILED( hr ) ) + { + piTmpConnection->Release( ); + dlPrompt->Release( ); + return connstr; + } + + piTmpConnection->Release( ); + dlPrompt->Release( ); + CoUninitialize(); + return _result; +} + +BSTR PromptEdit(long hWnd,BSTR connstr) +{ + HRESULT hr; + IDataSourceLocator* dlPrompt = NULL; + ADOConnection* piTmpConnection = NULL; + BSTR _result=NULL; + + // Initialize COM + ::CoInitialize( NULL ); + + hr = CoCreateInstance(CLSID_CADOConnection, + NULL, + CLSCTX_INPROC_SERVER, + IID_IADOConnection, + (LPVOID *)&piTmpConnection); + if( FAILED( hr ) ) + { + piTmpConnection->Release( ); + return connstr; + } + + + hr = piTmpConnection->put_ConnectionString(connstr); + if( FAILED( hr ) ) + { + piTmpConnection->Release( ); + return connstr; + } + + // Instantiate DataLinks object. + hr = CoCreateInstance( + CLSID_DataLinks, //clsid -- Data Links UI + NULL, //pUnkOuter + CLSCTX_INPROC_SERVER, //dwClsContext + IID_IDataSourceLocator, //riid + (void**)&dlPrompt //ppvObj + ); + if( FAILED( hr ) ) + { + piTmpConnection->Release( ); + dlPrompt->Release( ); + return connstr; + } + + dlPrompt->put_hWnd(hWnd); + if( FAILED( hr ) ) + { + piTmpConnection->Release( ); + dlPrompt->Release( ); + return connstr; + } + + VARIANT_BOOL pbSuccess; + + // Prompt for connection information. + hr = dlPrompt->PromptEdit((IDispatch **)&piTmpConnection,&pbSuccess); + if( SUCCEEDED( hr ) && FALSE == pbSuccess ) //if user press cancel then FALSE == pbSuccess + { + piTmpConnection->Release( ); + dlPrompt->Release( ); + return connstr; + } + + if( FAILED( hr ) ) + { + // Prompt for new connection information. + piTmpConnection->Release( ); + piTmpConnection = NULL; + hr = dlPrompt->PromptNew((IDispatch **)&piTmpConnection); + if( FAILED( hr ) || !piTmpConnection ) + { + dlPrompt->Release( ); + return connstr; + } + } + + hr = piTmpConnection->get_ConnectionString(&_result); + if( FAILED( hr ) ) + { + piTmpConnection->Release( ); + dlPrompt->Release( ); + return connstr; + } + + piTmpConnection->Release( ); + dlPrompt->Release( ); + CoUninitialize(); + return _result; +} +#endif diff --git a/dbaccess/source/ui/dlg/adodatalinks.hxx b/dbaccess/source/ui/dlg/adodatalinks.hxx new file mode 100644 index 000000000000..7daf5cda61e0 --- /dev/null +++ b/dbaccess/source/ui/dlg/adodatalinks.hxx @@ -0,0 +1,39 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBAUI_ADO_DATALINK_HXX_ +#define _DBAUI_ADO_DATALINK_HXX_ + +#ifndef _OSL_MODULE_H_ +#include <osl/module.h> +#endif +#ifndef _DBAUI_COMMON_TYPES_HXX_ +#include "commontypes.hxx" +#endif + +::rtl::OUString getAdoDatalink(long hWnd,::rtl::OUString& oldLink); +#endif
\ No newline at end of file diff --git a/dbaccess/source/ui/dlg/adtabdlg.cxx b/dbaccess/source/ui/dlg/adtabdlg.cxx new file mode 100644 index 000000000000..a4914cd45cc5 --- /dev/null +++ b/dbaccess/source/ui/dlg/adtabdlg.cxx @@ -0,0 +1,533 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#include "adtabdlg.hxx" +#include "adtabdlg.hrc" +#include "sqlmessage.hxx" +#include <tools/debug.hxx> +#include <tools/diagnose_ex.h> +#include <svtools/localresaccess.hxx> +#include "dbaccess_helpid.hrc" +#include "dbu_resource.hrc" +#include "dbu_dlg.hrc" +#include <sfx2/sfxsids.hrc> +#include "QueryTableView.hxx" +#include "QueryDesignView.hxx" +#include "querycontroller.hxx" +#include <connectivity/dbtools.hxx> +#include "browserids.hxx" +#include <com/sun/star/sdb/XQueriesSupplier.hpp> +#include <com/sun/star/sdbcx/XViewsSupplier.hpp> +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include "UITools.hxx" +#include "imageprovider.hxx" + +#include <comphelper/containermultiplexer.hxx> +#include "cppuhelper/basemutex.hxx" +#include <algorithm> + +// slot ids +using namespace dbaui; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::sdb; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::sdbcx; +using namespace dbtools; + +//============================================================================== +//= TableObjectListFacade +//============================================================================== +TableObjectListFacade::~TableObjectListFacade() +{ +} + +//============================================================================== +//= TableListFacade +//============================================================================== +class TableListFacade : public ::cppu::BaseMutex + , public TableObjectListFacade + , public ::comphelper::OContainerListener +{ + OTableTreeListBox& m_rTableList; + Reference< XConnection > m_xConnection; + ::rtl::Reference< comphelper::OContainerListenerAdapter> + m_pContainerListener; + bool m_bAllowViews; + +public: + TableListFacade( OTableTreeListBox& _rTableList, const Reference< XConnection >& _rxConnection ) + : ::comphelper::OContainerListener(m_aMutex) + ,m_rTableList( _rTableList ) + ,m_xConnection( _rxConnection ) + ,m_bAllowViews(true) + { + } + virtual ~TableListFacade(); + + +private: + virtual void updateTableObjectList( bool _bAllowViews ); + virtual String getSelectedName( String& _out_rAliasName ) const; + virtual bool isLeafSelected() const; + // OContainerListener + virtual void _elementInserted( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException); + virtual void _elementRemoved( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException); + virtual void _elementReplaced( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException); +}; + +TableListFacade::~TableListFacade() +{ + if ( m_pContainerListener.is() ) + m_pContainerListener->dispose(); +} +//------------------------------------------------------------------------------ +String TableListFacade::getSelectedName( String& _out_rAliasName ) const +{ + SvLBoxEntry* pEntry = m_rTableList.FirstSelected(); + if ( !pEntry ) + return String(); + + ::rtl::OUString aCatalog, aSchema, aTableName; + SvLBoxEntry* pSchema = m_rTableList.GetParent(pEntry); + if(pSchema && pSchema != m_rTableList.getAllObjectsEntry()) + { + SvLBoxEntry* pCatalog = m_rTableList.GetParent(pSchema); + if(pCatalog && pCatalog != m_rTableList.getAllObjectsEntry()) + aCatalog = m_rTableList.GetEntryText(pCatalog); + aSchema = m_rTableList.GetEntryText(pSchema); + } + aTableName = m_rTableList.GetEntryText(pEntry); + + ::rtl::OUString aComposedName; + try + { + Reference< XDatabaseMetaData > xMeta( m_xConnection->getMetaData(), UNO_QUERY_THROW ); + if ( !aCatalog.getLength() + && aSchema.getLength() + && xMeta->supportsCatalogsInDataManipulation() + && !xMeta->supportsSchemasInDataManipulation() ) + { + aCatalog = aSchema; + aSchema = ::rtl::OUString(); + } + + aComposedName = ::dbtools::composeTableName( + xMeta, aCatalog, aSchema, aTableName, sal_False, ::dbtools::eInDataManipulation ); + } + catch ( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + _out_rAliasName = aTableName; + return aComposedName; +} +// ----------------------------------------------------------------------------- +void TableListFacade::_elementInserted( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException) +{ + updateTableObjectList(m_bAllowViews); +} +// ----------------------------------------------------------------------------- +void TableListFacade::_elementRemoved( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException) +{ + updateTableObjectList(m_bAllowViews); +} +// ----------------------------------------------------------------------------- +void TableListFacade::_elementReplaced( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException) +{ +} +//------------------------------------------------------------------------------ +void TableListFacade::updateTableObjectList( bool _bAllowViews ) +{ + m_bAllowViews = _bAllowViews; + m_rTableList.Clear(); + try + { + Reference< XTablesSupplier > xTableSupp( m_xConnection, UNO_QUERY_THROW ); + + Reference< XViewsSupplier > xViewSupp; + Reference< XNameAccess > xTables, xViews; + Sequence< ::rtl::OUString > sTables, sViews; + + xTables = xTableSupp->getTables(); + if ( xTables.is() ) + { + if ( !m_pContainerListener.is() ) + { + Reference< XContainer> xContainer(xTables,uno::UNO_QUERY); + if ( xContainer.is() ) + m_pContainerListener = new ::comphelper::OContainerListenerAdapter(this,xContainer); + } + sTables = xTables->getElementNames(); + } // if ( xTables.is() ) + + xViewSupp.set( xTableSupp, UNO_QUERY ); + if ( xViewSupp.is() ) + { + xViews = xViewSupp->getViews(); + if ( xViews.is() ) + sViews = xViews->getElementNames(); + } + + // if no views are allowed remove the views also out the table name filter + if ( !_bAllowViews ) + { + const ::rtl::OUString* pTableBegin = sTables.getConstArray(); + const ::rtl::OUString* pTableEnd = pTableBegin + sTables.getLength(); + ::std::vector< ::rtl::OUString > aTables(pTableBegin,pTableEnd); + + const ::rtl::OUString* pViewBegin = sViews.getConstArray(); + const ::rtl::OUString* pViewEnd = pViewBegin + sViews.getLength(); + ::comphelper::TStringMixEqualFunctor aEqualFunctor; + for(;pViewBegin != pViewEnd;++pViewBegin) + aTables.erase(::std::remove_if(aTables.begin(),aTables.end(),::std::bind2nd(aEqualFunctor,*pViewBegin)),aTables.end()); + ::rtl::OUString* pTables = aTables.empty() ? 0 : &aTables[0]; + sTables = Sequence< ::rtl::OUString>(pTables, aTables.size()); + sViews = Sequence< ::rtl::OUString>(); + } + + m_rTableList.UpdateTableList( m_xConnection, sTables, sViews ); + SvLBoxEntry* pEntry = m_rTableList.First(); + while( pEntry && m_rTableList.GetModel()->HasChilds( pEntry ) ) + { + m_rTableList.Expand( pEntry ); + pEntry = m_rTableList.Next( pEntry ); + } + if ( pEntry ) + m_rTableList.Select(pEntry); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +//------------------------------------------------------------------------------ +bool TableListFacade::isLeafSelected() const +{ + SvLBoxEntry* pEntry = m_rTableList.FirstSelected(); + return pEntry && !m_rTableList.GetModel()->HasChilds( pEntry ); +} + +//============================================================================== +//= QueryListFacade +//============================================================================== +class QueryListFacade : public ::cppu::BaseMutex + , public TableObjectListFacade + , public ::comphelper::OContainerListener +{ + SvTreeListBox& m_rQueryList; + Reference< XConnection > m_xConnection; + ::rtl::Reference< comphelper::OContainerListenerAdapter> + m_pContainerListener; + +public: + QueryListFacade( SvTreeListBox& _rQueryList, const Reference< XConnection >& _rxConnection ) + : ::comphelper::OContainerListener(m_aMutex) + ,m_rQueryList( _rQueryList ) + ,m_xConnection( _rxConnection ) + { + } + virtual ~QueryListFacade(); +private: + virtual void updateTableObjectList( bool _bAllowViews ); + virtual String getSelectedName( String& _out_rAliasName ) const; + virtual bool isLeafSelected() const; + // OContainerListener + virtual void _elementInserted( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException); + virtual void _elementRemoved( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException); + virtual void _elementReplaced( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException); +}; +QueryListFacade::~QueryListFacade() +{ + if ( m_pContainerListener.is() ) + m_pContainerListener->dispose(); +} +// ----------------------------------------------------------------------------- +void QueryListFacade::_elementInserted( const container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException) +{ + ::rtl::OUString sName; + if ( _rEvent.Accessor >>= sName ) + m_rQueryList.InsertEntry( sName ); +} +// ----------------------------------------------------------------------------- +void QueryListFacade::_elementRemoved( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException) +{ + updateTableObjectList(true); +} +// ----------------------------------------------------------------------------- +void QueryListFacade::_elementReplaced( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException) +{ +} + +//------------------------------------------------------------------------------ +void QueryListFacade::updateTableObjectList( bool /*_bAllowViews*/ ) +{ + m_rQueryList.Clear(); + try + { + ImageProvider aImageProvider( m_xConnection ); + Image aQueryImage( aImageProvider.getDefaultImage( DatabaseObject::QUERY, false ) ); + Image aQueryImageHC( aImageProvider.getDefaultImage( DatabaseObject::QUERY, true ) ); + + m_rQueryList.SetDefaultExpandedEntryBmp( aQueryImage, BMP_COLOR_NORMAL ); + m_rQueryList.SetDefaultCollapsedEntryBmp( aQueryImage, BMP_COLOR_NORMAL ); + m_rQueryList.SetDefaultExpandedEntryBmp( aQueryImageHC, BMP_COLOR_HIGHCONTRAST ); + m_rQueryList.SetDefaultCollapsedEntryBmp( aQueryImageHC, BMP_COLOR_HIGHCONTRAST ); + + Reference< XQueriesSupplier > xSuppQueries( m_xConnection, UNO_QUERY_THROW ); + Reference< XNameAccess > xQueries( xSuppQueries->getQueries(), UNO_QUERY_THROW ); + if ( !m_pContainerListener.is() ) + { + Reference< XContainer> xContainer(xQueries,UNO_QUERY_THROW); + m_pContainerListener = new ::comphelper::OContainerListenerAdapter(this,xContainer); + } + Sequence< ::rtl::OUString > aQueryNames = xQueries->getElementNames(); + + const ::rtl::OUString* pQuery = aQueryNames.getConstArray(); + const ::rtl::OUString* pQueryEnd = aQueryNames.getConstArray() + aQueryNames.getLength(); + while ( pQuery != pQueryEnd ) + m_rQueryList.InsertEntry( *pQuery++ ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +//------------------------------------------------------------------------------ +String QueryListFacade::getSelectedName( String& _out_rAliasName ) const +{ + String sSelected; + SvLBoxEntry* pEntry = m_rQueryList.FirstSelected(); + if ( pEntry ) + sSelected = _out_rAliasName = m_rQueryList.GetEntryText( pEntry ); + return sSelected; +} + +//------------------------------------------------------------------------------ +bool QueryListFacade::isLeafSelected() const +{ + SvLBoxEntry* pEntry = m_rQueryList.FirstSelected(); + return pEntry && !m_rQueryList.GetModel()->HasChilds( pEntry ); +} + +//============================================================================== +//= OAddTableDlg +//============================================================================== +//------------------------------------------------------------------------------ +OAddTableDlg::OAddTableDlg( Window* pParent, IAddTableDialogContext& _rContext ) + :ModelessDialog( pParent, ModuleRes(DLG_JOIN_TABADD) ) + ,m_aCaseTables( this, ModuleRes( RB_CASE_TABLES ) ) + ,m_aCaseQueries( this, ModuleRes( RB_CASE_QUERIES ) ) + ,m_aTableList( this, NULL, ModuleRes( LB_TABLE_OR_QUERY ), sal_False ) + ,m_aQueryList( this, ModuleRes( LB_TABLE_OR_QUERY ) ) + ,aAddButton( this, ModuleRes( PB_ADDTABLE ) ) + ,aCloseButton( this, ModuleRes( PB_CLOSE ) ) + ,aHelpButton( this, ModuleRes( PB_HELP ) ) + ,m_rContext( _rContext ) +{ + // der Close-Button hat schon einen Standard-Help-Text, den ich aber hier nicht haben moechte, also den Text ruecksetzen + // und eine neue ID verteilen + aCloseButton.SetHelpText(String()); + aCloseButton.SetHelpId(HID_JOINSH_ADDTAB_CLOSE); + + m_aTableList.SetHelpId( HID_JOINSH_ADDTAB_TABLELIST ); + m_aQueryList.SetHelpId( HID_JOINSH_ADDTAB_QUERYLIST ); + + ////////////////////////////////////////////////////////////////////// + m_aCaseTables.SetClickHdl( LINK( this, OAddTableDlg, OnTypeSelected ) ); + m_aCaseQueries.SetClickHdl( LINK( this, OAddTableDlg, OnTypeSelected ) ); + aAddButton.SetClickHdl( LINK( this, OAddTableDlg, AddClickHdl ) ); + aCloseButton.SetClickHdl( LINK( this, OAddTableDlg, CloseClickHdl ) ); + m_aTableList.SetDoubleClickHdl( LINK( this, OAddTableDlg, TableListDoubleClickHdl ) ); + m_aTableList.SetSelectHdl( LINK( this, OAddTableDlg, TableListSelectHdl ) ); + m_aQueryList.SetDoubleClickHdl( LINK( this, OAddTableDlg, TableListDoubleClickHdl ) ); + m_aQueryList.SetSelectHdl( LINK( this, OAddTableDlg, TableListSelectHdl ) ); + + ////////////////////////////////////////////////////////////////////// + m_aTableList.EnableInplaceEditing( FALSE ); + m_aTableList.SetWindowBits(WB_BORDER | WB_HASLINES |WB_HASBUTTONS | WB_HASBUTTONSATROOT | WB_HASLINESATROOT | WB_SORT | WB_HSCROLL ); + m_aTableList.EnableCheckButton( NULL ); // do not show any buttons + m_aTableList.SetSelectionMode( SINGLE_SELECTION ); + m_aTableList.notifyHiContrastChanged(); + m_aTableList.suppressEmptyFolders(); + + ////////////////////////////////////////////////////////////////////// + m_aQueryList.EnableInplaceEditing( FALSE ); + m_aQueryList.SetSelectionMode( SINGLE_SELECTION ); + + ////////////////////////////////////////////////////////////////////// + if ( !m_rContext.allowQueries() ) + { + m_aCaseTables.Hide(); + m_aCaseQueries.Hide(); + + long nPixelDiff = m_aTableList.GetPosPixel().Y() - m_aCaseTables.GetPosPixel().Y(); + + Point aListPos( m_aTableList.GetPosPixel() ); + aListPos.Y() -= nPixelDiff; + + Size aListSize( m_aTableList.GetSizePixel() ); + aListSize.Height() += nPixelDiff; + + m_aTableList.SetPosSizePixel( aListPos, aListSize ); + } + + FreeResource(); + + SetText( getDialogTitleForContext( m_rContext ) ); +} + +//------------------------------------------------------------------------------ +OAddTableDlg::~OAddTableDlg() +{ + m_rContext.onWindowClosing( this ); +} + +//------------------------------------------------------------------------------ +void OAddTableDlg::impl_switchTo( ObjectList _eList ) +{ + switch ( _eList ) + { + case Tables: + m_aTableList.Show( TRUE ); m_aCaseTables.Check( TRUE ); + m_aQueryList.Show( FALSE ); m_aCaseQueries.Check( FALSE ); + m_pCurrentList.reset( new TableListFacade( m_aTableList, m_rContext.getConnection() ) ); + m_aTableList.GrabFocus(); + break; + + case Queries: + m_aTableList.Show( FALSE ); m_aCaseTables.Check( FALSE ); + m_aQueryList.Show( TRUE ); m_aCaseQueries.Check( TRUE ); + m_pCurrentList.reset( new QueryListFacade( m_aQueryList, m_rContext.getConnection() ) ); + m_aQueryList.GrabFocus(); + break; + } + m_pCurrentList->updateTableObjectList( m_rContext.allowViews() ); +} + +//------------------------------------------------------------------------------ +void OAddTableDlg::Update() +{ + if ( !m_pCurrentList.get() ) + impl_switchTo( Tables ); + else + m_pCurrentList->updateTableObjectList( m_rContext.allowViews() ); +} + +//------------------------------------------------------------------------------ +void OAddTableDlg::impl_addTable() +{ + if ( m_pCurrentList->isLeafSelected() ) + { + String sSelectedName, sAliasName; + sSelectedName = m_pCurrentList->getSelectedName( sAliasName ); + + m_rContext.addTableWindow( sSelectedName, sAliasName ); + } +} + +//------------------------------------------------------------------------------ +IMPL_LINK( OAddTableDlg, AddClickHdl, Button*, /*pButton*/ ) +{ + TableListDoubleClickHdl(NULL); + return 0; +} + +//------------------------------------------------------------------------------ +IMPL_LINK( OAddTableDlg, TableListDoubleClickHdl, void*, /*EMPTY_ARG*/ ) +{ + if ( impl_isAddAllowed() ) + { + impl_addTable(); + if ( !impl_isAddAllowed() ) + Close(); + return 1L; // handled + } + + return 0L; // not handled +} + +//------------------------------------------------------------------------------ +IMPL_LINK( OAddTableDlg, TableListSelectHdl, void*, /*EMPTY_ARG*/ ) +{ + aAddButton.Enable( m_pCurrentList->isLeafSelected() ); + return 0; +} + +//------------------------------------------------------------------------------ +IMPL_LINK( OAddTableDlg, CloseClickHdl, Button*, /*pButton*/ ) +{ + return Close(); +} + +//------------------------------------------------------------------------------ +IMPL_LINK( OAddTableDlg, OnTypeSelected, void*, /*EMPTY_ARG*/ ) +{ + if ( m_aCaseTables.IsChecked() ) + impl_switchTo( Tables ); + else + impl_switchTo( Queries ); + return 0; +} + +//------------------------------------------------------------------------------ +BOOL OAddTableDlg::Close() +{ + m_rContext.onWindowClosing( this ); + return ModelessDialog::Close(); +} + +//------------------------------------------------------------------------------ +bool OAddTableDlg::impl_isAddAllowed() +{ + return m_rContext.allowAddition(); +} + +//------------------------------------------------------------------------------ +String OAddTableDlg::getDialogTitleForContext( IAddTableDialogContext& _rContext ) +{ + String sTitle; + + ::svt::OLocalResourceAccess aLocalRes( ModuleRes( DLG_JOIN_TABADD ), RSC_MODELESSDIALOG ); + if ( _rContext.allowQueries() ) + sTitle = String( ModuleRes( STR_ADD_TABLE_OR_QUERY ) ); + else + sTitle = String( ModuleRes( STR_ADD_TABLES ) ); + + return sTitle; +} + +// ----------------------------------------------------------------------------- + diff --git a/dbaccess/source/ui/dlg/adtabdlg.hrc b/dbaccess/source/ui/dlg/adtabdlg.hrc new file mode 100644 index 000000000000..3c0e348abfaa --- /dev/null +++ b/dbaccess/source/ui/dlg/adtabdlg.hrc @@ -0,0 +1,47 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef DBAUI_ADTABDLG_HRC +#define DBAUI_ADTABDLG_HRC + +#define LB_TABLE_OR_QUERY 1 +#define LB_DATABASE 2 + +#define FT_DATABASE 1 + +#define PB_ADDTABLE 1 +#define PB_CLOSE 2 +#define PB_HELP 3 + +#define RB_CASE_TABLES 1 +#define RB_CASE_QUERIES 2 + +#define STR_ADD_TABLES 1 +#define STR_ADD_TABLE_OR_QUERY 2 + +#endif // DBAUI_ADTABDLG_HRC + + diff --git a/dbaccess/source/ui/dlg/adtabdlg.src b/dbaccess/source/ui/dlg/adtabdlg.src new file mode 100644 index 000000000000..af1d861a0faa --- /dev/null +++ b/dbaccess/source/ui/dlg/adtabdlg.src @@ -0,0 +1,102 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifndef DBAUI_ADTABDLG_HRC +#include "adtabdlg.hrc" +#endif +#include "dbaccess_helpid.hrc" +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif + +ModelessDialog DLG_JOIN_TABADD +{ + OutputSize = TRUE ; + SVLook = TRUE ; + HelpID = DLG_JOIN_TABADD ; + Size = MAP_APPFONT ( 178 , 147 ) ; + Moveable = TRUE ; + Closeable = TRUE ; + Hide = TRUE ; + + RadioButton RB_CASE_TABLES + { + Pos = MAP_APPFONT( 6, 6 ); + Size = MAP_APPFONT( 50, 8 ); + Text [ en-US ] = "Tables"; + }; + + RadioButton RB_CASE_QUERIES + { + Pos = MAP_APPFONT( 62, 6 ); + Size = MAP_APPFONT( 50, 8 ); + Text [ en-US ] = "Queries"; + }; + + Control LB_TABLE_OR_QUERY + { + Border = TRUE ; + Pos = MAP_APPFONT ( 6 , 18 ) ; + Size = MAP_APPFONT ( 106 , 122 ) ; + TabStop = TRUE ; + Hide = TRUE; + Group = TRUE; + }; + PushButton PB_ADDTABLE + { + Pos = MAP_APPFONT ( 123 , 6 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + Text [ en-US ] = "~Add" ; + TabStop = TRUE ; + DefButton = TRUE ; + }; + CancelButton PB_CLOSE + { + Pos = MAP_APPFONT ( 123 , 22 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + HelpId = HID_JOINSH_ADDTAB_CLOSE; + Text [ en-US ] = "~Close" ; + TabStop = TRUE ; + }; + HelpButton PB_HELP + { + Pos = MAP_APPFONT ( 123 , 43 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + + String STR_ADD_TABLES + { + Text [ en-US ] = "Add Tables"; + }; + + String STR_ADD_TABLE_OR_QUERY + { + Text [ en-US ] = "Add Table or Query" ; + }; +}; diff --git a/dbaccess/source/ui/dlg/advancedsettings.cxx b/dbaccess/source/ui/dlg/advancedsettings.cxx new file mode 100644 index 000000000000..a2e82e50757d --- /dev/null +++ b/dbaccess/source/ui/dlg/advancedsettings.cxx @@ -0,0 +1,565 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#include "advancedsettings.hxx" +#include "advancedsettingsdlg.hxx" +#include "moduledbu.hxx" +#include "dsitems.hxx" +#include "DbAdminImpl.hxx" +#include "DriverSettings.hxx" +#include "optionalboolitem.hxx" +#include "dbu_resource.hrc" +#include "dbu_dlg.hrc" +#include "dbadmin.hrc" +#include "advancedsettings.hrc" + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +#include <svl/eitem.hxx> +#include <svl/intitem.hxx> +#include <svl/stritem.hxx> + +#include <vcl/msgbox.hxx> + +//........................................................................ +namespace dbaui +{ +//........................................................................ + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::lang::XMultiServiceFactory; + using ::com::sun::star::uno::Any; + using ::com::sun::star::beans::XPropertySet; + using ::com::sun::star::sdbc::XConnection; + using ::com::sun::star::sdbc::XDriver; + /** === end UNO using === **/ + + //======================================================================== + //= SpecialSettingsPage + //======================================================================== + struct BooleanSettingDesc + { + CheckBox** ppControl; // the dialog's control which displays this setting + USHORT nControlResId; // the resource ID to load the control from + USHORT nItemId; // the ID of the item (in an SfxItemSet) which corresponds to this setting + bool bInvertedDisplay; // true if and only if the checkbox is checked when the item is FALSE, and vice versa + }; + + //======================================================================== + //= SpecialSettingsPage + //======================================================================== + SpecialSettingsPage::SpecialSettingsPage( Window* pParent, const SfxItemSet& _rCoreAttrs, const DataSourceMetaData& _rDSMeta ) + :OGenericAdministrationPage( pParent, ModuleRes( PAGE_ADVANCED_SETTINGS_SPECIAL ), _rCoreAttrs ) + ,m_aTopLine( this, ModuleRes( FL_DATAHANDLING ) ) + ,m_pIsSQL92Check( NULL ) + ,m_pAppendTableAlias( NULL ) + ,m_pAsBeforeCorrelationName( NULL ) + ,m_pEnableOuterJoin( NULL ) + ,m_pIgnoreDriverPrivileges( NULL ) + ,m_pParameterSubstitution( NULL ) + ,m_pSuppressVersionColumn( NULL ) + ,m_pCatalog( NULL ) + ,m_pSchema( NULL ) + ,m_pIndexAppendix( NULL ) + ,m_pDosLineEnds( NULL ) + ,m_pCheckRequiredFields( NULL ) + ,m_pIgnoreCurrency(NULL) + ,m_pEscapeDateTime(NULL) + ,m_pPrimaryKeySupport(NULL) + ,m_pBooleanComparisonModeLabel( NULL ) + ,m_pBooleanComparisonMode( NULL ) + ,m_aControlDependencies() + ,m_aBooleanSettings() + ,m_bHasBooleanComparisonMode( _rDSMeta.getFeatureSet().has( DSID_BOOLEANCOMPARISON ) ) + { + impl_initBooleanSettings(); + + const FeatureSet& rFeatures( _rDSMeta.getFeatureSet() ); + // create all the check boxes for the boolean settings + for ( BooleanSettingDescs::const_iterator setting = m_aBooleanSettings.begin(); + setting != m_aBooleanSettings.end(); + ++setting + ) + { + USHORT nItemId = setting->nItemId; + if ( rFeatures.has( nItemId ) ) + { + USHORT nResourceId = setting->nControlResId; + (*setting->ppControl) = new CheckBox( this, ModuleRes( nResourceId ) ); + (*setting->ppControl)->SetClickHdl( getControlModifiedLink() ); + + // check whether this must be a tristate check box + const SfxPoolItem& rItem = _rCoreAttrs.Get( nItemId ); + if ( rItem.ISA( OptionalBoolItem ) ) + (*setting->ppControl)->EnableTriState( TRUE ); + } + } + + if ( m_pAsBeforeCorrelationName && m_pAppendTableAlias ) + // make m_pAsBeforeCorrelationName depend on m_pAppendTableAlias + m_aControlDependencies.enableOnCheckMark( *m_pAppendTableAlias, *m_pAsBeforeCorrelationName ); + + // move the controls to the appropriate positions + Point aPos( m_aTopLine.GetPosPixel() ); + aPos.Move( 0, m_aTopLine.GetSizePixel().Height() ); + Size aFirstDistance( LogicToPixel( Size( INDENTED_X, RELATED_CONTROLS ), MAP_APPFONT ) ); + aPos.Move( aFirstDistance.Width(), aFirstDistance.Height() ); + + Size aUnrelatedControls( LogicToPixel( Size( RELATED_CONTROLS, RELATED_CONTROLS ), MAP_APPFONT ) ); + + for ( BooleanSettingDescs::const_iterator setting = m_aBooleanSettings.begin(); + setting != m_aBooleanSettings.end(); + ++setting + ) + { + if ( !*setting->ppControl ) + continue; + + (*setting->ppControl)->SetPosPixel( aPos ); + aPos.Move( 0, (*setting->ppControl)->GetSizePixel().Height() ); + aPos.Move( 0, aUnrelatedControls.Height() ); + } + + // create the controls for the boolean comparison mode + if ( m_bHasBooleanComparisonMode ) + { + m_pBooleanComparisonModeLabel = new FixedText( this, ModuleRes( FT_BOOLEANCOMPARISON ) ); + m_pBooleanComparisonMode = new ListBox( this, ModuleRes( LB_BOOLEANCOMPARISON ) ); + m_pBooleanComparisonMode->SetDropDownLineCount( 4 ); + m_pBooleanComparisonMode->SetSelectHdl( getControlModifiedLink() ); + + Point aLabelPos( m_pBooleanComparisonModeLabel->GetPosPixel() ); + Point aControlPos( m_pBooleanComparisonMode->GetPosPixel() ); + long nMoveUp = aControlPos.Y() - aPos.Y(); + + m_pBooleanComparisonModeLabel->SetPosPixel( Point( aLabelPos.X(), aLabelPos.Y() - nMoveUp ) ); + m_pBooleanComparisonMode->SetPosPixel( Point( aControlPos.X(), aControlPos.Y() - nMoveUp ) ); + } + + FreeResource(); + } + + // ----------------------------------------------------------------------- + SpecialSettingsPage::~SpecialSettingsPage() + { + m_aControlDependencies.clear(); + + DELETEZ( m_pIsSQL92Check ); + DELETEZ( m_pAppendTableAlias ); + DELETEZ( m_pAsBeforeCorrelationName ); + DELETEZ( m_pParameterSubstitution ); + DELETEZ( m_pIgnoreDriverPrivileges ); + DELETEZ( m_pSuppressVersionColumn ); + DELETEZ( m_pEnableOuterJoin ); + DELETEZ( m_pCatalog ); + DELETEZ( m_pSchema ); + DELETEZ( m_pIndexAppendix ); + DELETEZ( m_pDosLineEnds ); + DELETEZ( m_pCheckRequiredFields ); + DELETEZ( m_pIgnoreCurrency ); + DELETEZ( m_pEscapeDateTime ); + DELETEZ( m_pPrimaryKeySupport ); + DELETEZ( m_pBooleanComparisonModeLabel ); + DELETEZ( m_pBooleanComparisonMode ); + } + + // ----------------------------------------------------------------------- + void SpecialSettingsPage::impl_initBooleanSettings() + { + OSL_PRECOND( m_aBooleanSettings.empty(), "SpecialSettingsPage::impl_initBooleanSettings: called twice!" ); + + // for easier maintainance, write the table in this form, then copy it to m_aBooleanSettings + BooleanSettingDesc aSettings[] = { + { &m_pIsSQL92Check, CB_SQL92CHECK, DSID_SQL92CHECK, false }, + { &m_pAppendTableAlias, CB_APPENDTABLEALIAS, DSID_APPEND_TABLE_ALIAS, false }, + { &m_pAsBeforeCorrelationName, CB_AS_BEFORE_CORR_NAME, DSID_AS_BEFORE_CORRNAME, false }, + { &m_pEnableOuterJoin, CB_ENABLEOUTERJOIN, DSID_ENABLEOUTERJOIN, false }, + { &m_pIgnoreDriverPrivileges, CB_IGNOREDRIVER_PRIV, DSID_IGNOREDRIVER_PRIV, false }, + { &m_pParameterSubstitution, CB_PARAMETERNAMESUBST, DSID_PARAMETERNAMESUBST, false }, + { &m_pSuppressVersionColumn, CB_SUPPRESVERSIONCL, DSID_SUPPRESSVERSIONCL, true }, + { &m_pCatalog, CB_CATALOG, DSID_CATALOG, false }, + { &m_pSchema, CB_SCHEMA, DSID_SCHEMA, false }, + { &m_pIndexAppendix, CB_IGNOREINDEXAPPENDIX, DSID_INDEXAPPENDIX, false }, + { &m_pDosLineEnds, CB_DOSLINEENDS, DSID_DOSLINEENDS, false }, + { &m_pCheckRequiredFields, CB_CHECK_REQUIRED, DSID_CHECK_REQUIRED_FIELDS, false }, + { &m_pIgnoreCurrency, CB_IGNORECURRENCY, DSID_IGNORECURRENCY, false }, + { &m_pEscapeDateTime, CB_ESCAPE_DATETIME, DSID_ESCAPE_DATETIME, false }, + { &m_pPrimaryKeySupport, CB_PRIMARY_KEY_SUPPORT, DSID_PRIMARY_KEY_SUPPORT, false }, + { NULL, 0, 0, false } + }; + + for ( const BooleanSettingDesc* pCopy = aSettings; pCopy->nItemId != 0; ++pCopy ) + { + m_aBooleanSettings.push_back( *pCopy ); + } + } + + // ----------------------------------------------------------------------- + void SpecialSettingsPage::fillWindows( ::std::vector< ISaveValueWrapper* >& _rControlList ) + { + if ( m_bHasBooleanComparisonMode ) + { + _rControlList.push_back( new ODisableWrapper< FixedText >( m_pBooleanComparisonModeLabel ) ); + } + } + + // ----------------------------------------------------------------------- + void SpecialSettingsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) + { + for ( BooleanSettingDescs::const_iterator setting = m_aBooleanSettings.begin(); + setting != m_aBooleanSettings.end(); + ++setting + ) + { + if ( *setting->ppControl ) + { + _rControlList.push_back( new OSaveValueWrapper< CheckBox >( *setting->ppControl ) ); + } + } + + if ( m_bHasBooleanComparisonMode ) + _rControlList.push_back( new OSaveValueWrapper< ListBox >( m_pBooleanComparisonMode ) ); + } + + // ----------------------------------------------------------------------- + void SpecialSettingsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) + { + // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) + sal_Bool bValid, bReadonly; + getFlags( _rSet, bValid, bReadonly ); + + if ( !bValid ) + { + OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue); + return; + } + + // the boolean items + for ( BooleanSettingDescs::const_iterator setting = m_aBooleanSettings.begin(); + setting != m_aBooleanSettings.end(); + ++setting + ) + { + if ( !*setting->ppControl ) + continue; + + ::boost::optional< bool > aValue; + + SFX_ITEMSET_GET( _rSet, pItem, SfxPoolItem, setting->nItemId, sal_True ); + if ( pItem->ISA( SfxBoolItem ) ) + { + aValue.reset( PTR_CAST( SfxBoolItem, pItem )->GetValue() ); + } + else if ( pItem->ISA( OptionalBoolItem ) ) + { + aValue = PTR_CAST( OptionalBoolItem, pItem )->GetFullValue(); + } + else + DBG_ERROR( "SpecialSettingsPage::implInitControls: unknown boolean item type!" ); + + if ( !aValue ) + { + (*setting->ppControl)->SetState( STATE_DONTKNOW ); + } + else + { + BOOL bValue = *aValue; + if ( setting->bInvertedDisplay ) + bValue = !bValue; + (*setting->ppControl)->Check( bValue ); + } + } + + // the non-boolean items + if ( m_bHasBooleanComparisonMode ) + { + SFX_ITEMSET_GET( _rSet, pBooleanComparison, SfxInt32Item, DSID_BOOLEANCOMPARISON, sal_True ); + m_pBooleanComparisonMode->SelectEntryPos( static_cast< USHORT >( pBooleanComparison->GetValue() ) ); + } + + OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue); + } + + // ----------------------------------------------------------------------- + sal_Bool SpecialSettingsPage::FillItemSet( SfxItemSet& _rSet ) + { + sal_Bool bChangedSomething = sal_False; + + // the boolean items + for ( BooleanSettingDescs::const_iterator setting = m_aBooleanSettings.begin(); + setting != m_aBooleanSettings.end(); + ++setting + ) + { + if ( !*setting->ppControl ) + continue; + fillBool( _rSet, *setting->ppControl, setting->nItemId, bChangedSomething, setting->bInvertedDisplay ); + } + + // the non-boolean items + if ( m_bHasBooleanComparisonMode ) + { + if ( m_pBooleanComparisonMode->GetSelectEntryPos() != m_pBooleanComparisonMode->GetSavedValue() ) + { + _rSet.Put( SfxInt32Item( DSID_BOOLEANCOMPARISON, m_pBooleanComparisonMode->GetSelectEntryPos() ) ); + bChangedSomething = sal_True; + } + } + return bChangedSomething; + } + + //======================================================================== + //= GeneratedValuesPage + //======================================================================== + //------------------------------------------------------------------------ + GeneratedValuesPage::GeneratedValuesPage( Window* pParent, const SfxItemSet& _rCoreAttrs ) + :OGenericAdministrationPage(pParent, ModuleRes( PAGE_GENERATED_VALUES ), _rCoreAttrs) + ,m_aAutoFixedLine ( this, ModuleRes( FL_SEPARATORAUTO ) ) + ,m_aAutoRetrievingEnabled( this, ModuleRes( CB_RETRIEVE_AUTO ) ) + ,m_aAutoIncrementLabel ( this, ModuleRes( FT_AUTOINCREMENTVALUE ) ) + ,m_aAutoIncrement ( this, ModuleRes( ET_AUTOINCREMENTVALUE ) ) + ,m_aAutoRetrievingLabel ( this, ModuleRes( FT_RETRIEVE_AUTO ) ) + ,m_aAutoRetrieving ( this, ModuleRes( ET_RETRIEVE_AUTO ) ) + { + m_aAutoRetrievingEnabled.SetClickHdl( getControlModifiedLink() ); + m_aAutoIncrement.SetModifyHdl( getControlModifiedLink() ); + m_aAutoRetrieving.SetModifyHdl( getControlModifiedLink() ); + + m_aControlDependencies.enableOnCheckMark( m_aAutoRetrievingEnabled, + m_aAutoIncrementLabel, m_aAutoIncrement, m_aAutoRetrievingLabel, m_aAutoRetrieving ); + + FreeResource(); + } + + // ----------------------------------------------------------------------- + GeneratedValuesPage::~GeneratedValuesPage() + { + m_aControlDependencies.clear(); + } + + // ----------------------------------------------------------------------- + void GeneratedValuesPage::fillWindows( ::std::vector< ISaveValueWrapper* >& _rControlList ) + { + _rControlList.push_back( new ODisableWrapper< FixedLine >( &m_aAutoFixedLine ) ); + _rControlList.push_back( new ODisableWrapper< FixedText >( &m_aAutoIncrementLabel ) ); + _rControlList.push_back( new ODisableWrapper< FixedText >( &m_aAutoRetrievingLabel ) ); + } + + // ----------------------------------------------------------------------- + void GeneratedValuesPage::fillControls( ::std::vector< ISaveValueWrapper* >& _rControlList ) + { + _rControlList.push_back( new OSaveValueWrapper< CheckBox >( &m_aAutoRetrievingEnabled ) ); + _rControlList.push_back( new OSaveValueWrapper< Edit >( &m_aAutoIncrement ) ); + _rControlList.push_back( new OSaveValueWrapper< Edit >( &m_aAutoRetrieving ) ); + } + + // ----------------------------------------------------------------------- + void GeneratedValuesPage::implInitControls( const SfxItemSet& _rSet, sal_Bool _bSaveValue ) + { + // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) + sal_Bool bValid, bReadonly; + getFlags(_rSet, bValid, bReadonly); + + // collect the items + SFX_ITEMSET_GET(_rSet, pAutoIncrementItem, SfxStringItem, DSID_AUTOINCREMENTVALUE, sal_True); + SFX_ITEMSET_GET(_rSet, pAutoRetrieveValueItem, SfxStringItem, DSID_AUTORETRIEVEVALUE, sal_True); + SFX_ITEMSET_GET(_rSet, pAutoRetrieveEnabledItem, SfxBoolItem, DSID_AUTORETRIEVEENABLED, sal_True); + + // forward the values to the controls + if (bValid) + { + sal_Bool bEnabled = pAutoRetrieveEnabledItem->GetValue(); + m_aAutoRetrievingEnabled.Check( bEnabled ); + + m_aAutoIncrement.SetText( pAutoIncrementItem->GetValue() ); + m_aAutoIncrement.ClearModifyFlag(); + m_aAutoRetrieving.SetText( pAutoRetrieveValueItem->GetValue() ); + m_aAutoRetrieving.ClearModifyFlag(); + } + OGenericAdministrationPage::implInitControls( _rSet, _bSaveValue ); + } + + // ----------------------------------------------------------------------- + sal_Bool GeneratedValuesPage::FillItemSet(SfxItemSet& _rSet) + { + sal_Bool bChangedSomething = sal_False; + + fillString( _rSet, &m_aAutoIncrement, DSID_AUTOINCREMENTVALUE, bChangedSomething ); + fillBool( _rSet, &m_aAutoRetrievingEnabled, DSID_AUTORETRIEVEENABLED, bChangedSomething ); + fillString( _rSet, &m_aAutoRetrieving, DSID_AUTORETRIEVEVALUE, bChangedSomething ); + + return bChangedSomething; + } + + //======================================================================== + //= AdvancedSettingsDialog + //======================================================================== + //------------------------------------------------------------------------ + AdvancedSettingsDialog::AdvancedSettingsDialog( Window* _pParent, SfxItemSet* _pItems, + const Reference< XMultiServiceFactory >& _rxORB, const Any& _aDataSourceName ) + :SfxTabDialog(_pParent, ModuleRes(DLG_DATABASE_ADVANCED), _pItems) + ,m_pItemSet(_pItems) + { + m_pImpl = ::std::auto_ptr<ODbDataSourceAdministrationHelper>(new ODbDataSourceAdministrationHelper(_rxORB,_pParent,this)); + m_pImpl->setDataSourceOrName(_aDataSourceName); + Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource(); + m_pImpl->translateProperties(xDatasource, *_pItems); + SetInputSet(_pItems); + // propagate this set as our new input set and reset the example set + delete pExampleSet; + pExampleSet = new SfxItemSet(*GetInputSetImpl()); + + const ::rtl::OUString eType = m_pImpl->getDatasourceType(*_pItems); + + DataSourceMetaData aMeta( eType ); + const FeatureSet& rFeatures( aMeta.getFeatureSet() ); + + // auto-generated values? + if ( rFeatures.supportsGeneratedValues() ) + AddTabPage( PAGE_GENERATED_VALUES, String( ModuleRes( STR_GENERATED_VALUE ) ), ODriversSettings::CreateGeneratedValuesPage, NULL ); + + // any "special settings"? + if ( rFeatures.supportsAnySpecialSetting() ) + AddTabPage( PAGE_ADVANCED_SETTINGS_SPECIAL, String( ModuleRes( STR_DS_BEHAVIOUR ) ), ODriversSettings::CreateSpecialSettingsPage, NULL ); + + // remove the reset button - it's meaning is much too ambiguous in this dialog + RemoveResetButton(); + FreeResource(); + } + + // ----------------------------------------------------------------------- + AdvancedSettingsDialog::~AdvancedSettingsDialog() + { + SetInputSet(NULL); + DELETEZ(pExampleSet); + } + + // ----------------------------------------------------------------------- + bool AdvancedSettingsDialog::doesHaveAnyAdvancedSettings( const ::rtl::OUString& _sURL ) + { + DataSourceMetaData aMeta( _sURL ); + const FeatureSet& rFeatures( aMeta.getFeatureSet() ); + if ( rFeatures.supportsGeneratedValues() || rFeatures.supportsAnySpecialSetting() ) + return true; + return false; + } + + // ----------------------------------------------------------------------- + short AdvancedSettingsDialog::Execute() + { + short nRet = SfxTabDialog::Execute(); + if ( nRet == RET_OK ) + { + pExampleSet->Put(*GetOutputItemSet()); + m_pImpl->saveChanges(*pExampleSet); + } + return nRet; + } + + //------------------------------------------------------------------------- + void AdvancedSettingsDialog::PageCreated(USHORT _nId, SfxTabPage& _rPage) + { + // register ourself as modified listener + static_cast<OGenericAdministrationPage&>(_rPage).SetServiceFactory(m_pImpl->getORB()); + static_cast<OGenericAdministrationPage&>(_rPage).SetAdminDialog(this,this); + + AdjustLayout(); + Window *pWin = GetViewWindow(); + if(pWin) + pWin->Invalidate(); + + SfxTabDialog::PageCreated(_nId, _rPage); + } + + // ----------------------------------------------------------------------------- + const SfxItemSet* AdvancedSettingsDialog::getOutputSet() const + { + return pExampleSet; + } + + // ----------------------------------------------------------------------------- + SfxItemSet* AdvancedSettingsDialog::getWriteOutputSet() + { + return pExampleSet; + } + + // ----------------------------------------------------------------------------- + ::std::pair< Reference< XConnection >, sal_Bool > AdvancedSettingsDialog::createConnection() + { + return m_pImpl->createConnection(); + } + + // ----------------------------------------------------------------------------- + Reference< XMultiServiceFactory > AdvancedSettingsDialog::getORB() const + { + return m_pImpl->getORB(); + } + + // ----------------------------------------------------------------------------- + Reference< XDriver > AdvancedSettingsDialog::getDriver() + { + return m_pImpl->getDriver(); + } + + // ----------------------------------------------------------------------------- + ::rtl::OUString AdvancedSettingsDialog::getDatasourceType(const SfxItemSet& _rSet) const + { + return m_pImpl->getDatasourceType(_rSet); + } + + // ----------------------------------------------------------------------------- + void AdvancedSettingsDialog::clearPassword() + { + m_pImpl->clearPassword(); + } + + // ----------------------------------------------------------------------------- + void AdvancedSettingsDialog::setTitle(const ::rtl::OUString& _sTitle) + { + SetText(_sTitle); + } + + //------------------------------------------------------------------------- + void AdvancedSettingsDialog::enableConfirmSettings( bool _bEnable ) + { + (void)_bEnable; + } + + //------------------------------------------------------------------------- + sal_Bool AdvancedSettingsDialog::saveDatasource() + { + return PrepareLeaveCurrentPage(); + } + +//........................................................................ +} // namespace dbaui +//........................................................................ diff --git a/dbaccess/source/ui/dlg/advancedsettings.hrc b/dbaccess/source/ui/dlg/advancedsettings.hrc new file mode 100644 index 000000000000..8abc5d8810d2 --- /dev/null +++ b/dbaccess/source/ui/dlg/advancedsettings.hrc @@ -0,0 +1,75 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBAUI_ADVANCEDSETTINGS_HRC +#define DBAUI_ADVANCEDSETTINGS_HRC + +#define ADVANCED_CHECKBOX_OPTIONS 15 +#define ADVANCED_LISTBOX_OPTIONS 1 + +#define ADVANCED_PAGE_X 200 +#define ADVANCED_PAGE_Y \ + /* top space */ START_Y + \ + /* label */ FIXEDTEXT_HEIGHT + RELATED_CONTROLS + \ + /* check boxes */ ( ADVANCED_CHECKBOX_OPTIONS * ( CHECKBOX_HEIGHT + RELATED_CONTROLS ) ) + \ + /* list boxes */ ( ADVANCED_LISTBOX_OPTIONS * ( LISTBOX_HEIGHT + RELATED_CONTROLS ) ) + \ + /* bottom space */ START_Y + + +#define STR_GENERATED_VALUE 1 +#define STR_DS_BEHAVIOUR 2 + +#define FL_SEPARATORAUTO 1 +#define FL_DATAHANDLING 2 + +#define CB_SUPPRESVERSIONCL 1 +#define CB_SQL92CHECK 2 +#define CB_RETRIEVE_AUTO 3 +#define CB_APPENDTABLEALIAS 4 +#define CB_IGNOREDRIVER_PRIV 5 +#define CB_PARAMETERNAMESUBST 6 +#define CB_ENABLEOUTERJOIN 7 +#define CB_SCHEMA 8 +#define CB_CATALOG 9 +#define CB_IGNOREINDEXAPPENDIX 10 +#define CB_DOSLINEENDS 11 +#define CB_AS_BEFORE_CORR_NAME 12 +#define CB_CHECK_REQUIRED 13 +#define CB_IGNORECURRENCY 14 +#define CB_ESCAPE_DATETIME 15 +#define CB_PRIMARY_KEY_SUPPORT 16 + +#define ET_AUTOINCREMENTVALUE 1 +#define ET_RETRIEVE_AUTO 2 + +#define FT_AUTOINCREMENTVALUE 1 +#define FT_RETRIEVE_AUTO 2 +#define FT_BOOLEANCOMPARISON 3 + +#define LB_BOOLEANCOMPARISON 1 + +#endif // DBAUI_ADVANCEDSETTINGS_HRC diff --git a/dbaccess/source/ui/dlg/advancedsettings.hxx b/dbaccess/source/ui/dlg/advancedsettings.hxx new file mode 100644 index 000000000000..7e58f260f4e6 --- /dev/null +++ b/dbaccess/source/ui/dlg/advancedsettings.hxx @@ -0,0 +1,150 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBACCESS_ADVANCEDSETTINGS_HXX +#define DBACCESS_ADVANCEDSETTINGS_HXX + +#include "adminpages.hxx" +#include "dsmeta.hxx" + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +#include <svtools/dialogcontrolling.hxx> + +#include <vcl/lstbox.hxx> + +#include <vector> + +//........................................................................ +namespace dbaui +{ +//........................................................................ + + struct BooleanSettingDesc; + typedef ::std::vector< BooleanSettingDesc > BooleanSettingDescs; + + //==================================================================== + //= SpecialSettingsPage + //==================================================================== + /** implements the "Special Settings" page of the advanced database settings + */ + class SpecialSettingsPage : public OGenericAdministrationPage + { + protected: + FixedLine m_aTopLine; + CheckBox* m_pIsSQL92Check; + CheckBox* m_pAppendTableAlias; + CheckBox* m_pAsBeforeCorrelationName; + CheckBox* m_pEnableOuterJoin; + CheckBox* m_pIgnoreDriverPrivileges; + CheckBox* m_pParameterSubstitution; + CheckBox* m_pSuppressVersionColumn; + CheckBox* m_pCatalog; + CheckBox* m_pSchema; + CheckBox* m_pIndexAppendix; + CheckBox* m_pDosLineEnds; + CheckBox* m_pCheckRequiredFields; + CheckBox* m_pIgnoreCurrency; + CheckBox* m_pEscapeDateTime; + CheckBox* m_pPrimaryKeySupport; + + FixedText* m_pBooleanComparisonModeLabel; + ListBox* m_pBooleanComparisonMode; + + ::svt::ControlDependencyManager + m_aControlDependencies; + + BooleanSettingDescs m_aBooleanSettings; + + bool m_bHasBooleanComparisonMode; + + public: + virtual BOOL FillItemSet ( SfxItemSet& _rCoreAttrs ); + + SpecialSettingsPage(Window* pParent, const SfxItemSet& _rCoreAttrs, const DataSourceMetaData& _rDSMeta ); + + protected: + virtual ~SpecialSettingsPage(); + + // OGenericAdministrationPage overridables + virtual void implInitControls (const SfxItemSet& _rSet, sal_Bool _bSaveValue ); + + // <method>OGenericAdministrationPage::fillControls</method> + virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList); + + // <method>OGenericAdministrationPage::fillWindows</method> + virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList); + + private: + void impl_initBooleanSettings(); + }; + + //==================================================================== + //= GeneratedValuesPage + //==================================================================== + class GeneratedValuesPage : public OGenericAdministrationPage + { + protected: + + FixedLine m_aAutoFixedLine; + CheckBox m_aAutoRetrievingEnabled; + FixedText m_aAutoIncrementLabel; + Edit m_aAutoIncrement; + FixedText m_aAutoRetrievingLabel; + Edit m_aAutoRetrieving; + + ::svt::ControlDependencyManager + m_aControlDependencies; + + public: + virtual BOOL FillItemSet (SfxItemSet& _rCoreAttrs); + + GeneratedValuesPage( Window* pParent, const SfxItemSet& _rCoreAttrs ); + protected: + + // nControlFlags ist eine Kombination der CBTP_xxx-Konstanten + virtual ~GeneratedValuesPage(); + + // must be overloaded by subclasses, but it isn't pure virtual + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + + // <method>OGenericAdministrationPage::fillControls</method> + virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList); + + // <method>OGenericAdministrationPage::fillWindows</method> + virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList); + + private: + DECL_LINK( OnCheckBoxClick, CheckBox * ); + }; + +//........................................................................ +} // namespace dbaui +//........................................................................ + +#endif // DBACCESS_ADVANCEDSETTINGS_HXX diff --git a/dbaccess/source/ui/dlg/advancedsettings.src b/dbaccess/source/ui/dlg/advancedsettings.src new file mode 100644 index 000000000000..4c5a7d924d33 --- /dev/null +++ b/dbaccess/source/ui/dlg/advancedsettings.src @@ -0,0 +1,366 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "dbaccess_helpid.hrc" +#include "dbu_dlg.hrc" +#include "advancedsettings.hrc" + +//------------------------------------------------------------------------- + +#define AUTO_DATAHANDLING(AUTO_Y) \ + FixedLine FL_DATAHANDLING \ + { \ + Pos = MAP_APPFONT ( RELATED_CONTROLS , AUTO_Y ) ; \ + Size = MAP_APPFONT ( ADVANCED_PAGE_X - 2*RELATED_CONTROLS , FIXEDTEXT_HEIGHT ) ; \ + Text [ en-US ] = "Options"; \ + }; + +//------------------------------------------------------------------------- + +#define AUTO_SQL92CHECK(AUTO_Y) \ + CheckBox CB_SQL92CHECK \ + { \ + Pos = MAP_APPFONT ( 6 , AUTO_Y) ; \ + Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \ + TabStop = TRUE ; \ + HelpId = HID_DSADMIN_SQL92CHECK; \ + Text[ en-US ] = "Use SQL92 naming constraints"; \ + }; + +//------------------------------------------------------------------------- + +#define AUTO_APPENDTABLEALIAS(AUTO_Y) \ + CheckBox CB_APPENDTABLEALIAS \ + { \ + Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \ + Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \ + TabStop = TRUE ; \ + HelpId = HID_DSADMIN_APPENDTABLEALIAS; \ + Text[ en-US ] = "Append the table alias name on SELECT statements"; \ + }; + +//------------------------------------------------------------------------- + +#define AUTO_AS_BEFORE_CORR_NAME(AUTO_Y) \ + CheckBox CB_AS_BEFORE_CORR_NAME \ + { \ + Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \ + Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \ + TabStop = TRUE ; \ + HelpId = HID_DSADMIN_AS_BEFORE_CORRELATION_NAME; \ + Text[ en-US ] = "Use keyword AS before table alias names"; \ + }; + +//------------------------------------------------------------------------- + +#define AUTO_ENABLEOUTERJOIN(AUTO_Y) \ + CheckBox CB_ENABLEOUTERJOIN \ + { \ + Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \ + Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \ + TabStop = TRUE ; \ + HelpId = HID_DSADMIN_ENABLEOUTERJOIN; \ + Text [ en-US ] = "Use Outer Join syntax '{OJ }'"; \ + }; + + +//------------------------------------------------------------------------- + +#define AUTO_IGNOREDRIVER_PRIV(AUTO_Y) \ + CheckBox CB_IGNOREDRIVER_PRIV \ + { \ + Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \ + Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \ + TabStop = TRUE ; \ + HelpId = HID_DSADMIN_IGNOREDRIVER_PRIV; \ + Text[ en-US ] = "Ignore the privileges from the database driver"; \ + }; + +//------------------------------------------------------------------------- + +#define AUTO_PARAMETERNAMESUBST(AUTO_Y) \ + CheckBox CB_PARAMETERNAMESUBST \ + { \ + Pos = MAP_APPFONT ( 6 , AUTO_Y) ; \ + Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \ + TabStop = TRUE ; \ + HelpId = HID_DSADMIN_PARAMETERNAMESUBST; \ + Text[ en-US ] = "Replace named parameters with '?'"; \ + }; + +//------------------------------------------------------------------------- + +#define AUTO_SUPPRESVERSIONCOLUMN(AUTO_Y) \ + CheckBox CB_SUPPRESVERSIONCL \ + { \ + Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \ + Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \ + TabStop = TRUE ; \ + HelpId = HID_DSADMIN_SUPPRESS_VERSIONCL; \ + Text [ en-US ] = "Display version columns (when available)"; \ + }; + +//------------------------------------------------------------------------- + +#define AUTO_CATALOG(AUTO_Y) \ + CheckBox CB_CATALOG \ + { \ + Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \ + Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \ + TabStop = TRUE ; \ + HelpId = HID_DSADMIN_CATALOG; \ + Text [ en-US ] = "Use catalog name in SELECT statements"; \ + }; + + +//------------------------------------------------------------------------- + +#define AUTO_SCHEMA(AUTO_Y) \ + CheckBox CB_SCHEMA \ + { \ + Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \ + Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \ + TabStop = TRUE ; \ + HelpId = HID_DSADMIN_SCHEMA; \ + Text [ en-US ] = "Use schema name in SELECT statements"; \ + }; + +//------------------------------------------------------------------------- + +#define AUTO_IGNOREINDEXAPPENDIX(AUTO_Y) \ + CheckBox CB_IGNOREINDEXAPPENDIX \ + { \ + Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \ + Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \ + TabStop = TRUE ; \ + HelpId = HID_DSADMIN_IGNOREINDEXAPPENDIX; \ + Text[ en-US ] = "Create index with ASC or DESC statement"; \ + }; + +//------------------------------------------------------------------------- + +#define AUTO_DOSLINEENDS(AUTO_Y) \ + CheckBox CB_DOSLINEENDS \ + { \ + Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \ + Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \ + TabStop = TRUE ; \ + HelpId = HID_DSADMIN_DOSLINEENDS; \ + Text [ en-US ] = "End text lines with CR+LF"; \ + }; + +//------------------------------------------------------------------------- +#define AUTO_IGNORECURRENCY(AUTO_Y) \ + CheckBox CB_IGNORECURRENCY \ + { \ + Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \ + Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \ + TabStop = TRUE ; \ + HelpId = HID_DSADMIN_IGNORECURRENCY; \ + Text [ en-US ] = "Ignore currency field information"; \ + }; + +//------------------------------------------------------------------------- + +#define AUTO_CHECKREQUIRED(AUTO_Y) \ + CheckBox CB_CHECK_REQUIRED \ + { \ + Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \ + Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \ + TabStop = TRUE ; \ + HelpId = HID_DSADMIN_CHECK_REQUIRED_FIELDS; \ + Text [ en-US ] = "Form data input checks for required fields"; \ + }; + +#define AUTO_ESCAPE_DATETIME(AUTO_Y) \ + CheckBox CB_ESCAPE_DATETIME \ + { \ + Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \ + Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \ + TabStop = TRUE ; \ + HelpId = HID_DSADMIN_ESCAPE_DATETIME; \ + Text [ en-US ] = "Use ODBC conformant date/time literals"; \ + }; + + +#define AUTO_PRIMARY_KEY_SUPPORT(AUTO_Y) \ + CheckBox CB_PRIMARY_KEY_SUPPORT \ + { \ + Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \ + Size = MAP_APPFONT ( ADVANCED_PAGE_X - 12 , CHECKBOX_HEIGHT ) ; \ + TabStop = TRUE ; \ + HelpId = HID_DSADMIN_PRIMARY_KEY_SUPPORT; \ + Text [ en-US ] = "Supports primary keys"; \ + }; + + +//------------------------------------------------------------------------- + +#define WORKAROUND \ + StringList [ en-US ] = \ + { \ + < "Default" ; Default ; > ; \ + < "SQL" ; Default ; > ; \ + < "Mixed" ; Default ; > ; \ + < "MS Access" ; Default ; > ; \ + }; + + +#define AUTO_BOOLEANCOMPARISON(AUTO_Y) \ + FixedText FT_BOOLEANCOMPARISON \ + { \ + Pos = MAP_APPFONT ( START_X , AUTO_Y + ( LISTBOX_HEIGHT - CHECKBOX_HEIGHT ) / 2 ) ; \ + Size = MAP_APPFONT ( 100 , CHECKBOX_HEIGHT ); \ + Text [ en-US ] = "Comparison of Boolean values"; \ + }; \ + ListBox LB_BOOLEANCOMPARISON \ + { \ + Pos = MAP_APPFONT ( START_X + 100, AUTO_Y ) ; \ + Size = MAP_APPFONT ( 60 , LISTBOX_HEIGHT ) ; \ + TabStop = TRUE ; \ + SvLook = TRUE; \ + DropDown = TRUE; \ + Border = TRUE; \ + HelpId = HID_DSADMIN_BOOLEANCOMPARISON; \ + WORKAROUND \ + }; \ + +//------------------------------------------------------------------------- + +TabPage PAGE_GENERATED_VALUES +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( ADVANCED_PAGE_X , ADVANCED_PAGE_Y ) ; + Hide = TRUE; + + FixedLine FL_SEPARATORAUTO + { + Pos = MAP_APPFONT ( 4, UNRELATED_CONTROLS ) ; + Size = MAP_APPFONT ( ADVANCED_PAGE_X - 2*RELATED_CONTROLS , FIXEDTEXT_HEIGHT ) ; + Text [ en-US ] = "Settings"; + }; + + CheckBox CB_RETRIEVE_AUTO + { + Pos = MAP_APPFONT ( 6 , UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + RELATED_CONTROLS) ; + Size = MAP_APPFONT ( ADVANCED_PAGE_X - 2*UNRELATED_CONTROLS , CHECKBOX_HEIGHT ) ; + TabStop = TRUE ; + HelpId = HID_DSADMIN_AUTORETRIEVEENABLED; + Text [ en-US ] = "Re~trieve generated values"; + }; + + FixedText FT_AUTOINCREMENTVALUE + { + Pos = MAP_APPFONT ( 15 , UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + 2*RELATED_CONTROLS + CHECKBOX_HEIGHT ) ; + Size = MAP_APPFONT ( ADVANCED_PAGE_X - 15 - 6 , FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "~Auto-increment statement"; + }; + + Edit ET_AUTOINCREMENTVALUE + { + Border = TRUE ; + Pos = MAP_APPFONT ( 15 , UNRELATED_CONTROLS + 2*FIXEDTEXT_HEIGHT + CHECKBOX_HEIGHT + 3*RELATED_CONTROLS ) ; + Size = MAP_APPFONT ( ADVANCED_PAGE_X - 15 - 2*UNRELATED_CONTROLS , EDIT_HEIGHT ) ; + TabStop = TRUE ; + HelpId = HID_DSADMIN_AUTOINCREMENTVALUE; + }; + + FixedText FT_RETRIEVE_AUTO + { + Pos = MAP_APPFONT ( 15 , UNRELATED_CONTROLS + 2*FIXEDTEXT_HEIGHT + CHECKBOX_HEIGHT + 4*RELATED_CONTROLS + EDIT_HEIGHT) ; + Size = MAP_APPFONT ( ADVANCED_PAGE_X - 15 - 6 , 10 ) ; + Text [ en-US ] = "~Query of generated values"; + }; + + Edit ET_RETRIEVE_AUTO + { + Border = TRUE ; + Pos = MAP_APPFONT ( 15 , UNRELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + CHECKBOX_HEIGHT + 5*RELATED_CONTROLS + EDIT_HEIGHT ) ; + Size = MAP_APPFONT ( ADVANCED_PAGE_X - 15 - 2*UNRELATED_CONTROLS, EDIT_HEIGHT ) ; + TabStop = TRUE ; + HelpId = HID_DSADMIN_RETRIEVE_AUTO; + }; +}; + +//------------------------------------------------------------------------- + +TabPage PAGE_ADVANCED_SETTINGS_SPECIAL +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( ADVANCED_PAGE_X , ADVANCED_PAGE_Y ) ; + Hide = TRUE; + AUTO_DATAHANDLING( RELATED_CONTROLS ) + AUTO_SQL92CHECK( 1*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + RELATED_CONTROLS ) + AUTO_APPENDTABLEALIAS( 2*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 1*CHECKBOX_HEIGHT + RELATED_CONTROLS ) + AUTO_AS_BEFORE_CORR_NAME( 3*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 2*CHECKBOX_HEIGHT + RELATED_CONTROLS ) + AUTO_ENABLEOUTERJOIN( 4*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 3*CHECKBOX_HEIGHT + RELATED_CONTROLS ) + AUTO_IGNOREDRIVER_PRIV( 5*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 4*CHECKBOX_HEIGHT + RELATED_CONTROLS ) + AUTO_PARAMETERNAMESUBST( 6*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 5*CHECKBOX_HEIGHT + RELATED_CONTROLS ) + AUTO_SUPPRESVERSIONCOLUMN( 7*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 6*CHECKBOX_HEIGHT + RELATED_CONTROLS ) + AUTO_CATALOG( 8*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 7*CHECKBOX_HEIGHT + RELATED_CONTROLS ) + AUTO_SCHEMA( 9*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 8*CHECKBOX_HEIGHT + RELATED_CONTROLS ) + AUTO_IGNOREINDEXAPPENDIX( 10*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 9*CHECKBOX_HEIGHT + RELATED_CONTROLS ) + AUTO_DOSLINEENDS( 11*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 10*CHECKBOX_HEIGHT + RELATED_CONTROLS ) + AUTO_CHECKREQUIRED( 12*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 11*CHECKBOX_HEIGHT + RELATED_CONTROLS ) + AUTO_IGNORECURRENCY( 13*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 12*CHECKBOX_HEIGHT + RELATED_CONTROLS ) + AUTO_ESCAPE_DATETIME( 14*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 14*CHECKBOX_HEIGHT + RELATED_CONTROLS ) + AUTO_PRIMARY_KEY_SUPPORT( 15*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 15*CHECKBOX_HEIGHT + RELATED_CONTROLS ) + AUTO_BOOLEANCOMPARISON( 16*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 14*CHECKBOX_HEIGHT + RELATED_CONTROLS + ( LISTBOX_HEIGHT - CHECKBOX_HEIGHT ) / 2 ) +}; + +//------------------------------------------------------------------------- + +TabDialog DLG_DATABASE_ADVANCED +{ + OutputSize = TRUE ; + SVLook = TRUE ; + Moveable = TRUE ; + Closeable = TRUE ; + Hide = TRUE; + HelpId = HID_DSADMIN_ADVANCED; + + TabControl 1 + { + OutputSize = TRUE ; + HelpId = HID_DSADMIN_TABCONTROL; + SingleLine=TRUE; + }; + + String STR_GENERATED_VALUE + { + Text [ en-US ] = "Generated Values"; + }; + + String STR_DS_BEHAVIOUR + { + Text [ en-US ] = "Special Settings"; + }; + + Text [ en-US ] = "Advanced Properties" ; +}; diff --git a/dbaccess/source/ui/dlg/dbadmin.cxx b/dbaccess/source/ui/dlg/dbadmin.cxx new file mode 100644 index 000000000000..1d5bb1cb167c --- /dev/null +++ b/dbaccess/source/ui/dlg/dbadmin.cxx @@ -0,0 +1,515 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#include "ConnectionPage.hxx" +#include "DbAdminImpl.hxx" +#include "DriverSettings.hxx" +#include "adminpages.hxx" +#include "dbadmin.hrc" +#include "dbadmin.hxx" +#include "dbu_dlg.hrc" +#include <svl/stritem.hxx> +#include <svl/eitem.hxx> +#include <svl/intitem.hxx> +#include "dbustrings.hrc" +#include "dsitems.hxx" +#include "dsnItem.hxx" +#include "localresaccess.hxx" +#include "optionalboolitem.hxx" +#include "propertysetitem.hxx" +#include "stringlistitem.hxx" + +#include <svl/eitem.hxx> +#include <svl/intitem.hxx> +#include <svl/stritem.hxx> +#include <unotools/confignode.hxx> +#include <vcl/msgbox.hxx> + +//......................................................................... +namespace dbaui +{ +//......................................................................... +using namespace com::sun::star::uno; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::lang; +using namespace com::sun::star::util; +using namespace com::sun::star::beans; +using namespace com::sun::star::container; + +//========================================================================= +//= ODbAdminDialog +//========================================================================= +DBG_NAME(ODbAdminDialog) +//------------------------------------------------------------------------- +ODbAdminDialog::ODbAdminDialog(Window* _pParent + , SfxItemSet* _pItems + , const Reference< XMultiServiceFactory >& _rxORB + ) + :SfxTabDialog(_pParent, ModuleRes(DLG_DATABASE_ADMINISTRATION), _pItems) + ,m_bApplied(sal_False) + ,m_bUIEnabled( sal_True ) + ,m_nMainPageID( PAGE_CONNECTION ) +{ + DBG_CTOR(ODbAdminDialog,NULL); + + m_pImpl = ::std::auto_ptr<ODbDataSourceAdministrationHelper>(new ODbDataSourceAdministrationHelper(_rxORB,this,this)); + + // add the initial tab page + AddTabPage( m_nMainPageID, String( ModuleRes( STR_PAGETITLE_GENERAL ) ), OConnectionTabPage::Create, NULL ); + + // remove the reset button - it's meaning is much too ambiguous in this dialog + RemoveResetButton(); + // no local resources needed anymore + FreeResource(); +} + +//------------------------------------------------------------------------- +ODbAdminDialog::~ODbAdminDialog() +{ + SetInputSet(NULL); + DELETEZ(pExampleSet); + + DBG_DTOR(ODbAdminDialog,NULL); +} +//------------------------------------------------------------------------- +short ODbAdminDialog::Ok() +{ + SfxTabDialog::Ok(); + disabledUI(); + return ( AR_LEAVE_MODIFIED == implApplyChanges() ) ? RET_OK : RET_CANCEL; + // TODO : AR_ERROR is not handled correctly, we always close the dialog here +} + +//------------------------------------------------------------------------- +void ODbAdminDialog::PageCreated(USHORT _nId, SfxTabPage& _rPage) +{ + // register ourself as modified listener + static_cast<OGenericAdministrationPage&>(_rPage).SetServiceFactory(m_pImpl->getORB()); + static_cast<OGenericAdministrationPage&>(_rPage).SetAdminDialog(this,this); + + AdjustLayout(); + Window *pWin = GetViewWindow(); + if(pWin) + pWin->Invalidate(); + + SfxTabDialog::PageCreated(_nId, _rPage); +} + +// ----------------------------------------------------------------------------- +void ODbAdminDialog::addDetailPage(USHORT _nPageId, USHORT _nTextId, CreateTabPage _pCreateFunc) +{ + // open our own resource block, as the page titles are strings local to this block + LocalResourceAccess aDummy(DLG_DATABASE_ADMINISTRATION, RSC_TABDIALOG); + + AddTabPage(_nPageId, String(ModuleRes(_nTextId)), _pCreateFunc, NULL); + m_aCurrentDetailPages.push(_nPageId); +} + +//------------------------------------------------------------------------- +void ODbAdminDialog::impl_selectDataSource(const ::com::sun::star::uno::Any& _aDataSourceName) +{ + m_pImpl->setDataSourceOrName(_aDataSourceName); + Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource(); + impl_resetPages( xDatasource ); + + DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, getOutputSet()->GetItem(DSID_TYPECOLLECTION)); + ::dbaccess::ODsnTypeCollection* pCollection = pCollectionItem->getCollection(); + ::dbaccess::DATASOURCE_TYPE eType = pCollection->determineType(getDatasourceType(*getOutputSet())); + + // and insert the new ones + switch ( eType ) + { + case ::dbaccess::DST_DBASE: + addDetailPage(PAGE_DBASE, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateDbase); + // bResetPasswordRequired = sal_True; + break; + + case ::dbaccess::DST_ADO: + addDetailPage(PAGE_ADO, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateAdo); + break; + + case ::dbaccess::DST_FLAT: + addDetailPage(PAGE_TEXT, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateText); + // bResetPasswordRequired = sal_True; + break; + + case ::dbaccess::DST_ODBC: + addDetailPage(PAGE_ODBC, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateODBC); + break; + + case ::dbaccess::DST_MYSQL_ODBC: + addDetailPage(PAGE_MYSQL_ODBC, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateMySQLODBC); + break; + + case ::dbaccess::DST_MYSQL_JDBC: + addDetailPage(PAGE_MYSQL_JDBC, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateMySQLJDBC); + break; + + case ::dbaccess::DST_ORACLE_JDBC: + addDetailPage(PAGE_ORACLE_JDBC, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateOracleJDBC); + break; + + case ::dbaccess::DST_ADABAS: + // for adabas we have more than one page + // CAUTION: the order of inserting pages matters. + // the major detail page should be inserted last always (thus, it becomes the first page after + // the general page) + addDetailPage(PAGE_ADABAS, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateAdabas); + break; + + case ::dbaccess::DST_LDAP: + addDetailPage(PAGE_LDAP,STR_PAGETITLE_ADVANCED,ODriversSettings::CreateLDAP); + break; + case ::dbaccess::DST_USERDEFINE1: /// first user defined driver + case ::dbaccess::DST_USERDEFINE2: + case ::dbaccess::DST_USERDEFINE3: + case ::dbaccess::DST_USERDEFINE4: + case ::dbaccess::DST_USERDEFINE5: + case ::dbaccess::DST_USERDEFINE6: + case ::dbaccess::DST_USERDEFINE7: + case ::dbaccess::DST_USERDEFINE8: + case ::dbaccess::DST_USERDEFINE9: + case ::dbaccess::DST_USERDEFINE10: + { + LocalResourceAccess aDummy(DLG_DATABASE_ADMINISTRATION, RSC_TABDIALOG); + String aTitle(ModuleRes(STR_PAGETITLE_ADVANCED)); + AddTabPage(PAGE_USERDRIVER, aTitle, ODriversSettings::CreateUser, 0, sal_False, 1); + m_aCurrentDetailPages.push(PAGE_USERDRIVER); + } + break; + default: + break; + } +} + +//------------------------------------------------------------------------- +void ODbAdminDialog::impl_resetPages(const Reference< XPropertySet >& _rxDatasource) +{ + // the selection is valid if and only if we have a datasource now + GetInputSetImpl()->Put(SfxBoolItem(DSID_INVALID_SELECTION, !_rxDatasource.is())); + // (sal_False tells the tab pages to disable and reset all their controls, which is different + // from "just set them to readonly") + + // reset the pages + + // prevent flicker + SetUpdateMode(sal_False); + + // remove all items which relate to indirect properties from the input set + // (without this, the following may happen: select an arbitrary data source where some indirect properties + // are set. Select another data source of the same type, where the indirect props are not set (yet). Then, + // the indirect property values of the first ds are shown in the second ds ...) + const ODbDataSourceAdministrationHelper::MapInt2String& rMap = m_pImpl->getIndirectProperties(); + for ( ODbDataSourceAdministrationHelper::ConstMapInt2StringIterator aIndirect = rMap.begin(); + aIndirect != rMap.end(); + ++aIndirect + ) + GetInputSetImpl()->ClearItem( (sal_uInt16)aIndirect->first ); + + // extract all relevant data from the property set of the data source + m_pImpl->translateProperties(_rxDatasource, *GetInputSetImpl()); + + // propagate this set as our new input set and reset the example set + SetInputSet(GetInputSetImpl()); + delete pExampleSet; + pExampleSet = new SfxItemSet(*GetInputSetImpl()); + + // special case: MySQL Native does not have the generic PAGE_CONNECTION page + + DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, getOutputSet()->GetItem(DSID_TYPECOLLECTION)); + ::dbaccess::ODsnTypeCollection* pCollection = pCollectionItem->getCollection(); + if ( pCollection->determineType(getDatasourceType( *pExampleSet )) == ::dbaccess::DST_MYSQL_NATIVE ) + { + LocalResourceAccess aDummy(DLG_DATABASE_ADMINISTRATION, RSC_TABDIALOG); + AddTabPage( PAGE_MYSQL_NATIVE, String( ModuleRes( STR_PAGETITLE_CONNECTION ) ), ODriversSettings::CreateMySQLNATIVE, NULL ); + RemoveTabPage( PAGE_CONNECTION ); + m_nMainPageID = PAGE_MYSQL_NATIVE; + } + + ShowPage( m_nMainPageID ); + SfxTabPage* pConnectionPage = GetTabPage( m_nMainPageID ); + if ( pConnectionPage ) + pConnectionPage->Reset(*GetInputSetImpl()); + // if this is NULL, the page has not been created yet, which means we're called before the + // dialog was displayed (probably from inside the ctor) + + SetUpdateMode(sal_True); +} +// ----------------------------------------------------------------------------- +void ODbAdminDialog::setTitle(const ::rtl::OUString& _sTitle) +{ + SetText(_sTitle); +} +//------------------------------------------------------------------------- +void ODbAdminDialog::enableConfirmSettings( bool _bEnable ) +{ + (void)_bEnable; +} +//------------------------------------------------------------------------- +sal_Bool ODbAdminDialog::saveDatasource() +{ + return PrepareLeaveCurrentPage(); +} +//------------------------------------------------------------------------- +ODbAdminDialog::ApplyResult ODbAdminDialog::implApplyChanges() +{ + if (!PrepareLeaveCurrentPage()) + { // the page did not allow us to leave + return AR_KEEP; + } + + if ( !m_pImpl->saveChanges(*pExampleSet) ) + return AR_KEEP; + + if ( isUIEnabled() ) + ShowPage(GetCurPageId()); + // This does the usual ActivatePage, so the pages can save their current status. + // This way, next time they're asked what has changed since now and here, they really + // can compare with the status they have _now_ (not the one they had before this apply call). + + m_bApplied = sal_True; + + return AR_LEAVE_MODIFIED; +} +//------------------------------------------------------------------------- +void ODbAdminDialog::selectDataSource(const ::com::sun::star::uno::Any& _aDataSourceName) +{ + impl_selectDataSource(_aDataSourceName); +} + +// ----------------------------------------------------------------------------- +const SfxItemSet* ODbAdminDialog::getOutputSet() const +{ + return GetExampleSet(); +} +// ----------------------------------------------------------------------------- +SfxItemSet* ODbAdminDialog::getWriteOutputSet() +{ + return pExampleSet; +} +// ----------------------------------------------------------------------------- +::std::pair< Reference<XConnection>,sal_Bool> ODbAdminDialog::createConnection() +{ + return m_pImpl->createConnection(); +} +// ----------------------------------------------------------------------------- +Reference< XMultiServiceFactory > ODbAdminDialog::getORB() const +{ + return m_pImpl->getORB(); +} +// ----------------------------------------------------------------------------- +Reference< XDriver > ODbAdminDialog::getDriver() +{ + return m_pImpl->getDriver(); +} +// ----------------------------------------------------------------------------- +::rtl::OUString ODbAdminDialog::getDatasourceType(const SfxItemSet& _rSet) const +{ + return m_pImpl->getDatasourceType(_rSet); +} +// ----------------------------------------------------------------------------- +void ODbAdminDialog::clearPassword() +{ + m_pImpl->clearPassword(); +} +//------------------------------------------------------------------------- +SfxItemSet* ODbAdminDialog::createItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults, ::dbaccess::ODsnTypeCollection* _pTypeCollection) +{ + // just to be sure .... + _rpSet = NULL; + _rpPool = NULL; + _rppDefaults = NULL; + + const ::rtl::OUString sFilterAll( "%", 1, RTL_TEXTENCODING_ASCII_US ); + // create and initialize the defaults + _rppDefaults = new SfxPoolItem*[DSID_LAST_ITEM_ID - DSID_FIRST_ITEM_ID + 1]; + SfxPoolItem** pCounter = _rppDefaults; // want to modify this without affecting the out param _rppDefaults + *pCounter++ = new SfxStringItem(DSID_NAME, String()); + *pCounter++ = new SfxStringItem(DSID_ORIGINALNAME, String()); + *pCounter++ = new SfxStringItem(DSID_CONNECTURL, String()); + *pCounter++ = new OStringListItem(DSID_TABLEFILTER, Sequence< ::rtl::OUString >(&sFilterAll, 1)); + *pCounter++ = new DbuTypeCollectionItem(DSID_TYPECOLLECTION, _pTypeCollection); + *pCounter++ = new SfxBoolItem(DSID_INVALID_SELECTION, sal_False); + *pCounter++ = new SfxBoolItem(DSID_READONLY, sal_False); + *pCounter++ = new SfxStringItem(DSID_USER, String()); + *pCounter++ = new SfxStringItem(DSID_PASSWORD, String()); + *pCounter++ = new SfxStringItem(DSID_ADDITIONALOPTIONS, String()); + *pCounter++ = new SfxStringItem(DSID_CHARSET, String()); + *pCounter++ = new SfxBoolItem(DSID_PASSWORDREQUIRED, sal_False); + *pCounter++ = new SfxBoolItem(DSID_SHOWDELETEDROWS, sal_False); + *pCounter++ = new SfxBoolItem(DSID_ALLOWLONGTABLENAMES, sal_False); + *pCounter++ = new SfxStringItem(DSID_JDBCDRIVERCLASS, String()); + *pCounter++ = new SfxStringItem(DSID_FIELDDELIMITER, ','); + *pCounter++ = new SfxStringItem(DSID_TEXTDELIMITER, '"'); + *pCounter++ = new SfxStringItem(DSID_DECIMALDELIMITER, '.'); + *pCounter++ = new SfxStringItem(DSID_THOUSANDSDELIMITER, String()); + *pCounter++ = new SfxStringItem(DSID_TEXTFILEEXTENSION, String::CreateFromAscii("txt")); + *pCounter++ = new SfxBoolItem(DSID_TEXTFILEHEADER, sal_True); + *pCounter++ = new SfxBoolItem(DSID_PARAMETERNAMESUBST, sal_False); + *pCounter++ = new SfxInt32Item(DSID_CONN_PORTNUMBER, 8100); + *pCounter++ = new SfxBoolItem(DSID_SUPPRESSVERSIONCL, sal_False); + *pCounter++ = new OPropertySetItem(DSID_DATASOURCE_UNO); + *pCounter++ = new SfxBoolItem(DSID_CONN_SHUTSERVICE, sal_False); + *pCounter++ = new SfxInt32Item(DSID_CONN_DATAINC, 20); + *pCounter++ = new SfxInt32Item(DSID_CONN_CACHESIZE, 20); + *pCounter++ = new SfxStringItem(DSID_CONN_CTRLUSER, String()); + *pCounter++ = new SfxStringItem(DSID_CONN_CTRLPWD, String()); + *pCounter++ = new SfxBoolItem(DSID_USECATALOG, sal_False); + *pCounter++ = new SfxStringItem(DSID_CONN_HOSTNAME, String()); + *pCounter++ = new SfxStringItem(DSID_CONN_LDAP_BASEDN, String()); + *pCounter++ = new SfxInt32Item(DSID_CONN_LDAP_PORTNUMBER, 389); + *pCounter++ = new SfxInt32Item(DSID_CONN_LDAP_ROWCOUNT, 100); + *pCounter++ = new SfxBoolItem(DSID_SQL92CHECK, sal_False); + *pCounter++ = new SfxStringItem(DSID_AUTOINCREMENTVALUE, String()); + *pCounter++ = new SfxStringItem(DSID_AUTORETRIEVEVALUE, String()); + *pCounter++ = new SfxBoolItem(DSID_AUTORETRIEVEENABLED, sal_False); + *pCounter++ = new SfxBoolItem(DSID_APPEND_TABLE_ALIAS, sal_False); + *pCounter++ = new SfxInt32Item(DSID_MYSQL_PORTNUMBER, 3306); + *pCounter++ = new SfxBoolItem(DSID_IGNOREDRIVER_PRIV, sal_True); + *pCounter++ = new SfxInt32Item(DSID_BOOLEANCOMPARISON, 0); + *pCounter++ = new SfxInt32Item(DSID_ORACLE_PORTNUMBER, 1521); + *pCounter++ = new SfxBoolItem(DSID_ENABLEOUTERJOIN, sal_True); + *pCounter++ = new SfxBoolItem(DSID_CATALOG, sal_True); + *pCounter++ = new SfxBoolItem(DSID_SCHEMA, sal_True); + *pCounter++ = new SfxBoolItem(DSID_INDEXAPPENDIX, sal_True); + *pCounter++ = new SfxBoolItem(DSID_CONN_LDAP_USESSL, sal_False); + *pCounter++ = new SfxStringItem(DSID_DOCUMENT_URL, String()); + *pCounter++ = new SfxBoolItem(DSID_DOSLINEENDS, sal_False); + *pCounter++ = new SfxStringItem(DSID_DATABASENAME, String()); + *pCounter++ = new SfxBoolItem(DSID_AS_BEFORE_CORRNAME, sal_True); + *pCounter++ = new SfxBoolItem(DSID_CHECK_REQUIRED_FIELDS, sal_True); + *pCounter++ = new SfxBoolItem(DSID_IGNORECURRENCY, sal_False); + *pCounter++ = new SfxStringItem(DSID_CONN_SOCKET, String()); + *pCounter++ = new SfxBoolItem(DSID_ESCAPE_DATETIME, sal_True); + *pCounter++ = new SfxStringItem(DSID_NAMED_PIPE, String()); + *pCounter++ = new OptionalBoolItem( DSID_PRIMARY_KEY_SUPPORT ); + + // create the pool + static SfxItemInfo __READONLY_DATA aItemInfos[DSID_LAST_ITEM_ID - DSID_FIRST_ITEM_ID + 1] = + { + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0}, + {0,0} + }; + + OSL_ENSURE(sizeof(aItemInfos)/sizeof(aItemInfos[0]) == DSID_LAST_ITEM_ID,"Invalid Ids!"); + _rpPool = new SfxItemPool(String::CreateFromAscii("DSAItemPool"), DSID_FIRST_ITEM_ID, DSID_LAST_ITEM_ID, + aItemInfos, _rppDefaults); + _rpPool->FreezeIdRanges(); + + // and, finally, the set + _rpSet = new SfxItemSet(*_rpPool, sal_True); + + return _rpSet; +} +//------------------------------------------------------------------------- +void ODbAdminDialog::destroyItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults) +{ + // _first_ delete the set (refering the pool) + if (_rpSet) + { + delete _rpSet; + _rpSet = NULL; + } + + // delete the pool + if (_rpPool) + { + _rpPool->ReleaseDefaults(sal_True); + // the "true" means delete the items, too + SfxItemPool::Free(_rpPool); + _rpPool = NULL; + } + + // reset the defaults ptr + _rppDefaults = NULL; + // no need to explicitly delete the defaults, this has been done by the ReleaseDefaults +} + +//......................................................................... +} // namespace dbaui +//......................................................................... + diff --git a/dbaccess/source/ui/dlg/dbadmin.hrc b/dbaccess/source/ui/dlg/dbadmin.hrc new file mode 100644 index 000000000000..88ed5aea8d47 --- /dev/null +++ b/dbaccess/source/ui/dlg/dbadmin.hrc @@ -0,0 +1,111 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBAUI_DBADMIN_HRC_ +#define _DBAUI_DBADMIN_HRC_ + +//======================================================================== +// control ids + +#define FT_DATATYPE 1 +#define FT_DATASOURCETYPE_PRE 2 +#define FT_USERNAME 3 +#define FT_PASSWORD 4 +#define FT_OPTIONS 5 + // FREE +#define FT_JDBCDRIVERCLASS 7 +#define FT_SPECIAL_MESSAGE 8 +#define FT_FILTER_EXPLANATION 9 +#define FT_HOSTNAME 10 +#define FT_BASEDN 11 +#define FT_PORTNUMBER 12 +#define FT_LDAPROWCOUNT 13 +#define FT_DATASOURCETYPE_POST 14 +#define FT_GENERALHEADERTEXT 15 +#define FT_GENERALHELPTEXT 16 +#define FT_DATATYPEAPPENDIX 17 +#define FT_DATASOURCEHEADER 18 +#define FT_DOCLISTLABEL 19 + +#define LB_DATATYPE 1 + // FREE +#define LB_DOCUMENTLIST 3 + +#define ET_USERNAME 1 +#define ET_PASSWORD 2 +#define ET_OPTIONS 3 +#define ET_JDBCDRIVERCLASS 4 +#define ET_HOSTNAME 5 +#define ET_BASEDN 6 + +#define PB_INDICIES 1 +#define BTN_PASSWORD_OK 2 +#define BTN_PASSWORD_CANCEL 3 +#define BTN_PASSWORD_HELP 4 +#define PB_TESTDRIVERCLASS 5 +#define PB_OPENDOCUMENT 6 + +#define CB_PASSWORD_REQUIRED 1 +#define CB_SHOWDELETEDROWS 2 +#define CB_USESSL 3 +#define CB_USECATALOG 4 + +#define FL_SEPARATOR2 1 + +#define CTL_TABLESUBSCRIPTION 1 + +#define TLB_ACTIONS 1 + +#define NF_PORTNUMBER 1 +#define NF_LDAPROWCOUNT 2 + +#define RB_CREATEDBDATABASE 1 +#define RB_GETEXISTINGDATABASE 2 +#define RB_OPENEXISTINGDOC 3 + +//======================================================================== +// string ids (usually relative to other resources, that's why not necessarily unique) + +#define STR_PAGETITLE_GENERAL 1 +#define STR_PAGETITLE_CONNECTION 2 +#define STR_PAGETITLE_ADVANCED 3 +#define STR_NO_WILDCARDS 4 +#define STR_MYSQLENTRY 5 +#define STR_PARENTTITLE 6 +#define STR_COULDNOTLOAD_ODBCLIB 7 +#define STR_UNSUPPORTED_DATASOURCE_TYPE 8 +#define STR_MYSQL_CONFIG_NEXT_PAGE 9 +#define STR_JDBC_DEFAULT_URL 10 + +//======================================================================== +// menu item ids +#define MID_NEW_DATASOURCE 1 +#define MID_DELETE_DATASOURCE 2 +#define MID_RESTORE_DATASOURCE 3 + +#endif // _DBAUI_DBADMIN_HRC_ + diff --git a/dbaccess/source/ui/dlg/dbadmin.src b/dbaccess/source/ui/dlg/dbadmin.src new file mode 100644 index 000000000000..c4457c62eec0 --- /dev/null +++ b/dbaccess/source/ui/dlg/dbadmin.src @@ -0,0 +1,787 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif +#ifndef _DBAUI_AUTOCONTROLS_HRC_ +#include "AutoControls.hrc" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef _DBAUI_DBADMIN_HRC_ +#include "dbadmin.hrc" +#endif +#ifndef DBACCESS_UI_BROWSER_ID_HXX +#include "browserids.hxx" +#endif +#ifndef DBAUI_ADABASPAGE_HRC +#include "AdabasPage.hrc" +#endif +#include "admincontrols.hrc" + +//------------------------------------------------------------------------- + +#define AUTO_USECATALOG(AUTO_Y) \ + CheckBox CB_USECATALOG \ + { \ + Pos = MAP_APPFONT ( 6 ,AUTO_Y) ; \ + Size = MAP_APPFONT ( PAGE_X -12 , CHECKBOX_HEIGHT ) ; \ + TabStop = TRUE ; \ + HelpId = HID_DSADMIN_USECATALOG; \ + Text[ en-US ] = "Use catalog for file-based databases"; \ + }; + +//------------------------------------------------------------------------- + +#define AUTO_FIXEDLINE_CONNSETTINGS(AUTO_Y) \ + FixedLine FL_SEPARATOR1 \ + { \ + Pos = MAP_APPFONT ( 4 , AUTO_Y ) ; \ + Size = MAP_APPFONT ( PAGE_X - 8 , FIXEDTEXT_HEIGHT ) ; \ + Text[ en-US ] = "Connection Settings"; \ + }; \ + +#define AUTO_HOST_AND_PORT(AUTO_Y) \ + FixedText FT_HOSTNAME \ + { \ + Pos = MAP_APPFONT ( 6 , AUTO_Y + 2 ) ; \ + Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; \ + Text[ en-US ] = "~Host name"; \ + }; \ + Edit ET_HOSTNAME \ + { \ + TabStop = TRUE ; \ + Border = TRUE ; \ + HelpId = HID_DSADMIN_HOSTNAME; \ + Pos = MAP_APPFONT ( EDIT_X , AUTO_Y ) ; \ + Size = MAP_APPFONT ( 97 , EDIT_HEIGHT ) ; \ + }; \ + \ + FixedText FT_PORTNUMBER \ + { \ + Pos = MAP_APPFONT ( 6 , AUTO_Y + UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + 2 ) ; \ + Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; \ + Text[ en-US ] = "~Port number"; \ + }; \ + NumericField NF_PORTNUMBER \ + { \ + TabStop = TRUE ; \ + Border = TRUE ; \ + HelpId = HID_DSADMIN_PORTNUMBER; \ + NoThousandSep = TRUE; \ + Pos = MAP_APPFONT ( EDIT_X , AUTO_Y +UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT ) ; \ + Size = MAP_APPFONT ( 97 , EDIT_HEIGHT ) ; \ + }; +//------------------------------------------------------------------------- + +TabDialog DLG_DATABASE_ADMINISTRATION +{ + OutputSize = TRUE ; + SVLook = TRUE ; + Moveable = TRUE ; + Closeable = TRUE ; + Hide = TRUE; + HelpId = HID_DSADMIN_DIALOG; + + TabControl 1 + { + OutputSize = TRUE ; + HelpId = HID_DSADMIN_TABCONTROL; + SingleLine=TRUE; + }; + + //......................................................................... + String STR_PAGETITLE_GENERAL + { + Text [ en-US ] = "Advanced Properties" ; + }; + String STR_PAGETITLE_ADVANCED + { + Text [ en-US ] = "Additional Settings" ; + }; + String STR_PAGETITLE_CONNECTION + { + Text [ en-US ] = "Connection settings" ; + }; + + Text [ en-US ] = "Database properties" ; +}; + +// ----------------------------------------------------------------------------- + +ModalDialog DLG_DATABASE_TYPE_CHANGE +{ + OutputSize = TRUE ; + Moveable = TRUE; + Closeable = TRUE ; + Hide = TRUE; + HelpId = HID_DSADMIN_TYPE_DIALOG; + + TabControl 1 + { + OutputSize = TRUE ; + HelpId = HID_DSADMIN_TABCONTROL; + SingleLine=TRUE; + }; + Text [ en-US ] = "Database properties" ; +}; + +//------------------------------------------------------------------------- + +TabPage PAGE_GENERAL +{ + SVLook = TRUE ; + Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ; + Hide = TRUE; + HelpId = HID_DSADMIN_PAGE_GENERAL; + + + FixedText FT_GENERALHEADERTEXT + { + Pos = MAP_APPFONT ( START_X , 8 ) ; + Size = MAP_APPFONT ( (WIZARD_PAGE_X - START_X) - 12 , 2 * FIXEDTEXT_HEIGHT ) ; + Text [ en-US ] = "Welcome to the %PRODUCTNAME Database Wizard"; + WordBreak = TRUE; + }; + + FixedText FT_GENERALHELPTEXT + { + Pos = MAP_APPFONT (START_X , 27 ); + Size = MAP_APPFONT ( WIZARD_PAGE_X - START_X - 6, 5* FIXEDTEXT_HEIGHT ) ; + Text [ en-US ] = "Use the Database Wizard to create a new database, open an existing database file, or connect to a database stored on a server." ; + WordBreak = TRUE ; + }; + + FixedText FT_DATASOURCEHEADER + { + Pos = MAP_APPFONT ( START_X , 73 ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X - 12 , FIXEDTEXT_HEIGHT ) ; + Text [ en-US ] = "What do you want to do?"; + }; + + RadioButton RB_CREATEDBDATABASE + { + HelpId = HID_PAGE_DBWIZARD_GENERAL_RB_CREATEDBDATABASE ; + Pos = MAP_APPFONT (START_X + 6 , 85 ) ; + Size = MAP_APPFONT ( 205 , 10 ) ; + Group = TRUE; + Text [ en-US ] = "Create a n~ew database" ; + }; + + RadioButton RB_OPENEXISTINGDOC + { + Pos = MAP_APPFONT (START_X + 6 , 97 ); + Size = MAP_APPFONT ( 206 , 8 ) ; + Text [ en-US ] = "Open an existing database ~file" ; + }; + + FixedText FT_DOCLISTLABEL + { + Pos = MAP_APPFONT( START_X + INDENTED_X + INDENT_BELOW_RADIO, 110 ); + Size = MAP_APPFONT( 120, 8 ); + Text [ en-US ] = "Recently used"; + }; + + ListBox LB_DOCUMENTLIST + { + Pos = MAP_APPFONT( START_X + INDENTED_X + INDENT_BELOW_RADIO, 121 ); + Size = MAP_APPFONT( 120, 14 ); + DropDown = TRUE; + Border = TRUE; + }; + + PushButton PB_OPENDOCUMENT + { + Pos = MAP_APPFONT( START_X + INDENTED_X + INDENT_BELOW_RADIO, 139 ); + Size = MAP_APPFONT( 50, 16 ); + OutputSize = TRUE; + TabStop = TRUE; + }; + + RadioButton RB_GETEXISTINGDATABASE + { + HelpId = HID_PAGE_DBWIZARD_GENERAL_RB_GETEXISTINGDATABASE; + Pos = MAP_APPFONT (START_X + 6 , 159 ) ; + Size = MAP_APPFONT ( 206 , 8 ) ; + Text [ en-US ] = "Connect to an e~xisting database" ; + }; + + FixedText FT_DATASOURCETYPE_PRE + { + Pos = MAP_APPFONT ( 6 , UNRELATED_CONTROLS ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X - 12 , 3*FIXEDTEXT_HEIGHT ) ; + WordBreak = TRUE; + Text [ en-US ] = "Select the type of database to which you want to establish a connection."; + }; + + FixedText FT_DATATYPE + { + Pos = MAP_APPFONT ( 6 , 2*UNRELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + RELATED_CONTROLS) ; + Size = MAP_APPFONT ( 80 , FIXEDTEXT_HEIGHT ) ; + Text [ en-US ] = "Database ~type "; + }; + + ListBox LB_DATATYPE + { + HelpId = HID_DSADMIN_DSTYPE; + Pos = MAP_APPFONT ( 90, 2*UNRELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + RELATED_CONTROLS -2 ) ; + Size = MAP_APPFONT ( 120, 120 ) ; + Border = TRUE ; + TabStop = TRUE ; + DropDown = TRUE ; + Sort = FALSE; + }; + + FixedText FT_DATATYPEAPPENDIX + { + Pos = MAP_APPFONT ( 90, 2*UNRELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + RELATED_CONTROLS -2 + 72) ; + Size = MAP_APPFONT ( 60, 8 ); + Text [ en-US ] = "Database"; + }; + + FixedText FT_DATASOURCETYPE_POST + { + Pos = MAP_APPFONT ( 6 , 4*UNRELATED_CONTROLS + 4*FIXEDTEXT_HEIGHT + RELATED_CONTROLS ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X - 12 , 5*FIXEDTEXT_HEIGHT ) ; + WordBreak = TRUE; + Text [ en-US ] = "On the following pages, you can make detailed settings for the connection.\n\nThe new settings you make will overwrite your existing settings."; + }; + + FixedText FT_SPECIAL_MESSAGE + { + Pos = MAP_APPFONT ( 6, 4*UNRELATED_CONTROLS + 9*FIXEDTEXT_HEIGHT + 2*RELATED_CONTROLS ); + Size = MAP_APPFONT ( WIZARD_PAGE_X - 12, 3*FIXEDTEXT_HEIGHT ); + WordBreak = TRUE; + HelpId = HID_DSADMIN_SPECIAL_MESSAGE; + }; + + String STR_MYSQLENTRY + { + Text [ en-US ] = "MySQL" ; + }; + + String STR_PARENTTITLE + { + Text [ en-US ] = "Data Source Properties: #" ; + }; + String STR_COULDNOTLOAD_ODBCLIB + { + Text [ en-US ] = "Could not load the program library #lib# or it is corrupted. The ODBC data source selection is not available."; + }; + String STR_UNSUPPORTED_DATASOURCE_TYPE + { + Text [ en-US ] = "This kind of data source is not supported on this platform.\nYou are allowed to change the settings, but you probably will not be able to connect to the database."; + }; + Text [ en-US ] = "General" ; +}; + +//......................................................................... + +TabPage PAGE_DBASE +{ + SVLook = TRUE ; + Hide = TRUE; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( PAGE_X , PAGE_Y ) ; + HelpId = HID_DSADMIN_PAGE_DBASE; + + AUTO_CHARSET(UNRELATED_CONTROLS,PAGE_X) + + FixedLine FL_SEPARATOR1 + { + Pos = MAP_APPFONT ( 4 , 2*UNRELATED_CONTROLS + RELATED_CONTROLS + 2*FIXEDTEXT_HEIGHT) ; + Size = MAP_APPFONT ( PAGE_X - 8 , FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "Optional settings"; + }; + + CheckBox CB_SHOWDELETEDROWS + { + Pos = MAP_APPFONT ( 6 , 2*UNRELATED_CONTROLS + 2*RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT) ; + Size = MAP_APPFONT ( 200 , CHECKBOX_HEIGHT ) ; + TabStop = TRUE ; + HelpId = HID_DSADMIN_SHOWDELETED; + Text [ en-US ] = "Display deleted records as well" ; + }; + + FixedText FT_SPECIAL_MESSAGE + { + Hide = TRUE; + WordBreak = TRUE; + Pos = MAP_APPFONT ( 6 , 3*UNRELATED_CONTROLS + 2*RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + CHECKBOX_HEIGHT) ; + Size = MAP_APPFONT ( PAGE_X - 12 , 2*FIXEDTEXT_HEIGHT ) ; + Text [ en-US ] = "Note: When deleted, and thus inactive, records are displayed, you will not be able to delete records from the data source." ; + }; + + PushButton PB_INDICIES + { + Pos = MAP_APPFONT ( PAGE_X - BUTTON_WIDTH - UNRELATED_CONTROLS, PAGE_Y - BUTTON_HEIGHT - UNRELATED_CONTROLS) ; + Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ; + TabStop = TRUE ; + HelpId = HID_DSADMIN_DBASE_INDICIES; + Text [ en-US ] = "Indexes..."; + }; +}; + +//......................................................................... + +TabPage PAGE_ADO +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( PAGE_X , PAGE_Y ) ; + Hide = TRUE; + HelpId = HID_DSADMIN_PAGE_ADO; + AUTO_CHARSET(UNRELATED_CONTROLS,PAGE_X) +}; + +//......................................................................... + +TabPage PAGE_ODBC +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( PAGE_X , PAGE_Y ) ; + Hide = TRUE; + HelpId = HID_DSADMIN_PAGE_ODBC; + + AUTO_CHARSET(UNRELATED_CONTROLS,PAGE_X) + FixedLine FL_SEPARATOR1 + { + Pos = MAP_APPFONT ( 4 , 2*UNRELATED_CONTROLS + 2*FIXEDTEXT_HEIGHT + RELATED_CONTROLS ) ; + Size = MAP_APPFONT ( PAGE_X - 8 , FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "Optional Settings"; + }; + + FixedText FT_OPTIONS + { + Pos = MAP_APPFONT ( 6 , 2*UNRELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + 2*RELATED_CONTROLS) ; + Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; + Text [ en-US ] = "ODBC ~options" ; + }; + Edit ET_OPTIONS + { + Border = TRUE ; + Pos = MAP_APPFONT ( EDIT_X , 2*UNRELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + 2*RELATED_CONTROLS -1 ) ; + Size = MAP_APPFONT ( 130 , EDIT_HEIGHT ) ; + TabStop = TRUE ; + HelpId = HID_DSADMIN_ODBC_OPTIONS; + }; + + AUTO_USECATALOG( 3*UNRELATED_CONTROLS + 4*FIXEDTEXT_HEIGHT + 2*RELATED_CONTROLS ) +}; + +TabPage PAGE_ADABAS +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( PAGE_X , PAGE_Y ) ; + Hide = TRUE; + HelpId = HID_DSADMIN_PAGE_ADABAS; + + FixedLine FL_SEPARATOR1 + { + Pos = MAP_APPFONT ( 4 , UNRELATED_CONTROLS ) ; + Size = MAP_APPFONT ( PAGE_X - 8 , FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "Connection Settings"; + }; + + FixedText FT_HOSTNAME + { + Pos = MAP_APPFONT ( 6 , UNRELATED_CONTROLS + RELATED_CONTROLS + FIXEDTEXT_HEIGHT) ; + Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "~Host name"; + }; + Edit ET_HOSTNAME + { + TabStop = TRUE ; + Border = TRUE ; + + Pos = MAP_APPFONT ( EDIT_X , UNRELATED_CONTROLS + RELATED_CONTROLS + FIXEDTEXT_HEIGHT-1 ) ; + Size = MAP_APPFONT ( 105 , EDIT_HEIGHT ) ; + }; + + FixedText FT_CACHE_SIZE + { + Pos = MAP_APPFONT ( 6 , 2*UNRELATED_CONTROLS + RELATED_CONTROLS + 2*FIXEDTEXT_HEIGHT ) ; + Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "Data ~buffer size (MB)"; + }; + NumericField NF_CACHE_SIZE + { + Pos = MAP_APPFONT ( EDIT_X , 2*UNRELATED_CONTROLS + RELATED_CONTROLS + 2*FIXEDTEXT_HEIGHT -1 ) ; + Size = MAP_APPFONT ( 40 , EDIT_HEIGHT ) ; + Border = TRUE ; + TabStop = TRUE ; + Spin = TRUE ; + SpinSize = 1; + StrictFormat = TRUE; + }; + + FixedText FT_DATA_INCREMENT + { + Pos = MAP_APPFONT ( 6 , 3*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT ) ; + Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "~Data increment (MB)"; + }; + NumericField NF_DATA_INCREMENT + { + Pos = MAP_APPFONT ( EDIT_X , 3*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT -1 ) ; + Size = MAP_APPFONT ( 40 , EDIT_HEIGHT ) ; + Border = TRUE ; + TabStop = TRUE ; + Spin = TRUE ; + SpinSize = 1; + StrictFormat = TRUE; + }; + FixedLine FL_SEPARATOR2 + { + Pos = MAP_APPFONT ( 6 , 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 4*FIXEDTEXT_HEIGHT ) ; + Size = MAP_APPFONT ( 248 , FIXEDTEXT_HEIGHT ) ; + Text [ en-US ] = "Administration" ; + }; + FixedText FT_CTRLUSERNAME + { + Pos = MAP_APPFONT ( 6 , 4*UNRELATED_CONTROLS + 2*RELATED_CONTROLS + 5*FIXEDTEXT_HEIGHT ) ; + Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; + Text [ en-US ] = "Control ~user name" ; + }; + Edit ET_CTRLUSERNAME + { + Border = TRUE ; + Pos = MAP_APPFONT ( EDIT_X , 4*UNRELATED_CONTROLS + 2*RELATED_CONTROLS + 5*FIXEDTEXT_HEIGHT-1 ) ; + Size = MAP_APPFONT ( 105 , EDIT_HEIGHT ) ; + TabStop = TRUE ; + }; + FixedText FT_CTRLPASSWORD + { + Pos = MAP_APPFONT ( 6 , 5*UNRELATED_CONTROLS + 2*RELATED_CONTROLS + 6*FIXEDTEXT_HEIGHT ) ; + Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; + Text [ en-US ] = "Control ~password" ; + }; + Edit ET_CTRLPASSWORD + { + Border = TRUE ; + Pos = MAP_APPFONT ( EDIT_X , 5*UNRELATED_CONTROLS + 2*RELATED_CONTROLS + 6*FIXEDTEXT_HEIGHT-1 ) ; + Size = MAP_APPFONT ( 105 , EDIT_HEIGHT) ; + TabStop = TRUE ; + PassWord = TRUE ; + }; + + CheckBox CB_SHUTDB + { + Pos = MAP_APPFONT ( 6 , 6*UNRELATED_CONTROLS + 2*RELATED_CONTROLS + 7*FIXEDTEXT_HEIGHT ) ; + Size = MAP_APPFONT ( 248 , CHECKBOX_HEIGHT ) ; + Text[ en-US ] = "~Shut down service when closing %PRODUCTNAME"; + }; + + PushButton PB_STAT + { + Pos = MAP_APPFONT ( PAGE_X - BUTTON_WIDTH - UNRELATED_CONTROLS, PAGE_Y - BUTTON_HEIGHT - UNRELATED_CONTROLS ) ; + Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ; + Text[ en-US ] = "E~xtended..."; + }; + + AUTO_CHARSET( 7*UNRELATED_CONTROLS + 2*RELATED_CONTROLS + 7*FIXEDTEXT_HEIGHT + CHECKBOX_HEIGHT, PAGE_X ) +}; + +//......................................................................... +#define MYSQL_YDIST 53 +#define MYSQL_FL_Y 8 +#define MYSQL_DRIVERCLASS_Y 8 + +TabPage PAGE_MYSQL_ODBC +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( PAGE_X , PAGE_Y ) ; + Hide = TRUE; + + AUTO_CHARSET( UNRELATED_CONTROLS, PAGE_X ) +}; + +TabPage PAGE_MYSQL_JDBC +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( PAGE_X , PAGE_Y ) ; + Hide = TRUE; + + AUTO_FIXEDLINE_CONNSETTINGS( UNRELATED_CONTROLS ) + AUTO_HOST_AND_PORT( UNRELATED_CONTROLS + RELATED_CONTROLS + FIXEDTEXT_HEIGHT ) + AUTO_SOCKETCONTROLGROUP(3*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT) + + FixedText FT_JDBCDRIVERCLASS + { + Pos = MAP_APPFONT ( 6, + 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + EDIT_HEIGHT) ; + Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "MySQL JDBC d~river class"; + }; + Edit ET_JDBCDRIVERCLASS + { + Pos = MAP_APPFONT ( EDIT_X, + 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT -1 + EDIT_HEIGHT) ; + Size = MAP_APPFONT ( 97 , EDIT_HEIGHT ) ; + TabStop = TRUE ; + Border = TRUE ; + }; + PushButton PB_TESTDRIVERCLASS + { + TabStop = TRUE ; + Pos = MAP_APPFONT ( PAGE_X - BUTTON_WIDTH - UNRELATED_CONTROLS , 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT -2 + EDIT_HEIGHT) ; + Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ; + Text [ en-US ] = "Test class" ; + }; + + AUTO_CHARSET( 5*UNRELATED_CONTROLS + RELATED_CONTROLS + 4*FIXEDTEXT_HEIGHT+ EDIT_HEIGHT, PAGE_X ) +}; + +TabPage PAGE_MYSQL_NATIVE +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( PAGE_X , PAGE_Y ) ; + Hide = TRUE; + + AUTO_FIXEDLINE_CONNSETTINGS( UNRELATED_CONTROLS ) + + FixedLine FL_SEPARATOR2 + { + Pos = MAP_APPFONT ( 3 , 4*UNRELATED_CONTROLS + 3*RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + 3*EDIT_HEIGHT ) ; + Size = MAP_APPFONT ( PAGE_X - 6, FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "User authentication"; + }; + FixedText FT_USERNAME + { + Pos = MAP_APPFONT ( 6 , 4*UNRELATED_CONTROLS + 4*RELATED_CONTROLS + 4*FIXEDTEXT_HEIGHT + 3*EDIT_HEIGHT ) ; + Size = MAP_APPFONT ( EDIT_X - 6 - RELATED_CONTROLS, FIXEDTEXT_HEIGHT ) ; + Text [ en-US ] = "~User name" ; + }; + Edit ET_USERNAME + { + Border = TRUE ; + Pos = MAP_APPFONT ( EDIT_X, 4*UNRELATED_CONTROLS + 4*RELATED_CONTROLS + 4*FIXEDTEXT_HEIGHT + 3*EDIT_HEIGHT - 1 ) ; + Size = MAP_APPFONT ( 105 , EDIT_HEIGHT ) ; + TabStop = TRUE ; + }; + CheckBox CB_PASSWORD_REQUIRED + { + Pos = MAP_APPFONT ( EDIT_X, 4*UNRELATED_CONTROLS + 5*RELATED_CONTROLS + 4*FIXEDTEXT_HEIGHT + 4*EDIT_HEIGHT ) ; + Size = MAP_APPFONT ( 105, CHECKBOX_HEIGHT ) ; + Text [ en-US ] = "Password required"; + }; + + AUTO_CHARSET( 5*UNRELATED_CONTROLS + 5*RELATED_CONTROLS + 5*FIXEDTEXT_HEIGHT + 4*EDIT_HEIGHT, PAGE_X ) +}; + +TabPage PAGE_ORACLE_JDBC +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( PAGE_X , PAGE_Y ) ; + Hide = TRUE; + + AUTO_FIXEDLINE_CONNSETTINGS( UNRELATED_CONTROLS ) + AUTO_HOST_AND_PORT( UNRELATED_CONTROLS + RELATED_CONTROLS + FIXEDTEXT_HEIGHT ) + + AUTO_SOCKETCONTROLGROUP(3*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT) + + FixedText FT_JDBCDRIVERCLASS + { + Pos = MAP_APPFONT ( 6, + 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + EDIT_HEIGHT) ; + Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "Oracle JDBC d~river class"; + }; + Edit ET_JDBCDRIVERCLASS + { + Pos = MAP_APPFONT ( EDIT_X, + 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + EDIT_HEIGHT + ( FIXEDTEXT_HEIGHT - EDIT_HEIGHT ) / 2 ) ; + Size = MAP_APPFONT ( 97 , EDIT_HEIGHT ) ; + TabStop = TRUE ; + Border = TRUE ; + }; + PushButton PB_TESTDRIVERCLASS + { + TabStop = TRUE ; + Pos = MAP_APPFONT ( PAGE_X - BUTTON_WIDTH - UNRELATED_CONTROLS, + 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + EDIT_HEIGHT + ( FIXEDTEXT_HEIGHT - BUTTON_HEIGHT ) / 2 ) ; + Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ; + Text [ en-US ] = "Test class" ; + }; + + AUTO_CHARSET( 5*UNRELATED_CONTROLS + RELATED_CONTROLS + 4*FIXEDTEXT_HEIGHT+ EDIT_HEIGHT, PAGE_X ) +}; + +//......................................................................... + +TabPage PAGE_LDAP +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( PAGE_X , PAGE_Y ) ; + Hide = TRUE; + HelpId = HID_DSADMIN_PAGE_LDAP; + + FixedLine FL_SEPARATOR1 + { + Pos = MAP_APPFONT ( 4 , UNRELATED_CONTROLS ) ; + Size = MAP_APPFONT ( PAGE_X - 8 , FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "Connection Settings"; + }; + + FixedText FT_BASEDN + { + Pos = MAP_APPFONT ( 6 , UNRELATED_CONTROLS + RELATED_CONTROLS + FIXEDTEXT_HEIGHT) ; + Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "~Base DN"; + }; + Edit ET_BASEDN + { + TabStop = TRUE ; + Border = TRUE ; + HelpId = HID_DSADMIN_LDAP_BASEDN; + + Pos = MAP_APPFONT ( EDIT_X , UNRELATED_CONTROLS + RELATED_CONTROLS + FIXEDTEXT_HEIGHT -1 ) ; + Size = MAP_APPFONT ( 105 , EDIT_HEIGHT ) ; + }; + CheckBox CB_USESSL + { + Pos = MAP_APPFONT ( 6 , 2*UNRELATED_CONTROLS + RELATED_CONTROLS + 2*FIXEDTEXT_HEIGHT) ; + Size = MAP_APPFONT ( PAGE_X - 12 , CHECKBOX_HEIGHT ) ; + Text [ en-US ] = "Use secure connection(SSL)"; + HelpId = HID_DSADMIN_USESSL_LDAP; + }; + + FixedText FT_PORTNUMBER + { + Pos = MAP_APPFONT ( 6 , 3*UNRELATED_CONTROLS + RELATED_CONTROLS + 2*FIXEDTEXT_HEIGHT + CHECKBOX_HEIGHT) ; + Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "~Port number"; + }; + NumericField NF_PORTNUMBER + { + TabStop = TRUE ; + Border = TRUE ; + HelpId = HID_DSADMIN_LDAP_PORTNUMBER; + NoThousandSep = TRUE; + + Pos = MAP_APPFONT ( EDIT_X , 3*UNRELATED_CONTROLS + RELATED_CONTROLS + 2*FIXEDTEXT_HEIGHT-1 + CHECKBOX_HEIGHT) ; + Size = MAP_APPFONT ( 105 , EDIT_HEIGHT ) ; + }; + FixedText FT_LDAPROWCOUNT + { + Pos = MAP_APPFONT ( 6 , 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + CHECKBOX_HEIGHT ) ; + Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "Maximum number of ~records"; + }; + NumericField NF_LDAPROWCOUNT + { + TabStop = TRUE ; + Border = TRUE ; + HelpId = HID_DSADMIN_LDAP_ROWCOUNT; + NoThousandSep = TRUE; + + Pos = MAP_APPFONT ( EDIT_X , 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT -1 + CHECKBOX_HEIGHT) ; + Size = MAP_APPFONT ( 105 , EDIT_HEIGHT ) ; + }; +}; + + +//......................................................................... + +TabPage PAGE_TEXT +{ + SVLook = TRUE ; + Hide = TRUE; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( PAGE_X , PAGE_Y ) ; + HelpId = HID_DSADMIN_PAGE_TEXT; + + AUTO_SEPARATORCONTROLGROUP(UNRELATED_CONTROLS, PAGE_X) + +}; +//......................................................................... +TabPage PAGE_USERDRIVER +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( PAGE_X , PAGE_Y ) ; + Hide = TRUE; + HelpId = HID_DSADMIN_PAGE_USERDRIVER; + + FixedText FT_HOSTNAME + { + Pos = MAP_APPFONT ( 6 , UNRELATED_CONTROLS ) ; + Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "~Hostname"; + }; + Edit ET_HOSTNAME + { + TabStop = TRUE ; + Border = TRUE ; + Pos = MAP_APPFONT ( EDIT_X , UNRELATED_CONTROLS -1 ) ; + Size = MAP_APPFONT ( 105 , EDIT_HEIGHT ) ; + }; + + FixedText FT_PORTNUMBER + { + Pos = MAP_APPFONT ( 6 , 2*UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT) ; + Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "~Port number"; + }; + + NumericField NF_PORTNUMBER + { + TabStop = TRUE ; + Border = TRUE ; + NoThousandSep = TRUE; + + Pos = MAP_APPFONT ( EDIT_X , 2*UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT -1 ) ; + Size = MAP_APPFONT ( 105 , EDIT_HEIGHT ) ; + }; + + FixedText FT_OPTIONS + { + Pos = MAP_APPFONT ( 6 , 3*UNRELATED_CONTROLS + 2*FIXEDTEXT_HEIGHT ) ; + Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; + Text [ en-US ] = "~Driver settings" ; + }; + Edit ET_OPTIONS + { + Border = TRUE ; + TabStop = TRUE ; + }; + AUTO_CHARSET( 4*UNRELATED_CONTROLS+ 3*FIXEDTEXT_HEIGHT + RELATED_CONTROLS, PAGE_X) +}; + +String STR_ERR_USE_CONNECT_TO +{ + Text [ en-US ] = "Please choose 'Connect to an existing database' to connect to an existing database instead."; +}; diff --git a/dbaccess/source/ui/dlg/dbadmin2.src b/dbaccess/source/ui/dlg/dbadmin2.src new file mode 100644 index 000000000000..50b796541872 --- /dev/null +++ b/dbaccess/source/ui/dlg/dbadmin2.src @@ -0,0 +1,188 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif + +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef _DBAUI_DBADMIN_HRC_ +#include "dbadmin.hrc" +#endif +#ifndef DBACCESS_UI_BROWSER_ID_HXX +#include "browserids.hxx" +#endif +#ifndef DBAUI_TOOLBOX_HXX +#include "toolbox.hrc" +#endif +#ifndef _DBAUI_AUTOCONTROLS_HRC_ +#include "AutoControls.hrc" +#endif + +//......................................................................... + +String STR_ENTER_CONNECTION_PASSWORD +{ + Text [ en-US ] = "A password is needed to connect to the data source \"$name$\"."; +}; + +String STR_QUERY_DROP_ALL +{ + Text[ en-US ] = "Do you want to delete all selected items?"; +}; + +String STR_ASK_FOR_DIRECTORY_CREATION +{ + Text [ en-US ] = "The directory\n\n$path$\n\ndoes not exist. Should it be created?"; +}; + +String STR_COULD_NOT_CREATE_DIRECTORY +{ + Text [ en-US ] = "The directory $name$ could not be created."; +}; + +String STR_ADDRESSBOOK_SYSTEM +{ + Text[ en-US ] = "Windows address book"; +}; +String STR_ADDRESSBOOK_OUTLOOK +{ + Text[ en-US ] = "MS Outlook"; +}; +String STR_ADDRESSBOOK_MOZILLA +{ + Text[ en-US ] = "Mozilla address book"; +}; +String STR_ADDRESSBOOK_THUNDERBIRD +{ + Text[ en-US ] = "Thunderbird address book"; +}; +String STR_ADDRESSBOOK_EVOLUTION +{ + Text[ en-US ] = "Evolution address book"; +}; +String STR_ADDRESSBOOK_LDAP +{ + Text[ en-US ] = "LDAP address book"; +}; + +String STR_HINT_READONLY_CONNECTION +{ + Text [ en-US ] = "(Connection is read-only)"; +}; + +String STR_HINT_CONNECTION_NOT_CAPABLE +{ + Text [ en-US ] = "(Not supported by this connection)"; +}; + +#define EDIT_SIZE_X 50 +#define FT_SIZE_X 90 +#define WIN_X 220 +#define WIN_Y 72 + +ModalDialog DLG_DOMAINPASSWORD +{ + Border = TRUE ; + Moveable = TRUE ; + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( WIN_X , WIN_Y ) ; + Text[ en-US ] = "Convert Database"; + + FixedLine FT_PASSWORD + { + Pos = MAP_APPFONT ( 3 , 3 ) ; + Size = MAP_APPFONT ( WIN_X - 3 - 6 - 6 - 50 , 8 ) ; + Text[ en-US ] = "Please enter the ~password for the user 'DOMAIN'."; + }; + + Edit ET_PASSWORD + { + Border = TRUE ; + Pos = MAP_APPFONT ( 12 + FT_SIZE_X , 16 ) ; + Size = MAP_APPFONT ( EDIT_SIZE_X , 12 ) ; + PassWord = TRUE ; + }; + OKButton BTN_PASSWORD_OK + { + Pos = MAP_APPFONT ( WIN_X - 56 , 6 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + DefButton = TRUE ; + }; + CancelButton BTN_PASSWORD_CANCEL + { + Pos = MAP_APPFONT ( WIN_X - 56 , 23 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + }; + HelpButton BTN_PASSWORD_HELP + { + Pos = MAP_APPFONT ( WIN_X - 56 , 43 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + }; +}; + +#define PAGE_X_T (PAGE_X -80) +#define PAGE_Y_T (PAGE_Y -50) + +TabPage PAGE_TABLESUBSCRIPTION +{ + SVLook = TRUE ; + Hide = TRUE; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( PAGE_X_T, PAGE_Y_T) ; + HelpId = HID_DSADMIN_TABLE_SUBSCRIPTION; + + Text [ en-US ] = "Tables Filter" ; + + FixedLine FL_SEPARATOR1 + { + Pos = MAP_APPFONT ( RELATED_CONTROLS , UNRELATED_CONTROLS ) ; + Size = MAP_APPFONT ( PAGE_X_T - 2* RELATED_CONTROLS, FIXEDTEXT_HEIGHT ) ; + Text [ en-US ] = "Tables and table filter"; + }; + Control CTL_TABLESUBSCRIPTION + { + Pos = MAP_APPFONT ( UNRELATED_CONTROLS , UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + RELATED_CONTROLS) ; + Size = MAP_APPFONT ( PAGE_X_T - 2*UNRELATED_CONTROLS , 81 ) ; + Group = TRUE; + Border = TRUE ; + TabStop = TRUE ; + HelpId = HID_DSADMIN_TABLE_SELECTOR; + }; + FixedText FT_FILTER_EXPLANATION + { + Pos = MAP_APPFONT ( UNRELATED_CONTROLS , 2*UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + RELATED_CONTROLS + 81 ) ; + Size = MAP_APPFONT ( PAGE_X_T - 2*UNRELATED_CONTROLS , 16 ) ; + HelpId = HID_DSADMIN_FILTER_EXPLANATION; + WordBreak = TRUE; + Text [ en-US ] = "Mark the tables that should be visible for the applications."; + }; +}; + diff --git a/dbaccess/source/ui/dlg/dbadminsetup.hrc b/dbaccess/source/ui/dlg/dbadminsetup.hrc new file mode 100644 index 000000000000..b53e12425af7 --- /dev/null +++ b/dbaccess/source/ui/dlg/dbadminsetup.hrc @@ -0,0 +1,136 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBAUI_DBADMINSETUP_HRC_ +#define _DBAUI_DBADMINSETUP_HRC_ + + +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef DBACCESS_UI_BROWSER_ID_HXX +#include "browserids.hxx" +#endif + + +#define STR_DBASE_HELPTEXT 28 +#define STR_MSACCESS_HELPTEXT 29 +#define STR_TEXT_HELPTEXT 30 + // FREE +#define STR_ADO_HELPTEXT 32 +#define STR_JDBC_HELPTEXT 33 +#define STR_ODBC_HELPTEXT 34 +#define STR_MYSQLJDBC_HELPTEXT 35 +#define STR_SPREADSHEET_HELPTEXT 36 + // FREE +#define STR_FINAL_HELPTEXT 38 +#define STR_ADABAS_HELPTEXT 39 +#define STR_ORACLE_HELPTEXT 40 +#define STR_DBASE_HEADERTEXT 41 +#define STR_MSACCESS_HEADERTEXT 42 +#define STR_TEXT_HEADERTEXT 43 + // FREE +#define STR_ADO_HEADERTEXT 45 +#define STR_JDBC_HEADERTEXT 46 +#define STR_ODBC_HEADERTEXT 47 +#define STR_MYSQLJDBC_HEADERTEXT 48 + // FREE +#define STR_SPREADSHEET_HEADERTEXT 50 +#define STR_FINAL_HEADERTEXT 52 +#define STR_ADABAS_HEADERTEXT 53 +#define STR_ORACLE_HEADERTEXT 54 +#define STR_GENERAL_HEADERTEXT 55 +#define STR_DBWIZARDTITLE 56 + +#define STR_DEFAULTLDAPPORTNUMBER 60 + +#define STR_ADABASNAME 61 +//#define STR_ADOURL 62 +#define STR_ODBCDATASOURCENAME 63 +#define STR_SPREADSHEETPATH 64 +#define STR_DBLOCATIONLABEL 65 +#define STR_ADMIN_HELPTEXT 66 + +#define STR_ORACLE_DEFAULT 67 +#define STR_PAGETITLE_INTROPAGE 69 +#define STR_PAGETITLE_DBASE 70 +#define STR_PAGETITLE_TEXT 71 +#define STR_PAGETITLE_MSACCESS 72 +#define STR_PAGETITLE_LDAP 73 +#define STR_PAGETITLE_ADABAS 74 +#define STR_PAGETITLE_ADO 75 +#define STR_PAGETITLE_JDBC 76 +#define STR_PAGETITLE_ORACLE 77 +#define STR_PAGETITLE_MYSQL 78 +#define STR_PAGETITLE_ODBC 79 +#define STR_PAGETITLE_SPREADSHEET 80 +#define STR_PAGETITLE_AUTHENTIFICATION 81 +#define STR_PAGETITLE_FINAL 82 +#define STR_MYSQL_DEFAULT 83 +#define STR_ORACLE_DRIVERCLASSTEXT 84 +#define STR_MYSQL_DRIVERCLASSTEXT 85 +#define STR_LDAP_DEFAULT 86 +#define STR_PAGETITLE_MYSQL_NATIVE 87 + + +#define FT_PORTNUMBERDEFAULT 1 +#define FT_LDAP_HELPTEXT 2 +#define FT_MYSQL_HELPTEXT 3 +#define FT_MYSQL_HEADERTEXT 4 +#define FT_MYSQLCONNECTIONMODE 5 +#define FT_BROWSEURL 6 +#define FT_AUTHENTIFICATIONHELPTEXT 7 +#define FT_AUTHENTIFICATIONHEADERTEXT 8 +#define FT_LDAP_HEADERTEXT 9 +#define FT_GENERALUSERNAME 10 +#define FT_FINALHEADER 11 +#define FT_FINALTEXT 12 +#define FT_FINALHELPTEXT 13 +#define FT_ADDITIONALSETTINGS 14 +#define FT_SETUP_WIZARD_HEADER 15 +#define FT_SETUP_WIZARD_HELP 16 + +#define ET_GENERALUSERNAME 1 + +#define PB_TESTCONNECTION 1 + +#define RB_CONNECTVIAODBC 1 +#define RB_CONNECTVIAJDBC 2 +#define RB_REGISTERDATASOURCE 3 +#define RB_DONTREGISTERDATASOURCE 4 +#define RB_CONNECTVIANATIVE 5 + +#define CB_WIZ_USESSL 1 +#define CB_STARTTABLEWIZARD 2 +#define CB_OPENAFTERWARDS 3 +#define CB_SPREADSHEETPASSWORDREQUIRED 4 +#define CB_GENERALPASSWORDREQUIRED 5 + +#endif diff --git a/dbaccess/source/ui/dlg/dbadminsetup.src b/dbaccess/source/ui/dlg/dbadminsetup.src new file mode 100644 index 000000000000..7b0dbe011342 --- /dev/null +++ b/dbaccess/source/ui/dlg/dbadminsetup.src @@ -0,0 +1,673 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBAUI_DBADMINSETUP_HRC_ +#include "dbadminsetup.hrc" +#endif + +#ifndef _DBAUI_AUTOCONTROLS_HRC_ +#include "AutoControls.hrc" +#endif + + +#define CHECKBOX_HEIGHT 8 +#define FIXEDTEXT_HEIGHT 8 +#define RELATED_CONTROLS 4 +#define UNRELATED_CONTROLS 7 +#define EDIT_HEIGHT 12 +#define EDIT_X 101 + + +// ----------------------------------------------------------------------------- +ModalDialog DLG_DATABASE_WIZARD +{ + OutputSize = TRUE ; + Moveable = TRUE; + Closeable = TRUE ; + HelpId = HID_DLG_DATABASE_WIZARD; + Hide = TRUE; + Text[ en-US ] = "Database Wizard" ; + + TabControl 1 + { + OutputSize = TRUE ; + HelpId = HID_DSADMIN_TABCONTROL; + SingleLine=TRUE; + }; + + String STR_DBWIZARDTITLE + { + Text[ en-US ] = "Database Wizard" ; + }; + + String STR_PAGETITLE_INTROPAGE + { + Text[ en-US ] = "Select database" ; + }; + + String STR_PAGETITLE_DBASE + { + Text[ en-US ] = "Set up dBASE connection" ; + + }; + + String STR_PAGETITLE_TEXT + { + Text[ en-US ] = "Set up a connection to text files" ; + }; + + + String STR_PAGETITLE_MSACCESS + { + Text[ en-US ] = "Set up Microsoft Access connection" ; + }; + + String STR_PAGETITLE_LDAP + { + Text[ en-US ] = "Set up LDAP connection" ; + }; + + String STR_PAGETITLE_ADABAS + { + Text[ en-US ] = "Set up Adabas D connection" ; + }; + + String STR_PAGETITLE_ADO + { + Text[ en-US ] = "Set up ADO connection" ; + }; + + String STR_PAGETITLE_JDBC + { + Text[ en-US ] = "Set up JDBC connection" ; + }; + + String STR_PAGETITLE_ORACLE + { + Text[ en-US ] = "Set up Oracle database connection" ; + }; + + String STR_PAGETITLE_MYSQL + { + Text[ en-US ] = "Set up MySQL connection" ; + }; + + String STR_PAGETITLE_ODBC + { + Text[ en-US ] = "Set up ODBC connection" ; + }; + + String STR_PAGETITLE_SPREADSHEET + { + Text[ en-US ] = "Set up Spreadsheet connection" ; + }; + + String STR_PAGETITLE_AUTHENTIFICATION + { + Text[ en-US ] = "Set up user authentication" ; + }; + + String STR_PAGETITLE_MYSQL_NATIVE + { + Text [ en-US ] = "Set up MySQL server data"; + }; + + String STR_PAGETITLE_FINAL + { + Text[ en-US ] = "Save and proceed" ; + }; +}; + + +String STR_DATABASEDEFAULTNAME +{ + Text[ en-US ] = "New Database" ; +}; + + +TabPage PAGE_DBWIZARD_MYSQL_INTRO +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ; + Hide = TRUE ; + + FixedText FT_MYSQL_HEADERTEXT + { + Pos = MAP_APPFONT ( START_X , 8 ) ; + Size = MAP_APPFONT ( (WIZARD_PAGE_X - START_X) - 12 , 2 * FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "Set up a connection to a MySQL database"; + WordBreak = TRUE; + }; + + + FixedText FT_MYSQL_HELPTEXT + { + Pos = MAP_APPFONT (START_X , 27 ) ; + Size = MAP_APPFONT ( 213 , 48 ) ; + Text[ en-US ] = "You can connect to a MySQL database using either ODBC or JDBC.\nPlease contact your system administrator if you are unsure about the following settings."; + WordBreak = TRUE ; + }; + + FixedText FT_MYSQLCONNECTIONMODE + { + Pos = MAP_APPFONT (START_X , 79 ) ; + Size = MAP_APPFONT ( 209 , 8 ) ; + Text[ en-US ] = "How do you want to connect to your MySQL database?" ; + }; + + RadioButton RB_CONNECTVIAODBC + { + HelpId = HID_PAGE_DBWIZARD_MYSQL_RB_CONNECTVIAODBC ; + Pos = MAP_APPFONT (START_X + 6 , 91 ) ; + Size = MAP_APPFONT ( 205 , 9 ) ; + Text[ en-US ] = "Connect using ODBC (Open Database Connectivity)" ; + }; + + RadioButton RB_CONNECTVIAJDBC + { + HelpId = HID_PAGE_DBWIZARD_MYSQL_RB_CONNECTVIAJDBC ; + Pos = MAP_APPFONT (START_X + 6, 103 ) ; + Size = MAP_APPFONT ( 208 , 8 ) ; + Text[ en-US ] = "Connect using JDBC (Java Database Connectivity)" ; + }; + RadioButton RB_CONNECTVIANATIVE + { + Pos = MAP_APPFONT (START_X + 6 , 115 ) ; + Size = MAP_APPFONT ( 205 , 9 ) ; + Text[ en-US ] = "Connect directly" ; + Hide = TRUE ; + }; + +}; + +#define AUTHENTEDIT_X (EDIT_X - 10) + +TabPage PAGE_DBWIZARD_AUTHENTIFICATION +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ; + Hide = TRUE ; + + FixedText FT_AUTHENTIFICATIONHEADERTEXT + { + Pos = MAP_APPFONT ( START_X , 8 ) ; + Size = MAP_APPFONT ( (WIZARD_PAGE_X - START_X) - 12 , 2 * FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "Set up the user authentication"; + WordBreak = TRUE; + }; + + + FixedText FT_AUTHENTIFICATIONHELPTEXT\ + { + Pos = MAP_APPFONT (START_X , 27 ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X - START_X - 6, 3*FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "Some databases require you to enter a user name." ;\ + WordBreak = TRUE ; + }; + + FixedText FT_GENERALUSERNAME + { + Pos = MAP_APPFONT (START_X , 62 ) ; + Size = MAP_APPFONT ( AUTHENTEDIT_X - START_X , FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "~User name" ; + }; + + Edit ET_GENERALUSERNAME + { + Border = TRUE ; + HelpId = HID_PAGE_DBWIZARD_AUTHENTIFICATION_ET_GENERALUSERNAME ; + Pos = MAP_APPFONT (AUTHENTEDIT_X , 60 ) ; + Size = MAP_APPFONT ( (WIZARD_PAGE_X - AUTHENTEDIT_X - 6), EDIT_HEIGHT ) ; + }; + + CheckBox CB_GENERALPASSWORDREQUIRED + { + HelpId = HID_PAGE_DBWIZARD_AUTHENTIFICATION_CB_GENERALPASSWORDREQUIRED ; + Pos = MAP_APPFONT (AUTHENTEDIT_X , 76 ); + Size = MAP_APPFONT ( 93 , CHECKBOX_HEIGHT ); + Text[ en-US ] = "Password re~quired" ; + }; + + PushButton PB_TESTCONNECTION + { + HelpId = HID_PAGE_DBWIZARD_AUTHENTIFICATION_PB_TESTCONNECTION ; + Pos = MAP_APPFONT (WIZARD_PAGE_X - BUTTON_WIDTH - UNRELATED_CONTROLS , WIZARD_PAGE_Y - 18 ) ; + Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ; + Text[ en-US ] = "~Test Connection" ; + }; + +}; + + +TabPage PAGE_DBWIZARD_FINAL +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ; + Hide = TRUE ; + + + FixedText FT_FINALHEADER + { + Pos = MAP_APPFONT ( START_X , 8 ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X - START_X - 6 , 2* FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "Decide how to proceed after saving the database"; + WordBreak = TRUE; + }; + + FixedText FT_FINALHELPTEXT + { + Pos = MAP_APPFONT (START_X , 27 ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X - START_X - 6, 2*FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "Do you want the wizard to register the database in %PRODUCTNAME?" ; + WordBreak = TRUE ; + }; + + + RadioButton RB_REGISTERDATASOURCE + { + HelpId = HID_PAGE_DBWIZARD_FINAL_RB_REGISTERDATASOURCE; + Pos = MAP_APPFONT (START_X + 6 , 45 ) ; + Size = MAP_APPFONT ( 205 , 9 ) ; + Group = TRUE; + Text[ en-US ] = "~Yes, register the database for me" ; + }; + + + RadioButton RB_DONTREGISTERDATASOURCE + { + HelpId = HID_PAGE_DBWIZARD_FINAL_RB_DONTREGISTERDATASOURCE ; + Pos = MAP_APPFONT (START_X + 6, 57 ) ; + Size = MAP_APPFONT ( 208 , 8 ) ; + Text[ en-US ] = "N~o, do not register the database" ; + }; + + FixedText FT_ADDITIONALSETTINGS + { + Pos = MAP_APPFONT (START_X , 100 ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X - START_X - 6 , 8 ) ; + Text[ en-US ] = "After the database file has been saved, what do you want to do?" ; + }; + + CheckBox CB_OPENAFTERWARDS + { + HelpId = HID_PAGE_DBWIZARD_FINAL_CB_OPENAFTERWARDS ; + Pos = MAP_APPFONT (START_X + 6, 118 ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X - START_X , 8 ) ; + Text[ en-US ] = "Open the database for editing" ; + }; + + CheckBox CB_STARTTABLEWIZARD + { + HelpId = HID_PAGE_DBWIZARD_FINAL_CB_STARTTABLEWIZARD ; + Pos = MAP_APPFONT (START_X + 6, 130 ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X - START_X - 12 , 8 ) ; + Text[ en-US ] = "Create tables using the table wizard" ; + }; + + + FixedText FT_FINALTEXT + { + Pos = MAP_APPFONT ( START_X , 173 ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X - START_X - 6 , 2* FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "Click 'Finish' to save the database."; + WordBreak = TRUE; + }; +}; + +TabPage PAGE_DBWIZARD_MYSQL_JDBC +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ; + Hide = TRUE ; + + + String STR_MYSQLJDBC_HEADERTEXT + { + Text[ en-US ] = "Set up connection to a MySQL database using JDBC" ; + }; + + String STR_MYSQLJDBC_HELPTEXT + { + Text[ en-US ] = "Please enter the required information to connect to a MySQL database using JDBC. Note that a JDBC driver class must be installed on your system and registered with %PRODUCTNAME.\nPlease contact your system administrator if you are unsure about the following settings."; + }; + + String STR_MYSQL_DRIVERCLASSTEXT + { + Text [ en-US ] = "MySQL JDBC d~river class:"; + }; + + + String STR_MYSQL_DEFAULT + { + Text[ en-US ] = "Default: 3306"; + }; + + AUTOHELP_JDBCCONTROLGROUP(HID_PAGE_DBWIZARD_JDBC_ET_MYSQLDBNAME) +}; + +TabPage PAGE_DBWIZARD_MYSQL_NATIVE +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0, 0 ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ; + Hide = TRUE ; + + FixedText FT_SETUP_WIZARD_HEADER + { + Pos = MAP_APPFONT ( START_X , 8 ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X - START_X - 12 , 2 * FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "Set up connection to a MySQL database" ; + WordBreak = TRUE; + }; + + FixedText FT_SETUP_WIZARD_HELP + { + Pos = MAP_APPFONT ( START_X , INIT_Y ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X - START_X - 12 , 3 * FIXEDTEXT_HEIGHT ) ; + Text [ en-US ] = "Please enter the required information to connect to a MySQL database."; + WordBreak = TRUE; + }; +}; + + +TabPage PAGE_DBWIZARD_DBASE +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ; + Hide = TRUE ; + + String STR_DBASE_HEADERTEXT + { + Text[ en-US ] = "Set up a connection to dBASE files" ; + }; + + + String STR_DBASE_HELPTEXT + { + Text[ en-US ] = "Select the folder where the dBASE files are stored." ; + }; + + AUTO_HELP_BROWSECONTROLGROUP( 3, HID_PAGE_DBWIZARD_DBASE_ET_DBASELOCATION) +}; + + +TabPage PAGE_DBWIZARD_TEXT +{ + + String STR_TEXT_HEADERTEXT + { + Text[ en-US ] = "Set up a connection to text files" ; + }; + + + String STR_TEXT_HELPTEXT + { + Text[ en-US ] = "Select the folder where the CSV (Comma Separated Values) text files are stored. %PRODUCTNAME Base will open these files in read-only mode." ; + }; + + + String STR_TEXT_PATH_OR_FILE{ + Text[ en-US ] = "Path to text files"; + }; + + + AUTO_HELP_BROWSECONTROLGROUP(3, HID_PAGE_DBWIZARD_TEXT_ET_LOCATIONTEXTFILE) + AUTO_SEPARATORCONTROLGROUP(82, WIZARD_PAGE_X) + }; + + + +TabPage PAGE_DBWIZARD_MSACCESS +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ; + Hide = TRUE ; + + String STR_MSACCESS_HEADERTEXT + { + Text[ en-US ] = "Set up a connection to a Microsoft Access database" ; + }; + + + String STR_MSACCESS_HELPTEXT + { + Text[ en-US ] = "Please select the Microsoft Access file you want to access."; + }; + + AUTO_HELP_BROWSECONTROLGROUP(3, HID_PAGE_DBWIZARD_MSACCESS_ET_MSACCESSLOCATION) +// FT_MSACCESS_MDB_FILE +}; + + +TabPage PAGE_DBWIZARD_LDAP +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ; + Hide = TRUE ; + + FixedText FT_LDAP_HEADERTEXT + { + Pos = MAP_APPFONT ( START_X , 8 ) ; + Size = MAP_APPFONT ( (WIZARD_PAGE_X - START_X) - 12 , 2 * FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "Set up a connection to an LDAP directory"; + WordBreak = TRUE; + }; + + + FixedText FT_LDAP_HELPTEXT + { + Pos = MAP_APPFONT (START_X , 27 ) ; + Size = MAP_APPFONT (WIZARD_PAGE_X - START_X - 6, 5 * FIXEDTEXT_HEIGHT ) ; + Text[ en-US ] = "Please enter the required information to connect to an LDAP directory.\nPlease contact your system administrator if you are unsure about the following settings." ; + WordBreak = TRUE ; + }; + AUTO_HOSTCONTROLGROUP( INIT_Y + 7 * FIXEDTEXT_HEIGHT + UNRELATED_CONTROLS, HID_PAGE_DBWIZARD_LDAP_ET_HOSTSERVER) + AUTO_BASEDNCONTROLGROUP(INIT_Y + 7 * FIXEDTEXT_HEIGHT + UNRELATED_CONTROLS + EDIT_HEIGHT + RELATED_CONTROLS, HID_PAGE_DBWIZARD_LDAP_ET_BASEDN) + AUTO_PORTCONTROLGROUP( INIT_Y + 7 * FIXEDTEXT_HEIGHT + UNRELATED_CONTROLS + 2 * EDIT_HEIGHT + 2 * RELATED_CONTROLS, HID_PAGE_DBWIZARD_LDAP_ET_PORTNUMBER) + + String STR_LDAP_DEFAULT{ + Text[ en-US ] = "Default: 389" ; + }; + + CheckBox CB_WIZ_USESSL + { + HelpId = HID_PAGE_DBWIZARD_LDAP_CB_USESSL ; + Pos = MAP_APPFONT (START_X , INIT_Y + 7 * FIXEDTEXT_HEIGHT + UNRELATED_CONTROLS + 3 * EDIT_HEIGHT + 4 * RELATED_CONTROLS ) ; + Size = MAP_APPFONT ( 212 , 8 ) ; + Text[ en-US ] = "Use ~secure connection (SSL)" ; + }; +}; + + +TabPage PAGE_DBWIZARD_ADABAS +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ; + Hide = TRUE ; + + String STR_ADABAS_HEADERTEXT + { + Text[ en-US ] = "Set up a connection to an Adabas D database" ; + }; + + + String STR_ADABAS_HELPTEXT{ + Text[ en-US ] = "Enter the name of the Adabas D database you want to connect to.\nClick 'Browse...' to select an Adabas D database that is already registered in %PRODUCTNAME." ; + }; + + AUTO_HELP_BROWSECONTROLGROUP(4, HID_PAGE_DBWIZARD_ADABAS_ET_ADABASNAME) +}; + + +TabPage PAGE_DBWIZARD_ADO +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ; + Hide = TRUE ; + + String STR_ADO_HEADERTEXT + { + Text[ en-US ] = "Set up a connection to an ADO database" ; + }; + + String STR_ADO_HELPTEXT{ + Text[ en-US ] = "Please enter the URL of the ADO data source you want to connect to.\nClick 'Browse' to configure provider-specific settings.\nPlease contact your system administrator if you are unsure about the following settings." ; + }; + + AUTO_HELP_BROWSECONTROLGROUP(5, HID_PAGE_DBWIZARD_ADO_ET_ADOURL) + +}; + + +TabPage PAGE_DBWIZARD_ODBC +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ; + Hide = TRUE ; + + String STR_ODBC_HEADERTEXT + { + Text[ en-US ] = "Set up a connection to an ODBC database" ; + }; + + String STR_ODBC_HELPTEXT{ + Text[ en-US ] = "Enter the name of the ODBC database you want to connect to.\nClick 'Browse...' to select an ODBC database that is already registered in %PRODUCTNAME.\nPlease contact your system administrator if you are unsure about the following settings." ; + }; + + AUTO_HELP_BROWSECONTROLGROUP(6, HID_PAGE_DBWIZARD_ODBC_ET_NAMEOFODBCDATASOURCE) +}; + +TabPage PAGE_DBWIZARD_USERDEFINED +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ; + Hide = TRUE ; + + AUTO_HELP_BROWSECONTROLGROUP(6, HID_PAGE_DBWIZARD_USERDEFINED_ET_BROWSE) +}; + + + +TabPage PAGE_DBWIZARD_JDBC +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ; + Hide = TRUE ; + + String STR_JDBC_HEADERTEXT + { + Text[ en-US ] = "Set up a connection to a JDBC database" ; + }; + + String STR_JDBC_HELPTEXT{ + Text[ en-US ] = "Please enter the required information to connect to a JDBC database.\nPlease contact your system administrator if you are unsure about the following settings." ; + }; + + AUTO_HELP_BROWSECONTROLGROUP(4, HID_PAGE_DBWIZARD_JDBC_ET_JDBCURL) + AUTO_JDBCDRIVERCLASSGROUP(119, HID_PAGE_DBWIZARD_JDBC_ET_JDBCCLASS) +}; + + + +TabPage PAGE_DBWIZARD_ORACLE +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ; + Hide = TRUE ; + + String STR_ORACLE_HEADERTEXT + { + Text[ en-US ] = "Set up a connection to an Oracle database"; + }; + + String STR_ORACLE_DEFAULT + { + Text[ en-US ] = "Default: 1521" ; + }; + + + String STR_ORACLE_DRIVERCLASSTEXT{ + Text [ en-US ] = "Oracle JDBC ~driver class"; + }; + + + String STR_ORACLE_HELPTEXT{ + Text[ en-US ] = "Please enter the required information to connect to an Oracle database.Note that a JDBC Driver Class must be installed on your system and registered with %PRODUCTNAME.\nPlease contact your system administrator if you are unsure about the following settings." ; + }; + + AUTOHELP_JDBCCONTROLGROUP(HID_PAGE_DBWIZARD_ORACLE_ET_ORACLEDBNAME) +}; + + +TabPage PAGE_DBWIZARD_SPREADSHEET +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ; + Hide = TRUE ; + + String STR_SPREADSHEET_HEADERTEXT + { + Text[ en-US ] = "Set up a connection to spreadsheets"; + }; + + + String STR_SPREADSHEET_HELPTEXT{ + Text[ en-US ] = "Click 'Browse...' to select a %PRODUCTNAME spreadsheet or Microsoft Excel workbook.\n%PRODUCTNAME will open this file in read-only mode." ; + }; + + + AUTO_HELP_BROWSECONTROLGROUP(3, HID_PAGE_DBWIZARD_SPREADSHEET_ET_SPREADSHEETPATH ) + + String STR_SPREADSHEETPATH{ + Text[ en-US ] = "~Location and file name" ; + }; + + + CheckBox CB_SPREADSHEETPASSWORDREQUIRED + { + HelpId = HID_PAGE_DBWIZARD_SPREADSHEET_CB_SPREADSHEETPASSWORDREQUIRED ; + Pos = MAP_APPFONT (START_X + UNRELATED_CONTROLS , 83 ) ; + Size = MAP_APPFONT ( 93 , 11 ) ; + Text[ en-US ] = "~Password required" ; + }; +}; + + diff --git a/dbaccess/source/ui/dlg/dbfindex.cxx b/dbaccess/source/ui/dlg/dbfindex.cxx new file mode 100644 index 000000000000..020e23eb87ce --- /dev/null +++ b/dbaccess/source/ui/dlg/dbfindex.cxx @@ -0,0 +1,583 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#ifndef _DBAUI_DBFINDEX_HXX_ +#include "dbfindex.hxx" +#endif + +#ifndef _CONFIG_HXX +#include <tools/config.hxx> +#endif +#ifndef _SFXAPP_HXX //autogen +#include <sfx2/app.hxx> +#endif +#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "moduledbu.hxx" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef _DBAUI_DBF_INDEXES_HRC_ +#include "dbfindex.hrc" +#endif +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif +#ifndef _UNOTOOLS_LOCALFILEHELPER_HXX +#include <unotools/localfilehelper.hxx> +#endif +#ifndef _URLOBJ_HXX +#include <tools/urlobj.hxx> +#endif +#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX +#include <unotools/pathoptions.hxx> +#endif +#ifndef _UCBHELPER_CONTENT_HXX +#include <ucbhelper/content.hxx> +#endif +#ifndef SVTOOLS_FILENOTATION_HXX_ +#include <svl/filenotation.hxx> +#endif + + +//......................................................................... +namespace dbaui +{ +//......................................................................... + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::ucb; +using namespace ::svt; + +const ByteString aGroupIdent("dBase III"); + +////////////////////////////////////////////////////////////////////////// +// Klasse ODbaseIndexDialog +DBG_NAME(ODbaseIndexDialog) +//------------------------------------------------------------------------- +ODbaseIndexDialog::ODbaseIndexDialog( Window * pParent, String aDataSrcName ) + : ModalDialog( pParent, ModuleRes(DLG_DBASE_INDEXES) ), + aPB_OK( this, ModuleRes( PB_OK ) ), + aPB_CANCEL( this, ModuleRes( PB_CANCEL ) ), + aPB_HELP( this, ModuleRes( PB_HELP ) ), + m_FT_Tables( this, ModuleRes( FT_TABLES ) ), + aCB_Tables( this, ModuleRes( CB_TABLES ) ), + m_FL_Indexes( this, ModuleRes( FL_INDEXES ) ), + m_FT_TableIndexes( this, ModuleRes( FT_TABLEINDEXES ) ), + aLB_TableIndexes( this, ModuleRes( LB_TABLEINDEXES ) ), + m_FT_AllIndexes( this, ModuleRes( FT_ALLINDEXES ) ), + aLB_FreeIndexes( this, ModuleRes( LB_FREEINDEXES ) ), + aIB_Add( this, ModuleRes( IB_ADD ) ), + aIB_Remove( this, ModuleRes( IB_REMOVE ) ), + aIB_AddAll( this, ModuleRes( IB_ADDALL ) ), + aIB_RemoveAll( this, ModuleRes( IB_REMOVEALL ) ), + m_aDSN(aDataSrcName), + m_bCaseSensitiv(sal_True) +{ + DBG_CTOR(ODbaseIndexDialog,NULL); + + aCB_Tables.SetSelectHdl( LINK(this, ODbaseIndexDialog, TableSelectHdl) ); + aIB_Add.SetClickHdl( LINK(this, ODbaseIndexDialog, AddClickHdl) ); + aIB_Remove.SetClickHdl( LINK(this, ODbaseIndexDialog, RemoveClickHdl) ); + aIB_AddAll.SetClickHdl( LINK(this, ODbaseIndexDialog, AddAllClickHdl) ); + aIB_RemoveAll.SetClickHdl( LINK(this, ODbaseIndexDialog, RemoveAllClickHdl) ); + aPB_OK.SetClickHdl( LINK(this, ODbaseIndexDialog, OKClickHdl) ); + + aLB_FreeIndexes.SetSelectHdl( LINK(this, ODbaseIndexDialog, OnListEntrySelected) ); + aLB_TableIndexes.SetSelectHdl( LINK(this, ODbaseIndexDialog, OnListEntrySelected) ); + + aCB_Tables.SetDropDownLineCount(8); + Init(); + SetCtrls(); + FreeResource(); + + // set Hi contrast bitmaps + aIB_Add.SetModeImage( ModuleRes(IMG_ONE_LEFT_H),BMP_COLOR_HIGHCONTRAST); + aIB_AddAll.SetModeImage( ModuleRes(IMG_ALL_LEFT_H),BMP_COLOR_HIGHCONTRAST); + aIB_Remove.SetModeImage( ModuleRes(IMG_ONE_RIGHT_H),BMP_COLOR_HIGHCONTRAST); + aIB_RemoveAll.SetModeImage( ModuleRes(IMG_ALL_RIGHT_H),BMP_COLOR_HIGHCONTRAST); +} + +//------------------------------------------------------------------------- +ODbaseIndexDialog::~ODbaseIndexDialog() +{ + + DBG_DTOR(ODbaseIndexDialog,NULL); +} + +//------------------------------------------------------------------------- +sal_Bool ODbaseIndexDialog::GetTable(const String& _rName, TableInfoListIterator& _rPosition) +{ + for ( _rPosition = m_aTableInfoList.begin(); + _rPosition != m_aTableInfoList.end(); + ++_rPosition + ) + { + if (m_bCaseSensitiv) + { + if (_rPosition->aTableName.Equals(_rName)) + return sal_True; + } + else + { + if (_rPosition->aTableName.EqualsIgnoreCaseAscii(_rName)) + return sal_True; + } + } + return sal_False; +} + +//------------------------------------------------------------------------- +void ODbaseIndexDialog::checkButtons() +{ + aIB_Add.Enable(0 != aLB_FreeIndexes.GetSelectEntryCount()); + aIB_AddAll.Enable(0 != aLB_FreeIndexes.GetEntryCount()); + + aIB_Remove.Enable(0 != aLB_TableIndexes.GetSelectEntryCount()); + aIB_RemoveAll.Enable(0 != aLB_TableIndexes.GetEntryCount()); +} + +//------------------------------------------------------------------------- +OTableIndex ODbaseIndexDialog::implRemoveIndex(const String& _rName, TableIndexList& _rList, ListBox& _rDisplay, sal_Bool _bMustExist) +{ + OTableIndex aReturn; + + sal_Int32 nPos = 0; + + TableIndexListIterator aSearch; + for ( aSearch = _rList.begin(); + aSearch != _rList.end(); + ++aSearch, ++nPos + ) + { + if ( m_bCaseSensitiv ? aSearch->GetIndexFileName().Equals(_rName) : aSearch->GetIndexFileName().EqualsIgnoreCaseAscii(_rName) ) + { + aReturn = *aSearch; + + _rList.erase(aSearch); + _rDisplay.RemoveEntry( _rName ); + + // adjust selection if necessary + if ((sal_uInt32)nPos == _rList.size()) + _rDisplay.SelectEntryPos((sal_uInt16)nPos-1); + else + _rDisplay.SelectEntryPos((sal_uInt16)nPos); + + break; + } + } + + (void)_bMustExist; + DBG_ASSERT(!_bMustExist || (aSearch != _rList.end()), "ODbaseIndexDialog::implRemoveIndex : did not find the index!"); + return aReturn; +} + +//------------------------------------------------------------------------- +void ODbaseIndexDialog::implInsertIndex(const OTableIndex& _rIndex, TableIndexList& _rList, ListBox& _rDisplay) +{ + _rList.push_front( _rIndex ); + _rDisplay.InsertEntry( _rIndex.GetIndexFileName() ); + _rDisplay.SelectEntryPos(0); +} + +//------------------------------------------------------------------------- +OTableIndex ODbaseIndexDialog::RemoveTableIndex( const String& _rTableName, const String& _rIndexName, sal_Bool _bMustExist ) +{ + OTableIndex aReturn; + + // does the table exist ? + TableInfoListIterator aTablePos; + if (!GetTable(_rTableName, aTablePos)) + return aReturn; + + return implRemoveIndex(_rIndexName, aTablePos->aIndexList, aLB_TableIndexes, _bMustExist); +} + +//------------------------------------------------------------------------- +void ODbaseIndexDialog::InsertTableIndex( const String& _rTableName, const OTableIndex& _rIndex) +{ + TableInfoListIterator aTablePos; + if (!GetTable(_rTableName, aTablePos)) + return; + + implInsertIndex(_rIndex, aTablePos->aIndexList, aLB_TableIndexes); +} + +//------------------------------------------------------------------------- +IMPL_LINK( ODbaseIndexDialog, OKClickHdl, PushButton*, /*pButton*/ ) +{ + // let all tables write their INF file + + for ( ConstTableInfoListIterator aLoop = m_aTableInfoList.begin(); + aLoop != m_aTableInfoList.end(); + ++aLoop + ) + aLoop->WriteInfFile(m_aDSN); + + EndDialog(); + return 0; +} + +//------------------------------------------------------------------------- +IMPL_LINK( ODbaseIndexDialog, AddClickHdl, PushButton*, /*pButton*/ ) +{ + String aSelection = aLB_FreeIndexes.GetSelectEntry(); + String aTableName = aCB_Tables.GetText(); + OTableIndex aIndex = RemoveFreeIndex( aSelection, sal_True ); + InsertTableIndex( aTableName, aIndex ); + + checkButtons(); + return 0; +} + +//------------------------------------------------------------------------- +IMPL_LINK( ODbaseIndexDialog, RemoveClickHdl, PushButton*, /*pButton*/ ) +{ + String aSelection = aLB_TableIndexes.GetSelectEntry(); + String aTableName = aCB_Tables.GetText(); + OTableIndex aIndex = RemoveTableIndex( aTableName, aSelection, sal_True ); + InsertFreeIndex( aIndex ); + + checkButtons(); + return 0; +} + +//------------------------------------------------------------------------- +IMPL_LINK( ODbaseIndexDialog, AddAllClickHdl, PushButton*, /*pButton*/ ) +{ + sal_uInt16 nCnt = aLB_FreeIndexes.GetEntryCount(); + String aTableName = aCB_Tables.GetText(); + String aEntry; + + for( sal_uInt16 nPos = 0; nPos < nCnt; ++nPos ) + InsertTableIndex( aTableName, RemoveFreeIndex( aLB_FreeIndexes.GetEntry(0), sal_True ) ); + + checkButtons(); + return 0; +} + +//------------------------------------------------------------------------- +IMPL_LINK( ODbaseIndexDialog, RemoveAllClickHdl, PushButton*, /*pButton*/ ) +{ + sal_uInt16 nCnt = aLB_TableIndexes.GetEntryCount(); + String aTableName = aCB_Tables.GetText(); + String aEntry; + + for( sal_uInt16 nPos = 0; nPos < nCnt; ++nPos ) + InsertFreeIndex( RemoveTableIndex( aTableName, aLB_TableIndexes.GetEntry(0), sal_True ) ); + + checkButtons(); + return 0; +} + +//------------------------------------------------------------------------- +IMPL_LINK( ODbaseIndexDialog, OnListEntrySelected, ListBox*, /*NOTINTERESTEDIN*/ ) +{ + checkButtons(); + return 0; +} + +//------------------------------------------------------------------------- +IMPL_LINK( ODbaseIndexDialog, TableSelectHdl, ComboBox*, pComboBox ) +{ + // search the table + TableInfoListIterator aTablePos; + if (!GetTable(pComboBox->GetText(), aTablePos)) + return 0L; + + // fill the listbox for the indexes + aLB_TableIndexes.Clear(); + for ( ConstTableIndexListIterator aLoop = aTablePos->aIndexList.begin(); + aLoop != aTablePos->aIndexList.end(); + ++aLoop + ) + aLB_TableIndexes.InsertEntry( aLoop->GetIndexFileName() ); + + if ( aTablePos->aIndexList.size() ) + aLB_TableIndexes.SelectEntryPos(0); + + checkButtons(); + return 0; +} + +//------------------------------------------------------------------------- +void ODbaseIndexDialog::Init() +{ + aPB_OK.Disable(); + m_FL_Indexes.Disable(); + m_FT_TableIndexes.Disable(); + aLB_TableIndexes.Disable(); + m_FT_AllIndexes.Disable(); + aLB_FreeIndexes.Disable(); + aIB_Add.Disable(); + aIB_Remove.Disable(); + aIB_AddAll.Disable(); + aIB_RemoveAll.Disable(); + + /////////////////////////////////////////////////////////////////////////// + // Alle Indizes werden erst einmal zur Liste der freien Indizes hinzugefuegt. + // Dann wird fuer jede Tabelle in der Inf-Datei nachgeschaut, welche Indizes sie besitzt. + // Diese Indizes werden aus der Liste der freien Indizes entfernt + // und in die Indexliste der Tabelle eingetragen + + /////////////////////////////////////////////////////////////////////////// + // if the string does not contain a path, cut the string + INetURLObject aURL; + aURL.SetSmartProtocol(INET_PROT_FILE); + { + SvtPathOptions aPathOptions; + m_aDSN = aPathOptions.SubstituteVariable(m_aDSN); + } + aURL.SetSmartURL(m_aDSN); + + + // String aFileName = aURL.PathToFileName(); + m_aDSN = aURL.GetMainURL(INetURLObject::NO_DECODE); + ::ucbhelper::Content aFile; + sal_Bool bFolder=sal_True; + try + { + aFile = ::ucbhelper::Content(m_aDSN,Reference< ::com::sun::star::ucb::XCommandEnvironment >()); + bFolder = aFile.isFolder(); + } + catch(Exception&) + { + return; + } + + /////////////////////////////////////////////////////////////////////////// + // first assume for all indexes they're free + + Sequence< ::rtl::OUString> aFolderContent( ::utl::LocalFileHelper::GetFolderContents(m_aDSN,bFolder)); + + ::rtl::OUString aIndexExt = ::rtl::OUString::createFromAscii("ndx"); + ::rtl::OUString aTableExt = ::rtl::OUString::createFromAscii("dbf"); + + ::std::vector< String > aUsedIndexes; + + String aExt; + const ::rtl::OUString *pBegin = aFolderContent.getConstArray(); + const ::rtl::OUString *pEnd = pBegin + aFolderContent.getLength(); + aURL.SetSmartProtocol(INET_PROT_FILE); + for(;pBegin != pEnd;++pBegin) + { + String aName; + ::utl::LocalFileHelper::ConvertURLToPhysicalName(pBegin->getStr(),aName); + aURL.SetSmartURL(aName); + aExt = aURL.getExtension(); + if(aExt == aIndexExt.getStr()) + { + m_aFreeIndexList.push_back( OTableIndex(aURL.getName()) ); + } + else if(aExt == aTableExt.getStr()) + { + m_aTableInfoList.push_back( OTableInfo(aURL.getName()) ); + OTableInfo& rTabInfo = m_aTableInfoList.back(); + + // open the INF file + aURL.setExtension(String::CreateFromAscii("inf")); + OFileNotation aTransformer(aURL.GetURLNoPass(), OFileNotation::N_URL); + Config aInfFile( aTransformer.get(OFileNotation::N_SYSTEM) ); + aInfFile.SetGroup( aGroupIdent ); + + /////////////////////////////////////////////////////////////////////////// + // fill the indexes list + ByteString aNDX; + sal_uInt16 nKeyCnt = aInfFile.GetKeyCount(); + ByteString aKeyName; + String aEntry; + + for( sal_uInt16 nKey = 0; nKey < nKeyCnt; nKey++ ) + { + // does the key point to an index file ? + aKeyName = aInfFile.GetKeyName( nKey ); + aNDX = aKeyName.Copy(0,3); + + // yes -> add to the tables index list + if (aNDX == "NDX" ) + { + aEntry = String(aInfFile.ReadKey(aKeyName), gsl_getSystemTextEncoding()); + rTabInfo.aIndexList.push_back( OTableIndex( aEntry ) ); + + // and remove it from the free index list + aUsedIndexes.push_back(aEntry); + // do this later below. We may not have encountered the index file, yet, thus we may not + // know the index as beeing free, yet + } + + } + } + } + + for ( ::std::vector< String >::const_iterator aUsedIndex = aUsedIndexes.begin(); + aUsedIndex != aUsedIndexes.end(); + ++aUsedIndex + ) + RemoveFreeIndex( *aUsedIndex, sal_False ); + + if (m_aTableInfoList.size()) + { + aPB_OK.Enable(); + m_FL_Indexes.Enable(); + m_FT_TableIndexes.Enable(); + aLB_TableIndexes.Enable(); + m_FT_AllIndexes.Enable(); + aLB_FreeIndexes.Enable(); + } + + checkButtons(); +} + +//------------------------------------------------------------------------- +void ODbaseIndexDialog::SetCtrls() +{ + // ComboBox Tabellen + for ( ConstTableInfoListIterator aLoop = m_aTableInfoList.begin(); + aLoop != m_aTableInfoList.end(); + ++aLoop + ) + aCB_Tables.InsertEntry( aLoop->aTableName ); + + // Den ersten Datensatz ins Edit stellen + if( m_aTableInfoList.size() ) + { + const OTableInfo& rTabInfo = m_aTableInfoList.front(); + aCB_Tables.SetText( rTabInfo.aTableName ); + + // ListBox der Tabellenindizes aufbauen + for ( ConstTableIndexListIterator aIndex = rTabInfo.aIndexList.begin(); + aIndex != rTabInfo.aIndexList.end(); + ++aIndex + ) + aLB_TableIndexes.InsertEntry( aIndex->GetIndexFileName() ); + + if( rTabInfo.aIndexList.size() ) + aLB_TableIndexes.SelectEntryPos( 0 ); + + } + + // ListBox freie Indizes + for ( ConstTableIndexListIterator aFree = m_aFreeIndexList.begin(); + aFree != m_aFreeIndexList.end(); + ++aFree + ) + aLB_FreeIndexes.InsertEntry( aFree->GetIndexFileName() ); + + if( m_aFreeIndexList.size() ) + aLB_FreeIndexes.SelectEntryPos( 0 ); + + + TableSelectHdl(&aCB_Tables); + checkButtons(); +} + +////////////////////////////////////////////////////////////////////////// +// Klasse OTableInfo +//------------------------------------------------------------------------- +void OTableInfo::WriteInfFile( const String& rDSN ) const +{ + // INF-Datei oeffnen + INetURLObject aURL; + aURL.SetSmartProtocol(INET_PROT_FILE); + String aDsn = rDSN; + { + SvtPathOptions aPathOptions; + aDsn = aPathOptions.SubstituteVariable(aDsn); + } + aURL.SetSmartURL(aDsn); + aURL.Append(aTableName); + aURL.setExtension(String::CreateFromAscii("inf")); + + OFileNotation aTransformer(aURL.GetURLNoPass(), OFileNotation::N_URL); + Config aInfFile( aTransformer.get(OFileNotation::N_SYSTEM) ); + aInfFile.SetGroup( aGroupIdent ); + + // Erst einmal alle Tabellenindizes loeschen + ByteString aNDX; + sal_uInt16 nKeyCnt = aInfFile.GetKeyCount(); + ByteString aKeyName; + ByteString aEntry; + sal_uInt16 nKey = 0; + + while( nKey < nKeyCnt ) + { + // Verweist der Key auf ein Indexfile?... + aKeyName = aInfFile.GetKeyName( nKey ); + aNDX = aKeyName.Copy(0,3); + + //...wenn ja, Indexfile loeschen, nKey steht dann auf nachfolgendem Key + if( aNDX == "NDX" ) + { + aInfFile.DeleteKey(aKeyName); + nKeyCnt--; + } + else + nKey++; + + } + + // Jetzt alle gespeicherten Indizes hinzufuegen + sal_uInt16 nPos = 0; + for ( ConstTableIndexListIterator aIndex = aIndexList.begin(); + aIndex != aIndexList.end(); + ++aIndex, ++nPos + ) + { + aKeyName = "NDX"; + if( nPos > 0 ) // Erster Index erhaelt keine Ziffer + aKeyName += ByteString::CreateFromInt32( nPos ); + aInfFile.WriteKey( aKeyName, ByteString(aIndex->GetIndexFileName(), gsl_getSystemTextEncoding()) ); + } + + aInfFile.Flush(); + + // Falls nur noch [dbase] in INF-File steht, Datei loeschen + if(!nPos) + { + try + { + ::ucbhelper::Content aContent(aURL.GetURLNoPass(),Reference<XCommandEnvironment>()); + aContent.executeCommand( rtl::OUString::createFromAscii( "delete" ),makeAny( sal_Bool( sal_True ) ) ); + } + catch (const Exception& e ) + { + (void)e; // make compiler happy + // simply silent this. The strange algorithm here does a lot of things even if no files at all were + // created or accessed, so it's possible that the file we're trying to delete does not even exist, + // and this is a valid condition. + // 2003-05-15 - #109677# - fs@openoffice.org + } + } +} + +//......................................................................... +} // namespace dbaui +//......................................................................... + diff --git a/dbaccess/source/ui/dlg/dbfindex.hrc b/dbaccess/source/ui/dlg/dbfindex.hrc new file mode 100644 index 000000000000..0d67da065568 --- /dev/null +++ b/dbaccess/source/ui/dlg/dbfindex.hrc @@ -0,0 +1,26 @@ +#ifndef _DBAUI_DBF_INDEXES_HRC_ +#define _DBAUI_DBF_INDEXES_HRC_ + +#define CB_TABLES 1 + +#define FT_TABLES 1 +#define FT_TABLEINDEXES 2 +#define FT_ALLINDEXES 3 + +#define FL_INDEXES 1 + +#define LB_TABLEINDEXES 1 +#define LB_FREEINDEXES 2 + +#define PB_OK 1 +#define PB_CANCEL 1 +#define PB_HELP 1 + +#define IB_ADD 1 +#define IB_REMOVE 2 +#define IB_ADDALL 3 +#define IB_REMOVEALL 4 + + +#endif //_DBAUI_DBF_INDEXES_HRC_ + diff --git a/dbaccess/source/ui/dlg/dbfindex.hxx b/dbaccess/source/ui/dlg/dbfindex.hxx new file mode 100644 index 000000000000..5189bb34810d --- /dev/null +++ b/dbaccess/source/ui/dlg/dbfindex.hxx @@ -0,0 +1,166 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBAUI_DBFINDEX_HXX_ +#define _DBAUI_DBFINDEX_HXX_ + +#ifndef _DIALOG_HXX //autogen +#include <vcl/dialog.hxx> +#endif +#ifndef _BUTTON_HXX //autogen +#include <vcl/button.hxx> +#endif +#ifndef _COMBOBOX_HXX //autogen +#include <vcl/combobox.hxx> +#endif +#ifndef _LSTBOX_HXX //autogen +#include <vcl/lstbox.hxx> +#endif +#ifndef _SV_FIXED_HXX +#include <vcl/fixed.hxx> +#endif +#ifndef __SGI_STL_LIST +#include <list> +#endif +#ifndef _COMPHELPER_STLTYPES_HXX_ +#include <comphelper/stl_types.hxx> +#endif + +//......................................................................... +namespace dbaui +{ +//......................................................................... + +//========================================================================= +//= OTableIndex +//========================================================================= +/// represents a single dbf index +class OTableIndex +{ +private: + String aIndexFileName; + +public: + OTableIndex() { } + OTableIndex( const OTableIndex& _rSource) : aIndexFileName(_rSource.aIndexFileName) { } + OTableIndex( const String& rFileName ) : aIndexFileName( rFileName ) { } + + void SetIndexFileName( const String& rFileName ) { aIndexFileName = rFileName; } + String GetIndexFileName() const { return aIndexFileName; } +}; + +//------------------------------------------------------------------------- +typedef ::std::list< OTableIndex > TableIndexList; +DECLARE_STL_ITERATORS(TableIndexList); + +//========================================================================= +//= OTableInfo +//========================================================================= +class ODbaseIndexDialog; +/** holds the INF file of a table +*/ +class OTableInfo +{ + friend class ODbaseIndexDialog; +private: + String aTableName; + TableIndexList aIndexList; + +public: + OTableInfo() { } + OTableInfo( const String& rName ) : aTableName(rName) { } + + void WriteInfFile( const String& rDSN ) const; +}; + +//------------------------------------------------------------------------- +typedef ::std::list< OTableInfo > TableInfoList; +DECLARE_STL_ITERATORS(TableInfoList); + +////////////////////////////////////////////////////////////////////////// +// IndexDialog +class ODbaseIndexDialog : public ModalDialog +{ +protected: + OKButton aPB_OK; + CancelButton aPB_CANCEL; + HelpButton aPB_HELP; + + FixedText m_FT_Tables; + ComboBox aCB_Tables; + + FixedLine m_FL_Indexes; + + FixedText m_FT_TableIndexes; + ListBox aLB_TableIndexes; + + FixedText m_FT_AllIndexes; + ListBox aLB_FreeIndexes; + + ImageButton aIB_Add; + ImageButton aIB_Remove; + ImageButton aIB_AddAll; + ImageButton aIB_RemoveAll; + + DECL_LINK( TableSelectHdl, ComboBox* ); + DECL_LINK( AddClickHdl, PushButton* ); + DECL_LINK( RemoveClickHdl, PushButton* ); + DECL_LINK( AddAllClickHdl, PushButton* ); + DECL_LINK( RemoveAllClickHdl, PushButton* ); + DECL_LINK( OKClickHdl, PushButton* ); + DECL_LINK( OnListEntrySelected, ListBox* ); + + String m_aDSN; + TableInfoList m_aTableInfoList; + TableIndexList m_aFreeIndexList; + BOOL m_bCaseSensitiv; + + void Init(); + void SetCtrls(); + sal_Bool GetTable(const String& rName, TableInfoListIterator& _rPosition); + + OTableIndex implRemoveIndex(const String& _rName, TableIndexList& _rList, ListBox& _rDisplay, sal_Bool _bMustExist); + void implInsertIndex(const OTableIndex& _rIndex, TableIndexList& _rList, ListBox& _rDisplay); + + OTableIndex RemoveFreeIndex( const String& _rName, sal_Bool _bMustExist ) { return implRemoveIndex(_rName, m_aFreeIndexList, aLB_FreeIndexes, _bMustExist); } + void InsertFreeIndex( const OTableIndex& _rIndex ) { implInsertIndex(_rIndex, m_aFreeIndexList, aLB_FreeIndexes); } + OTableIndex RemoveTableIndex( const String& _rTableName, const String& _rIndexName, sal_Bool _bMustExist ); + void InsertTableIndex( const String& _rTableName, const OTableIndex& _rIndex ); + + void checkButtons(); + +public: + ODbaseIndexDialog( Window * pParent, String aDataSrcName ); + virtual ~ODbaseIndexDialog(); +}; + +//......................................................................... +} // namespace dbaui +//......................................................................... + +#endif // _DBAUI_DBFINDEX_HXX_ + diff --git a/dbaccess/source/ui/dlg/dbfindex.src b/dbaccess/source/ui/dlg/dbfindex.src new file mode 100644 index 000000000000..ad401102601d --- /dev/null +++ b/dbaccess/source/ui/dlg/dbfindex.src @@ -0,0 +1,246 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBAUI_DBF_INDEXES_HRC_ +#include "dbfindex.hrc" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif + +#define WIN_X 264 +#define WIN_Y 149 + +Image IMG_ONE_LEFT_H +{ + ImageBitmap = Bitmap + { + File = "one_left_h.bmp" ; + }; + MaskColor = Color + { + Red = 0xFFFF ; + Green = 0x0000 ; + Blue = 0xFFFF ; + }; +}; + +Image IMG_ALL_LEFT_H +{ + ImageBitmap = Bitmap + { + File = "all_left_h.bmp" ; + }; + MaskColor = Color + { + Red = 0xFFFF ; + Green = 0x0000 ; + Blue = 0xFFFF ; + }; +}; + +Image IMG_ONE_RIGHT_H +{ + ImageBitmap = Bitmap + { + File = "one_right_h.bmp" ; + }; + MaskColor = Color + { + Red = 0xFFFF ; + Green = 0x0000 ; + Blue = 0xFFFF ; + }; +}; + +Image IMG_ALL_RIGHT_H +{ + ImageBitmap = Bitmap + { + File = "all_right_h.bmp" ; + }; + MaskColor = Color + { + Red = 0xFFFF ; + Green = 0x0000 ; + Blue = 0xFFFF ; + }; +}; + +ModalDialog DLG_DBASE_INDEXES +{ + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( WIN_X , WIN_Y ) ; + Text [ en-US ] = "Indexes" ; + Moveable = TRUE ; + Closeable = TRUE ; + OKButton PB_OK + { + Pos = MAP_APPFONT ( 208 , 5 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + CancelButton PB_CANCEL + { + Pos = MAP_APPFONT ( 208 , 23 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + HelpButton PB_HELP + { + Pos = MAP_APPFONT ( 208 , 43 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + FixedText FT_TABLES + { + Pos = MAP_APPFONT ( 8 , 7 ) ; + Size = MAP_APPFONT ( 50 , 8 ) ; + Text [ en-US ] = "~Table"; + }; + ComboBox CB_TABLES + { + Border = TRUE ; + SVLook = TRUE ; + Pos = MAP_APPFONT ( 62 , 5 ) ; + Size = MAP_APPFONT ( 134 , 12 ) ; + TabStop = TRUE ; + DropDown = TRUE ; + }; + FixedLine FL_INDEXES + { + Pos = MAP_APPFONT ( 6 , 22 ) ; + Size = MAP_APPFONT ( 196 , 8 ) ; + Text [ en-US ] = "Assignment" ; + }; + FixedText FT_TABLEINDEXES + { + Pos = MAP_APPFONT ( 12 , 33 ) ; + Size = MAP_APPFONT ( 83 , 8 ) ; + Text [ en-US ] = "T~able indexes"; + }; + ListBox LB_TABLEINDEXES + { + Border = TRUE ; + SVLook = TRUE ; + Pos = MAP_APPFONT ( 12 , 44 ) ; + Size = MAP_APPFONT ( 76 , 98 ) ; + TabStop = TRUE ; + }; + FixedText FT_ALLINDEXES + { + Pos = MAP_APPFONT ( 120 , 33 ) ; + Size = MAP_APPFONT ( 73 , 8 ) ; + Text [ en-US ] = "~Free indexes"; + }; + ListBox LB_FREEINDEXES + { + Border = TRUE ; + SVLook = TRUE ; + Pos = MAP_APPFONT ( 120 , 44 ) ; + Size = MAP_APPFONT ( 76 , 98 ) ; + TabStop = TRUE ; + }; + ImageButton IB_ADD + { + Pos = MAP_APPFONT ( 94 , 60 ) ; + Size = MAP_APPFONT ( 20 , 14 ) ; + TabStop = TRUE ; + ButtonImage = Image + { + ImageBitmap = Bitmap + { + File = "one_left.bmp" ; + }; + MaskColor = Color + { + Red = 0xFFFF ; + Green = 0x0000 ; + Blue = 0xFFFF ; + }; + }; + }; + ImageButton IB_ADDALL + { + Pos = MAP_APPFONT ( 94 , 77 ) ; + Size = MAP_APPFONT ( 20 , 14 ) ; + TabStop = TRUE ; + ButtonImage = Image + { + ImageBitmap = Bitmap + { + File = "all_left.bmp" ; + }; + MaskColor = Color + { + Red = 0xFFFF ; + Green = 0x0000 ; + Blue = 0xFFFF ; + }; + }; + }; + ImageButton IB_REMOVE + { + Pos = MAP_APPFONT ( 94 , 98 ) ; + Size = MAP_APPFONT ( 20 , 14 ) ; + TabStop = TRUE ; + ButtonImage = Image + { + ImageBitmap = Bitmap + { + File = "one_right.bmp" ; + }; + MaskColor = Color + { + Red = 0xFFFF ; + Green = 0x0000 ; + Blue = 0xFFFF ; + }; + }; + }; + ImageButton IB_REMOVEALL + { + Pos = MAP_APPFONT ( 94, 114 ) ; + Size = MAP_APPFONT ( 20 , 14 ) ; + TabStop = TRUE ; + ButtonImage = Image + { + ImageBitmap = Bitmap + { + File = "all_right.bmp" ; + }; + MaskColor = Color + { + Red = 0xFFFF ; + Green = 0x0000 ; + Blue = 0xFFFF ; + }; + }; + }; + +}; diff --git a/dbaccess/source/ui/dlg/dbwiz.cxx b/dbaccess/source/ui/dlg/dbwiz.cxx new file mode 100644 index 000000000000..7fcf2ae8429d --- /dev/null +++ b/dbaccess/source/ui/dlg/dbwiz.cxx @@ -0,0 +1,421 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#ifndef DBAUI_DBWIZ_HXX +#include "dbwiz.hxx" +#endif +#ifndef _DBAUI_DBADMIN_HRC_ +#include "dbadmin.hrc" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef _DBAUI_DATASOURCEITEMS_HXX_ +#include "dsitems.hxx" +#endif +#include "dsnItem.hxx" +#ifndef _SFXSTRITEM_HXX +#include <svl/stritem.hxx> +#endif +#ifndef _SFXENUMITEM_HXX +#include <svl/eitem.hxx> +#endif +#ifndef _SFXINTITEM_HXX +#include <svl/intitem.hxx> +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef _DBAUI_ADMINPAGES_HXX_ +#include "adminpages.hxx" +#endif +#ifndef _DBAUI_GENERALPAGE_HXX_ +#include "generalpage.hxx" +#endif +#ifndef _DBAUI_LOCALRESACCESS_HXX_ +#include "localresaccess.hxx" +#endif +#ifndef _DBAUI_STRINGLISTITEM_HXX_ +#include "stringlistitem.hxx" +#endif +#ifndef _DBAUI_PROPERTYSETITEM_HXX_ +#include "propertysetitem.hxx" +#endif +#ifndef _UNOTOOLS_CONFIGNODE_HXX_ +#include <unotools/confignode.hxx> +#endif +#ifndef DBAUI_CONNECTIONPAGE_HXX +#include "ConnectionPage.hxx" +#endif +#ifndef DBAUI_DRIVERSETTINGS_HXX +#include "DriverSettings.hxx" +#endif +#ifndef _DBAUI_DBADMINIMPL_HXX_ +#include "DbAdminImpl.hxx" +#endif +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif + +//......................................................................... +namespace dbaui +{ +//......................................................................... +using namespace svt; +using namespace com::sun::star::uno; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::lang; +using namespace com::sun::star::util; +using namespace com::sun::star::beans; +using namespace com::sun::star::container; + +#define START_PAGE 0 +#define CONNECTION_PAGE 1 +#define ADDITIONAL_PAGE_DBASE 2 +#define ADDITIONAL_PAGE_FLAT 3 +#define ADDITIONAL_PAGE_LDAP 4 +#define ADDITIONAL_PAGE_ADABAS 5 +#define ADDITIONAL_PAGE_MYSQL_JDBC 6 +#define ADDITIONAL_PAGE_MYSQL_ODBC 7 +#define ADDITIONAL_PAGE_ORACLE_JDBC 8 +#define ADDITIONAL_PAGE_ADO 9 +#define ADDITIONAL_PAGE_ODBC 10 +#define ADDITIONAL_USERDEFINED 11 +#define ADDITIONAL_PAGE_MYSQL_NATIVE 12 + + +DBG_NAME(ODbTypeWizDialog) +//========================================================================= +//= ODbTypeWizDialog +//========================================================================= +//------------------------------------------------------------------------- +ODbTypeWizDialog::ODbTypeWizDialog(Window* _pParent + ,SfxItemSet* _pItems + ,const Reference< XMultiServiceFactory >& _rxORB + ,const ::com::sun::star::uno::Any& _aDataSourceName + ) + :OWizardMachine(_pParent, ModuleRes(DLG_DATABASE_TYPE_CHANGE), WZB_NEXT | WZB_PREVIOUS | WZB_FINISH | WZB_CANCEL | WZB_HELP ) + ,m_pOutSet(NULL) + ,m_bResetting(sal_False) + ,m_bApplied(sal_False) + ,m_bUIEnabled( sal_True ) +{ + DBG_CTOR(ODbTypeWizDialog,NULL); + m_pImpl = ::std::auto_ptr<ODbDataSourceAdministrationHelper>(new ODbDataSourceAdministrationHelper(_rxORB,this,this)); + m_pImpl->setDataSourceOrName(_aDataSourceName); + Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource(); + m_pOutSet = new SfxItemSet( *_pItems->GetPool(), _pItems->GetRanges() ); + + m_pImpl->translateProperties(xDatasource, *m_pOutSet); + m_eType = m_pImpl->getDatasourceType(*m_pOutSet); + + SetPageSizePixel(LogicToPixel(::Size(PAGE_X, PAGE_Y), MAP_APPFONT)); + ShowButtonFixedLine(sal_True); + defaultButton(WZB_NEXT); + enableButtons(WZB_FINISH, sal_False); + enableAutomaticNextButtonState( true ); + + m_pPrevPage->SetHelpId(HID_DBWIZ_PREVIOUS); + m_pNextPage->SetHelpId(HID_DBWIZ_NEXT); + m_pCancel->SetHelpId(HID_DBWIZ_CANCEL); + m_pFinish->SetHelpId(HID_DBWIZ_FINISH); + m_pHelp->SetUniqueId(UID_DBWIZ_HELP); + // no local resources needed anymore + + DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _pItems->GetItem(DSID_TYPECOLLECTION)); + m_pCollection = pCollectionItem->getCollection(); + + FreeResource(); + ActivatePage(); +} + +//------------------------------------------------------------------------- +ODbTypeWizDialog::~ODbTypeWizDialog() +{ + DBG_DTOR(ODbTypeWizDialog,NULL); + delete m_pOutSet; +} +//------------------------------------------------------------------------- +IMPL_LINK(ODbTypeWizDialog, OnTypeSelected, OGeneralPage*, _pTabPage) +{ + m_eType = _pTabPage->GetSelectedType(); + const bool bURLRequired = m_pCollection->isConnectionUrlRequired(m_eType); + enableButtons(WZB_NEXT,bURLRequired); + enableButtons(WZB_FINISH,!bURLRequired); + return 1L; +} +//------------------------------------------------------------------------- +WizardTypes::WizardState ODbTypeWizDialog::determineNextState( WizardState _nCurrentState ) const +{ + WizardTypes::WizardState nNextState = WZS_INVALID_STATE; + switch(_nCurrentState) + { + case START_PAGE: + switch(m_pCollection->determineType(m_eType)) + { + case ::dbaccess::DST_MOZILLA: + case ::dbaccess::DST_OUTLOOK: + case ::dbaccess::DST_OUTLOOKEXP: + case ::dbaccess::DST_EVOLUTION: + case ::dbaccess::DST_EVOLUTION_GROUPWISE: + case ::dbaccess::DST_EVOLUTION_LDAP: + case ::dbaccess::DST_KAB: + case ::dbaccess::DST_MACAB: + nNextState = WZS_INVALID_STATE; + break; + case ::dbaccess::DST_MYSQL_NATIVE: + nNextState = ADDITIONAL_PAGE_MYSQL_NATIVE; + break; + default: + nNextState = CONNECTION_PAGE; + break; + } + break; + case CONNECTION_PAGE: + switch(m_pCollection->determineType(m_eType)) + { + case ::dbaccess::DST_MOZILLA: + case ::dbaccess::DST_THUNDERBIRD: + case ::dbaccess::DST_OUTLOOK: + case ::dbaccess::DST_OUTLOOKEXP: + case ::dbaccess::DST_EVOLUTION: + case ::dbaccess::DST_EVOLUTION_GROUPWISE: + case ::dbaccess::DST_EVOLUTION_LDAP: + case ::dbaccess::DST_KAB: + case ::dbaccess::DST_MACAB: + case ::dbaccess::DST_MSACCESS: + case ::dbaccess::DST_MSACCESS_2007: + case ::dbaccess::DST_JDBC: + case ::dbaccess::DST_CALC: + nNextState = WZS_INVALID_STATE; + break; + case ::dbaccess::DST_DBASE: + nNextState = ADDITIONAL_PAGE_DBASE; + break; + case ::dbaccess::DST_FLAT: + nNextState = ADDITIONAL_PAGE_FLAT; + break; + case ::dbaccess::DST_LDAP: + nNextState = ADDITIONAL_PAGE_LDAP; + break; + case ::dbaccess::DST_ADABAS: + nNextState = ADDITIONAL_PAGE_ADABAS; + break; + case ::dbaccess::DST_MYSQL_JDBC: + nNextState = ADDITIONAL_PAGE_MYSQL_JDBC; + break; + case ::dbaccess::DST_MYSQL_ODBC: + nNextState = ADDITIONAL_PAGE_MYSQL_ODBC; + break; + case ::dbaccess::DST_ORACLE_JDBC: + nNextState = ADDITIONAL_PAGE_ORACLE_JDBC; + break; + case ::dbaccess::DST_ADO: + nNextState = ADDITIONAL_PAGE_ADO; + break; + case ::dbaccess::DST_ODBC: + nNextState = ADDITIONAL_PAGE_ODBC; + break; + default: + nNextState = WZS_INVALID_STATE; + break; + } + break; + } + + return nNextState; +} + +// ----------------------------------------------------------------------------- +const SfxItemSet* ODbTypeWizDialog::getOutputSet() const +{ + return m_pOutSet; +} +// ----------------------------------------------------------------------------- +SfxItemSet* ODbTypeWizDialog::getWriteOutputSet() +{ + return m_pOutSet; +} +// ----------------------------------------------------------------------------- +::std::pair< Reference<XConnection>,sal_Bool> ODbTypeWizDialog::createConnection() +{ + return m_pImpl->createConnection(); +} +// ----------------------------------------------------------------------------- +Reference< XMultiServiceFactory > ODbTypeWizDialog::getORB() const +{ + return m_pImpl->getORB(); +} +// ----------------------------------------------------------------------------- +Reference< XDriver > ODbTypeWizDialog::getDriver() +{ + return m_pImpl->getDriver(); +} +// ----------------------------------------------------------------------------- +::rtl::OUString ODbTypeWizDialog::getDatasourceType(const SfxItemSet& _rSet) const +{ + return m_pImpl->getDatasourceType(_rSet); +} +// ----------------------------------------------------------------------------- +void ODbTypeWizDialog::clearPassword() +{ + m_pImpl->clearPassword(); +} + +// ----------------------------------------------------------------------------- +TabPage* ODbTypeWizDialog::createPage(WizardState _nState) +{ + USHORT nStringId = STR_PAGETITLE_ADVANCED; + TabPage* pPage = NULL; + switch(_nState) + { + case START_PAGE: // start state + { + pPage = OGeneralPage::Create(this,*m_pOutSet); + OGeneralPage* pGeneralPage = static_cast< OGeneralPage* >( pPage ); + pGeneralPage->SetTypeSelectHandler( LINK( this, ODbTypeWizDialog, OnTypeSelected)); +// pGeneralPage->SetCreationModeHandler( LINK( this, ODbTypeWizDialog, TODO ) ); + nStringId = STR_PAGETITLE_GENERAL; + } + break; + case CONNECTION_PAGE: + pPage = OConnectionTabPage::Create(this,*m_pOutSet); + nStringId = STR_PAGETITLE_CONNECTION; + break; + + case ADDITIONAL_PAGE_DBASE: + pPage = ODriversSettings::CreateDbase(this,*m_pOutSet); + break; + case ADDITIONAL_PAGE_FLAT: + pPage = ODriversSettings::CreateText(this,*m_pOutSet); + break; + case ADDITIONAL_PAGE_LDAP: + pPage = ODriversSettings::CreateLDAP(this,*m_pOutSet); + break; + case ADDITIONAL_PAGE_ADABAS: + pPage = ODriversSettings::CreateAdabas(this,*m_pOutSet); + break; + case ADDITIONAL_PAGE_MYSQL_JDBC: + pPage = ODriversSettings::CreateMySQLJDBC(this,*m_pOutSet); + break; + case ADDITIONAL_PAGE_MYSQL_NATIVE: + pPage = ODriversSettings::CreateMySQLNATIVE(this,*m_pOutSet); + break; + case ADDITIONAL_PAGE_MYSQL_ODBC: + pPage = ODriversSettings::CreateMySQLODBC(this,*m_pOutSet); + break; + case ADDITIONAL_PAGE_ORACLE_JDBC: + pPage = ODriversSettings::CreateOracleJDBC(this,*m_pOutSet); + break; + case ADDITIONAL_PAGE_ADO: + pPage = ODriversSettings::CreateAdo(this,*m_pOutSet); + break; + case ADDITIONAL_PAGE_ODBC: + pPage = ODriversSettings::CreateODBC(this,*m_pOutSet); + break; + case ADDITIONAL_USERDEFINED: + pPage = ODriversSettings::CreateUser(this,*m_pOutSet); + break; + default: + OSL_ENSURE(0,"Wrong state!"); + break; + } + + // register ourself as modified listener + if ( pPage ) + { + static_cast<OGenericAdministrationPage*>(pPage)->SetServiceFactory(m_pImpl->getORB()); + static_cast<OGenericAdministrationPage*>(pPage)->SetAdminDialog(this,this); + // open our own resource block, as the page titles are strings local to this block + LocalResourceAccess aDummy(DLG_DATABASE_ADMINISTRATION, RSC_TABDIALOG); + + pPage->SetText(String(ModuleRes(nStringId))); + defaultButton( _nState == START_PAGE ? WZB_NEXT : WZB_FINISH ); + enableButtons( WZB_FINISH, _nState == START_PAGE ? sal_False : sal_True); + pPage->Show(); + } + return pPage; +} +// ----------------------------------------------------------------------------- +sal_Bool ODbTypeWizDialog::leaveState(WizardState _nState) +{ + SfxTabPage* pPage = static_cast<SfxTabPage*>(WizardDialog::GetPage(_nState)); + if ( pPage ) + pPage->FillItemSet(*m_pOutSet); + return sal_True; +} +// ----------------------------------------------------------------------------- +void ODbTypeWizDialog::setTitle(const ::rtl::OUString& _sTitle) +{ + SetText(_sTitle); +} +//------------------------------------------------------------------------- +void ODbTypeWizDialog::enableConfirmSettings( bool _bEnable ) +{ + enableButtons( WZB_FINISH, _bEnable ); + // TODO: + // this is hacky. At the moment, this method is used in only one case (#b6532894#). + // As soon as it is to be used more wide-spread, we should find a proper concept + // for enabling both the Next and Finish buttons, depending on the current page state. + // Plus, the concept must also care for the case where those pages are embedded into + // anormal tab dialog. +} +//------------------------------------------------------------------------- +sal_Bool ODbTypeWizDialog::saveDatasource() +{ + SfxTabPage* pPage = static_cast<SfxTabPage*>(WizardDialog::GetPage(getCurrentState())); + if ( pPage ) + pPage->FillItemSet(*m_pOutSet); + + DataSourceInfoConverter aConverter(getORB()); + ::rtl::OUString sOldURL; + if ( m_pImpl->getCurrentDataSource().is() ) + m_pImpl->getCurrentDataSource()->getPropertyValue(PROPERTY_URL) >>= sOldURL; + aConverter.convert(m_pCollection,sOldURL,m_eType,m_pImpl->getCurrentDataSource()); + return sal_True; +} +// ----------------------------------------------------------------------------- +IWizardPageController* ODbTypeWizDialog::getPageController( TabPage* _pCurrentPage ) const +{ + OGenericAdministrationPage* pPage = static_cast<OGenericAdministrationPage*>(_pCurrentPage); + return pPage; +} +// ----------------------------------------------------------------------------- +sal_Bool ODbTypeWizDialog::onFinish() +{ + saveDatasource(); + return m_pImpl->saveChanges(*m_pOutSet) ? OWizardMachine::onFinish() : sal_False; +} +//......................................................................... +} // namespace dbaui +//......................................................................... diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx new file mode 100644 index 000000000000..b09c691864a3 --- /dev/null +++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx @@ -0,0 +1,1251 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#include "dbwizsetup.hxx" +#include "dsmeta.hxx" +#include "DBSetupConnectionPages.hxx" +#include "dbadminsetup.hrc" +#include "dbu_dlg.hrc" +#include "dsitems.hxx" +#include "dsnItem.hxx" + +#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX +#include <unotools/pathoptions.hxx> +#endif +#ifndef _SFXSTRITEM_HXX +#include <svl/stritem.hxx> +#endif +#ifndef _SFXENUMITEM_HXX +#include <svl/eitem.hxx> +#endif +#ifndef _SFXINTITEM_HXX +#include <svl/intitem.hxx> +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef _DBAUI_ADMINPAGES_HXX_ +#include "adminpages.hxx" +#endif +#ifndef _SFX_DOCFILT_HACK_HXX +#include <sfx2/docfilt.hxx> +#endif +#ifndef _UNOTOOLS_UCBHELPER_HXX +#include <unotools/ucbhelper.hxx> +#endif +#ifndef _DBAUI_GENERALPAGE_HXX_ +#include "generalpage.hxx" +#endif +#ifndef _DBAUI_LOCALRESACCESS_HXX_ +#include "localresaccess.hxx" +#endif +#ifndef _DBAUI_STRINGLISTITEM_HXX_ +#include "stringlistitem.hxx" +#endif +#ifndef _DBAUI_PROPERTYSETITEM_HXX_ +#include "propertysetitem.hxx" +#endif +#ifndef _UNOTOOLS_CONFIGNODE_HXX_ +#include <unotools/confignode.hxx> +#endif +#ifndef _DBAUI_DBADMINIMPL_HXX_ +#include "DbAdminImpl.hxx" +#endif +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif +#ifndef DBAUI_CONNECTIONPAGESETUP_HXX +#include "ConnectionPageSetup.hxx" +#endif +#ifndef DBAUI_TOOLS_HXX +#include "UITools.hxx" +#endif +#ifndef _DBAUI_DBADMIN_HRC_ +#include "dbadmin.hrc" +#endif +#ifndef DBAUI_ASYNCRONOUSLINK_HXX +#include "AsyncronousLink.hxx" +#endif +#ifndef _FILEDLGHELPER_HXX +#include <sfx2/filedlghelper.hxx> +#endif +#include <cppuhelper/exc_hlp.hxx> + +/** === begin UNO includes === **/ +#ifndef _COM_SUN_STAR_FRAME_XSTORABLE_HPP_ +#include <com/sun/star/frame/XStorable.hpp> +#endif +#ifndef _COM_SUN_STAR_UNO_XNAMINGSERVICE_HPP_ +#include <com/sun/star/uno/XNamingService.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_ +#include <com/sun/star/sdbc/XDataSource.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_XDOCUMENTDATASOURCE_HPP_ +#include <com/sun/star/sdb/XDocumentDataSource.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_ +#include <com/sun/star/frame/FrameSearchFlag.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_ +#include <com/sun/star/frame/XComponentLoader.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_ +#include <com/sun/star/frame/XModel.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_XSIMPLEFILEACCESS_HPP_ +#include <com/sun/star/ucb/XSimpleFileAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_TASK_XJOBEXECUTOR_HPP_ +#include <com/sun/star/task/XJobExecutor.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include <com/sun/star/lang/XInitialization.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ +#include <com/sun/star/sdb/CommandType.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_INTERACTIVEIOEXCEPTION_HPP_ +#include <com/sun/star/ucb/InteractiveIOException.hpp> +#endif +#ifndef _COM_SUN_STAR_IO_IOEXCEPTION_HPP_ +#include <com/sun/star/io/IOException.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XTERMINATELISTENER_HPP_ +#include <com/sun/star/frame/XTerminateListener.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XDESKTOP_HPP_ +#include <com/sun/star/frame/XDesktop.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XDRIVERACCESS_HPP_ +#include <com/sun/star/sdbc/XDriverAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_DOCUMENT_MACROEXECMODE_HPP_ +#include <com/sun/star/document/MacroExecMode.hpp> +#endif +#include <com/sun/star/ucb/IOErrorCode.hpp> +#include <com/sun/star/task/XInteractionHandler2.hpp> +#include <com/sun/star/ui/dialogs/TemplateDescription.hpp> + + +/** === end UNO includes === **/ + +#include <svl/filenotation.hxx> +#include <comphelper/interaction.hxx> +#include <comphelper/namedvaluecollection.hxx> +#include <comphelper/sequenceashashmap.hxx> +#include <tools/diagnose_ex.h> +#include <connectivity/DriversConfig.hxx> + +#include <memory> + + +//......................................................................... +namespace dbaui +{ +//......................................................................... +using namespace dbtools; +using namespace svt; +using namespace com::sun::star; +using namespace com::sun::star::uno; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::sdbcx; +using namespace com::sun::star::task; +using namespace com::sun::star::lang; +using namespace com::sun::star::io; +using namespace com::sun::star::util; +using namespace com::sun::star::beans; +using namespace com::sun::star::container; +using namespace com::sun::star::frame; +using namespace com::sun::star::ucb; +using namespace ::com::sun::star::sdb; +using namespace ::com::sun::star::document; +using namespace ::comphelper; +using namespace ::cppu; + +#define START_PAGE 0 +#define CONNECTION_PAGE 1 + + + + +//#define DBASE_PATH 1 +//#define TEXT_PATH 2 +//#define MSACCESS_PATH 3 +//#define LDAP_PATH 4 +//#define ADABAS_PATH 5 +//#define ADO_PATH 6 +//#define JDBC_PATH 7 +//#define ORACLE_PATH 8 +//#define MYSQL_JDBC_PATH 9 +//#define MYSQL_ODBC_PATH 10 +//#define ODBC_PATH 11 +//#define SPREADSHEET_PATH 12 +//#define OUTLOOKEXP_PATH 13 +//#define OUTLOOK_PATH 14 +//#define MOZILLA_PATH 15 +//#define EVOLUTION_PATH 16 +//#define EVOLUTION_PATH_GROUPWISE 17 +//#define EVOLUTION_PATH_LDAP 18 +//#define KAB_PATH 19 +//#define MACAB_PATH 20 +//#define THUNDERBIRD_PATH 21 +//#define CREATENEW_PATH 22 +//#define USERDEFINED_PATH 23 +//#define OPEN_DOC_PATH 24 +//#define MSACCESS2007_PATH 25 +//#define MYSQL_NATIVE_PATH 26 + +OFinalDBPageSetup* pFinalPage; + + + +DBG_NAME(ODbTypeWizDialogSetup) +//========================================================================= +//= ODbTypeWizDialogSetup +//========================================================================= +//------------------------------------------------------------------------- +ODbTypeWizDialogSetup::ODbTypeWizDialogSetup(Window* _pParent + ,SfxItemSet* _pItems + ,const Reference< XMultiServiceFactory >& _rxORB + ,const ::com::sun::star::uno::Any& _aDataSourceName + ) + :svt::RoadmapWizard( _pParent, ModuleRes(DLG_DATABASE_WIZARD), + WZB_NEXT | WZB_PREVIOUS | WZB_FINISH | WZB_CANCEL | WZB_HELP ) + + , m_pOutSet(NULL) + , m_bResetting(sal_False) + , m_bApplied(sal_False) + , m_bUIEnabled( sal_True ) + , m_bIsConnectable( sal_False) + , m_sRM_IntroText(ModuleRes(STR_PAGETITLE_INTROPAGE)) + , m_sRM_dBaseText(ModuleRes(STR_PAGETITLE_DBASE)) + , m_sRM_TextText(ModuleRes(STR_PAGETITLE_TEXT)) + , m_sRM_MSAccessText(ModuleRes(STR_PAGETITLE_MSACCESS)) + , m_sRM_LDAPText(ModuleRes(STR_PAGETITLE_LDAP)) + , m_sRM_ADABASText(ModuleRes(STR_PAGETITLE_ADABAS)) + , m_sRM_ADOText(ModuleRes(STR_PAGETITLE_ADO)) + , m_sRM_JDBCText(ModuleRes(STR_PAGETITLE_JDBC)) + , m_sRM_MySQLNativePageTitle(ModuleRes(STR_PAGETITLE_MYSQL_NATIVE)) + , m_pGeneralPage( NULL ) + , m_pMySQLIntroPage(NULL) + , m_pCollection( NULL ) +{ + DBG_CTOR(ODbTypeWizDialogSetup,NULL); + // no local resources needed anymore + m_sRM_MySQLText = String(ModuleRes(STR_PAGETITLE_MYSQL)); + m_sRM_OracleText = String(ModuleRes(STR_PAGETITLE_ORACLE)); + m_sRM_ODBCText = String(ModuleRes(STR_PAGETITLE_ODBC)); + m_sRM_SpreadSheetText = String(ModuleRes(STR_PAGETITLE_SPREADSHEET)); + m_sRM_AuthentificationText = String(ModuleRes(STR_PAGETITLE_AUTHENTIFICATION)); + m_sRM_FinalText = String(ModuleRes(STR_PAGETITLE_FINAL)); + m_sWorkPath = SvtPathOptions().GetWorkPath(); + pFinalPage = NULL; + // extract the datasource type collection from the item set + DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _pItems->GetItem(DSID_TYPECOLLECTION)); + if (pCollectionItem) + m_pCollection = pCollectionItem->getCollection(); + + DBG_ASSERT(m_pCollection, "ODbTypeWizDialogSetup::ODbTypeWizDialogSetup : really need a DSN type collection !"); + + FreeResource(); + + m_pImpl = ::std::auto_ptr<ODbDataSourceAdministrationHelper>(new ODbDataSourceAdministrationHelper(_rxORB,this,this)); + m_pImpl->setDataSourceOrName(_aDataSourceName); + Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource(); + m_pOutSet = new SfxItemSet( *_pItems->GetPool(), _pItems->GetRanges() ); + + m_pImpl->translateProperties(xDatasource, *m_pOutSet); +// eType = m_pImpl->getDatasourceType(*m_pOutSet); + + SetPageSizePixel(LogicToPixel(::Size(WIZARD_PAGE_X, WIZARD_PAGE_Y), MAP_APPFONT)); + ShowButtonFixedLine(sal_True); + defaultButton(WZB_NEXT); + enableButtons(WZB_FINISH, sal_True); + enableAutomaticNextButtonState(); + + ::dbaccess::ODsnTypeCollection::TypeIterator aIter = m_pCollection->begin(); + ::dbaccess::ODsnTypeCollection::TypeIterator aEnd = m_pCollection->end(); + for(PathId i = 1;aIter != aEnd;++aIter,++i) + { + const ::rtl::OUString sURLPrefix = aIter.getURLPrefix(); + svt::RoadmapWizardTypes::WizardPath aPath; + aPath.push_back(PAGE_DBSETUPWIZARD_INTRO); + m_pCollection->fillPageIds(sURLPrefix,aPath); + aPath.push_back(PAGE_DBSETUPWIZARD_AUTHENTIFICATION); + aPath.push_back(PAGE_DBSETUPWIZARD_FINAL); + + declareAuthDepPath(sURLPrefix,i,aPath); + } + + svt::RoadmapWizardTypes::WizardPath aPath; + aPath.push_back(PAGE_DBSETUPWIZARD_INTRO); + declarePath( static_cast<PathId>(m_pCollection->size()+1), aPath); + + m_pPrevPage->SetHelpId(HID_DBWIZ_PREVIOUS); + m_pNextPage->SetHelpId(HID_DBWIZ_NEXT); + m_pCancel->SetHelpId(HID_DBWIZ_CANCEL); + m_pFinish->SetHelpId(HID_DBWIZ_FINISH); + m_pHelp->SetUniqueId(UID_DBWIZ_HELP); + SetRoadmapInteractive( sal_True ); + ActivatePage(); +} + +void ODbTypeWizDialogSetup::declareAuthDepPath( const ::rtl::OUString& _sURL, PathId _nPathId, const svt::RoadmapWizardTypes::WizardPath& _rPaths) +{ + bool bHasAuthentication = DataSourceMetaData::getAuthentication( _sURL ) != AuthNone; + + // collect the elements of the path + WizardPath aPath; + + svt::RoadmapWizardTypes::WizardPath::const_iterator aIter = _rPaths.begin(); + svt::RoadmapWizardTypes::WizardPath::const_iterator aEnd = _rPaths.end(); + for(;aIter != aEnd;++aIter) + { + if ( bHasAuthentication || ( *aIter != PAGE_DBSETUPWIZARD_AUTHENTIFICATION ) ) + aPath.push_back( *aIter ); + } // for(;aIter != aEnd;++aIter) + + // call base method + ::svt::RoadmapWizard::declarePath( _nPathId, aPath ); +} + +String ODbTypeWizDialogSetup::getStateDisplayName( WizardState _nState ) const +{ + String sRoadmapItem; + switch( _nState ) + { + case PAGE_DBSETUPWIZARD_INTRO: + sRoadmapItem = m_sRM_IntroText; + break; + + case PAGE_DBSETUPWIZARD_DBASE: + sRoadmapItem = m_sRM_dBaseText; + break; + case PAGE_DBSETUPWIZARD_ADO: + sRoadmapItem = m_sRM_ADOText; + break; + case PAGE_DBSETUPWIZARD_TEXT: + sRoadmapItem = m_sRM_TextText; + break; + case PAGE_DBSETUPWIZARD_MSACCESS: + sRoadmapItem = m_sRM_MSAccessText; + break; + case PAGE_DBSETUPWIZARD_LDAP: + sRoadmapItem = m_sRM_LDAPText; + break; + case PAGE_DBSETUPWIZARD_ADABAS: + sRoadmapItem = m_sRM_ADABASText; + break; + case PAGE_DBSETUPWIZARD_JDBC: + sRoadmapItem = m_sRM_JDBCText; + break; + case PAGE_DBSETUPWIZARD_ORACLE: + sRoadmapItem = m_sRM_OracleText; + break; + case PAGE_DBSETUPWIZARD_MYSQL_INTRO: + sRoadmapItem = m_sRM_MySQLText; + break; + case PAGE_DBSETUPWIZARD_MYSQL_JDBC: + sRoadmapItem = m_sRM_JDBCText; + break; + case PAGE_DBSETUPWIZARD_MYSQL_NATIVE: + sRoadmapItem = m_sRM_MySQLNativePageTitle; + break; + case PAGE_DBSETUPWIZARD_MYSQL_ODBC: + sRoadmapItem = m_sRM_ODBCText; + break; + case PAGE_DBSETUPWIZARD_ODBC: + sRoadmapItem = m_sRM_ODBCText; + break; + case PAGE_DBSETUPWIZARD_SPREADSHEET: + sRoadmapItem = m_sRM_SpreadSheetText; + break; + case PAGE_DBSETUPWIZARD_AUTHENTIFICATION: + sRoadmapItem = m_sRM_AuthentificationText; + break; + case PAGE_DBSETUPWIZARD_USERDEFINED: + { + LocalResourceAccess aDummy(DLG_DATABASE_ADMINISTRATION, RSC_TABDIALOG); + sRoadmapItem = String(ModuleRes(STR_PAGETITLE_CONNECTION)); + } + break; + case PAGE_DBSETUPWIZARD_FINAL: + sRoadmapItem = m_sRM_FinalText; + break; + default: + break; + } + return sRoadmapItem; +} + +//------------------------------------------------------------------------- +ODbTypeWizDialogSetup::~ODbTypeWizDialogSetup() +{ + delete m_pOutSet; + DBG_DTOR(ODbTypeWizDialogSetup,NULL); +} + +//------------------------------------------------------------------------- +IMPL_LINK(ODbTypeWizDialogSetup, OnTypeSelected, OGeneralPage*, /*_pTabPage*/) +{ + activateDatabasePath(); + return 1L; +} + +void lcl_removeUnused(const ::comphelper::NamedValueCollection& _aOld,const ::comphelper::NamedValueCollection& _aNew,::comphelper::NamedValueCollection& _rDSInfo) +{ + _rDSInfo.merge(_aNew,true); + uno::Sequence< beans::NamedValue > aOldValues = _aOld.getNamedValues(); + const beans::NamedValue* pIter = aOldValues.getConstArray(); + const beans::NamedValue* pEnd = pIter + aOldValues.getLength(); + for(;pIter != pEnd;++pIter) + { + if ( !_aNew.has(pIter->Name) ) + { + _rDSInfo.remove(pIter->Name); + } + } +} +// ----------------------------------------------------------------------------- +void DataSourceInfoConverter::convert(const ::dbaccess::ODsnTypeCollection* _pCollection,const ::rtl::OUString& _sOldURLPrefix,const ::rtl::OUString& _sNewURLPrefix,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDatasource) +{ + if ( _pCollection->getPrefix(_sOldURLPrefix) == _pCollection->getPrefix(_sNewURLPrefix) ) + return ; + uno::Sequence< beans::PropertyValue> aInfo; + _xDatasource->getPropertyValue(PROPERTY_INFO) >>= aInfo; + ::comphelper::NamedValueCollection aDS(aInfo); + + ::connectivity::DriversConfig aDriverConfig(m_xFactory); + + const ::comphelper::NamedValueCollection& aOldProperties = aDriverConfig.getProperties(_sOldURLPrefix); + const ::comphelper::NamedValueCollection& aNewProperties = aDriverConfig.getProperties(_sNewURLPrefix); + lcl_removeUnused(aOldProperties,aNewProperties,aDS); + + aDS >>= aInfo; + _xDatasource->setPropertyValue(PROPERTY_INFO,uno::makeAny(aInfo)); +} +//------------------------------------------------------------------------- +void ODbTypeWizDialogSetup::activateDatabasePath() +{ + switch ( m_pGeneralPage->GetDatabaseCreationMode() ) + { + case OGeneralPage::eCreateNew: + { + sal_Int32 nCreateNewDBIndex = m_pCollection->getIndexOf( m_pCollection->getEmbeddedDatabase() ); + if ( nCreateNewDBIndex == -1 ) + nCreateNewDBIndex = m_pCollection->getIndexOf( ::rtl::OUString::createFromAscii( "sdbc:dbase:" ) ); + OSL_ENSURE( nCreateNewDBIndex != -1, "ODbTypeWizDialogSetup::activateDatabasePath: the GeneralPage should have prevented this!" ); + activatePath( static_cast< PathId >( nCreateNewDBIndex + 1 ), sal_True ); + + enableState(PAGE_DBSETUPWIZARD_FINAL, sal_True ); + enableButtons( WZB_FINISH, sal_True); + } + break; + case OGeneralPage::eConnectExternal: + { + ::rtl::OUString sOld = m_sURL; + DataSourceInfoConverter aConverter(getORB()); + m_sURL = m_pGeneralPage->GetSelectedType(); + aConverter.convert(m_pCollection,sOld,m_sURL,m_pImpl->getCurrentDataSource()); + ::dbaccess::DATASOURCE_TYPE eType = VerifyDataSourceType(m_pCollection->determineType(m_sURL)); + if (eType == ::dbaccess::DST_UNKNOWN) + eType = m_pCollection->determineType(m_sOldURL); + + activatePath( static_cast<PathId>(m_pCollection->getIndexOf(m_sURL) + 1), sal_True); + updateTypeDependentStates(); + } + break; + case OGeneralPage::eOpenExisting: + { + activatePath( static_cast<PathId>(m_pCollection->size() + 1), sal_True ); + enableButtons( WZB_FINISH, m_pGeneralPage->GetSelectedDocument().sURL.Len() != 0 ); + } + break; + default: + DBG_ERROR( "ODbTypeWizDialogSetup::activateDatabasePath: unknown creation mode!" ); + } + + enableButtons( WZB_NEXT, m_pGeneralPage->GetDatabaseCreationMode() != OGeneralPage::eOpenExisting ); + // TODO: this should go into the base class. Point is, we activate a path whose *last* + // step is also the current one. The base class should automatically disable + // the Next button in such a case. However, not for this patch ... +} + +//------------------------------------------------------------------------- +void ODbTypeWizDialogSetup::updateTypeDependentStates() +{ + sal_Bool bDoEnable = sal_False; + sal_Bool bIsConnectionRequired = IsConnectionUrlRequired(); + if (!bIsConnectionRequired) + { + bDoEnable = sal_True; + } + else if ( m_sURL == m_sOldURL ) + { + bDoEnable = m_bIsConnectable; + } + enableState(PAGE_DBSETUPWIZARD_AUTHENTIFICATION, bDoEnable); + enableState(PAGE_DBSETUPWIZARD_FINAL, bDoEnable ); + enableButtons( WZB_FINISH, bDoEnable); +} + + +//------------------------------------------------------------------------- +sal_Bool ODbTypeWizDialogSetup::IsConnectionUrlRequired() +{ + return m_pCollection->isConnectionUrlRequired(m_sURL); +} + +//------------------------------------------------------------------------- +void ODbTypeWizDialogSetup::resetPages(const Reference< XPropertySet >& _rxDatasource) +{ + // remove all items which relate to indirect properties from the input set + // (without this, the following may happen: select an arbitrary data source where some indirect properties + // are set. Select another data source of the same type, where the indirect props are not set (yet). Then, + // the indirect property values of the first ds are shown in the second ds ...) + const ODbDataSourceAdministrationHelper::MapInt2String& rMap = m_pImpl->getIndirectProperties(); + for ( ODbDataSourceAdministrationHelper::ConstMapInt2StringIterator aIndirect = rMap.begin(); + aIndirect != rMap.end(); + ++aIndirect + ) + getWriteOutputSet()->ClearItem( (sal_uInt16)aIndirect->first ); + + // extract all relevant data from the property set of the data source + m_pImpl->translateProperties(_rxDatasource, *getWriteOutputSet()); +} +// ----------------------------------------------------------------------------- +const SfxItemSet* ODbTypeWizDialogSetup::getOutputSet() const +{ + return m_pOutSet; +} +// ----------------------------------------------------------------------------- +SfxItemSet* ODbTypeWizDialogSetup::getWriteOutputSet() +{ + return m_pOutSet; +} +// ----------------------------------------------------------------------------- +::std::pair< Reference<XConnection>,sal_Bool> ODbTypeWizDialogSetup::createConnection() +{ + return m_pImpl->createConnection(); +} +// ----------------------------------------------------------------------------- +Reference< XMultiServiceFactory > ODbTypeWizDialogSetup::getORB() const +{ + return m_pImpl->getORB(); +} +// ----------------------------------------------------------------------------- +Reference< XDriver > ODbTypeWizDialogSetup::getDriver() +{ + return m_pImpl->getDriver(); +} + + +::dbaccess::DATASOURCE_TYPE ODbTypeWizDialogSetup::VerifyDataSourceType(const ::dbaccess::DATASOURCE_TYPE _DatabaseType) const +{ + ::dbaccess::DATASOURCE_TYPE LocDatabaseType = _DatabaseType; + if ((LocDatabaseType == ::dbaccess::DST_MYSQL_JDBC) || (LocDatabaseType == ::dbaccess::DST_MYSQL_ODBC) || (LocDatabaseType == ::dbaccess::DST_MYSQL_NATIVE)) + { + if (m_pMySQLIntroPage != NULL) + { + switch( m_pMySQLIntroPage->getMySQLMode() ) + { + case OMySQLIntroPageSetup::VIA_JDBC: + return ::dbaccess::DST_MYSQL_JDBC; + case OMySQLIntroPageSetup::VIA_NATIVE: + return ::dbaccess::DST_MYSQL_NATIVE; + case OMySQLIntroPageSetup::VIA_ODBC: + return ::dbaccess::DST_MYSQL_ODBC; + } + } + } + return LocDatabaseType; +} + + + +// ----------------------------------------------------------------------------- +::rtl::OUString ODbTypeWizDialogSetup::getDatasourceType(const SfxItemSet& _rSet) const +{ + ::rtl::OUString sRet = m_pImpl->getDatasourceType(_rSet); + if (m_pMySQLIntroPage != NULL && m_pMySQLIntroPage->IsVisible() ) + { + switch( m_pMySQLIntroPage->getMySQLMode() ) + { + case OMySQLIntroPageSetup::VIA_JDBC: + sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:jdbc:")); + break; + case OMySQLIntroPageSetup::VIA_NATIVE: + sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:mysqlc:")); + break; + case OMySQLIntroPageSetup::VIA_ODBC: + sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:odbc:")); + break; + } + } + return sRet; +} + +// ----------------------------------------------------------------------------- +void ODbTypeWizDialogSetup::clearPassword() +{ + m_pImpl->clearPassword(); +} + +// ----------------------------------------------------------------------------- +TabPage* ODbTypeWizDialogSetup::createPage(WizardState _nState) +{ + SfxTabPage* pFirstPage; + OGenericAdministrationPage* pPage = NULL; + switch(_nState) + { + case PAGE_DBSETUPWIZARD_INTRO: + pFirstPage = OGeneralPage::Create(this,*m_pOutSet, sal_True); + pPage = static_cast<OGenericAdministrationPage*> (pFirstPage); + m_pGeneralPage = static_cast<OGeneralPage*>(pFirstPage); + m_pGeneralPage->SetTypeSelectHandler(LINK(this, ODbTypeWizDialogSetup, OnTypeSelected)); + m_pGeneralPage->SetCreationModeHandler(LINK( this, ODbTypeWizDialogSetup, OnChangeCreationMode ) ); + m_pGeneralPage->SetDocumentSelectionHandler(LINK( this, ODbTypeWizDialogSetup, OnRecentDocumentSelected ) ); + m_pGeneralPage->SetChooseDocumentHandler(LINK( this, ODbTypeWizDialogSetup, OnSingleDocumentChosen ) ); + break; + + case PAGE_DBSETUPWIZARD_DBASE: + pPage = OConnectionTabPageSetup::CreateDbaseTabPage(this,*m_pOutSet); + break; + + case PAGE_DBSETUPWIZARD_ADO: + pPage = OConnectionTabPageSetup::CreateADOTabPage( this, *m_pOutSet); + break; + + case PAGE_DBSETUPWIZARD_TEXT: + pPage = OTextConnectionPageSetup::CreateTextTabPage(this,*m_pOutSet); + break; + + case PAGE_DBSETUPWIZARD_ODBC: + pPage = OConnectionTabPageSetup::CreateODBCTabPage( this, *m_pOutSet); + break; + + case PAGE_DBSETUPWIZARD_JDBC: + pPage = OJDBCConnectionPageSetup::CreateJDBCTabPage( this, *m_pOutSet); + break; + + case PAGE_DBSETUPWIZARD_MYSQL_ODBC: + m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:odbc:"))))); + pPage = OConnectionTabPageSetup::CreateODBCTabPage( this, *m_pOutSet); + break; + + case PAGE_DBSETUPWIZARD_MYSQL_JDBC: + m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:jdbc:"))))); + pPage = OGeneralSpecialJDBCConnectionPageSetup::CreateMySQLJDBCTabPage( this, *m_pOutSet); + break; + case PAGE_DBSETUPWIZARD_MYSQL_NATIVE: + m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:mysqlc:"))))); + pPage = MySQLNativeSetupPage::Create( this, *m_pOutSet); + break; + + case PAGE_DBSETUPWIZARD_ORACLE: + pPage = OGeneralSpecialJDBCConnectionPageSetup::CreateOracleJDBCTabPage( this, *m_pOutSet); + break; + + case PAGE_DBSETUPWIZARD_ADABAS: + pPage = OConnectionTabPageSetup::CreateAdabasTabPage( this, *m_pOutSet); + break; + + case PAGE_DBSETUPWIZARD_LDAP : + pPage = OLDAPConnectionPageSetup::CreateLDAPTabPage(this,*m_pOutSet); + break; + + case PAGE_DBSETUPWIZARD_SPREADSHEET: /// first user defined driver + pPage = OSpreadSheetConnectionPageSetup::CreateSpreadSheetTabPage(this,*m_pOutSet); + break; + + case PAGE_DBSETUPWIZARD_MSACCESS: + pPage = OConnectionTabPageSetup::CreateMSAccessTabPage(this,*m_pOutSet); + break; + case PAGE_DBSETUPWIZARD_MYSQL_INTRO: + m_pMySQLIntroPage = OMySQLIntroPageSetup::CreateMySQLIntroTabPage(this,*m_pOutSet); + m_pMySQLIntroPage->SetClickHdl(LINK( this, ODbTypeWizDialogSetup, ImplClickHdl ) ); + pPage = m_pMySQLIntroPage; + break; + + case PAGE_DBSETUPWIZARD_AUTHENTIFICATION: + pPage = OAuthentificationPageSetup::CreateAuthentificationTabPage(this,*m_pOutSet); + break; + + case PAGE_DBSETUPWIZARD_USERDEFINED: + pPage = OConnectionTabPageSetup::CreateUserDefinedTabPage(this,*m_pOutSet); + break; + + case PAGE_DBSETUPWIZARD_FINAL: + pPage = OFinalDBPageSetup::CreateFinalDBTabPageSetup(this,*m_pOutSet); + pFinalPage = static_cast<OFinalDBPageSetup*> (pPage); + break; + } + + if ((_nState != PAGE_DBSETUPWIZARD_INTRO) && (_nState != PAGE_DBSETUPWIZARD_AUTHENTIFICATION)) + { + pPage->SetModifiedHandler(LINK( this, ODbTypeWizDialogSetup, ImplModifiedHdl ) ); + } + + if ( pPage ) + { + pPage->SetServiceFactory(m_pImpl->getORB()); + pPage->SetAdminDialog(this, this); + + defaultButton( _nState == PAGE_DBSETUPWIZARD_FINAL ? WZB_FINISH : WZB_NEXT ); + enableButtons( WZB_FINISH, _nState == PAGE_DBSETUPWIZARD_FINAL ); + enableButtons( WZB_NEXT, _nState == PAGE_DBSETUPWIZARD_FINAL ? sal_False : sal_True); + pPage->Show(); + } + return pPage; +} + + +IMPL_LINK(ODbTypeWizDialogSetup, ImplModifiedHdl, OGenericAdministrationPage*, _pConnectionPageSetup) +{ + m_bIsConnectable = _pConnectionPageSetup->GetRoadmapStateValue( ); + enableState(PAGE_DBSETUPWIZARD_FINAL, m_bIsConnectable); + enableState(PAGE_DBSETUPWIZARD_AUTHENTIFICATION, m_bIsConnectable); + if (getCurrentState() == PAGE_DBSETUPWIZARD_FINAL) + enableButtons( WZB_FINISH, sal_True); + else + enableButtons( WZB_FINISH, m_bIsConnectable); + enableButtons( WZB_NEXT, m_bIsConnectable && (getCurrentState() != PAGE_DBSETUPWIZARD_FINAL)); + return sal_True; +} + + +// ----------------------------------------------------------------------------- +IMPL_LINK(ODbTypeWizDialogSetup, ImplClickHdl, OMySQLIntroPageSetup*, _pMySQLIntroPageSetup) +{ + ::rtl::OUString sURLPrefix; + switch( _pMySQLIntroPageSetup->getMySQLMode() ) + { + case OMySQLIntroPageSetup::VIA_ODBC: + sURLPrefix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:odbc:")); + break; + case OMySQLIntroPageSetup::VIA_JDBC: + sURLPrefix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:jdbc:")); + break; + case OMySQLIntroPageSetup::VIA_NATIVE: + sURLPrefix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:mysqlc:")); + break; + } // switch( _pMySQLIntroPageSetup->getMySQLMode() ) + activatePath( static_cast<PathId>(m_pCollection->getIndexOf(sURLPrefix) + 1), sal_True); + return sal_True; +} + +// ----------------------------------------------------------------------------- +IMPL_LINK(ODbTypeWizDialogSetup, OnChangeCreationMode, OGeneralPage*, /*_pGeneralPage*/) +{ + activateDatabasePath(); + return sal_True; +} + +// ----------------------------------------------------------------------------- +IMPL_LINK(ODbTypeWizDialogSetup, OnRecentDocumentSelected, OGeneralPage*, /*_pGeneralPage*/) +{ + enableButtons( WZB_FINISH, m_pGeneralPage->GetSelectedDocument().sURL.Len() != 0 ); + return 0L; +} + +// ----------------------------------------------------------------------------- +IMPL_LINK(ODbTypeWizDialogSetup, OnSingleDocumentChosen, OGeneralPage*, /*_pGeneralPage*/) +{ + if ( prepareLeaveCurrentState( eFinish ) ) + onFinish(); + return 0L; +} + +// ----------------------------------------------------------------------------- +void ODbTypeWizDialogSetup::enterState(WizardState _nState) +{ + m_sURL = m_pImpl->getDatasourceType(*m_pOutSet); + RoadmapWizard::enterState(_nState); + switch(_nState) + { + case PAGE_DBSETUPWIZARD_INTRO: + m_sOldURL = m_sURL; + break; + case PAGE_DBSETUPWIZARD_FINAL: + enableButtons( WZB_FINISH, sal_True); + if ( pFinalPage ) + pFinalPage->enableTableWizardCheckBox(m_pCollection->supportsTableCreation(m_sURL)); + break; + } +} + +//------------------------------------------------------------------------- +sal_Bool ODbTypeWizDialogSetup::saveDatasource() +{ + SfxTabPage* pPage = static_cast<SfxTabPage*>(WizardDialog::GetPage(getCurrentState())); + if ( pPage ) + pPage->FillItemSet(*m_pOutSet); + return sal_True; +} + + +// ----------------------------------------------------------------------------- +sal_Bool ODbTypeWizDialogSetup::leaveState(WizardState _nState) +{ + if (_nState == PAGE_DBSETUPWIZARD_MYSQL_INTRO) + return sal_True; + if ( _nState == PAGE_DBSETUPWIZARD_INTRO && m_sURL != m_sOldURL ) + { + resetPages(m_pImpl->getCurrentDataSource()); + } + SfxTabPage* pPage = static_cast<SfxTabPage*>(WizardDialog::GetPage(_nState)); + return pPage && pPage->DeactivatePage(m_pOutSet) != 0; +} + +// ----------------------------------------------------------------------------- +void ODbTypeWizDialogSetup::setTitle(const ::rtl::OUString& /*_sTitle*/) +{ + DBG_ERROR( "ODbTypeWizDialogSetup::setTitle: not implemented!" ); + // why? +} + +//------------------------------------------------------------------------- +void ODbTypeWizDialogSetup::enableConfirmSettings( bool _bEnable ) +{ + (void)_bEnable; +} + +//------------------------------------------------------------------------- +namespace +{ + bool lcl_handle( const Reference< XInteractionHandler2 >& _rxHandler, const Any& _rRequest ) + { + OInteractionRequest* pRequest = new OInteractionRequest( _rRequest ); + Reference < XInteractionRequest > xRequest( pRequest ); + OInteractionAbort* pAbort = new OInteractionAbort; + pRequest->addContinuation( pAbort ); + + return _rxHandler->handleInteractionRequest( xRequest ); + } +} + +//------------------------------------------------------------------------- +sal_Bool ODbTypeWizDialogSetup::SaveDatabaseDocument() +{ + Reference< XInteractionHandler2 > xHandler( getORB()->createInstance( SERVICE_TASK_INTERACTION_HANDLER ), UNO_QUERY ); + try + { + if (callSaveAsDialog() == sal_True) + { + m_pImpl->saveChanges(*m_pOutSet); + Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource(); + Reference< XModel > xModel( getDataSourceOrModel( xDatasource ), UNO_QUERY_THROW ); + Reference< XStorable > xStore( xModel, UNO_QUERY_THROW ); + + if ( m_pGeneralPage->GetDatabaseCreationMode() == OGeneralPage::eCreateNew ) + CreateDatabase(); + + ::comphelper::NamedValueCollection aArgs( xModel->getArgs() ); + aArgs.put( "Overwrite", sal_Bool( sal_True ) ); + aArgs.put( "InteractionHandler", xHandler ); + aArgs.put( "MacroExecutionMode", MacroExecMode::USE_CONFIG ); + + ::rtl::OUString sPath = m_pImpl->getDocumentUrl( *m_pOutSet ); + xStore->storeAsURL( sPath, aArgs.getPropertyValues() ); + + if ( !pFinalPage || pFinalPage->IsDatabaseDocumentToBeRegistered() ) + RegisterDataSourceByLocation( sPath ); + + return sal_True; + } + } + catch ( const Exception& e ) + { + Any aError = ::cppu::getCaughtException(); + if ( xHandler.is() ) + { + if ( !lcl_handle( xHandler, aError ) ) + { + InteractiveIOException aRequest; + aRequest.Classification = InteractionClassification_ERROR; + if ( aError.isExtractableTo( ::cppu::UnoType< IOException >::get() ) ) + // assume savint the document faile + aRequest.Code = IOErrorCode_CANT_WRITE; + else + aRequest.Code = IOErrorCode_GENERAL; + aRequest.Message = e.Message; + aRequest.Context = e.Context; + lcl_handle( xHandler, makeAny( aRequest ) ); + } + } + } + return sal_False; +} + // ------------------------------------------------------------------------ + sal_Bool ODbTypeWizDialogSetup::IsDatabaseDocumentToBeOpened() const + { + if ( m_pGeneralPage->GetDatabaseCreationMode() == OGeneralPage::eOpenExisting ) + return sal_True; + + if ( pFinalPage != NULL ) + return pFinalPage->IsDatabaseDocumentToBeOpened(); + + return sal_True; + } + + // ------------------------------------------------------------------------ + sal_Bool ODbTypeWizDialogSetup::IsTableWizardToBeStarted() const + { + if ( m_pGeneralPage->GetDatabaseCreationMode() == OGeneralPage::eOpenExisting ) + return sal_False; + + if ( pFinalPage != NULL ) + return pFinalPage->IsTableWizardToBeStarted(); + + return sal_False; + } + + //------------------------------------------------------------------------- + ::rtl::OUString ODbTypeWizDialogSetup::getDefaultDatabaseType() const + { + ::rtl::OUString sEmbeddedURL = m_pCollection->getEmbeddedDatabase(); + ::connectivity::DriversConfig aDriverConfig(getORB()); + try + { + if ( !aDriverConfig.getDriverFactoryName(sEmbeddedURL).getLength() || !m_pImpl->getDriver(sEmbeddedURL).is() ) + sEmbeddedURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:dbase:")); + } + catch(const Exception&) + { + sEmbeddedURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:dbase:")); + } + + return sEmbeddedURL; + } + + //------------------------------------------------------------------------- + void ODbTypeWizDialogSetup::CreateDatabase() + { + ::rtl::OUString sUrl; + ::rtl::OUString eType = getDefaultDatabaseType(); + if ( m_pCollection->isEmbeddedDatabase(eType) ) + { + sUrl = eType; + Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource(); + OSL_ENSURE(xDatasource.is(),"DataSource is null!"); + if ( xDatasource.is() ) + xDatasource->setPropertyValue( PROPERTY_INFO, makeAny( m_pCollection->getDefaultDBSettings( eType ) ) ); + m_pImpl->translateProperties(xDatasource,*m_pOutSet); + } + else if ( m_pCollection->isFileSystemBased(eType) ) + { + Reference< XSimpleFileAccess > xSimpleFileAccess(getORB()->createInstance(::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" )), UNO_QUERY); + INetURLObject aDBPathURL(m_sWorkPath); + aDBPathURL.Append(m_aDocURL.getBase()); + createUniqueFolderName(&aDBPathURL); + ::rtl::OUString sPrefix = eType; + sUrl = aDBPathURL.GetMainURL( INetURLObject::NO_DECODE); + xSimpleFileAccess->createFolder(sUrl); + //OFileNotation aFileNotation(sUrl); + //sUrl = aFileNotation.get(OFileNotation::N_SYSTEM); + sUrl = sPrefix.concat(sUrl); + } + m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, sUrl)); + m_pImpl->saveChanges(*m_pOutSet); + } + + //------------------------------------------------------------------------- + void ODbTypeWizDialogSetup::RegisterDataSourceByLocation(const ::rtl::OUString& _sPath) + { + Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource(); + Reference< XNamingService > xDatabaseContext(getORB()->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY); + Reference< XNameAccess > xNameAccessDatabaseContext(xDatabaseContext, UNO_QUERY); + INetURLObject aURL( _sPath ); + ::rtl::OUString sFilename = aURL.getBase( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ); + ::rtl::OUString sDatabaseName = ::dbtools::createUniqueName(xNameAccessDatabaseContext, sFilename,sal_False); + xDatabaseContext->registerObject(sDatabaseName, xDatasource); + } + + + //------------------------------------------------------------------------- + sal_Bool ODbTypeWizDialogSetup::callSaveAsDialog() + { + sal_Bool bRet = sal_False; + WinBits nBits(WB_STDMODAL|WB_SAVEAS); + ::sfx2::FileDialogHelper aFileDlg( com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION, static_cast<sal_uInt32>(nBits), this); + const SfxFilter* pFilter = getStandardDatabaseFilter(); + if ( pFilter ) + { + INetURLObject aWorkURL( m_sWorkPath ); + aFileDlg.SetDisplayFolder( aWorkURL.GetMainURL( INetURLObject::NO_DECODE )); + + ::rtl::OUString sDefaultName = String( ModuleRes( STR_DATABASEDEFAULTNAME ) ); + ::rtl::OUString sExtension = pFilter->GetDefaultExtension(); + sDefaultName += sExtension.replaceAt( 0, 1, ::rtl::OUString() ); + aWorkURL.Append( sDefaultName ); + sDefaultName = createUniqueFileName( aWorkURL ); + aFileDlg.SetFileName( sDefaultName ); + + aFileDlg.AddFilter(pFilter->GetUIName(),pFilter->GetDefaultExtension()); + aFileDlg.SetCurrentFilter(pFilter->GetUIName()); + } + if ( aFileDlg.Execute() == ERRCODE_NONE ) + { + m_aDocURL = INetURLObject(aFileDlg.GetPath()); + + if( m_aDocURL.GetProtocol() != INET_PROT_NOT_VALID ) + { + ::rtl::OUString sFileName = m_aDocURL.GetMainURL( INetURLObject::NO_DECODE ); + if ( ::utl::UCBContentHelper::IsDocument(sFileName) ) + ::utl::UCBContentHelper::Kill(sFileName); + m_pOutSet->Put(SfxStringItem(DSID_DOCUMENT_URL, sFileName)); + bRet = sal_True; + } + } + return bRet; + } + + //------------------------------------------------------------------------- + void ODbTypeWizDialogSetup::createUniqueFolderName(INetURLObject* pURL) + { + Reference< XSimpleFileAccess > xSimpleFileAccess(getORB()->createInstance(::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" )), UNO_QUERY); + :: rtl::OUString sLastSegmentName = pURL->getName(); + sal_Bool bFolderExists = sal_True; + sal_Int32 i = 1; + while (bFolderExists == sal_True) + { + bFolderExists = xSimpleFileAccess->isFolder(pURL->GetMainURL( INetURLObject::NO_DECODE )); + if (bFolderExists == sal_True) + { + i++; + pURL->setName(sLastSegmentName.concat(::rtl::OUString::valueOf(i))); + } + } + } + + //------------------------------------------------------------------------- + String ODbTypeWizDialogSetup::createUniqueFileName(const INetURLObject& _rURL) + { + Reference< XSimpleFileAccess > xSimpleFileAccess(getORB()->createInstance(::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" )), UNO_QUERY); + :: rtl::OUString sFilename = _rURL.getName(); + ::rtl::OUString BaseName = _rURL.getBase(); + ::rtl::OUString sExtension = _rURL.getExtension(); + + sal_Bool bElementExists = sal_True; + + INetURLObject aExistenceCheck( _rURL ); + for ( sal_Int32 i = 1; bElementExists; ) + { + bElementExists = xSimpleFileAccess->exists( aExistenceCheck.GetMainURL( INetURLObject::NO_DECODE ) ); + if ( bElementExists ) + { + aExistenceCheck.setBase( BaseName.concat( ::rtl::OUString::valueOf( i ) ) ); + ++i; + } + } + return aExistenceCheck.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ); + } + // ----------------------------------------------------------------------------- + IWizardPageController* ODbTypeWizDialogSetup::getPageController( TabPage* _pCurrentPage ) const + { + OGenericAdministrationPage* pPage = static_cast<OGenericAdministrationPage*>(_pCurrentPage); + return pPage; + } + + // ----------------------------------------------------------------------------- + namespace + { + // ............................................................................. + typedef ::cppu::WeakImplHelper1 < XTerminateListener + > AsyncLoader_Base; + class AsyncLoader : public AsyncLoader_Base + { + private: + Reference< XComponentLoader > m_xFrameLoader; + Reference< XDesktop > m_xDesktop; + Reference< XInteractionHandler > m_xInteractionHandler; + ::rtl::OUString m_sURL; + OAsyncronousLink m_aAsyncCaller; + + public: + AsyncLoader( const Reference< XMultiServiceFactory >& _rxORB, const ::rtl::OUString& _rURL ); + + void doLoadAsync(); + + // XTerminateListener + virtual void SAL_CALL queryTermination( const EventObject& Event ) throw (TerminationVetoException, RuntimeException); + virtual void SAL_CALL notifyTermination( const EventObject& Event ) throw (RuntimeException); + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); + + private: + DECL_LINK( OnOpenDocument, void* ); + }; + + // ............................................................................. + AsyncLoader::AsyncLoader( const Reference< XMultiServiceFactory >& _rxORB, const ::rtl::OUString& _rURL ) + :m_sURL( _rURL ) + ,m_aAsyncCaller( LINK( this, AsyncLoader, OnOpenDocument ) ) + { + try + { + m_xDesktop.set( _rxORB->createInstance( SERVICE_FRAME_DESKTOP ), UNO_QUERY_THROW ); + m_xFrameLoader.set( m_xDesktop, UNO_QUERY_THROW ); + m_xInteractionHandler.set( + _rxORB->createInstance( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.task.InteractionHandler" ) ) + ), + UNO_QUERY_THROW ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + // ............................................................................. + void AsyncLoader::doLoadAsync() + { + OSL_ENSURE( !m_aAsyncCaller.IsRunning(), "AsyncLoader:doLoadAsync: already running!" ); + + acquire(); + try + { + if ( m_xDesktop.is() ) + m_xDesktop->addTerminateListener( this ); + } + catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } + + m_aAsyncCaller.Call( NULL ); + } + + // ............................................................................. + IMPL_LINK( AsyncLoader, OnOpenDocument, void*, /*_pEmptyArg*/ ) + { + try + { + if ( m_xFrameLoader.is() ) + { + ::comphelper::NamedValueCollection aLoadArgs; + aLoadArgs.put( "InteractionHandler", m_xInteractionHandler ); + aLoadArgs.put( "MacroExecutionMode", MacroExecMode::USE_CONFIG ); + + Sequence< PropertyValue > aLoadArgPV; + aLoadArgs >>= aLoadArgPV; + + m_xFrameLoader->loadComponentFromURL( m_sURL, + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_default" ) ), + FrameSearchFlag::ALL, + aLoadArgPV + ); + } + } + catch( const Exception& ) + { + // do not assert. + // Such an exception happens for instance of the to-be-loaded document does not exist anymore. + } + + try + { + if ( m_xDesktop.is() ) + m_xDesktop->removeTerminateListener( this ); + } + catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } + + release(); + return 0L; + } + + // ............................................................................. + void SAL_CALL AsyncLoader::queryTermination( const EventObject& /*Event*/ ) throw (TerminationVetoException, RuntimeException) + { + throw TerminationVetoException(); + } + + // ............................................................................. + void SAL_CALL AsyncLoader::notifyTermination( const EventObject& /*Event*/ ) throw (RuntimeException) + { + } + // ............................................................................. + void SAL_CALL AsyncLoader::disposing( const EventObject& /*Source*/ ) throw (RuntimeException) + { + } + } + + // ----------------------------------------------------------------------------- + sal_Bool ODbTypeWizDialogSetup::onFinish() + { + if ( m_pGeneralPage->GetDatabaseCreationMode() == OGeneralPage::eOpenExisting ) + { + // we're not going to re-use the XModel we have - since the document the user + // wants us to load could be a non-database document. Instead, we asynchronously + // open the selected document. Thus, the wizard's return value is RET_CANCEL, + // which means to not continue loading the database document + if ( !OWizardMachine::Finnish( RET_CANCEL ) ) + return sal_False; + + Reference< XComponentLoader > xFrameLoader; + try + { + AsyncLoader* pAsyncLoader = new AsyncLoader( getORB(), m_pGeneralPage->GetSelectedDocument().sURL ); + ::rtl::Reference< AsyncLoader > xKeepAlive( pAsyncLoader ); + pAsyncLoader->doLoadAsync(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + return sal_True; + } + + if (getCurrentState() != PAGE_DBSETUPWIZARD_FINAL) + { + skipUntil(PAGE_DBSETUPWIZARD_FINAL); + } + if (getCurrentState() == PAGE_DBSETUPWIZARD_FINAL) + return SaveDatabaseDocument() ? OWizardMachine::onFinish() : sal_False; + else + { + enableButtons( WZB_FINISH, sal_False ); + return sal_False; + } + } + +//......................................................................... +} // namespace dbaui +//......................................................................... + diff --git a/dbaccess/source/ui/dlg/detailpages.cxx b/dbaccess/source/ui/dlg/detailpages.cxx new file mode 100644 index 000000000000..d90dbd8bc296 --- /dev/null +++ b/dbaccess/source/ui/dlg/detailpages.cxx @@ -0,0 +1,1151 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#include "detailpages.hxx" +#include "sqlmessage.hxx" +#include "dsmeta.hxx" +#include "advancedsettings.hxx" +#include "DbAdminImpl.hxx" +#include "dsitems.hxx" +#include "dbfindex.hxx" +#include "localresaccess.hxx" +#include "dsnItem.hxx" + +#include "dbaccess_helpid.hrc" +#include "dbu_dlg.hrc" +#include "dbadmin.hrc" + +#ifndef _SFXITEMSET_HXX +#include <svl/itemset.hxx> +#endif +#ifndef _SFXSTRITEM_HXX +#include <svl/stritem.hxx> +#endif +#ifndef _SFXENUMITEM_HXX +#include <svl/eitem.hxx> +#endif +#ifndef _SFXINTITEM_HXX +#include <svl/intitem.hxx> +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif +#ifndef _SV_MNEMONIC_HXX +#include <vcl/mnemonic.hxx> +#endif +#ifndef _SVTOOLS_CJKOPTIONS_HXX +#include <svl/cjkoptions.hxx> +#endif +#include <jvmaccess/virtualmachine.hxx> +#ifndef DBAUI_ADABASPAGE_HRC +#include "AdabasPage.hrc" +#endif +#ifndef _DBAUI_ADASTAT_HXX_ +#include "AdabasStat.hxx" +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include <connectivity/CommonTools.hxx> +#endif +#ifndef DBAUI_DRIVERSETTINGS_HXX +#include "DriverSettings.hxx" +#endif +#ifndef _DBAUI_DBADMIN_HXX_ +#include "dbadmin.hxx" +#endif +#ifndef _COMPHELPER_TYPES_HXX_ +#include <comphelper/types.hxx> +#endif +#include "AutoControls.hrc" + +//......................................................................... +namespace dbaui +{ +//......................................................................... + + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::sdbc; + using namespace ::com::sun::star::beans; + using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::container; + using namespace ::dbtools; + + //======================================================================== + //= OCommonBehaviourTabPage + //======================================================================== + DBG_NAME(OCommonBehaviourTabPage) + //------------------------------------------------------------------------ + OCommonBehaviourTabPage::OCommonBehaviourTabPage(Window* pParent, USHORT nResId, const SfxItemSet& _rCoreAttrs, + sal_uInt32 nControlFlags,bool _bFreeResource) + + :OGenericAdministrationPage(pParent, ModuleRes(nResId), _rCoreAttrs) + ,m_pOptionsLabel(NULL) + ,m_pOptions(NULL) + ,m_pDataConvertFixedLine(NULL) + ,m_pCharsetLabel(NULL) + ,m_pCharset(NULL) + ,m_pAutoFixedLine(NULL) + ,m_pAutoRetrievingEnabled(NULL) + ,m_pAutoIncrementLabel(NULL) + ,m_pAutoIncrement(NULL) + ,m_pAutoRetrievingLabel(NULL) + ,m_pAutoRetrieving(NULL) + ,m_nControlFlags(nControlFlags) + { + DBG_CTOR(OCommonBehaviourTabPage,NULL); + + if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS) + { + m_pOptionsLabel = new FixedText(this, ModuleRes(FT_OPTIONS)); + m_pOptions = new Edit(this, ModuleRes(ET_OPTIONS)); + m_pOptions->SetModifyHdl(getControlModifiedLink()); + } + + if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET) + { + m_pDataConvertFixedLine = new FixedLine(this, ModuleRes(FL_DATACONVERT)); + m_pCharsetLabel = new FixedText(this, ModuleRes(FT_CHARSET)); + m_pCharset = new CharSetListBox(this, ModuleRes(LB_CHARSET)); + m_pCharset->SetSelectHdl(getControlModifiedLink()); + } + + Window* pWindows[] = { m_pAutoRetrievingEnabled, m_pAutoFixedLine, + m_pAutoIncrementLabel, m_pAutoIncrement, + m_pAutoRetrievingLabel, m_pAutoRetrieving }; + + sal_Int32 nCount = sizeof(pWindows) / sizeof(pWindows[0]); + for (sal_Int32 i=1; i < nCount; ++i) + { + if ( pWindows[i] ) + { + Window* pPrev = pWindows[i-1]; + for (sal_Int32 j = i-1; pPrev == NULL && j >= 0 ; --j) + { + pPrev = pWindows[j]; + } + if ( pPrev ) + pWindows[i]->SetZOrder(pPrev, WINDOW_ZORDER_BEHIND); + } + } + + if ( _bFreeResource ) + FreeResource(); + } + + // ----------------------------------------------------------------------- + OCommonBehaviourTabPage::~OCommonBehaviourTabPage() + { + DELETEZ(m_pOptionsLabel); + DELETEZ(m_pOptions); + + DELETEZ(m_pDataConvertFixedLine); + DELETEZ(m_pCharsetLabel); + DELETEZ(m_pCharset); + + DELETEZ(m_pAutoFixedLine); + DELETEZ(m_pAutoIncrementLabel); + DELETEZ(m_pAutoIncrement); + + DELETEZ(m_pAutoRetrievingEnabled); + DELETEZ(m_pAutoRetrievingLabel); + DELETEZ(m_pAutoRetrieving); + + DBG_DTOR(OCommonBehaviourTabPage,NULL); + } + + // ----------------------------------------------------------------------- + void OCommonBehaviourTabPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) + { + if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS) + { + _rControlList.push_back(new ODisableWrapper<FixedText>(m_pOptionsLabel)); + } + + if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET) + { + _rControlList.push_back(new ODisableWrapper<FixedLine>(m_pDataConvertFixedLine)); + _rControlList.push_back(new ODisableWrapper<FixedText>(m_pCharsetLabel)); + } + } + // ----------------------------------------------------------------------- + void OCommonBehaviourTabPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) + { + if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS) + _rControlList.push_back(new OSaveValueWrapper<Edit>(m_pOptions)); + + if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET) + _rControlList.push_back(new OSaveValueWrapper<ListBox>(m_pCharset)); + } + + // ----------------------------------------------------------------------- + void OCommonBehaviourTabPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) + { + // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) + sal_Bool bValid, bReadonly; + getFlags(_rSet, bValid, bReadonly); + + // collect the items + SFX_ITEMSET_GET(_rSet, pOptionsItem, SfxStringItem, DSID_ADDITIONALOPTIONS, sal_True); + SFX_ITEMSET_GET(_rSet, pCharsetItem, SfxStringItem, DSID_CHARSET, sal_True); + + // forward the values to the controls + if (bValid) + { + if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS) + { + m_pOptions->SetText(pOptionsItem->GetValue()); + m_pOptions->ClearModifyFlag(); + } + + if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET) + { + m_pCharset->SelectEntryByIanaName( pCharsetItem->GetValue() ); + } + } + OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue); + } + // ----------------------------------------------------------------------- + sal_Bool OCommonBehaviourTabPage::FillItemSet(SfxItemSet& _rSet) + { + sal_Bool bChangedSomething = sal_False; + + if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS) + { + fillString(_rSet,m_pOptions,DSID_ADDITIONALOPTIONS,bChangedSomething); + } + + if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET) + { + if ( m_pCharset->StoreSelectedCharSet( _rSet, DSID_CHARSET ) ) + bChangedSomething = sal_True; + } + + return bChangedSomething; + } + + //======================================================================== + //= ODbaseDetailsPage + //======================================================================== + DBG_NAME(ODbaseDetailsPage) + //------------------------------------------------------------------------ + ODbaseDetailsPage::ODbaseDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs ) + :OCommonBehaviourTabPage(pParent, PAGE_DBASE, _rCoreAttrs, CBTP_USE_CHARSET ,false) + ,m_aShowDeleted (this, ModuleRes(CB_SHOWDELETEDROWS)) + ,m_aFL_1 (this, ModuleRes( FL_SEPARATOR1) ) + ,m_aFT_Message (this, ModuleRes( FT_SPECIAL_MESSAGE) ) + ,m_aIndexes (this, ModuleRes(PB_INDICIES)) + { + DBG_CTOR(ODbaseDetailsPage,NULL); + + m_aIndexes.SetClickHdl(LINK(this, ODbaseDetailsPage, OnButtonClicked)); + m_aShowDeleted.SetClickHdl(LINK(this, ODbaseDetailsPage, OnButtonClicked)); + + // correct the z-order which is mixed-up because the base class constructed some controls before we did + m_pCharset->SetZOrder(&m_aShowDeleted, WINDOW_ZORDER_BEFOR); + + FreeResource(); + } + + // ----------------------------------------------------------------------- + ODbaseDetailsPage::~ODbaseDetailsPage() + { + + DBG_DTOR(ODbaseDetailsPage,NULL); + } + + // ----------------------------------------------------------------------- + SfxTabPage* ODriversSettings::CreateDbase( Window* pParent, const SfxItemSet& _rAttrSet ) + { + return ( new ODbaseDetailsPage( pParent, _rAttrSet ) ); + } + + // ----------------------------------------------------------------------- + void ODbaseDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) + { + OCommonBehaviourTabPage::fillControls(_rControlList); + _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aShowDeleted)); + } + // ----------------------------------------------------------------------- + void ODbaseDetailsPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) + { + OCommonBehaviourTabPage::fillWindows(_rControlList); + _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL_1)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFT_Message)); + _rControlList.push_back(new ODisableWrapper<PushButton>(&m_aIndexes)); + } + // ----------------------------------------------------------------------- + void ODbaseDetailsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) + { + // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) + sal_Bool bValid, bReadonly; + getFlags(_rSet, bValid, bReadonly); + + // get the DSN string (needed for the index dialog) + SFX_ITEMSET_GET(_rSet, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True); + SFX_ITEMSET_GET(_rSet, pTypesItem, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True); + ::dbaccess::ODsnTypeCollection* pTypeCollection = pTypesItem ? pTypesItem->getCollection() : NULL; + if (pTypeCollection && pUrlItem && pUrlItem->GetValue().Len()) + m_sDsn = pTypeCollection->cutPrefix(pUrlItem->GetValue()); + + // get the other relevant items + SFX_ITEMSET_GET(_rSet, pDeletedItem, SfxBoolItem, DSID_SHOWDELETEDROWS, sal_True); + + if ( bValid ) + { + m_aShowDeleted.Check( pDeletedItem->GetValue() ); + m_aFT_Message.Show(m_aShowDeleted.IsChecked()); + } + + OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue); + } + + // ----------------------------------------------------------------------- + sal_Bool ODbaseDetailsPage::FillItemSet( SfxItemSet& _rSet ) + { + sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet); + + fillBool(_rSet,&m_aShowDeleted,DSID_SHOWDELETEDROWS,bChangedSomething); + return bChangedSomething; + } + + //------------------------------------------------------------------------ + IMPL_LINK( ODbaseDetailsPage, OnButtonClicked, Button*, pButton ) + { + if (&m_aIndexes == pButton) + { + ODbaseIndexDialog aIndexDialog(this, m_sDsn); + aIndexDialog.Execute(); + } + else + { + m_aFT_Message.Show(m_aShowDeleted.IsChecked()); + // it was one of the checkboxes -> we count as modified from now on + callModifiedHdl(); + } + + return 0; + } + + //======================================================================== + //= OAdoDetailsPage + //======================================================================== + DBG_NAME(OAdoDetailsPage) + // ----------------------------------------------------------------------- + OAdoDetailsPage::OAdoDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs ) + :OCommonBehaviourTabPage(pParent, PAGE_ADO, _rCoreAttrs, CBTP_USE_CHARSET ) + { + DBG_CTOR(OAdoDetailsPage,NULL); + + } + + // ----------------------------------------------------------------------- + OAdoDetailsPage::~OAdoDetailsPage() + { + + DBG_DTOR(OAdoDetailsPage,NULL); + } + // ----------------------------------------------------------------------- + SfxTabPage* ODriversSettings::CreateAdo( Window* pParent, const SfxItemSet& _rAttrSet ) + { + return ( new OAdoDetailsPage( pParent, _rAttrSet ) ); + } + + // ----------------------------------------------------------------------- + //======================================================================== + //= OOdbcDetailsPage + //======================================================================== + OOdbcDetailsPage::OOdbcDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs ) + :OCommonBehaviourTabPage(pParent, PAGE_ODBC, _rCoreAttrs, CBTP_USE_CHARSET | CBTP_USE_OPTIONS,false) + ,m_aFL_1 (this, ModuleRes(FL_SEPARATOR1)) + ,m_aUseCatalog (this, ModuleRes(CB_USECATALOG)) + { + m_aUseCatalog.SetToggleHdl(getControlModifiedLink()); + FreeResource(); + + Window* pWindows[] = { m_pCharsetLabel, m_pCharset + ,m_pOptionsLabel,m_pOptions,&m_aUseCatalog + }; + + sal_Int32 nCount = sizeof(pWindows) / sizeof(pWindows[0]); + for (sal_Int32 i=1; i < nCount; ++i) + pWindows[i]->SetZOrder(pWindows[i-1], WINDOW_ZORDER_BEHIND); + } + + // ----------------------------------------------------------------------- + SfxTabPage* ODriversSettings::CreateODBC( Window* pParent, const SfxItemSet& _rAttrSet ) + { + return ( new OOdbcDetailsPage( pParent, _rAttrSet ) ); + } + + // ----------------------------------------------------------------------- + sal_Bool OOdbcDetailsPage::FillItemSet( SfxItemSet& _rSet ) + { + sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet); + fillBool(_rSet,&m_aUseCatalog,DSID_USECATALOG,bChangedSomething); + return bChangedSomething; + } + // ----------------------------------------------------------------------- + void OOdbcDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) + { + OCommonBehaviourTabPage::fillControls(_rControlList); + _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aUseCatalog)); + } + // ----------------------------------------------------------------------- + void OOdbcDetailsPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) + { + OCommonBehaviourTabPage::fillWindows(_rControlList); + _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL_1)); + } + // ----------------------------------------------------------------------- + void OOdbcDetailsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) + { + // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) + sal_Bool bValid, bReadonly; + getFlags(_rSet, bValid, bReadonly); + + SFX_ITEMSET_GET(_rSet, pUseCatalogItem, SfxBoolItem, DSID_USECATALOG, sal_True); + + if ( bValid ) + m_aUseCatalog.Check(pUseCatalogItem->GetValue()); + + OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue); + } + //======================================================================== + //= OOdbcDetailsPage + //======================================================================== + OUserDriverDetailsPage::OUserDriverDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs ) + :OCommonBehaviourTabPage(pParent, PAGE_USERDRIVER, _rCoreAttrs, + CBTP_USE_CHARSET | CBTP_USE_OPTIONS ,false) + ,m_aFTHostname (this, ModuleRes(FT_HOSTNAME)) + ,m_aEDHostname (this, ModuleRes(ET_HOSTNAME)) + ,m_aPortNumber (this, ModuleRes(FT_PORTNUMBER)) + ,m_aNFPortNumber (this, ModuleRes(NF_PORTNUMBER)) + ,m_aUseCatalog (this, ModuleRes(CB_USECATALOG)) + { + m_aUseCatalog.SetToggleHdl(getControlModifiedLink()); + FreeResource(); + } + + // ----------------------------------------------------------------------- + SfxTabPage* ODriversSettings::CreateUser( Window* pParent, const SfxItemSet& _rAttrSet ) + { + return ( new OUserDriverDetailsPage( pParent, _rAttrSet ) ); + } + + // ----------------------------------------------------------------------- + sal_Bool OUserDriverDetailsPage::FillItemSet( SfxItemSet& _rSet ) + { + sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet); + + fillInt32(_rSet,&m_aNFPortNumber,DSID_CONN_PORTNUMBER,bChangedSomething); + fillString(_rSet,&m_aEDHostname,DSID_CONN_HOSTNAME,bChangedSomething); + fillBool(_rSet,&m_aUseCatalog,DSID_USECATALOG,bChangedSomething); + + return bChangedSomething; + } + // ----------------------------------------------------------------------- + void OUserDriverDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) + { + OCommonBehaviourTabPage::fillControls(_rControlList); + _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aEDHostname)); + _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aUseCatalog)); + _rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_aNFPortNumber)); + } + // ----------------------------------------------------------------------- + void OUserDriverDetailsPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) + { + OCommonBehaviourTabPage::fillWindows(_rControlList); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHostname)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aPortNumber)); + } + // ----------------------------------------------------------------------- + void OUserDriverDetailsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) + { + // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) + sal_Bool bValid, bReadonly; + getFlags(_rSet, bValid, bReadonly); + + SFX_ITEMSET_GET(_rSet, pUseCatalogItem, SfxBoolItem, DSID_USECATALOG, sal_True); + SFX_ITEMSET_GET(_rSet, pHostName, SfxStringItem, DSID_CONN_HOSTNAME, sal_True); + SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, DSID_CONN_PORTNUMBER, sal_True); + + if ( bValid ) + { + m_aEDHostname.SetText(pHostName->GetValue()); + m_aEDHostname.ClearModifyFlag(); + + m_aNFPortNumber.SetValue(pPortNumber->GetValue()); + m_aNFPortNumber.ClearModifyFlag(); + + m_aUseCatalog.Check(pUseCatalogItem->GetValue()); + } + + OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue); + } + //======================================================================== + //= OMySQLODBCDetailsPage + //======================================================================== + OMySQLODBCDetailsPage::OMySQLODBCDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs ) + :OCommonBehaviourTabPage(pParent, PAGE_MYSQL_ODBC, _rCoreAttrs, CBTP_USE_CHARSET ) + { + } + + // ----------------------------------------------------------------------- + SfxTabPage* ODriversSettings::CreateMySQLODBC( Window* pParent, const SfxItemSet& _rAttrSet ) + { + return ( new OMySQLODBCDetailsPage( pParent, _rAttrSet ) ); + } + + //======================================================================== + //= OMySQLJDBCDetailsPage + //======================================================================== + OGeneralSpecialJDBCDetailsPage::OGeneralSpecialJDBCDetailsPage( Window* pParent,USHORT _nResId, const SfxItemSet& _rCoreAttrs ,USHORT _nPortId) + :OCommonBehaviourTabPage(pParent, _nResId, _rCoreAttrs, CBTP_USE_CHARSET ,false) + ,m_aFL_1 (this, ModuleRes( FL_SEPARATOR1) ) + ,m_aFTHostname (this, ModuleRes(FT_HOSTNAME)) + ,m_aEDHostname (this, ModuleRes(ET_HOSTNAME)) + ,m_aPortNumber (this, ModuleRes(FT_PORTNUMBER)) + ,m_aNFPortNumber (this, ModuleRes(NF_PORTNUMBER)) + ,m_aFTSocket (this, ModuleRes(FT_SOCKET)) + ,m_aEDSocket (this, ModuleRes(ET_SOCKET)) + ,m_aFTDriverClass (this, ModuleRes(FT_JDBCDRIVERCLASS)) + ,m_aEDDriverClass (this, ModuleRes(ET_JDBCDRIVERCLASS)) + ,m_aTestJavaDriver (this, ModuleRes(PB_TESTDRIVERCLASS)) + ,m_nPortId(_nPortId) + ,m_bUseClass(true) + { + SFX_ITEMSET_GET(_rCoreAttrs, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True); + SFX_ITEMSET_GET(_rCoreAttrs, pTypesItem, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True); + ::dbaccess::ODsnTypeCollection* pTypeCollection = pTypesItem ? pTypesItem->getCollection() : NULL; + if (pTypeCollection && pUrlItem && pUrlItem->GetValue().Len() ) + { + m_sDefaultJdbcDriverName = pTypeCollection->getJavaDriverClass(pUrlItem->GetValue()); + } + if ( m_sDefaultJdbcDriverName.Len() ) + { + m_aEDDriverClass.SetModifyHdl(getControlModifiedLink()); + m_aEDDriverClass.SetModifyHdl(LINK(this, OGeneralSpecialJDBCDetailsPage, OnEditModified)); + m_aTestJavaDriver.SetClickHdl(LINK(this,OGeneralSpecialJDBCDetailsPage,OnTestJavaClickHdl)); + } + else + { + m_bUseClass = false; + m_aFTDriverClass.Show(FALSE); + m_aEDDriverClass.Show(FALSE); + m_aTestJavaDriver.Show(FALSE); + } + + m_aFTSocket.Show(PAGE_MYSQL_JDBC == _nResId && !m_bUseClass); + m_aEDSocket.Show(PAGE_MYSQL_JDBC == _nResId && !m_bUseClass); + + m_aEDHostname.SetModifyHdl(getControlModifiedLink()); + m_aNFPortNumber.SetModifyHdl(getControlModifiedLink()); + m_aEDSocket.SetModifyHdl(getControlModifiedLink()); + + Window* pWindows[] = { &m_aFTHostname,&m_aEDHostname, + &m_aPortNumber,&m_aNFPortNumber,&m_aFTSocket,&m_aEDSocket, + &m_aFTDriverClass, &m_aEDDriverClass,&m_aTestJavaDriver, + m_pCharsetLabel, m_pCharset}; + + sal_Int32 nCount = sizeof(pWindows) / sizeof(pWindows[0]); + for (sal_Int32 i=1; i < nCount; ++i) + pWindows[i]->SetZOrder(pWindows[i-1], WINDOW_ZORDER_BEHIND); + + FreeResource(); + } + + // ----------------------------------------------------------------------- + void OGeneralSpecialJDBCDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) + { + OCommonBehaviourTabPage::fillControls(_rControlList); + if ( m_bUseClass ) + _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aEDDriverClass)); + _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aEDHostname)); + _rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_aNFPortNumber)); + _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aEDSocket)); + } + // ----------------------------------------------------------------------- + void OGeneralSpecialJDBCDetailsPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) + { + OCommonBehaviourTabPage::fillWindows(_rControlList); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHostname)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aPortNumber)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTSocket)); + if ( m_bUseClass ) + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDriverClass)); + _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL_1)); + } + + // ----------------------------------------------------------------------- + sal_Bool OGeneralSpecialJDBCDetailsPage::FillItemSet( SfxItemSet& _rSet ) + { + sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet); + if ( m_bUseClass ) + fillString(_rSet,&m_aEDDriverClass,DSID_JDBCDRIVERCLASS,bChangedSomething); + fillString(_rSet,&m_aEDHostname,DSID_CONN_HOSTNAME,bChangedSomething); + fillString(_rSet,&m_aEDSocket,DSID_CONN_SOCKET,bChangedSomething); + fillInt32(_rSet,&m_aNFPortNumber,m_nPortId,bChangedSomething ); + + return bChangedSomething; + } + // ----------------------------------------------------------------------- + void OGeneralSpecialJDBCDetailsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) + { + // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) + sal_Bool bValid, bReadonly; + getFlags(_rSet, bValid, bReadonly); + + SFX_ITEMSET_GET(_rSet, pDrvItem, SfxStringItem, DSID_JDBCDRIVERCLASS, sal_True); + SFX_ITEMSET_GET(_rSet, pHostName, SfxStringItem, DSID_CONN_HOSTNAME, sal_True); + SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, m_nPortId, sal_True); + SFX_ITEMSET_GET(_rSet, pSocket, SfxStringItem, DSID_CONN_SOCKET, sal_True); + + if ( bValid ) + { + if ( m_bUseClass ) + { + m_aEDDriverClass.SetText(pDrvItem->GetValue()); + m_aEDDriverClass.ClearModifyFlag(); + } + + m_aEDHostname.SetText(pHostName->GetValue()); + m_aEDHostname.ClearModifyFlag(); + + m_aNFPortNumber.SetValue(pPortNumber->GetValue()); + m_aNFPortNumber.ClearModifyFlag(); + + m_aEDSocket.SetText(pSocket->GetValue()); + m_aEDSocket.ClearModifyFlag(); + } + + OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue); + + // to get the correcxt value when saveValue was called by base class + if ( m_bUseClass && !m_aEDDriverClass.GetText().Len() ) + { + m_aEDDriverClass.SetText(m_sDefaultJdbcDriverName); + m_aEDDriverClass.SetModifyFlag(); + } + } + // ----------------------------------------------------------------------- + IMPL_LINK(OGeneralSpecialJDBCDetailsPage, OnTestJavaClickHdl, PushButton*, /*_pButton*/) + { + OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF"); + OSL_ENSURE(m_bUseClass,"Who called me?"); + + sal_Bool bSuccess = sal_False; + try + { + if ( m_aEDDriverClass.GetText().Len() ) + { +// TODO chage jvmaccess + ::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM(m_pAdminDialog->getORB()); + bSuccess = ::connectivity::existsJavaClassByName(xJVM,m_aEDDriverClass.GetText()); + } + } + catch(Exception&) + { + } + + USHORT nMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS; + OSQLMessageBox aMsg( this, String( ModuleRes( nMessage ) ), String() ); + aMsg.Execute(); + return 0L; + } + // ----------------------------------------------------------------------- + IMPL_LINK(OGeneralSpecialJDBCDetailsPage, OnEditModified, Edit*, _pEdit) + { + if ( m_bUseClass && _pEdit == &m_aEDDriverClass ) + m_aTestJavaDriver.Enable( m_aEDDriverClass.GetText().Len() != 0 ); + + // tell the listener we were modified + callModifiedHdl(); + return 0L; + } + + //======================================================================== + //= MySQLNativePage + //======================================================================== + MySQLNativePage::MySQLNativePage( Window* pParent, const SfxItemSet& _rCoreAttrs ) + :OCommonBehaviourTabPage(pParent, PAGE_MYSQL_NATIVE, _rCoreAttrs, CBTP_USE_CHARSET, false ) + ,m_aSeparator1 ( this, ModuleRes( FL_SEPARATOR1) ) + ,m_aMySQLSettings ( *this, getControlModifiedLink() ) + ,m_aSeparator2 ( this, ModuleRes(FL_SEPARATOR2)) + ,m_aUserNameLabel ( this, ModuleRes(FT_USERNAME)) + ,m_aUserName ( this, ModuleRes(ET_USERNAME)) + ,m_aPasswordRequired ( this, ModuleRes(CB_PASSWORD_REQUIRED)) + { + m_aUserName.SetModifyHdl(getControlModifiedLink()); + + Window* pWindows[] = { &m_aMySQLSettings, &m_aSeparator2, &m_aUserNameLabel, &m_aUserName, + &m_aPasswordRequired, m_pCharsetLabel, m_pCharset}; + sal_Int32 nCount = sizeof(pWindows) / sizeof(pWindows[0]); + for (sal_Int32 i=1; i < nCount; ++i) + pWindows[i]->SetZOrder(pWindows[i-1], WINDOW_ZORDER_BEHIND); + + LayoutHelper::positionBelow( m_aSeparator1, m_aMySQLSettings, RelatedControls, 3 ); + m_aMySQLSettings.Show(); + + FreeResource(); + } + + // ----------------------------------------------------------------------- + void MySQLNativePage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) + { + OCommonBehaviourTabPage::fillControls( _rControlList ); + m_aMySQLSettings.fillControls( _rControlList ); + + _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aUserName)); + _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aPasswordRequired)); + } + // ----------------------------------------------------------------------- + void MySQLNativePage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) + { + OCommonBehaviourTabPage::fillWindows( _rControlList ); + m_aMySQLSettings.fillWindows( _rControlList); + + _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aSeparator1)); + _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aSeparator2)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aUserNameLabel)); + } + + // ----------------------------------------------------------------------- + sal_Bool MySQLNativePage::FillItemSet( SfxItemSet& _rSet ) + { + sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet( _rSet ); + + bChangedSomething |= m_aMySQLSettings.FillItemSet( _rSet ); + + if ( m_aUserName.GetText() != m_aUserName.GetSavedValue() ) + { + _rSet.Put( SfxStringItem( DSID_USER, m_aUserName.GetText() ) ); + _rSet.Put( SfxStringItem( DSID_PASSWORD, String())); + bChangedSomething = sal_True; + } + fillBool(_rSet,&m_aPasswordRequired,DSID_PASSWORDREQUIRED,bChangedSomething); + + return bChangedSomething; + } + // ----------------------------------------------------------------------- + void MySQLNativePage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) + { + // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) + sal_Bool bValid, bReadonly; + getFlags(_rSet, bValid, bReadonly); + + m_aMySQLSettings.implInitControls( _rSet ); + + SFX_ITEMSET_GET(_rSet, pUidItem, SfxStringItem, DSID_USER, sal_True); + SFX_ITEMSET_GET(_rSet, pAllowEmptyPwd, SfxBoolItem, DSID_PASSWORDREQUIRED, sal_True); + + if ( bValid ) + { + m_aUserName.SetText(pUidItem->GetValue()); + m_aUserName.ClearModifyFlag(); + m_aPasswordRequired.Check(pAllowEmptyPwd->GetValue()); + } + + OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue); + } + + // ----------------------------------------------------------------------- + SfxTabPage* ODriversSettings::CreateMySQLJDBC( Window* pParent, const SfxItemSet& _rAttrSet ) + { + return ( new OGeneralSpecialJDBCDetailsPage( pParent,PAGE_MYSQL_JDBC, _rAttrSet,DSID_MYSQL_PORTNUMBER ) ); + } + // ----------------------------------------------------------------------- + SfxTabPage* ODriversSettings::CreateMySQLNATIVE( Window* pParent, const SfxItemSet& _rAttrSet ) + { + return ( new MySQLNativePage( pParent, _rAttrSet ) ); + } + + // ----------------------------------------------------------------------- + SfxTabPage* ODriversSettings::CreateOracleJDBC( Window* pParent, const SfxItemSet& _rAttrSet ) + { + return ( new OGeneralSpecialJDBCDetailsPage( pParent,PAGE_ORACLE_JDBC, _rAttrSet,DSID_ORACLE_PORTNUMBER) ); + } + + + //======================================================================== + //= OAdabasDetailsPage + //======================================================================== + OAdabasDetailsPage::OAdabasDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs ) + :OCommonBehaviourTabPage(pParent, PAGE_ADABAS, _rCoreAttrs, CBTP_USE_CHARSET ,false) + ,m_aFTHostname (this, ModuleRes(FT_HOSTNAME)) + ,m_aEDHostname (this, ModuleRes(ET_HOSTNAME)) + ,m_aFL_1 (this, ModuleRes( FL_SEPARATOR1) ) + ,m_FT_CACHE_SIZE( this, ModuleRes( FT_CACHE_SIZE ) ) + ,m_NF_CACHE_SIZE( this, ModuleRes( NF_CACHE_SIZE ) ) + ,m_FT_DATA_INCREMENT( this, ModuleRes( FT_DATA_INCREMENT ) ) + ,m_NF_DATA_INCREMENT( this, ModuleRes( NF_DATA_INCREMENT ) ) + ,m_aFL_2( this, ModuleRes( FL_SEPARATOR2 ) ) + ,m_FT_CTRLUSERNAME( this, ModuleRes( FT_CTRLUSERNAME ) ) + ,m_ET_CTRLUSERNAME( this, ModuleRes( ET_CTRLUSERNAME ) ) + ,m_FT_CTRLPASSWORD( this, ModuleRes( FT_CTRLPASSWORD ) ) + ,m_ET_CTRLPASSWORD( this, ModuleRes( ET_CTRLPASSWORD ) ) + ,m_CB_SHUTDB( this, ModuleRes( CB_SHUTDB ) ) + ,m_PB_STAT( this, ModuleRes( PB_STAT ) ) + { + m_aEDHostname.SetModifyHdl(getControlModifiedLink()); + + FreeResource(); + + m_PB_STAT.SetClickHdl( LINK(this,OAdabasDetailsPage,PBClickHdl)); + + m_CB_SHUTDB.SetClickHdl( LINK(this,OAdabasDetailsPage,AttributesChangedHdl)); + m_NF_CACHE_SIZE.SetModifyHdl( LINK(this,OAdabasDetailsPage,AttributesChangedHdl)); + m_NF_DATA_INCREMENT.SetModifyHdl( LINK(this,OAdabasDetailsPage,AttributesChangedHdl)); + m_ET_CTRLUSERNAME.SetModifyHdl( LINK(this,OAdabasDetailsPage,AttributesChangedHdl)); + m_ET_CTRLPASSWORD.SetModifyHdl( LINK(this,OAdabasDetailsPage,AttributesChangedHdl)); + + m_ET_CTRLUSERNAME.SetLoseFocusHdl( LINK(this,OAdabasDetailsPage,LoseFocusHdl)); + m_ET_CTRLPASSWORD.SetLoseFocusHdl( LINK(this,OAdabasDetailsPage,LoseFocusHdl)); + + m_NF_DATA_INCREMENT.SetMin(20); + m_NF_DATA_INCREMENT.SetMax(LONG_MAX); + m_NF_DATA_INCREMENT.SetValue(20); + m_NF_DATA_INCREMENT.SetDecimalDigits(0); + + m_NF_CACHE_SIZE.SetMin(4); + m_NF_CACHE_SIZE.SetMax(LONG_MAX); + m_NF_CACHE_SIZE.SetValue(4); + m_NF_CACHE_SIZE.SetDecimalDigits(0); + + Window* pWindows[] = { &m_aFTHostname,&m_aEDHostname + ,&m_FT_CACHE_SIZE,&m_NF_CACHE_SIZE + ,&m_FT_DATA_INCREMENT,&m_NF_DATA_INCREMENT + ,&m_FT_CTRLUSERNAME,&m_ET_CTRLUSERNAME + ,&m_FT_CTRLPASSWORD,&m_ET_CTRLPASSWORD + ,&m_CB_SHUTDB + ,m_pCharsetLabel, m_pCharset,&m_PB_STAT}; + + sal_Int32 nCount = sizeof(pWindows) / sizeof(pWindows[0]); + for (sal_Int32 i=1; i < nCount; ++i) + pWindows[i]->SetZOrder(pWindows[i-1], WINDOW_ZORDER_BEHIND); + } + + // ----------------------------------------------------------------------- + SfxTabPage* ODriversSettings::CreateAdabas( Window* pParent, const SfxItemSet& _rAttrSet ) + { + return ( new OAdabasDetailsPage( pParent, _rAttrSet ) ); + } + + // ----------------------------------------------------------------------- + void OAdabasDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) + { + OCommonBehaviourTabPage::fillControls(_rControlList); + _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aEDHostname)); + _rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_NF_CACHE_SIZE)); + _rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_NF_DATA_INCREMENT)); + _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_ET_CTRLUSERNAME)); + _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_ET_CTRLPASSWORD)); + _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_CB_SHUTDB)); + } + // ----------------------------------------------------------------------- + void OAdabasDetailsPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) + { + OCommonBehaviourTabPage::fillWindows(_rControlList); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHostname)); + _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL_1)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_FT_CACHE_SIZE)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_FT_DATA_INCREMENT)); + _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL_2)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_FT_CTRLUSERNAME)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_FT_CTRLPASSWORD)); + _rControlList.push_back(new ODisableWrapper<PushButton>(&m_PB_STAT)); + } + // ----------------------------------------------------------------------- + void OAdabasDetailsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) + { + // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) + sal_Bool bValid, bReadonly; + getFlags(_rSet, bValid, bReadonly); + + SFX_ITEMSET_GET(_rSet, pHostName, SfxStringItem, DSID_CONN_HOSTNAME, sal_True); + SFX_ITEMSET_GET(_rSet, pCtrlUserItem, SfxStringItem, DSID_CONN_CTRLUSER, sal_True); + SFX_ITEMSET_GET(_rSet, pCtrlPwdItem, SfxStringItem, DSID_CONN_CTRLPWD, sal_True); + SFX_ITEMSET_GET(_rSet, pShutItem, SfxBoolItem, DSID_CONN_SHUTSERVICE, sal_True); + SFX_ITEMSET_GET(_rSet, pIncItem, SfxInt32Item, DSID_CONN_DATAINC, sal_True); + SFX_ITEMSET_GET(_rSet, pCacheItem, SfxInt32Item, DSID_CONN_CACHESIZE, sal_True); + if ( bValid ) + { + m_aEDHostname.SetText(pHostName->GetValue()); + m_aEDHostname.ClearModifyFlag(); + m_CB_SHUTDB.Check( pShutItem->GetValue() ); + m_NF_DATA_INCREMENT.SetValue( pIncItem->GetValue() ); + m_NF_CACHE_SIZE.SetValue( pCacheItem->GetValue() ); + m_ET_CTRLUSERNAME.SetText(pCtrlUserItem->GetValue()); + m_ET_CTRLPASSWORD.SetText(pCtrlPwdItem->GetValue()); + m_CB_SHUTDB.Enable(m_ET_CTRLUSERNAME.GetText().Len() && m_ET_CTRLPASSWORD.GetText().Len()); + } + + OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue); + } + // ----------------------------------------------------------------------- + sal_Bool OAdabasDetailsPage::FillItemSet( SfxItemSet& _rSet ) + { + sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet); + + fillString(_rSet,&m_aEDHostname,DSID_CONN_HOSTNAME,bChangedSomething); + fillBool(_rSet,&m_CB_SHUTDB,DSID_CONN_SHUTSERVICE,bChangedSomething); + fillInt32(_rSet,&m_NF_DATA_INCREMENT,DSID_CONN_DATAINC,bChangedSomething ); + fillInt32(_rSet,&m_NF_CACHE_SIZE,DSID_CONN_CACHESIZE,bChangedSomething ); + fillString(_rSet,&m_ET_CTRLUSERNAME,DSID_CONN_CTRLUSER,bChangedSomething ); + fillString(_rSet,&m_ET_CTRLPASSWORD,DSID_CONN_CTRLPWD,bChangedSomething ); + + return bChangedSomething; + } + //------------------------------------------------------------------------ + IMPL_LINK( OAdabasDetailsPage, AttributesChangedHdl, void *, EMPTYARG ) + { + m_CB_SHUTDB.Enable(m_ET_CTRLUSERNAME.GetText().Len() && m_ET_CTRLPASSWORD.GetText().Len()); + bAttrsChanged = TRUE; + callModifiedHdl(); + return 0; + } + //------------------------------------------------------------------------ + IMPL_LINK( OAdabasDetailsPage, LoseFocusHdl, Edit *, /*pEdit*/ ) + { + m_CB_SHUTDB.Enable(m_ET_CTRLUSERNAME.GetText().Len() && m_ET_CTRLPASSWORD.GetText().Len()); + return 0; + } + //------------------------------------------------------------------------ + IMPL_LINK( OAdabasDetailsPage, PBClickHdl, Button *, /*pButton*/ ) + { + OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF"); + if ( m_pAdminDialog ) + { + m_pAdminDialog->saveDatasource(); + try + { + Reference< XConnection > xConnection = m_pAdminDialog->createConnection().first; + if ( xConnection.is() ) + { + OAdabasStatistics aDlg(this,m_sUser,xConnection,m_pAdminDialog->getORB()); + aDlg.Execute(); + ::comphelper::disposeComponent(xConnection); + } + } + catch(Exception&) + { + } + } + + return 0; + } + + + //======================================================================== + //= OLDAPDetailsPage + //======================================================================== + OLDAPDetailsPage::OLDAPDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs ) + :OCommonBehaviourTabPage(pParent, PAGE_LDAP, _rCoreAttrs,0,false) + ,m_aFL_1 (this, ModuleRes( FL_SEPARATOR1) ) + ,m_aBaseDN (this, ModuleRes(FT_BASEDN)) + ,m_aETBaseDN (this, ModuleRes(ET_BASEDN)) + ,m_aCBUseSSL (this, ModuleRes(CB_USESSL)) + ,m_aPortNumber (this, ModuleRes(FT_PORTNUMBER)) + ,m_aNFPortNumber (this, ModuleRes(NF_PORTNUMBER)) + ,m_aFTRowCount (this, ModuleRes(FT_LDAPROWCOUNT)) + ,m_aNFRowCount (this, ModuleRes(NF_LDAPROWCOUNT)) + { + m_aETBaseDN.SetModifyHdl(getControlModifiedLink()); + m_aCBUseSSL.SetToggleHdl(getControlModifiedLink()); + m_aNFPortNumber.SetModifyHdl(getControlModifiedLink()); + m_aNFRowCount.SetModifyHdl(getControlModifiedLink()); + + m_aNFRowCount.SetUseThousandSep(sal_False); + m_iNormalPort = 389; + m_iSSLPort = 636; + m_aCBUseSSL.SetClickHdl(LINK(this, OLDAPDetailsPage,OnCheckBoxClick)); + FreeResource(); + } + + // ----------------------------------------------------------------------- + SfxTabPage* ODriversSettings::CreateLDAP( Window* pParent, const SfxItemSet& _rAttrSet ) + { + return ( new OLDAPDetailsPage( pParent, _rAttrSet ) ); + } + + // ----------------------------------------------------------------------- + sal_Bool OLDAPDetailsPage::FillItemSet( SfxItemSet& _rSet ) + { + sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet); + + fillString(_rSet,&m_aETBaseDN,DSID_CONN_LDAP_BASEDN,bChangedSomething); + fillInt32(_rSet,&m_aNFPortNumber,DSID_CONN_LDAP_PORTNUMBER,bChangedSomething); + fillInt32(_rSet,&m_aNFRowCount,DSID_CONN_LDAP_ROWCOUNT,bChangedSomething); + fillBool(_rSet,&m_aCBUseSSL,DSID_CONN_LDAP_USESSL,bChangedSomething); + return bChangedSomething; + } + //------------------------------------------------------------------------ + IMPL_LINK( OLDAPDetailsPage, OnCheckBoxClick, CheckBox*, pCheckBox ) + { + callModifiedHdl(); + if ( pCheckBox == &m_aCBUseSSL) + { + if ( m_aCBUseSSL.IsChecked() ) + { + m_iNormalPort = static_cast<sal_Int32>(m_aNFPortNumber.GetValue()); + m_aNFPortNumber.SetValue(m_iSSLPort); + } + else + { + m_iSSLPort = static_cast<sal_Int32>(m_aNFPortNumber.GetValue()); + m_aNFPortNumber.SetValue(m_iNormalPort); + } + } + return 0; + } + + // ----------------------------------------------------------------------- + void OLDAPDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) + { + OCommonBehaviourTabPage::fillControls(_rControlList); + _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETBaseDN)); + _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aCBUseSSL)); + _rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_aNFPortNumber)); + _rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_aNFRowCount)); + } + // ----------------------------------------------------------------------- + void OLDAPDetailsPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) + { + OCommonBehaviourTabPage::fillWindows(_rControlList); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aBaseDN)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aPortNumber)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTRowCount)); + _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL_1)); + } + // ----------------------------------------------------------------------- + void OLDAPDetailsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) + { + // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) + sal_Bool bValid, bReadonly; + getFlags(_rSet, bValid, bReadonly); + + + SFX_ITEMSET_GET(_rSet, pBaseDN, SfxStringItem, DSID_CONN_LDAP_BASEDN, sal_True); + SFX_ITEMSET_GET(_rSet, pUseSSL, SfxBoolItem, DSID_CONN_LDAP_USESSL, sal_True); + SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, DSID_CONN_LDAP_PORTNUMBER, sal_True); + SFX_ITEMSET_GET(_rSet, pRowCount, SfxInt32Item, DSID_CONN_LDAP_ROWCOUNT, sal_True); + + if ( bValid ) + { + m_aETBaseDN.SetText(pBaseDN->GetValue()); + m_aNFPortNumber.SetValue(pPortNumber->GetValue()); + m_aNFRowCount.SetValue(pRowCount->GetValue()); + m_aCBUseSSL.Check(pUseSSL->GetValue()); + } + + OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue); + } + + + //======================================================================== + //= OTextDetailsPage + //======================================================================== + DBG_NAME(OTextDetailsPage) + //------------------------------------------------------------------------ + OTextDetailsPage::OTextDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs ) + :OCommonBehaviourTabPage(pParent, PAGE_TEXT, _rCoreAttrs, 0, false ) + { + DBG_CTOR(OTextDetailsPage,NULL); + + m_pTextConnectionHelper = new OTextConnectionHelper( this, TC_EXTENSION | TC_HEADER | TC_SEPARATORS | TC_CHARSET ); + FreeResource(); + } + + // ----------------------------------------------------------------------- + OTextDetailsPage::~OTextDetailsPage() + { + DELETEZ(m_pTextConnectionHelper); + + DBG_DTOR(OTextDetailsPage,NULL); + } + + // ----------------------------------------------------------------------- + SfxTabPage* ODriversSettings::CreateText( Window* pParent, const SfxItemSet& _rAttrSet ) + { + return ( new OTextDetailsPage( pParent, _rAttrSet ) ); + } + // ----------------------------------------------------------------------- + void OTextDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) + { + OCommonBehaviourTabPage::fillControls(_rControlList); + m_pTextConnectionHelper->fillControls(_rControlList); + + } + // ----------------------------------------------------------------------- + void OTextDetailsPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) + { + OCommonBehaviourTabPage::fillWindows(_rControlList); + m_pTextConnectionHelper->fillWindows(_rControlList); + + } + // ----------------------------------------------------------------------- + void OTextDetailsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) + { + // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) + sal_Bool bValid, bReadonly; + getFlags(_rSet, bValid, bReadonly); + + m_pTextConnectionHelper->implInitControls(_rSet, bValid); + OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue); + } + + // ----------------------------------------------------------------------- + sal_Bool OTextDetailsPage::FillItemSet( SfxItemSet& rSet ) + { + sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(rSet); + bChangedSomething = m_pTextConnectionHelper->FillItemSet(rSet, bChangedSomething); + return bChangedSomething; + } + + // ----------------------------------------------------------------------- + sal_Bool OTextDetailsPage::prepareLeave() + { + return m_pTextConnectionHelper->prepareLeave(); + } + + //------------------------------------------------------------------------ + SfxTabPage* ODriversSettings::CreateGeneratedValuesPage( Window* _pParent, const SfxItemSet& _rAttrSet ) + { + return new GeneratedValuesPage( _pParent, _rAttrSet ); + } + + //------------------------------------------------------------------------ + SfxTabPage* ODriversSettings::CreateSpecialSettingsPage( Window* _pParent, const SfxItemSet& _rAttrSet ) + { + ::rtl::OUString eType = ODbDataSourceAdministrationHelper::getDatasourceType( _rAttrSet ); + DataSourceMetaData aMetaData( eType ); + return new SpecialSettingsPage( _pParent, _rAttrSet, aMetaData ); + } +//......................................................................... +} // namespace dbaui +//......................................................................... diff --git a/dbaccess/source/ui/dlg/detailpages.hxx b/dbaccess/source/ui/dlg/detailpages.hxx new file mode 100644 index 000000000000..e93fa9b201c4 --- /dev/null +++ b/dbaccess/source/ui/dlg/detailpages.hxx @@ -0,0 +1,388 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBAUI_DETAILPAGES_HXX_ +#define _DBAUI_DETAILPAGES_HXX_ + +#ifndef _DBAUI_ADMINPAGES_HXX_ +#include "adminpages.hxx" +#endif +#ifndef _DBAUI_CHARSETS_HXX_ +#include "charsets.hxx" +#endif +#ifndef CHARSETLISTBOX_HXX +#include "charsetlistbox.hxx" +#endif +#ifndef _SV_FIELD_HXX +#include <vcl/field.hxx> +#endif +#ifndef _SV_FIXED_HXX +#include <vcl/fixed.hxx> +#endif +#ifndef _SV_LSTBOX_HXX +#include <vcl/lstbox.hxx> +#endif +#ifndef _SV_EDIT_HXX +#include <vcl/edit.hxx> +#endif +#ifndef _SV_BUTTON_HXX +#include <vcl/button.hxx> +#endif +#ifndef DBAUI_TEXTCONNECTIONHELPER_HXX +#include "TextConnectionHelper.hxx" +#endif +#include "admincontrols.hxx" + +#include <svtools/dialogcontrolling.hxx> + + +//......................................................................... +namespace dbaui +{ +//......................................................................... + //========================================================================= + //= OCommonBehaviourTabPage + //========================================================================= + #define CBTP_NONE 0x00000000 + #define CBTP_USE_CHARSET 0x00000002 + #define CBTP_USE_OPTIONS 0x00000004 + + /** eases the implementation of tab pages handling user/password and/or character + set and/or generic options input + <BR> + The controls to be used habe to be defined within the resource, as usual, but + this class does all the handling necessary. + */ + class OCommonBehaviourTabPage : public OGenericAdministrationPage + { + protected: + + FixedText* m_pOptionsLabel; + Edit* m_pOptions; + + FixedLine* m_pDataConvertFixedLine; + FixedText* m_pCharsetLabel; + CharSetListBox* m_pCharset; + + FixedLine* m_pAutoFixedLine; + CheckBox* m_pAutoRetrievingEnabled; + FixedText* m_pAutoIncrementLabel; + Edit* m_pAutoIncrement; + FixedText* m_pAutoRetrievingLabel; + Edit* m_pAutoRetrieving; + + sal_uInt32 m_nControlFlags; + + public: + virtual BOOL FillItemSet (SfxItemSet& _rCoreAttrs); + + OCommonBehaviourTabPage(Window* pParent, USHORT nResId, const SfxItemSet& _rCoreAttrs, sal_uInt32 nControlFlags,bool _bFreeResource = true); + protected: + + // nControlFlags ist eine Kombination der CBTP_xxx-Konstanten + virtual ~OCommonBehaviourTabPage(); + + // must be overloaded by subclasses, but it isn't pure virtual + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + + // <method>OGenericAdministrationPage::fillControls</method> + virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList); + + // <method>OGenericAdministrationPage::fillWindows</method> + virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList); + }; + + //======================================================================== + //= ODbaseDetailsPage + //======================================================================== + class ODbaseDetailsPage : public OCommonBehaviourTabPage + { + public: + virtual BOOL FillItemSet ( SfxItemSet& _rCoreAttrs ); + + ODbaseDetailsPage(Window* pParent, const SfxItemSet& _rCoreAttrs); + private: + // please add new controls also to <method>fillControls</method> or <method>fillWindows</method> + CheckBox m_aShowDeleted; + FixedLine m_aFL_1; + FixedText m_aFT_Message; + PushButton m_aIndexes; + + String m_sDsn; + + protected: + + virtual ~ODbaseDetailsPage(); + + protected: + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList); + virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList); + + private: + DECL_LINK( OnButtonClicked, Button * ); + }; + + //======================================================================== + //= OAdoDetailsPage + //======================================================================== + class OAdoDetailsPage : public OCommonBehaviourTabPage + { + protected: + virtual ~OAdoDetailsPage(); + public: + + OAdoDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs ); + }; + + //======================================================================== + //= OOdbcDetailsPage + //======================================================================== + class OOdbcDetailsPage : public OCommonBehaviourTabPage + { + public: + virtual BOOL FillItemSet ( SfxItemSet& _rCoreAttrs ); + + OOdbcDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs ); + protected: + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList); + virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList); + private: + FixedLine m_aFL_1; + CheckBox m_aUseCatalog; + }; + + + //======================================================================== + //= OUserDriverDetailsPage + //======================================================================== + class OUserDriverDetailsPage : public OCommonBehaviourTabPage + { + public: + virtual BOOL FillItemSet ( SfxItemSet& _rCoreAttrs ); + + OUserDriverDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs ); + protected: + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList); + virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList); + private: + FixedText m_aFTHostname; + Edit m_aEDHostname; + FixedText m_aPortNumber; + NumericField m_aNFPortNumber; + CheckBox m_aUseCatalog; + }; + + //======================================================================== + //= OMySQLODBCDetailsPage + //======================================================================== + class OMySQLODBCDetailsPage : public OCommonBehaviourTabPage + { + public: + OMySQLODBCDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs ); + }; + + //======================================================================== + //= OGeneralSpecialJDBCDetailsPage + //======================================================================== + class OGeneralSpecialJDBCDetailsPage : public OCommonBehaviourTabPage + { + public: + OGeneralSpecialJDBCDetailsPage( Window* pParent + , USHORT _nResId + , const SfxItemSet& _rCoreAttrs + , USHORT _nPortId + ); + + protected: + + + virtual BOOL FillItemSet( SfxItemSet& _rCoreAttrs ); + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList); + virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList); + + DECL_LINK(OnTestJavaClickHdl,PushButton*); + DECL_LINK(OnEditModified,Edit*); + + FixedLine m_aFL_1; + FixedText m_aFTHostname; + Edit m_aEDHostname; + FixedText m_aPortNumber; + NumericField m_aNFPortNumber; + FixedText m_aFTSocket; + Edit m_aEDSocket; + + FixedText m_aFTDriverClass; + Edit m_aEDDriverClass; + PushButton m_aTestJavaDriver; + + String m_sDefaultJdbcDriverName; + USHORT m_nPortId; + bool m_bUseClass; + }; + + //======================================================================== + //= MySQLNativePage + //======================================================================== + class MySQLNativePage : public OCommonBehaviourTabPage + { + public: + MySQLNativePage( Window* pParent, + const SfxItemSet& _rCoreAttrs ); + + private: + FixedLine m_aSeparator1; + MySQLNativeSettings m_aMySQLSettings; + + FixedLine m_aSeparator2; + FixedText m_aUserNameLabel; + Edit m_aUserName; + CheckBox m_aPasswordRequired; + + protected: + virtual BOOL FillItemSet( SfxItemSet& _rCoreAttrs ); + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList); + virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList); + }; + + //======================================================================== + //= OAdabasDetailsPage + //======================================================================== + class OAdabasDetailsPage : public OCommonBehaviourTabPage + { + public: + virtual BOOL FillItemSet (SfxItemSet& _rCoreAttrs); + + OAdabasDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs ); + protected: + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList); + virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList); + + private: + FixedText m_aFTHostname; + Edit m_aEDHostname; + FixedLine m_aFL_1; + FixedText m_FT_CACHE_SIZE; + NumericField m_NF_CACHE_SIZE; + + FixedText m_FT_DATA_INCREMENT; + NumericField m_NF_DATA_INCREMENT; + + FixedLine m_aFL_2; + FixedText m_FT_CTRLUSERNAME; + Edit m_ET_CTRLUSERNAME; + FixedText m_FT_CTRLPASSWORD; + Edit m_ET_CTRLPASSWORD; + + CheckBox m_CB_SHUTDB; + PushButton m_PB_STAT; + String m_sUser; + BOOL bAttrsChanged; + + DECL_LINK( AttributesChangedHdl, void * ); + DECL_LINK( UserSettingsHdl, void * ); + DECL_LINK( LoseFocusHdl, Edit * ); + DECL_LINK( PBClickHdl, Button *); + }; + + //======================================================================== + //= OOdbcDetailsPage + //======================================================================== + class OLDAPDetailsPage : public OCommonBehaviourTabPage + { + public: + virtual BOOL FillItemSet ( SfxItemSet& _rCoreAttrs ); + + OLDAPDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs ); + protected: + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList); + virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList); + private: + FixedLine m_aFL_1; + FixedText m_aBaseDN; + Edit m_aETBaseDN; + CheckBox m_aCBUseSSL; + FixedText m_aPortNumber; + NumericField m_aNFPortNumber; + FixedText m_aFTRowCount; + NumericField m_aNFRowCount; + + sal_Int32 m_iSSLPort; + sal_Int32 m_iNormalPort; + DECL_LINK( OnCheckBoxClick, CheckBox * ); + }; + + //======================================================================== + //= OMozillaDetailsPage Detail page for Mozilla and Thunderbird addressbook + //======================================================================== + class OMozillaDetailsPage : public OCommonBehaviourTabPage + { + protected: + virtual ~OMozillaDetailsPage(); + public: + + OMozillaDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs ); + }; + + //======================================================================== + //= OTextDetailsPage + //======================================================================== + class OTextDetailsPage : public OCommonBehaviourTabPage + { + public: + virtual BOOL FillItemSet ( SfxItemSet& _rCoreAttrs ); + + OTextDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs ); + OTextConnectionHelper* m_pTextConnectionHelper; + + private: + + String m_aFieldSeparatorList; + String m_aTextSeparatorList; + String m_aTextNone; + protected: + virtual ~OTextDetailsPage(); + virtual sal_Bool prepareLeave(); + + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList); + virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList); + + private: + }; + +//......................................................................... +} // namespace dbaui +//......................................................................... + +#endif // _DBAUI_DETAILPAGES_HXX_ diff --git a/dbaccess/source/ui/dlg/directsql.cxx b/dbaccess/source/ui/dlg/directsql.cxx new file mode 100644 index 000000000000..9465cfa58fed --- /dev/null +++ b/dbaccess/source/ui/dlg/directsql.cxx @@ -0,0 +1,367 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#ifndef _DBACCESS_UI_DIRECTSQL_HXX_ +#include "directsql.hxx" +#endif +#ifndef _DBACCESS_UI_DIRECTSQL_HRC_ +#include "directsql.hrc" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif +#ifndef _COMPHELPER_TYPES_HXX_ +#include <comphelper/types.hxx> +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif +#ifndef _SV_SVAPP_HXX +#include <vcl/svapp.hxx> +#endif +#ifndef _VOS_MUTEX_HXX_ +#include <vos/mutex.hxx> +#endif +#ifndef TOOLS_DIAGNOSE_EX_H +#include <tools/diagnose_ex.h> +#endif + +//........................................................................ +namespace dbaui +{ +//........................................................................ + + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::sdbc; + using namespace ::com::sun::star::lang; + + //==================================================================== + //= LargeEntryListBox + //==================================================================== + class LargeEntryListBox : public ListBox + { + public: + LargeEntryListBox( Window* _pParent, const ResId& _rId ); + + protected: + virtual void UserDraw( const UserDrawEvent& rUDEvt ); + }; + + //-------------------------------------------------------------------- + LargeEntryListBox::LargeEntryListBox( Window* _pParent, const ResId& _rId ) + :ListBox(_pParent, _rId ) + { + EnableUserDraw(sal_True); + } + + //-------------------------------------------------------------------- + void LargeEntryListBox::UserDraw( const UserDrawEvent& _rUDEvt ) + { + if (LISTBOX_ENTRY_NOTFOUND == _rUDEvt.GetItemId()) + ListBox::UserDraw( _rUDEvt ); + else + _rUDEvt.GetDevice()->DrawText( _rUDEvt.GetRect(), GetEntry( _rUDEvt.GetItemId() ), TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER | TEXT_DRAW_ENDELLIPSIS); + } + + //==================================================================== + //= DirectSQLDialog + //==================================================================== +DBG_NAME(DirectSQLDialog) +//-------------------------------------------------------------------- + DirectSQLDialog::DirectSQLDialog( Window* _pParent, const Reference< XConnection >& _rxConn ) + :ModalDialog(_pParent, ModuleRes(DLG_DIRECTSQL)) + ,m_aFrame (this, ModuleRes(FL_SQL)) + ,m_aSQLLabel (this, ModuleRes(FT_SQL)) + ,m_aSQL (this, ModuleRes(ME_SQL)) + ,m_aExecute (this, ModuleRes(PB_EXECUTE)) + ,m_aHistoryLabel (this, ModuleRes(FT_HISTORY)) + ,m_pSQLHistory(new LargeEntryListBox(this, ModuleRes(LB_HISTORY))) + ,m_aStatusFrame (this, ModuleRes(FL_STATUS)) + ,m_aStatus (this, ModuleRes(ME_STATUS)) + ,m_aButtonSeparator (this, ModuleRes(FL_BUTTONS)) + ,m_aHelp (this, ModuleRes(PB_HELP)) + ,m_aClose (this, ModuleRes(PB_CLOSE)) + ,m_nHistoryLimit(20) + ,m_nStatusCount(1) + ,m_xConnection(_rxConn) + { + DBG_CTOR(DirectSQLDialog,NULL); + + FreeResource(); + + m_aSQL.GrabFocus(); + + m_aExecute.SetClickHdl(LINK(this, DirectSQLDialog, OnExecute)); + m_aClose.SetClickHdl(LINK(this, DirectSQLDialog, OnClose)); + m_pSQLHistory->SetSelectHdl(LINK(this, DirectSQLDialog, OnListEntrySelected)); + m_pSQLHistory->SetDropDownLineCount(10); + + // add a dispose listener to the connection + Reference< XComponent > xConnComp(m_xConnection, UNO_QUERY); + OSL_ENSURE(xConnComp.is(), "DirectSQLDialog::DirectSQLDialog: invalid connection!"); + if (xConnComp.is()) + startComponentListening(xConnComp); + + m_aSQL.SetModifyHdl(LINK(this, DirectSQLDialog, OnStatementModified)); + OnStatementModified(&m_aSQL); + } + + //-------------------------------------------------------------------- + DirectSQLDialog::~DirectSQLDialog() + { + { + ::osl::MutexGuard aGuard(m_aMutex); + stopAllComponentListening(); + } + delete m_pSQLHistory; + + DBG_DTOR(DirectSQLDialog,NULL); + } + + //-------------------------------------------------------------------- + void DirectSQLDialog::_disposing( const EventObject& _rSource ) + { + ::vos::OGuard aSolarGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard(m_aMutex); + + OSL_ENSURE(Reference< XConnection >(_rSource.Source, UNO_QUERY).get() == m_xConnection.get(), + "DirectSQLDialog::_disposing: where does this come from?"); + (void)_rSource; + + { + String sMessage(ModuleRes(STR_DIRECTSQL_CONNECTIONLOST)); + ErrorBox aError(this, WB_OK, sMessage); + aError.Execute(); + } + + PostUserEvent(LINK(this, DirectSQLDialog, OnClose)); + } + + //-------------------------------------------------------------------- + sal_Int32 DirectSQLDialog::getHistorySize() const + { + CHECK_INVARIANTS("DirectSQLDialog::getHistorySize"); + return m_aStatementHistory.size(); + } + + //-------------------------------------------------------------------- + void DirectSQLDialog::implEnsureHistoryLimit() + { + CHECK_INVARIANTS("DirectSQLDialog::implEnsureHistoryLimit"); + + if (getHistorySize() <= m_nHistoryLimit) + // nothing to do + return; + + sal_Int32 nRemoveEntries = getHistorySize() - m_nHistoryLimit; + while (nRemoveEntries--) + { + m_aStatementHistory.pop_front(); + m_aNormalizedHistory.pop_front(); + m_pSQLHistory->RemoveEntry((USHORT)0); + } + } + + //-------------------------------------------------------------------- + void DirectSQLDialog::implAddToStatementHistory(const String& _rStatement) + { + CHECK_INVARIANTS("DirectSQLDialog::implAddToStatementHistory"); + + // add the statement to the history + m_aStatementHistory.push_back(_rStatement); + + // normalize the statement, and remember the normalized form, too + String sNormalized(_rStatement); + sNormalized.SearchAndReplaceAll((sal_Unicode)'\n', ' '); + m_aNormalizedHistory.push_back(sNormalized); + + // add the normalized version to the list box + m_pSQLHistory->InsertEntry(sNormalized); + + // ensure that we don't exceed the history limit + implEnsureHistoryLimit(); + } + +#ifdef DBG_UTIL + //-------------------------------------------------------------------- + const sal_Char* DirectSQLDialog::impl_CheckInvariants() const + { + if (m_aStatementHistory.size() != m_aNormalizedHistory.size()) + return "statement history is inconsistent!"; + + if (!m_pSQLHistory) + return "invalid listbox!"; + + if (m_aStatementHistory.size() != m_pSQLHistory->GetEntryCount()) + return "invalid listbox entry count!"; + + if (!m_xConnection.is()) + return "have no connection!"; + + return NULL; + } +#endif + + //-------------------------------------------------------------------- + void DirectSQLDialog::implExecuteStatement(const String& _rStatement) + { + CHECK_INVARIANTS("DirectSQLDialog::implExecuteStatement"); + + ::osl::MutexGuard aGuard(m_aMutex); + + String sStatus; + try + { + // create a statement + Reference< XStatement > xStatement = m_xConnection->createStatement(); + OSL_ENSURE(xStatement.is(), "DirectSQLDialog::implExecuteStatement: no statement returned by the connection!"); + + // execute it + if (xStatement.is()) + xStatement->execute(_rStatement); + + // successfull + sStatus = String(ModuleRes(STR_COMMAND_EXECUTED_SUCCESSFULLY)); + + // dispose the statement + ::comphelper::disposeComponent(xStatement); + } + catch(const SQLException& e) + { + sStatus = e.Message; + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + // add the status text + addStatusText(sStatus); + } + + //-------------------------------------------------------------------- + void DirectSQLDialog::addStatusText(const String& _rMessage) + { + String sAppendMessage = String::CreateFromInt32(m_nStatusCount++); + sAppendMessage += String::CreateFromAscii(": "); + sAppendMessage += _rMessage; + sAppendMessage += String::CreateFromAscii("\n\n"); + + String sCompleteMessage = m_aStatus.GetText(); + sCompleteMessage += sAppendMessage; + m_aStatus.SetText(sCompleteMessage); + + m_aStatus.SetSelection(Selection(sCompleteMessage.Len(), sCompleteMessage.Len())); + } + + //-------------------------------------------------------------------- + void DirectSQLDialog::executeCurrent() + { + CHECK_INVARIANTS("DirectSQLDialog::executeCurrent"); + + String sStatement = m_aSQL.GetText(); + + // execute + implExecuteStatement(sStatement); + + // add the statement to the history + implAddToStatementHistory(sStatement); + + m_aSQL.SetSelection(Selection()); + m_aSQL.GrabFocus(); + } + + //-------------------------------------------------------------------- + void DirectSQLDialog::switchToHistory(sal_Int32 _nHistoryPos, sal_Bool _bUpdateListBox) + { + CHECK_INVARIANTS("DirectSQLDialog::switchToHistory"); + + if ((_nHistoryPos >= 0) && (_nHistoryPos < getHistorySize())) + { + // set the text in the statement editor + String sStatement = m_aStatementHistory[_nHistoryPos]; + m_aSQL.SetText(sStatement); + OnStatementModified(&m_aSQL); + + if (_bUpdateListBox) + { + // selecte the normalized statement in the list box + m_pSQLHistory->SelectEntryPos((USHORT)_nHistoryPos); + OSL_ENSURE(m_pSQLHistory->GetSelectEntry() == m_aNormalizedHistory[_nHistoryPos], + "DirectSQLDialog::switchToHistory: inconsistent listbox entries!"); + } + + m_aSQL.GrabFocus(); + m_aSQL.SetSelection(Selection(sStatement.Len(), sStatement.Len())); + } + else + OSL_ENSURE(sal_False, "DirectSQLDialog::switchToHistory: invalid position!"); + } + + //-------------------------------------------------------------------- + IMPL_LINK( DirectSQLDialog, OnStatementModified, void*, /*NOTINTERESTEDIN*/ ) + { + m_aExecute.Enable(0 != m_aSQL.GetText().Len()); + return 0L; + } + + //-------------------------------------------------------------------- + IMPL_LINK( DirectSQLDialog, OnClose, void*, /*NOTINTERESTEDIN*/ ) + { + EndDialog( RET_OK ); + return 0L; + } + + //-------------------------------------------------------------------- + IMPL_LINK( DirectSQLDialog, OnExecute, void*, /*NOTINTERESTEDIN*/ ) + { + executeCurrent(); + return 0L; + } + + //-------------------------------------------------------------------- + IMPL_LINK( DirectSQLDialog, OnListEntrySelected, void*, /*NOTINTERESTEDIN*/ ) + { + if (!m_pSQLHistory->IsTravelSelect()) + { + const sal_uInt16 nSelected = m_pSQLHistory->GetSelectEntryPos(); + if (LISTBOX_ENTRY_NOTFOUND != nSelected) + switchToHistory(nSelected, sal_False); + } + return 0L; + } + +//........................................................................ +} // namespace dbaui +//........................................................................ + diff --git a/dbaccess/source/ui/dlg/directsql.hrc b/dbaccess/source/ui/dlg/directsql.hrc new file mode 100644 index 000000000000..23f19a350ab4 --- /dev/null +++ b/dbaccess/source/ui/dlg/directsql.hrc @@ -0,0 +1,43 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBACCESS_UI_DIRECTSQL_HRC_ +#define _DBACCESS_UI_DIRECTSQL_HRC_ + +#define FL_SQL 1 +#define FT_SQL 2 +#define ME_SQL 3 +#define PB_EXECUTE 4 +#define FT_HISTORY 5 +#define LB_HISTORY 6 +#define FL_STATUS 7 +#define ME_STATUS 8 +#define FL_BUTTONS 9 +#define PB_HELP 10 +#define PB_CLOSE 11 + +#endif // _DBACCESS_UI_DIRECTSQL_HRC_ diff --git a/dbaccess/source/ui/dlg/directsql.src b/dbaccess/source/ui/dlg/directsql.src new file mode 100644 index 000000000000..230fe4dac320 --- /dev/null +++ b/dbaccess/source/ui/dlg/directsql.src @@ -0,0 +1,134 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBACCESS_UI_DIRECTSQL_HRC_ +#include "directsql.hrc" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif + +#define BUTTON_SIZE_X 50 +#define BUTTON_SIZE_Y 14 + +#define WINDOW_SIZE_X 200 +#define WINDOW_SIZE_Y 210 + BUTTON_SIZE_Y + BUTTON_SIZE_Y + +ModalDialog DLG_DIRECTSQL +{ + OutputSize = TRUE ; + Moveable = TRUE ; + Closeable = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ; + + FixedLine FL_SQL + { + Pos = MAP_APPFONT( 4, 3 ); + Size = MAP_APPFONT( WINDOW_SIZE_X - 8, 8 ); + Text [ en-US ] = "SQL command"; + }; + FixedText FT_SQL + { + Pos = MAP_APPFONT( 7, 15 ); + Size = MAP_APPFONT( WINDOW_SIZE_X - 14, 8 ); + Text [ en-US ] = "Command to execute"; + }; + MultiLineEdit ME_SQL + { + Pos = MAP_APPFONT( 7, 26 ); + Size = MAP_APPFONT( WINDOW_SIZE_X - 14, 80 ); + SVLook = TRUE; + Border = TRUE; + TabStop = TRUE; + IgnoreTab = TRUE; + }; + PushButton PB_EXECUTE + { + Pos = MAP_APPFONT( WINDOW_SIZE_X - BUTTON_SIZE_X - 7, 109 ); + 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 ); + Size = MAP_APPFONT( WINDOW_SIZE_X - 14, 8 ); + Text [ en-US ] = "Previous commands"; + }; + ListBox LB_HISTORY + { + Pos = MAP_APPFONT( 7, 121 + BUTTON_SIZE_Y + 3 ); + Size = MAP_APPFONT( WINDOW_SIZE_X - 14, 14 ); + SvLook = TRUE; + DropDown = TRUE; + Border = TRUE; + }; + FixedLine FL_STATUS + { + Pos = MAP_APPFONT( 4, 138 + BUTTON_SIZE_Y + 4 ); + Size = MAP_APPFONT( WINDOW_SIZE_X - 8, 8 ); + Text [ en-US ] = "Status"; + }; + MultiLineEdit ME_STATUS + { + Pos = MAP_APPFONT( 7, 153 + BUTTON_SIZE_Y ); + Size = MAP_APPFONT( WINDOW_SIZE_X - 14, 41 ); + Border = TRUE; + ReadOnly = TRUE; + VScroll = TRUE; + }; + FixedLine FL_BUTTONS + { + Pos = MAP_APPFONT( 4, 193 + 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 ); + Size = MAP_APPFONT( BUTTON_SIZE_X, BUTTON_SIZE_Y ); + }; + PushButton PB_CLOSE + { + Pos = MAP_APPFONT( WINDOW_SIZE_X - 7 - BUTTON_SIZE_X, 207 + BUTTON_SIZE_Y ); + Size = MAP_APPFONT( BUTTON_SIZE_X, BUTTON_SIZE_Y ); + Text [ en-US ] = "Close"; + }; + + Text [ en-US ] = "Execute SQL Statement" ; +}; + +String STR_COMMAND_EXECUTED_SUCCESSFULLY +{ + Text [ en-US ] = "Command successfully executed." ; +}; + +String STR_DIRECTSQL_CONNECTIONLOST +{ + Text [ en-US ] = "The connection to the database has been lost. This dialog will be closed."; +}; + diff --git a/dbaccess/source/ui/dlg/dlgattr.cxx b/dbaccess/source/ui/dlg/dlgattr.cxx new file mode 100644 index 000000000000..0608997ef0c1 --- /dev/null +++ b/dbaccess/source/ui/dlg/dlgattr.cxx @@ -0,0 +1,148 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + + +#ifndef DBAUI_SBATTRDLG_HXX +#include "dlgattr.hxx" +#endif + +#ifndef _SFXTABDLG_HXX //autogen +#include <sfx2/tabdlg.hxx> +#endif + +#ifndef _SVX_NUMINF_HXX //autogen +#include <svx/numinf.hxx> +#endif + +//CHINA001 #ifndef _SVX_CHARDLG_HXX //autogen +//CHINA001 #include <svx/chardlg.hxx> +//CHINA001 #endif + +//CHINA001 #ifndef _SVX_NUMFMT_HXX //autogen +//CHINA001 #include <svx/numfmt.hxx> +//CHINA001 #endif +#ifndef _SVX_NUMINF_HXX +#include <svx/numinf.hxx> +#endif + +//CHINA001 #ifndef _SVX_ALIGN_HXX //autogen +//CHINA001 #include <svx/align.hxx> +//CHINA001 #endif + +#ifndef _SVX_DIALOGS_HRC +#include <svx/dialogs.hrc> +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef _SFXITEMSET_HXX +#include <svl/itemset.hxx> +#endif +#define _ZFORLIST_DECLARE_TABLE +#ifndef _ZFORLIST_HXX +#include <svl/zforlist.hxx> +#endif +#include <svx/svxids.hrc> //CHINA001 +#include <svx/flagsdef.hxx> //CHINA001 +#ifndef _SFXINTITEM_HXX //CHINA001 +#include <svl/intitem.hxx> //CHINA001 +#endif //CHINA001 +#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "moduledbu.hxx" +#endif +using namespace dbaui; + +DBG_NAME(SbaSbAttrDlg) +//================================================================== +SbaSbAttrDlg::SbaSbAttrDlg(Window* pParent, const SfxItemSet* pCellAttrs, SvNumberFormatter* pFormatter, USHORT nFlags, BOOL bRow) + : SfxTabDialog(pParent, ModuleRes( DLG_ATTR ), pCellAttrs ) + ,aTitle(ModuleRes(ST_ROW)) +{ + DBG_CTOR(SbaSbAttrDlg,NULL); + + pNumberInfoItem = new SvxNumberInfoItem( pFormatter, 0 ); + + if (bRow) + SetText(aTitle); + if( nFlags & TP_ATTR_CHAR ) + { +// AddTabPage( RID_SVXPAGE_CHAR_STD,String(ModuleRes(TP_ATTR_CHAR)),SvxCharStdPage::Create, 0 ); + DBG_ERROR( "found flag TP_ATTR_CHAR" ); + } + if( nFlags & TP_ATTR_NUMBER ) + AddTabPage( RID_SVXPAGE_NUMBERFORMAT,String(ModuleRes(TP_ATTR_NUMBER)) ); //CHINA001 AddTabPage( RID_SVXPAGE_NUMBERFORMAT,String(ModuleRes(TP_ATTR_NUMBER)),SvxNumberFormatTabPage::Create, 0 ); + if( nFlags & TP_ATTR_ALIGN ) + AddTabPage( RID_SVXPAGE_ALIGNMENT,String(ModuleRes(TP_ATTR_ALIGN)) );//CHINA001 AddTabPage( RID_SVXPAGE_ALIGNMENT,String(ModuleRes(TP_ATTR_ALIGN)),SvxAlignmentTabPage::Create, 0 ); + FreeResource(); +} + +// ----------------------------------------------------------------------- +SbaSbAttrDlg::~SbaSbAttrDlg() +{ + delete pNumberInfoItem; + + DBG_DTOR(SbaSbAttrDlg,NULL); +} + +// ----------------------------------------------------------------------- +void SbaSbAttrDlg::PageCreated( sal_uInt16 nPageId, SfxTabPage& rTabPage ) +{ + SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool())); + switch ( nPageId ) + { + case RID_SVXPAGE_NUMBERFORMAT: + { + //CHINA001 ((SvxNumberFormatTabPage&)rTabPage). + //CHINA001 SetNumberFormatList( *pNumberInfoItem ); + aSet.Put (SvxNumberInfoItem( pNumberInfoItem->GetNumberFormatter(), (const USHORT)SID_ATTR_NUMBERFORMAT_INFO)); + rTabPage.PageCreated(aSet); + } + break; + + case RID_SVXPAGE_CHAR_STD: + { + // ((SvxCharStdPage&)rTabPage).SetFontList(SBA_MOD_EXT()->FontListItem()); + } + break; + + case RID_SVXPAGE_ALIGNMENT: + { + //CHINA001 ((SvxAlignmentTabPage&)rTabPage).SetFlags(WBA_NO_ORIENTATION|WBA_NO_LINEBREAK|WBA_NO_GRIDLINES|WBA_NO_VERTICAL|WBA_NO_LEFTINDENT); +// aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, WBA_NO_ORIENTATION|WBA_NO_LINEBREAK|WBA_NO_GRIDLINES|WBA_NO_VERTICAL|WBA_NO_LEFTINDENT)); +// rTabPage.PageCreated(aSet); + } + break; + + default: + break; + } +} + + diff --git a/dbaccess/source/ui/dlg/dlgattr.src b/dbaccess/source/ui/dlg/dlgattr.src new file mode 100644 index 000000000000..8dce0835aa69 --- /dev/null +++ b/dbaccess/source/ui/dlg/dlgattr.src @@ -0,0 +1,122 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _SVX_DIALOGS_HRC +#include <svx/dialogs.hrc> +#endif +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef DBAUI_SBATTRDLG_HRC +#include "dlgattr.hrc" +#endif + //================================================ + // Der Attributdialog: +TabDialog DLG_ATTR +{ + Moveable = TRUE ; + Closeable = TRUE ; + OutputSize = TRUE ; + SVLook = TRUE ; + Text [ en-US ] = "Field Format" ; + TabControl 1 + { + OutputSize = TRUE ; + }; + OKButton 1 + { + Size = MAP_APPFONT ( 40 , 12 ) ; + TabStop = TRUE ; + DefButton = TRUE; + }; + CancelButton 1 + { + Size = MAP_APPFONT ( 40 , 12 ) ; + TabStop = TRUE ; + }; + HelpButton 1 + { + Size = MAP_APPFONT ( 40 , 12 ) ; + TabStop = TRUE ; + }; + PushButton 1 + { + TabStop = TRUE ; + Size = MAP_APPFONT ( 40 , 12 ) ; + Text [ en-US ] = "Bac~k" ; + }; + String TP_ATTR_CHAR + { + /* ### ACHTUNG: Neuer Text in Resource? Schrift : Zeichen */ + Text [ en-US ] = "Font" ; + }; + String TP_ATTR_NUMBER + { + Text [ en-US ] = "Format" ; + }; + String TP_ATTR_ALIGN + { + Text [ en-US ] = "Alignment" ; + }; + String ST_ROW + { + Text [ en-US ] = "Table Format" ; + }; +}; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dbaccess/source/ui/dlg/dlgsave.cxx b/dbaccess/source/ui/dlg/dlgsave.cxx new file mode 100644 index 000000000000..7a287829057d --- /dev/null +++ b/dbaccess/source/ui/dlg/dlgsave.cxx @@ -0,0 +1,486 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#ifndef DBAUI_DLGSAVE_HXX +#include "dlgsave.hxx" +#endif +#ifndef DBAUI_DLGSAVE_HRC +#include "dlgsave.hrc" +#endif +#ifndef _SV_MSGBOX_HXX //autogen +#include <vcl/msgbox.hxx> +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ +#include <com/sun/star/sdb/CommandType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _DBAUI_SQLMESSAGE_HXX_ +#include "sqlmessage.hxx" +#endif +#ifndef _CONNECTIVITY_DBTOOLS_HXX_ +#include <connectivity/dbtools.hxx> +#endif +#ifndef DBAUI_TOOLS_HXX +#include "UITools.hxx" +#endif +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif +#ifndef DBAUI_SQLNAMEEDIT_HXX +#include "SqlNameEdit.hxx" +#endif +#ifndef _BUTTON_HXX //autogen +#include <vcl/button.hxx> +#endif +#ifndef _FIXED_HXX //autogen +#include <vcl/fixed.hxx> +#endif +#ifndef _EDIT_HXX //autogen +#include <vcl/edit.hxx> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMEACCESS_HPP_ +#include <com/sun/star/container/XHierarchicalNameAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#endif +#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "moduledbu.hxx" +#endif +#ifndef DBACCESS_SOURCE_UI_INC_OBJECTNAMECHECK_HXX +#include "objectnamecheck.hxx" +#endif +#ifndef TOOLS_DIAGNOSE_EX_H +#include <tools/diagnose_ex.h> +#endif + + +using namespace dbaui; +using namespace dbtools; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::sdb; +using namespace ::com::sun::star::sdbc; +namespace dbaui +{ +class OSaveAsDlgImpl +{ +public: + FixedText m_aDescription; + FixedText m_aCatalogLbl; + OSQLNameComboBox m_aCatalog; + FixedText m_aSchemaLbl; + OSQLNameComboBox m_aSchema; + FixedText m_aLabel; + OSQLNameEdit m_aTitle; + OKButton m_aPB_OK; + CancelButton m_aPB_CANCEL; + HelpButton m_aPB_HELP; + String m_aQryLabel; + String m_sTblLabel; + rtl::OUString m_sCatalog; + rtl::OUString m_sSchema; + String m_aName; + const IObjectNameCheck& + m_rObjectNameCheck; + String m_sParentURL; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> m_xMetaData; + sal_Int32 m_nType; + sal_Int32 m_nFlags; + + OSaveAsDlgImpl( Window * pParent,const sal_Int32& _rType, + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection, + const String& rDefault, + const IObjectNameCheck& _rObjectNameCheck, + sal_Int32 _nFlags); + OSaveAsDlgImpl( Window * pParent, + const String& rDefault, + const IObjectNameCheck& _rObjectNameCheck, + sal_Int32 _nFlags); +}; +// ----------------------------------------------------------------------------- +} // dbaui +// ----------------------------------------------------------------------------- +OSaveAsDlgImpl::OSaveAsDlgImpl( Window * _pParent, + const sal_Int32& _rType, + const Reference< XConnection>& _xConnection, + const String& rDefault, + const IObjectNameCheck& _rObjectNameCheck, + sal_Int32 _nFlags) + :m_aDescription(_pParent, ModuleRes (FT_DESCRIPTION)) + ,m_aCatalogLbl(_pParent, ModuleRes (FT_CATALOG)) + ,m_aCatalog(_pParent, ModuleRes (ET_CATALOG), ::rtl::OUString()) + ,m_aSchemaLbl(_pParent, ModuleRes (FT_SCHEMA)) + ,m_aSchema(_pParent, ModuleRes (ET_SCHEMA), ::rtl::OUString()) + ,m_aLabel(_pParent, ModuleRes (FT_TITLE)) + ,m_aTitle(_pParent, ModuleRes (ET_TITLE), ::rtl::OUString()) + ,m_aPB_OK(_pParent, ModuleRes( PB_OK ) ) + ,m_aPB_CANCEL(_pParent, ModuleRes( PB_CANCEL )) + ,m_aPB_HELP(_pParent, ModuleRes( PB_HELP)) + ,m_aQryLabel(ModuleRes(STR_QRY_LABEL)) + ,m_sTblLabel(ModuleRes(STR_TBL_LABEL)) + ,m_aName(rDefault) + ,m_rObjectNameCheck( _rObjectNameCheck ) + ,m_nType(_rType) + ,m_nFlags(_nFlags) +{ + if ( _xConnection.is() ) + m_xMetaData = _xConnection->getMetaData(); + + if ( m_xMetaData.is() ) + { + ::rtl::OUString sExtraNameChars( m_xMetaData->getExtraNameCharacters() ); + m_aCatalog.setAllowedChars( sExtraNameChars ); + m_aSchema.setAllowedChars( sExtraNameChars ); + m_aTitle.setAllowedChars( sExtraNameChars ); + } + + m_aCatalog.SetDropDownLineCount( 10 ); + m_aSchema.SetDropDownLineCount( 10 ); +} +// ----------------------------------------------------------------------------- +OSaveAsDlgImpl::OSaveAsDlgImpl( Window * _pParent, + const String& rDefault, + const IObjectNameCheck& _rObjectNameCheck, + sal_Int32 _nFlags) + :m_aDescription(_pParent, ModuleRes (FT_DESCRIPTION)) + ,m_aCatalogLbl(_pParent, ModuleRes (FT_CATALOG)) + ,m_aCatalog(_pParent, ModuleRes (ET_CATALOG)) + ,m_aSchemaLbl(_pParent, ModuleRes (FT_SCHEMA)) + ,m_aSchema(_pParent, ModuleRes (ET_SCHEMA)) + ,m_aLabel(_pParent, ModuleRes (FT_TITLE)) + ,m_aTitle(_pParent, ModuleRes (ET_TITLE)) + ,m_aPB_OK(_pParent, ModuleRes( PB_OK ) ) + ,m_aPB_CANCEL(_pParent, ModuleRes( PB_CANCEL )) + ,m_aPB_HELP(_pParent, ModuleRes( PB_HELP)) + ,m_aQryLabel(ModuleRes(STR_QRY_LABEL)) + ,m_sTblLabel(ModuleRes(STR_TBL_LABEL)) + ,m_aName(rDefault) + ,m_rObjectNameCheck( _rObjectNameCheck ) + ,m_nType(CommandType::COMMAND) + ,m_nFlags(_nFlags) +{ + m_aCatalog.SetDropDownLineCount( 10 ); + m_aSchema.SetDropDownLineCount( 10 ); +} + +// ----------------------------------------------------------------------------- +using namespace ::com::sun::star::lang; + +//================================================================== +namespace +{ + typedef Reference< XResultSet > (SAL_CALL XDatabaseMetaData::*FGetMetaStrings)(); + + void lcl_fillComboList( ComboBox& _rList, const Reference< XConnection >& _rxConnection, + FGetMetaStrings _GetAll, const ::rtl::OUString& _rCurrent ) + { + try + { + Reference< XDatabaseMetaData > xMetaData( _rxConnection->getMetaData(), UNO_QUERY_THROW ); + + Reference< XResultSet > xRes = (xMetaData.get()->*_GetAll)(); + Reference< XRow > xRow( xRes, UNO_QUERY_THROW ); + ::rtl::OUString sValue; + while ( xRes->next() ) + { + sValue = xRow->getString( 1 ); + if ( !xRow->wasNull() ) + _rList.InsertEntry( sValue ); + } + + USHORT nPos = _rList.GetEntryPos( String( _rCurrent ) ); + if ( nPos != COMBOBOX_ENTRY_NOTFOUND ) + _rList.SelectEntryPos( nPos ); + else + _rList.SelectEntryPos( 0 ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } +} + +//================================================================== +OSaveAsDlg::OSaveAsDlg( Window * pParent, + const sal_Int32& _rType, + const Reference< XMultiServiceFactory >& _rxORB, + const Reference< XConnection>& _xConnection, + const String& rDefault, + const IObjectNameCheck& _rObjectNameCheck, + sal_Int32 _nFlags) + :ModalDialog( pParent, ModuleRes(DLG_SAVE_AS)) + ,m_xORB( _rxORB ) +{ + m_pImpl = new OSaveAsDlgImpl(this,_rType,_xConnection,rDefault,_rObjectNameCheck,_nFlags); + + switch (_rType) + { + case CommandType::QUERY: + implInitOnlyTitle(m_pImpl->m_aQryLabel); + break; + + case CommandType::TABLE: + OSL_ENSURE( m_pImpl->m_xMetaData.is(), "OSaveAsDlg::OSaveAsDlg: no meta data for entering table names: this will crash!" ); + { + m_pImpl->m_aLabel.SetText(m_pImpl->m_sTblLabel); + Point aPos(m_pImpl->m_aPB_OK.GetPosPixel()); + if(m_pImpl->m_xMetaData.is() && !m_pImpl->m_xMetaData->supportsCatalogsInTableDefinitions()) + { + m_pImpl->m_aCatalogLbl.Hide(); + m_pImpl->m_aCatalog.Hide(); + + aPos = m_pImpl->m_aLabel.GetPosPixel(); + + m_pImpl->m_aLabel.SetPosPixel(m_pImpl->m_aSchemaLbl.GetPosPixel()); + m_pImpl->m_aTitle.SetPosPixel(m_pImpl->m_aSchema.GetPosPixel()); + + m_pImpl->m_aSchemaLbl.SetPosPixel(m_pImpl->m_aCatalogLbl.GetPosPixel()); + m_pImpl->m_aSchema.SetPosPixel(m_pImpl->m_aCatalog.GetPosPixel()); + } + else + { + // now fill the catalogs + lcl_fillComboList( m_pImpl->m_aCatalog, _xConnection, + &XDatabaseMetaData::getCatalogs, _xConnection->getCatalog() ); + } + + if ( !m_pImpl->m_xMetaData->supportsSchemasInTableDefinitions()) + { + m_pImpl->m_aSchemaLbl.Hide(); + m_pImpl->m_aSchema.Hide(); + + aPos = m_pImpl->m_aLabel.GetPosPixel(); + + m_pImpl->m_aLabel.SetPosPixel(m_pImpl->m_aSchemaLbl.GetPosPixel()); + m_pImpl->m_aTitle.SetPosPixel(m_pImpl->m_aSchema.GetPosPixel()); + } + else + { + lcl_fillComboList( m_pImpl->m_aSchema, _xConnection, + &XDatabaseMetaData::getSchemas, m_pImpl->m_xMetaData->getUserName() ); + } + + OSL_ENSURE(m_pImpl->m_xMetaData.is(),"The metadata can not be null!"); + if(m_pImpl->m_aName.Search('.') != STRING_NOTFOUND) + { + ::rtl::OUString sCatalog,sSchema,sTable; + ::dbtools::qualifiedNameComponents(m_pImpl->m_xMetaData, + m_pImpl->m_aName, + sCatalog, + sSchema, + sTable, + ::dbtools::eInDataManipulation); + + USHORT nPos = m_pImpl->m_aCatalog.GetEntryPos(String(sCatalog)); + if ( nPos != COMBOBOX_ENTRY_NOTFOUND ) + m_pImpl->m_aCatalog.SelectEntryPos(nPos); + + if ( sSchema.getLength() ) + { + nPos = m_pImpl->m_aSchema.GetEntryPos(String(sSchema)); + if ( nPos != COMBOBOX_ENTRY_NOTFOUND ) + m_pImpl->m_aSchema.SelectEntryPos(nPos); + } + m_pImpl->m_aTitle.SetText(sTable); + } + else + m_pImpl->m_aTitle.SetText(m_pImpl->m_aName); + m_pImpl->m_aTitle.SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) ); + + m_pImpl->m_aPB_OK.SetPosPixel(Point(m_pImpl->m_aPB_OK.GetPosPixel().X(),aPos.Y())); + m_pImpl->m_aPB_CANCEL.SetPosPixel(Point(m_pImpl->m_aPB_CANCEL.GetPosPixel().X(),aPos.Y())); + m_pImpl->m_aPB_HELP.SetPosPixel(Point(m_pImpl->m_aPB_HELP.GetPosPixel().X(),aPos.Y())); + + USHORT nLength = m_pImpl->m_xMetaData.is() ? static_cast<USHORT>(m_pImpl->m_xMetaData->getMaxTableNameLength()) : 0; + nLength = nLength ? nLength : EDIT_NOLIMIT; + + m_pImpl->m_aTitle.SetMaxTextLen(nLength); + m_pImpl->m_aSchema.SetMaxTextLen(nLength); + m_pImpl->m_aCatalog.SetMaxTextLen(nLength); + + sal_Bool bCheck = _xConnection.is() && isSQL92CheckEnabled(_xConnection); + m_pImpl->m_aTitle.setCheck(bCheck); // enable non valid sql chars as well + m_pImpl->m_aSchema.setCheck(bCheck); // enable non valid sql chars as well + m_pImpl->m_aCatalog.setCheck(bCheck); // enable non valid sql chars as well + + Size aSize = GetSizePixel(); + aSize.Height() = + aPos.Y() + m_pImpl->m_aPB_OK.GetSizePixel().Height() + m_pImpl->m_aTitle.GetSizePixel().Height() / 2; + SetSizePixel(aSize); + } + break; + + default: + OSL_ENSURE( false, "OSaveAsDlg::OSaveAsDlg: Type not supported yet!" ); + } + + implInit(); +} +// ----------------------------------------------------------------------------- +OSaveAsDlg::OSaveAsDlg( Window * pParent, + const Reference< XMultiServiceFactory >& _rxORB, + const String& rDefault, + const String& _sLabel, + const IObjectNameCheck& _rObjectNameCheck, + sal_Int32 _nFlags) + :ModalDialog( pParent, ModuleRes(DLG_SAVE_AS)) + ,m_xORB( _rxORB ) +{ + m_pImpl = new OSaveAsDlgImpl(this,rDefault,_rObjectNameCheck,_nFlags); + implInitOnlyTitle(_sLabel); + implInit(); +} +// ----------------------------------------------------------------------------- +OSaveAsDlg::~OSaveAsDlg() +{ + DELETEZ(m_pImpl); +} +// ----------------------------------------------------------------------------- +IMPL_LINK(OSaveAsDlg, ButtonClickHdl, Button *, pButton) +{ + if (pButton == &m_pImpl->m_aPB_OK) + { + m_pImpl->m_aName = m_pImpl->m_aTitle.GetText(); + + ::rtl::OUString sNameToCheck( m_pImpl->m_aName ); + + if ( m_pImpl->m_nType == CommandType::TABLE ) + { + sNameToCheck = ::dbtools::composeTableName( + m_pImpl->m_xMetaData, + getCatalog(), + getSchema(), + sNameToCheck, + sal_False, // no quoting + ::dbtools::eInDataManipulation + ); + } + + SQLExceptionInfo aNameError; + if ( m_pImpl->m_rObjectNameCheck.isNameValid( sNameToCheck, aNameError ) ) + EndDialog( RET_OK ); + + showError( aNameError, this, m_xORB ); + m_pImpl->m_aTitle.GrabFocus(); + } + return 0; +} +// ----------------------------------------------------------------------------- + +IMPL_LINK(OSaveAsDlg, EditModifyHdl, Edit *, pEdit ) +{ + if (pEdit == &m_pImpl->m_aTitle) + m_pImpl->m_aPB_OK.Enable(0 != m_pImpl->m_aTitle.GetText().Len()); + return 0; +} +// ----------------------------------------------------------------------------- +void OSaveAsDlg::implInitOnlyTitle(const String& _rLabel) +{ + m_pImpl->m_aLabel.SetText(_rLabel); + m_pImpl->m_aCatalogLbl.Hide(); + m_pImpl->m_aCatalog.Hide(); + m_pImpl->m_aSchemaLbl.Hide(); + m_pImpl->m_aSchema.Hide(); + + Point aPos(m_pImpl->m_aSchemaLbl.GetPosPixel()); + m_pImpl->m_aLabel.SetPosPixel(m_pImpl->m_aCatalogLbl.GetPosPixel()); + m_pImpl->m_aTitle.SetPosPixel(m_pImpl->m_aCatalog.GetPosPixel()); + + m_pImpl->m_aPB_OK.SetPosPixel(Point(m_pImpl->m_aPB_OK.GetPosPixel().X(),aPos.Y())); + m_pImpl->m_aPB_CANCEL.SetPosPixel(Point(m_pImpl->m_aPB_CANCEL.GetPosPixel().X(),aPos.Y())); + m_pImpl->m_aPB_HELP.SetPosPixel(Point(m_pImpl->m_aPB_HELP.GetPosPixel().X(),aPos.Y())); + + sal_Int32 nNewHeight = + aPos.Y() + m_pImpl->m_aPB_OK.GetSizePixel().Height() + m_pImpl->m_aTitle.GetSizePixel().Height() / 2; + + SetSizePixel(Size(GetSizePixel().Width(), nNewHeight)); + + m_pImpl->m_aTitle.SetText(m_pImpl->m_aName); + m_pImpl->m_aTitle.setCheck(sal_False); // enable non valid sql chars as well +} +// ----------------------------------------------------------------------------- +void OSaveAsDlg::implInit() +{ + if ( 0 == ( m_pImpl->m_nFlags & SAD_ADDITIONAL_DESCRIPTION ) ) + { + // hide the description window + m_pImpl->m_aDescription.Hide(); + + // the number of pixels we have to move the other controls + sal_Int32 nMoveUp = m_pImpl->m_aCatalog.GetPosPixel().Y() - m_pImpl->m_aDescription.GetPosPixel().Y(); + + // loop to all controls and move them ... + for ( Window* pChildControl = GetWindow( WINDOW_FIRSTCHILD ); + pChildControl; + pChildControl= pChildControl->GetWindow( WINDOW_NEXT ) + ) + { + if ( &m_pImpl->m_aDescription != pChildControl ) + { + Point aPos = pChildControl->GetPosPixel(); + aPos.Y() -= nMoveUp; + pChildControl->SetPosPixel(aPos); + } + } + + // change our own size accordingly + Size aSize = GetSizePixel(); + aSize.Height() -= nMoveUp; + SetSizePixel(aSize); + } + + if ( SAD_TITLE_PASTE_AS == ( m_pImpl->m_nFlags & SAD_TITLE_PASTE_AS ) ) + SetText( String( ModuleRes( STR_TITLE_PASTE_AS ) ) ); + else if ( SAD_TITLE_RENAME == ( m_pImpl->m_nFlags & SAD_TITLE_RENAME ) ) + { + SetText( String( ModuleRes( STR_TITLE_RENAME ) ) ); + m_pImpl->m_aTitle.SetHelpId(HID_DLG_RENAME); + } + + m_pImpl->m_aPB_OK.SetClickHdl(LINK(this,OSaveAsDlg,ButtonClickHdl)); + m_pImpl->m_aTitle.SetModifyHdl(LINK(this,OSaveAsDlg,EditModifyHdl)); + m_pImpl->m_aTitle.GrabFocus(); + FreeResource(); +} +// ----------------------------------------------------------------------------- +String OSaveAsDlg::getName() const { return m_pImpl->m_aName; } +String OSaveAsDlg::getCatalog() const { return m_pImpl->m_aCatalog.IsVisible() ? m_pImpl->m_aCatalog.GetText() : String(); } +String OSaveAsDlg::getSchema() const { return m_pImpl->m_aSchema.IsVisible() ? m_pImpl->m_aSchema.GetText() : String(); } + diff --git a/dbaccess/source/ui/dlg/dlgsave.hrc b/dbaccess/source/ui/dlg/dlgsave.hrc new file mode 100644 index 000000000000..7a36319ef4de --- /dev/null +++ b/dbaccess/source/ui/dlg/dlgsave.hrc @@ -0,0 +1,53 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBAUI_DLGSAVE_HRC +#define DBAUI_DLGSAVE_HRC + +// defines ------------------------------------------------------------------ + +#define PB_OK 1 +#define PB_CANCEL 1 +#define PB_HELP 1 + +#define ET_CATALOG 1 +#define ET_SCHEMA 2 +#define ET_TITLE 3 + +#define FT_DESCRIPTION 1 +#define FT_CATALOG 2 +#define FT_SCHEMA 3 +#define FT_TITLE 4 + +#define STR_TBL_LABEL 1 +#define STR_VW_LABEL 2 +#define STR_QRY_LABEL 3 +#define STR_TITLE_RENAME 4 +#define STR_TITLE_PASTE_AS 6 + +#endif // DBAUI_DLGSAVE_HRC + diff --git a/dbaccess/source/ui/dlg/dlgsave.src b/dbaccess/source/ui/dlg/dlgsave.src new file mode 100644 index 000000000000..d550704b85f8 --- /dev/null +++ b/dbaccess/source/ui/dlg/dlgsave.src @@ -0,0 +1,141 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBAUI_DLGSAVE_HRC +#include "dlgsave.hrc" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif + +ModalDialog DLG_SAVE_AS +{ + OutputSize = TRUE ; + SVLook = TRUE ; + HelpId = HID_DLG_SAVE_AS ; + Size = MAP_APPFONT ( 174 , 75 ) ; + Moveable = TRUE ; + Closeable = TRUE ; + Text [ en-US ] = "Save As" ; + + FixedText FT_DESCRIPTION + { + Pos = MAP_APPFONT ( 6 , 6 ) ; + Size = MAP_APPFONT ( 174 - 12 , 16 ) ; + WordBreak=TRUE; + Text [ en-US ] = "Please enter a name for the object to be created:"; + }; + + FixedText FT_CATALOG + { + Pos = MAP_APPFONT ( 6 , 26 ) ; + Size = MAP_APPFONT ( 70 , 10 ) ; + Text [ en-US ] = "~Catalog"; + }; + ComboBox ET_CATALOG + { + Border = TRUE ; + Pos = MAP_APPFONT ( 77 , 25 ) ; + Size = MAP_APPFONT ( 89 , 12 ) ; + SVLook = TRUE ; + TabStop = TRUE ; + DropDown = TRUE ; + AutoHScroll = TRUE ; + }; + FixedText FT_SCHEMA + { + Pos = MAP_APPFONT ( 6 , 43 ) ; + Size = MAP_APPFONT ( 70 , 10 ) ; + Text [ en-US ] = "~Schema"; + }; + ComboBox ET_SCHEMA + { + Border = TRUE ; + Pos = MAP_APPFONT ( 77 , 42 ) ; + Size = MAP_APPFONT ( 89 , 12 ) ; + SVLook = TRUE ; + TabStop = TRUE ; + DropDown = TRUE ; + AutoHScroll = TRUE ; + }; + FixedText FT_TITLE + { + Pos = MAP_APPFONT ( 6 , 60 ) ; + Size = MAP_APPFONT ( 70 , 10 ) ; + }; + Edit ET_TITLE + { + Border = TRUE ; + Pos = MAP_APPFONT ( 77 , 59 ) ; + Size = MAP_APPFONT ( 89 , 12 ) ; + TabStop = TRUE ; + }; + OKButton PB_OK + { + Pos = MAP_APPFONT ( 6 , 77 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + DefButton = TRUE ; + }; + CancelButton PB_CANCEL + { + Pos = MAP_APPFONT ( 62 , 77 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + HelpButton PB_HELP + { + Pos = MAP_APPFONT ( 118 , 77 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + // String Resourcen ------------------------------------------------------------------ + String STR_TBL_LABEL + { + Text [ en-US ] = "~Table Name" ; + }; + String STR_VW_LABEL + { + Text [ en-US ] = "~Name of table view" ; + }; + String STR_QRY_LABEL + { + Text [ en-US ] = "~Query name" ; + }; + String STR_TITLE_RENAME + { + Text [ en-US ] = "Rename to"; + }; + String STR_TITLE_PASTE_AS + { + Text [ en-US ] = "Insert as"; + }; +}; + diff --git a/dbaccess/source/ui/dlg/dlgsize.cxx b/dbaccess/source/ui/dlg/dlgsize.cxx new file mode 100644 index 000000000000..474d292bfe5d --- /dev/null +++ b/dbaccess/source/ui/dlg/dlgsize.cxx @@ -0,0 +1,130 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" +#ifndef DBAUI_DLGSIZE_HRC +#include "dlgsize.hrc" +#endif +#ifndef _DBAUI_DLGSIZE_HXX +#include "dlgsize.hxx" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "moduledbu.hxx" +#endif + +//......................................................................... +namespace dbaui +{ +//......................................................................... + + +#define DEF_ROW_HEIGHT 45 +#define DEF_COL_WIDTH 227 + +DBG_NAME(DlgSize) +//================================================================== +DlgSize::DlgSize( Window* pParent, sal_Int32 nVal, sal_Bool bRow, sal_Int32 _nAlternativeStandard ) + :ModalDialog( pParent, ModuleRes(bRow ? DLG_ROWHEIGHT : DLG_COLWIDTH)) + ,m_nPrevValue(nVal) + ,m_nStandard(bRow ? DEF_ROW_HEIGHT : DEF_COL_WIDTH) + ,aFT_VALUE(this, ModuleRes( FT_VALUE)) + ,aMF_VALUE(this, ModuleRes( MF_VALUE)) + ,aCB_STANDARD(this, ModuleRes(CB_STANDARD)) + ,aPB_OK(this, ModuleRes(PB_OK)) + ,aPB_CANCEL(this, ModuleRes(PB_CANCEL)) + ,aPB_HELP(this, ModuleRes(PB_HELP)) +{ + DBG_CTOR(DlgSize,NULL); + + if ( _nAlternativeStandard > 0 ) + m_nStandard = _nAlternativeStandard; + aCB_STANDARD.SetClickHdl(LINK(this,DlgSize,CbClickHdl)); + + aMF_VALUE.EnableEmptyFieldValue(sal_True); + sal_Bool bDefault = -1 == nVal; + aCB_STANDARD.Check(bDefault); + if (bDefault) + { + SetValue(m_nStandard); + m_nPrevValue = m_nStandard; + } + LINK(this,DlgSize,CbClickHdl).Call(&aCB_STANDARD); + + FreeResource(); +} + +//------------------------------------------------------------------------------ +DlgSize::~DlgSize() +{ + + DBG_DTOR(DlgSize,NULL); +} + +//------------------------------------------------------------------------------ +void DlgSize::SetValue( sal_Int32 nVal ) +{ + aMF_VALUE.SetValue(nVal, FUNIT_CM ); +} + +//------------------------------------------------------------------------------ +sal_Int32 DlgSize::GetValue() +{ + if (aCB_STANDARD.IsChecked()) + return -1; + return (sal_Int32)aMF_VALUE.GetValue( FUNIT_CM ); +} + +//------------------------------------------------------------------------------ +IMPL_LINK( DlgSize, CbClickHdl, Button *, pButton ) +{ + + if( pButton == &aCB_STANDARD ) + { + aMF_VALUE.Enable(!aCB_STANDARD.IsChecked()); + if (aCB_STANDARD.IsChecked()) + { + m_nPrevValue = static_cast<sal_Int32>(aMF_VALUE.GetValue(FUNIT_CM)); + // don't use getValue as this will use aCB_STANDARD.to determine if we're standard + aMF_VALUE.SetEmptyFieldValue(); + } + else + { + SetValue( m_nPrevValue ); + } + } + return 0; +} +// ----------------------------------------------------------------------------- +//......................................................................... +} // namespace dbaui +//......................................................................... + + diff --git a/dbaccess/source/ui/dlg/dlgsize.hrc b/dbaccess/source/ui/dlg/dlgsize.hrc new file mode 100644 index 000000000000..3eef0951a0dd --- /dev/null +++ b/dbaccess/source/ui/dlg/dlgsize.hrc @@ -0,0 +1,39 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBAUI_DLGSIZE_HRC +#define DBAUI_DLGSIZE_HRC + +#define FT_VALUE 1 +#define MF_VALUE 1 +#define CB_STANDARD 2 +#define PB_OK 1 +#define PB_CANCEL 1 +#define PB_HELP 1 + +#endif //DBAUI_DLGSIZE_HRC + diff --git a/dbaccess/source/ui/dlg/dlgsize.src b/dbaccess/source/ui/dlg/dlgsize.src new file mode 100644 index 000000000000..ade6f3ff1222 --- /dev/null +++ b/dbaccess/source/ui/dlg/dlgsize.src @@ -0,0 +1,189 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + //--------------------------------------------------------------------------- + // + // (c) Copyright 1996 - 2000 by Star Division GmbH, Hamburg, Germany + // + // Ersterstellung: + // JN + // + // Letzte Aenderung: + // $Author: rt $ $Date: 2008-04-10 14:52:17 $ $Revision: 1.32 $ + // + //--------------------------------------------------------------------------- + +#ifndef DBAUI_DLGSIZE_HRC +#include "dlgsize.hrc" +#endif +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif + +ModalDialog DLG_ROWHEIGHT +{ + OutputSize = TRUE ; + SVLook = TRUE ; + HelpId = HID_DLG_ROWHEIGHT ; + Size = MAP_APPFONT ( 159 , 59 ) ; + Moveable = TRUE ; + Closeable = TRUE ; + FixedText FT_VALUE + { + Pos = MAP_APPFONT ( 6 , 8 ) ; + Size = MAP_APPFONT ( 23 , 10 ) ; + Text [ en-US ] = "~Height" ; + }; + MetricField MF_VALUE + { + Border = TRUE ; + Pos = MAP_APPFONT ( 36 , 6 ) ; + Size = MAP_APPFONT ( 63 , 12 ) ; + TabStop = TRUE ; + Spin = TRUE ; + Minimum = 10 ; + Maximum = 1600 ; + DecimalDigits = 2 ; + Unit = FUNIT_CM ; + Repeat = TRUE ; + }; + CheckBox CB_STANDARD + { + Pos = MAP_APPFONT ( 36 , 25 ) ; + Size = MAP_APPFONT ( 62 , 12 ) ; + TabStop = TRUE ; + Text [ en-US ] = "~Automatic"; + }; + OKButton PB_OK + { + Pos = MAP_APPFONT ( 105 , 6 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + DefButton = TRUE ; + }; + CancelButton PB_CANCEL + { + Pos = MAP_APPFONT ( 105 , 23 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + HelpButton PB_HELP + { + Pos = MAP_APPFONT ( 105 , 42 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + Text [ en-US ] = "Row Height" ; +}; +ModalDialog DLG_COLWIDTH +{ + OutputSize = TRUE ; + SVLook = TRUE ; + HelpId = HID_DLG_COLWIDTH ; + Size = MAP_APPFONT ( 159 , 59 ) ; + Moveable = TRUE ; + Closeable = TRUE ; + FixedText FT_VALUE + { + Pos = MAP_APPFONT ( 6 , 8 ) ; + Size = MAP_APPFONT ( 23 , 10 ) ; + Text [ en-US ] = "~Width" ; + }; + MetricField MF_VALUE + { + Border = TRUE ; + Pos = MAP_APPFONT ( 36 , 6 ) ; + Size = MAP_APPFONT ( 63 , 12 ) ; + TabStop = TRUE ; + Spin = TRUE ; + Minimum = 10 ; + Maximum = 20000 ; + DecimalDigits = 2 ; + Unit = FUNIT_CM ; + Repeat = TRUE ; + }; + CheckBox CB_STANDARD + { + Pos = MAP_APPFONT ( 36 , 25 ) ; + Size = MAP_APPFONT ( 62 , 12 ) ; + TabStop = TRUE ; + Text [ en-US ] = "~Automatic"; + }; + OKButton PB_OK + { + Pos = MAP_APPFONT ( 105 , 6 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + DefButton = TRUE ; + }; + CancelButton PB_CANCEL + { + Pos = MAP_APPFONT ( 105 , 23 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + HelpButton PB_HELP + { + Pos = MAP_APPFONT ( 105 , 42 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + Text [ en-US ] = "Column Width" ; +}; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dbaccess/source/ui/dlg/dsnItem.hxx b/dbaccess/source/ui/dlg/dsnItem.hxx new file mode 100644 index 000000000000..ac66e4386bf9 --- /dev/null +++ b/dbaccess/source/ui/dlg/dsnItem.hxx @@ -0,0 +1,69 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBAUI_DSNITEM_HXX_ +#define _DBAUI_DSNITEM_HXX_ + +#include <svl/poolitem.hxx> + +//......................................................................... +namespace dbaccess +{ +//......................................................................... + class ODsnTypeCollection; +//......................................................................... +} +//......................................................................... +//......................................................................... +namespace dbaui +{ +//......................................................................... + //========================================================================= + //= DbuTypeCollectionItem + //========================================================================= + /** allows an ODsnTypeCollection to be transported in an SfxItemSet + */ + class DbuTypeCollectionItem : public SfxPoolItem + { + ::dbaccess::ODsnTypeCollection* m_pCollection; + + public: + TYPEINFO(); + DbuTypeCollectionItem(sal_Int16 nWhich = 0, ::dbaccess::ODsnTypeCollection* _pCollection = NULL); + DbuTypeCollectionItem(const DbuTypeCollectionItem& _rSource); + + virtual int operator==(const SfxPoolItem& _rItem) const; + virtual SfxPoolItem* Clone(SfxItemPool* _pPool = NULL) const; + + ::dbaccess::ODsnTypeCollection* getCollection() const { return m_pCollection; } + }; +//......................................................................... +} // namespace dbaui +//......................................................................... + +#endif // _DBAUI_DSNITEM_HXX_ + diff --git a/dbaccess/source/ui/dlg/dsselect.cxx b/dbaccess/source/ui/dlg/dsselect.cxx new file mode 100644 index 000000000000..b710cf990047 --- /dev/null +++ b/dbaccess/source/ui/dlg/dsselect.cxx @@ -0,0 +1,318 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#ifndef _DBAUI_DSSELECT_HXX_ +#include "dsselect.hxx" +#endif +#ifndef _DBAUI_DSSELECT_HRC_ +#include "dsselect.hrc" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif +#ifndef _DBAUI_LOCALRESACCESS_HXX_ +#include "localresaccess.hxx" +#endif +#ifndef _TOOLS_RCID_H +#include <tools/rcid.h> +#endif + +#ifndef _COM_SUN_STAR_SDBCX_XCREATECATALOG_HPP_ +#include <com/sun/star/sdbcx/XCreateCatalog.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP_ +#include <com/sun/star/beans/XPropertySetInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_UI_DIALOGS_XEXECUTABLEDIALOG_HPP_ +#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_ +#include <com/sun/star/awt/XWindow.hpp> +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ +#include <toolkit/helper/vclunohelper.hxx> +#endif +#ifndef _COMPHELPER_EXTRACT_HXX_ +#include <comphelper/extract.hxx> +#endif +#ifndef _COMPHELPER_TYPES_HXX_ +#include <comphelper/types.hxx> +#endif +#ifndef _COMPHELPER_PROCESSFACTORY_HXX_ +#include <comphelper/processfactory.hxx> +#endif +#ifndef _DBAUI_DATASOURCEITEMS_HXX_ +#include "dsitems.hxx" +#endif +#ifndef _SFXSTRITEM_HXX +#include <svl/stritem.hxx> +#endif +#ifndef _SFXINTITEM_HXX +#include <svl/intitem.hxx> +#endif +#ifndef _SFXENUMITEM_HXX +#include <svl/eitem.hxx> +#endif +#ifndef _SFXITEMSET_HXX +#include <svl/itemset.hxx> +#endif + +//......................................................................... +namespace dbaui +{ +//......................................................................... +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::ui::dialogs; +using namespace ::comphelper; +//================================================================== +ODatasourceSelectDialog::ODatasourceSelectDialog(Window* _pParent, const StringBag& _rDatasources, bool _bAdabas,SfxItemSet* _pOutputSet) + :ModalDialog(_pParent, ModuleRes(DLG_DATASOURCE_SELECTION)) + ,m_aDescription (this, ModuleRes(FT_DESCRIPTION)) + ,m_aDatasource (this, ModuleRes(LB_DATASOURCE)) + ,m_aOk (this, ModuleRes(PB_OK)) + ,m_aCancel (this, ModuleRes(PB_CANCEL)) + ,m_aHelp (this, ModuleRes(PB_HELP)) +#ifdef HAVE_ODBC_ADMINISTRATION + ,m_aManageDatasources (this, ModuleRes(PB_MANAGE)) +#endif + ,m_aCreateAdabasDB (this, ModuleRes(PB_CREATE)) + ,m_pOutputSet(_pOutputSet) +{ + if ( _bAdabas ) + { // set a new title (indicating that we're browsing local data sources only) + SetText(ModuleRes(STR_LOCAL_DATASOURCES)); + m_aDescription.SetText(ModuleRes(STR_DESCRIPTION2)); + + m_aCreateAdabasDB.Show(); + m_aCreateAdabasDB.SetClickHdl(LINK(this,ODatasourceSelectDialog,CreateDBClickHdl)); + + // resize the dialog a little bit, 'cause Adabas data source names are usually somewhat shorter + // than ODBC ones are + + // shrink the listbox + Size aOldSize = m_aDatasource.GetSizePixel(); + Size aNewSize(3 * aOldSize.Width() / 4, aOldSize.Height()); + m_aDatasource.SetSizePixel(aNewSize); + + sal_Int32 nLostPixels = aOldSize.Width() - aNewSize.Width(); + + // shrink the fixed text + aOldSize = m_aDescription.GetSizePixel(); + m_aDescription.SetSizePixel(Size(aOldSize.Width() - nLostPixels, aOldSize.Height())); + + // move the buttons + PushButton* pButtons[] = { &m_aOk, &m_aCancel, &m_aHelp ,&m_aCreateAdabasDB}; + for (size_t i=0; i<sizeof(pButtons)/sizeof(pButtons[0]); ++i) + { + Point aOldPos = pButtons[i]->GetPosPixel(); + pButtons[i]->SetPosPixel(Point(aOldPos.X() - nLostPixels, aOldPos.Y())); + } + + // resize the dialog itself + aOldSize = GetSizePixel(); + SetSizePixel(Size(aOldSize.Width() - nLostPixels, aOldSize.Height())); + } + + fillListBox(_rDatasources); +#ifdef HAVE_ODBC_ADMINISTRATION + // allow ODBC datasource managenment + if ( !_bAdabas ) + { + m_aManageDatasources.Show(); + m_aManageDatasources.Enable(); + m_aManageDatasources.SetClickHdl(LINK(this,ODatasourceSelectDialog,ManageClickHdl)); + } +#endif + m_aDatasource.SetDoubleClickHdl(LINK(this,ODatasourceSelectDialog,ListDblClickHdl)); + FreeResource(); +} + +// ----------------------------------------------------------------------- +ODatasourceSelectDialog::~ODatasourceSelectDialog() +{ +} + +// ----------------------------------------------------------------------- +IMPL_LINK( ODatasourceSelectDialog, ListDblClickHdl, ListBox *, pListBox ) +{ + if (pListBox->GetSelectEntryCount()) + EndDialog(RET_OK); + return 0; +} +// ----------------------------------------------------------------------- +IMPL_LINK( ODatasourceSelectDialog, CreateDBClickHdl, PushButton*, /*pButton*/ ) +{ + try + { + OSL_ENSURE(m_pOutputSet,"No itemset given!"); + Reference< ::com::sun::star::lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory(); + Reference<XCreateCatalog> xCatalog(xORB->createInstance(SERVICE_EXTENDED_ADABAS_DRIVER),UNO_QUERY); + if ( xCatalog.is() && m_pOutputSet ) + { + Sequence< Any > aArgs(2); + aArgs[0] <<= PropertyValue(::rtl::OUString::createFromAscii("CreateCatalog"), 0,makeAny(xCatalog) , PropertyState_DIRECT_VALUE); + aArgs[1] <<= PropertyValue(PROPERTY_PARENTWINDOW, 0, makeAny(VCLUnoHelper::GetInterface(this)), PropertyState_DIRECT_VALUE); + + Reference< XExecutableDialog > xDialog( + xORB->createInstanceWithArguments(SERVICE_SDB_ADABASCREATIONDIALOG, aArgs), UNO_QUERY); + if (!xDialog.is()) + { + // ShowServiceNotAvailableError(this, String(SERVICE_SDB_ADABASCREATIONDIALOG), sal_True); + return 0L; + } + + if ( xDialog->execute() == RET_OK ) + { + Reference<XPropertySet> xProp(xDialog,UNO_QUERY); + if(xProp.is()) + { + Reference<XPropertySetInfo> xPropInfo(xProp->getPropertySetInfo()); + if(xPropInfo->hasPropertyByName(PROPERTY_DATABASENAME)) + { + String sDatabaseName; + sDatabaseName = String(::comphelper::getString(xProp->getPropertyValue(PROPERTY_DATABASENAME))); + m_aDatasource.SelectEntryPos(m_aDatasource.InsertEntry( sDatabaseName )); + + } + if ( xPropInfo->hasPropertyByName(PROPERTY_CONTROLUSER) ) + m_pOutputSet->Put(SfxStringItem(DSID_CONN_CTRLUSER, ::comphelper::getString(xProp->getPropertyValue(PROPERTY_CONTROLUSER)))); + if ( xPropInfo->hasPropertyByName(PROPERTY_CONTROLPASSWORD) ) + m_pOutputSet->Put(SfxStringItem(DSID_CONN_CTRLPWD, ::comphelper::getString(xProp->getPropertyValue(PROPERTY_CONTROLPASSWORD)))); + if ( xPropInfo->hasPropertyByName(PROPERTY_USER) ) + m_pOutputSet->Put(SfxStringItem(DSID_USER, ::comphelper::getString(xProp->getPropertyValue(PROPERTY_USER)))); + if ( xPropInfo->hasPropertyByName(PROPERTY_PASSWORD) ) + { + m_pOutputSet->Put(SfxStringItem(DSID_PASSWORD, ::comphelper::getString(xProp->getPropertyValue(PROPERTY_PASSWORD)))); + m_pOutputSet->Put(SfxBoolItem(DSID_PASSWORDREQUIRED, TRUE)); + } + if ( xPropInfo->hasPropertyByName(PROPERTY_CACHESIZE) ) + m_pOutputSet->Put(SfxInt32Item(DSID_CONN_CACHESIZE, ::comphelper::getINT32(xProp->getPropertyValue(PROPERTY_CACHESIZE)))); + } + } + } + } + catch(Exception&) + { + } + return 0L; +} + +// ----------------------------------------------------------------------- +BOOL ODatasourceSelectDialog::Close() +{ +#ifdef HAVE_ODBC_ADMINISTRATION + if ( m_pODBCManagement.get() && m_pODBCManagement->isRunning() ) + return FALSE; +#endif + + return ModalDialog::Close(); +} + +// ----------------------------------------------------------------------- +#ifdef HAVE_ODBC_ADMINISTRATION +IMPL_LINK( ODatasourceSelectDialog, ManageClickHdl, PushButton*, EMPTYARG ) +{ + if ( !m_pODBCManagement.get() ) + m_pODBCManagement.reset( new OOdbcManagement( LINK( this, ODatasourceSelectDialog, ManageProcessFinished ) ) ); + + if ( !m_pODBCManagement->manageDataSources_async() ) + { + // TODO: error message + m_aDatasource.GrabFocus(); + m_aManageDatasources.Disable(); + return 1L; + } + + m_aDatasource.Disable(); + m_aOk.Disable(); + m_aCancel.Disable(); + m_aManageDatasources.Disable(); + + OSL_POSTCOND( m_pODBCManagement->isRunning(), "ODatasourceSelectDialog::ManageClickHdl: success, but not running - you were *fast*!" ); + return 0L; +} + +IMPL_LINK( ODatasourceSelectDialog, ManageProcessFinished, void*, /**/ ) +{ + StringBag aOdbcDatasources; + OOdbcEnumeration aEnumeration; + aEnumeration.getDatasourceNames( aOdbcDatasources ); + fillListBox( aOdbcDatasources ); + + m_aDatasource.Enable(); + m_aOk.Enable(); + m_aCancel.Enable(); + m_aManageDatasources.Enable(); + + return 0L; +} + +#endif +// ----------------------------------------------------------------------------- +void ODatasourceSelectDialog::fillListBox(const StringBag& _rDatasources) +{ + ::rtl::OUString sSelected; + if (m_aDatasource.GetEntryCount()) + sSelected = m_aDatasource.GetSelectEntry(); + m_aDatasource.Clear(); + // fill the list + for ( ConstStringBagIterator aDS = _rDatasources.begin(); + aDS != _rDatasources.end(); + ++aDS + ) + { + m_aDatasource.InsertEntry( *aDS ); + } + + if (m_aDatasource.GetEntryCount()) + { + if (sSelected.getLength()) + m_aDatasource.SelectEntry(sSelected); + else // select the first entry + m_aDatasource.SelectEntryPos(0); + } +} + +//......................................................................... +} // namespace dbaui +//......................................................................... + diff --git a/dbaccess/source/ui/dlg/dsselect.hrc b/dbaccess/source/ui/dlg/dsselect.hrc new file mode 100644 index 000000000000..5deffeeef102 --- /dev/null +++ b/dbaccess/source/ui/dlg/dsselect.hrc @@ -0,0 +1,41 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBAUI_DSSELECT_HRC_ +#define _DBAUI_DSSELECT_HRC_ + +#define LB_DATASOURCE 1 +#define PB_OK 2 +#define PB_CANCEL 3 +#define PB_HELP 4 +#define PB_MANAGE 5 +#define FT_DESCRIPTION 6 +#define STR_LOCAL_DATASOURCES 7 +#define PB_CREATE 9 +#define STR_DESCRIPTION2 10 + +#endif // _DBAUI_DSSELECT_HRC_ diff --git a/dbaccess/source/ui/dlg/dsselect.hxx b/dbaccess/source/ui/dlg/dsselect.hxx new file mode 100644 index 000000000000..d2ac059827e9 --- /dev/null +++ b/dbaccess/source/ui/dlg/dsselect.hxx @@ -0,0 +1,95 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBAUI_DSSELECT_HXX_ +#define _DBAUI_DSSELECT_HXX_ + +#include "dsntypes.hxx" +#include "odbcconfig.hxx" +#include "commontypes.hxx" + +#include <vcl/dialog.hxx> +#include <vcl/lstbox.hxx> +#include <vcl/button.hxx> +#include <vcl/group.hxx> +#include <vcl/fixed.hxx> +#include <rtl/ustring.hxx> + +#include <memory> + +class SfxItemSet; +//......................................................................... +namespace dbaui +{ +//......................................................................... + +//========================================================================= +//= ODatasourceSelector +//========================================================================= +class ODatasourceSelectDialog : public ModalDialog +{ +protected: + FixedText m_aDescription; + ListBox m_aDatasource; + OKButton m_aOk; + CancelButton m_aCancel; + HelpButton m_aHelp; +#ifdef HAVE_ODBC_ADMINISTRATION + PushButton m_aManageDatasources; +#endif + PushButton m_aCreateAdabasDB; + SfxItemSet* m_pOutputSet; +#ifdef HAVE_ODBC_ADMINISTRATION + ::std::auto_ptr< OOdbcManagement > + m_pODBCManagement; +#endif + +public: + ODatasourceSelectDialog( Window* _pParent, const StringBag& _rDatasources, bool _bAdabas,SfxItemSet* _pOutputSet = NULL ); + ~ODatasourceSelectDialog(); + + inline String GetSelected() const { return m_aDatasource.GetSelectEntry();} + void Select( const String& _rEntry ) { m_aDatasource.SelectEntry(_rEntry); } + + virtual BOOL Close(); + +protected: + DECL_LINK( ListDblClickHdl, ListBox * ); +#ifdef HAVE_ODBC_ADMINISTRATION + DECL_LINK( ManageClickHdl, PushButton * ); + DECL_LINK( ManageProcessFinished, void* ); +#endif + DECL_LINK( CreateDBClickHdl, PushButton * ); + void fillListBox(const StringBag& _rDatasources); +}; + +//......................................................................... +} // namespace dbaui +//......................................................................... + +#endif // _DBAUI_DSSELECT_HXX_ + diff --git a/dbaccess/source/ui/dlg/dsselect.src b/dbaccess/source/ui/dlg/dsselect.src new file mode 100644 index 000000000000..8eff7fffe6c4 --- /dev/null +++ b/dbaccess/source/ui/dlg/dsselect.src @@ -0,0 +1,107 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBAUI_DSSELECT_HRC_ +#include "dsselect.hrc" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif + + +ModalDialog DLG_DATASOURCE_SELECTION +{ + OutputSize = TRUE ; + Moveable = TRUE ; + Closeable = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 218 , 118 ) ; + Text [ en-US ] = "Data Source" ; + + FixedText FT_DESCRIPTION + { + Pos = MAP_APPFONT ( 6 , 6 ) ; + Size = MAP_APPFONT ( 154 , 10 ) ; + Text [ en-US ] = "Choose a data source:"; + }; + ListBox LB_DATASOURCE + { + Border = TRUE ; + Pos = MAP_APPFONT ( 6 , 19 ) ; + Size = MAP_APPFONT ( 154 , 94 ) ; + TabStop = TRUE ; + HScroll = TRUE ; + Sort = TRUE ; + }; + + OKButton PB_OK + { + Pos = MAP_APPFONT ( 166 , 6 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + DefButton = TRUE ; + }; + CancelButton PB_CANCEL + { + Pos = MAP_APPFONT ( 166 , 23 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + HelpButton PB_HELP + { + Pos = MAP_APPFONT ( 166 , 43 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + PushButton PB_MANAGE + { + Pos = MAP_APPFONT ( 166 , 99 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + Disable = TRUE ; + Hide = TRUE ; + Text [ en-US ] = "Organize..." ; + }; + PushButton PB_CREATE + { + Pos = MAP_APPFONT ( 166 , 99 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + Hide = TRUE ; + Text [ en-US ] = "Create..." ; + }; + String STR_LOCAL_DATASOURCES + { + Text [ en-US ] = "Local Databases" ; + }; + String STR_DESCRIPTION2 + { + Text [ en-US ] = "Choose a database"; + }; +}; + + diff --git a/dbaccess/source/ui/dlg/finteraction.cxx b/dbaccess/source/ui/dlg/finteraction.cxx new file mode 100644 index 000000000000..b7e11951e14e --- /dev/null +++ b/dbaccess/source/ui/dlg/finteraction.cxx @@ -0,0 +1,88 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#ifndef DBAUI_FILEPICKER_INTERACTION_HXX +#include "finteraction.hxx" +#endif +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif +#ifndef _COM_SUN_STAR_UCB_INTERACTIVEIOEXCEPTION_HPP_ +#include <com/sun/star/ucb/InteractiveIOException.hpp> +#endif + +//........................................................................ +namespace dbaui +{ +//........................................................................ + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::task; + using namespace ::com::sun::star::ucb; + + //==================================================================== + //= OFilePickerInteractionHandler + //==================================================================== + DBG_NAME( OFilePickerInteractionHandler ) + //-------------------------------------------------------------------- + OFilePickerInteractionHandler::OFilePickerInteractionHandler( const Reference< XInteractionHandler >& _rxMaster ) + :m_xMaster( _rxMaster ) + ,m_bDoesNotExist(sal_False) + { + DBG_CTOR( OFilePickerInteractionHandler, NULL ); + DBG_ASSERT( m_xMaster.is(), "OFilePickerInteractionHandler::OFilePickerInteractionHandler: invalid master handler!" ); + } + + //-------------------------------------------------------------------- + OFilePickerInteractionHandler::~OFilePickerInteractionHandler( ) + { + DBG_DTOR( OFilePickerInteractionHandler, NULL ); + } + + //-------------------------------------------------------------------- + void SAL_CALL OFilePickerInteractionHandler::handle( const Reference< XInteractionRequest >& _rxRequest ) throw (RuntimeException) + { + InteractiveIOException aIoException; + if ( _rxRequest->getRequest() >>= aIoException ) + { + if ( IOErrorCode_NOT_EXISTING == aIoException.Code ) + { + m_bDoesNotExist = sal_True; + return; + } + } + + if ( m_xMaster.is() ) + m_xMaster->handle( _rxRequest ); + } + +//........................................................................ +} // namespace svt +//........................................................................ + diff --git a/dbaccess/source/ui/dlg/finteraction.hxx b/dbaccess/source/ui/dlg/finteraction.hxx new file mode 100644 index 000000000000..b11e960a144e --- /dev/null +++ b/dbaccess/source/ui/dlg/finteraction.hxx @@ -0,0 +1,75 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBAUI_FILEPICKER_INTERACTION_HXX +#define DBAUI_FILEPICKER_INTERACTION_HXX + +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif +#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_ +#include <com/sun/star/task/XInteractionHandler.hpp> +#endif + +//........................................................................ +namespace dbaui +{ +//........................................................................ + + //==================================================================== + //= OFilePickerInteractionHandler + //==================================================================== + typedef ::cppu::WeakImplHelper1 < ::com::sun::star::task::XInteractionHandler + > OFilePickerInteractionHandler_Base; + + /** a InteractionHandler implementation which extends another handler with some customizability + */ + class OFilePickerInteractionHandler : public OFilePickerInteractionHandler_Base + { + protected: + ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > + m_xMaster; // our master handler + sal_Bool m_bDoesNotExist; + + public: + OFilePickerInteractionHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _rxMaster ); + + inline sal_Bool isDoesNotExist( ) const { return m_bDoesNotExist; } + + protected: + // XInteractionHandler + virtual void SAL_CALL handle( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& _rxRequest ) throw (::com::sun::star::uno::RuntimeException); + + virtual ~OFilePickerInteractionHandler(); + }; + +//........................................................................ +} // namespace dbaui +//........................................................................ + +#endif // DBAUI_FILEPICKER_INTERACTION_HXX + diff --git a/dbaccess/source/ui/dlg/generalpage.cxx b/dbaccess/source/ui/dlg/generalpage.cxx new file mode 100644 index 000000000000..50658fb7811d --- /dev/null +++ b/dbaccess/source/ui/dlg/generalpage.cxx @@ -0,0 +1,636 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#include "dsnItem.hxx" +#include "generalpage.hxx" +#include <connectivity/dbexception.hxx> +#include "dbu_dlg.hrc" +#include "dbadmin.hrc" +#include "dsitems.hxx" +#include "dbustrings.hrc" +#include "dbadmin.hxx" +#include <sfx2/filedlghelper.hxx> +#include <sfx2/docfilt.hxx> +#include <vcl/stdtext.hxx> +#include "localresaccess.hxx" +#include <vcl/msgbox.hxx> +#include <svl/stritem.hxx> +#include <vcl/waitobj.hxx> +#include <com/sun/star/sdbc/XDriverAccess.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/container/XNameAccess.hpp> +#include "DriverSettings.hxx" +#include "UITools.hxx" +#include <comphelper/processfactory.hxx> +#include <unotools/confignode.hxx> + +//......................................................................... +namespace dbaui +{ +//......................................................................... + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::sdbc; + using namespace ::com::sun::star::beans; + using namespace ::com::sun::star::container; + + //========================================================================= + //= OGeneralPage + //========================================================================= + //------------------------------------------------------------------------- + OGeneralPage::OGeneralPage(Window* pParent, const SfxItemSet& _rItems, sal_Bool _bDBWizardMode) + :OGenericAdministrationPage(pParent, ModuleRes(PAGE_GENERAL), _rItems) + ,m_aFTHeaderText (this, ModuleRes(FT_GENERALHEADERTEXT)) + ,m_aFTHelpText (this, ModuleRes(FT_GENERALHELPTEXT)) + ,m_aFT_DatasourceTypeHeader (this, ModuleRes(FT_DATASOURCEHEADER)) + ,m_aRB_CreateDatabase (this, ModuleRes(RB_CREATEDBDATABASE)) + ,m_aRB_OpenDocument (this, ModuleRes(RB_OPENEXISTINGDOC)) + ,m_aRB_GetExistingDatabase (this, ModuleRes(RB_GETEXISTINGDATABASE)) + ,m_aFT_DocListLabel (this, ModuleRes(FT_DOCLISTLABEL)) + ,m_pLB_DocumentList ( new OpenDocumentListBox( this, "com.sun.star.sdb.OfficeDatabaseDocument", ModuleRes( LB_DOCUMENTLIST ) ) ) + ,m_aPB_OpenDocument (this, "com.sun.star.sdb.OfficeDatabaseDocument", ModuleRes(PB_OPENDOCUMENT)) + ,m_aTypePreLabel (this, ModuleRes(FT_DATASOURCETYPE_PRE)) + ,m_aDatasourceTypeLabel (this, ModuleRes(FT_DATATYPE)) + ,m_pDatasourceType ( new ListBox(this, ModuleRes(LB_DATATYPE))) + ,m_aFTDataSourceAppendix (this, ModuleRes(FT_DATATYPEAPPENDIX)) + ,m_aTypePostLabel (this, ModuleRes(FT_DATASOURCETYPE_POST)) + ,m_aSpecialMessage (this, ModuleRes(FT_SPECIAL_MESSAGE)) + ,m_DBWizardMode (_bDBWizardMode) + ,m_sMySQLEntry (ModuleRes(STR_MYSQLENTRY)) + ,m_eOriginalCreationMode (eCreateNew) + ,m_pCollection (NULL) + ,m_eNotSupportedKnownType ( ::dbaccess::DST_UNKNOWN) + ,m_eLastMessage (smNone) + ,m_bDisplayingInvalid (sal_False) + ,m_bUserGrabFocus (sal_True) + ,m_bInitTypeList (true) + { + // fill the listbox with the UI descriptions for the possible types + // and remember the respective DSN prefixes + FreeResource(); + // extract the datasource type collection from the item set + DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _rItems.GetItem(DSID_TYPECOLLECTION)); + if (pCollectionItem) + m_pCollection = pCollectionItem->getCollection(); + DBG_ASSERT(m_pCollection, "OGeneralPage::OGeneralPage : really need a DSN type collection !"); + + // If no driver for embedded DBs is installed, and no dBase driver, then hide the "Create new database" option + sal_Int32 nCreateNewDBIndex = m_pCollection->getIndexOf( m_pCollection->getEmbeddedDatabase() ); + if ( nCreateNewDBIndex == -1 ) + nCreateNewDBIndex = m_pCollection->getIndexOf( ::rtl::OUString::createFromAscii( "sdbc:dbase:" ) ); + bool bHideCreateNew = ( nCreateNewDBIndex == -1 ); + + // also, if our application policies tell us to hide the option, do it + ::utl::OConfigurationTreeRoot aConfig( ::utl::OConfigurationTreeRoot::createWithServiceFactory( + ::comphelper::getProcessServiceFactory(), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.DataAccess/Policies/Features/Base" ) ) + ) ); + sal_Bool bAllowCreateLocalDatabase( sal_True ); + OSL_VERIFY( aConfig.getNodeValue( "CreateLocalDatabase" ) >>= bAllowCreateLocalDatabase ); + if ( !bAllowCreateLocalDatabase ) + bHideCreateNew = true; + + if ( bHideCreateNew ) + { + m_aRB_CreateDatabase.Hide(); + Window* pWindowsToMove[] = { + &m_aRB_OpenDocument, &m_aRB_GetExistingDatabase, &m_aFT_DocListLabel, m_pLB_DocumentList.get(), + &m_aPB_OpenDocument, &m_aDatasourceTypeLabel, m_pDatasourceType.get(), &m_aFTDataSourceAppendix, + &m_aTypePostLabel + }; + const long nOffset = m_aRB_OpenDocument.GetPosPixel().Y() - m_aRB_CreateDatabase.GetPosPixel().Y(); + for ( size_t i=0; i < sizeof( pWindowsToMove ) / sizeof( pWindowsToMove[0] ); ++i ) + { + Point aPos( pWindowsToMove[i]->GetPosPixel() ); + aPos.Y() -= nOffset; + pWindowsToMove[i]->SetPosPixel( aPos ); + } + } + + if ( bHideCreateNew ) + m_aRB_GetExistingDatabase.Check(); + else + m_aRB_CreateDatabase.Check(); + + // do some knittings + m_pDatasourceType->SetSelectHdl(LINK(this, OGeneralPage, OnDatasourceTypeSelected)); + m_aRB_CreateDatabase.SetClickHdl(LINK(this, OGeneralPage, OnSetupModeSelected)); + m_aRB_GetExistingDatabase.SetClickHdl(LINK(this, OGeneralPage, OnSetupModeSelected)); + m_aRB_OpenDocument.SetClickHdl(LINK(this, OGeneralPage, OnSetupModeSelected)); + m_pLB_DocumentList->SetSelectHdl( LINK( this, OGeneralPage, OnDocumentSelected ) ); + m_aPB_OpenDocument.SetClickHdl( LINK( this, OGeneralPage, OnOpenDocument ) ); + } + + //------------------------------------------------------------------------- + OGeneralPage::~OGeneralPage() + { + m_pDatasourceType.reset( NULL ); + m_pLB_DocumentList.reset( NULL ); + } + + //------------------------------------------------------------------------- + namespace + { + struct DisplayedType + { + ::rtl::OUString eType; + String sDisplayName; + + DisplayedType( const ::rtl::OUString& _eType, const String& _rDisplayName ) : eType( _eType ), sDisplayName( _rDisplayName ) { } + }; + typedef ::std::vector< DisplayedType > DisplayedTypes; + + struct DisplayedTypeLess : ::std::binary_function< DisplayedType, DisplayedType, bool > + { + bool operator() ( const DisplayedType& _rLHS, const DisplayedType& _rRHS ) + { + return _rLHS.eType < _rRHS.eType; + } + }; + } + + //------------------------------------------------------------------------- + void OGeneralPage::initializeTypeList() + { + if ( m_bInitTypeList ) + { + m_bInitTypeList = false; + m_pDatasourceType->Clear(); + + if ( m_pCollection ) + { + DisplayedTypes aDisplayedTypes; + + ::dbaccess::ODsnTypeCollection::TypeIterator aEnd = m_pCollection->end(); + for ( ::dbaccess::ODsnTypeCollection::TypeIterator aTypeLoop = m_pCollection->begin(); + aTypeLoop != aEnd; + ++aTypeLoop + ) + { + const ::rtl::OUString sURLPrefix = aTypeLoop.getURLPrefix(); + if ( sURLPrefix.getLength() ) + { + String sDisplayName = aTypeLoop.getDisplayName(); + if ( m_pDatasourceType->GetEntryPos( sDisplayName ) == LISTBOX_ENTRY_NOTFOUND + && approveDataSourceType( sURLPrefix, sDisplayName ) ) + { + aDisplayedTypes.push_back( DisplayedTypes::value_type( sURLPrefix, sDisplayName ) ); + } + } + } + ::std::sort( aDisplayedTypes.begin(), aDisplayedTypes.end(), DisplayedTypeLess() ); + DisplayedTypes::const_iterator aDisplayEnd = aDisplayedTypes.end(); + for ( DisplayedTypes::const_iterator loop = aDisplayedTypes.begin(); + loop != aDisplayEnd; + ++loop + ) + insertDatasourceTypeEntryData( loop->eType, loop->sDisplayName ); + } // if ( m_pCollection ) + } + } + + + + //------------------------------------------------------------------------- + void OGeneralPage::setParentTitle(const ::rtl::OUString& _sURLPrefix) + { + if (!m_DBWizardMode) + { + const String sName = m_pCollection->getTypeDisplayName(_sURLPrefix); + if ( m_pAdminDialog ) + { + LocalResourceAccess aStringResAccess( PAGE_GENERAL, RSC_TABPAGE ); + String sMessage = String(ModuleRes(STR_PARENTTITLE)); + sMessage.SearchAndReplaceAscii("#",sName); + m_pAdminDialog->setTitle(sMessage); + } + } + } + + //------------------------------------------------------------------------- + OGeneralPage::CreationMode OGeneralPage::GetDatabaseCreationMode() const + { + if ( m_aRB_CreateDatabase.IsChecked() ) + return eCreateNew; + if ( m_aRB_GetExistingDatabase.IsChecked() ) + return eConnectExternal; + return eOpenExisting; + } + + //------------------------------------------------------------------------- + void OGeneralPage::GetFocus() + { + OGenericAdministrationPage::GetFocus(); + if ( m_pLB_DocumentList.get() && m_pLB_DocumentList->IsEnabled() ) + m_pLB_DocumentList->GrabFocus(); + else if (m_pDatasourceType.get() && m_pDatasourceType->IsEnabled()) + m_pDatasourceType->GrabFocus(); + } + + //------------------------------------------------------------------------- + void OGeneralPage::switchMessage(const ::rtl::OUString& _sURLPrefix) + { + SPECIAL_MESSAGE eMessage = smNone; + if ( !_sURLPrefix.getLength()/*_eType == m_eNotSupportedKnownType*/ ) + { + eMessage = smUnsupportedType; + } + + + if ( eMessage != m_eLastMessage ) + { + sal_uInt16 nResId = 0; + if ( smUnsupportedType == eMessage ) + nResId = STR_UNSUPPORTED_DATASOURCE_TYPE; + String sMessage; + if ( nResId ) + { + LocalResourceAccess aStringResAccess( PAGE_GENERAL, RSC_TABPAGE ); + sMessage = String(ModuleRes(nResId)); + } + m_aSpecialMessage.SetText(sMessage); + + m_eLastMessage = eMessage; + } + } + + //------------------------------------------------------------------------- + void OGeneralPage::onTypeSelected(const ::rtl::OUString& _sURLPrefix) + { + // the the new URL text as indicated by the selection history + implSetCurrentType( _sURLPrefix ); + + switchMessage(_sURLPrefix); + + if ( m_aTypeSelectHandler.IsSet() ) + m_aTypeSelectHandler.Call(this); + } + + //------------------------------------------------------------------------- + void OGeneralPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) + { + initializeTypeList(); + + // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) + sal_Bool bValid, bReadonly; + getFlags(_rSet, bValid, bReadonly); + if (m_DBWizardMode) + { + m_aTypePreLabel.Hide(); + m_aTypePostLabel.Hide(); + m_aSpecialMessage.Hide(); + SetControlFontWeight(&m_aFTHeaderText); + SetText(String()); + + LayoutHelper::positionBelow( m_aRB_GetExistingDatabase, *m_pDatasourceType, RelatedControls, INDENT_BELOW_RADIO ); + + if ( !bValid || bReadonly ) + { + m_aDatasourceTypeLabel.Enable( false ); + m_pDatasourceType->Enable( false ); + m_aFTDataSourceAppendix.Enable( false ); + m_aPB_OpenDocument.Enable( false ); + m_aFT_DocListLabel.Enable( false ); + m_pLB_DocumentList->Enable( false ); + } + else + { + m_aControlDependencies.enableOnRadioCheck( m_aRB_GetExistingDatabase, m_aDatasourceTypeLabel, *m_pDatasourceType, m_aFTDataSourceAppendix ); + m_aControlDependencies.enableOnRadioCheck( m_aRB_OpenDocument, m_aPB_OpenDocument, m_aFT_DocListLabel, *m_pLB_DocumentList ); + } + + m_pLB_DocumentList->SetDropDownLineCount( 20 ); + if ( m_pLB_DocumentList->GetEntryCount() ) + m_pLB_DocumentList->SelectEntryPos( 0 ); + + m_aDatasourceTypeLabel.Hide(); + m_aFTDataSourceAppendix.Hide(); + + m_eOriginalCreationMode = GetDatabaseCreationMode(); + } + else + { + m_aFT_DatasourceTypeHeader.Hide(); + m_aRB_CreateDatabase.Hide(); + m_aRB_GetExistingDatabase.Hide(); + m_aRB_OpenDocument.Hide(); + m_aPB_OpenDocument.Hide(); + m_aFT_DocListLabel.Hide(); + m_pLB_DocumentList->Hide(); + m_aFTHeaderText.Hide(); + m_aFTHelpText.Hide(); + m_aTypePreLabel.Enable(bValid); + m_aTypePostLabel.Enable(bValid); + m_aDatasourceTypeLabel.Enable(bValid); + m_pDatasourceType->Enable(bValid); + } + // if the selection is invalid, disable evrything + String sName,sConnectURL; + m_bDisplayingInvalid = !bValid; + if ( bValid ) + { + // collect some items and some values + SFX_ITEMSET_GET(_rSet, pNameItem, SfxStringItem, DSID_NAME, sal_True); + SFX_ITEMSET_GET(_rSet, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True); + DBG_ASSERT(pUrlItem, "OGeneralPage::implInitControls : missing the type attribute !"); + DBG_ASSERT(pNameItem, "OGeneralPage::implInitControls : missing the type attribute !"); + sName = pNameItem->GetValue(); + sConnectURL = pUrlItem->GetValue(); + } + + ::rtl::OUString eOldSelection = m_eCurrentSelection; + m_eNotSupportedKnownType = ::dbaccess::DST_UNKNOWN; + implSetCurrentType( ::rtl::OUString() ); + + // compare the DSN prefix with the registered ones + String sDisplayName; + + if (m_pCollection && bValid) + { + implSetCurrentType( m_pCollection->getPrefix(sConnectURL) ); + sDisplayName = m_pCollection->getTypeDisplayName(m_eCurrentSelection); + } + + // select the correct datasource type + if ( approveDataSourceType( m_eCurrentSelection, sDisplayName ) + && ( LISTBOX_ENTRY_NOTFOUND == m_pDatasourceType->GetEntryPos( sDisplayName ) ) + ) + { // this indicates it's really a type which is known in general, but not supported on the current platform + // show a message saying so + // eSpecialMessage = smUnsupportedType; + insertDatasourceTypeEntryData(m_eCurrentSelection, sDisplayName); + // remember this type so we can show the special message again if the user selects this + // type again (without changing the data source) + m_eNotSupportedKnownType = m_pCollection->determineType(m_eCurrentSelection); + } + + if (m_aRB_CreateDatabase.IsChecked() && m_DBWizardMode) + sDisplayName = m_pCollection->getTypeDisplayName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("jdbc:"))); + m_pDatasourceType->SelectEntry(sDisplayName); + + // notify our listener that our type selection has changed (if so) + if ( eOldSelection != m_eCurrentSelection ) + { + setParentTitle(m_eCurrentSelection); + onTypeSelected(m_eCurrentSelection); + } + + // a special message for the current page state + switchMessage(m_eCurrentSelection); + + OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue); + } + + + // For the databaseWizard we only have one entry for the MySQL Database, + // because we have a seperate tabpage to retrieve the respective datasource type + // ( ::dbaccess::DST_MYSQL_ODBC || ::dbaccess::DST_MYSQL_JDBC). Therefore we use ::dbaccess::DST_MYSQL_JDBC as a temporary + // representative for all MySQl databases) + // Also, embedded databases (embedded HSQL, at the moment), are not to appear in the list of + // databases to connect to. + bool OGeneralPage::approveDataSourceType( const ::rtl::OUString& _sURLPrefix, String& _inout_rDisplayName ) + { + const ::dbaccess::DATASOURCE_TYPE eType = m_pCollection->determineType(_sURLPrefix); + + if ( m_DBWizardMode ) + { + switch ( eType ) + { + case ::dbaccess::DST_MYSQL_JDBC: + _inout_rDisplayName = m_sMySQLEntry; + break; + case ::dbaccess::DST_MYSQL_ODBC: + case ::dbaccess::DST_MYSQL_NATIVE: + // don't display those, the decision whether the user connects via JDBC/ODBC/C-OOo is made on another + // page + _inout_rDisplayName = String(); + break; + default: + break; + } + } + + if ( eType == ::dbaccess::DST_MYSQL_NATIVE_DIRECT ) + { + // do not display the Connector/OOo driver itself, it is always wrapped via the MySQL-Driver, if + // this driver is installed + if ( m_pCollection->hasDriver( "sdbc:mysql:mysqlc:" ) ) + _inout_rDisplayName = String(); + } + + if ( eType == ::dbaccess::DST_EMBEDDED_HSQLDB ) + _inout_rDisplayName = String(); + + return _inout_rDisplayName.Len() > 0; + } + + + // ----------------------------------------------------------------------- + void OGeneralPage::insertDatasourceTypeEntryData(const ::rtl::OUString& _sType, String sDisplayName) + { + // insert a (temporary) entry + sal_uInt16 nPos = m_pDatasourceType->InsertEntry(sDisplayName); + if ( nPos >= m_aURLPrefixes.size() ) + m_aURLPrefixes.resize(nPos+1); + m_aURLPrefixes[nPos] = _sType; + } + + // ----------------------------------------------------------------------- + void OGeneralPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) + { + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aTypePreLabel)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aDatasourceTypeLabel)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aTypePostLabel)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aSpecialMessage)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDataSourceAppendix)); + } + // ----------------------------------------------------------------------- + void OGeneralPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) + { + _rControlList.push_back(new OSaveValueWrapper<ListBox>(m_pDatasourceType.get())); + } + + //------------------------------------------------------------------------- + SfxTabPage* OGeneralPage::Create(Window* _pParent, const SfxItemSet& _rAttrSet, sal_Bool _bWizardMode) + { + return ( new OGeneralPage( _pParent, _rAttrSet, _bWizardMode ) ); + } + + //------------------------------------------------------------------------- + void OGeneralPage::implSetCurrentType( const ::rtl::OUString& _eType ) + { + if ( _eType == m_eCurrentSelection ) + return; + + m_eCurrentSelection = _eType; + } + + //------------------------------------------------------------------------- + void OGeneralPage::Reset(const SfxItemSet& _rCoreAttrs) + { + // reset all locale data + implSetCurrentType( ::rtl::OUString() ); + // this ensures that our type selection link will be called, even if the new is is the same as the + // current one + OGenericAdministrationPage::Reset(_rCoreAttrs); + } + + //------------------------------------------------------------------------- + BOOL OGeneralPage::FillItemSet(SfxItemSet& _rCoreAttrs) + { + sal_Bool bChangedSomething = sal_False; + + bool bCommitTypeSelection = true; + if ( m_DBWizardMode ) + { + if ( m_aRB_CreateDatabase.IsChecked() ) + { + _rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:dbase:")))); + bChangedSomething = sal_True; + bCommitTypeSelection = false; + } + else if ( m_aRB_OpenDocument.IsChecked() ) + { + if ( m_aRB_OpenDocument.GetSavedValue() != m_aRB_OpenDocument.IsChecked() ) + bChangedSomething = sal_True; + + // TODO + bCommitTypeSelection = false; + } + } + + if ( bCommitTypeSelection ) + { + USHORT nEntry = m_pDatasourceType->GetSelectEntryPos(); + ::rtl::OUString sURLPrefix = m_aURLPrefixes[nEntry]; + if (m_DBWizardMode) + { + if ( ( m_pDatasourceType->GetSavedValue() != nEntry ) + || ( GetDatabaseCreationMode() != m_eOriginalCreationMode ) + ) + { + _rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL,sURLPrefix )); + bChangedSomething = sal_True; + } + else + implSetCurrentType(sURLPrefix); + } + else + { + if ( m_pDatasourceType->GetSavedValue() != nEntry) + { + _rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL, sURLPrefix)); + bChangedSomething = sal_True; + } + } + } + return bChangedSomething; + } + + //------------------------------------------------------------------------- + IMPL_LINK(OGeneralPage, OnDatasourceTypeSelected, ListBox*, _pBox) + { + // get the type from the entry data + sal_Int16 nSelected = _pBox->GetSelectEntryPos(); + const ::rtl::OUString sURLPrefix = m_aURLPrefixes[nSelected]; + + setParentTitle(sURLPrefix); + // let the impl method do all the stuff + onTypeSelected(sURLPrefix); + // tell the listener we were modified + callModifiedHdl(); + // outta here + return 0L; + } + + //------------------------------------------------------------------------- + OGeneralPage::DocumentDescriptor OGeneralPage::GetSelectedDocument() const + { + DocumentDescriptor aDocument; + if ( m_aBrowsedDocument.sURL.Len() ) + aDocument = m_aBrowsedDocument; + else + { + aDocument.sURL = m_pLB_DocumentList->GetSelectedDocumentURL(); + aDocument.sFilter = m_pLB_DocumentList->GetSelectedDocumentFilter(); + } + return aDocument; + } + + //------------------------------------------------------------------------- + IMPL_LINK(OGeneralPage, OnSetupModeSelected, RadioButton*, /*_pBox*/) + { + if ( m_aCreationModeHandler.IsSet() ) + m_aCreationModeHandler.Call(this); + return 1L; + } + + //------------------------------------------------------------------------- + IMPL_LINK(OGeneralPage, OnDocumentSelected, ListBox*, /*_pBox*/) + { + m_aDocumentSelectionHandler.Call( this ); + return 0L; + } + + //------------------------------------------------------------------------- + IMPL_LINK(OGeneralPage, OnOpenDocument, PushButton*, /*_pBox*/) + { + ::sfx2::FileDialogHelper aFileDlg( WB_OPEN, ::String::CreateFromAscii("sdatabase") ); + const SfxFilter* pFilter = getStandardDatabaseFilter(); + if ( pFilter ) + { +// aFileDlg.AddFilter(pFilter->GetUIName(),pFilter->GetDefaultExtension()); + aFileDlg.SetCurrentFilter(pFilter->GetUIName()); + } + if ( aFileDlg.Execute() == ERRCODE_NONE ) + { + String sPath = aFileDlg.GetPath(); + if ( aFileDlg.GetCurrentFilter() != pFilter->GetUIName() || !pFilter->GetWildcard().Matches(sPath) ) + { + String sMessage(ModuleRes(STR_ERR_USE_CONNECT_TO)); + InfoBox aError(this, sMessage); + aError.Execute(); + m_aRB_GetExistingDatabase.Check(); + OnSetupModeSelected(&m_aRB_GetExistingDatabase); + return 0L; + } + m_aBrowsedDocument.sURL = sPath; + m_aBrowsedDocument.sFilter = String(); + m_aChooseDocumentHandler.Call( this ); + return 1L; + } + + return 0L; + } + +//......................................................................... +} // namespace dbaui +//......................................................................... + diff --git a/dbaccess/source/ui/dlg/generalpage.hxx b/dbaccess/source/ui/dlg/generalpage.hxx new file mode 100644 index 000000000000..efd1e326d5cf --- /dev/null +++ b/dbaccess/source/ui/dlg/generalpage.hxx @@ -0,0 +1,177 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBAUI_GENERALPAGE_HXX_ +#define _DBAUI_GENERALPAGE_HXX_ + +#ifndef _DBAUI_ADMINPAGES_HXX_ +#include "adminpages.hxx" +#endif +#ifndef DBACCESS_SOURCE_UI_INC_OPENDOCCONTROLS_HXX +#include "opendoccontrols.hxx" +#endif +#ifndef _SV_FIXED_HXX +#include <vcl/fixed.hxx> +#endif +#ifndef _SV_LSTBOX_HXX +#include <vcl/lstbox.hxx> +#endif +#ifndef _SV_EDIT_HXX +#include <vcl/edit.hxx> +#endif +#include <svtools/dialogcontrolling.hxx> +#include <memory> + +//......................................................................... +namespace dbaui +{ +//......................................................................... + class IDatabaseSettingsDialog; + //========================================================================= + //= OGeneralPage + //========================================================================= + class OGeneralPage : public OGenericAdministrationPage + { + OGeneralPage(Window* pParent, const SfxItemSet& _rItems, sal_Bool _bDBWizardMode = sal_False); + ~OGeneralPage(); + + public: + enum CreationMode + { + eCreateNew, + eConnectExternal, + eOpenExisting + }; + + struct DocumentDescriptor + { + String sURL; + String sFilter; + }; + + private: + // dialog controls + FixedText m_aFTHeaderText; + FixedText m_aFTHelpText; + FixedText m_aFT_DatasourceTypeHeader; + RadioButton m_aRB_CreateDatabase; + RadioButton m_aRB_OpenDocument; + RadioButton m_aRB_GetExistingDatabase; + FixedText m_aFT_DocListLabel; + ::std::auto_ptr< OpenDocumentListBox > + m_pLB_DocumentList; + OpenDocumentButton m_aPB_OpenDocument; + FixedText m_aTypePreLabel; + FixedText m_aDatasourceTypeLabel; + ::std::auto_ptr< ListBox > + m_pDatasourceType; + FixedText m_aFTDataSourceAppendix; + FixedText m_aTypePostLabel; + FixedText m_aSpecialMessage; + sal_Bool m_DBWizardMode; + String m_sMySQLEntry; + CreationMode m_eOriginalCreationMode; + DocumentDescriptor m_aBrowsedDocument; + + ::svt::ControlDependencyManager + m_aControlDependencies; + ::std::vector< ::rtl::OUString> m_aURLPrefixes; + + + ::dbaccess::ODsnTypeCollection* + m_pCollection; /// the DSN type collection instance + ::rtl::OUString m_eCurrentSelection; /// currently selected type + ::dbaccess::DATASOURCE_TYPE m_eNotSupportedKnownType; /// if a data source of an unsupported, but known type is encountered .... + + enum SPECIAL_MESSAGE + { + smNone, + smUnsupportedType + }; + SPECIAL_MESSAGE m_eLastMessage; + + Link m_aTypeSelectHandler; /// to be called if a new type is selected + Link m_aCreationModeHandler; /// to be called if a new type is selected + Link m_aDocumentSelectionHandler; /// to be called when a document in the RecentDoc list is selected + Link m_aChooseDocumentHandler; /// to be called when a recent document has been definately chosen + sal_Bool m_bDisplayingInvalid : 1; // the currently displayed data source is deleted + sal_Bool m_bUserGrabFocus : 1; + bool m_bInitTypeList : 1; + bool approveDataSourceType( const ::rtl::OUString& _sURLPrefix, String& _inout_rDisplayName ); + void insertDatasourceTypeEntryData(const ::rtl::OUString& _sType, String sDisplayName); + + public: + static SfxTabPage* Create(Window* pParent, const SfxItemSet& _rAttrSet, sal_Bool _bDBWizardMode = sal_False); + + /// set a handler which gets called every time the user selects a new type + void SetTypeSelectHandler(const Link& _rHandler) { m_aTypeSelectHandler = _rHandler; } + void SetCreationModeHandler(const Link& _rHandler) { m_aCreationModeHandler = _rHandler; } + void SetDocumentSelectionHandler( const Link& _rHandler) { m_aDocumentSelectionHandler = _rHandler; } + void SetChooseDocumentHandler( const Link& _rHandler) { m_aChooseDocumentHandler = _rHandler; } + CreationMode GetDatabaseCreationMode() const; + + DocumentDescriptor GetSelectedDocument() const; + + /// get the currently selected datasource type + ::rtl::OUString GetSelectedType() const { return m_eCurrentSelection; } + + protected: + // SfxTabPage overridables + virtual BOOL FillItemSet(SfxItemSet& _rCoreAttrs); + virtual void Reset(const SfxItemSet& _rCoreAttrs); + + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + + virtual void GetFocus(); + + // <method>OGenericAdministrationPage::fillControls</method> + virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList); + // <method>OGenericAdministrationPage::fillWindows</method> + virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList); + + protected: + + void onTypeSelected(const ::rtl::OUString& _sURLPrefix); + void initializeTypeList(); + + void implSetCurrentType( const ::rtl::OUString& _eType ); + + void switchMessage(const ::rtl::OUString& _sURLPrefix); + + /// sets the the title of the parent dialog + void setParentTitle(const ::rtl::OUString& _sURLPrefix); + + DECL_LINK(OnDatasourceTypeSelected, ListBox*); + DECL_LINK(OnSetupModeSelected, RadioButton*); + DECL_LINK(OnDocumentSelected, ListBox*); + DECL_LINK(OnOpenDocument, PushButton*); + }; + +//......................................................................... +} // namespace dbaui +//......................................................................... +#endif // _DBAUI_GENERALPAGE_HXX_ diff --git a/dbaccess/source/ui/dlg/indexdialog.cxx b/dbaccess/source/ui/dlg/indexdialog.cxx new file mode 100644 index 000000000000..b9a0b0e75bfc --- /dev/null +++ b/dbaccess/source/ui/dlg/indexdialog.cxx @@ -0,0 +1,962 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#ifndef _DBAUI_INDEXDIALOG_HXX_ +#include "indexdialog.hxx" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif +#ifndef _DBAUI_INDEXDIALOG_HRC_ +#include "indexdialog.hrc" +#endif +#ifndef _DBAUI_INDEXFIELDSCONTROL_HXX_ +#include "indexfieldscontrol.hxx" +#endif +#ifndef _DBAUI_INDEXCOLLECTION_HXX_ +#include "indexcollection.hxx" +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif +#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_ +#include <com/sun/star/sdb/SQLContext.hpp> +#endif +#ifndef DBAUI_TOOLS_HXX +#include "UITools.hxx" +#endif +#ifndef _SVTOOLS_IMGDEF_HXX +#include <svtools/imgdef.hxx> +#endif +#ifndef DBACCESS_UI_BROWSER_ID_HXX +#include "browserids.hxx" +#endif +#ifndef _CONNECTIVITY_DBTOOLS_HXX_ +#include <connectivity/dbtools.hxx> +#endif +//...................................................................... +namespace dbaui +{ +//...................................................................... + + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::container; + using namespace ::com::sun::star::sdbc; + using namespace ::com::sun::star::sdb; + using namespace ::com::sun::star::lang; + using namespace ::dbtools; + + //================================================================== + //= helper + //================================================================== + //------------------------------------------------------------------ + sal_Bool operator ==(const OIndexField& _rLHS, const OIndexField& _rRHS) + { + return (_rLHS.sFieldName == _rRHS.sFieldName) + && (_rLHS.bSortAscending == _rRHS.bSortAscending); + } + + //------------------------------------------------------------------ + sal_Bool operator !=(const OIndexField& _rLHS, const OIndexField& _rRHS) + { + return !(_rLHS == _rRHS); + } + + //------------------------------------------------------------------ + sal_Bool operator ==(const IndexFields& _rLHS, const IndexFields& _rRHS) + { + if (_rLHS.size() != _rRHS.size()) + return sal_False; + + ConstIndexFieldsIterator aLeft = _rLHS.begin(); + ConstIndexFieldsIterator aLeftEnd = _rLHS.end(); + ConstIndexFieldsIterator aRight = _rRHS.begin(); + for (; aLeft != aLeftEnd; ++aLeft, ++aRight) + { + if (*aLeft != *aRight) + return sal_False; + } + + return sal_True; + } + + //------------------------------------------------------------------ + sal_Bool operator !=(const IndexFields& _rLHS, const IndexFields& _rRHS) + { + return !(_rLHS == _rRHS); + } + + //================================================================== + //= DbaIndexList + //================================================================== + //------------------------------------------------------------------ + DbaIndexList::DbaIndexList(Window* _pParent, const ResId& _rId) + :SvTreeListBox(_pParent, _rId) + ,m_bSuspendSelectHdl(sal_False) + { + } + + extern sal_Bool isCharOk(sal_Unicode _cChar,sal_Bool _bFirstChar,sal_Bool _bUpperCase,const ::rtl::OUString& _sAllowedChars); + //------------------------------------------------------------------ + sal_Bool DbaIndexList::EditedEntry( SvLBoxEntry* _pEntry, const String& _rNewText ) + { + // first check if this is valid SQL92 name + if ( isSQL92CheckEnabled(m_xConnection) ) + { + Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData(); + if ( xMeta.is() ) + { + ::rtl::OUString sNewName(_rNewText); + ::rtl::OUString sAlias = ::dbtools::convertName2SQLName(sNewName,xMeta->getExtraNameCharacters()); + if ( ( xMeta->supportsMixedCaseQuotedIdentifiers() ) + ? + sAlias != sNewName + : + !sNewName.equalsIgnoreAsciiCase(sAlias)) + return sal_False; + } + } + + if (!SvTreeListBox::EditedEntry(_pEntry, _rNewText)) + return sal_False; + + String sOldText = GetEntryText(_pEntry); + SvTreeListBox::SetEntryText(_pEntry, _rNewText); + + sal_Bool bValid = sal_True; + if (m_aEndEditHdl.IsSet()) + bValid = (0 != m_aEndEditHdl.Call(_pEntry)); + + if (bValid) + return sal_True; + + SvTreeListBox::SetEntryText(_pEntry, sOldText); + + return sal_False; + } + + //------------------------------------------------------------------ + void DbaIndexList::enableSelectHandler() + { + DBG_ASSERT(m_bSuspendSelectHdl, "DbaIndexList::enableSelectHandler: invalid call (this is not cumulative)!"); + m_bSuspendSelectHdl = sal_False; + } + + //------------------------------------------------------------------ + void DbaIndexList::disableSelectHandler() + { + DBG_ASSERT(!m_bSuspendSelectHdl, "DbaIndexList::enableSelectHandler: invalid call (this is not cumulative)!"); + m_bSuspendSelectHdl = sal_True; + } + + //------------------------------------------------------------------ + void DbaIndexList::SelectNoHandlerCall( SvLBoxEntry* _pEntry ) + { + disableSelectHandler(); + Select(_pEntry, sal_True); + enableSelectHandler(); + } + + //------------------------------------------------------------------ + sal_Bool DbaIndexList::Select( SvLBoxEntry* pEntry, sal_Bool _bSelect ) + { + sal_Bool bReturn = SvTreeListBox::Select(pEntry, _bSelect); + + if (m_aSelectHdl.IsSet() && !m_bSuspendSelectHdl && _bSelect) + m_aSelectHdl.Call(this); + + return bReturn; + } + + //================================================================== + //= DbaIndexDialog + //================================================================== +DBG_NAME(DbaIndexDialog) +//------------------------------------------------------------------ + DbaIndexDialog::DbaIndexDialog( Window* _pParent, const Sequence< ::rtl::OUString >& _rFieldNames, + const Reference< XNameAccess >& _rxIndexes, + const Reference< XConnection >& _rxConnection, + const Reference< XMultiServiceFactory >& _rxORB,sal_Int32 _nMaxColumnsInIndex) + :ModalDialog( _pParent, ModuleRes(DLG_INDEXDESIGN)) + ,m_xConnection(_rxConnection) + ,m_aGeometrySettings(E_DIALOG, ::rtl::OUString::createFromAscii("dbaccess.tabledesign.indexdialog")) + ,m_aActions (this, ModuleRes(TLB_ACTIONS)) + ,m_aIndexes (this, ModuleRes(CTR_INDEXLIST)) + ,m_aIndexDetails (this, ModuleRes(FL_INDEXDETAILS)) + ,m_aDescriptionLabel (this, ModuleRes(FT_DESC_LABEL)) + ,m_aDescription (this, ModuleRes(FT_DESCRIPTION)) + ,m_aUnique (this, ModuleRes(CB_UNIQUE)) + ,m_aFieldsLabel (this, ModuleRes(FT_FIELDS)) + ,m_pFields(new IndexFieldsControl (this, ModuleRes(CTR_FIELDS),_nMaxColumnsInIndex,::dbtools::getBooleanDataSourceSetting( m_xConnection, "AddIndexAppendix" ))) + ,m_aClose (this, ModuleRes(PB_CLOSE)) + ,m_aHelp (this, ModuleRes(HB_HELP)) + ,m_pIndexes(NULL) + ,m_pPreviousSelection(NULL) + ,m_bEditAgain(sal_False) + ,m_xORB(_rxORB) + { + DBG_CTOR(DbaIndexDialog,NULL); + + FreeResource(); + + m_aActions.SetSelectHdl(LINK(this, DbaIndexDialog, OnIndexAction)); + + m_aIndexes.SetSelectHdl(LINK(this, DbaIndexDialog, OnIndexSelected)); + m_aIndexes.SetEndEditHdl(LINK(this, DbaIndexDialog, OnEntryEdited)); + m_aIndexes.SetSelectionMode(SINGLE_SELECTION); + m_aIndexes.SetHighlightRange(); + m_aIndexes.setConnection(m_xConnection); + + m_pFields->Init(_rFieldNames); + + setToolBox(&m_aActions); + + m_pIndexes = new OIndexCollection(); + try + { + m_pIndexes->attach(_rxIndexes); + } + catch(SQLException& e) + { + ::dbaui::showError(SQLExceptionInfo(e),_pParent,_rxORB); + } + catch(Exception&) + { + OSL_ENSURE(sal_False, "DbaIndexDialog::DbaIndexDialog: could not retrieve basic information from the UNO collection!"); + } + + fillIndexList(); + + m_aUnique.SetClickHdl(LINK(this, DbaIndexDialog, OnModified)); + m_pFields->SetModifyHdl(LINK(this, DbaIndexDialog, OnModified)); + + m_aClose.SetClickHdl(LINK(this, DbaIndexDialog, OnCloseDialog)); + + // get our most recent geometry settings +// if (m_aGeometrySettings.Exists()) +// { +// Point aPos; +// m_aGeometrySettings.GetPosition(aPos.X(), aPos.Y()); +// SetPosPixel(aPos); +// } + + // if all of the indexes have an empty description, we're not interested in displaying it + Indexes::const_iterator aCheck; + + for ( aCheck = m_pIndexes->begin(); + aCheck != m_pIndexes->end(); + ++aCheck + ) + { + if (aCheck->sDescription.getLength()) + break; + } + + if (aCheck == m_pIndexes->end()) + { + sal_Int32 nMoveUp = m_aUnique.GetPosPixel().Y() - m_aDescriptionLabel.GetPosPixel().Y(); + + // hide the controls which are necessary for the description + m_aDescription.Hide(); + m_aDescriptionLabel.Hide(); + + // move other controls up + Point aPos = m_aUnique.GetPosPixel(); + aPos.Y() -= nMoveUp; + m_aUnique.SetPosPixel(aPos); + + aPos = m_aFieldsLabel.GetPosPixel(); + aPos.Y() -= nMoveUp; + m_aFieldsLabel.SetPosPixel(aPos); + + aPos = m_pFields->GetPosPixel(); + aPos.Y() -= nMoveUp; + m_pFields->SetPosPixel(aPos); + + // and enlarge the fields list + Size aSize = m_pFields->GetSizePixel(); + aSize.Height() += nMoveUp; + m_pFields->SetSizePixel(aSize); + } + } + + //------------------------------------------------------------------ + void DbaIndexDialog::updateToolbox() + { + m_aActions.EnableItem(ID_INDEX_NEW, !m_aIndexes.IsEditingActive()); + + SvLBoxEntry* pSelected = m_aIndexes.FirstSelected(); + sal_Bool bSelectedAnything = NULL != pSelected; + + + if (pSelected) + { + // is the current entry modified? + Indexes::const_iterator aSelectedPos = m_pIndexes->begin() + reinterpret_cast<sal_IntPtr>(pSelected->GetUserData()); + m_aActions.EnableItem(ID_INDEX_SAVE, aSelectedPos->isModified() || aSelectedPos->isNew()); + m_aActions.EnableItem(ID_INDEX_RESET, aSelectedPos->isModified() || aSelectedPos->isNew()); + bSelectedAnything = bSelectedAnything && !aSelectedPos->bPrimaryKey; + } + else + { + m_aActions.EnableItem(ID_INDEX_SAVE, sal_False); + m_aActions.EnableItem(ID_INDEX_RESET, sal_False); + } + m_aActions.EnableItem(ID_INDEX_DROP, bSelectedAnything); + m_aActions.EnableItem(ID_INDEX_RENAME, bSelectedAnything); + } + + //------------------------------------------------------------------ + void DbaIndexDialog::fillIndexList() + { + sal_Bool bHiContrast = GetSettings().GetStyleSettings().GetHighContrastMode(); + Image aPKeyIcon(ModuleRes( bHiContrast ? IMG_PKEYICON_SCH : IMG_PKEYICON)); + // fill the list with the index names + m_aIndexes.Clear(); + Indexes::iterator aIndexLoop = m_pIndexes->begin(); + Indexes::iterator aEnd = m_pIndexes->end(); + for (; aIndexLoop != aEnd; ++aIndexLoop) + { + SvLBoxEntry* pNewEntry = NULL; + if (aIndexLoop->bPrimaryKey) + pNewEntry = m_aIndexes.InsertEntry(aIndexLoop->sName, aPKeyIcon, aPKeyIcon); + else + pNewEntry = m_aIndexes.InsertEntry(aIndexLoop->sName); + + pNewEntry->SetUserData(reinterpret_cast< void* >(sal_Int32(aIndexLoop - m_pIndexes->begin()))); + } + + OnIndexSelected(&m_aIndexes); + } + + //------------------------------------------------------------------ + DbaIndexDialog::~DbaIndexDialog( ) + { + setToolBox(NULL); + delete m_pIndexes; + delete m_pFields; + + // save our geometry settings +// Point aPos = GetPosPixel(); +// m_aGeometrySettings.SetPosition(aPos.X(), aPos.Y()); + + DBG_DTOR(DbaIndexDialog,NULL); + } + + //------------------------------------------------------------------ + sal_Bool DbaIndexDialog::implCommit(SvLBoxEntry* _pEntry) + { + DBG_ASSERT(_pEntry, "DbaIndexDialog::implCommit: invalid entry!"); + + Indexes::iterator aCommitPos = m_pIndexes->begin() + reinterpret_cast<sal_IntPtr>(_pEntry->GetUserData()); + + // if it's not a new index, remove it + // (we can't modify indexes, only drop'n'insert) + if (!aCommitPos->isNew()) + if (!implDropIndex(_pEntry, sal_False)) + return sal_False; + + // create the new index + SQLExceptionInfo aExceptionInfo; + try + { + m_pIndexes->commitNewIndex(aCommitPos); + } + catch(SQLContext& e) { aExceptionInfo = SQLExceptionInfo(e); } + catch(SQLWarning& e) { aExceptionInfo = SQLExceptionInfo(e); } + catch(SQLException& e) { aExceptionInfo = SQLExceptionInfo(e); } + + // reflect the new selection in the toolbox + updateToolbox(); + + if (aExceptionInfo.isValid()) + showError(aExceptionInfo, this, m_xORB); + else + { + m_aUnique.SaveValue(); + m_pFields->SaveValue(); + } + + return !aExceptionInfo.isValid(); + } + + //------------------------------------------------------------------ + void DbaIndexDialog::OnNewIndex() + { + // commit the current entry, if necessary + if (!implCommitPreviouslySelected()) + return; + + // get a new unique name for the new index + String sNewIndexName; + const String sNewIndexNameBase(ModuleRes(STR_LOGICAL_INDEX_NAME)); + sal_Int32 i; + + for ( i = 1; i < 0x7FFFFFFF; ++i ) + { + sNewIndexName = sNewIndexNameBase; + sNewIndexName += String::CreateFromInt32(i); + if (m_pIndexes->end() == m_pIndexes->find(sNewIndexName)) + break; + } + if ((i>0x7FFFFFFF) || (i<0)) + { + DBG_ERROR("DbaIndexDialog::OnNewIndex: no free index name found!"); + // can't do anything ... of course we try another base, but this could end with the same result ... + return; + } + + SvLBoxEntry* pNewEntry = m_aIndexes.InsertEntry(sNewIndexName); + m_pIndexes->insert(sNewIndexName); + + // update the user data on the entries in the list box: + // they're iterators of the index collection, and thus they have changed when removing the index + for (SvLBoxEntry* pAdjust = m_aIndexes.First(); pAdjust; pAdjust = m_aIndexes.Next(pAdjust)) + { + Indexes::iterator aAfterInsertPos = m_pIndexes->find(m_aIndexes.GetEntryText(pAdjust)); + DBG_ASSERT(aAfterInsertPos != m_pIndexes->end(), "DbaIndexDialog::OnNewIndex: problems with on of the entries!"); + pAdjust->SetUserData(reinterpret_cast< void* >(sal_Int32(aAfterInsertPos - m_pIndexes->begin()))); + } + + // select the entry and start in-place editing + m_aIndexes.SelectNoHandlerCall(pNewEntry); + OnIndexSelected(&m_aIndexes); + m_aIndexes.EditEntry(pNewEntry); + updateToolbox(); + } + + //------------------------------------------------------------------ + void DbaIndexDialog::OnDropIndex(sal_Bool _bConfirm) + { + // the selected index + SvLBoxEntry* pSelected = m_aIndexes.FirstSelected(); + DBG_ASSERT(pSelected, "DbaIndexDialog::OnDropIndex: invalid call!"); + if (pSelected) + { + // let the user confirm the drop + if (_bConfirm) + { + String sConfirm(ModuleRes(STR_CONFIRM_DROP_INDEX)); + sConfirm.SearchAndReplaceAscii("$name$", m_aIndexes.GetEntryText(pSelected)); + QueryBox aConfirm(this, WB_YES_NO, sConfirm); + if (RET_YES != aConfirm.Execute()) + return; + } + + // do the drop + implDropIndex(pSelected, sal_True); + + // reflect the new selection in the toolbox + updateToolbox(); + } + } + + //------------------------------------------------------------------ + sal_Bool DbaIndexDialog::implDropIndex(SvLBoxEntry* _pEntry, sal_Bool _bRemoveFromCollection) + { + // do the drop + Indexes::iterator aDropPos = m_pIndexes->begin() + reinterpret_cast<sal_IntPtr>(_pEntry->GetUserData()); + DBG_ASSERT(aDropPos != m_pIndexes->end(), "DbaIndexDialog::OnDropIndex: did not find the index in my collection!"); + + SQLExceptionInfo aExceptionInfo; + sal_Bool bSuccess = sal_False; + try + { + if (_bRemoveFromCollection) + bSuccess = m_pIndexes->drop(aDropPos); + else + bSuccess = m_pIndexes->dropNoRemove(aDropPos); + } + catch(SQLContext& e) { aExceptionInfo = SQLExceptionInfo(e); } + catch(SQLWarning& e) { aExceptionInfo = SQLExceptionInfo(e); } + catch(SQLException& e) { aExceptionInfo = SQLExceptionInfo(e); } + + if (aExceptionInfo.isValid()) + showError(aExceptionInfo, this, m_xORB); + else if (bSuccess && _bRemoveFromCollection) + { + SvLBoxTreeList* pModel = m_aIndexes.GetModel(); + + m_aIndexes.disableSelectHandler(); + pModel->Remove(_pEntry); + m_aIndexes.enableSelectHandler(); + + // update the user data on the entries in the list box: + // they're iterators of the index collection, and thus they have changed when removing the index + for (SvLBoxEntry* pAdjust = m_aIndexes.First(); pAdjust; pAdjust = m_aIndexes.Next(pAdjust)) + { + Indexes::iterator aAfterDropPos = m_pIndexes->find(m_aIndexes.GetEntryText(pAdjust)); + DBG_ASSERT(aAfterDropPos != m_pIndexes->end(), "DbaIndexDialog::OnDropIndex: problems with on of the remaining entries!"); + pAdjust->SetUserData(reinterpret_cast< void* >(sal_Int32(aAfterDropPos - m_pIndexes->begin()))); + } + + // if the remvoved entry was the selected on ... + if (m_pPreviousSelection == _pEntry) + m_pPreviousSelection = NULL; + + // the Remove automatically selected another entry (if possible), but we disabled the calling of the handler + // to prevent that we missed something ... call the handler directly + OnIndexSelected(&m_aIndexes); + } + + return !aExceptionInfo.isValid(); + } + + //------------------------------------------------------------------ + void DbaIndexDialog::OnRenameIndex() + { + // the selected index + SvLBoxEntry* pSelected = m_aIndexes.FirstSelected(); + DBG_ASSERT(pSelected, "DbaIndexDialog::OnRenameIndex: invalid call!"); + + // save the changes made 'til here + // Upon leaving the edit mode, the control will be re-initialized with the + // settings from the current entry + implSaveModified(sal_False); + + m_aIndexes.EditEntry(pSelected); + updateToolbox(); + } + + //------------------------------------------------------------------ + void DbaIndexDialog::OnSaveIndex() + { + // the selected index +#if OSL_DEBUG_LEVEL > 0 + SvLBoxEntry* pSelected = m_aIndexes.FirstSelected(); + OSL_ENSURE( pSelected, "DbaIndexDialog::OnSaveIndex: invalid call!" ); +#endif + + implCommitPreviouslySelected(); + updateToolbox(); + } + + //------------------------------------------------------------------ + void DbaIndexDialog::OnResetIndex() + { + // the selected index + SvLBoxEntry* pSelected = m_aIndexes.FirstSelected(); + DBG_ASSERT(pSelected, "DbaIndexDialog::OnResetIndex: invalid call!"); + + Indexes::iterator aResetPos = m_pIndexes->begin() + reinterpret_cast<sal_IntPtr>(pSelected->GetUserData()); + + if (aResetPos->isNew()) + { + OnDropIndex(sal_False); + return; + } + + SQLExceptionInfo aExceptionInfo; + try + { + m_pIndexes->resetIndex(aResetPos); + } + catch(SQLContext& e) { aExceptionInfo = SQLExceptionInfo(e); } + catch(SQLWarning& e) { aExceptionInfo = SQLExceptionInfo(e); } + catch(SQLException& e) { aExceptionInfo = SQLExceptionInfo(e); } + + if (aExceptionInfo.isValid()) + showError(aExceptionInfo, this, m_xORB); + else + m_aIndexes.SetEntryText(pSelected, aResetPos->sName); + + updateControls(pSelected); + updateToolbox(); + } + + //------------------------------------------------------------------ + IMPL_LINK( DbaIndexDialog, OnIndexAction, ToolBox*, /*NOTINTERESTEDIN*/ ) + { + sal_uInt16 nClicked = m_aActions.GetCurItemId(); + switch (nClicked) + { + case ID_INDEX_NEW: + OnNewIndex(); + break; + case ID_INDEX_DROP: + OnDropIndex(); + break; + case ID_INDEX_RENAME: + OnRenameIndex(); + break; + case ID_INDEX_SAVE: + OnSaveIndex(); + break; + case ID_INDEX_RESET: + OnResetIndex(); + break; + } + return 0L; + } + + //------------------------------------------------------------------ + IMPL_LINK( DbaIndexDialog, OnCloseDialog, void*, /*NOTINTERESTEDIN*/ ) + { + if (m_aIndexes.IsEditingActive()) + { + DBG_ASSERT(!m_bEditAgain, "DbaIndexDialog::OnCloseDialog: somebody was faster than hell!"); + // this means somebody entered a new name, which was invalid, which cause us to posted us an event, + // and before the event arrived the user clicked onto "close". VERY fast, this user .... + m_aIndexes.EndEditing(sal_False); + if (m_bEditAgain) + // could not commit the new name (started a new - asynchronous - edit trial) + return 1L; + } + + // the currently selected entry + const SvLBoxEntry* pSelected = m_aIndexes.FirstSelected(); + DBG_ASSERT(pSelected == m_pPreviousSelection, "DbaIndexDialog::OnCloseDialog: inconsistence!"); + + sal_Int32 nResponse = RET_NO; + if (pSelected) + { + // the descriptor + Indexes::const_iterator aSelected = m_pIndexes->begin() + reinterpret_cast<sal_IntPtr>(pSelected->GetUserData()); + + if (aSelected->isModified() || aSelected->isNew()) + { + QueryBox aQuestion(this, ModuleRes(QUERY_SAVE_CURRENT_INDEX)); + nResponse = aQuestion.Execute(); + } + } + + switch (nResponse) + { + case RET_YES: + if (!implCommitPreviouslySelected()) + return 1L; + break; + case RET_NO: + break; + default: + return 1L; + } + + EndDialog(RET_OK); + + return 0L; + } + + //------------------------------------------------------------------ + IMPL_LINK( DbaIndexDialog, OnEditIndexAgain, SvLBoxEntry*, _pEntry ) + { + m_bEditAgain = sal_False; + m_aIndexes.EditEntry(_pEntry); + return 0L; + } + + //------------------------------------------------------------------ + IMPL_LINK( DbaIndexDialog, OnEntryEdited, SvLBoxEntry*, _pEntry ) + { + Indexes::iterator aPosition = m_pIndexes->begin() + reinterpret_cast<sal_IntPtr>(_pEntry->GetUserData()); + + DBG_ASSERT(aPosition >= m_pIndexes->begin() && aPosition < m_pIndexes->end(), + "DbaIndexDialog::OnEntryEdited: invalid entry!"); + + String sNewName = m_aIndexes.GetEntryText(_pEntry); + + Indexes::const_iterator aSameName = m_pIndexes->find(sNewName); + if ((aSameName != aPosition) && (m_pIndexes->end() != aSameName)) + { + String sError(ModuleRes(STR_INDEX_NAME_ALREADY_USED)); + sError.SearchAndReplaceAscii("$name$", sNewName); + ErrorBox aError(this, WB_OK, sError); + aError.Execute(); + + updateToolbox(); + m_bEditAgain = sal_True; + PostUserEvent(LINK(this, DbaIndexDialog, OnEditIndexAgain), _pEntry); + return 0L; + } + + aPosition->sName = sNewName; + + // rename can be done by a drop/insert combination only + if (aPosition->isNew()) + { + updateToolbox(); + // no commitment needed here .... + return 1L; + } + + if (aPosition->sName != aPosition->getOriginalName()) + { + aPosition->setModified(sal_True); + updateToolbox(); + } + + return 1L; + } + + //------------------------------------------------------------------ + sal_Bool DbaIndexDialog::implSaveModified(sal_Bool _bPlausibility) + { + if (m_pPreviousSelection) + { + // try to commit the previously selected index + if (m_pFields->IsModified() && !m_pFields->SaveModified()) + return sal_False; + + Indexes::iterator aPreviouslySelected = m_pIndexes->begin() + reinterpret_cast<sal_IntPtr>(m_pPreviousSelection->GetUserData()); + + // the unique flag + aPreviouslySelected->bUnique = m_aUnique.IsChecked(); + if (m_aUnique.GetSavedValue() != m_aUnique.GetState()) + aPreviouslySelected->setModified(sal_True); + + // the fields + m_pFields->commitTo(aPreviouslySelected->aFields); + if (m_pFields->GetSavedValue() != aPreviouslySelected->aFields) + aPreviouslySelected->setModified(sal_True); + + // plausibility checks + if (_bPlausibility && !implCheckPlausibility(aPreviouslySelected)) + return sal_False; + } + + return sal_True; + } + + //------------------------------------------------------------------ + sal_Bool DbaIndexDialog::implCheckPlausibility(const ConstIndexesIterator& _rPos) + { + // need at least one field + if (0 == _rPos->aFields.size()) + { + ErrorBox aError(this, ModuleRes(ERR_NEED_INDEX_FIELDS)); + aError.Execute(); + m_pFields->GrabFocus(); + return sal_False; + } + + // no double fields + DECLARE_STL_STDKEY_SET( String, StringBag ); + StringBag aExistentFields; + for ( ConstIndexFieldsIterator aFieldCheck = _rPos->aFields.begin(); + aFieldCheck != _rPos->aFields.end(); + ++aFieldCheck + ) + { + if (aExistentFields.end() != aExistentFields.find(aFieldCheck->sFieldName)) + { + // a column is specified twice ... won't work anyway, so prevent this here and now + String sMessage(ModuleRes(STR_INDEXDESIGN_DOUBLE_COLUMN_NAME)); + sMessage.SearchAndReplaceAscii("$name$", aFieldCheck->sFieldName); + ErrorBox aError(this, WB_OK, sMessage); + aError.Execute(); + m_pFields->GrabFocus(); + return sal_False; + } + aExistentFields.insert(aFieldCheck->sFieldName); + } + + return sal_True; + } + + //------------------------------------------------------------------ + sal_Bool DbaIndexDialog::implCommitPreviouslySelected() + { + if (m_pPreviousSelection) + { + Indexes::iterator aPreviouslySelected = m_pIndexes->begin() + reinterpret_cast<sal_IntPtr>(m_pPreviousSelection->GetUserData()); + + if (!implSaveModified()) + return sal_False; + + // commit the index (if necessary) + if (aPreviouslySelected->isModified() && !implCommit(m_pPreviousSelection)) + return sal_False; + } + + return sal_True; + } + + //------------------------------------------------------------------ + IMPL_LINK( DbaIndexDialog, OnModified, void*, /*NOTINTERESTEDIN*/ ) + { + DBG_ASSERT(m_pPreviousSelection, "DbaIndexDialog, OnModified: invalid call!"); + Indexes::iterator aPosition = m_pIndexes->begin() + reinterpret_cast<sal_IntPtr>(m_pPreviousSelection->GetUserData()); + + aPosition->setModified(sal_True); + updateToolbox(); + + return 1L; + } + + //------------------------------------------------------------------ + void DbaIndexDialog::updateControls(const SvLBoxEntry* _pEntry) + { + if (_pEntry) + { + // the descriptor of the selected index + Indexes::const_iterator aSelectedIndex = m_pIndexes->begin() + reinterpret_cast<sal_IntPtr>(_pEntry->GetUserData()); + + // fill the controls + m_aUnique.Check(aSelectedIndex->bUnique); + m_aUnique.Enable(!aSelectedIndex->bPrimaryKey); + m_aUnique.SaveValue(); + + m_pFields->initializeFrom(aSelectedIndex->aFields); + m_pFields->Enable(!aSelectedIndex->bPrimaryKey); + m_pFields->SaveValue(); + + m_aDescription.SetText(aSelectedIndex->sDescription); + m_aDescription.Enable(!aSelectedIndex->bPrimaryKey); + + m_aDescriptionLabel.Enable(!aSelectedIndex->bPrimaryKey); + } + else + { + m_aUnique.Check(sal_False); + m_pFields->initializeFrom(IndexFields()); + m_aDescription.SetText(String()); + } + } + + //------------------------------------------------------------------ + IMPL_LINK( DbaIndexDialog, OnIndexSelected, DbaIndexList*, /*NOTINTERESTEDIN*/ ) + { + m_aIndexes.EndSelection(); + + if (m_aIndexes.IsEditingActive()) + m_aIndexes.EndEditing(sal_False); + + // commit the old data + if (m_aIndexes.FirstSelected() != m_pPreviousSelection) + { // (this call may happen in case somebody ended an in-place edit with 'return', so we need to check this before committing) + if (!implCommitPreviouslySelected()) + { + m_aIndexes.SelectNoHandlerCall(m_pPreviousSelection); + return 1L; + } + } + + sal_Bool bHaveSelection = (NULL != m_aIndexes.FirstSelected()); + + // disable/enable the detail controls + m_aIndexDetails.Enable(bHaveSelection); + m_aUnique.Enable(bHaveSelection); + m_aDescriptionLabel.Enable(bHaveSelection); + m_aFieldsLabel.Enable(bHaveSelection); + m_pFields->Enable(bHaveSelection); + + SvLBoxEntry* pNewSelection = m_aIndexes.FirstSelected(); + updateControls(pNewSelection); + if (bHaveSelection) + m_aIndexes.GrabFocus(); + + m_pPreviousSelection = pNewSelection; + + updateToolbox(); + return 0L; + } + // ----------------------------------------------------------------------------- + void DbaIndexDialog::StateChanged( StateChangedType nType ) + { + ModalDialog::StateChanged( nType ); + + if ( nType == STATE_CHANGE_CONTROLBACKGROUND ) + { + // Check if we need to get new images for normal/high contrast mode + checkImageList(); + } + else if ( nType == STATE_CHANGE_TEXT ) + { + // The physical toolbar changed its outlook and shows another logical toolbar! + // We have to set the correct high contrast mode on the new tbx manager. + // pMgr->SetHiContrast( IsHiContrastMode() ); + checkImageList(); + } + } + // ----------------------------------------------------------------------------- + void DbaIndexDialog::DataChanged( const DataChangedEvent& rDCEvt ) + { + ModalDialog::DataChanged( rDCEvt ); + + if ((( rDCEvt.GetType() == DATACHANGED_SETTINGS ) || + ( rDCEvt.GetType() == DATACHANGED_DISPLAY )) && + ( rDCEvt.GetFlags() & SETTINGS_STYLE )) + { + // Check if we need to get new images for normal/high contrast mode + checkImageList(); + } + } + //------------------------------------------------------------------ + ImageList DbaIndexDialog::getImageList(sal_Int16 _eBitmapSet,sal_Bool _bHiContast) const + { + sal_Int16 nN = IMG_INDEX_DLG_SC; + sal_Int16 nH = IMG_INDEX_DLG_SCH; + if ( _eBitmapSet == SFX_SYMBOLS_SIZE_LARGE ) + { + nN = IMG_INDEX_DLG_LC; + nH = IMG_INDEX_DLG_LCH; + } // if ( _eBitmapSet == SFX_SYMBOLS_LARGE ) + return ImageList(ModuleRes( _bHiContast ? nH : nN )); + } + //------------------------------------------------------------------ + void DbaIndexDialog::resizeControls(const Size& _rDiff) + { + // we use large images so we must change them + Size aTbNewSize = m_aActions.GetSizePixel(); + if ( _rDiff.Width() || _rDiff.Height() ) + { + Size aDlgSize = GetSizePixel(); + // adjust size of dlg + SetSizePixel(Size(aDlgSize.Width() + _rDiff.Width(), + aDlgSize.Height() + _rDiff.Height()) + ); + Size aIndexSize = m_aIndexes.GetSizePixel(); + m_aIndexes.SetPosSizePixel(m_aIndexes.GetPosPixel() + Point(0,_rDiff.Height()), + Size(aIndexSize.Width() + _rDiff.Width(), + aIndexSize.Height())); + + //now move the rest to the left side + Point aMove(_rDiff.Width(),_rDiff.Height()); + m_aIndexDetails.SetPosPixel(m_aIndexDetails.GetPosPixel() + aMove); + m_aDescriptionLabel.SetPosPixel(m_aDescriptionLabel.GetPosPixel() + aMove); + m_aDescription.SetPosPixel(m_aDescription.GetPosPixel() + aMove); + m_aUnique.SetPosPixel(m_aUnique.GetPosPixel() + aMove); + m_aFieldsLabel.SetPosPixel(m_aFieldsLabel.GetPosPixel() + aMove); + OSL_ENSURE(m_pFields,"NO valid fields!"); + m_pFields->SetPosPixel(m_pFields->GetPosPixel() + aMove); + m_aClose.SetPosPixel(m_aClose.GetPosPixel() + aMove); + m_aHelp.SetPosPixel(m_aHelp.GetPosPixel() + aMove); + + Invalidate(); + } + } + +//...................................................................... +} // namespace dbaui +//...................................................................... + diff --git a/dbaccess/source/ui/dlg/indexdialog.hrc b/dbaccess/source/ui/dlg/indexdialog.hrc new file mode 100644 index 000000000000..825e96de2edc --- /dev/null +++ b/dbaccess/source/ui/dlg/indexdialog.hrc @@ -0,0 +1,49 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBAUI_INDEXDIALOG_HRC_ +#define _DBAUI_INDEXDIALOG_HRC_ + + +#define CTR_INDEXLIST 1 +#define CTR_FIELDS 2 + +#define FL_INDEXDETAILS 1 + +#define CB_UNIQUE 1 + +#define FT_FIELDS 1 +#define FT_DESC_LABEL 2 +#define FT_DESCRIPTION 3 + +#define TLB_ACTIONS 1 + +#define PB_CLOSE 1 + +#define HB_HELP 1 + +#endif // _DBAUI_INDEXDIALOG_HRC_ diff --git a/dbaccess/source/ui/dlg/indexdialog.src b/dbaccess/source/ui/dlg/indexdialog.src new file mode 100644 index 000000000000..ae8f80d6c616 --- /dev/null +++ b/dbaccess/source/ui/dlg/indexdialog.src @@ -0,0 +1,236 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef _DBAUI_INDEXDIALOG_HRC_ +#include "indexdialog.hrc" +#endif +#ifndef DBACCESS_UI_BROWSER_ID_HXX +#include "browserids.hxx" +#endif +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif + +#define DIALOG_SIZE_X 220 +#define DIALOG_SIZE_Y 140 +#define BUTTON_SIZE_X 50 +#define BUTTON_SIZE_Y 14 + +#define LIST_WIDTH 70 + +ModalDialog DLG_INDEXDESIGN +{ + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( DIALOG_SIZE_X , DIALOG_SIZE_Y ) ; + Text [ en-US ] = "Indexes" ; + Moveable = TRUE ; + Closeable = TRUE ; + + ToolBox TLB_ACTIONS + { + Pos = MAP_APPFONT ( 6 , 6 ) ; + // Size = MAP_APPFONT ( DIALOG_SIZE_X - 14 , 14 ) ; + ButtonType = BUTTON_SYMBOL; + Align = BOXALIGN_TOP; + HelpId = HID_INDEX_DIALOG_ACTION_TB; + Customize = FALSE; + ItemImageList = IMG_INDEX_DLG_SC ; + + ItemList = + { + ToolBoxItem + { + Identifier = ID_INDEX_NEW; + HelpId = HID_DLGIDX_NEWINDEX; + Command = ".index:createNew"; + Text [ en-US ] = "New Index" ; + }; + ToolBoxItem + { + Identifier = ID_INDEX_DROP; + HelpId = HID_DLGIDX_DROPINDEX; + Command = ".index:dropCurrent"; + Text [ en-US ] = "Delete Current Index" ; + }; + ToolBoxItem + { + Identifier = ID_INDEX_RENAME; + HelpId = HID_DLGIDX_RENAMEINDEX; + Command = ".index:renameCurrent"; + Text [ en-US ] = "Rename Current Index" ; + }; + ToolBoxItem + { + Identifier = ID_INDEX_SAVE; + HelpId = HID_DLGIDX_SAVEINDEX; + Command = ".index:saveCurrent"; + Text [ en-US ] = "Save Current Index" ; + }; + ToolBoxItem + { + Identifier = ID_INDEX_RESET; + HelpId = HID_DLGIDX_RESETINDEX; + Command = ".index:resetCurrent"; + Text [ en-US ] = "Reset Current Index" ; + }; + }; + }; + Control CTR_INDEXLIST + { + Pos = MAP_APPFONT ( 6 , 23 ) ; + Size = MAP_APPFONT ( LIST_WIDTH , DIALOG_SIZE_Y - (BUTTON_SIZE_Y + 4) - 29 ) ; + SVLook = TRUE; + Border = TRUE; + + HelpId = HID_DLGIDX_INDEXLIST; + TabStop = TRUE ; + }; + FixedLine FL_INDEXDETAILS + { + Pos = MAP_APPFONT ( LIST_WIDTH + 16 - 3, 9 ) ; + Size = MAP_APPFONT ( DIALOG_SIZE_X - LIST_WIDTH - 22, 8 ) ; + Text [ en-US ] = "Index details"; + }; + FixedText FT_DESC_LABEL + { + Pos = MAP_APPFONT ( LIST_WIDTH + 16, 23 ) ; + Size = MAP_APPFONT ( 50, 8 ) ; + Text [ en-US ] = "Index identifier:"; + }; + FixedText FT_DESCRIPTION + { + Pos = MAP_APPFONT ( LIST_WIDTH + 69, 23 ) ; + Size = MAP_APPFONT ( DIALOG_SIZE_X - LIST_WIDTH - 75, 8 ) ; + }; + CheckBox CB_UNIQUE + { + Pos = MAP_APPFONT ( LIST_WIDTH + 16, 34 ) ; + Size = MAP_APPFONT ( DIALOG_SIZE_X - LIST_WIDTH - 22, 8 ) ; + SVLook = TRUE; + Text [ en-US ] = "~Unique"; + }; + FixedText FT_FIELDS + { + Pos = MAP_APPFONT ( LIST_WIDTH + 16, 48 ) ; + Size = MAP_APPFONT ( DIALOG_SIZE_X - LIST_WIDTH - 22, 8 ) ; + SVLook = TRUE; + Text [ en-US ] = "Fields"; + }; + Control CTR_FIELDS + { + Pos = MAP_APPFONT ( LIST_WIDTH + 16, 59 ) ; + Size = MAP_APPFONT ( DIALOG_SIZE_X - LIST_WIDTH - 22, DIALOG_SIZE_Y - (BUTTON_SIZE_Y + 4) - 65 ) ; + SVLook = TRUE; + Border = TRUE; + TabStop = TRUE ; + }; + PushButton PB_CLOSE + { + Pos = MAP_APPFONT ( DIALOG_SIZE_X - BUTTON_SIZE_X - 6 - BUTTON_SIZE_X - 6, DIALOG_SIZE_Y - BUTTON_SIZE_Y - 6 ) ; + Size = MAP_APPFONT ( BUTTON_SIZE_X, BUTTON_SIZE_Y ); + SVLook = TRUE; + DefButton = TRUE; + Text [ en-US ] = "~Close"; + }; + HelpButton HB_HELP + { + Pos = MAP_APPFONT ( DIALOG_SIZE_X - BUTTON_SIZE_X - 6, DIALOG_SIZE_Y - BUTTON_SIZE_Y - 6 ) ; + Size = MAP_APPFONT ( BUTTON_SIZE_X, BUTTON_SIZE_Y ); + }; +}; + +String STR_TAB_INDEX_SORTORDER +{ + Text [ en-US ] = "Sort order" ; +}; +String STR_TAB_INDEX_FIELD +{ + Text [ en-US ] = "Index field" ; +}; +String STR_ORDER_ASCENDING +{ + Text [ en-US ] = "Ascending" ; +}; +String STR_ORDER_DESCENDING +{ + Text [ en-US ] = "Descending" ; +}; + +String STR_CONFIRM_DROP_INDEX +{ + Text [ en-US ] = "Do you really want to delete the index '$name$'?"; +}; + +String STR_LOGICAL_INDEX_NAME +{ + Text [ en-US ] = "index"; +}; + +Image IMG_PKEYICON +{ + ImageBitmap = Bitmap { File = "pkey.bmp"; }; + MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; }; +}; +Image IMG_PKEYICON_SCH +{ + ImageBitmap = Bitmap { File = "pkey_sch.bmp"; }; + MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; }; +}; + +ErrorBox ERR_NEED_INDEX_FIELDS +{ + Title [ en-US ] = "Save Index"; + + Message [ en-US ] = "The index must contain at least one field."; + + Buttons = WB_OK; +}; + +QueryBox QUERY_SAVE_CURRENT_INDEX +{ + Title [ en-US ] = "Exit Index Design"; + + Message [ en-US ] = "Do you want to save the changes made to the current index?"; + + Buttons = WB_YES_NO_CANCEL; + DefButton = WB_DEF_YES; +}; + +String STR_INDEX_NAME_ALREADY_USED +{ + Text [ en-US ] = "There is already another index named \"$name$\"."; +}; + +String STR_INDEXDESIGN_DOUBLE_COLUMN_NAME +{ + Text [ en-US ] = "In an index definition, no table column may occur more than once. However, you have entered column \"$name$\" twice."; +}; + diff --git a/dbaccess/source/ui/dlg/indexfieldscontrol.cxx b/dbaccess/source/ui/dlg/indexfieldscontrol.cxx new file mode 100644 index 000000000000..55457a36ae64 --- /dev/null +++ b/dbaccess/source/ui/dlg/indexfieldscontrol.cxx @@ -0,0 +1,516 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#ifndef _DBAUI_INDEXFIELDSCONTROL_HXX_ +#include "indexfieldscontrol.hxx" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif + +//...................................................................... +namespace dbaui +{ +//...................................................................... + +#define BROWSER_STANDARD_FLAGS BROWSER_COLUMNSELECTION | BROWSER_HLINESFULL | BROWSER_VLINESFULL | \ + BROWSER_HIDECURSOR | BROWSER_HIDESELECT | BROWSER_AUTO_HSCROLL | BROWSER_AUTO_VSCROLL + +#define COLUMN_ID_FIELDNAME 1 +#define COLUMN_ID_ORDER 2 + + using namespace ::com::sun::star::uno; + using namespace ::svt; + + //================================================================== + //= DbaMouseDownListBoxController + //================================================================== + class DbaMouseDownListBoxController : public ListBoxCellController + { + protected: + Link m_aOriginalModifyHdl; + Link m_aAdditionalModifyHdl; + + public: + DbaMouseDownListBoxController(ListBoxControl* _pParent) + :ListBoxCellController(_pParent) + { + } + + void SetAdditionalModifyHdl(const Link& _rHdl); + + protected: + virtual sal_Bool WantMouseEvent() const { return sal_True; } + virtual void SetModifyHdl(const Link& _rHdl); + + private: + void implCheckLinks(); + DECL_LINK( OnMultiplexModify, void* ); + }; + + //------------------------------------------------------------------ + void DbaMouseDownListBoxController::SetAdditionalModifyHdl(const Link& _rHdl) + { + m_aAdditionalModifyHdl = _rHdl; + implCheckLinks(); + } + + //------------------------------------------------------------------ + void DbaMouseDownListBoxController::SetModifyHdl(const Link& _rHdl) + { + m_aOriginalModifyHdl = _rHdl; + implCheckLinks(); + } + + //------------------------------------------------------------------ + IMPL_LINK( DbaMouseDownListBoxController, OnMultiplexModify, void*, _pArg ) + { + if (m_aAdditionalModifyHdl.IsSet()) + m_aAdditionalModifyHdl.Call(_pArg); + if (m_aOriginalModifyHdl.IsSet()) + m_aOriginalModifyHdl.Call(_pArg); + return 0L; + } + + //------------------------------------------------------------------ + void DbaMouseDownListBoxController::implCheckLinks() + { + if (m_aAdditionalModifyHdl.IsSet() || m_aOriginalModifyHdl.IsSet()) + ListBoxCellController::SetModifyHdl(LINK(this, DbaMouseDownListBoxController, OnMultiplexModify)); + else + ListBoxCellController::SetModifyHdl(Link()); + } + + //================================================================== + //= IndexFieldsControl + //================================================================== +DBG_NAME(IndexFieldsControl) +//------------------------------------------------------------------ + IndexFieldsControl::IndexFieldsControl( Window* _pParent, const ResId& _rId ,sal_Int32 _nMaxColumnsInIndex,sal_Bool _bAddIndexAppendix) + :EditBrowseBox(_pParent, _rId, EBBF_SMART_TAB_TRAVEL | EBBF_ACTIVATE_ON_BUTTONDOWN, BROWSER_STANDARD_FLAGS) + ,m_aSeekRow(m_aFields.end()) + ,m_pSortingCell(NULL) + ,m_pFieldNameCell(NULL) + ,m_nMaxColumnsInIndex(_nMaxColumnsInIndex) + ,m_bAddIndexAppendix(_bAddIndexAppendix) + { + DBG_CTOR(IndexFieldsControl,NULL); + + SetUniqueId( UID_DLGINDEX_INDEXDETAILS_BACK ); + GetDataWindow().SetUniqueId( UID_DLGINDEX_INDEXDETAILS_MAIN ); + } + + //------------------------------------------------------------------ + IndexFieldsControl::~IndexFieldsControl() + { + delete m_pSortingCell; + delete m_pFieldNameCell; + + DBG_DTOR(IndexFieldsControl,NULL); + } + + //------------------------------------------------------------------ + sal_Bool IndexFieldsControl::SeekRow(long nRow) + { + if (!EditBrowseBox::SeekRow(nRow)) + return sal_False; + + if (nRow < 0) + { + m_aSeekRow = m_aFields.end(); + } + else + { + m_aSeekRow = m_aFields.begin() + nRow; + OSL_ENSURE(m_aSeekRow <= m_aFields.end(), "IndexFieldsControl::SeekRow: invalid row!"); + } + + return sal_True; + } + + //------------------------------------------------------------------ + void IndexFieldsControl::PaintCell( OutputDevice& _rDev, const Rectangle& _rRect, sal_uInt16 _nColumnId ) const + { + Point aPos(_rRect.TopLeft()); + aPos.X() += 1; + + String aText = GetRowCellText(m_aSeekRow,_nColumnId); + Size TxtSize(GetDataWindow().GetTextWidth(aText), GetDataWindow().GetTextHeight()); + + // clipping + if (aPos.X() < _rRect.Right() || aPos.X() + TxtSize.Width() > _rRect.Right() || + aPos.Y() < _rRect.Top() || aPos.Y() + TxtSize.Height() > _rRect.Bottom()) + _rDev.SetClipRegion( _rRect ); + + // allow for a disabled control ... + sal_Bool bEnabled = IsEnabled(); + Color aOriginalColor = _rDev.GetTextColor(); + if (!bEnabled) + _rDev.SetTextColor(GetSettings().GetStyleSettings().GetDisableColor()); + + // draw the text + _rDev.DrawText(aPos, aText); + + // reset the color (if necessary) + if (!bEnabled) + _rDev.SetTextColor(aOriginalColor); + + if (_rDev.IsClipRegion()) + _rDev.SetClipRegion(); + } + + //------------------------------------------------------------------ + void IndexFieldsControl::initializeFrom(const IndexFields& _rFields) + { + // copy the field descriptions + m_aFields = _rFields; + m_aSeekRow = m_aFields.end(); + + SetUpdateMode(sal_False); + // remove all rows + RowRemoved(1, GetRowCount()); + // insert rows for the the fields + RowInserted(GetRowCount(), m_aFields.size(), sal_False); + // insert an additional row for a new field for that index +// if(!m_nMaxColumnsInIndex || GetRowCount() < m_nMaxColumnsInIndex ) + RowInserted(GetRowCount(), 1, sal_False); + SetUpdateMode(sal_True); + + GoToRowColumnId(0, COLUMN_ID_FIELDNAME); + } + + //------------------------------------------------------------------ + void IndexFieldsControl::commitTo(IndexFields& _rFields) + { + // do not just copy the array, we may have empty field names (which should not be copied) + _rFields.resize(m_aFields.size()); + ConstIndexFieldsIterator aSource = m_aFields.begin(); + ConstIndexFieldsIterator aSourceEnd = m_aFields.end(); + IndexFieldsIterator aDest = _rFields.begin(); + for (; aSource < aSourceEnd; ++aSource) + if (0 != aSource->sFieldName.Len()) + { + *aDest = *aSource; + ++aDest; + } + + _rFields.resize(aDest - _rFields.begin()); + } + + //------------------------------------------------------------------ + sal_uInt32 IndexFieldsControl::GetTotalCellWidth(long _nRow, sal_uInt16 _nColId) + { + if (COLUMN_ID_ORDER == _nColId) + { + sal_Int32 nWidthAsc = GetTextWidth(m_sAscendingText) + GetSettings().GetStyleSettings().GetScrollBarSize(); + sal_Int32 nWidthDesc = GetTextWidth(m_sDescendingText) + GetSettings().GetStyleSettings().GetScrollBarSize(); + // maximum plus some additional space + return (nWidthAsc > nWidthDesc ? nWidthAsc : nWidthDesc) + GetTextWidth('0') * 2; + } + return EditBrowseBox::GetTotalCellWidth(_nRow, _nColId); + } + + //------------------------------------------------------------------ + void IndexFieldsControl::Init(const Sequence< ::rtl::OUString >& _rAvailableFields) + { + RemoveColumns(); + + // for the width: both columns together should be somewhat smaller than the whole window (without the scrollbar) + sal_Int32 nFieldNameWidth = GetSizePixel().Width(); + + if ( m_bAddIndexAppendix ) + { + m_sAscendingText = String(ModuleRes(STR_ORDER_ASCENDING)); + m_sDescendingText = String(ModuleRes(STR_ORDER_DESCENDING)); + + // the "sort order" column + String sColumnName = String(ModuleRes(STR_TAB_INDEX_SORTORDER)); + // the width of the order column is the maximum widths of the texts used + // (the title of the column) + sal_Int32 nSortOrderColumnWidth = GetTextWidth(sColumnName); + // ("ascending" + scrollbar width) + sal_Int32 nOther = GetTextWidth(m_sAscendingText) + GetSettings().GetStyleSettings().GetScrollBarSize(); + nSortOrderColumnWidth = nSortOrderColumnWidth > nOther ? nSortOrderColumnWidth : nOther; + // ("descending" + scrollbar width) + nOther = GetTextWidth(m_sDescendingText) + GetSettings().GetStyleSettings().GetScrollBarSize(); + nSortOrderColumnWidth = nSortOrderColumnWidth > nOther ? nSortOrderColumnWidth : nOther; + // (plus some additional space) + nSortOrderColumnWidth += GetTextWidth('0') * 2; + InsertDataColumn(COLUMN_ID_ORDER, sColumnName, nSortOrderColumnWidth, HIB_STDSTYLE, 1); + + m_pSortingCell = new ListBoxControl(&GetDataWindow()); + m_pSortingCell->InsertEntry(m_sAscendingText); + m_pSortingCell->InsertEntry(m_sDescendingText); + m_pSortingCell->SetHelpId( HID_DLGINDEX_INDEXDETAILS_SORTORDER ); + + nFieldNameWidth -= nSortOrderColumnWidth; + } + StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings(); + nFieldNameWidth -= aSystemStyle.GetScrollBarSize(); + nFieldNameWidth -= 8; + // the "field name" column + String sColumnName = String(ModuleRes(STR_TAB_INDEX_FIELD)); + InsertDataColumn(COLUMN_ID_FIELDNAME, sColumnName, nFieldNameWidth, HIB_STDSTYLE, 0); + + // create the cell controllers + // for the field name cell + m_pFieldNameCell = new ListBoxControl(&GetDataWindow()); + m_pFieldNameCell->InsertEntry(String()); + m_pFieldNameCell->SetHelpId( HID_DLGINDEX_INDEXDETAILS_FIELD ); + const ::rtl::OUString* pFields = _rAvailableFields.getConstArray(); + const ::rtl::OUString* pFieldsEnd = pFields + _rAvailableFields.getLength(); + for (;pFields < pFieldsEnd; ++pFields) + m_pFieldNameCell->InsertEntry(*pFields); + } + + //------------------------------------------------------------------ + CellController* IndexFieldsControl::GetController(long _nRow, sal_uInt16 _nColumnId) + { + if (!IsEnabled()) + return NULL; + + ConstIndexFieldsIterator aRow; + sal_Bool bNewField = !implGetFieldDesc(_nRow, aRow); + + DbaMouseDownListBoxController* pReturn = NULL; + switch (_nColumnId) + { + case COLUMN_ID_ORDER: + if (!bNewField && m_pSortingCell && 0 != aRow->sFieldName.Len()) + pReturn = new DbaMouseDownListBoxController(m_pSortingCell); + break; + + case COLUMN_ID_FIELDNAME: + pReturn = new DbaMouseDownListBoxController(m_pFieldNameCell); + break; + + default: + OSL_ENSURE(sal_False, "IndexFieldsControl::GetController: invalid column id!"); + } + + if (pReturn) + pReturn->SetAdditionalModifyHdl(LINK(this, IndexFieldsControl, OnListEntrySelected)); + + return pReturn; + } + + //------------------------------------------------------------------ + sal_Bool IndexFieldsControl::implGetFieldDesc(long _nRow, ConstIndexFieldsIterator& _rPos) + { + _rPos = m_aFields.end(); + if ((_nRow < 0) || (_nRow >= (sal_Int32)m_aFields.size())) + return sal_False; + _rPos = m_aFields.begin() + _nRow; + return sal_True; + } + + //------------------------------------------------------------------ + sal_Bool IndexFieldsControl::IsModified() const + { + return EditBrowseBox::IsModified(); + } + + //------------------------------------------------------------------ + sal_Bool IndexFieldsControl::SaveModified() + { + if (!IsModified()) + return sal_True; + + switch (GetCurColumnId()) + { + case COLUMN_ID_FIELDNAME: + { + String sFieldSelected = m_pFieldNameCell->GetSelectEntry(); + sal_Bool bEmptySelected = 0 == sFieldSelected.Len(); + if (isNewField()) + { + if (!bEmptySelected) + { + // add a new field to the collection + OIndexField aNewField; + aNewField.sFieldName = sFieldSelected; + m_aFields.push_back(aNewField); + RowInserted(GetRowCount(), 1, sal_True); + } + } + else + { + sal_Int32 nRow = GetCurRow(); + OSL_ENSURE(nRow < (sal_Int32)m_aFields.size(), "IndexFieldsControl::SaveModified: invalid current row!"); + if (nRow >= 0) // may be -1 in case the control was empty + { + // remove the field from the selection + IndexFieldsIterator aPos = m_aFields.begin() + nRow; + + if (bEmptySelected) + { + aPos->sFieldName = String(); + + // invalidate the row to force repaint + Invalidate(GetRowRectPixel(nRow)); + return sal_True; + } + + if (sFieldSelected == aPos->sFieldName) + // nothing changed + return sal_True; + + aPos->sFieldName = sFieldSelected; + } + } + + Invalidate(GetRowRectPixel(GetCurRow())); + } + break; + case COLUMN_ID_ORDER: + { + OSL_ENSURE(!isNewField(), "IndexFieldsControl::SaveModified: why the hell ...!!!"); + // selected entry + sal_uInt16 nPos = m_pSortingCell->GetSelectEntryPos(); + OSL_ENSURE(LISTBOX_ENTRY_NOTFOUND != nPos, "IndexFieldsControl::SaveModified: how did you get this selection??"); + // adjust the sort flag in the index field description + OIndexField& rCurrentField = m_aFields[GetCurRow()]; + rCurrentField.bSortAscending = (0 == nPos); + + } + break; + default: + OSL_ENSURE(sal_False, "IndexFieldsControl::SaveModified: invalid column id!"); + } + return sal_True; + } + + //------------------------------------------------------------------ + void IndexFieldsControl::InitController(CellControllerRef& /*_rController*/, long _nRow, sal_uInt16 _nColumnId) + { + ConstIndexFieldsIterator aFieldDescription; + sal_Bool bNewField = !implGetFieldDesc(_nRow, aFieldDescription); + + switch (_nColumnId) + { + case COLUMN_ID_FIELDNAME: + m_pFieldNameCell->SelectEntry(bNewField ? String() : aFieldDescription->sFieldName); + m_pFieldNameCell->SaveValue(); + break; + + case COLUMN_ID_ORDER: + m_pSortingCell->SelectEntry(aFieldDescription->bSortAscending ? m_sAscendingText : m_sDescendingText); + m_pSortingCell->SaveValue(); + break; + + default: + OSL_ENSURE(sal_False, "IndexFieldsControl::InitController: invalid column id!"); + } + } + + //------------------------------------------------------------------ + IMPL_LINK( IndexFieldsControl, OnListEntrySelected, ListBox*, _pBox ) + { + if (!_pBox->IsTravelSelect() && m_aModifyHdl.IsSet()) + m_aModifyHdl.Call(this); + + if (_pBox == m_pFieldNameCell) + { // a field has been selected + if (GetCurRow() >= GetRowCount() - 2) + { // and we're in one of the last two rows + String sSelectedEntry = m_pFieldNameCell->GetSelectEntry(); + sal_Int32 nCurrentRow = GetCurRow(); + sal_Int32 rowCount = GetRowCount(); + + OSL_ENSURE(((sal_Int32)(m_aFields.size() + 1)) == rowCount, "IndexFieldsControl::OnListEntrySelected: inconsistence!"); + + if (sSelectedEntry.Len() && (nCurrentRow == rowCount - 1) /*&& (!m_nMaxColumnsInIndex || rowCount < m_nMaxColumnsInIndex )*/ ) + { // in the last row, an non-empty string has been selected + // -> insert a new row + m_aFields.push_back(OIndexField()); + RowInserted(GetRowCount(), 1); + Invalidate(GetRowRectPixel(nCurrentRow)); + } + else if (!sSelectedEntry.Len() && (nCurrentRow == rowCount - 2)) + { // in the (last-1)th row, an empty entry has been selected + // -> remove the last row + m_aFields.erase(m_aFields.end() - 1); + RowRemoved(GetRowCount() - 1, 1); + Invalidate(GetRowRectPixel(nCurrentRow)); + } + } + + SaveModified(); + } + return 0L; + } + //------------------------------------------------------------------ + String IndexFieldsControl::GetCellText(long _nRow,sal_uInt16 nColId) const + { + ConstIndexFieldsIterator aRow = m_aFields.end(); + if ( _nRow >= 0 ) + { + aRow = m_aFields.begin() + _nRow; + OSL_ENSURE(aRow <= m_aFields.end(), "IndexFieldsControl::SeekRow: invalid row!"); + } + return GetRowCellText(aRow,nColId); + } + //------------------------------------------------------------------ + String IndexFieldsControl::GetRowCellText(const ConstIndexFieldsIterator& _rRow,sal_uInt16 nColId) const + { + if (_rRow < m_aFields.end()) + { + switch (nColId) + { + case COLUMN_ID_FIELDNAME: + return _rRow->sFieldName; + case COLUMN_ID_ORDER: + if (0 == _rRow->sFieldName.Len()) + return String(); + else + return _rRow->bSortAscending ? m_sAscendingText : m_sDescendingText; + default: + OSL_ENSURE(sal_False, "IndexFieldsControl::GetCurrentRowCellText: invalid column id!"); + } + } + return String(); + } + //------------------------------------------------------------------ + sal_Bool IndexFieldsControl::IsTabAllowed(sal_Bool /*bForward*/) const + { + return sal_False; + } + //------------------------------------------------------------------ + +//...................................................................... +} // namespace dbaui +//...................................................................... + diff --git a/dbaccess/source/ui/dlg/makefile.mk b/dbaccess/source/ui/dlg/makefile.mk new file mode 100644 index 000000000000..270741d00857 --- /dev/null +++ b/dbaccess/source/ui/dlg/makefile.mk @@ -0,0 +1,156 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/..$/.. +PRJINC=$(PRJ)$/source +PRJNAME=dbaccess +TARGET=uidlg + +# --- Settings ---------------------------------- + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +.IF "$(SYSTEM_ODBC_HEADERS)" == "YES" +CFLAGS+=-DSYSTEM_ODBC_HEADERS +.ENDIF + +.IF "$(WINDOWS_VISTA_PSDK)"!="" && "$(PROF_EDITION)"=="" +CDEFS+=-DWINDOWS_VISTA_PSDK +.ENDIF + +.IF "$(GUI)$(COM)"=="WNTGCC" # for adoint.h +CFLAGS+=-fpermissive +.ENDIF + +# --- Files ------------------------------------- + +# ... resource files ............................ + + +LOCALIZE_ME=AutoControls_tmpl.hrc + +SRS1NAME=$(TARGET) +SRC1FILES = \ + AutoControls.src \ + ConnectionPage.src \ + UserAdmin.src \ + admincontrols.src \ + directsql.src \ + AdabasStat.src \ + indexdialog.src \ + RelationDlg.src \ + adtabdlg.src \ + dlgsave.src \ + queryorder.src \ + queryfilter.src \ + paramdialog.src \ + dsselect.src \ + dbadmin.src \ + dbadmin2.src \ + dbadminsetup.src \ + dbfindex.src \ + dlgsize.src \ + CollectionView.src \ + dlgattr.src \ + advancedsettings.src\ + UserAdminDlg.src \ + sqlmessage.src \ + textconnectionsettings.src + + +# ... object files ............................ +EXCEPTIONSFILES= \ + $(SLO)$/directsql.obj \ + $(SLO)$/dbwiz.obj \ + $(SLO)$/dbwizsetup.obj \ + $(SLO)$/generalpage.obj \ + $(SLO)$/indexfieldscontrol.obj \ + $(SLO)$/indexdialog.obj \ + $(SLO)$/RelationDlg.obj \ + $(SLO)$/adtabdlg.obj \ + $(SLO)$/dlgsave.obj \ + $(SLO)$/admincontrols.obj \ + $(SLO)$/adminpages.obj \ + $(SLO)$/queryorder.obj \ + $(SLO)$/queryfilter.obj \ + $(SLO)$/paramdialog.obj \ + $(SLO)$/dbadmin.obj \ + $(SLO)$/detailpages.obj \ + $(SLO)$/sqlmessage.obj \ + $(SLO)$/finteraction.obj \ + $(SLO)$/ConnectionPage.obj \ + $(SLO)$/ConnectionHelper.obj \ + $(SLO)$/TextConnectionHelper.obj \ + $(SLO)$/ConnectionPageSetup.obj \ + $(SLO)$/DBSetupConnectionPages.obj \ + $(SLO)$/UserAdminDlg.obj \ + $(SLO)$/UserAdmin.obj \ + $(SLO)$/AdabasStat.obj \ + $(SLO)$/tablespage.obj \ + $(SLO)$/DbAdminImpl.obj \ + $(SLO)$/TablesSingleDlg.obj \ + $(SLO)$/CollectionView.obj \ + $(SLO)$/dsselect.obj \ + $(SLO)$/dbfindex.obj \ + $(SLO)$/DriverSettings.obj \ + $(SLO)$/odbcconfig.obj \ + $(SLO)$/advancedsettings.obj \ + $(SLO)$/textconnectionsettings.obj + +SLOFILES= \ + $(EXCEPTIONSFILES) \ + $(SLO)$/dlgsize.obj \ + $(SLO)$/dlgattr.obj \ + $(SLO)$/optionalboolitem.obj + +.IF "$(WINDOWS_VISTA_PSDK)"!="" && "$(PROF_EDITION)"=="" +DISABLE_ADO=TRUE +.ENDIF # "$(WINDOWS_VISTA_PSDK)"!="" && "$(PROF_EDITION)"=="" + +.IF "$(GUI)"=="WNT" && "$(DISABLE_ADO)"=="" +SLOFILES+= $(SLO)$/adodatalinks.obj +.ENDIF + +# --- Targets ---------------------------------- +#LOCALIZE_ME=AutoControls_tmpl.hrc + +.INCLUDE : target.mk + +$(SLO)$/ConnectionHelper.obj : $(LOCALIZE_ME_DEST) + +$(SLO)$/ConnectionPageSetup.obj : $(LOCALIZE_ME_DEST) + +$(SLO)$/DBSetupConnectionPages.obj : $(LOCALIZE_ME_DEST) + +$(SLO)$/TextConnectionHelper.obj : $(LOCALIZE_ME_DEST) + +$(SLO)$/detailpages.obj : $(LOCALIZE_ME_DEST) + +$(SLO)$/tablespage.obj : $(LOCALIZE_ME_DEST) + +$(SLO)$/ConnectionPage.obj : $(LOCALIZE_ME_DEST) diff --git a/dbaccess/source/ui/dlg/odbcconfig.cxx b/dbaccess/source/ui/dlg/odbcconfig.cxx new file mode 100644 index 000000000000..c4b73ee08af0 --- /dev/null +++ b/dbaccess/source/ui/dlg/odbcconfig.cxx @@ -0,0 +1,403 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#ifndef _DBAUI_ODBC_CONFIG_HXX_ +#include "odbcconfig.hxx" +#endif +#include <rtl/bootstrap.hxx> +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif +#ifndef _RTL_USTRBUF_HXX_ +#include <rtl/ustrbuf.hxx> +#endif +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif +#ifndef _OSL_PROCESS_H_ +#include <osl/process.h> +#endif +#ifndef _THREAD_HXX_ +#include <osl/thread.hxx> +#endif +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif +#ifndef _SV_SVAPP_HXX +#include <vcl/svapp.hxx> +#endif + +#ifdef HAVE_ODBC_SUPPORT + +#if defined(WIN) || defined(OS2) +#define ODBC_LIBRARY "ODBC.DLL" +#define ODBC_UI_LIBRARY "ODBCINST.DLL" +#endif +#if defined WNT +#define ODBC_LIBRARY "ODBC32.DLL" +#define ODBC_UI_LIBRARY "ODBCCP32.DLL" +#endif +#ifdef UNX +#ifdef MACOSX +#define ODBC_LIBRARY "libiodbc.dylib" +#define ODBC_UI_LIBRARY "libiodbcinst.dylib" +#else +#define ODBC_LIBRARY_1 "libodbc.so.1" +#define ODBC_UI_LIBRARY_1 "libodbcinst.so.1" +#define ODBC_LIBRARY "libodbc.so" +#define ODBC_UI_LIBRARY "libodbcinst.so" +#endif +#endif + +// just to go with calling convention of windows +// so don't touch this +#if defined(WIN) || defined(WNT) +#define SQL_API __stdcall +// At least under some circumstances, the below #include <odbc/sqlext.h> re- +// defines SQL_API to an empty string, leading to a compiler warning on MSC; to +// not break the current behavior, this is worked around by locally disabling +// that warning: +#if defined _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4005) +#endif +#endif // defined(WIN) || defined(WNT) + +#if defined(OS2) +#define ALLREADY_HAVE_OS2_TYPES +#define DONT_TD_VOID +#endif + +#ifdef SYSTEM_ODBC_HEADERS +#include <sqlext.h> +#else +#ifndef __SQLEXT_H +#include <odbc/sqlext.h> +#endif +#endif + +#if defined(WIN) || defined(WNT) +#if defined _MSC_VER +#pragma warning(pop) +#endif +#undef SQL_API +#define SQL_API __stdcall +#endif // defined(WIN) || defined(WNT) +// from here on you can do what you want to + +#if defined(OS2) +#define SQL_API _System +#endif // defined(OS2) + +#else + +#define ODBC_LIBRARY "" +#define ODBC_UI_LIBRARY "" + +#endif // HAVE_ODBC_SUPPORT + +//......................................................................... +namespace dbaui +{ +//......................................................................... + + +#ifdef HAVE_ODBC_SUPPORT +typedef SQLRETURN (SQL_API* TSQLManageDataSource) (SQLHWND hwndParent); +typedef SQLRETURN (SQL_API* TSQLAllocHandle) (SQLSMALLINT HandleType, SQLHANDLE InputHandle, SQLHANDLE* OutputHandlePtr); +typedef SQLRETURN (SQL_API* TSQLFreeHandle) (SQLSMALLINT HandleType, SQLHANDLE Handle); +typedef SQLRETURN (SQL_API* TSQLSetEnvAttr) (SQLHENV EnvironmentHandle, SQLINTEGER Attribute, SQLPOINTER ValuePtr, SQLINTEGER StringLength); +typedef SQLRETURN (SQL_API* TSQLDataSources) (SQLHENV EnvironmentHandle, SQLUSMALLINT Direction, SQLCHAR* ServerName, + SQLSMALLINT BufferLength1, SQLSMALLINT* NameLength1Ptr, SQLCHAR* Description, SQLSMALLINT BufferLength2, SQLSMALLINT* NameLength2Ptr); + +#define NSQLManageDataSource(a) (*(TSQLManageDataSource)(m_pSQLManageDataSource))(a) +#define NSQLAllocHandle(a,b,c) (*(TSQLAllocHandle)(m_pAllocHandle))(a,b,c) +#define NSQLFreeHandle(a,b) (*(TSQLFreeHandle)(m_pFreeHandle))(a,b) +#define NSQLSetEnvAttr(a,b,c,d) (*(TSQLSetEnvAttr)(m_pSetEnvAttr))(a,b,c,d) +#define NSQLDataSources(a,b,c,d,e,f,g,h) (*(TSQLDataSources)(m_pDataSources))(a,b,c,d,e,f,g,h) +#endif + +//========================================================================= +//= OOdbcLibWrapper +//========================================================================= +DBG_NAME(OOdbcLibWrapper) +//------------------------------------------------------------------------- +#ifdef HAVE_ODBC_SUPPORT +OOdbcLibWrapper::OOdbcLibWrapper() + :m_pOdbcLib(NULL) +{ + DBG_CTOR(OOdbcLibWrapper,NULL); + +} +#endif + +//------------------------------------------------------------------------- +sal_Bool OOdbcLibWrapper::load(const sal_Char* _pLibPath) +{ + m_sLibPath = ::rtl::OUString::createFromAscii(_pLibPath); +#ifdef HAVE_ODBC_SUPPORT + // load the module + m_pOdbcLib = osl_loadModule(m_sLibPath.pData, SAL_LOADMODULE_NOW); + return (NULL != m_pOdbcLib); +#endif +} + +//------------------------------------------------------------------------- +void OOdbcLibWrapper::unload() +{ +#ifdef HAVE_ODBC_SUPPORT + if (isLoaded()) + { + osl_unloadModule(m_pOdbcLib); + m_pOdbcLib = NULL; + } +#endif +} + +//------------------------------------------------------------------------- +oslGenericFunction OOdbcLibWrapper::loadSymbol(const sal_Char* _pFunctionName) +{ + return osl_getFunctionSymbol(m_pOdbcLib, ::rtl::OUString::createFromAscii(_pFunctionName).pData); +} + +//------------------------------------------------------------------------- +OOdbcLibWrapper::~OOdbcLibWrapper() +{ + unload(); + + DBG_DTOR(OOdbcLibWrapper,NULL); +} + +//========================================================================= +//= OOdbcEnumeration +//========================================================================= +struct OdbcTypesImpl +{ +#ifdef HAVE_ODBC_SUPPORT + SQLHANDLE hEnvironment; + OdbcTypesImpl() : hEnvironment(0) { } +#else + void* pDummy; +#endif +}; +DBG_NAME(OOdbcEnumeration) +//------------------------------------------------------------------------- +OOdbcEnumeration::OOdbcEnumeration() +#ifdef HAVE_ODBC_SUPPORT + :m_pAllocHandle(NULL) + ,m_pSetEnvAttr(NULL) + ,m_pDataSources(NULL) + ,m_pImpl(new OdbcTypesImpl) +#endif +{ + DBG_CTOR(OOdbcEnumeration,NULL); + + sal_Bool bLoaded = load(ODBC_LIBRARY); +#ifdef ODBC_LIBRARY_1 + if ( !bLoaded ) + bLoaded = load(ODBC_LIBRARY_1); +#endif + + if ( bLoaded ) + { +#ifdef HAVE_ODBC_SUPPORT + // load the generic functions + m_pAllocHandle = loadSymbol("SQLAllocHandle"); + m_pFreeHandle = loadSymbol("SQLFreeHandle"); + m_pSetEnvAttr = loadSymbol("SQLSetEnvAttr"); + m_pDataSources = loadSymbol("SQLDataSources"); + + // all or nothing + if (!m_pAllocHandle || !m_pSetEnvAttr || !m_pDataSources || !m_pFreeHandle) + { + unload(); + m_pAllocHandle = m_pFreeHandle = m_pSetEnvAttr = m_pDataSources = NULL; + } +#endif + } +} + +//------------------------------------------------------------------------- +OOdbcEnumeration::~OOdbcEnumeration() +{ + freeEnv(); + delete m_pImpl; + + DBG_DTOR(OOdbcEnumeration,NULL); +} + +//------------------------------------------------------------------------- +sal_Bool OOdbcEnumeration::allocEnv() +{ + OSL_ENSURE(isLoaded(), "OOdbcEnumeration::allocEnv: not loaded!"); + if (!isLoaded()) + return sal_False; + +#ifdef HAVE_ODBC_SUPPORT + if (m_pImpl->hEnvironment) + // nothing to do + return sal_True; + SQLRETURN nResult = NSQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &m_pImpl->hEnvironment); + if (SQL_SUCCESS != nResult) + // can't do anything without environment + return sal_False; + + NSQLSetEnvAttr(m_pImpl->hEnvironment, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3, SQL_IS_INTEGER); + return sal_True; +#else + return sal_False; +#endif +} + +//------------------------------------------------------------------------- +void OOdbcEnumeration::freeEnv() +{ +#ifdef HAVE_ODBC_SUPPORT + if (m_pImpl->hEnvironment) + NSQLFreeHandle(SQL_HANDLE_ENV, m_pImpl->hEnvironment); + m_pImpl->hEnvironment = 0; +#endif +} + +//------------------------------------------------------------------------- +void OOdbcEnumeration::getDatasourceNames(StringBag& _rNames) +{ + OSL_ENSURE(isLoaded(), "OOdbcEnumeration::getDatasourceNames: not loaded!"); + if (!isLoaded()) + return; + + if (!allocEnv()) + { + OSL_ENSURE(sal_False, "OOdbcEnumeration::getDatasourceNames: could not allocate an ODBC environment!"); + return; + } + +#ifdef HAVE_ODBC_SUPPORT + // now that we have an environment collect the data source names + UCHAR szDSN[SQL_MAX_DSN_LENGTH+1]; + SWORD pcbDSN; + UCHAR szDescription[1024+1]; + SWORD pcbDescription; + SQLRETURN nResult = SQL_SUCCESS; + rtl_TextEncoding nTextEncoding = osl_getThreadTextEncoding(); + + for ( nResult = NSQLDataSources(m_pImpl->hEnvironment, SQL_FETCH_FIRST, szDSN, sizeof(szDSN), &pcbDSN, szDescription, sizeof(szDescription)-1, &pcbDescription); + ; + nResult = NSQLDataSources(m_pImpl->hEnvironment, SQL_FETCH_NEXT, szDSN, sizeof(szDSN), &pcbDSN, szDescription, sizeof(szDescription)-1, &pcbDescription) + ) + { + if (nResult != SQL_SUCCESS) + // no further error handling + break; + else + { + ::rtl::OUString aCurrentDsn(reinterpret_cast<const char*>(szDSN),pcbDSN, nTextEncoding); + _rNames.insert(aCurrentDsn); + } + } +#endif +} + +#ifdef HAVE_ODBC_ADMINISTRATION + +//========================================================================= +//= ProcessTerminationWait +//========================================================================= +class ProcessTerminationWait : public ::osl::Thread +{ + oslProcess m_hProcessHandle; + Link m_aFinishHdl; + +public: + ProcessTerminationWait( oslProcess _hProcessHandle, const Link& _rFinishHdl ) + :m_hProcessHandle( _hProcessHandle ) + ,m_aFinishHdl( _rFinishHdl ) + { + } + +protected: + virtual void SAL_CALL run() + { + osl_joinProcess( m_hProcessHandle ); + osl_freeProcessHandle( m_hProcessHandle ); + Application::PostUserEvent( m_aFinishHdl ); + } +}; + +//========================================================================= +//= OOdbcManagement +//========================================================================= +//------------------------------------------------------------------------- +OOdbcManagement::OOdbcManagement( const Link& _rAsyncFinishCallback ) + :m_pProcessWait( NULL ) + ,m_aAsyncFinishCallback( _rAsyncFinishCallback ) +{ +} + +//------------------------------------------------------------------------- +OOdbcManagement::~OOdbcManagement() +{ + // wait for our thread to be finished + if ( m_pProcessWait.get() ) + m_pProcessWait->join(); +} + +//------------------------------------------------------------------------- +bool OOdbcManagement::manageDataSources_async() +{ + OSL_PRECOND( !isRunning(), "OOdbcManagement::manageDataSources_async: still running from the previous call!" ); + if ( isRunning() ) + return false; + + // this is done in an external process, due to #i78733# + // (and note this whole functionality is supported on Windows only, ATM) + ::rtl::OUString sExecutableName( RTL_CONSTASCII_USTRINGPARAM( "$OOO_BASE_DIR/program/odbcconfig.exe" ) ); + ::rtl::Bootstrap::expandMacros( sExecutableName ); //TODO: detect failure + oslProcess hProcessHandle(0); + oslProcessError eError = osl_executeProcess( sExecutableName.pData, NULL, 0, 0, NULL, NULL, NULL, 0, &hProcessHandle ); + if ( eError != osl_Process_E_None ) + return false; + + m_pProcessWait.reset( new ProcessTerminationWait( hProcessHandle, m_aAsyncFinishCallback ) ); + m_pProcessWait->create(); + return true; +} + +//------------------------------------------------------------------------- +bool OOdbcManagement::isRunning() const +{ + return ( m_pProcessWait.get() && m_pProcessWait->isRunning() ); +} + +#endif // HAVE_ODBC_ADMINISTRATION + +//......................................................................... +} // namespace dbaui +//......................................................................... diff --git a/dbaccess/source/ui/dlg/odbcconfig.hxx b/dbaccess/source/ui/dlg/odbcconfig.hxx new file mode 100644 index 000000000000..b4a10625e49b --- /dev/null +++ b/dbaccess/source/ui/dlg/odbcconfig.hxx @@ -0,0 +1,140 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBAUI_ODBC_CONFIG_HXX_ +#define _DBAUI_ODBC_CONFIG_HXX_ + +#include "commontypes.hxx" + +#if defined(WIN) || defined(WNT) || defined (UNX) || defined (OS2) +#define HAVE_ODBC_SUPPORT +#endif + +#if ( defined(WIN) || defined(WNT) || defined (OS2) ) && defined(HAVE_ODBC_SUPPORT) +#define HAVE_ODBC_ADMINISTRATION +#endif + +#include <tools/link.hxx> +#include <osl/module.h> + +#include <memory> + +//......................................................................... +namespace dbaui +{ +//......................................................................... + +//========================================================================= +//= OOdbcLibWrapper +//========================================================================= +/** base for helper classes wrapping functionality from an ODBC library +*/ +class OOdbcLibWrapper +{ + oslModule m_pOdbcLib; // the library handle + ::rtl::OUString m_sLibPath; // the path to the library + +public: +#ifdef HAVE_ODBC_SUPPORT + sal_Bool isLoaded() const { return NULL != m_pOdbcLib; } +#else + sal_Bool isLoaded() const { return sal_False; } +#endif + ::rtl::OUString getLibraryName() const { return m_sLibPath; } + +protected: +#ifndef HAVE_ODBC_SUPPORT + OOdbcLibWrapper() : m_pOdbcLib(NULL) { } +#else + OOdbcLibWrapper(); +#endif + ~OOdbcLibWrapper(); + + oslGenericFunction loadSymbol(const sal_Char* _pFunctionName); + + /// load the lib + sal_Bool load(const sal_Char* _pLibPath); + /// unload the lib + void unload(); +}; + +//========================================================================= +//= OOdbcEnumeration +//========================================================================= +struct OdbcTypesImpl; +class OOdbcEnumeration : public OOdbcLibWrapper +{ +#ifdef HAVE_ODBC_SUPPORT + // entry points for ODBC administration + oslGenericFunction m_pAllocHandle; + oslGenericFunction m_pFreeHandle; + oslGenericFunction m_pSetEnvAttr; + oslGenericFunction m_pDataSources; + +#endif + OdbcTypesImpl* m_pImpl; + // needed because we can't have a member of type SQLHANDLE: this would require us to include the respective + // ODBC file, which would lead to a lot of conflicts with other includes + +public: + OOdbcEnumeration(); + ~OOdbcEnumeration(); + + void getDatasourceNames(StringBag& _rNames); + +protected: + /// ensure that an ODBC environment is allocated + sal_Bool allocEnv(); + /// free any allocated ODBC environment + void freeEnv(); +}; + +//========================================================================= +//= OOdbcManagement +//========================================================================= +#ifdef HAVE_ODBC_ADMINISTRATION +class ProcessTerminationWait; +class OOdbcManagement +{ + ::std::auto_ptr< ProcessTerminationWait > m_pProcessWait; + Link m_aAsyncFinishCallback; + +public: + OOdbcManagement( const Link& _rAsyncFinishCallback ); + ~OOdbcManagement(); + + bool manageDataSources_async(); + bool isRunning() const; +}; +#endif + +//......................................................................... +} // namespace dbaui +//......................................................................... + +#endif // _DBAUI_ODBC_CONFIG_HXX_ + diff --git a/dbaccess/source/ui/dlg/optionalboolitem.cxx b/dbaccess/source/ui/dlg/optionalboolitem.cxx new file mode 100644 index 000000000000..cdc3ff03ee5b --- /dev/null +++ b/dbaccess/source/ui/dlg/optionalboolitem.cxx @@ -0,0 +1,76 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#include "optionalboolitem.hxx" + +//........................................................................ +namespace dbaui +{ +//........................................................................ + + //==================================================================== + //= OptionalBoolItem + //==================================================================== + TYPEINIT1( OptionalBoolItem, SfxPoolItem ); + //-------------------------------------------------------------------- + OptionalBoolItem::OptionalBoolItem( sal_Int16 _nWhich ) + :SfxPoolItem( _nWhich ) + ,m_aValue() + { + } + + //-------------------------------------------------------------------- + OptionalBoolItem::OptionalBoolItem( const OptionalBoolItem& _rSource ) + :SfxPoolItem( _rSource ) + ,m_aValue( _rSource.m_aValue ) + { + } + + //-------------------------------------------------------------------- + int OptionalBoolItem::operator==( const SfxPoolItem& _rItem ) const + { + const OptionalBoolItem* pCompare = PTR_CAST( OptionalBoolItem, &_rItem ); + if ( !pCompare ) + return 0; + + if ( m_aValue == pCompare->m_aValue ) + return 1; + + return 0; + } + + //-------------------------------------------------------------------- + SfxPoolItem* OptionalBoolItem::Clone( SfxItemPool* /*_pPool*/ ) const + { + return new OptionalBoolItem( *this ); + } + +//........................................................................ +} // namespace dbaui +//........................................................................ diff --git a/dbaccess/source/ui/dlg/optionalboolitem.hxx b/dbaccess/source/ui/dlg/optionalboolitem.hxx new file mode 100644 index 000000000000..89d7d0d5de3b --- /dev/null +++ b/dbaccess/source/ui/dlg/optionalboolitem.hxx @@ -0,0 +1,67 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef DBACCESS_OPTIONALBOOLITEM_HXX +#define DBACCESS_OPTIONALBOOLITEM_HXX + +#include <svl/poolitem.hxx> + +#include <boost/optional.hpp> + +//........................................................................ +namespace dbaui +{ +//........................................................................ + + //==================================================================== + //= OptionalBoolItem + //==================================================================== + class OptionalBoolItem : public SfxPoolItem + { + ::boost::optional< bool > m_aValue; + + public: + TYPEINFO(); + OptionalBoolItem( sal_Int16 nWhich ); + OptionalBoolItem( const OptionalBoolItem& _rSource ); + + virtual int operator==( const SfxPoolItem& _rItem ) const; + virtual SfxPoolItem* Clone( SfxItemPool* _pPool = NULL ) const; + + bool HasValue() const { return !!m_aValue; } + void ClearValue() { m_aValue.reset(); } + bool GetValue() const { return *m_aValue; } + void SetValue( const bool _bValue ) { m_aValue.reset( _bValue ); } + + const ::boost::optional< bool >& + GetFullValue() const { return m_aValue; } + }; + +//........................................................................ +} // namespace dbaui +//........................................................................ + +#endif // DBACCESS_OPTIONALBOOLITEM_HXX diff --git a/dbaccess/source/ui/dlg/paramdialog.cxx b/dbaccess/source/ui/dlg/paramdialog.cxx new file mode 100644 index 000000000000..61d6551ef08e --- /dev/null +++ b/dbaccess/source/ui/dlg/paramdialog.cxx @@ -0,0 +1,452 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#ifndef _DBAUI_PARAMDIALOG_HXX_ +#include "paramdialog.hxx" +#endif +#ifndef _DBAUI_PARAMDIALOG_HRC_ +#include "paramdialog.hrc" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef _DBAUI_COMMON_TYPES_HXX_ +#include "commontypes.hxx" +#endif +#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "moduledbu.hxx" +#endif +#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_ +#include <com/sun/star/util/XNumberFormatter.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _CONNECTIVITY_DBTOOLS_HXX_ +#include <connectivity/dbtools.hxx> +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef _SV_SVAPP_HXX +#include <vcl/svapp.hxx> +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif +#include <tools/diagnose_ex.h> +#ifndef _DBAUI_LOCALRESACCESS_HXX_ +#include "localresaccess.hxx" +#endif +#ifndef INCLUDED_SVTOOLS_SYSLOCALE_HXX +#include <unotools/syslocale.hxx> +#endif + +#define EF_VISITED 0x0001 +#define EF_DIRTY 0x0002 + +//......................................................................... +namespace dbaui +{ +//......................................................................... + + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::beans; + using namespace ::com::sun::star::container; + using namespace ::com::sun::star::sdbc; + using namespace ::com::sun::star::util; + using namespace ::connectivity; + + //================================================================== + //= OParameterDialog + //================================================================== + + //------------------------------------------------------------------------------ + #define INIT_MEMBERS() \ + :ModalDialog( pParent, ModuleRes(DLG_PARAMETERS)) \ + ,m_aNamesFrame (this, ModuleRes(FL_PARAMS)) \ + ,m_aAllParams (this, ModuleRes(LB_ALLPARAMS)) \ + ,m_aValueFrame (this, ModuleRes(FT_VALUE)) \ + ,m_aParam (this, ModuleRes(ET_PARAM)) \ + ,m_aTravelNext (this, ModuleRes(BT_TRAVELNEXT)) \ + ,m_aOKBtn (this, ModuleRes(BT_OK)) \ + ,m_aCancelBtn (this, ModuleRes(BT_CANCEL)) \ + ,m_nCurrentlySelected(LISTBOX_ENTRY_NOTFOUND) \ + ,m_xConnection(_rxConnection) \ + ,m_aPredicateInput( _rxORB, _rxConnection, getParseContext() ) \ + ,m_bNeedErrorOnCurrent(sal_True) \ + + + //------------------------------------------------------------------------------ +DBG_NAME(OParameterDialog) + + OParameterDialog::OParameterDialog( + Window* pParent, const Reference< XIndexAccess > & rParamContainer, + const Reference< XConnection > & _rxConnection, const Reference< XMultiServiceFactory >& _rxORB) + INIT_MEMBERS() + { + DBG_CTOR(OParameterDialog,NULL); + + if (_rxORB.is()) + m_xFormatter = Reference< XNumberFormatter>(_rxORB->createInstance( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.NumberFormatter"))), UNO_QUERY); + else { + DBG_ERROR("OParameterDialog::OParameterDialog: need a service factory!"); + } + + Reference< XNumberFormatsSupplier > xNumberFormats = ::dbtools::getNumberFormats(m_xConnection, sal_True); + if (!xNumberFormats.is()) + ::comphelper::disposeComponent(m_xFormatter); + else if (m_xFormatter.is()) + m_xFormatter->attachNumberFormatsSupplier(xNumberFormats); + try + { + DBG_ASSERT(rParamContainer->getCount(), "OParameterDialog::OParameterDialog : can't handle empty containers !"); + + m_aFinalValues.realloc(rParamContainer->getCount()); + PropertyValue* pValues = m_aFinalValues.getArray(); + + for (sal_Int32 i = 0, nCount = rParamContainer->getCount(); i<nCount; ++i, ++pValues) + { + Reference< XPropertySet > xParamAsSet; + rParamContainer->getByIndex(i) >>= xParamAsSet; + OSL_ENSURE(xParamAsSet.is(),"Parameter is null!"); + if(!xParamAsSet.is()) + continue; + pValues->Name = ::comphelper::getString(xParamAsSet->getPropertyValue(PROPERTY_NAME)); + m_aAllParams.InsertEntry(pValues->Name); + + if (!pValues->Value.hasValue()) + // it won't have a value, 'cause it's default constructed. But may be later we support + // initializing this dialog with values + pValues->Value = makeAny(::rtl::OUString()); + // default the values to an empty string + + m_aVisitedParams.push_back(0); + // not visited, not dirty + } + + m_xParams = rParamContainer; + } + catch(Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + + + Construct(); + + m_aResetVisitFlag.SetTimeoutHdl(LINK(this, OParameterDialog, OnVisitedTimeout)); + + FreeResource(); + } + + //------------------------------------------------------------------------------ + OParameterDialog::~OParameterDialog() + { + if (m_aResetVisitFlag.IsActive()) + m_aResetVisitFlag.Stop(); + + DBG_DTOR(OParameterDialog,NULL); + } + + //------------------------------------------------------------------------------ + void OParameterDialog::Construct() + { + m_aAllParams.SetSelectHdl(LINK(this, OParameterDialog, OnEntrySelected)); + m_aParam.SetLoseFocusHdl(LINK(this, OParameterDialog, OnValueLoseFocus)); + m_aParam.SetModifyHdl(LINK(this, OParameterDialog, OnValueModified)); + m_aTravelNext.SetClickHdl(LINK(this, OParameterDialog, OnButtonClicked)); + m_aOKBtn.SetClickHdl(LINK(this, OParameterDialog, OnButtonClicked)); + m_aCancelBtn.SetClickHdl(LINK(this, OParameterDialog, OnButtonClicked)); + + if (m_aAllParams.GetEntryCount()) + { + m_aAllParams.SelectEntryPos(0); + LINK(this, OParameterDialog, OnEntrySelected).Call(&m_aAllParams); + + if (m_aAllParams.GetEntryCount() == 1) + { + m_aTravelNext.Enable(sal_False); + } + + if (m_aAllParams.GetEntryCount() > 1) + { + m_aOKBtn.SetStyle(m_aOKBtn.GetStyle() & ~WB_DEFBUTTON); + m_aTravelNext.SetStyle(m_aTravelNext.GetStyle() | WB_DEFBUTTON); + } + } + + m_aParam.GrabFocus(); + } + + //------------------------------------------------------------------------------ + IMPL_LINK(OParameterDialog, OnValueLoseFocus, Control*, /*pSource*/) + { + if (m_nCurrentlySelected != LISTBOX_ENTRY_NOTFOUND) + { + if ( ( m_aVisitedParams[ m_nCurrentlySelected ] & EF_DIRTY ) == 0 ) + // nothing to do, the value isn't dirty + return 0L; + } + + // transform the current string according to the param field type + ::rtl::OUString sTransformedText(m_aParam.GetText()); + Reference< XPropertySet > xParamAsSet; + m_xParams->getByIndex(m_nCurrentlySelected) >>= xParamAsSet; + if (xParamAsSet.is()) + { + if (m_xConnection.is() && m_xFormatter.is()) + { + ::rtl::OUString sParamValue( m_aParam.GetText() ); + sal_Bool bValid = m_aPredicateInput.normalizePredicateString( sParamValue, xParamAsSet ); + m_aParam.SetText( sParamValue ); + if ( bValid ) + { + // with this the value isn't dirty anymore + if (m_nCurrentlySelected != LISTBOX_ENTRY_NOTFOUND) + m_aVisitedParams[m_nCurrentlySelected] &= ~EF_DIRTY; + } + else + { + if (!m_bNeedErrorOnCurrent) + return 1L; + + m_bNeedErrorOnCurrent = sal_False; // will be reset in OnValueModified + + ::rtl::OUString sName; + try + { + sName = ::comphelper::getString(xParamAsSet->getPropertyValue(PROPERTY_NAME)); + } + catch(Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + + String sMessage; + { + LocalResourceAccess aDummy(DLG_PARAMETERS, RSC_MODALDIALOG); + sMessage = String(ModuleRes(STR_COULD_NOT_CONVERT_PARAM)); + } + sMessage.SearchAndReplaceAll(String::CreateFromAscii("$name$"), sName.getStr()); + ErrorBox(NULL, WB_OK, sMessage).Execute(); + m_aParam.GrabFocus(); + return 1L; + } + } + } + + return 0L; + } + + //------------------------------------------------------------------------------ + IMPL_LINK(OParameterDialog, OnButtonClicked, PushButton*, pButton) + { + if (&m_aCancelBtn == pButton) + { + // no interpreting of the given values anymore .... + m_aParam.SetLoseFocusHdl(Link()); // no direct call from the control anymore ... + m_bNeedErrorOnCurrent = sal_False; // in case of any indirect calls -> no error message + m_aCancelBtn.SetClickHdl(Link()); + m_aCancelBtn.Click(); + } + else if (&m_aOKBtn == pButton) + { + // transfer the current values into the Any + if (LINK(this, OParameterDialog, OnEntrySelected).Call(&m_aAllParams) != 0L) + { // there was an error interpreting the current text + m_bNeedErrorOnCurrent = sal_True; + // we're are out of the complex web :) of direct and indirect calls to OnValueLoseFocus now, + // so the next time it is called we need an error message, again .... + // (TODO : there surely are better solutions for this ...) + return 1L; + } + + if (m_xParams.is()) + { + // write the parameters + try + { + ::rtl::OUString sError; + PropertyValue* pValues = m_aFinalValues.getArray(); + for (sal_Int32 i = 0, nCount = m_xParams->getCount(); i<nCount; ++i, ++pValues) + { + Reference< XPropertySet > xParamAsSet; + m_xParams->getByIndex(i) >>= xParamAsSet; + + ::rtl::OUString sValue; + pValues->Value >>= sValue; + pValues->Value <<= ::rtl::OUString( m_aPredicateInput.getPredicateValue( sValue, xParamAsSet, sal_False ) ); + } + } + catch(Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + + } + // to close the dialog (which is more code than a simple EndDialog) + m_aOKBtn.SetClickHdl(Link()); + m_aOKBtn.Click(); + } + else if (&m_aTravelNext == pButton) + { + sal_uInt16 nCurrent = m_aAllParams.GetSelectEntryPos(); + sal_uInt16 nCount = m_aAllParams.GetEntryCount(); + DBG_ASSERT(nCount == m_aVisitedParams.size(), "OParameterDialog::OnButtonClicked : inconsistent lists !"); + + // search the next entry in list we haven't visited yet + sal_uInt16 nNext = (nCurrent + 1) % nCount; + while ((nNext != nCurrent) && ( m_aVisitedParams[nNext] & EF_VISITED )) + nNext = (nNext + 1) % nCount; + + if ( m_aVisitedParams[nNext] & EF_VISITED ) + // there is no such "not visited yet" entry -> simpy take the next one + nNext = (nCurrent + 1) % nCount; + + m_aAllParams.SelectEntryPos(nNext); + LINK(this, OParameterDialog, OnEntrySelected).Call(&m_aAllParams); + m_bNeedErrorOnCurrent = sal_True; + // we're are out of the complex web :) of direct and indirect calls to OnValueLoseFocus now, + // so the next time it is called we need an error message, again .... + // (TODO : there surely are better solutions for this ...) + } + + return 0L; + } + + //------------------------------------------------------------------------------ + IMPL_LINK(OParameterDialog, OnEntrySelected, ListBox*, /*pList*/) + { + if (m_aResetVisitFlag.IsActive()) + { + LINK(this, OParameterDialog, OnVisitedTimeout).Call(&m_aResetVisitFlag); + m_aResetVisitFlag.Stop(); + } + // save the old values + if (m_nCurrentlySelected != LISTBOX_ENTRY_NOTFOUND) + { + // do the transformation of the current text + if (LINK(this, OParameterDialog, OnValueLoseFocus).Call(&m_aParam) != 0L) + { // there was an error interpreting the text + m_aAllParams.SelectEntryPos(m_nCurrentlySelected); + return 1L; + } + + m_aFinalValues[m_nCurrentlySelected].Value <<= ::rtl::OUString(m_aParam.GetText()); + } + + // initialize the controls with the new values + sal_uInt16 nSelected = m_aAllParams.GetSelectEntryPos(); + DBG_ASSERT(nSelected != LISTBOX_ENTRY_NOTFOUND, "OParameterDialog::OnEntrySelected : no current entry !"); + + m_aParam.SetText(::comphelper::getString(m_aFinalValues[nSelected].Value)); + m_nCurrentlySelected = nSelected; + + // with this the value isn't dirty + DBG_ASSERT(m_nCurrentlySelected < m_aVisitedParams.size(), "OParameterDialog::OnEntrySelected : invalid current entry !"); + m_aVisitedParams[m_nCurrentlySelected] &= ~EF_DIRTY; + + m_aResetVisitFlag.SetTimeout(1000); + m_aResetVisitFlag.Start(); + + return 0L; + } + + //------------------------------------------------------------------------------ + IMPL_LINK(OParameterDialog, OnVisitedTimeout, Timer*, /*pTimer*/) + { + DBG_ASSERT(m_nCurrentlySelected != LISTBOX_ENTRY_NOTFOUND, "OParameterDialog::OnVisitedTimeout : invalid call !"); + + // mark the currently selected entry as visited + DBG_ASSERT(m_nCurrentlySelected < m_aVisitedParams.size(), "OParameterDialog::OnVisitedTimeout : invalid entry !"); + m_aVisitedParams[m_nCurrentlySelected] |= EF_VISITED; + + // was it the last "not visited yet" entry ? + ConstByteVectorIterator aIter; + for ( aIter = m_aVisitedParams.begin(); + aIter < m_aVisitedParams.end(); + ++aIter + ) + { + if (((*aIter) & EF_VISITED) == 0) + break; + } + if (aIter == m_aVisitedParams.end()) + { // yes, there isn't another one -> change the "default button" + m_aTravelNext.SetStyle(m_aTravelNext.GetStyle() & ~WB_DEFBUTTON); + m_aOKBtn.SetStyle(m_aOKBtn.GetStyle() | WB_DEFBUTTON); + + // set to focus to one of the buttons temporary (with this their "default"-state is really updated) + Window* pOldFocus = Application::GetFocusWindow(); + + // if the old focus window is the value edit do some preparations ... + Selection aSel; + if (pOldFocus == &m_aParam) + { + m_aParam.SetLoseFocusHdl(Link()); + aSel = m_aParam.GetSelection(); + } + m_aTravelNext.GrabFocus(); + if (pOldFocus) + pOldFocus->GrabFocus(); + + // restore the settings for the value edit + if (pOldFocus == &m_aParam) + { + m_aParam.SetLoseFocusHdl(LINK(this, OParameterDialog, OnValueLoseFocus)); + m_aParam.SetSelection(aSel); + } + } + + return 0L; + } + + //------------------------------------------------------------------------------ + IMPL_LINK(OParameterDialog, OnValueModified, Control*, /*pBox*/) + { + // mark the currently selected entry as dirty + DBG_ASSERT(m_nCurrentlySelected < m_aVisitedParams.size(), "OParameterDialog::OnValueModified : invalid entry !"); + m_aVisitedParams[m_nCurrentlySelected] |= EF_DIRTY; + + m_bNeedErrorOnCurrent = sal_True; + + return 0L; + } + + +//......................................................................... +} // namespace dbaui +//......................................................................... diff --git a/dbaccess/source/ui/dlg/paramdialog.hrc b/dbaccess/source/ui/dlg/paramdialog.hrc new file mode 100644 index 000000000000..0b834dd3e7eb --- /dev/null +++ b/dbaccess/source/ui/dlg/paramdialog.hrc @@ -0,0 +1,46 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBAUI_PARAMDIALOG_HRC_ +#define _DBAUI_PARAMDIALOG_HRC_ + +#define LB_ALLPARAMS 1 +#define FL_PARAMS 2 +#define FT_VALUE 3 +#define ET_PARAM 4 +#define CB_NULLVAL 5 +#define BT_TRAVELNEXT 6 +#define BT_OK 7 +#define BT_CANCEL 8 +#define AB_PREV 9 +#define AB_NEXT 10 + + +#define STR_COULD_NOT_CONVERT_PARAM 1 + +#endif // _DBAUI_PARAMDIALOG_HRC_ + diff --git a/dbaccess/source/ui/dlg/paramdialog.src b/dbaccess/source/ui/dlg/paramdialog.src new file mode 100644 index 000000000000..3993096f8847 --- /dev/null +++ b/dbaccess/source/ui/dlg/paramdialog.src @@ -0,0 +1,100 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBAUI_PARAMDIALOG_HRC_ +#include "paramdialog.hrc" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif + +#define LIST_WIDTH 100 +#define LIST_HEIGHT 50 + +ModalDialog DLG_PARAMETERS +{ + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 6 + LIST_WIDTH + 3 + 6 + BUTTON_WIDTH + 6, 98 ) ; + Moveable = TRUE ; + Closeable = TRUE ; + + + FixedLine FL_PARAMS + { + Pos = MAP_APPFONT ( 4 , 3 ) ; + Size = MAP_APPFONT ( 3 + LIST_WIDTH + 3 , 8 ) ; + Text [ en-US ] = "~Parameters"; + }; + ListBox LB_ALLPARAMS + { + Pos = MAP_APPFONT ( 7 , 12 ) ; + Size = MAP_APPFONT ( LIST_WIDTH , LIST_HEIGHT ) ; + Border = TRUE; + SVLook = TRUE; + }; + FixedText FT_VALUE + { + Pos = MAP_APPFONT ( 7 , 12 + LIST_HEIGHT + 4 ) ; + Size = MAP_APPFONT ( LIST_WIDTH , 8 ) ; + Text [ en-US ] = "~Value"; + }; + Edit ET_PARAM + { + Border = TRUE ; + Pos = MAP_APPFONT ( 7 , 12 + LIST_HEIGHT + 4 + 8 + 3 ) ; + Size = MAP_APPFONT ( LIST_WIDTH , 12 ) ; + TabStop = TRUE ; + }; + PushButton BT_TRAVELNEXT + { + Pos = MAP_APPFONT ( 4 + 3 + LIST_WIDTH + 3 + 6 , 12 + LIST_HEIGHT + 4 + 8 + 3 + ( 12 - BUTTON_HEIGHT ) / 2) ; + Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ; + TabStop = TRUE ; + Text [ en-US ] = "~Next"; + }; + OKButton BT_OK + { + Pos = MAP_APPFONT ( 4 + 3 + LIST_WIDTH + 3 + 6 , 3 ) ; + Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ; + TabStop = TRUE ; + DefButton = TRUE ; + }; + CancelButton BT_CANCEL + { + Pos = MAP_APPFONT ( 4 + 3 + LIST_WIDTH + 3 + 6 , 3 + BUTTON_HEIGHT + 3 ) ; + Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ; + TabStop = TRUE ; + }; + Text [ en-US ] = "Parameter Input" ; + + String STR_COULD_NOT_CONVERT_PARAM + { + Text [ en-US ] = "The entry could not be converted to a valid value for the \"$name$\"column"; + }; +}; + diff --git a/dbaccess/source/ui/dlg/queryfilter.cxx b/dbaccess/source/ui/dlg/queryfilter.cxx new file mode 100644 index 000000000000..96eb49b1c38e --- /dev/null +++ b/dbaccess/source/ui/dlg/queryfilter.cxx @@ -0,0 +1,921 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#ifndef DBAUI_QUERYFILTER_HXX +#include "queryfilter.hxx" +#endif +#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "moduledbu.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_DATE_HPP_ +#include <com/sun/star/util/Date.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_ +#include <com/sun/star/util/DateTime.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_TIME_HPP_ +#include <com/sun/star/util/Time.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSER_HPP_ +#include <com/sun/star/sdb/XSQLQueryComposer.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNSEARCH_HPP_ +#include <com/sun/star/sdbc/ColumnSearch.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_SQLFILTEROPERATOR_HPP_ +#include <com/sun/star/sdb/SQLFilterOperator.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#endif +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif +#ifndef TOOLS_DIAGNOSE_EX_H +#include <tools/diagnose_ex.h> +#endif +#ifndef TOOLS_DIAGNOSE_EX_H +#include <tools/diagnose_ex.h> +#endif +#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "moduledbu.hxx" +#endif +#ifndef _CONNECTIVITY_PARSE_SQLITERATOR_HXX_ +#include <connectivity/sqliterator.hxx> +#endif +#ifndef _CONNECTIVITY_DBTOOLS_HXX_ +#include <connectivity/dbtools.hxx> +#endif +#ifndef DBAUI_QUERYFILTER_HRC +#include "queryfilter.hrc" +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_ +#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_SQLFILTEROPERATOR_HPP_ +#include <com/sun/star/sdb/SQLFilterOperator.hpp> +#endif + +using namespace dbaui; +using namespace connectivity; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +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::sdb; +using namespace ::com::sun::star::beans; + +//------------------------------------------------------------------------------ +void Replace_OS_PlaceHolder(String& aString) +{ + while (aString.SearchAndReplace( '*', '%' ) != STRING_NOTFOUND) ; + while (aString.SearchAndReplace( '?', '_' ) != STRING_NOTFOUND) ; +} + +//------------------------------------------------------------------------------ +void Replace_SQL_PlaceHolder(String& aString) +{ + while (aString.SearchAndReplace( '%', '*' ) != STRING_NOTFOUND) ; + while (aString.SearchAndReplace( '_', '?' ) != STRING_NOTFOUND) ; +} + +DBG_NAME(DlgFilterCrit); +//------------------------------------------------------------------------------ +DlgFilterCrit::DlgFilterCrit(Window * pParent, + const Reference< XMultiServiceFactory >& _rxORB, + const Reference< XConnection>& _rxConnection, + const Reference< XSingleSelectQueryComposer >& _rxComposer, + const Reference< XNameAccess>& _rxCols + ) + :ModalDialog( pParent, ModuleRes( DLG_FILTERCRIT ) ) + ,aLB_WHEREFIELD1 ( this, ModuleRes( LB_WHEREFIELD1 ) ) + ,aLB_WHERECOMP1 ( this, ModuleRes( LB_WHERECOMP1 ) ) + ,aET_WHEREVALUE1 ( this, ModuleRes( ET_WHEREVALUE1 ) ) + ,aLB_WHERECOND2 ( this, ModuleRes( LB_WHERECOND2 ) ) + ,aLB_WHEREFIELD2 ( this, ModuleRes( LB_WHEREFIELD2 ) ) + ,aLB_WHERECOMP2 ( this, ModuleRes( LB_WHERECOMP2 ) ) + ,aET_WHEREVALUE2 ( this, ModuleRes( ET_WHEREVALUE2 ) ) + ,aLB_WHERECOND3 ( this, ModuleRes( LB_WHERECOND3 ) ) + ,aLB_WHEREFIELD3 ( this, ModuleRes( LB_WHEREFIELD3 ) ) + ,aLB_WHERECOMP3 ( this, ModuleRes( LB_WHERECOMP3 ) ) + ,aET_WHEREVALUE3 ( this, ModuleRes( ET_WHEREVALUE3 ) ) + ,aFT_WHEREFIELD ( this, ModuleRes( FT_WHEREFIELD ) ) + ,aFT_WHERECOMP ( this, ModuleRes( FT_WHERECOMP ) ) + ,aFT_WHEREVALUE ( this, ModuleRes( FT_WHEREVALUE ) ) + ,aFT_WHEREOPER ( this, ModuleRes( FT_WHEREOPER ) ) + ,aFL_FIELDS ( this, ModuleRes( FL_FIELDS ) ) + ,aBT_OK ( this, ModuleRes( BT_OK ) ) + ,aBT_CANCEL ( this, ModuleRes( BT_CANCEL ) ) + ,aBT_HELP ( this, ModuleRes( BT_HELP ) ) + ,aSTR_NOENTRY ( ModuleRes( STR_NOENTRY ) ) + ,aSTR_COMPARE_OPERATORS( ModuleRes( STR_COMPARE_OPERATORS ) ) + ,m_xQueryComposer(_rxComposer) + ,m_xColumns( _rxCols ) + ,m_xConnection( _rxConnection ) + ,m_xMetaData( _rxConnection->getMetaData() ) + ,m_aPredicateInput( _rxORB, _rxConnection, getParseContext() ) +{ + DBG_CTOR(DlgFilterCrit,NULL); + // Den String fuer noEntry in die ListBoxen der Feldnamen schreiben + aLB_WHEREFIELD1.InsertEntry( aSTR_NOENTRY ); + aLB_WHEREFIELD2.InsertEntry( aSTR_NOENTRY ); + aLB_WHEREFIELD3.InsertEntry( aSTR_NOENTRY ); + + try + { + // ... sowie auch die restlichen Felder + Sequence< ::rtl::OUString> aNames = m_xColumns->getElementNames(); + const ::rtl::OUString* pIter = aNames.getConstArray(); + const ::rtl::OUString* pEnd = pIter + aNames.getLength(); + Reference<XPropertySet> xColumn; + for(;pIter != pEnd;++pIter) + { + try + { + xColumn.set( m_xColumns->getByName( *pIter ), UNO_QUERY_THROW ); + + sal_Int32 nDataType( 0 ); + OSL_VERIFY( xColumn->getPropertyValue( PROPERTY_TYPE ) >>= nDataType ); + sal_Int32 eColumnSearch = ::dbtools::getSearchColumnFlag( m_xConnection, nDataType ); + if ( eColumnSearch == ColumnSearch::NONE ) + continue; + + sal_Bool bIsSearchable( sal_True ); + OSL_VERIFY( xColumn->getPropertyValue( PROPERTY_ISSEARCHABLE ) >>= bIsSearchable ); + if ( !bIsSearchable ) + continue; + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + aLB_WHEREFIELD1.InsertEntry( *pIter ); + aLB_WHEREFIELD2.InsertEntry( *pIter ); + aLB_WHEREFIELD3.InsertEntry( *pIter ); + } + + Reference<XNameAccess> xSelectColumns = Reference<XColumnsSupplier>(m_xQueryComposer,UNO_QUERY)->getColumns(); + aNames = xSelectColumns->getElementNames(); + pIter = aNames.getConstArray(); + pEnd = pIter + aNames.getLength(); + for(;pIter != pEnd;++pIter) + { + // don't insert a column name twice + if ( !m_xColumns->hasByName(*pIter) ) + { + xColumn.set(xSelectColumns->getByName(*pIter),UNO_QUERY); + OSL_ENSURE(xColumn.is(),"DlgFilterCrit::DlgFilterCrit: Column is null!"); + sal_Int32 nDataType(0); + xColumn->getPropertyValue(PROPERTY_TYPE) >>= nDataType; + sal_Int32 eColumnSearch = dbtools::getSearchColumnFlag(m_xConnection,nDataType); + // TODO + // !pColumn->IsFunction() + if(eColumnSearch != ColumnSearch::NONE) + { + aLB_WHEREFIELD1.InsertEntry( *pIter ); + aLB_WHEREFIELD2.InsertEntry( *pIter ); + aLB_WHEREFIELD3.InsertEntry( *pIter ); + } + } + } + // initialize the listboxes with noEntry + aLB_WHEREFIELD1.SelectEntryPos(0); + aLB_WHEREFIELD2.SelectEntryPos(0); + aLB_WHEREFIELD3.SelectEntryPos(0); + + // insert the criteria into the dialog + Sequence<Sequence<PropertyValue > > aValues = m_xQueryComposer->getStructuredFilter(); + fillLines(aValues); + aValues = m_xQueryComposer->getStructuredHavingClause(); + fillLines(aValues); + + } + catch(Exception&) + { + FreeResource(); + throw; + } + + EnableLines(); + + aLB_WHEREFIELD1.SetSelectHdl(LINK(this,DlgFilterCrit,ListSelectHdl)); + aLB_WHEREFIELD2.SetSelectHdl(LINK(this,DlgFilterCrit,ListSelectHdl)); + aLB_WHEREFIELD3.SetSelectHdl(LINK(this,DlgFilterCrit,ListSelectHdl)); + + aLB_WHERECOMP1.SetSelectHdl(LINK(this,DlgFilterCrit,ListSelectCompHdl)); + aLB_WHERECOMP2.SetSelectHdl(LINK(this,DlgFilterCrit,ListSelectCompHdl)); + aLB_WHERECOMP3.SetSelectHdl(LINK(this,DlgFilterCrit,ListSelectCompHdl)); + + aET_WHEREVALUE1.SetLoseFocusHdl( LINK( this, DlgFilterCrit, PredicateLoseFocus ) ); + aET_WHEREVALUE2.SetLoseFocusHdl( LINK( this, DlgFilterCrit, PredicateLoseFocus ) ); + aET_WHEREVALUE3.SetLoseFocusHdl( LINK( this, DlgFilterCrit, PredicateLoseFocus ) ); + + if ( aET_WHEREVALUE1.IsEnabled() ) + aET_WHEREVALUE1.GrabFocus(); + + FreeResource(); +} +//------------------------------------------------------------------------------ +DlgFilterCrit::~DlgFilterCrit() +{ + DBG_DTOR(DlgFilterCrit,NULL); +} + +#define LbText(x) ((x).GetSelectEntry()) +#define LbPos(x) ((x).GetSelectEntryPos()) + +//------------------------------------------------------------------------------ +sal_Int32 DlgFilterCrit::GetOSQLPredicateType( const String& _rSelectedPredicate ) const +{ + sal_Int32 nPredicateIndex = -1; + for ( xub_StrLen i=0; i<aSTR_COMPARE_OPERATORS.GetTokenCount(); ++i) + if ( aSTR_COMPARE_OPERATORS.GetToken(i) == _rSelectedPredicate ) + { + nPredicateIndex = i; + break; + } + + sal_Int32 nPredicateType = SQLFilterOperator::NOT_SQLNULL; + switch ( nPredicateIndex ) + { + case 0: + nPredicateType = SQLFilterOperator::EQUAL; + break; + case 1: + nPredicateType = SQLFilterOperator::NOT_EQUAL; + break; + case 2: + nPredicateType = SQLFilterOperator::LESS; + break; + case 3: + nPredicateType = SQLFilterOperator::LESS_EQUAL; + break; + case 4: + nPredicateType = SQLFilterOperator::GREATER; + break; + case 5: + nPredicateType = SQLFilterOperator::GREATER_EQUAL; + break; + case 6: + nPredicateType = SQLFilterOperator::LIKE; + break; + case 7: + nPredicateType = SQLFilterOperator::NOT_LIKE; + break; + case 8: + nPredicateType = SQLFilterOperator::SQLNULL; + break; + case 9: + nPredicateType = SQLFilterOperator::NOT_SQLNULL; + break; + default: + OSL_ENSURE( false, "DlgFilterCrit::GetOSQLPredicateType: unknown predicate string!" ); + break; + } + + return nPredicateType; +} +//------------------------------------------------------------------------------ +sal_uInt16 DlgFilterCrit::GetSelectionPos(sal_Int32 eType,const ListBox& rListBox) const +{ + sal_uInt16 nPos; + switch(eType) + { + case SQLFilterOperator::EQUAL: + nPos = 0; + break; + case SQLFilterOperator::NOT_EQUAL: + nPos = 1; + break; + case SQLFilterOperator::LESS: + nPos = 2; + break; + case SQLFilterOperator::LESS_EQUAL: + nPos = 3; + break; + case SQLFilterOperator::GREATER: + nPos = 4; + break; + case SQLFilterOperator::GREATER_EQUAL: + nPos = 5; + break; + case SQLFilterOperator::NOT_LIKE: + nPos = rListBox.GetEntryCount() > 2 ? rListBox.GetEntryCount()-3 : 0; + break; + case SQLFilterOperator::LIKE: + nPos = rListBox.GetEntryCount() > 2 ? rListBox.GetEntryCount()-4 : 1; + break; + case SQLFilterOperator::SQLNULL: + nPos = rListBox.GetEntryCount()-2; + break; + case SQLFilterOperator::NOT_SQLNULL: + nPos = rListBox.GetEntryCount()-1; + break; + default: + // TODO What value should this be? + nPos = 0; + break; + } + return nPos; +} +// ----------------------------------------------------------------------------- +sal_Bool DlgFilterCrit::getCondition(const ListBox& _rField,const ListBox& _rComp,const Edit& _rValue,PropertyValue& _rFilter) const +{ + sal_Bool bHaving = sal_False; + try + { + ::rtl::OUString sTableName; + sal_Bool bFunction = sal_False; + _rFilter.Name = _rField.GetSelectEntry(); + Reference< XPropertySet > xColumn = getQueryColumn(_rFilter.Name); + if ( xColumn.is() ) + { + Reference< XPropertySetInfo > xInfo = xColumn->getPropertySetInfo(); + if ( xInfo->hasPropertyByName(PROPERTY_REALNAME) ) + { + if ( xInfo->hasPropertyByName(PROPERTY_TABLENAME) ) + { + xColumn->getPropertyValue(PROPERTY_TABLENAME) >>= sTableName; + if ( sTableName.getLength() ) + { + // properly quote all parts of the table name, so e.g. <schema>.<table> becomes "<schema>"."<table>" + ::rtl::OUString aCatlog,aSchema,aTable; + ::dbtools::qualifiedNameComponents( m_xMetaData, sTableName, aCatlog, aSchema, aTable, ::dbtools::eInDataManipulation ); + sTableName = ::dbtools::composeTableName( m_xMetaData, aCatlog, aSchema, aTable, sal_True, ::dbtools::eInDataManipulation ); + } + } + xColumn->getPropertyValue(PROPERTY_REALNAME) >>= _rFilter.Name; + static ::rtl::OUString sAgg(RTL_CONSTASCII_USTRINGPARAM("AggregateFunction")); + if ( xInfo->hasPropertyByName(sAgg) ) + xColumn->getPropertyValue(sAgg) >>= bHaving; + static ::rtl::OUString sFunction(RTL_CONSTASCII_USTRINGPARAM("Function")); + if ( xInfo->hasPropertyByName(sFunction) ) + xColumn->getPropertyValue(sFunction) >>= bFunction; + } + if ( !bFunction ) + { + const ::rtl::OUString aQuote = m_xMetaData.is() ? m_xMetaData->getIdentifierQuoteString() : ::rtl::OUString(); + _rFilter.Name = ::dbtools::quoteName(aQuote,_rFilter.Name); + if ( sTableName.getLength() ) + { + static ::rtl::OUString sSep(RTL_CONSTASCII_USTRINGPARAM(".")); + sTableName += sSep; + sTableName += _rFilter.Name; + _rFilter.Name = sTableName; + } + } // if ( !bFunction ) + } + } + catch(Exception) + { + } + + _rFilter.Handle = GetOSQLPredicateType( _rComp.GetSelectEntry() ); + if ( SQLFilterOperator::SQLNULL != _rFilter.Handle && _rFilter.Handle != SQLFilterOperator::NOT_SQLNULL ) + { + String sPredicateValue = m_aPredicateInput.getPredicateValue( _rValue.GetText(), getMatchingColumn( _rValue ), sal_True ); + ::Replace_OS_PlaceHolder( sPredicateValue ); + _rFilter.Value <<= ::rtl::OUString(sPredicateValue); + } + return bHaving; +} + +//------------------------------------------------------------------------------ +Reference< XPropertySet > DlgFilterCrit::getColumn( const ::rtl::OUString& _rFieldName ) const +{ + Reference< XPropertySet > xColumn; + try + { + if ( m_xColumns.is() && m_xColumns->hasByName( _rFieldName ) ) + m_xColumns->getByName( _rFieldName ) >>= xColumn; + + Reference< XNameAccess> xColumns = Reference< XColumnsSupplier >(m_xQueryComposer,UNO_QUERY)->getColumns(); + if ( xColumns.is() && !xColumn.is() ) + { + Sequence< ::rtl::OUString> aSeq = xColumns->getElementNames(); + const ::rtl::OUString* pIter = aSeq.getConstArray(); + const ::rtl::OUString* pEnd = pIter + aSeq.getLength(); + for(;pIter != pEnd;++pIter) + { + Reference<XPropertySet> xProp(xColumns->getByName(*pIter),UNO_QUERY); + if ( xProp.is() && xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_REALNAME) ) + { + ::rtl::OUString sRealName; + xProp->getPropertyValue(PROPERTY_REALNAME) >>= sRealName; + if ( sRealName == _rFieldName ) + { + if ( m_xColumns.is() && m_xColumns->hasByName( *pIter ) ) + m_xColumns->getByName( *pIter ) >>= xColumn; + break; + } + } + } + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + return xColumn; +} +//------------------------------------------------------------------------------ +Reference< XPropertySet > DlgFilterCrit::getQueryColumn( const ::rtl::OUString& _rFieldName ) const +{ + Reference< XPropertySet > xColumn; + try + { + Reference< XNameAccess> xColumns = Reference< XColumnsSupplier >(m_xQueryComposer,UNO_QUERY)->getColumns(); + if ( xColumns.is() && xColumns->hasByName( _rFieldName ) ) + xColumns->getByName( _rFieldName ) >>= xColumn; + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + return xColumn; +} + +//------------------------------------------------------------------------------ +Reference< XPropertySet > DlgFilterCrit::getMatchingColumn( const Edit& _rValueInput ) const +{ + // the name + ::rtl::OUString sField; + if ( &_rValueInput == &aET_WHEREVALUE1 ) + { + sField = aLB_WHEREFIELD1.GetSelectEntry(); + } + else if ( &_rValueInput == &aET_WHEREVALUE2 ) + { + sField = aLB_WHEREFIELD2.GetSelectEntry(); + } + else if ( &_rValueInput == &aET_WHEREVALUE3 ) + { + sField = aLB_WHEREFIELD3.GetSelectEntry(); + } + else { + DBG_ERROR( "DlgFilterCrit::getMatchingColumn: invalid event source!" ); + } + + // the field itself + return getColumn( sField ); +} + +//------------------------------------------------------------------------------ +IMPL_LINK( DlgFilterCrit, PredicateLoseFocus, Edit*, _pField ) +{ + DBG_ASSERT( _pField, "DlgFilterCrit::PredicateLoseFocus: invalid event source!" ); + if ( _pField ) + { + // retrieve the field affected + Reference< XPropertySet> xColumn( getMatchingColumn( *_pField ) ); + // and normalize it's content + if ( xColumn.is() ) + { + ::rtl::OUString sText( _pField->GetText() ); + m_aPredicateInput.normalizePredicateString( sText, xColumn ); + _pField->SetText( sText ); + } + } + + return 0L; +} + +//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +void DlgFilterCrit::SetLine( sal_uInt16 nIdx,const PropertyValue& _rItem,sal_Bool _bOr ) +{ + DBG_CHKTHIS(DlgFilterCrit,NULL); + ::rtl::OUString aCondition; + _rItem.Value >>= aCondition; + String aStr = aCondition.getStr(); + ::Replace_SQL_PlaceHolder(aStr); + aStr.EraseTrailingChars(); + + Reference< XPropertySet > xColumn = getColumn( _rItem.Name ); + + // remove the predicate from the condition + switch(_rItem.Handle) + { + case SQLFilterOperator::EQUAL: + // aStr.Erase(0,1); + break; + case SQLFilterOperator::NOT_EQUAL: + aStr.Erase(0,2); + break; + case SQLFilterOperator::LESS: + aStr.Erase(0,1); + break; + case SQLFilterOperator::LESS_EQUAL: + aStr.Erase(0,2); + break; + case SQLFilterOperator::GREATER: + aStr.Erase(0,1); + break; + case SQLFilterOperator::GREATER_EQUAL: + aStr.Erase(0,2); + break; + case SQLFilterOperator::NOT_LIKE: + aStr.Erase(0,8); + break; + case SQLFilterOperator::LIKE: + aStr.Erase(0,4); + break; + case SQLFilterOperator::SQLNULL: + aStr.Erase(0,7); + break; + case SQLFilterOperator::NOT_SQLNULL: + aStr.Erase(0,11); + break; + } + aStr.EraseLeadingChars(); + + // to make sure that we only set first three + ListBox* pColumnListControl = NULL; + ListBox* pPredicateListControl = NULL; + Edit* pPredicateValueControl = NULL; + switch( nIdx ) + { + case 0: + pColumnListControl = &aLB_WHEREFIELD1; + pPredicateListControl = &aLB_WHERECOMP1; + pPredicateValueControl = &aET_WHEREVALUE1; + break; + + case 1: + aLB_WHERECOND2.SelectEntryPos( _bOr ? 1 : 0 ); + + pColumnListControl = &aLB_WHEREFIELD2; + pPredicateListControl = &aLB_WHERECOMP2; + pPredicateValueControl = &aET_WHEREVALUE2; + break; + + case 2: + aLB_WHERECOND3.SelectEntryPos( _bOr ? 1 : 0 ); + + pColumnListControl = &aLB_WHEREFIELD3; + pPredicateListControl = &aLB_WHERECOMP3; + pPredicateValueControl = &aET_WHEREVALUE3; + break; + } + + if ( pColumnListControl && pPredicateListControl && pPredicateValueControl ) + { + ::rtl::OUString sName; + if ( xColumn.is() ) + xColumn->getPropertyValue(PROPERTY_NAME) >>= sName; + else + sName = _rItem.Name; + // select the appropriate field name + SelectField( *pColumnListControl, sName ); + ListSelectHdl( pColumnListControl ); + + // select the appropriate condition + pPredicateListControl->SelectEntryPos( GetSelectionPos( (sal_Int32)_rItem.Handle, *pPredicateListControl ) ); + + // initially normalize this value + ::rtl::OUString aString( aStr ); + m_aPredicateInput.normalizePredicateString( aString, xColumn ); + pPredicateValueControl->SetText( aString ); + } +} + +//------------------------------------------------------------------------------ +void DlgFilterCrit::SelectField( ListBox& rBox, const String& rField ) +{ + DBG_CHKTHIS(DlgFilterCrit,NULL); + sal_uInt16 nCnt = rBox.GetEntryCount(); + // sal_Bool bCase = m_rIterator.TablesAreSensitive(); + + for( sal_uInt16 i=0 ; i<nCnt ; i++ ) + { + // if(bCase ? rBox.GetEntry(i) == rField : rBox.GetEntry(i).EqualsIgnoreCaseAscii(rField)) + if(rBox.GetEntry(i) == rField) + { + rBox.SelectEntryPos(i); + return; + } + } + + rBox.SelectEntryPos(0); +} + +//------------------------------------------------------------------------------ +void DlgFilterCrit::EnableLines() +{ + DBG_CHKTHIS(DlgFilterCrit,NULL); + // Enablen/Disablen ganzer Zeilen + if( LbPos(aLB_WHEREFIELD1) == 0 ) + { + aLB_WHEREFIELD2.Disable(); + aLB_WHERECOND2.Disable(); + aLB_WHERECOMP2.Disable(); + aET_WHEREVALUE2.Disable(); + + aLB_WHEREFIELD3.Disable(); + aLB_WHERECOND3.Disable(); + aLB_WHERECOMP3.Disable(); + aET_WHEREVALUE3.Disable(); + } + else + { + aLB_WHEREFIELD2.Enable(); + aLB_WHERECOND2.Enable(); + aLB_WHERECOMP2.Enable(); + aET_WHEREVALUE2.Enable(); + + aLB_WHEREFIELD3.Enable(); + aLB_WHERECOND3.Enable(); + aLB_WHERECOMP3.Enable(); + aET_WHEREVALUE3.Enable(); + } + + if( LbPos(aLB_WHEREFIELD2) == 0 ) + { + aLB_WHEREFIELD3.Disable(); + aLB_WHERECOND3.Disable(); + aLB_WHERECOMP3.Disable(); + aET_WHEREVALUE3.Disable(); + } + else + { + aLB_WHEREFIELD3.Enable(); + aLB_WHERECOND3.Enable(); + aLB_WHERECOMP3.Enable(); + aET_WHEREVALUE3.Enable(); + } + + // Vergleichsfeld gleich NOENTRY + if( LbPos(aLB_WHEREFIELD1) == 0 ) + { + aLB_WHERECOMP1.Disable(); + aET_WHEREVALUE1.Disable(); + } + else + { + aLB_WHEREFIELD1.Enable(); + aLB_WHERECOMP1.Enable(); + aET_WHEREVALUE1.Enable(); + } + + if( LbPos(aLB_WHEREFIELD2) == 0 ) + { + aLB_WHERECOND2.Disable(); + aLB_WHERECOMP2.Disable(); + aET_WHEREVALUE2.Disable(); + } + else + { + aLB_WHERECOND2.Enable(); + aLB_WHEREFIELD2.Enable(); + aLB_WHERECOMP2.Enable(); + aET_WHEREVALUE2.Enable(); + } + + if( LbPos(aLB_WHEREFIELD3) == 0 ) + { + aLB_WHERECOND3.Disable(); + aLB_WHERECOMP3.Disable(); + aET_WHEREVALUE3.Disable(); + } + else + { + aLB_WHERECOND3.Enable(); + aLB_WHERECOND3.Enable(); + aLB_WHEREFIELD3.Enable(); + aLB_WHERECOMP3.Enable(); + aET_WHEREVALUE3.Enable(); + } + + // Vergleichsoperator gleich ISNULL oder ISNOTNULL + if(aLB_WHERECOMP1.GetEntryCount() > 2 && + ((LbPos(aLB_WHERECOMP1) == aLB_WHERECOMP1.GetEntryCount()-1) || + (LbPos(aLB_WHERECOMP1) == aLB_WHERECOMP1.GetEntryCount()-2)) ) + aET_WHEREVALUE1.Disable(); + + if(aLB_WHERECOMP2.GetEntryCount() > 2 && + ((LbPos(aLB_WHERECOMP2) == aLB_WHERECOMP2.GetEntryCount()-1) || + (LbPos(aLB_WHERECOMP2) == aLB_WHERECOMP2.GetEntryCount()-2)) ) + aET_WHEREVALUE2.Disable(); + + if(aLB_WHERECOMP3.GetEntryCount() > 2 && + ((LbPos(aLB_WHERECOMP3) == aLB_WHERECOMP3.GetEntryCount()-1) || + (LbPos(aLB_WHERECOMP3) == aLB_WHERECOMP3.GetEntryCount()-2)) ) + aET_WHEREVALUE3.Disable(); + +} + +//------------------------------------------------------------------------------ +IMPL_LINK( DlgFilterCrit, ListSelectHdl, ListBox *, pListBox ) +{ + String aName; + ListBox* pComp; + if(pListBox == &aLB_WHEREFIELD1) + { + aName = LbText(aLB_WHEREFIELD1); + pComp = &aLB_WHERECOMP1; + } + else if(pListBox == &aLB_WHEREFIELD2) + { + aName = LbText(aLB_WHEREFIELD2); + pComp = &aLB_WHERECOMP2; + } + else + { + aName = LbText(aLB_WHEREFIELD3); + pComp = &aLB_WHERECOMP3; + } + + pComp->Clear(); + + Reference<XPropertySet> xColumn = getColumn(aName); + if ( xColumn.is() ) + { + sal_Int32 nDataType = 0; + xColumn->getPropertyValue(PROPERTY_TYPE) >>= nDataType; + sal_Int32 eColumnSearch = dbtools::getSearchColumnFlag(m_xConnection,nDataType); + + if(eColumnSearch == ColumnSearch::FULL) + { + for(xub_StrLen i=0;i<aSTR_COMPARE_OPERATORS.GetTokenCount();i++) + pComp->InsertEntry(aSTR_COMPARE_OPERATORS.GetToken(i)); + } + else if(eColumnSearch == ColumnSearch::CHAR) + { + for(xub_StrLen i=6;i<10;i++) + pComp->InsertEntry(aSTR_COMPARE_OPERATORS.GetToken(i)); + } + else if(eColumnSearch == ColumnSearch::BASIC) + { + xub_StrLen i; + for( i = 0; i < 6; i++ ) + pComp->InsertEntry(aSTR_COMPARE_OPERATORS.GetToken(i)); + for(i=8;i<aSTR_COMPARE_OPERATORS.GetTokenCount();i++) + pComp->InsertEntry(aSTR_COMPARE_OPERATORS.GetToken(i)); + } + else + { + DBG_ASSERT(0,"DlgFilterCrit::ListSelectHdl: Diese Column d�rfte garnicht vorhanden sein!"); + } + } + pComp->SelectEntryPos(0); + + EnableLines(); + return 0; +} + + + +//------------------------------------------------------------------------------ +IMPL_LINK_INLINE_START( DlgFilterCrit, ListSelectCompHdl, ListBox *, /*pListBox*/ ) +{ + EnableLines(); + return 0; +} +IMPL_LINK_INLINE_END( DlgFilterCrit, ListSelectCompHdl, ListBox *, pListBox ) +//------------------------------------------------------------------------------ +void DlgFilterCrit::BuildWherePart() +{ + DBG_CHKTHIS(DlgFilterCrit,NULL); + Sequence<Sequence<PropertyValue> > aFilter,aHaving; + aFilter.realloc(1); + aHaving.realloc(1); + // ::rtl::OUString aFilter; + + if( LbPos(aLB_WHEREFIELD1) != 0 ) + { + PropertyValue aValue; + if ( getCondition(aLB_WHEREFIELD1,aLB_WHERECOMP1,aET_WHEREVALUE1,aValue) ) + { + aHaving[0].realloc(1); + aHaving[0][0] = aValue; + } + else + { + aFilter[0].realloc(1); + aFilter[0][0] = aValue; + } + } + + if( LbPos(aLB_WHEREFIELD2) != 0 ) + { + PropertyValue aValue; + Sequence<Sequence<PropertyValue> >& _rValues = aFilter; + if ( getCondition(aLB_WHEREFIELD2,aLB_WHERECOMP2,aET_WHEREVALUE2,aValue) ) + _rValues = aHaving; + PropertyValue* pPos = NULL; + if ( aLB_WHERECOND2.GetSelectEntryPos() ) + { + sal_Int32 nPos = _rValues.getLength(); + _rValues.realloc( nPos + 1); + _rValues[nPos].realloc( 1); + pPos = &_rValues[nPos][0]; + } + else + { + sal_Int32 nPos = _rValues.getLength() - 1; + sal_Int32 nAndPos = _rValues[nPos].getLength(); + _rValues[nPos].realloc( _rValues[nPos].getLength() + 1); + pPos = &_rValues[nPos][nAndPos]; + } + *pPos = aValue; + } + + if( LbPos(aLB_WHEREFIELD3) != 0 ) + { + PropertyValue aValue; + Sequence<Sequence<PropertyValue> >& _rValues = aFilter; + if ( getCondition(aLB_WHEREFIELD3,aLB_WHERECOMP3,aET_WHEREVALUE3,aValue) ) + _rValues = aHaving; + PropertyValue* pPos = NULL; + if ( aLB_WHERECOND3.GetSelectEntryPos() ) + { + sal_Int32 nPos = _rValues.getLength(); + _rValues.realloc( nPos + 1); + _rValues[nPos].realloc( 1); + pPos = &_rValues[nPos][0]; + } + else + { + sal_Int32 nPos = _rValues.getLength() - 1; + sal_Int32 nAndPos = _rValues[nPos].getLength(); + _rValues[nPos].realloc( _rValues[nPos].getLength() + 1); + pPos = &_rValues[nPos][nAndPos]; + } + *pPos = aValue; + } + try + { + m_xQueryComposer->setStructuredFilter(aFilter); + m_xQueryComposer->setStructuredHavingClause(aHaving); + } + catch(Exception) + { + DBG_UNHANDLED_EXCEPTION(); + } +} +// ----------------------------------------------------------------------------- +void DlgFilterCrit::fillLines(const Sequence<Sequence<PropertyValue > >& _aValues) +{ + const Sequence<PropertyValue >* pOrIter = _aValues.getConstArray(); + const Sequence<PropertyValue >* pOrEnd = pOrIter + _aValues.getLength(); + sal_Bool bOr = sal_True; + for(sal_uInt16 i=0;pOrIter != pOrEnd; ++pOrIter) + { + bOr = sal_True; + const PropertyValue* pAndIter = pOrIter->getConstArray(); + const PropertyValue* pAndEnd = pAndIter + pOrIter->getLength(); + for(;pAndIter != pAndEnd; ++pAndIter) + { + SetLine( i++,*pAndIter,bOr); + bOr = sal_False; + } + } +} + diff --git a/dbaccess/source/ui/dlg/queryfilter.hrc b/dbaccess/source/ui/dlg/queryfilter.hrc new file mode 100644 index 000000000000..ff2aaaca30d0 --- /dev/null +++ b/dbaccess/source/ui/dlg/queryfilter.hrc @@ -0,0 +1,64 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef DBAUI_QUERYFILTER_HRC +#define DBAUI_QUERYFILTER_HRC + +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif + +#define FT_WHEREFIELD 1 +#define FT_WHERECOMP 2 +#define FT_WHEREVALUE 3 +#define FT_WHEREOPER 4 + +#define LB_WHEREFIELD1 1 +#define LB_WHERECOMP1 2 +#define LB_WHEREFIELD2 3 +#define LB_WHERECOMP2 4 +#define LB_WHEREFIELD3 5 +#define LB_WHERECOMP3 6 +#define LB_WHERECOND2 7 +#define LB_WHERECOND3 8 + +#define FL_FIELDS 1 + +#define ET_WHEREVALUE1 1 +#define ET_WHEREVALUE2 2 +#define ET_WHEREVALUE3 3 + +#define STR_NOENTRY 1 +#define STR_NOENTRY2 2 +#define STR_DEFAULT 3 +#define STR_COMPARE_OPERATORS 4 + +#define BT_OK 1 +#define BT_CANCEL 2 +#define BT_HELP 3 + +#endif // DBAUI_QUERYFILTER_HRC + diff --git a/dbaccess/source/ui/dlg/queryfilter.src b/dbaccess/source/ui/dlg/queryfilter.src new file mode 100644 index 000000000000..2b1ef6e6baf5 --- /dev/null +++ b/dbaccess/source/ui/dlg/queryfilter.src @@ -0,0 +1,222 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBAUI_QUERYFILTER_HRC +#include "queryfilter.hrc" +#endif +#include "dbaccess_helpid.hrc" + +/* +#define STRLST_AND_OR \ + StringList [ en-US ] = \ + {\ + < "AND" ; Default ; > ; \ + < "OR" ; Default ; > ; \ + };\ +*/ + +ModalDialog DLG_FILTERCRIT +{ + OutputSize = TRUE ; + Hide = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 303 , 76 ) ; + /* These strings are equal to the toolbox bubble helptext from MID_SBA_QRY_FILTERCRIT in toolbox.hrc */ + Text [ en-US ] ="Standard Filter"; + + Moveable = TRUE ; + Closeable = TRUE ; + HelpId = HID_DLG_FILTERCRIT ; + ListBox LB_WHEREFIELD1 + { + Border = TRUE ; + Pos = MAP_APPFONT ( 60 , 25 ) ; + Size = MAP_APPFONT ( 60 , 90 ) ; + TabStop = TRUE ; + DropDown = TRUE ; + }; + ListBox LB_WHERECOMP1 + { + Border = TRUE ; + Pos = MAP_APPFONT ( 124 , 25 ) ; + Size = MAP_APPFONT ( 49 , 72 ) ; + TabStop = TRUE ; + DDExtraWidth = TRUE ; + DropDown = TRUE ; + CurPos = 0 ; + }; + Edit ET_WHEREVALUE1 + { + Border = TRUE ; + Pos = MAP_APPFONT ( 177 , 25 ) ; + Size = MAP_APPFONT ( 60 , 12 ) ; + TabStop = TRUE ; + }; + ListBox LB_WHERECOND2 + { + Border = TRUE ; + Pos = MAP_APPFONT ( 15 , 41 ) ; + Size = MAP_APPFONT ( 41 , 36 ) ; + TabStop = TRUE ; + DropDown = TRUE ; + CurPos = 0 ; +// STRLST_AND_OR + StringList [ en-US ] = + { + < "AND" ; Default ; > ; + < "OR" ; Default ; > ; + }; + }; + ListBox LB_WHEREFIELD2 + { + Border = TRUE ; + Pos = MAP_APPFONT ( 60 , 41 ) ; + Size = MAP_APPFONT ( 60 , 90 ) ; + TabStop = TRUE ; + DropDown = TRUE ; + }; + ListBox LB_WHERECOMP2 + { + Border = TRUE ; + Pos = MAP_APPFONT ( 124 , 41 ) ; + Size = MAP_APPFONT ( 49 , 72 ) ; + TabStop = TRUE ; + DropDown = TRUE ; + DDExtraWidth = TRUE ; + CurPos = 0 ; + }; + Edit ET_WHEREVALUE2 + { + Border = TRUE ; + Pos = MAP_APPFONT ( 177 , 41 ) ; + Size = MAP_APPFONT ( 60 , 12 ) ; + TabStop = TRUE ; + }; + ListBox LB_WHERECOND3 + { + Border = TRUE ; + Pos = MAP_APPFONT ( 15 , 57 ) ; + Size = MAP_APPFONT ( 41 , 36 ) ; + TabStop = TRUE ; + DropDown = TRUE ; + CurPos = 0 ; +// STRLST_AND_OR + StringList [ en-US ] = + { + < "AND" ; Default ; > ; + < "OR" ; Default ; > ; + }; + }; + ListBox LB_WHEREFIELD3 + { + Border = TRUE ; + Pos = MAP_APPFONT ( 60 , 57 ) ; + Size = MAP_APPFONT ( 60 , 90 ) ; + TabStop = TRUE ; + DropDown = TRUE ; + }; + ListBox LB_WHERECOMP3 + { + Border = TRUE ; + Pos = MAP_APPFONT ( 124 , 57 ) ; + Size = MAP_APPFONT ( 49 , 72 ) ; + TabStop = TRUE ; + DropDown = TRUE ; + DDExtraWidth = TRUE ; + CurPos = 0 ; + }; + Edit ET_WHEREVALUE3 + { + Border = TRUE ; + Pos = MAP_APPFONT ( 177 , 57 ) ; + Size = MAP_APPFONT ( 60 , 12 ) ; + TabStop = TRUE ; + }; + FixedText FT_WHEREFIELD + { + Pos = MAP_APPFONT ( 60 , 14 ) ; + Size = MAP_APPFONT ( 60 , 8 ) ; + Center = TRUE ; + Text [ en-US ] = "Field name" ; + }; + FixedText FT_WHERECOMP + { + Pos = MAP_APPFONT ( 124 , 14 ) ; + Size = MAP_APPFONT ( 50 , 8 ) ; + Center = TRUE ; + Text [ en-US ] = "Condition" ; + }; + FixedText FT_WHEREVALUE + { + Pos = MAP_APPFONT ( 177 , 14 ) ; + Size = MAP_APPFONT ( 60 , 8 ) ; + Center = TRUE ; + Text [ en-US ] = "Value" ; + }; + FixedText FT_WHEREOPER + { + Pos = MAP_APPFONT ( 15 , 14 ) ; + Size = MAP_APPFONT ( 40 , 8 ) ; + /* ### ACHTUNG: Neuer Text in Resource? Verknüpfung : Verkn³pfung */ + Center = TRUE ; + Text [ en-US ] = "Operator" ; + }; + FixedLine FL_FIELDS + { + Pos = MAP_APPFONT ( 6 , 3 ) ; + Size = MAP_APPFONT ( 236 , 8 ) ; + Text [ en-US ] = "Criteria" ; + }; + OKButton BT_OK + { + Pos = MAP_APPFONT ( 249 , 6 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + DefButton = TRUE ; + }; + CancelButton BT_CANCEL + { + Pos = MAP_APPFONT ( 249 , 23 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + HelpButton BT_HELP + { + Pos = MAP_APPFONT ( 249 , 43 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + String STR_NOENTRY + { + Text [ en-US ] = "- none -" ; + }; + String STR_COMPARE_OPERATORS + { + Text [ en-US ] = "=;<>;<;<=;>;>=;like;not like;null;not null"; + }; +}; + diff --git a/dbaccess/source/ui/dlg/queryorder.cxx b/dbaccess/source/ui/dlg/queryorder.cxx new file mode 100644 index 000000000000..45dea3837d00 --- /dev/null +++ b/dbaccess/source/ui/dlg/queryorder.cxx @@ -0,0 +1,334 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" +#ifndef DBAUI_QUERYORDER_HRC +#include "queryorder.hrc" +#endif +#ifndef DBAUI_QUERYORDER_HXX +#include "queryorder.hxx" +#endif + +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif + +#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_ +#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNSEARCH_HPP_ +#include <com/sun/star/sdbc/ColumnSearch.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#endif +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif +#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "moduledbu.hxx" +#endif +#ifndef _CONNECTIVITY_PARSE_SQLITERATOR_HXX_ +#include <connectivity/sqliterator.hxx> +#endif +#ifndef _CONNECTIVITY_DBTOOLS_HXX_ +#include <connectivity/dbtools.hxx> +#endif +#ifndef _COMPHELPER_EXTRACT_HXX_ +#include <comphelper/extract.hxx> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#endif + +#ifndef TOOLS_DIAGNOSE_EX_H +#include <tools/diagnose_ex.h> +#endif + +#include <algorithm> + + +using namespace dbaui; +using namespace connectivity; +using namespace ::com::sun::star::uno; +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::beans; + +DBG_NAME(DlgOrderCrit) +//------------------------------------------------------------------------------ +DlgOrderCrit::DlgOrderCrit( Window * pParent, + const Reference< XConnection>& _rxConnection, + const Reference< XSingleSelectQueryComposer >& _rxComposer, + const Reference< XNameAccess>& _rxCols) + :ModalDialog( pParent, ModuleRes(DLG_ORDERCRIT) ) + ,aLB_ORDERFIELD1( this, ModuleRes( LB_ORDERFIELD1 ) ) + ,aLB_ORDERVALUE1( this, ModuleRes( LB_ORDERVALUE1 ) ) + ,aLB_ORDERFIELD2( this, ModuleRes( LB_ORDERFIELD2 ) ) + ,aLB_ORDERVALUE2( this, ModuleRes( LB_ORDERVALUE2 ) ) + ,aLB_ORDERFIELD3( this, ModuleRes( LB_ORDERFIELD3 ) ) + ,aLB_ORDERVALUE3( this, ModuleRes( LB_ORDERVALUE3 ) ) + ,aFT_ORDERFIELD( this, ModuleRes( FT_ORDERFIELD ) ) + ,aFT_ORDERAFTER1( this, ModuleRes( FT_ORDERAFTER1 ) ) + ,aFT_ORDERAFTER2( this, ModuleRes( FT_ORDERAFTER2 ) ) + ,aFT_ORDEROPER( this, ModuleRes( FT_ORDEROPER ) ) + ,aFT_ORDERDIR( this, ModuleRes( FT_ORDERDIR ) ) + ,aBT_OK( this, ModuleRes( BT_OK ) ) + ,aBT_CANCEL( this, ModuleRes( BT_CANCEL ) ) + ,aBT_HELP( this, ModuleRes( BT_HELP ) ) + ,aFL_ORDER( this, ModuleRes( FL_ORDER ) ) + ,aSTR_NOENTRY( ModuleRes( STR_NOENTRY ) ) + ,m_xQueryComposer( _rxComposer ) + ,m_xColumns(_rxCols) + ,m_xConnection(_rxConnection) +{ + DBG_CTOR(DlgOrderCrit,NULL); + + AllSettings aSettings( GetSettings() ); + StyleSettings aStyle( aSettings.GetStyleSettings() ); + aStyle.SetAutoMnemonic( FALSE ); + aSettings.SetStyleSettings( aStyle ); + SetSettings( aSettings ); + + m_aColumnList[0] = &aLB_ORDERFIELD1; + m_aColumnList[1] = &aLB_ORDERFIELD2; + m_aColumnList[2] = &aLB_ORDERFIELD3; + + m_aValueList[0] = &aLB_ORDERVALUE1; + m_aValueList[1] = &aLB_ORDERVALUE2; + m_aValueList[2] = &aLB_ORDERVALUE3; + + xub_StrLen j; + for(j=0 ; j < DOG_ROWS ; j++ ) + { + m_aColumnList[j]->InsertEntry( aSTR_NOENTRY ); + } + + for( j=0 ; j < DOG_ROWS ; j++ ) + { + m_aColumnList[j]->SelectEntryPos(0); + m_aValueList[j]->SelectEntryPos(0); + } + try + { + // ... sowie auch die restlichen Felder + Sequence< ::rtl::OUString> aNames = m_xColumns->getElementNames(); + const ::rtl::OUString* pIter = aNames.getConstArray(); + const ::rtl::OUString* pEnd = pIter + aNames.getLength(); + Reference<XPropertySet> xColumn; + for(;pIter != pEnd;++pIter) + { + xColumn.set(m_xColumns->getByName(*pIter),UNO_QUERY); + OSL_ENSURE(xColumn.is(),"Column is null!"); + if ( xColumn.is() ) + { + sal_Int32 nDataType = 0; + xColumn->getPropertyValue(PROPERTY_TYPE) >>= nDataType; + sal_Int32 eColumnSearch = dbtools::getSearchColumnFlag(m_xConnection,nDataType); + if(eColumnSearch != ColumnSearch::NONE) + { + for( j=0 ; j < DOG_ROWS ; j++ ) + { + m_aColumnList[j]->InsertEntry(*pIter); + } + } + } + } + + m_sOrgOrder = m_xQueryComposer->getOrder(); + impl_initializeOrderList_nothrow(); + } + catch(const Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + EnableLines(); + + aLB_ORDERFIELD1.SetSelectHdl(LINK(this,DlgOrderCrit,FieldListSelectHdl)); + aLB_ORDERFIELD2.SetSelectHdl(LINK(this,DlgOrderCrit,FieldListSelectHdl)); + + FreeResource(); + +} + +//------------------------------------------------------------------------------ + +#define LbText(x) ((x).GetSelectEntry()) +#define LbPos(x) ((x).GetSelectEntryPos()) + +//------------------------------------------------------------------------------ +DlgOrderCrit::~DlgOrderCrit() +{ + DBG_DTOR(DlgOrderCrit,NULL); +} + +//------------------------------------------------------------------------------ +IMPL_LINK_INLINE_START( DlgOrderCrit, FieldListSelectHdl, ListBox *, /*pListBox*/ ) +{ + DBG_CHKTHIS(DlgOrderCrit,NULL); + EnableLines(); + return 0; +} +IMPL_LINK_INLINE_END( DlgOrderCrit, FieldListSelectHdl, ListBox *, pListBox ) + +//------------------------------------------------------------------------------ +void DlgOrderCrit::impl_initializeOrderList_nothrow() +{ + try + { + const ::rtl::OUString sNameProperty = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ); + const ::rtl::OUString sAscendingProperty = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsAscending" ) ); + + Reference< XIndexAccess > xOrderColumns( m_xQueryComposer->getOrderColumns(), UNO_QUERY_THROW ); + sal_Int32 nColumns = xOrderColumns->getCount(); + if ( nColumns > DOG_ROWS ) + nColumns = DOG_ROWS; + + for ( sal_Int32 i = 0; i < nColumns; ++i ) + { + Reference< XPropertySet > xColumn( xOrderColumns->getByIndex( i ), UNO_QUERY_THROW ); + + ::rtl::OUString sColumnName; + sal_Bool bIsAscending( sal_True ); + + xColumn->getPropertyValue( sNameProperty ) >>= sColumnName; + xColumn->getPropertyValue( sAscendingProperty ) >>= bIsAscending; + + m_aColumnList[i]->SelectEntry( sColumnName ); + m_aValueList[i]->SelectEntryPos( bIsAscending ? 0 : 1 ); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +//------------------------------------------------------------------------------ +void DlgOrderCrit::EnableLines() +{ + DBG_CHKTHIS(DlgOrderCrit,NULL); + + if ( aLB_ORDERFIELD1.GetSelectEntryPos() == 0 ) + { + aLB_ORDERFIELD2.Disable(); + aLB_ORDERVALUE2.Disable(); + + aLB_ORDERFIELD2.SelectEntryPos( 0 ); + aLB_ORDERVALUE2.SelectEntryPos( 0 ); + } + else + { + aLB_ORDERFIELD2.Enable(); + aLB_ORDERVALUE2.Enable(); + } + + if ( aLB_ORDERFIELD2.GetSelectEntryPos() == 0 ) + { + aLB_ORDERFIELD3.Disable(); + aLB_ORDERVALUE3.Disable(); + + aLB_ORDERFIELD3.SelectEntryPos( 0 ); + aLB_ORDERVALUE3.SelectEntryPos( 0 ); + } + else + { + aLB_ORDERFIELD3.Enable(); + aLB_ORDERVALUE3.Enable(); + } +} + +//------------------------------------------------------------------------------ +::rtl::OUString DlgOrderCrit::GetOrderList( ) const +{ + DBG_CHKTHIS(DlgOrderCrit,NULL); + Reference<XDatabaseMetaData> xMetaData = m_xConnection->getMetaData(); + ::rtl::OUString sQuote = xMetaData.is() ? xMetaData->getIdentifierQuoteString() : ::rtl::OUString(); + static const ::rtl::OUString sDESC = ::rtl::OUString::createFromAscii(" DESC "); + static const ::rtl::OUString sASC = ::rtl::OUString::createFromAscii(" ASC "); + + Reference< XNameAccess> xColumns = Reference< XColumnsSupplier >(m_xQueryComposer,UNO_QUERY)->getColumns(); + + ::rtl::OUString sOrder; + for( sal_uInt16 i=0 ; i<DOG_ROWS; i++ ) + { + if(m_aColumnList[i]->GetSelectEntryPos() != 0) + { + if(sOrder.getLength()) + sOrder += ::rtl::OUString::createFromAscii(","); + + String sName = m_aColumnList[i]->GetSelectEntry(); + try + { + sal_Bool bFunction = sal_False; + Reference< XPropertySet > xColumn; + if ( xColumns.is() && xColumns->hasByName( sName ) && (xColumns->getByName( sName ) >>= xColumn) && xColumn.is() ) + { + if ( xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_REALNAME) ) + { + ::rtl::OUString sRealName; + xColumn->getPropertyValue(PROPERTY_REALNAME) >>= sRealName; + sName = sRealName; + static ::rtl::OUString sAgg(RTL_CONSTASCII_USTRINGPARAM("AggregateFunction")); + static ::rtl::OUString sFunction(RTL_CONSTASCII_USTRINGPARAM("Function")); + if ( xColumn->getPropertySetInfo()->hasPropertyByName(sFunction) ) + xColumn->getPropertyValue(sFunction) >>= bFunction; + } + } + if ( bFunction ) + sOrder += sName; + else + sOrder += ::dbtools::quoteName(sQuote,sName); + } + catch(Exception) + { + } + if(m_aValueList[i]->GetSelectEntryPos()) + sOrder += sDESC; + else + sOrder += sASC; + } + } + return sOrder; +} + +//------------------------------------------------------------------------------ +void DlgOrderCrit::BuildOrderPart() +{ + DBG_CHKTHIS(DlgOrderCrit,NULL); + m_xQueryComposer->setOrder(GetOrderList()); +} +// ----------------------------------------------------------------------------- + + + + + diff --git a/dbaccess/source/ui/dlg/queryorder.hrc b/dbaccess/source/ui/dlg/queryorder.hrc new file mode 100644 index 000000000000..059151ba9a8d --- /dev/null +++ b/dbaccess/source/ui/dlg/queryorder.hrc @@ -0,0 +1,57 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef DBAUI_QUERYORDER_HRC +#define DBAUI_QUERYORDER_HRC + +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif + + +#define FT_ORDERFIELD 1 +#define FT_ORDERDIR 3 +#define FT_ORDERAFTER1 4 +#define FT_ORDERAFTER2 5 +#define FT_ORDEROPER 6 + +#define LB_ORDERFIELD1 1 +#define LB_ORDERFIELD2 2 +#define LB_ORDERFIELD3 3 +#define LB_ORDERVALUE1 4 +#define LB_ORDERVALUE2 5 +#define LB_ORDERVALUE3 6 + +#define FL_ORDER 1 + +#define BT_OK 1 +#define BT_CANCEL 2 +#define BT_HELP 3 + +#define STR_NOENTRY 1 + +#endif // DBAUI_QUERYORDER_HRC + diff --git a/dbaccess/source/ui/dlg/queryorder.src b/dbaccess/source/ui/dlg/queryorder.src new file mode 100644 index 000000000000..2f2f85a797a0 --- /dev/null +++ b/dbaccess/source/ui/dlg/queryorder.src @@ -0,0 +1,211 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBAUI_QUERYORDER_HRC +#include "queryorder.hrc" +#endif +#include "dbaccess_helpid.hrc" + +ModalDialog DLG_ORDERCRIT +{ + OutputSize = TRUE ; + Border = TRUE ; + SVLook = TRUE ; + HelpId = HID_DLG_ORDERCRIT ; + Size = MAP_APPFONT ( 252 , 76 ) ; + Text [ en-US ] = "Sort Order" ; + Moveable = TRUE ; + Closeable = TRUE ; + ListBox LB_ORDERFIELD1 + { + Border = TRUE ; + Pos = MAP_APPFONT ( 59 , 25 ) ; + Size = MAP_APPFONT ( 60 , 72 ) ; + TabStop = TRUE ; + DropDown = TRUE ; + DDExtraWidth = TRUE ; + }; + ListBox LB_ORDERVALUE1 + { + Border = TRUE ; + Pos = MAP_APPFONT ( 123 , 25 ) ; + Size = MAP_APPFONT ( 60 , 36 ) ; + TabStop = TRUE ; + DropDown = TRUE ; + CurPos = 0 ; + StringList [ en-US ] = + { + < "ascending" ; Default ; > ; + < "descending" ; Default ; > ; + }; + }; + ListBox LB_ORDERFIELD2 + { + Border = TRUE ; + Pos = MAP_APPFONT ( 59 , 41 ) ; + Size = MAP_APPFONT ( 60 , 72 ) ; + TabStop = TRUE ; + DropDown = TRUE ; + DDExtraWidth = TRUE ; + }; + ListBox LB_ORDERVALUE2 + { + Border = TRUE ; + Pos = MAP_APPFONT ( 123 , 41 ) ; + Size = MAP_APPFONT ( 60 , 36 ) ; + TabStop = TRUE ; + DropDown = TRUE ; + CurPos = 0 ; + StringList [ en-US ] = + { + < "ascending" ; Default ; > ; + < "descending" ; Default ; > ; + }; + }; + ListBox LB_ORDERFIELD3 + { + Border = TRUE ; + Pos = MAP_APPFONT ( 59 , 57 ) ; + Size = MAP_APPFONT ( 60 , 72 ) ; + TabStop = TRUE ; + DropDown = TRUE ; + DDExtraWidth = TRUE ; + }; + ListBox LB_ORDERVALUE3 + { + Border = TRUE ; + Pos = MAP_APPFONT ( 123 , 57 ) ; + Size = MAP_APPFONT ( 60 , 36 ) ; + TabStop = TRUE ; + DropDown = TRUE ; + CurPos = 0 ; + StringList [ en-US ] = + { + < "ascending" ; Default ; > ; + < "descending" ; Default ; > ; + }; + }; + FixedText FT_ORDERFIELD + { + Pos = MAP_APPFONT ( 58 , 14 ) ; + Size = MAP_APPFONT ( 60 , 8 ) ; + Text [ en-US ] = "Field name" ; + Center = TRUE ; + }; + + FixedText FT_ORDERAFTER1 + { + Pos = MAP_APPFONT ( 12 , 43 ) ; + Size = MAP_APPFONT ( 40 , 8 ) ; + Text [ en-US ] = "and then" ; + }; + FixedText FT_ORDERAFTER2 + { + Pos = MAP_APPFONT ( 12 , 59 ) ; + Size = MAP_APPFONT ( 40 , 8 ) ; + Text [ en-US ] = "and then" ; + }; + FixedText FT_ORDEROPER + { + Pos = MAP_APPFONT ( 12 , 14 ) ; + Size = MAP_APPFONT ( 46 , 8 ) ; + /* ### ACHTUNG: Neuer Text in Resource? Verknüpfung : Verkn³pfung */ + Text [ en-US ] = "Operator" ; + }; + FixedText FT_ORDERDIR + { + Pos = MAP_APPFONT ( 122 , 14 ) ; + Size = MAP_APPFONT ( 60 , 8 ) ; + Text [ en-US ] = "Order" ; + Center = TRUE ; + }; + OKButton BT_OK + { + Pos = MAP_APPFONT ( 196 , 6 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + DefButton = TRUE ; + }; + CancelButton BT_CANCEL + { + Pos = MAP_APPFONT ( 196 , 23 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + HelpButton BT_HELP + { + Pos = MAP_APPFONT ( 196 , 43 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + FixedLine FL_ORDER + { + Pos = MAP_APPFONT ( 6 , 3 ) ; + Size = MAP_APPFONT ( 184 , 8 ) ; + Text [ en-US ] = "Sort order" ; + }; + String STR_NOENTRY + { + Text [ en-US ] = "<none>" ; + }; +}; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dbaccess/source/ui/dlg/sqlmessage.cxx b/dbaccess/source/ui/dlg/sqlmessage.cxx new file mode 100644 index 000000000000..f7600fd137ed --- /dev/null +++ b/dbaccess/source/ui/dlg/sqlmessage.cxx @@ -0,0 +1,817 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#ifndef _DBAUI_SQLMESSAGE_HXX_ +#include "sqlmessage.hxx" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef _DBAUI_SQLMESSAGE_HRC_ +#include "sqlmessage.hrc" +#endif +#ifndef _COM_SUN_STAR_SDBC_SQLEXCEPTION_HPP_ +#include <com/sun/star/sdbc/SQLException.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_ +#include <com/sun/star/sdb/SQLContext.hpp> +#endif +#ifndef _SV_GROUP_HXX //autogen +#include <vcl/fixed.hxx> +#endif +#ifndef _SVTREEBOX_HXX +#include <svtools/svtreebx.hxx> +#endif +#ifndef _SVEDIT_HXX //autogen +#include <svtools/svmedit.hxx> +#endif +#ifndef _DBHELPER_DBEXCEPTION_HXX_ +#include <connectivity/dbexception.hxx> +#endif +#ifndef CONNECTIVITY_SQLERROR_HXX +#include <connectivity/sqlerror.hxx> +#endif +#ifndef _SV_MSGBOX_HXX //autogen +#include <vcl/msgbox.hxx> +#endif +#ifndef _UTL_CONFIGMGR_HXX_ +#include <unotools/configmgr.hxx> +#endif +#ifndef _SFX_SFXUNO_HXX +#include <sfx2/sfxuno.hxx> +#endif +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif +#ifndef DBAUI_TOOLS_HXX +#include "UITools.hxx" +#endif +#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "moduledbu.hxx" +#endif + +#define BUTTONID_MORE BUTTONID_RETRY + 1 + +#define DIALOG_WIDTH 220 +#define OUTER_MARGIN 6 +#define IMAGE_SIZE 20 +#define INNER_PADDING 3 +#define TEXT_POS_X ( OUTER_MARGIN + IMAGE_SIZE + INNER_PADDING ) + +using namespace dbtools; +using namespace com::sun::star::uno; +using namespace com::sun::star::sdb; +using namespace com::sun::star::sdbc; + +//......................................................................... +namespace dbaui +{ +//......................................................................... + +namespace +{ + //------------------------------------------------------------------------------ + class IImageProvider + { + public: + virtual Image getImage( bool _highContrast ) const = 0; + + virtual ~IImageProvider() { } + }; + + //------------------------------------------------------------------------------ + class ILabelProvider + { + public: + virtual String getLabel() const = 0; + + virtual ~ILabelProvider() { }; + }; + + //------------------------------------------------------------------------------ + class ImageProvider : public IImageProvider + { + private: + USHORT m_defaultImageID; + USHORT m_highContrastImageID; + + mutable Image m_defaultImage; + mutable Image m_highContrastImage; + + public: + ImageProvider( USHORT _defaultImageID, USHORT _highContrastImageID ) + :m_defaultImageID( _defaultImageID ) + ,m_highContrastImageID( _highContrastImageID ) + { + } + + virtual Image getImage( bool _highContrast ) const + { + if ( _highContrast ) + { + if ( !m_highContrastImage ) + m_highContrastImage = Image( ModuleRes( m_highContrastImageID ) ); + return m_highContrastImage; + } + + if ( !m_defaultImage ) + m_defaultImage = Image( ModuleRes( m_defaultImageID ) ); + return m_defaultImage; + } + }; + + //------------------------------------------------------------------------------ + class LabelProvider : public ILabelProvider + { + private: + String m_label; + public: + LabelProvider( USHORT _labelResourceID ) + :m_label( ModuleRes( _labelResourceID ) ) + { + } + + virtual String getLabel() const + { + return m_label; + } + }; + + //------------------------------------------------------------------------------ + class ProviderFactory + { + private: + mutable ::boost::shared_ptr< IImageProvider > m_pErrorImage; + mutable ::boost::shared_ptr< IImageProvider > m_pWarningsImage; + mutable ::boost::shared_ptr< IImageProvider > m_pInfoImage; + mutable ::boost::shared_ptr< ILabelProvider > m_pErrorLabel; + mutable ::boost::shared_ptr< ILabelProvider > m_pWarningsLabel; + mutable ::boost::shared_ptr< ILabelProvider > m_pInfoLabel; + + public: + ProviderFactory() + { + } + + ::boost::shared_ptr< IImageProvider > getImageProvider( SQLExceptionInfo::TYPE _eType ) const + { + ::boost::shared_ptr< IImageProvider >* ppProvider( &m_pErrorImage ); + USHORT nNormalImageID( BMP_EXCEPTION_ERROR ); + USHORT nHCImageID( BMP_EXCEPTION_ERROR_SCH ); + + switch ( _eType ) + { + case SQLExceptionInfo::SQL_WARNING: + ppProvider = &m_pWarningsImage; + nNormalImageID = BMP_EXCEPTION_WARNING; + nHCImageID = BMP_EXCEPTION_WARNING_SCH; + break; + + case SQLExceptionInfo::SQL_CONTEXT: + ppProvider = &m_pInfoImage; + nNormalImageID = BMP_EXCEPTION_INFO; + nHCImageID = BMP_EXCEPTION_INFO_SCH; + break; + + default: + break; + } + + if ( !ppProvider->get() ) + ppProvider->reset( new ImageProvider( nNormalImageID, nHCImageID ) ); + return *ppProvider; + } + + ::boost::shared_ptr< ILabelProvider > getLabelProvider( SQLExceptionInfo::TYPE _eType, bool _bSubLabel ) const + { + ::boost::shared_ptr< ILabelProvider >* ppProvider( &m_pErrorLabel ); + USHORT nLabelID( STR_EXCEPTION_ERROR ); + + switch ( _eType ) + { + case SQLExceptionInfo::SQL_WARNING: + ppProvider = &m_pWarningsLabel; + nLabelID = STR_EXCEPTION_WARNING; + break; + + case SQLExceptionInfo::SQL_CONTEXT: + ppProvider = &m_pInfoLabel; + nLabelID = _bSubLabel ? STR_EXCEPTION_DETAILS : STR_EXCEPTION_INFO; + break; + default: + break; + } + + if ( !ppProvider->get() ) + ppProvider->reset( new LabelProvider( nLabelID ) ); + return *ppProvider; + } + + }; + + //------------------------------------------------------------------------------ + /// a stripped version of the SQLException, packed for displaying + struct ExceptionDisplayInfo + { + SQLExceptionInfo::TYPE eType; + + ::boost::shared_ptr< IImageProvider > pImageProvider; + ::boost::shared_ptr< ILabelProvider > pLabelProvider; + + bool bSubEntry; + + String sMessage; + String sSQLState; + String sErrorCode; + + ExceptionDisplayInfo() : eType( SQLExceptionInfo::UNDEFINED ), bSubEntry( false ) { } + ExceptionDisplayInfo( SQLExceptionInfo::TYPE _eType ) : eType( _eType ), bSubEntry( false ) { } + }; + + static bool lcl_hasDetails( const ExceptionDisplayInfo& _displayInfo ) + { + return ( _displayInfo.sErrorCode.Len() ) + || ( _displayInfo.sSQLState.Len() + && !_displayInfo.sSQLState.EqualsAscii( "S1000" ) + ); + } + + typedef ::std::vector< ExceptionDisplayInfo > ExceptionDisplayChain; + + //------------------------------------------------------------------------------ + /// strips the [OOoBase] vendor identifier from the given error message, if applicable + ::rtl::OUString lcl_stripOOoBaseVendor( const ::rtl::OUString& _rErrorMessage ) + { + ::rtl::OUString sErrorMessage( _rErrorMessage ); + + const ::rtl::OUString sVendorIdentifier( ::connectivity::SQLError::getMessagePrefix() ); + if ( sErrorMessage.indexOf( sVendorIdentifier ) == 0 ) + { + // characters to strip + sal_Int32 nStripLen( sVendorIdentifier.getLength() ); + // usually, there should be a whitespace between the vendor and the real message + while ( ( sErrorMessage.getLength() > nStripLen ) + && ( sErrorMessage[nStripLen] == ' ' ) + ) + ++nStripLen; + sErrorMessage = sErrorMessage.copy( nStripLen ); + } + + return sErrorMessage; + } + + //------------------------------------------------------------------------------ + void lcl_buildExceptionChain( const SQLExceptionInfo& _rErrorInfo, const ProviderFactory& _rFactory, ExceptionDisplayChain& _out_rChain ) + { + { + ExceptionDisplayChain empty; + _out_rChain.swap( empty ); + } + + SQLExceptionIteratorHelper iter( _rErrorInfo ); + while ( iter.hasMoreElements() ) + { + // current chain element + SQLExceptionInfo aCurrentElement; + iter.next( aCurrentElement ); + + const SQLException* pCurrentError = (const SQLException*)aCurrentElement; + DBG_ASSERT( pCurrentError, "lcl_buildExceptionChain: iterator failure!" ); + // hasMoreElements should not have returned <TRUE/> in this case + + ExceptionDisplayInfo aDisplayInfo( aCurrentElement.getType() ); + + aDisplayInfo.sMessage = pCurrentError->Message.trim(); + aDisplayInfo.sSQLState = pCurrentError->SQLState; + if ( pCurrentError->ErrorCode ) + aDisplayInfo.sErrorCode = String::CreateFromInt32( pCurrentError->ErrorCode ); + + if ( !aDisplayInfo.sMessage.Len() + && !lcl_hasDetails( aDisplayInfo ) + ) + { + OSL_ENSURE( false, "lcl_buildExceptionChain: useles exception: no state, no error code, no message!" ); + continue; + } + + aDisplayInfo.pImageProvider = _rFactory.getImageProvider( aCurrentElement.getType() ); + aDisplayInfo.pLabelProvider = _rFactory.getLabelProvider( aCurrentElement.getType(), false ); + + _out_rChain.push_back( aDisplayInfo ); + + if ( aCurrentElement.getType() == SQLExceptionInfo::SQL_CONTEXT ) + { + const SQLContext* pContext = (const SQLContext*)aCurrentElement; + if ( pContext->Details.getLength() ) + { + ExceptionDisplayInfo aSubInfo( aCurrentElement.getType() ); + + aSubInfo.sMessage = pContext->Details; + aSubInfo.pImageProvider = _rFactory.getImageProvider( aCurrentElement.getType() ); + aSubInfo.pLabelProvider = _rFactory.getLabelProvider( aCurrentElement.getType(), true ); + aSubInfo.bSubEntry = true; + + _out_rChain.push_back( aSubInfo ); + } + } + } + } + + //------------------------------------------------------------------------------ + void lcl_insertExceptionEntry( SvTreeListBox& _rList, bool _bHiContrast, size_t _nElementPos, const ExceptionDisplayInfo& _rEntry ) + { + Image aEntryImage( _rEntry.pImageProvider->getImage( _bHiContrast ) ); + SvLBoxEntry* pListEntry = + _rList.InsertEntry( _rEntry.pLabelProvider->getLabel(), aEntryImage, aEntryImage ); + pListEntry->SetUserData( reinterpret_cast< void* >( _nElementPos ) ); + } +} + +//============================================================================== +class OExceptionChainDialog : public ModalDialog +{ + FixedLine m_aFrame; + FixedText m_aListLabel; + SvTreeListBox m_aExceptionList; + FixedText m_aDescLabel; + MultiLineEdit m_aExceptionText; + OKButton m_aOK; + + String m_sStatusLabel; + String m_sErrorCodeLabel; + + ExceptionDisplayChain m_aExceptions; + +public: + OExceptionChainDialog( Window* pParent, const ExceptionDisplayChain& _rExceptions ); + ~OExceptionChainDialog(); + +protected: + DECL_LINK(OnExceptionSelected, void*); +}; + +DBG_NAME(OExceptionChainDialog) +//------------------------------------------------------------------------------ +OExceptionChainDialog::OExceptionChainDialog( Window* pParent, const ExceptionDisplayChain& _rExceptions ) + :ModalDialog(pParent, ModuleRes(DLG_SQLEXCEPTIONCHAIN)) + ,m_aFrame (this, ModuleRes(FL_DETAILS)) + ,m_aListLabel (this, ModuleRes(FT_ERRORLIST)) + ,m_aExceptionList (this, ModuleRes(CTL_ERRORLIST)) + ,m_aDescLabel (this, ModuleRes(FT_DESCRIPTION)) + ,m_aExceptionText (this, ModuleRes(ME_DESCRIPTION)) + ,m_aOK (this, ModuleRes(PB_OK)) + ,m_aExceptions( _rExceptions ) +{ + DBG_CTOR(OExceptionChainDialog,NULL); + + m_sStatusLabel = String( ModuleRes( STR_EXCEPTION_STATUS ) ); + m_sErrorCodeLabel = String( ModuleRes( STR_EXCEPTION_ERRORCODE ) ); + + FreeResource(); + + m_aExceptionList.SetSelectionMode(SINGLE_SELECTION); + m_aExceptionList.SetDragDropMode(0); + m_aExceptionList.EnableInplaceEditing(sal_False); + m_aExceptionList.SetWindowBits(WB_HASLINES | WB_HASBUTTONS | WB_HASBUTTONSATROOT | WB_HSCROLL); + + m_aExceptionList.SetSelectHdl(LINK(this, OExceptionChainDialog, OnExceptionSelected)); + m_aExceptionList.SetNodeDefaultImages( ); + m_aExceptionText.SetReadOnly(sal_True); + + bool bHave22018 = false; + bool bHiContrast = isHiContrast( this ); + size_t elementPos = 0; + + for ( ExceptionDisplayChain::const_iterator loop = m_aExceptions.begin(); + loop != m_aExceptions.end(); + ++loop, ++elementPos + ) + { + lcl_insertExceptionEntry( m_aExceptionList, bHiContrast, elementPos, *loop ); + bHave22018 = loop->sSQLState.EqualsAscii( "22018" ); + } + + // if the error has the code 22018, then add an additional explanation + // #i24021# / 2004-10-14 / frank.schoenheit@sun.com + if ( bHave22018 ) + { + ProviderFactory aProviderFactory; + + ExceptionDisplayInfo aInfo22018; + aInfo22018.sMessage = String( ModuleRes( STR_EXPLAN_STRINGCONVERSION_ERROR ) ); + aInfo22018.pLabelProvider = aProviderFactory.getLabelProvider( SQLExceptionInfo::SQL_CONTEXT, false ); + aInfo22018.pImageProvider = aProviderFactory.getImageProvider( SQLExceptionInfo::SQL_CONTEXT ); + m_aExceptions.push_back( aInfo22018 ); + + lcl_insertExceptionEntry( m_aExceptionList, bHiContrast, m_aExceptions.size() - 1, aInfo22018 ); + } +} + +//------------------------------------------------------------------------------ +OExceptionChainDialog::~OExceptionChainDialog() +{ + DBG_DTOR(OExceptionChainDialog,NULL); +} + +//------------------------------------------------------------------------------ +IMPL_LINK(OExceptionChainDialog, OnExceptionSelected, void*, EMPTYARG) +{ + SvLBoxEntry* pSelected = m_aExceptionList.FirstSelected(); + DBG_ASSERT(!pSelected || !m_aExceptionList.NextSelected(pSelected), "OExceptionChainDialog::OnExceptionSelected : multi selection ?"); + + String sText; + + if ( pSelected ) + { + size_t pos = reinterpret_cast< size_t >( pSelected->GetUserData() ); + const ExceptionDisplayInfo& aExceptionInfo( m_aExceptions[ pos ] ); + + if ( aExceptionInfo.sSQLState.Len() ) + { + sText += m_sStatusLabel; + sText.AppendAscii(": "); + sText += aExceptionInfo.sSQLState; + sText.AppendAscii("\n"); + } + + if ( aExceptionInfo.sErrorCode.Len() ) + { + sText += m_sErrorCodeLabel; + sText.AppendAscii(": "); + sText += aExceptionInfo.sErrorCode; + sText.AppendAscii("\n"); + } + + if ( sText.Len() ) + sText.AppendAscii( "\n" ); + + sText += aExceptionInfo.sMessage; + } + + m_aExceptionText.SetText(sText); + + return 0L; +} + +//============================================================================== +//= SQLMessageBox_Impl +//============================================================================== +struct SQLMessageBox_Impl +{ + ExceptionDisplayChain aDisplayInfo; + + SQLMessageBox_Impl( const SQLExceptionInfo& _rExceptionInfo ) + { + // transform the exception chain to a form more suitable for displaying it here + ProviderFactory aProviderFactory; + lcl_buildExceptionChain( _rExceptionInfo, aProviderFactory, aDisplayInfo ); + } +}; + +//------------------------------------------------------------------------------ +namespace +{ + ::rtl::OUString lcl_getProductName() + { + ::rtl::OUString sProductName; + OSL_VERIFY( ::utl::ConfigManager::GetDirectConfigProperty( ::utl::ConfigManager::PRODUCTNAME ) >>= sProductName ); + return sProductName; + } + + void lcl_positionInAppFont( const Window& _rParent, Window& _rChild, long _nX, long _nY, long _Width, long _Height ) + { + Point aPos = _rParent.LogicToPixel( Point( _nX, _nY ), MAP_APPFONT ); + Size aSize = _rParent.LogicToPixel( Size( _Width, _Height ), MAP_APPFONT ); + _rChild.SetPosSizePixel( aPos, aSize ); + } + + void lcl_addButton( ButtonDialog& _rDialog, StandardButtonType _eType, bool _bDefault ) + { + USHORT nButtonID = 0; + switch ( _eType ) + { + case BUTTON_YES: nButtonID = BUTTONID_YES; break; + case BUTTON_NO: nButtonID = BUTTONID_NO; break; + case BUTTON_OK: nButtonID = BUTTONID_OK; break; + case BUTTON_CANCEL: nButtonID = BUTTONID_CANCEL; break; + case BUTTON_RETRY: nButtonID = BUTTONID_RETRY; break; + case BUTTON_HELP: nButtonID = BUTTONID_HELP; break; + default: + OSL_ENSURE( false, "lcl_addButton: invalid button id!" ); + break; + } + _rDialog.AddButton( _eType, nButtonID, _bDefault ? BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON : 0 ); + } +} + +//------------------------------------------------------------------------------ +void OSQLMessageBox::impl_positionControls() +{ + OSL_PRECOND( !m_pImpl->aDisplayInfo.empty(), "OSQLMessageBox::impl_positionControls: nothing to display at all?" ); + + + if ( m_pImpl->aDisplayInfo.empty() ) + return; + const ExceptionDisplayInfo* pSecondInfo = NULL; + + const ExceptionDisplayInfo& rFirstInfo = *m_pImpl->aDisplayInfo.begin(); + if ( m_pImpl->aDisplayInfo.size() > 1 ) + pSecondInfo = &m_pImpl->aDisplayInfo[1]; + String sPrimary, sSecondary; + sPrimary = rFirstInfo.sMessage; + // one or two texts to display? + if ( pSecondInfo ) + { + // we show two elements in the main dialog if and only if one of + // - the first element in the chain is an SQLContext, and the second + // element denotes its sub entry + // - the first and the second element are both independent (i.e. the second + // is no sub entry), and none of them is a context. + bool bFirstElementIsContext = ( rFirstInfo.eType == SQLExceptionInfo::SQL_CONTEXT ); + bool bSecondElementIsContext = ( pSecondInfo->eType == SQLExceptionInfo::SQL_CONTEXT ); + + if ( bFirstElementIsContext && pSecondInfo->bSubEntry ) + sSecondary = pSecondInfo->sMessage; + if ( !bFirstElementIsContext && !bSecondElementIsContext ) + sSecondary = pSecondInfo->sMessage; + } + + // image + lcl_positionInAppFont( *this, m_aInfoImage, OUTER_MARGIN, OUTER_MARGIN, IMAGE_SIZE, IMAGE_SIZE ); + m_aInfoImage.Show(); + + // primary text + lcl_positionInAppFont( *this, m_aTitle, TEXT_POS_X, OUTER_MARGIN, DIALOG_WIDTH - TEXT_POS_X - 2 * OUTER_MARGIN, 16 ); + sPrimary = lcl_stripOOoBaseVendor( sPrimary ); + m_aTitle.SetText( sPrimary ); + m_aTitle.Show(); + + Rectangle aPrimaryRect( m_aTitle.GetPosPixel(), m_aTitle.GetSizePixel() ); + + // secondary text (if applicable) + m_aMessage.SetStyle( m_aMessage.GetStyle() | WB_NOLABEL ); + sSecondary = lcl_stripOOoBaseVendor( sSecondary ); + m_aMessage.SetText( sSecondary ); + + lcl_positionInAppFont( *this, m_aMessage, TEXT_POS_X, OUTER_MARGIN + 16 + 3, DIALOG_WIDTH - TEXT_POS_X - 2 * OUTER_MARGIN, 8 ); + Rectangle aSecondaryRect( m_aMessage.GetPosPixel(), m_aMessage.GetSizePixel() ); + + bool bHaveSecondaryText = sSecondary.Len() != 0; + + // determine which space the secondary text would occupy + if ( bHaveSecondaryText ) + aSecondaryRect = GetTextRect( aSecondaryRect, sSecondary, TEXT_DRAW_WORDBREAK | TEXT_DRAW_MULTILINE | TEXT_DRAW_LEFT ); + else + aSecondaryRect.Bottom() = aSecondaryRect.Top() - 1; + + // adjust secondary control height accordingly + m_aMessage.SetSizePixel( aSecondaryRect.GetSize() ); + m_aMessage.Show( aSecondaryRect.GetHeight() > 0 ); + + // if there's no secondary text ... + if ( !bHaveSecondaryText ) + { // then give the primary text as much horizontal space as it needs + Rectangle aSuggestedRect( GetTextRect( aPrimaryRect, sPrimary, TEXT_DRAW_WORDBREAK | TEXT_DRAW_MULTILINE | TEXT_DRAW_CENTER ) ); + aPrimaryRect.Right() = aPrimaryRect.Left() + aSuggestedRect.GetWidth(); + aPrimaryRect.Bottom() = aPrimaryRect.Top() + aSuggestedRect.GetHeight(); + // and center it horizontally + m_aTitle.SetStyle( ( m_aTitle.GetStyle() & ~WB_LEFT ) | WB_CENTER ); + + Rectangle aInfoRect( m_aInfoImage.GetPosPixel(), m_aInfoImage.GetSizePixel() ); + // also, if it's not as high as the image ... + if ( aPrimaryRect.GetHeight() < m_aInfoImage.GetSizePixel().Height() ) + { // ... make it fit the image height + aPrimaryRect.Bottom() += aInfoRect.GetHeight() - aPrimaryRect.GetHeight(); + // and center it vertically + m_aTitle.SetStyle( m_aTitle.GetStyle() | WB_VCENTER ); + } + else + { // ... otherwise, center the image vertically, relative to the primary text + aInfoRect.Move( 0, ( aPrimaryRect.GetHeight() - aInfoRect.GetHeight() ) / 2 ); + m_aInfoImage.SetPosSizePixel( aInfoRect.TopLeft(), aInfoRect.GetSize() ); + } + + m_aTitle.SetPosSizePixel( aPrimaryRect.TopLeft(), aPrimaryRect.GetSize() ); + } + + // adjust dialog size accordingly + const Rectangle& rBottomTextRect( bHaveSecondaryText ? aSecondaryRect : aPrimaryRect ); + Size aBorderSize = LogicToPixel( Size( OUTER_MARGIN, OUTER_MARGIN ), MAP_APPFONT ); + Size aDialogSize( LogicToPixel( Size( DIALOG_WIDTH, 30 ), MAP_APPFONT ) ); + aDialogSize.Height() = rBottomTextRect.Bottom() + aBorderSize.Height(); + aDialogSize.Width() = aPrimaryRect.Right() + aBorderSize.Width(); + + SetSizePixel( aDialogSize ); + SetPageSizePixel( aDialogSize ); +} + +//------------------------------------------------------------------------------ +void OSQLMessageBox::impl_initImage( MessageType _eImage ) +{ + switch (_eImage) + { + default: + DBG_ERROR( "OSQLMessageBox::impl_initImage: unsupported image type!" ); + + case Info: + m_aInfoImage.SetImage(InfoBox::GetStandardImage()); + break; + case Warning: + m_aInfoImage.SetImage(WarningBox::GetStandardImage()); + break; + case Error: + m_aInfoImage.SetImage(ErrorBox::GetStandardImage()); + break; + case Query: + m_aInfoImage.SetImage(QueryBox::GetStandardImage()); + break; + } +} + +//------------------------------------------------------------------------------ +void OSQLMessageBox::impl_createStandardButtons( WinBits _nStyle ) +{ + if ( _nStyle & WB_YES_NO_CANCEL ) + { + lcl_addButton( *this, BUTTON_YES, ( _nStyle & WB_DEF_YES ) != 0 ); + lcl_addButton( *this, BUTTON_NO, ( _nStyle & WB_DEF_NO ) != 0 ); + lcl_addButton( *this, BUTTON_CANCEL, ( _nStyle & WB_DEF_CANCEL ) != 0 ); + } + else if ( _nStyle & WB_OK_CANCEL ) + { + lcl_addButton( *this, BUTTON_OK, ( _nStyle & WB_DEF_OK ) != 0 ); + lcl_addButton( *this, BUTTON_CANCEL, ( _nStyle & WB_DEF_CANCEL ) != 0 ); + } + else if ( _nStyle & WB_YES_NO ) + { + lcl_addButton( *this, BUTTON_YES, ( _nStyle & WB_DEF_YES ) != 0 ); + lcl_addButton( *this, BUTTON_NO, ( _nStyle & WB_DEF_NO ) != 0 ); + } + else if ( _nStyle & WB_RETRY_CANCEL ) + { + lcl_addButton( *this, BUTTON_RETRY, ( _nStyle & WB_DEF_RETRY ) != 0 ); + lcl_addButton( *this, BUTTON_CANCEL, ( _nStyle & WB_DEF_CANCEL ) != 0 ); + } + else + { + OSL_ENSURE( WB_OK & _nStyle, "OSQLMessageBox::impl_createStandardButtons: unsupported dialog style requested!" ); + AddButton( BUTTON_OK, BUTTONID_OK, BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON ); + } + + if ( m_sHelpURL.getLength() ) + { + lcl_addButton( *this, BUTTON_HELP, false ); + + SmartId aHelpId( m_sHelpURL ); + if ( m_sHelpURL.indexOfAsciiL( "HID:", 4 ) == 0 ) + aHelpId = SmartId( m_sHelpURL.copy( 4 ).toInt32() ); + + SetSmartHelpId( aHelpId ); + } +} + +//------------------------------------------------------------------------------ +void OSQLMessageBox::impl_addDetailsButton() +{ + size_t nFirstPageVisible = m_aMessage.IsVisible() ? 2 : 1; + + bool bMoreDetailsAvailable = m_pImpl->aDisplayInfo.size() > nFirstPageVisible; + if ( !bMoreDetailsAvailable ) + { + // even if the text fits into what we can display, we might need to details button + // if there is more non-trivial information in the errors than the mere messages + for ( ExceptionDisplayChain::const_iterator error = m_pImpl->aDisplayInfo.begin(); + error != m_pImpl->aDisplayInfo.end(); + ++error + ) + { + if ( lcl_hasDetails( *error ) ) + { + bMoreDetailsAvailable = true; + break; + } + } + } + + if ( bMoreDetailsAvailable ) + { + AddButton( BUTTON_MORE, BUTTONID_MORE, 0 ); + PushButton* pButton = GetPushButton( BUTTONID_MORE ); + OSL_ENSURE( pButton, "OSQLMessageBox::impl_addDetailsButton: just added this button, why isn't it there?" ); + pButton->SetClickHdl( LINK( this, OSQLMessageBox, ButtonClickHdl ) ); + pButton->SetUniqueId( UID_SQLERROR_BUTTONMORE ); + } +} + +//------------------------------------------------------------------------------ +void OSQLMessageBox::Construct( WinBits _nStyle, MessageType _eImage ) +{ + // Changed as per BugID 79541 Branding/Configuration + String sDialogTitle( lcl_getProductName() ); + SetText( sDialogTitle.AppendAscii( " Base" ) ); + + // position and size the controls and the dialog, depending on whether we have one or two texts to display + impl_positionControls(); + + // init the image + MessageType eType( _eImage ); + if ( eType == AUTO ) + { + switch ( m_pImpl->aDisplayInfo[0].eType ) + { + case SQLExceptionInfo::SQL_EXCEPTION: eType = Error; break; + case SQLExceptionInfo::SQL_WARNING: eType = Warning; break; + case SQLExceptionInfo::SQL_CONTEXT: eType = Info; break; + default: OSL_ENSURE( false, "OSQLMessageBox::Construct: invalid type!" ); + } + } + impl_initImage( eType ); + + // create buttons + impl_createStandardButtons( _nStyle ); + impl_addDetailsButton(); +} + +//------------------------------------------------------------------------------ +OSQLMessageBox::OSQLMessageBox(Window* _pParent, const SQLExceptionInfo& _rException, WinBits _nStyle, const ::rtl::OUString& _rHelpURL ) + :ButtonDialog( _pParent, WB_HORZ | WB_STDDIALOG ) + ,m_aInfoImage( this ) + ,m_aTitle( this, WB_WORDBREAK | WB_LEFT ) + ,m_aMessage( this, WB_WORDBREAK | WB_LEFT ) + ,m_sHelpURL( _rHelpURL ) + ,m_pImpl( new SQLMessageBox_Impl( _rException ) ) +{ + Construct( _nStyle, AUTO ); +} + +//------------------------------------------------------------------------------ +OSQLMessageBox::OSQLMessageBox( Window* _pParent, const UniString& _rTitle, const UniString& _rMessage, WinBits _nStyle, MessageType _eType, const ::dbtools::SQLExceptionInfo* _pAdditionalErrorInfo ) + :ButtonDialog( _pParent, WB_HORZ | WB_STDDIALOG ) + ,m_aInfoImage( this ) + ,m_aTitle( this, WB_WORDBREAK | WB_LEFT ) + ,m_aMessage( this, WB_WORDBREAK | WB_LEFT ) +{ + SQLContext aError; + aError.Message = _rTitle; + aError.Details = _rMessage; + if ( _pAdditionalErrorInfo ) + aError.NextException = _pAdditionalErrorInfo->get(); + + m_pImpl.reset( new SQLMessageBox_Impl( SQLExceptionInfo( aError ) ) ); + + Construct( _nStyle, _eType ); +} + +//-------------------------------------------------------------------------- +OSQLMessageBox::~OSQLMessageBox() +{ +} + +//-------------------------------------------------------------------------- +IMPL_LINK( OSQLMessageBox, ButtonClickHdl, Button *, /*pButton*/ ) +{ + OExceptionChainDialog aDlg( this, m_pImpl->aDisplayInfo ); + aDlg.Execute(); + return 0; +} + +//================================================================== +// OSQLWarningBox +//================================================================== +OSQLWarningBox::OSQLWarningBox( Window* _pParent, const UniString& _rMessage, WinBits _nStyle, + const ::dbtools::SQLExceptionInfo* _pAdditionalErrorInfo ) + :OSQLMessageBox( _pParent, String( ModuleRes( STR_STAT_WARNING ) ), _rMessage, _nStyle, OSQLMessageBox::Warning, _pAdditionalErrorInfo ) +{ +} + +//......................................................................... +} // namespace dbaui +//......................................................................... + diff --git a/dbaccess/source/ui/dlg/sqlmessage.hrc b/dbaccess/source/ui/dlg/sqlmessage.hrc new file mode 100644 index 000000000000..76f722a1b08f --- /dev/null +++ b/dbaccess/source/ui/dlg/sqlmessage.hrc @@ -0,0 +1,50 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBAUI_SQLMESSAGE_HRC_ +#define _DBAUI_SQLMESSAGE_HRC_ + +#define FT_ERRORLIST 1 +#define FT_DESCRIPTION 2 + +#define ED_TEXT 1 + +#define FL_DATA 1 + +#define FL_DETAILS 1 + +#define PB_OK 1 +#define PB_CANCEL 2 + +#define CTL_ERRORLIST 1 + +#define ME_DESCRIPTION 1 + +#define STR_EXCEPTION_STATUS 1 +#define STR_EXCEPTION_ERRORCODE 2 + +#endif // _DBAUI_SQLMESSAGE_HRC_ diff --git a/dbaccess/source/ui/dlg/sqlmessage.src b/dbaccess/source/ui/dlg/sqlmessage.src new file mode 100644 index 000000000000..af3d53f785dd --- /dev/null +++ b/dbaccess/source/ui/dlg/sqlmessage.src @@ -0,0 +1,161 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef _DBAUI_SQLMESSAGE_HRC_ +#include "sqlmessage.hrc" +#endif + +//------------------------------------------------------------------------- +Image BMP_EXCEPTION_ERROR +{ + ImageBitmap = Bitmap { File = "exerror.bmp"; }; + MaskColor = Color { Red = 0xff00 ; Green = 0x0000 ; Blue = 0xff00 ; }; +}; + +Image BMP_EXCEPTION_WARNING +{ + ImageBitmap = Bitmap { File = "exwarning.bmp"; }; + MaskColor = Color { Red = 0xff00 ; Green = 0x0000 ; Blue = 0xff00 ; }; +}; + +Image BMP_EXCEPTION_INFO +{ + ImageBitmap = Bitmap { File = "exinfo.bmp"; }; + MaskColor = Color { Red = 0xff00 ; Green = 0x0000 ; Blue = 0xff00 ; }; +}; +Image BMP_EXCEPTION_ERROR_SCH +{ + ImageBitmap = Bitmap { File = "exerror_sch.bmp"; }; + MaskColor = Color { Red = 0xff00 ; Green = 0x0000 ; Blue = 0xff00 ; }; +}; + +Image BMP_EXCEPTION_WARNING_SCH +{ + ImageBitmap = Bitmap { File = "exwarning_sch.bmp"; }; + MaskColor = Color { Red = 0xff00 ; Green = 0x0000 ; Blue = 0xff00 ; }; +}; + +Image BMP_EXCEPTION_INFO_SCH +{ + ImageBitmap = Bitmap { File = "exinfo_sch.bmp"; }; + MaskColor = Color { Red = 0xff00 ; Green = 0x0000 ; Blue = 0xff00 ; }; +}; + +ModalDialog DLG_SQLEXCEPTIONCHAIN +{ + Moveable = TRUE ; + Closeable = TRUE ; + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 240 , 150 ) ; + Text [ en-US ] = "%PRODUCTNAME Base" ; + + FixedLine FL_DETAILS + { + Pos = MAP_APPFONT ( 6, 3 ) ; + Size = MAP_APPFONT ( 228, 8 ) ; + Text [ en-US ] = "Details"; + }; + FixedText FT_ERRORLIST + { + Pos = MAP_APPFONT ( 12, 12 ) ; + Size = MAP_APPFONT ( 85, 10 ) ; + Text [ en-US ] = "Error ~list:"; + Group = TRUE; + }; + Control CTL_ERRORLIST + { + Pos = MAP_APPFONT ( 12, 25 ) ; + Size = MAP_APPFONT ( 85, 93 ) ; + Border = TRUE; + TabStop = TRUE; + HelpId = HID_SQLERROR_EXCHAIN_ERRORS; + }; + FixedText FT_DESCRIPTION + { + Pos = MAP_APPFONT ( 103, 12 ) ; + Size = MAP_APPFONT ( 125, 10 ) ; + Text [ en-US ] = "~Description:"; + Group = TRUE; + }; + MultiLineEdit ME_DESCRIPTION + { + Border = TRUE ; + Pos = MAP_APPFONT ( 103 , 25 ) ; + Size = MAP_APPFONT ( 125 , 93 ) ; + TabStop = TRUE ; + VScroll = TRUE ; + HelpId = HID_SQLERROR_EXCHAIN_TEXT; + }; + OKButton PB_OK + { + Pos = MAP_APPFONT ( 95 , 130 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + DefButton = TRUE ; + }; + + String STR_EXCEPTION_STATUS + { + Text [ en-US ] = "SQL Status"; + }; + String STR_EXCEPTION_ERRORCODE + { + Text [ en-US ] = "Error code"; + }; +}; + +String STR_EXPLAN_STRINGCONVERSION_ERROR +{ + Text [ en-US ] = "A frequent reason for this error is an inappropriate character set setting for the language of your database. Check the setting by choosing Edit - Database - Properties."; +}; + +String STR_EXCEPTION_ERROR +{ + Text [ en-US ] = "Error"; +}; + +String STR_EXCEPTION_WARNING +{ + Text [ en-US ] = "Warning"; +}; + +String STR_EXCEPTION_INFO +{ + Text [ en-US ] = "Information"; +}; + +String STR_EXCEPTION_DETAILS +{ + Text [ en-US ] = "Details"; +}; diff --git a/dbaccess/source/ui/dlg/tablespage.cxx b/dbaccess/source/ui/dlg/tablespage.cxx new file mode 100644 index 000000000000..a48b08de740d --- /dev/null +++ b/dbaccess/source/ui/dlg/tablespage.cxx @@ -0,0 +1,694 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#ifndef _DBAUI_TABLESPAGE_HXX_ +#include "tablespage.hxx" +#endif +#ifndef _DBU_DLG_HRC_ +#include "dbu_dlg.hrc" +#endif +#ifndef _DBAUI_DBADMIN_HRC_ +#include "dbadmin.hrc" +#endif +#ifndef _DBAUI_DATASOURCEITEMS_HXX_ +#include "dsitems.hxx" +#endif +#ifndef DBACCESS_UI_BROWSER_ID_HXX +#include "browserids.hxx" +#endif +#ifndef _DBAUI_DATASOURCECONNECTOR_HXX_ +#include "datasourceconnector.hxx" +#endif +#ifndef _COMPHELPER_TYPES_HXX_ +#include <comphelper/types.hxx> +#endif +#ifndef _CONNECTIVITY_DBTOOLS_HXX_ +#include <connectivity/dbtools.hxx> +#endif +#ifndef _DBHELPER_DBEXCEPTION_HXX_ +#include <connectivity/dbexception.hxx> +#endif +#ifndef _DBAUI_STRINGLISTITEM_HXX_ +#include "stringlistitem.hxx" +#endif +#ifndef _SFXENUMITEM_HXX +#include <svl/eitem.hxx> +#endif +#ifndef _SFXSTRITEM_HXX +#include <svl/stritem.hxx> +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef _SV_SVAPP_HXX +#include <vcl/svapp.hxx> +#endif +#ifndef _SV_WAITOBJ_HXX +#include <vcl/waitobj.hxx> +#endif +#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_ +#include <com/sun/star/sdb/SQLContext.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_ +#include <com/sun/star/sdbcx/XAppend.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XMODIFIABLE_HPP_ +#include <com/sun/star/util/XModifiable.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_ +#include <com/sun/star/sdbcx/XDrop.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XDATADEFINITIONSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp> +#endif +#ifndef _DBAUI_SQLMESSAGE_HXX_ +#include "sqlmessage.hxx" +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif +#ifndef DBAUI_TOOLS_HXX +#include "UITools.hxx" +#endif +#ifndef _VOS_MUTEX_HXX_ +#include <vos/mutex.hxx> +#endif +#ifndef _SVTOOLS_IMGDEF_HXX +#include <svtools/imgdef.hxx> +#endif +#ifndef _DBAUI_TABLESSINGLEDLG_HXX_ +#include "TablesSingleDlg.hxx" +#endif +#ifndef TOOLS_DIAGNOSE_EX_H +#include <tools/diagnose_ex.h> +#endif +#ifndef _CPPUHELPER_EXC_HLP_HXX_ +#include <cppuhelper/exc_hlp.hxx> +#endif +#ifndef _DBAUI_AUTOCONTROLS_HRC_ +#include "AutoControls.hrc" +#endif + +//......................................................................... +namespace dbaui +{ +//......................................................................... + + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::sdbc; + using namespace ::com::sun::star::sdbcx; + using namespace ::com::sun::star::sdb; + using namespace ::com::sun::star::beans; + using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::i18n; + using namespace ::com::sun::star::container; + using namespace ::com::sun::star::frame; + using namespace ::com::sun::star::util; + using namespace ::dbtools; + using namespace ::comphelper; + + //======================================================================== + //= OTableSubscriptionPage + //======================================================================== +DBG_NAME(OTableSubscriptionPage) +//------------------------------------------------------------------------ + OTableSubscriptionPage::OTableSubscriptionPage( Window* pParent, const SfxItemSet& _rCoreAttrs,OTableSubscriptionDialog* _pTablesDlg ) + :OGenericAdministrationPage( pParent, ModuleRes(PAGE_TABLESUBSCRIPTION), _rCoreAttrs ) + ,m_aTables (this, ModuleRes(FL_SEPARATOR1)) + ,m_aTablesList (this, NULL,ModuleRes(CTL_TABLESUBSCRIPTION),sal_True) + ,m_aExplanation (this, ModuleRes(FT_FILTER_EXPLANATION)) + ,m_bCheckedAll ( sal_False ) + ,m_bCatalogAtStart ( sal_True ) + ,m_pTablesDlg(_pTablesDlg) + { + DBG_CTOR(OTableSubscriptionPage,NULL); + + m_aTablesList.SetCheckHandler(getControlModifiedLink()); + + // initialize the TabListBox + m_aTablesList.SetSelectionMode( MULTIPLE_SELECTION ); + m_aTablesList.SetDragDropMode( 0 ); + m_aTablesList.EnableInplaceEditing( sal_False ); + m_aTablesList.SetWindowBits(WB_BORDER | WB_HASLINES | WB_HASLINESATROOT | WB_SORT | WB_HASBUTTONS | WB_HSCROLL |WB_HASBUTTONSATROOT); + + m_aTablesList.Clear(); + + FreeResource(); + + m_aTablesList.SetCheckButtonHdl(LINK(this, OTableSubscriptionPage, OnTreeEntryChecked)); + m_aTablesList.SetCheckHandler(LINK(this, OTableSubscriptionPage, OnTreeEntryChecked)); + } + + //------------------------------------------------------------------------ + OTableSubscriptionPage::~OTableSubscriptionPage() + { + // just to make sure that our connection will be removed + try + { + ::comphelper::disposeComponent(m_xCurrentConnection); + } + catch (RuntimeException&) { } + + DBG_DTOR(OTableSubscriptionPage,NULL); + } + + // ----------------------------------------------------------------------------- + void OTableSubscriptionPage::StateChanged( StateChangedType nType ) + { + OGenericAdministrationPage::StateChanged( nType ); + + if ( nType == STATE_CHANGE_CONTROLBACKGROUND ) + { + // Check if we need to get new images for normal/high contrast mode + m_aTablesList.notifyHiContrastChanged(); + } + } + // ----------------------------------------------------------------------------- + void OTableSubscriptionPage::DataChanged( const DataChangedEvent& rDCEvt ) + { + OGenericAdministrationPage::DataChanged( rDCEvt ); + + if ((( rDCEvt.GetType() == DATACHANGED_SETTINGS ) || + ( rDCEvt.GetType() == DATACHANGED_DISPLAY )) && + ( rDCEvt.GetFlags() & SETTINGS_STYLE )) + { + // Check if we need to get new images for normal/high contrast mode + m_aTablesList.notifyHiContrastChanged(); + } + } + //------------------------------------------------------------------ + void OTableSubscriptionPage::resizeControls(const Size& _rDiff) + { + if ( _rDiff.Height() ) + { + Size aOldSize = m_aTablesList.GetSizePixel(); + aOldSize.Height() -= _rDiff.Height(); + m_aTablesList.SetPosSizePixel( + m_aTablesList.GetPosPixel()+Point(0,_rDiff.Height()), + aOldSize + ); + } + } + //------------------------------------------------------------------------ + void OTableSubscriptionPage::implCheckTables(const Sequence< ::rtl::OUString >& _rTables) + { + // the meta data for the current connection, used for splitting up table names + Reference< XDatabaseMetaData > xMeta; + try + { + if (m_xCurrentConnection.is()) + xMeta = m_xCurrentConnection->getMetaData(); + } + catch(SQLException&) + { + DBG_ERROR("OTableSubscriptionPage::implCheckTables : could not retrieve the current connection's meta data!"); + } + + // uncheck all + CheckAll(sal_False); + + // check the ones which are in the list + String aListBoxTable; + ::rtl::OUString sCatalog, sSchema, sName; + + SvLBoxEntry* pRootEntry = m_aTablesList.getAllObjectsEntry(); + sal_Bool bAllTables = sal_False; + sal_Bool bAllSchemas = sal_False; + + const ::rtl::OUString* pIncludeTable = _rTables.getConstArray(); + for (sal_Int32 i=0; i<_rTables.getLength(); ++i, ++pIncludeTable) + { + if (xMeta.is()) + qualifiedNameComponents(xMeta, pIncludeTable->getStr(), sCatalog, sSchema, sName,::dbtools::eInDataManipulation); + else + sName = pIncludeTable->getStr(); + + bAllTables = (1 == sName.getLength()) && ('%' == sName[0]); + bAllSchemas = (1 == sSchema.getLength()) && ('%' == sSchema[0]); + + // the catalog entry + SvLBoxEntry* pCatalog = m_aTablesList.GetEntryPosByName(sCatalog, pRootEntry); + if (!pCatalog && sCatalog.getLength()) + // the table (resp. its catalog) refered in this filter entry does not exist anymore + continue; + + if (bAllSchemas && pCatalog) + { + m_aTablesList.checkWildcard(pCatalog); + continue; + } + + // the schema entry + SvLBoxEntry* pSchema = m_aTablesList.GetEntryPosByName(sSchema, (pCatalog ? pCatalog : pRootEntry)); + if (!pSchema && sSchema.getLength()) + // the table (resp. its schema) refered in this filter entry does not exist anymore + continue; + + if (bAllTables && pSchema) + { + m_aTablesList.checkWildcard(pSchema); + continue; + } + + SvLBoxEntry* pEntry = m_aTablesList.GetEntryPosByName(sName, pSchema ? pSchema : (pCatalog ? pCatalog : pRootEntry) ); + if (pEntry) + m_aTablesList.SetCheckButtonState(pEntry, SV_BUTTON_CHECKED); + } + m_aTablesList.CheckButtons(); + } + + //------------------------------------------------------------------------ + void OTableSubscriptionPage::implCompleteTablesCheck( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rTableFilter ) + { + if (!_rTableFilter.getLength()) + { // no tables visible + CheckAll(sal_False); + } + else + { + if ((1 == _rTableFilter.getLength()) && _rTableFilter[0].equalsAsciiL("%", 1)) + { // all tables visible + CheckAll(sal_True); + } + else + implCheckTables( _rTableFilter ); + } + } + + //------------------------------------------------------------------------- + void OTableSubscriptionPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) + { + // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) + sal_Bool bValid, bReadonly; + getFlags(_rSet, bValid, bReadonly); + + // get the name of the data source we're working for + SFX_ITEMSET_GET(_rSet, pNameItem, SfxStringItem, DSID_NAME, sal_True); + DBG_ASSERT(pNameItem, "OTableSubscriptionPage::implInitControls: missing the name attribute!"); + String sDSName = pNameItem->GetValue(); + + if (bValid && sDSName.Len() && !m_xCurrentConnection.is() ) + { // get the current table list from the connection for the current settings + + // the PropertyValues for the current dialog settings + Sequence< PropertyValue > aConnectionParams; + DBG_ASSERT(m_pTablesDlg, "OTableSubscriptionPage::implInitControls: need a parent dialog doing the translation!"); + if ( m_pTablesDlg ) + { + if (!m_pTablesDlg->getCurrentSettings(aConnectionParams)) + { + m_aTablesList.Clear(); + m_pTablesDlg->endExecution(); + return; + } + } + + if (!m_xCollator.is()) + { + // the collator for the string compares + try + { + m_xCollator = Reference< XCollator >(m_xORB->createInstance(SERVICE_I18N_COLLATOR), UNO_QUERY); + if (m_xCollator.is()) + m_xCollator->loadDefaultCollator(Application::GetSettings().GetLocale(), 0); + } + catch(const Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + // fill the table list with this connection information + SQLExceptionInfo aErrorInfo; + // the current DSN + String sURL; + if ( m_pTablesDlg ) + sURL = m_pTablesDlg->getConnectionURL(); + + try + { + WaitObject aWaitCursor(this); + m_aTablesList.GetModel()->SetSortMode(SortAscending); + m_aTablesList.GetModel()->SetCompareHdl(LINK(this, OTableSubscriptionPage, OnTreeEntryCompare)); + + Reference< XDriver > xDriver; + m_aTablesList.setORB(m_xORB); + Reference<XPropertySet> xProp = m_pTablesDlg->getCurrentDataSource(); + OSL_ENSURE(xProp.is(),"No data source set!"); + if ( xProp.is() ) + { + Any aTableFilter = xProp->getPropertyValue(PROPERTY_TABLEFILTER); + Any aTableTypeFilter = xProp->getPropertyValue(PROPERTY_TABLETYPEFILTER); + + Reference<XModifiable> xModi(getDataSourceOrModel(xProp),UNO_QUERY); + sal_Bool bModified = ( xModi.is() && xModi->isModified() ); + + Sequence< ::rtl::OUString > aNewTableFilter(1); + aNewTableFilter[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")); + xProp->setPropertyValue(PROPERTY_TABLEFILTER,makeAny(aNewTableFilter)); + + xProp->setPropertyValue( PROPERTY_TABLETYPEFILTER, makeAny( Sequence< ::rtl::OUString >() ) ); + Reference< ::com::sun::star::lang::XEventListener> xEvt; + aErrorInfo = ::dbaui::createConnection(xProp,m_xORB,xEvt,m_xCurrentConnection); + + xProp->setPropertyValue(PROPERTY_TABLEFILTER,aTableFilter); + xProp->setPropertyValue(PROPERTY_TABLETYPEFILTER,aTableTypeFilter); + + if ( xModi.is() && !bModified ) + xModi->setModified(sal_False); + + } + + if ( m_xCurrentConnection.is() ) + { + m_aTablesList.UpdateTableList( m_xCurrentConnection ); + if (m_pTablesDlg) + m_pTablesDlg->successfullyConnected(); + } + } + catch (const SQLException&) + { + aErrorInfo = ::cppu::getCaughtException(); + } + + if (aErrorInfo.isValid()) + { + // establishing the connection failed. Show an error window and exit. + OSQLMessageBox aMessageBox( GetParent()->GetParent(), aErrorInfo ); + aMessageBox.Execute(); + m_aTables.Enable(sal_False); + m_aTablesList.Enable(sal_False); + m_aExplanation.Enable(sal_False); + m_aTablesList.Clear(); + + if ( m_pTablesDlg ) + { + m_pTablesDlg->clearPassword(); + m_pTablesDlg->endExecution(); + } + } + else + { + // in addition, we need some infos about the connection used + m_sCatalogSeparator = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".")); // (default) + m_bCatalogAtStart = sal_True; // (default) + try + { + Reference< XDatabaseMetaData > xMeta; + if (m_xCurrentConnection.is()) + xMeta = m_xCurrentConnection->getMetaData(); + if (xMeta.is() && xMeta->supportsCatalogsInDataManipulation()) + { + m_sCatalogSeparator = xMeta->getCatalogSeparator(); + m_bCatalogAtStart = xMeta->isCatalogAtStart(); + } + } + catch(Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + } + + bValid = bValid && m_xCurrentConnection.is(); + bReadonly = bReadonly || !bValid; + + // get the current table filter + SFX_ITEMSET_GET(_rSet, pTableFilter, OStringListItem, DSID_TABLEFILTER, sal_True); + SFX_ITEMSET_GET(_rSet, pSuppress, SfxBoolItem, DSID_SUPPRESSVERSIONCL, sal_True); + Sequence< ::rtl::OUString > aTableFilter; + sal_Bool bSuppressVersionColumns = sal_True; + if (pTableFilter) + aTableFilter = pTableFilter->getList(); + if (pSuppress) + bSuppressVersionColumns = pSuppress->GetValue(); + + implCompleteTablesCheck( aTableFilter ); + + // expand the first entry by default + SvLBoxEntry* pExpand = m_aTablesList.getAllObjectsEntry(); + while (pExpand) + { + m_aTablesList.Expand(pExpand); + pExpand = m_aTablesList.FirstChild(pExpand); + if (pExpand && m_aTablesList.NextSibling(pExpand)) + pExpand = NULL; + } + + // update the toolbox according the the current selection and check state + OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue); + } + + //------------------------------------------------------------------------ + void OTableSubscriptionPage::CheckAll( sal_Bool _bCheck ) + { + SvButtonState eState = _bCheck ? SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED; + SvLBoxEntry* pEntry = m_aTablesList.First(); + while (pEntry) + { + m_aTablesList.SetCheckButtonState( pEntry, eState); + pEntry = m_aTablesList.Next(pEntry); + } + + if (_bCheck && m_aTablesList.getAllObjectsEntry()) + m_aTablesList.checkWildcard(m_aTablesList.getAllObjectsEntry()); + } + + //------------------------------------------------------------------------ + int OTableSubscriptionPage::DeactivatePage(SfxItemSet* _pSet) + { + int nResult = OGenericAdministrationPage::DeactivatePage(_pSet); + + // dispose the connection, we don't need it anymore, so we're not wasting resources + try + { + ::comphelper::disposeComponent(m_xCurrentConnection); + } + catch (RuntimeException&) { } + + return nResult; + } + //------------------------------------------------------------------------ + IMPL_LINK( OTableSubscriptionPage, OnTreeEntryChecked, Control*, _pControl ) + { + return OnControlModified(_pControl); + } + //------------------------------------------------------------------------ + IMPL_LINK( OTableSubscriptionPage, OnTreeEntryCompare, const SvSortData*, _pSortData ) + { + SvLBoxEntry* pLHS = static_cast<SvLBoxEntry*>(_pSortData->pLeft); + SvLBoxEntry* pRHS = static_cast<SvLBoxEntry*>(_pSortData->pRight); + DBG_ASSERT(pLHS && pRHS, "SbaTableQueryBrowser::OnTreeEntryCompare: invalid tree entries!"); + + SvLBoxString* pLeftTextItem = static_cast<SvLBoxString*>(pLHS->GetFirstItem(SV_ITEM_ID_LBOXSTRING)); + SvLBoxString* pRightTextItem = static_cast<SvLBoxString*>(pRHS->GetFirstItem(SV_ITEM_ID_LBOXSTRING)); + DBG_ASSERT(pLeftTextItem && pRightTextItem, "SbaTableQueryBrowser::OnTreeEntryCompare: invalid text items!"); + + String sLeftText = pLeftTextItem->GetText(); + String sRightText = pRightTextItem->GetText(); + + sal_Int32 nCompareResult = 0; // equal by default + + if (m_xCollator.is()) + { + try + { + nCompareResult = m_xCollator->compareString(sLeftText, sRightText); + } + catch(Exception&) + { + } + } + else + // default behaviour if we do not have a collator -> do the simple string compare + nCompareResult = sLeftText.CompareTo(sRightText); + + return nCompareResult; + } + + //------------------------------------------------------------------------ + Sequence< ::rtl::OUString > OTableSubscriptionPage::collectDetailedSelection() const + { + Sequence< ::rtl::OUString > aTableFilter; + static const ::rtl::OUString sDot(RTL_CONSTASCII_USTRINGPARAM(".")); + static const ::rtl::OUString sWildcard(RTL_CONSTASCII_USTRINGPARAM("%")); + + ::rtl::OUString sComposedName; + const SvLBoxEntry* pAllObjectsEntry = m_aTablesList.getAllObjectsEntry(); + if (!pAllObjectsEntry) + return aTableFilter; + SvLBoxEntry* pEntry = m_aTablesList.GetModel()->Next(const_cast<SvLBoxEntry*>(pAllObjectsEntry)); + while(pEntry) + { + sal_Bool bCatalogWildcard = sal_False; + sal_Bool bSchemaWildcard = sal_False; + SvLBoxEntry* pSchema = NULL; + SvLBoxEntry* pCatalog = NULL; + + if (m_aTablesList.GetCheckButtonState(pEntry) == SV_BUTTON_CHECKED && !m_aTablesList.GetModel()->HasChilds(pEntry)) + { // checked and a leaf, which means it's no catalog, no schema, but a real table + ::rtl::OUString sCatalog; + if(m_aTablesList.GetModel()->HasParent(pEntry)) + { + pSchema = m_aTablesList.GetModel()->GetParent(pEntry); + if (pAllObjectsEntry == pSchema) + // do not want to have the root entry + pSchema = NULL; + + if (pSchema) + { // it's a real schema entry, not the "all objects" root + if(m_aTablesList.GetModel()->HasParent(pSchema)) + { + pCatalog = m_aTablesList.GetModel()->GetParent(pSchema); + if (pAllObjectsEntry == pCatalog) + // do not want to have the root entry + pCatalog = NULL; + + if (pCatalog) + { // it's a real catalog entry, not the "all objects" root + bCatalogWildcard = m_aTablesList.isWildcardChecked(pCatalog); + if (m_bCatalogAtStart) + { + sComposedName += m_aTablesList.GetEntryText( pCatalog ); + sComposedName += m_sCatalogSeparator; + if (bCatalogWildcard) + sComposedName += sWildcard; + } + else + { + if (bCatalogWildcard) + sCatalog = sWildcard; + else + sCatalog = ::rtl::OUString(); + sCatalog += m_sCatalogSeparator; + sCatalog += m_aTablesList.GetEntryText( pCatalog ); + } + } + } + bSchemaWildcard = m_aTablesList.isWildcardChecked(pSchema); + sComposedName += m_aTablesList.GetEntryText( pSchema ); + sComposedName += sDot; + } + + if (bSchemaWildcard) + sComposedName += sWildcard; + } + if (!bSchemaWildcard && !bCatalogWildcard) + sComposedName += m_aTablesList.GetEntryText( pEntry ); + + if (!m_bCatalogAtStart && !bCatalogWildcard) + sComposedName += sCatalog; + + // need some space + sal_Int32 nOldLen = aTableFilter.getLength(); + aTableFilter.realloc(nOldLen + 1); + // add the new name + aTableFilter[nOldLen] = sComposedName; + + // reset the composed name + sComposedName = ::rtl::OUString(); + } + + if (bCatalogWildcard) + pEntry = implNextSibling(pCatalog); + else if (bSchemaWildcard) + pEntry = implNextSibling(pSchema); + else + pEntry = m_aTablesList.GetModel()->Next(pEntry); + } + + return aTableFilter; + } + + //------------------------------------------------------------------------ + SvLBoxEntry* OTableSubscriptionPage::implNextSibling(SvLBoxEntry* _pEntry) const + { + SvLBoxEntry* pReturn = NULL; + if (_pEntry) + { + pReturn = m_aTablesList.NextSibling(_pEntry); + if (!pReturn) + pReturn = implNextSibling(m_aTablesList.GetParent(_pEntry)); + } + return pReturn; + } + + //------------------------------------------------------------------------ + BOOL OTableSubscriptionPage::FillItemSet( SfxItemSet& _rCoreAttrs ) + { + sal_Bool bValid, bReadonly; + getFlags(_rCoreAttrs, bValid, bReadonly); + + if (!bValid || bReadonly) + // don't store anything if the data we're working with is invalid or readonly + return sal_True; + + ///////////////////////////////////////////////////////////////////////// + // create the output string which contains all the table names + if ( m_xCurrentConnection.is() ) + { // collect the table filter data only if we have a connection - else no tables are displayed at all + Sequence< ::rtl::OUString > aTableFilter; + if (m_aTablesList.isWildcardChecked(m_aTablesList.getAllObjectsEntry())) + { + aTableFilter.realloc(1); + aTableFilter[0] = ::rtl::OUString("%", 1, RTL_TEXTENCODING_ASCII_US); + } + else + { + aTableFilter = collectDetailedSelection(); + } + _rCoreAttrs.Put( OStringListItem(DSID_TABLEFILTER, aTableFilter) ); + } + + return sal_True; + } + + // ----------------------------------------------------------------------- + void OTableSubscriptionPage::fillControls(::std::vector< ISaveValueWrapper* >& /*_rControlList*/) + { + } + // ----------------------------------------------------------------------- + void OTableSubscriptionPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) + { + _rControlList.push_back(new ODisableWrapper<OTableTreeListBox>(&m_aTablesList)); + _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aTables)); + _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aExplanation)); + } + // ----------------------------------------------------------------------- +//......................................................................... +} // namespace dbaui +//......................................................................... + diff --git a/dbaccess/source/ui/dlg/tablespage.hxx b/dbaccess/source/ui/dlg/tablespage.hxx new file mode 100644 index 000000000000..0e7f72bd5c93 --- /dev/null +++ b/dbaccess/source/ui/dlg/tablespage.hxx @@ -0,0 +1,135 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBAUI_TABLESPAGE_HXX_ +#define _DBAUI_TABLESPAGE_HXX_ + +#ifndef _DBAUI_ADMINPAGES_HXX_ +#include "adminpages.hxx" +#endif +#ifndef _COM_SUN_STAR_I18N_XCOLLATOR_HPP_ +#include <com/sun/star/i18n/XCollator.hpp> +#endif +#ifndef _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif +#ifndef _COMPHELPER_STLTYPES_HXX_ +#include <comphelper/stl_types.hxx> +#endif +#ifndef _SV_FIXED_HXX +#include <vcl/fixed.hxx> +#endif +#ifndef _DBAUI_TABLETREE_HXX_ +#include "tabletree.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ +#include <com/sun/star/sdbc/XConnection.hpp> +#endif + + +//......................................................................... +namespace dbaui +{ +//......................................................................... + + //======================================================================== + //= OTableSubscriptionPage + //======================================================================== + class OTableSubscriptionDialog; + class OTableSubscriptionPage + :public OGenericAdministrationPage + { + private: + FixedLine m_aTables; + OTableTreeListBox m_aTablesList; + FixedText m_aExplanation; + + ::rtl::OUString m_sCatalogSeparator; + sal_Bool m_bCheckedAll : 1; + sal_Bool m_bCatalogAtStart : 1; + + ::osl::Mutex m_aNotifierMutex; + + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > + m_xCurrentConnection; /// valid as long as the page is active + ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCollator > + m_xCollator; + OTableSubscriptionDialog* m_pTablesDlg; + + public: + virtual BOOL FillItemSet(SfxItemSet& _rCoreAttrs); + virtual int DeactivatePage(SfxItemSet* _pSet); + using OGenericAdministrationPage::DeactivatePage; + + virtual void StateChanged( StateChangedType nStateChange ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + + /** will be called when the controls need to be resized. + */ + virtual void resizeControls(const Size& _rDiff); + + OTableSubscriptionPage( Window* pParent, const SfxItemSet& _rCoreAttrs ,OTableSubscriptionDialog* _pTablesDlg); + virtual ~OTableSubscriptionPage(); + + protected: + virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList); + virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList); + + DECL_LINK( OnTreeEntryCompare, const SvSortData* ); + DECL_LINK( OnTreeEntryChecked, Control* ); + + private: + + + /** check the tables in <member>m_aTablesList</member> according to <arg>_rTables</arg> + */ + void implCheckTables(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rTables); + + /// returns the next sibling, if not available, the next sibling of the parent, a.s.o. + SvLBoxEntry* implNextSibling(SvLBoxEntry* _pEntry) const; + + /** return the current selection in <member>m_aTablesList</member> + */ + ::com::sun::star::uno::Sequence< ::rtl::OUString > collectDetailedSelection() const; + + /// (un)check all entries + void CheckAll( BOOL bCheck = sal_True ); + + virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); + + // checks the tables according to the filter given + // in oppsofite to implCheckTables, this method handles the case of an empty sequence, too ... + void implCompleteTablesCheck( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rTableFilter ); + }; + +//......................................................................... +} // namespace dbaui +//......................................................................... + +#endif // _DBAUI_TABLESPAGE_HXX_ + diff --git a/dbaccess/source/ui/dlg/textconnectionsettings.cxx b/dbaccess/source/ui/dlg/textconnectionsettings.cxx new file mode 100644 index 000000000000..d0276d7cd20d --- /dev/null +++ b/dbaccess/source/ui/dlg/textconnectionsettings.cxx @@ -0,0 +1,106 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#include "textconnectionsettings.hxx" +#include "TextConnectionHelper.hxx" +#include "dbu_resource.hrc" +#include "moduledbu.hxx" +#include "dsitems.hxx" +#include "dbustrings.hrc" + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +#include <vcl/msgbox.hxx> + +//........................................................................ +namespace dbaui +{ +//........................................................................ + + /** === begin UNO using === **/ + /** === end UNO using === **/ + + //==================================================================== + //= TextConnectionSettingsDialog + //==================================================================== + //-------------------------------------------------------------------- + TextConnectionSettingsDialog::TextConnectionSettingsDialog( Window* _pParent, SfxItemSet& _rItems ) + :ModalDialog( _pParent, ModuleRes( DLG_TEXT_CONNECTION_SETTINGS ) ) + ,m_aOK( this, ModuleRes( 1 ) ) + ,m_aCancel( this, ModuleRes( 1 ) ) + ,m_rItems( _rItems ) + { + m_pTextConnectionHelper.reset( new OTextConnectionHelper( this, TC_HEADER | TC_SEPARATORS | TC_CHARSET ) ); + FreeResource(); + + m_aOK.SetClickHdl( LINK( this, TextConnectionSettingsDialog, OnOK ) ); + } + + //-------------------------------------------------------------------- + TextConnectionSettingsDialog::~TextConnectionSettingsDialog() + { + } + + //-------------------------------------------------------------------- + void TextConnectionSettingsDialog::bindItemStorages( SfxItemSet& _rSet, PropertyValues& _rValues ) + { + _rValues[ PROPERTY_ID_HEADER_LINE ].reset( new SetItemPropertyStorage( _rSet, DSID_TEXTFILEHEADER ) ); + _rValues[ PROPERTY_ID_FIELD_DELIMITER ].reset( new SetItemPropertyStorage( _rSet, DSID_FIELDDELIMITER ) ); + _rValues[ PROPERTY_ID_STRING_DELIMITER ].reset( new SetItemPropertyStorage( _rSet, DSID_TEXTDELIMITER ) ); + _rValues[ PROPERTY_ID_DECIMAL_DELIMITER ].reset( new SetItemPropertyStorage( _rSet, DSID_DECIMALDELIMITER ) ); + _rValues[ PROPERTY_ID_THOUSAND_DELIMITER ].reset( new SetItemPropertyStorage( _rSet, DSID_THOUSANDSDELIMITER ) ); + _rValues[ PROPERTY_ID_ENCODING ].reset( new SetItemPropertyStorage( _rSet, DSID_CHARSET ) ); + } + + //-------------------------------------------------------------------- + short TextConnectionSettingsDialog::Execute() + { + m_pTextConnectionHelper->implInitControls( m_rItems, sal_True ); + return ModalDialog::Execute(); + } + + //-------------------------------------------------------------------- + IMPL_LINK( TextConnectionSettingsDialog, OnOK, PushButton*, /*_pButton*/ ) + { + if ( m_pTextConnectionHelper->prepareLeave() ) + { + sal_Bool bUnused = sal_False; + m_pTextConnectionHelper->FillItemSet( m_rItems, bUnused ); + EndDialog( RET_OK ); + return 1L; + } + + return 0L; + } + +//........................................................................ +} // namespace dbaui +//........................................................................ diff --git a/dbaccess/source/ui/dlg/textconnectionsettings.src b/dbaccess/source/ui/dlg/textconnectionsettings.src new file mode 100644 index 000000000000..cca76e7f65a3 --- /dev/null +++ b/dbaccess/source/ui/dlg/textconnectionsettings.src @@ -0,0 +1,60 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "dbu_dlg.hrc" +#include "dbu_resource.hrc" +#include "AutoControls.hrc" + +#define DIALOG_WIDTH 200 +#define DIALOG_HEIGHT 160 + +ModalDialog DLG_TEXT_CONNECTION_SETTINGS +{ + Size = MAP_APPFONT( DIALOG_WIDTH, DIALOG_HEIGHT ); + OutputSize = TRUE ; + + Moveable = TRUE ; + Closeable = TRUE ; + + Text [ en-US ] = "Text Connection Settings"; + + AUTO_SEPARATORCONTROLGROUP( UNRELATED_CONTROLS, DIALOG_WIDTH ) + + OKButton 1 + { + Pos = MAP_APPFONT( DIALOG_WIDTH - 6 - BUTTON_WIDTH - RELATED_CONTROLS - BUTTON_WIDTH, DIALOG_HEIGHT - 6 - BUTTON_HEIGHT ); + Size = MAP_APPFONT( BUTTON_WIDTH, BUTTON_HEIGHT ); + + DefButton = TRUE; + }; + + CancelButton 1 + { + Pos = MAP_APPFONT( DIALOG_WIDTH - 6 - BUTTON_WIDTH, DIALOG_HEIGHT - 6 - BUTTON_HEIGHT ); + Size = MAP_APPFONT( BUTTON_WIDTH, BUTTON_HEIGHT ); + }; +}; |