diff options
Diffstat (limited to 'dbaccess/source/ui/uno')
32 files changed, 5894 insertions, 0 deletions
diff --git a/dbaccess/source/ui/uno/AdabasSettingsDlg.cxx b/dbaccess/source/ui/uno/AdabasSettingsDlg.cxx new file mode 100644 index 000000000000..6047ebfc3af3 --- /dev/null +++ b/dbaccess/source/ui/uno/AdabasSettingsDlg.cxx @@ -0,0 +1,133 @@ +/************************************************************************* + * + * 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 _DBU_REGHELPER_HXX_ +#include "dbu_reghelper.hxx" +#endif +#ifndef _DBAUI_ADABASSETTINGSDLG_HXX +#include "AdabasSettingsDlg.hxx" +#endif +#ifndef DBAUI_ADABASSTATDLG_HXX +#include "AdabasStatDlg.hxx" +#endif + + +using namespace dbaui; + +extern "C" void SAL_CALL createRegistryInfo_OAdabasSettingsDialog() +{ + static OMultiInstanceAutoRegistration< OAdabasSettingsDialog > aAutoRegistration; +} + +//......................................................................... +namespace dbaui +{ +//......................................................................... + + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::beans; + +//========================================================================= +//------------------------------------------------------------------------- +OAdabasSettingsDialog::OAdabasSettingsDialog(const Reference< XMultiServiceFactory >& _rxORB) + :ODatabaseAdministrationDialog(_rxORB) +{ +} +//------------------------------------------------------------------------- +Sequence<sal_Int8> SAL_CALL OAdabasSettingsDialog::getImplementationId( ) throw(RuntimeException) +{ + static ::cppu::OImplementationId aId; + return aId.getImplementationId(); +} + +//------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL OAdabasSettingsDialog::Create(const Reference< XMultiServiceFactory >& _rxFactory) +{ + return *(new OAdabasSettingsDialog(_rxFactory)); +} + +//------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OAdabasSettingsDialog::getImplementationName() throw(RuntimeException) +{ + return getImplementationName_Static(); +} + +//------------------------------------------------------------------------- +::rtl::OUString OAdabasSettingsDialog::getImplementationName_Static() throw(RuntimeException) +{ + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.OAdabasSettingsDialog")); +} + +//------------------------------------------------------------------------- +::comphelper::StringSequence SAL_CALL OAdabasSettingsDialog::getSupportedServiceNames() throw(RuntimeException) +{ + return getSupportedServiceNames_Static(); +} + +//------------------------------------------------------------------------- +::comphelper::StringSequence OAdabasSettingsDialog::getSupportedServiceNames_Static() throw(RuntimeException) +{ + ::comphelper::StringSequence aSupported(1); + aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.AdabasAdministrationDialog")); + return aSupported; +} + +//------------------------------------------------------------------------- +Reference<XPropertySetInfo> SAL_CALL OAdabasSettingsDialog::getPropertySetInfo() throw(RuntimeException) +{ + Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; +} + +//------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper& OAdabasSettingsDialog::getInfoHelper() +{ + return *const_cast<OAdabasSettingsDialog*>(this)->getArrayHelper(); +} + +//------------------------------------------------------------------------------ +::cppu::IPropertyArrayHelper* OAdabasSettingsDialog::createArrayHelper( ) const +{ + Sequence< Property > aProps; + describeProperties(aProps); + return new ::cppu::OPropertyArrayHelper(aProps); +} +//------------------------------------------------------------------------------ +Dialog* OAdabasSettingsDialog::createDialog(Window* _pParent) +{ + OAdabasStatPageDlg* pDlg = new OAdabasStatPageDlg(_pParent, m_pDatasourceItems, m_aContext.getLegacyServiceFactory(),m_aInitialSelection); + return pDlg; +} + +//......................................................................... +} // namespace dbaui +//......................................................................... + diff --git a/dbaccess/source/ui/uno/AdabasSettingsDlg.hxx b/dbaccess/source/ui/uno/AdabasSettingsDlg.hxx new file mode 100644 index 000000000000..4ccd46f4c45a --- /dev/null +++ b/dbaccess/source/ui/uno/AdabasSettingsDlg.hxx @@ -0,0 +1,80 @@ +/************************************************************************* + * + * 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_ADABASSETTINGSDLG_HXX +#define _DBAUI_ADABASSETTINGSDLG_HXX + +#ifndef _DBAUI_UNOADMIN_ +#include "unoadmin.hxx" +#endif + +//......................................................................... +namespace dbaui +{ +//......................................................................... +//========================================================================= +//= OAdabasSettingsDialog +//========================================================================= +class OAdabasSettingsDialog + :public ODatabaseAdministrationDialog + ,public ::comphelper::OPropertyArrayUsageHelper< OAdabasSettingsDialog > +{ + +protected: + OAdabasSettingsDialog(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB); + +public: + // XTypeProvider + virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); + virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo - static methods + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > + SAL_CALL Create(const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >&); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException); + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; +protected: +// OGenericUnoDialog overridables + virtual Dialog* createDialog(Window* _pParent); +}; + +//......................................................................... +} // namespace dbaui +//......................................................................... + +#endif // _DBAUI_ADABASSETTINGSDLG_HXX + diff --git a/dbaccess/source/ui/uno/AdvancedSettingsDlg.cxx b/dbaccess/source/ui/uno/AdvancedSettingsDlg.cxx new file mode 100644 index 000000000000..6fe26f228180 --- /dev/null +++ b/dbaccess/source/ui/uno/AdvancedSettingsDlg.cxx @@ -0,0 +1,159 @@ +/************************************************************************* + * + * 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 "unoadmin.hxx" +#include "dbu_reghelper.hxx" +#include "advancedsettingsdlg.hxx" + +//......................................................................... +namespace dbaui +{ +//......................................................................... + + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::beans; + + //========================================================================= + //= OAdvancedSettingsDialog + //========================================================================= + class OAdvancedSettingsDialog + :public ODatabaseAdministrationDialog + ,public ::comphelper::OPropertyArrayUsageHelper< OAdvancedSettingsDialog > + { + + protected: + OAdvancedSettingsDialog(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB); + + public: + // XTypeProvider + virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); + virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo - static methods + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > + SAL_CALL Create(const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >&); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException); + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; + protected: + // OGenericUnoDialog overridables + virtual Dialog* createDialog(Window* _pParent); + }; + + //========================================================================= + //------------------------------------------------------------------------- + OAdvancedSettingsDialog::OAdvancedSettingsDialog(const Reference< XMultiServiceFactory >& _rxORB) + :ODatabaseAdministrationDialog(_rxORB) + { + } + //------------------------------------------------------------------------- + Sequence<sal_Int8> SAL_CALL OAdvancedSettingsDialog::getImplementationId( ) throw(RuntimeException) + { + static ::cppu::OImplementationId aId; + return aId.getImplementationId(); + } + + //------------------------------------------------------------------------- + Reference< XInterface > SAL_CALL OAdvancedSettingsDialog::Create(const Reference< XMultiServiceFactory >& _rxFactory) + { + return *(new OAdvancedSettingsDialog(_rxFactory)); + } + + //------------------------------------------------------------------------- + ::rtl::OUString SAL_CALL OAdvancedSettingsDialog::getImplementationName() throw(RuntimeException) + { + return getImplementationName_Static(); + } + + //------------------------------------------------------------------------- + ::rtl::OUString OAdvancedSettingsDialog::getImplementationName_Static() throw(RuntimeException) + { + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.OAdvancedSettingsDialog")); + } + + //------------------------------------------------------------------------- + ::comphelper::StringSequence SAL_CALL OAdvancedSettingsDialog::getSupportedServiceNames() throw(RuntimeException) + { + return getSupportedServiceNames_Static(); + } + + //------------------------------------------------------------------------- + ::comphelper::StringSequence OAdvancedSettingsDialog::getSupportedServiceNames_Static() throw(RuntimeException) + { + ::comphelper::StringSequence aSupported(1); + aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.AdvancedDatabaseSettingsDialog")); + return aSupported; + } + + //------------------------------------------------------------------------- + Reference<XPropertySetInfo> SAL_CALL OAdvancedSettingsDialog::getPropertySetInfo() throw(RuntimeException) + { + Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; + } + + //------------------------------------------------------------------------- + ::cppu::IPropertyArrayHelper& OAdvancedSettingsDialog::getInfoHelper() + { + return *const_cast<OAdvancedSettingsDialog*>(this)->getArrayHelper(); + } + + //------------------------------------------------------------------------------ + ::cppu::IPropertyArrayHelper* OAdvancedSettingsDialog::createArrayHelper( ) const + { + Sequence< Property > aProps; + describeProperties(aProps); + return new ::cppu::OPropertyArrayHelper(aProps); + } + //------------------------------------------------------------------------------ + Dialog* OAdvancedSettingsDialog::createDialog(Window* _pParent) + { + AdvancedSettingsDialog* pDlg = new AdvancedSettingsDialog(_pParent, m_pDatasourceItems, m_aContext.getLegacyServiceFactory(),m_aInitialSelection); + return pDlg; + } + +//......................................................................... +} // namespace dbaui +//......................................................................... + +extern "C" void SAL_CALL createRegistryInfo_OAdvancedSettingsDialog() +{ + static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OAdvancedSettingsDialog > aAutoRegistration; +} diff --git a/dbaccess/source/ui/uno/ColumnControl.cxx b/dbaccess/source/ui/uno/ColumnControl.cxx new file mode 100644 index 000000000000..6d9d1eba083a --- /dev/null +++ b/dbaccess/source/ui/uno/ColumnControl.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_COLUMNCONTROL_HXX +#include "ColumnControl.hxx" +#endif +#ifndef DBAUI_COLUMNPEER_HXX +#include "ColumnPeer.hxx" +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef _DBASHARED_APITOOLS_HXX_ +#include "apitools.hxx" +#endif +#ifndef _COM_SUN_STAR_AWT_POSSIZE_HPP_ +#include <com/sun/star/awt/PosSize.hpp> +#endif +#ifndef _DBU_REGHELPER_HXX_ +#include "dbu_reghelper.hxx" +#endif + +extern "C" void SAL_CALL createRegistryInfo_OColumnControl() +{ + static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OColumnControl> aAutoRegistration; +} +//......................................................................... +namespace dbaui +{ +//......................................................................... +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::awt; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::sdbc; + +OColumnControl::OColumnControl(const Reference<XMultiServiceFactory>& _rxFactory) +: m_xORB(_rxFactory) +{ +} +// ----------------------------------------------------------------------------- +IMPLEMENT_SERVICE_INFO2_STATIC(OColumnControl,SERVICE_CONTROLDEFAULT,"com.sun.star.awt.UnoControl","com.sun.star.sdb.ColumnDescriptorControl") +// ----------------------------------------------------------------------------- +::rtl::OUString OColumnControl::GetComponentServiceName() +{ + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.ColumnDescriptorControl")); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OColumnControl::createPeer(const Reference< XToolkit >& /*rToolkit*/, const Reference< XWindowPeer >& rParentPeer) throw( RuntimeException ) +{ + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + if ( !getPeer().is() ) + { + mbCreatingPeer = sal_True; + + Window* pParentWin = NULL; + if (rParentPeer.is()) + { + VCLXWindow* pParent = VCLXWindow::GetImplementation(rParentPeer); + if (pParent) + pParentWin = pParent->GetWindow(); + } + + OColumnPeer* pPeer = new OColumnPeer(pParentWin,m_xORB); + OSL_ENSURE(pPeer != NULL, "FmXGridControl::createPeer : imp_CreatePeer didn't return a peer !"); + setPeer( pPeer ); + + UnoControlComponentInfos aComponentInfos(maComponentInfos); + Reference< XGraphics > xGraphics( mxGraphics ); + Reference< XView > xV(getPeer(), UNO_QUERY); + Reference< XWindow > xW(getPeer(), UNO_QUERY); + + aGuard.clear(); + + updateFromModel(); + + xV->setZoom( aComponentInfos.nZoomX, aComponentInfos.nZoomY ); + setPosSize( aComponentInfos.nX, aComponentInfos.nY, aComponentInfos.nWidth, aComponentInfos.nHeight, ::com::sun::star::awt::PosSize::POSSIZE ); + + Reference<XPropertySet> xProp(getModel(), UNO_QUERY); + if ( xProp.is() ) + { + Reference<XConnection> xCon(xProp->getPropertyValue(PROPERTY_ACTIVE_CONNECTION),UNO_QUERY); + pPeer->setConnection(xCon); + Reference<XPropertySet> xColumn(xProp->getPropertyValue(PROPERTY_COLUMN),UNO_QUERY); + pPeer->setColumn(xColumn); + sal_Int32 nWidth = 50; + xProp->getPropertyValue(PROPERTY_EDIT_WIDTH) >>= nWidth; + pPeer->setEditWidth(nWidth); + } + + if (aComponentInfos.bVisible) + xW->setVisible(sal_True); + + if (!aComponentInfos.bEnable) + xW->setEnable(sal_False); + + if (maWindowListeners.getLength()) + xW->addWindowListener( &maWindowListeners ); + + if (maFocusListeners.getLength()) + xW->addFocusListener( &maFocusListeners ); + + if (maKeyListeners.getLength()) + xW->addKeyListener( &maKeyListeners ); + + if (maMouseListeners.getLength()) + xW->addMouseListener( &maMouseListeners ); + + if (maMouseMotionListeners.getLength()) + xW->addMouseMotionListener( &maMouseMotionListeners ); + + if (maPaintListeners.getLength()) + xW->addPaintListener( &maPaintListeners ); + + Reference< ::com::sun::star::awt::XView > xPeerView(getPeer(), UNO_QUERY); + xPeerView->setZoom( maComponentInfos.nZoomX, maComponentInfos.nZoomY ); + xPeerView->setGraphics( xGraphics ); + + mbCreatingPeer = sal_False; + } +} +//......................................................................... +} // namespace dbaui +//......................................................................... diff --git a/dbaccess/source/ui/uno/ColumnControl.hxx b/dbaccess/source/ui/uno/ColumnControl.hxx new file mode 100644 index 000000000000..866eba99b18c --- /dev/null +++ b/dbaccess/source/ui/uno/ColumnControl.hxx @@ -0,0 +1,58 @@ +/************************************************************************* + * + * 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_COLUMNCONTROL_HXX +#define DBAUI_COLUMNCONTROL_HXX + +#ifndef _TOOLKIT_CONTROLS_UNOCONTROL_HXX_ +#include <toolkit/controls/unocontrol.hxx> +#endif +#ifndef _DBASHARED_APITOOLS_HXX_ +#include "apitools.hxx" +#endif + +namespace dbaui +{ + class OColumnControl : public UnoControl + { + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xORB; + public: + OColumnControl(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory); + + // UnoControl + virtual ::rtl::OUString GetComponentServiceName(); + + // XServiceInfo + DECLARE_SERVICE_INFO_STATIC(); + + // ::com::sun::star::awt::XControl + virtual void SAL_CALL createPeer(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit >& _rToolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& Parent) throw(::com::sun::star::uno::RuntimeException); + }; +//......................................................................... +} // namespace dbaui +//......................................................................... + +#endif // DBAUI_COLUMNCONTROL_HXX diff --git a/dbaccess/source/ui/uno/ColumnModel.cxx b/dbaccess/source/ui/uno/ColumnModel.cxx new file mode 100644 index 000000000000..d8d43caa7f94 --- /dev/null +++ b/dbaccess/source/ui/uno/ColumnModel.cxx @@ -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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#ifndef DBAUI_COLUMNMODEL_HXX +#include "ColumnModel.hxx" +#endif +#ifndef _COM_SUN_STAR_AWT_FONTRELIEF_HPP_ +#include <com/sun/star/awt/FontRelief.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_FONTEMPHASISMARK_HPP_ +#include <com/sun/star/awt/FontEmphasisMark.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ +#include <com/sun/star/beans/PropertyAttribute.hpp> +#endif + +#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_ +#include <cppuhelper/queryinterface.hxx> +#endif +#ifndef _COMPHELPER_EXTRACT_HXX_ +#include <comphelper/extract.hxx> +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef _DBU_REGHELPER_HXX_ +#include "dbu_reghelper.hxx" +#endif +#ifndef _TOOLKIT_UNOHLP_HXX +#include <toolkit/helper/vclunohelper.hxx> +#endif +#ifndef _COMPHELPER_PROPERTY_HXX_ +#include <comphelper/property.hxx> +#endif + +extern "C" void SAL_CALL createRegistryInfo_OColumnControlModel() +{ + static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OColumnControlModel> aAutoRegistration; +} + +//......................................................................... +namespace dbaui +{ +//......................................................................... +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::awt; +using namespace ::com::sun::star::io; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::util; + + +DBG_NAME(OColumnControlModel) +//------------------------------------------------------------------ +OColumnControlModel::OColumnControlModel(const Reference<XMultiServiceFactory>& _rxFactory) + :OPropertyContainer(m_aBHelper) + ,OColumnControlModel_BASE(m_aMutex) + ,m_xORB(_rxFactory) + ,m_sDefaultControl(SERVICE_CONTROLDEFAULT) + ,m_bEnable(sal_True) + ,m_nBorder(0) + ,m_nWidth(50) +{ + DBG_CTOR(OColumnControlModel,NULL); + registerProperties(); +} +// ----------------------------------------------------------------------------- +OColumnControlModel::OColumnControlModel(const OColumnControlModel* _pSource,const Reference<XMultiServiceFactory>& _rxFactory) + :OPropertyContainer(m_aBHelper) + ,OColumnControlModel_BASE(m_aMutex) + ,m_xORB(_rxFactory) + ,m_sDefaultControl(_pSource->m_sDefaultControl) + ,m_aTabStop(_pSource->m_aTabStop) + ,m_bEnable(_pSource->m_bEnable) + ,m_nBorder(_pSource->m_nBorder) + ,m_nWidth(50) +{ + DBG_CTOR(OColumnControlModel,NULL); + registerProperties(); +} +// ----------------------------------------------------------------------------- +OColumnControlModel::~OColumnControlModel() +{ + DBG_DTOR(OColumnControlModel,NULL); + if ( !OColumnControlModel_BASE::rBHelper.bDisposed && !OColumnControlModel_BASE::rBHelper.bInDispose ) + { + acquire(); + dispose(); + } +} +// ----------------------------------------------------------------------------- +void OColumnControlModel::registerProperties() +{ + registerProperty( PROPERTY_ACTIVE_CONNECTION, PROPERTY_ID_ACTIVE_CONNECTION, PropertyAttribute::TRANSIENT | PropertyAttribute::BOUND, + &m_xConnection, ::getCppuType( &m_xConnection ) ); + Any a; + a <<= m_xColumn; +// registerMayBeVoidProperty( PROPERTY_COLUMN, PROPERTY_ID_COLUMN, PropertyAttribute::TRANSIENT | PropertyAttribute::BOUND| PropertyAttribute::MAYBEVOID, +// &a, ::getCppuType( &m_xColumn ) ); + registerProperty( PROPERTY_COLUMN, PROPERTY_ID_COLUMN, PropertyAttribute::TRANSIENT | PropertyAttribute::BOUND, + &m_xColumn, ::getCppuType( &m_xColumn ) ); + + registerMayBeVoidProperty( PROPERTY_TABSTOP, PROPERTY_ID_TABSTOP, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID, + &m_aTabStop, ::getCppuType( static_cast<sal_Int16*>(NULL) ) ); + registerProperty( PROPERTY_DEFAULTCONTROL, PROPERTY_ID_DEFAULTCONTROL, PropertyAttribute::BOUND, + &m_sDefaultControl, ::getCppuType( &m_sDefaultControl ) ); + registerProperty( PROPERTY_ENABLED, PROPERTY_ID_ENABLED, PropertyAttribute::BOUND, + &m_bEnable, ::getCppuType( &m_bEnable ) ); + registerProperty( PROPERTY_BORDER, PROPERTY_ID_BORDER, PropertyAttribute::BOUND, + &m_nBorder, ::getCppuType( &m_nBorder ) ); + registerProperty( PROPERTY_EDIT_WIDTH, PROPERTY_ID_EDIT_WIDTH, PropertyAttribute::BOUND, + &m_nWidth, ::getCppuType( &m_nWidth ) ); +} +// XCloneable +//------------------------------------------------------------------------------ +Reference< XCloneable > SAL_CALL OColumnControlModel::createClone( ) throw (RuntimeException) +{ + return new OColumnControlModel( this, getORB() ); +} +//------------------------------------------------------------------------------ +IMPLEMENT_TYPEPROVIDER2(OColumnControlModel,OColumnControlModel_BASE,comphelper::OPropertyContainer) +IMPLEMENT_PROPERTYCONTAINER_DEFAULTS(OColumnControlModel) +IMPLEMENT_SERVICE_INFO2_STATIC(OColumnControlModel,"com.sun.star.comp.dbu.OColumnControlModel","com.sun.star.awt.UnoControlModel","com.sun.star.sdb.ColumnDescriptorControlModel") +IMPLEMENT_FORWARD_REFCOUNT( OColumnControlModel, OColumnControlModel_BASE ) +//------------------------------------------------------------------------------ +Any SAL_CALL OColumnControlModel::queryInterface( const Type& _rType ) throw (RuntimeException) +{ + return OColumnControlModel_BASE::queryInterface( _rType ); +} +// ----------------------------------------------------------------------------- +// com::sun::star::XAggregation +Any SAL_CALL OColumnControlModel::queryAggregation( const Type& rType ) throw(RuntimeException) +{ + Any aRet(OColumnControlModel_BASE::queryAggregation(rType)); + if (!aRet.hasValue()) + aRet = comphelper::OPropertyContainer::queryInterface(rType); + return aRet; +} +//------------------------------------------------------------------------------ +::rtl::OUString SAL_CALL OColumnControlModel::getServiceName() throw ( RuntimeException) +{ + return ::rtl::OUString(); +} +//------------------------------------------------------------------------------ +void OColumnControlModel::write(const Reference<XObjectOutputStream>& /*_rxOutStream*/) throw ( ::com::sun::star::io::IOException, RuntimeException) +{ + // TODO +} + +//------------------------------------------------------------------------------ +void OColumnControlModel::read(const Reference<XObjectInputStream>& /*_rxInStream*/) throw ( ::com::sun::star::io::IOException, RuntimeException) +{ + // TODO +} + +//......................................................................... +} // namespace dbaui +//......................................................................... + diff --git a/dbaccess/source/ui/uno/ColumnModel.hxx b/dbaccess/source/ui/uno/ColumnModel.hxx new file mode 100644 index 000000000000..363898c89111 --- /dev/null +++ b/dbaccess/source/ui/uno/ColumnModel.hxx @@ -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 DBAUI_COLUMNMODEL_HXX +#define DBAUI_COLUMNMODEL_HXX + +#ifndef _COM_SUN_STAR_AWT_XCONTROLMODEL_HPP_ +#include <com/sun/star/awt/XControlModel.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XCLONEABLE_HPP_ +#include <com/sun/star/util/XCloneable.hpp> +#endif +#ifndef _COM_SUN_STAR_IO_XPERSISTOBJECT_HPP_ +#include <com/sun/star/io/XPersistObject.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ +#include <com/sun/star/sdbc/XConnection.hpp> +#endif +#ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_ +#include <comphelper/proparrhlp.hxx> +#endif +#ifndef _COMPHELPER_PROPERTYCONTAINER_HXX_ +#include <comphelper/propertycontainer.hxx> +#endif +#ifndef _COMPHELPER_BROADCASTHELPER_HXX_ +#include <comphelper/broadcasthelper.hxx> +#endif +#ifndef _COMPHELPER_UNO3_HXX_ +#include <comphelper/uno3.hxx> +#endif +#ifndef _CPPUHELPER_COMPBASE4_HXX_ +#include <cppuhelper/compbase4.hxx> +#endif +#ifndef _DBASHARED_APITOOLS_HXX_ +#include "apitools.hxx" +#endif + +//......................................................................... +namespace dbaui +{ +//......................................................................... + +//================================================================== +// OColumnControlModel +//================================================================== +typedef ::cppu::WeakAggComponentImplHelper4 < ::com::sun::star::awt::XControlModel + , ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::util::XCloneable + , ::com::sun::star::io::XPersistObject + > OColumnControlModel_BASE; + +class OColumnControlModel; + +class OColumnControlModel : public ::comphelper::OMutexAndBroadcastHelper + ,public ::comphelper::OPropertyContainer + ,public ::comphelper::OPropertyArrayUsageHelper< OColumnControlModel > + ,public OColumnControlModel_BASE +{ + + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xORB; +// [properties] + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> m_xConnection; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xColumn; + ::rtl::OUString m_sDefaultControl; + ::com::sun::star::uno::Any m_aTabStop; + sal_Bool m_bEnable; + sal_Int16 m_nBorder; + sal_Int32 m_nWidth; +// [properties] + + inline ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> getORB() const { return m_xORB; } + void registerProperties(); +protected: + + virtual ~OColumnControlModel(); + OColumnControlModel(const OColumnControlModel* _pSource + ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory); +public: + OColumnControlModel(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory); + +// UNO Anbindung + DECLARE_XINTERFACE( ) + +// ::com::sun::star::lang::XServiceInfo + DECLARE_SERVICE_INFO_STATIC(); + +// XTypeProvider + DECLARE_TYPEPROVIDER( ); + +// com::sun::star::uno::XAggregation + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException); + +// ::com::sun::star::io::XPersistObject + virtual ::rtl::OUString SAL_CALL getServiceName() throw ( ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + + +// OPropertyArrayUsageHelper + DECLARE_PROPERTYCONTAINER_DEFAULTS( ); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException); +}; + +//......................................................................... +} // namespace dbaui +//......................................................................... +#endif // DBAUI_COLUMNMODEL_HXX diff --git a/dbaccess/source/ui/uno/ColumnPeer.cxx b/dbaccess/source/ui/uno/ColumnPeer.cxx new file mode 100644 index 000000000000..2f4c7a264329 --- /dev/null +++ b/dbaccess/source/ui/uno/ColumnPeer.cxx @@ -0,0 +1,172 @@ +/************************************************************************* + * + * 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_COLUMNPEER_HXX +#include "ColumnPeer.hxx" +#endif +#ifndef DBAUI_COLUMNCONTROLWINDOW_HXX +#include "ColumnControlWindow.hxx" +#endif +#ifndef _SV_SVAPP_HXX +#include <vcl/svapp.hxx> +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef DBAUI_FIELDDESCRIPTIONS_HXX +#include "FieldDescriptions.hxx" +#endif + +//......................................................................... +namespace dbaui +{ +//......................................................................... +using namespace ::com::sun::star::awt; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::sdbc; + +OColumnPeer::OColumnPeer(Window* _pParent,const Reference<XMultiServiceFactory>& _rxFactory) + :m_xORB(_rxFactory) + ,m_pActFieldDescr(NULL) +{ + osl_incrementInterlockedCount( &m_refCount ); + { + OColumnControlWindow* pFieldControl = new OColumnControlWindow(_pParent,m_xORB); + pFieldControl->SetComponentInterface(this); + pFieldControl->Show(); + } + osl_decrementInterlockedCount( &m_refCount ); +} +// ----------------------------------------------------------------------------- +void OColumnPeer::setEditWidth(sal_Int32 _nWidth) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + + OColumnControlWindow* pFieldControl = static_cast<OColumnControlWindow*>( GetWindow() ); + if ( pFieldControl ) + { + pFieldControl->setEditWidth(_nWidth); + } +} +// ----------------------------------------------------------------------------- +void OColumnPeer::setColumn(const Reference< XPropertySet>& _xColumn) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + + OColumnControlWindow* pFieldControl = static_cast<OColumnControlWindow*>( GetWindow() ); + if ( pFieldControl ) + { + if ( m_pActFieldDescr ) + { + delete m_pActFieldDescr; + m_pActFieldDescr = NULL; + } + if ( _xColumn.is() ) + { + sal_Int32 nType = 0; + sal_Int32 nScale = 0; + sal_Int32 nPrecision = 0; + sal_Bool bAutoIncrement = sal_False; + ::rtl::OUString sTypeName; + + try + { + // get the properties from the column + _xColumn->getPropertyValue(PROPERTY_TYPENAME) >>= sTypeName; + _xColumn->getPropertyValue(PROPERTY_TYPE) >>= nType; + _xColumn->getPropertyValue(PROPERTY_SCALE) >>= nScale; + _xColumn->getPropertyValue(PROPERTY_PRECISION) >>= nPrecision; + _xColumn->getPropertyValue(PROPERTY_ISAUTOINCREMENT) >>= bAutoIncrement; + } + catch(Exception) + { + } + + m_pActFieldDescr = new OFieldDescription(_xColumn,sal_True); + // search for type + ::rtl::OUString sCreateParam(RTL_CONSTASCII_USTRINGPARAM("x")); + sal_Bool bForce; + TOTypeInfoSP pTypeInfo = ::dbaui::getTypeInfoFromType(*pFieldControl->getTypeInfo(),nType,sTypeName,sCreateParam,nPrecision,nScale,bAutoIncrement,bForce); + if ( !pTypeInfo.get() ) + pTypeInfo = pFieldControl->getDefaultTyp(); + + m_pActFieldDescr->FillFromTypeInfo(pTypeInfo,sal_True,sal_False); + m_xColumn = _xColumn; + } + pFieldControl->DisplayData(m_pActFieldDescr); + } +} +// ----------------------------------------------------------------------------- +void OColumnPeer::setConnection(const Reference< XConnection>& _xCon) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + OColumnControlWindow* pFieldControl = static_cast<OColumnControlWindow*>( GetWindow() ); + if ( pFieldControl ) + pFieldControl->setConnection(_xCon); +} +//------------------------------------------------------------------------------ +void OColumnPeer::setProperty( const ::rtl::OUString& _rPropertyName, const Any& Value) throw( RuntimeException ) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + + if ( 0 == _rPropertyName.compareToAscii( PROPERTY_COLUMN ) ) + { + Reference<XPropertySet> xProp(Value,UNO_QUERY); + setColumn(xProp); + } + else if ( 0 == _rPropertyName.compareToAscii( PROPERTY_ACTIVE_CONNECTION ) ) + { + Reference<XConnection> xCon(Value,UNO_QUERY); + setConnection(xCon); + } + else + VCLXWindow::setProperty(_rPropertyName,Value); +} +// ----------------------------------------------------------------------------- +Any OColumnPeer::getProperty( const ::rtl::OUString& _rPropertyName ) throw( RuntimeException ) +{ + Any aProp; + OFieldDescControl* pFieldControl = static_cast<OFieldDescControl*>( GetWindow() ); + if ( pFieldControl && 0 == _rPropertyName.compareToAscii( PROPERTY_COLUMN ) ) + { + aProp <<= m_xColumn; + } + else if ( pFieldControl && 0 == _rPropertyName.compareToAscii( PROPERTY_ACTIVE_CONNECTION ) ) + { + aProp <<= pFieldControl->getConnection(); + } + else + aProp = VCLXWindow::getProperty(_rPropertyName); + return aProp; +} +//......................................................................... +} // namespace dbaui +//......................................................................... diff --git a/dbaccess/source/ui/uno/ColumnPeer.hxx b/dbaccess/source/ui/uno/ColumnPeer.hxx new file mode 100644 index 000000000000..e00459a67c10 --- /dev/null +++ b/dbaccess/source/ui/uno/ColumnPeer.hxx @@ -0,0 +1,70 @@ +/************************************************************************* + * + * 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_COLUMNPEER_HXX +#define DBAUI_COLUMNPEER_HXX + +#ifndef _TOOLKIT_AWT_VCLXWINDOW_HXX_ +#include <toolkit/awt/vclxwindow.hxx> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#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 +{ +//......................................................................... + class OFieldDescription; + class OColumnPeer : public VCLXWindow + { + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xORB; + OFieldDescription* m_pActFieldDescr; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xColumn; + public: + + OColumnPeer(Window* _pParent + ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory); + + void setColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xColumn); + void setConnection(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xCon); + void setEditWidth(sal_Int32 _nWidth); + // VCLXWindow + virtual void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); + }; +//......................................................................... +} // namespace dbaui +//......................................................................... +#endif //DBAUI_COLUMNPEER_HXX + + diff --git a/dbaccess/source/ui/uno/DBTypeWizDlg.cxx b/dbaccess/source/ui/uno/DBTypeWizDlg.cxx new file mode 100644 index 000000000000..27b8d1d14b92 --- /dev/null +++ b/dbaccess/source/ui/uno/DBTypeWizDlg.cxx @@ -0,0 +1,132 @@ +/************************************************************************* + * + * 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 _DBU_REGHELPER_HXX_ +#include "dbu_reghelper.hxx" +#endif +#ifndef DBAUI_DBTYPEWIZDLG_HXX +#include "DBTypeWizDlg.hxx" +#endif +#ifndef DBAUI_DBWIZ_HXX +#include "dbwiz.hxx" +#endif + +using namespace dbaui; + +extern "C" void SAL_CALL createRegistryInfo_ODBTypeWizDialog() +{ + static OMultiInstanceAutoRegistration< ODBTypeWizDialog > aAutoRegistration; +} + +//......................................................................... +namespace dbaui +{ +//......................................................................... + + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::beans; + +//========================================================================= +//------------------------------------------------------------------------- +ODBTypeWizDialog::ODBTypeWizDialog(const Reference< XMultiServiceFactory >& _rxORB) + :ODatabaseAdministrationDialog(_rxORB) +{ +} +//------------------------------------------------------------------------- +Sequence<sal_Int8> SAL_CALL ODBTypeWizDialog::getImplementationId( ) throw(RuntimeException) +{ + static ::cppu::OImplementationId aId; + return aId.getImplementationId(); +} + +//------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL ODBTypeWizDialog::Create(const Reference< XMultiServiceFactory >& _rxFactory) +{ + return *(new ODBTypeWizDialog(_rxFactory)); +} + +//------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODBTypeWizDialog::getImplementationName() throw(RuntimeException) +{ + return getImplementationName_Static(); +} + +//------------------------------------------------------------------------- +::rtl::OUString ODBTypeWizDialog::getImplementationName_Static() throw(RuntimeException) +{ + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.ODBTypeWizDialog")); +} + +//------------------------------------------------------------------------- +::comphelper::StringSequence SAL_CALL ODBTypeWizDialog::getSupportedServiceNames() throw(RuntimeException) +{ + return getSupportedServiceNames_Static(); +} + +//------------------------------------------------------------------------- +::comphelper::StringSequence ODBTypeWizDialog::getSupportedServiceNames_Static() throw(RuntimeException) +{ + ::comphelper::StringSequence aSupported(1); + aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DataSourceTypeChangeDialog")); + return aSupported; +} + +//------------------------------------------------------------------------- +Reference<XPropertySetInfo> SAL_CALL ODBTypeWizDialog::getPropertySetInfo() throw(RuntimeException) +{ + Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; +} + +//------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper& ODBTypeWizDialog::getInfoHelper() +{ + return *const_cast<ODBTypeWizDialog*>(this)->getArrayHelper(); +} + +//------------------------------------------------------------------------------ +::cppu::IPropertyArrayHelper* ODBTypeWizDialog::createArrayHelper( ) const +{ + Sequence< Property > aProps; + describeProperties(aProps); + return new ::cppu::OPropertyArrayHelper(aProps); +} +//------------------------------------------------------------------------------ +Dialog* ODBTypeWizDialog::createDialog(Window* _pParent) +{ + ODbTypeWizDialog* pDlg = new ODbTypeWizDialog(_pParent, m_pDatasourceItems, m_aContext.getLegacyServiceFactory(),m_aInitialSelection); + return pDlg; +} + +//......................................................................... +} // namespace dbaui +//......................................................................... + diff --git a/dbaccess/source/ui/uno/DBTypeWizDlg.hxx b/dbaccess/source/ui/uno/DBTypeWizDlg.hxx new file mode 100644 index 000000000000..4fee89192679 --- /dev/null +++ b/dbaccess/source/ui/uno/DBTypeWizDlg.hxx @@ -0,0 +1,80 @@ +/************************************************************************* + * + * 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_DBTYPEWIZDLG_HXX +#define DBAUI_DBTYPEWIZDLG_HXX + +#ifndef _DBAUI_UNOADMIN_ +#include "unoadmin.hxx" +#endif + +//......................................................................... +namespace dbaui +{ +//......................................................................... +//========================================================================= +//= ODBTypeWizDialog +//========================================================================= +class ODBTypeWizDialog + :public ODatabaseAdministrationDialog + ,public ::comphelper::OPropertyArrayUsageHelper< ODBTypeWizDialog > +{ + +protected: + ODBTypeWizDialog(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB); + +public: + // XTypeProvider + virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); + virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo - static methods + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > + SAL_CALL Create(const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >&); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException); + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; +protected: +// OGenericUnoDialog overridables + virtual Dialog* createDialog(Window* _pParent); +}; + +//......................................................................... +} // namespace dbaui +//......................................................................... + +#endif // DBAUI_DBTYPEWIZDLG_HXX + diff --git a/dbaccess/source/ui/uno/DBTypeWizDlgSetup.cxx b/dbaccess/source/ui/uno/DBTypeWizDlgSetup.cxx new file mode 100644 index 000000000000..4d879464bf5a --- /dev/null +++ b/dbaccess/source/ui/uno/DBTypeWizDlgSetup.cxx @@ -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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#ifndef _DBU_REGHELPER_HXX_ +#include "dbu_reghelper.hxx" +#endif +#ifndef _COM_SUN_STAR_DOCUMENT_XEVENTLISTENER_HPP_ +#include <com/sun/star/document/XEventListener.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XSET_HPP_ +#include <com/sun/star/container/XSet.hpp> +#endif +#ifndef DBAUI_DBTYPEWIZDLGSETUP_HXX +#include "DBTypeWizDlgSetup.hxx" +#endif +#ifndef DBAUI_DBWIZSETUP_HXX +#include "dbwizsetup.hxx" +#endif +#ifndef _COM_SUN_STAR_SDB_XOFFICEDATABASEDOCUMENT_HPP_ +#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_ +#include <com/sun/star/sdbc/XDataSource.hpp> +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif + +using namespace dbaui; +namespace css = ::com::sun::star; + +extern "C" void SAL_CALL createRegistryInfo_ODBTypeWizDialogSetup() +{ + static OMultiInstanceAutoRegistration< ODBTypeWizDialogSetup > aAutoRegistration; +} + +//......................................................................... +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::sdb; + using namespace ::com::sun::star::sdbc; + +//========================================================================= +//------------------------------------------------------------------------- +ODBTypeWizDialogSetup::ODBTypeWizDialogSetup(const Reference< XMultiServiceFactory >& _rxORB) + :ODatabaseAdministrationDialog(_rxORB) + ,m_bOpenDatabase(sal_True) + ,m_bStartTableWizard(sal_False) +{ + registerProperty(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OpenDatabase")), 3, PropertyAttribute::TRANSIENT, + &m_bOpenDatabase, getBooleanCppuType()); + + registerProperty(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StartTableWizard")), 4, PropertyAttribute::TRANSIENT, + &m_bStartTableWizard, getBooleanCppuType()); +} +//------------------------------------------------------------------------- +Sequence<sal_Int8> SAL_CALL ODBTypeWizDialogSetup::getImplementationId( ) throw(RuntimeException) +{ + static ::cppu::OImplementationId aId; + return aId.getImplementationId(); +} + +//------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL ODBTypeWizDialogSetup::Create(const Reference< XMultiServiceFactory >& _rxFactory) +{ + Reference < XInterface > xDBWizard = *(new ODBTypeWizDialogSetup(_rxFactory)); + return xDBWizard; +} + +//------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODBTypeWizDialogSetup::getImplementationName() throw(RuntimeException) +{ + return getImplementationName_Static(); +} + +//------------------------------------------------------------------------- +::rtl::OUString ODBTypeWizDialogSetup::getImplementationName_Static() throw(RuntimeException) +{ + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.ODBTypeWizDialogSetup")); +} + +//------------------------------------------------------------------------- +::comphelper::StringSequence SAL_CALL ODBTypeWizDialogSetup::getSupportedServiceNames() throw(RuntimeException) +{ + return getSupportedServiceNames_Static(); +} + +//------------------------------------------------------------------------- +::comphelper::StringSequence ODBTypeWizDialogSetup::getSupportedServiceNames_Static() throw(RuntimeException) +{ + ::comphelper::StringSequence aSupported(1); + aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DatabaseWizardDialog")); + return aSupported; +} + +//------------------------------------------------------------------------- +Reference<XPropertySetInfo> SAL_CALL ODBTypeWizDialogSetup::getPropertySetInfo() throw(RuntimeException) +{ + return createPropertySetInfo( getInfoHelper() ); +} + +//------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper& ODBTypeWizDialogSetup::getInfoHelper() +{ + return *const_cast<ODBTypeWizDialogSetup*>(this)->getArrayHelper(); +} + +//------------------------------------------------------------------------------ +::cppu::IPropertyArrayHelper* ODBTypeWizDialogSetup::createArrayHelper( ) const +{ + Sequence< Property > aProps; + describeProperties(aProps); + return new ::cppu::OPropertyArrayHelper(aProps); +} +//------------------------------------------------------------------------------ +Dialog* ODBTypeWizDialogSetup::createDialog(Window* _pParent) +{ + return new ODbTypeWizDialogSetup(_pParent, m_pDatasourceItems, m_aContext.getLegacyServiceFactory(), m_aInitialSelection); +} +// ----------------------------------------------------------------------------- +void ODBTypeWizDialogSetup::executedDialog(sal_Int16 _nExecutionResult) +{ + if ( _nExecutionResult == RET_OK ) + { + const ODbTypeWizDialogSetup* pDialog = static_cast< ODbTypeWizDialogSetup* >( m_pDialog ); + m_bOpenDatabase = pDialog->IsDatabaseDocumentToBeOpened(); + m_bStartTableWizard = pDialog->IsTableWizardToBeStarted(); + } +} + +//......................................................................... +} // namespace dbaui +//......................................................................... + diff --git a/dbaccess/source/ui/uno/DBTypeWizDlgSetup.hxx b/dbaccess/source/ui/uno/DBTypeWizDlgSetup.hxx new file mode 100644 index 000000000000..1c85d1599c9b --- /dev/null +++ b/dbaccess/source/ui/uno/DBTypeWizDlgSetup.hxx @@ -0,0 +1,84 @@ +/************************************************************************* + * + * 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_DBTYPEWIZDLGSETUP_HXX +#define DBAUI_DBTYPEWIZDLGSETUP_HXX + +#ifndef _DBAUI_UNOADMIN_ +#include "unoadmin.hxx" +#endif + +//......................................................................... +namespace dbaui +{ +//......................................................................... +//========================================================================= +//= ODBTypeWizDialogSetup +//========================================================================= +class ODBTypeWizDialogSetup + :public ODatabaseAdministrationDialog + ,public ::comphelper::OPropertyArrayUsageHelper< ODBTypeWizDialogSetup > +{ + ::rtl::OUString m_sExistingDocToOpen; + sal_Bool m_bOpenDatabase; + sal_Bool m_bStartTableWizard; + +protected: + ODBTypeWizDialogSetup(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB); + +public: + // XTypeProvider + virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); + virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo - static methods + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > + SAL_CALL Create(const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >&); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException); + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; +protected: +// OGenericUnoDialog overridables + virtual Dialog* createDialog(Window* _pParent); + virtual void executedDialog(sal_Int16 _nExecutionResult); +}; + +//......................................................................... +} // namespace dbaui +//......................................................................... + +#endif // DBAUI_DBTYPEWIZDLG_HXX + diff --git a/dbaccess/source/ui/uno/TableFilterDlg.cxx b/dbaccess/source/ui/uno/TableFilterDlg.cxx new file mode 100644 index 000000000000..73771c3e7fd7 --- /dev/null +++ b/dbaccess/source/ui/uno/TableFilterDlg.cxx @@ -0,0 +1,133 @@ +/************************************************************************* + * + * 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 _DBU_REGHELPER_HXX_ +#include "dbu_reghelper.hxx" +#endif +#ifndef _DBAUI_TABLEFILTERDLG_HXX +#include "TableFilterDlg.hxx" +#endif +#ifndef _DBAUI_TABLESSINGLEDLG_HXX_ +#include "TablesSingleDlg.hxx" +#endif + + +using namespace dbaui; + +extern "C" void SAL_CALL createRegistryInfo_OTableFilterDialog() +{ + static OMultiInstanceAutoRegistration< OTableFilterDialog > aAutoRegistration; +} + +//......................................................................... +namespace dbaui +{ +//......................................................................... + + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::beans; + +//========================================================================= +//------------------------------------------------------------------------- +OTableFilterDialog::OTableFilterDialog(const Reference< XMultiServiceFactory >& _rxORB) + :ODatabaseAdministrationDialog(_rxORB) +{ +} +//------------------------------------------------------------------------- +Sequence<sal_Int8> SAL_CALL OTableFilterDialog::getImplementationId( ) throw(RuntimeException) +{ + static ::cppu::OImplementationId aId; + return aId.getImplementationId(); +} + +//------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL OTableFilterDialog::Create(const Reference< XMultiServiceFactory >& _rxFactory) +{ + return *(new OTableFilterDialog(_rxFactory)); +} + +//------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OTableFilterDialog::getImplementationName() throw(RuntimeException) +{ + return getImplementationName_Static(); +} + +//------------------------------------------------------------------------- +::rtl::OUString OTableFilterDialog::getImplementationName_Static() throw(RuntimeException) +{ + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.OTableFilterDialog")); +} + +//------------------------------------------------------------------------- +::comphelper::StringSequence SAL_CALL OTableFilterDialog::getSupportedServiceNames() throw(RuntimeException) +{ + return getSupportedServiceNames_Static(); +} + +//------------------------------------------------------------------------- +::comphelper::StringSequence OTableFilterDialog::getSupportedServiceNames_Static() throw(RuntimeException) +{ + ::comphelper::StringSequence aSupported(1); + aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.TableFilterDialog")); + return aSupported; +} + +//------------------------------------------------------------------------- +Reference<XPropertySetInfo> SAL_CALL OTableFilterDialog::getPropertySetInfo() throw(RuntimeException) +{ + Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; +} + +//------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper& OTableFilterDialog::getInfoHelper() +{ + return *const_cast<OTableFilterDialog*>(this)->getArrayHelper(); +} + +//------------------------------------------------------------------------------ +::cppu::IPropertyArrayHelper* OTableFilterDialog::createArrayHelper( ) const +{ + Sequence< Property > aProps; + describeProperties(aProps); + return new ::cppu::OPropertyArrayHelper(aProps); +} +//------------------------------------------------------------------------------ +Dialog* OTableFilterDialog::createDialog(Window* _pParent) +{ + OTableSubscriptionDialog* pDlg = new OTableSubscriptionDialog(_pParent, m_pDatasourceItems, m_aContext.getLegacyServiceFactory(),m_aInitialSelection); + return pDlg; +} + +//......................................................................... +} // namespace dbaui +//......................................................................... + diff --git a/dbaccess/source/ui/uno/TableFilterDlg.hxx b/dbaccess/source/ui/uno/TableFilterDlg.hxx new file mode 100644 index 000000000000..32aba9e4be82 --- /dev/null +++ b/dbaccess/source/ui/uno/TableFilterDlg.hxx @@ -0,0 +1,80 @@ +/************************************************************************* + * + * 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_TABLEFILTERDLG_HXX +#define _DBAUI_TABLEFILTERDLG_HXX + +#ifndef _DBAUI_UNOADMIN_ +#include "unoadmin.hxx" +#endif + +//......................................................................... +namespace dbaui +{ +//......................................................................... +//========================================================================= +//= OTableFilterDialog +//========================================================================= +class OTableFilterDialog + :public ODatabaseAdministrationDialog + ,public ::comphelper::OPropertyArrayUsageHelper< OTableFilterDialog > +{ + +protected: + OTableFilterDialog(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB); + +public: + // XTypeProvider + virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); + virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo - static methods + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > + SAL_CALL Create(const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >&); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException); + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; +protected: +// OGenericUnoDialog overridables + virtual Dialog* createDialog(Window* _pParent); +}; + +//......................................................................... +} // namespace dbaui +//......................................................................... + +#endif // _DBAUI_TABLEFILTERDLG_HXX + diff --git a/dbaccess/source/ui/uno/UserSettingsDlg.cxx b/dbaccess/source/ui/uno/UserSettingsDlg.cxx new file mode 100644 index 000000000000..fae46a854c32 --- /dev/null +++ b/dbaccess/source/ui/uno/UserSettingsDlg.cxx @@ -0,0 +1,133 @@ +/************************************************************************* + * + * 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 _DBU_REGHELPER_HXX_ +#include "dbu_reghelper.hxx" +#endif +#ifndef _DBAUI_USERSETTINGSDLG_HXX +#include "UserSettingsDlg.hxx" +#endif +#ifndef DBAUI_USERADMINDLG_HXX +#include "UserAdminDlg.hxx" +#endif + + +using namespace dbaui; + +extern "C" void SAL_CALL createRegistryInfo_OUserSettingsDialog() +{ + static OMultiInstanceAutoRegistration< OUserSettingsDialog > aAutoRegistration; +} + +//......................................................................... +namespace dbaui +{ +//......................................................................... + + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::beans; + +//========================================================================= +//------------------------------------------------------------------------- +OUserSettingsDialog::OUserSettingsDialog(const Reference< XMultiServiceFactory >& _rxORB) + :ODatabaseAdministrationDialog(_rxORB) +{ +} +//------------------------------------------------------------------------- +Sequence<sal_Int8> SAL_CALL OUserSettingsDialog::getImplementationId( ) throw(RuntimeException) +{ + static ::cppu::OImplementationId aId; + return aId.getImplementationId(); +} + +//------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL OUserSettingsDialog::Create(const Reference< XMultiServiceFactory >& _rxFactory) +{ + return *(new OUserSettingsDialog(_rxFactory)); +} + +//------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OUserSettingsDialog::getImplementationName() throw(RuntimeException) +{ + return getImplementationName_Static(); +} + +//------------------------------------------------------------------------- +::rtl::OUString OUserSettingsDialog::getImplementationName_Static() throw(RuntimeException) +{ + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.OUserSettingsDialog")); +} + +//------------------------------------------------------------------------- +::comphelper::StringSequence SAL_CALL OUserSettingsDialog::getSupportedServiceNames() throw(RuntimeException) +{ + return getSupportedServiceNames_Static(); +} + +//------------------------------------------------------------------------- +::comphelper::StringSequence OUserSettingsDialog::getSupportedServiceNames_Static() throw(RuntimeException) +{ + ::comphelper::StringSequence aSupported(1); + aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.UserAdministrationDialog")); + return aSupported; +} + +//------------------------------------------------------------------------- +Reference<XPropertySetInfo> SAL_CALL OUserSettingsDialog::getPropertySetInfo() throw(RuntimeException) +{ + Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; +} + +//------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper& OUserSettingsDialog::getInfoHelper() +{ + return *const_cast<OUserSettingsDialog*>(this)->getArrayHelper(); +} + +//------------------------------------------------------------------------------ +::cppu::IPropertyArrayHelper* OUserSettingsDialog::createArrayHelper( ) const +{ + Sequence< Property > aProps; + describeProperties(aProps); + return new ::cppu::OPropertyArrayHelper(aProps); +} +//------------------------------------------------------------------------------ +Dialog* OUserSettingsDialog::createDialog(Window* _pParent) +{ + OUserAdminDlg* pDlg = new OUserAdminDlg(_pParent, m_pDatasourceItems, m_aContext.getLegacyServiceFactory(),m_aInitialSelection,m_xActiveConnection); + return pDlg; +} + +//......................................................................... +} // namespace dbaui +//......................................................................... + diff --git a/dbaccess/source/ui/uno/UserSettingsDlg.hxx b/dbaccess/source/ui/uno/UserSettingsDlg.hxx new file mode 100644 index 000000000000..b2f603d09628 --- /dev/null +++ b/dbaccess/source/ui/uno/UserSettingsDlg.hxx @@ -0,0 +1,80 @@ +/************************************************************************* + * + * 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_USERSETTINGSDLG_HXX +#define _DBAUI_USERSETTINGSDLG_HXX + +#ifndef _DBAUI_UNOADMIN_ +#include "unoadmin.hxx" +#endif + +//......................................................................... +namespace dbaui +{ +//......................................................................... +//========================================================================= +//= OUserSettingsDialog +//========================================================================= +class OUserSettingsDialog + :public ODatabaseAdministrationDialog + ,public ::comphelper::OPropertyArrayUsageHelper< OUserSettingsDialog > +{ + +protected: + OUserSettingsDialog(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB); + +public: + // XTypeProvider + virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); + virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo - static methods + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > + SAL_CALL Create(const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >&); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException); + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; +protected: +// OGenericUnoDialog overridables + virtual Dialog* createDialog(Window* _pParent); +}; + +//......................................................................... +} // namespace dbaui +//......................................................................... + +#endif // _DBAUI_USERSETTINGSDLG_HXX + diff --git a/dbaccess/source/ui/uno/admindlg.cxx b/dbaccess/source/ui/uno/admindlg.cxx new file mode 100644 index 000000000000..0ffa3b4f1b45 --- /dev/null +++ b/dbaccess/source/ui/uno/admindlg.cxx @@ -0,0 +1,139 @@ +/************************************************************************* + * + * 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 _DBU_REGHELPER_HXX_ +#include "dbu_reghelper.hxx" +#endif +#ifndef _DBAUI_ADMINDLG_HXX +#include "admindlg.hxx" +#endif +#ifndef _DBAUI_DBADMIN_HXX_ +#include "dbadmin.hxx" +#endif + + +using namespace dbaui; + +extern "C" void SAL_CALL createRegistryInfo_ODataSourcePropertyDialog() +{ + static OMultiInstanceAutoRegistration< ODataSourcePropertyDialog > aAutoRegistration; +} + +//......................................................................... +namespace dbaui +{ +//......................................................................... + + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::beans; + +//========================================================================= +//------------------------------------------------------------------------- +ODataSourcePropertyDialog::ODataSourcePropertyDialog(const Reference< XMultiServiceFactory >& _rxORB) + :ODatabaseAdministrationDialog(_rxORB) +{ +} +//------------------------------------------------------------------------- +Sequence<sal_Int8> SAL_CALL ODataSourcePropertyDialog::getImplementationId( ) throw(RuntimeException) +{ + static ::cppu::OImplementationId aId; + return aId.getImplementationId(); +} + +//------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL ODataSourcePropertyDialog::Create(const Reference< XMultiServiceFactory >& _rxFactory) +{ + return *(new ODataSourcePropertyDialog(_rxFactory)); +} + +//------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODataSourcePropertyDialog::getImplementationName() throw(RuntimeException) +{ + return getImplementationName_Static(); +} + +//------------------------------------------------------------------------- +::rtl::OUString ODataSourcePropertyDialog::getImplementationName_Static() throw(RuntimeException) +{ + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.ODatasourceAdministrationDialog")); +} + +//------------------------------------------------------------------------- +::comphelper::StringSequence SAL_CALL ODataSourcePropertyDialog::getSupportedServiceNames() throw(RuntimeException) +{ + return getSupportedServiceNames_Static(); +} + +//------------------------------------------------------------------------- +::comphelper::StringSequence ODataSourcePropertyDialog::getSupportedServiceNames_Static() throw(RuntimeException) +{ + ::comphelper::StringSequence aSupported(1); + aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DatasourceAdministrationDialog")); + return aSupported; +} + +//------------------------------------------------------------------------- +Reference<XPropertySetInfo> SAL_CALL ODataSourcePropertyDialog::getPropertySetInfo() throw(RuntimeException) +{ + Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; +} + +//------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper& ODataSourcePropertyDialog::getInfoHelper() +{ + return *const_cast<ODataSourcePropertyDialog*>(this)->getArrayHelper(); +} + +//------------------------------------------------------------------------------ +::cppu::IPropertyArrayHelper* ODataSourcePropertyDialog::createArrayHelper( ) const +{ + Sequence< Property > aProps; + describeProperties(aProps); + return new ::cppu::OPropertyArrayHelper(aProps); +} +//------------------------------------------------------------------------------ +Dialog* ODataSourcePropertyDialog::createDialog(Window* _pParent) +{ + + ODbAdminDialog* pDialog = new ODbAdminDialog(_pParent, m_pDatasourceItems, m_aContext.getLegacyServiceFactory()); + + // the initial selection + if ( m_aInitialSelection.hasValue() ) + pDialog->selectDataSource(m_aInitialSelection); + + return pDialog; +} + +//......................................................................... +} // namespace dbaui +//......................................................................... + diff --git a/dbaccess/source/ui/uno/admindlg.hxx b/dbaccess/source/ui/uno/admindlg.hxx new file mode 100644 index 000000000000..81af43fd92f0 --- /dev/null +++ b/dbaccess/source/ui/uno/admindlg.hxx @@ -0,0 +1,80 @@ +/************************************************************************* + * + * 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_ADMINDLG_HXX +#define _DBAUI_ADMINDLG_HXX + +#ifndef _DBAUI_UNOADMIN_ +#include "unoadmin.hxx" +#endif + +//......................................................................... +namespace dbaui +{ +//......................................................................... +//========================================================================= +//= ODataSourcePropertyDialog +//========================================================================= +class ODataSourcePropertyDialog + :public ODatabaseAdministrationDialog + ,public ::comphelper::OPropertyArrayUsageHelper< ODataSourcePropertyDialog > +{ + +protected: + ODataSourcePropertyDialog(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB); + +public: + // XTypeProvider + virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); + virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo - static methods + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > + SAL_CALL Create(const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >&); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException); + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; +protected: +// OGenericUnoDialog overridables + virtual Dialog* createDialog(Window* _pParent); +}; + +//......................................................................... +} // namespace dbaui +//......................................................................... + +#endif // _DBAUI_ADMINDLG_HXX + diff --git a/dbaccess/source/ui/uno/composerdialogs.cxx b/dbaccess/source/ui/uno/composerdialogs.cxx new file mode 100644 index 000000000000..6b7c74318563 --- /dev/null +++ b/dbaccess/source/ui/uno/composerdialogs.cxx @@ -0,0 +1,227 @@ +/************************************************************************* + * + * 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_SOURCE_UI_UNO_COMPOSERDIALOGS_HXX +#include "composerdialogs.hxx" +#endif + +/** === begin UNO includes === **/ +#ifndef _DBU_REGHELPER_HXX_ +#include "dbu_reghelper.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#endif +/** === end UNO includes === **/ +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef DBAUI_QUERYFILTER_HXX +#include "queryfilter.hxx" +#endif +#ifndef DBAUI_QUERYORDER_HXX +#include "queryorder.hxx" +#endif +#ifndef _CONNECTIVITY_DBTOOLS_HXX_ +#include <connectivity/dbtools.hxx> +#endif +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif +#ifndef TOOLS_DIAGNOSE_EX_H +#include <tools/diagnose_ex.h> +#endif + +extern "C" void SAL_CALL createRegistryInfo_ComposerDialogs() +{ + static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::RowsetOrderDialog > aOrderDialogRegistration; + static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::RowsetFilterDialog > aFilterDialogRegistration; +} + +//......................................................................... +namespace dbaui +{ +//......................................................................... + +#define PROPERTY_ID_QUERYCOMPOSER 100 +#define PROPERTY_ID_ROWSET 101 + + IMPLEMENT_CONSTASCII_USTRING( PROPERTY_QUERYCOMPOSER, "QueryComposer" ); + IMPLEMENT_CONSTASCII_USTRING( PROPERTY_ROWSET, "RowSet" ); + + 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::sdbcx; + using namespace ::com::sun::star::sdbc; + using namespace ::com::sun::star::sdb; + + //===================================================================== + //= ComposerDialog + //===================================================================== + DBG_NAME(ComposerDialog) + //--------------------------------------------------------------------- + ComposerDialog::ComposerDialog(const Reference< XMultiServiceFactory >& _rxORB) + :ComposerDialog_BASE( _rxORB ) + { + DBG_CTOR(ComposerDialog,NULL); + + registerProperty( PROPERTY_QUERYCOMPOSER, PROPERTY_ID_QUERYCOMPOSER, PropertyAttribute::TRANSIENT, + &m_xComposer, ::getCppuType( &m_xComposer ) ); + registerProperty( PROPERTY_ROWSET, PROPERTY_ID_ROWSET, PropertyAttribute::TRANSIENT, + &m_xRowSet, ::getCppuType( &m_xRowSet ) ); + } + + //--------------------------------------------------------------------- + ComposerDialog::~ComposerDialog() + { + + DBG_DTOR(ComposerDialog,NULL); + } + + //--------------------------------------------------------------------- + IMPLEMENT_IMPLEMENTATION_ID( ComposerDialog ) + + //--------------------------------------------------------------------- + IMPLEMENT_PROPERTYCONTAINER_DEFAULTS( ComposerDialog ) + + //--------------------------------------------------------------------- + Dialog* ComposerDialog::createDialog(Window* _pParent) + { + // obtain all the objects needed for the dialog + Reference< XConnection > xConnection; + Reference< XNameAccess > xColumns; + try + { + // the connection the row set is working with + if ( !::dbtools::isEmbeddedInDatabase( m_xRowSet, xConnection ) ) + { + Reference< XPropertySet > xRowsetProps( m_xRowSet, UNO_QUERY ); + if ( xRowsetProps.is() ) + xRowsetProps->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xConnection; + } + + // fallback: if there is a connection and thus a row set, but no composer, create one + if ( xConnection.is() && !m_xComposer.is() ) + m_xComposer = ::dbtools::getCurrentSettingsComposer( Reference< XPropertySet >( m_xRowSet, UNO_QUERY ), m_aContext.getLegacyServiceFactory() ); + + // the columns of the row set + Reference< XColumnsSupplier > xSuppColumns( m_xRowSet, UNO_QUERY ); + if ( xSuppColumns.is() ) + xColumns = xSuppColumns->getColumns(); + + if ( !xColumns.is() || !xColumns->hasElements() ) + { // perhaps the composer can supply us with columns? This is necessary for cases + // where the dialog is invoked for a rowset which is not yet loaded + // #i22878# - 2003-12-16 - fs@openoffice.org + xSuppColumns = xSuppColumns.query( m_xComposer ); + if ( xSuppColumns.is() ) + xColumns = xSuppColumns->getColumns(); + } + + DBG_ASSERT( xColumns.is() && xColumns->hasElements(), "ComposerDialog::createDialog: not much fun without any columns!" ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + if ( !xConnection.is() || !xColumns.is() || !m_xComposer.is() ) + // can't create the dialog if I have improper settings + return NULL; + + return createComposerDialog( _pParent, xConnection, xColumns ); + } + + //===================================================================== + //= RowsetFilterDialog + //===================================================================== + //--------------------------------------------------------------------- + RowsetFilterDialog::RowsetFilterDialog( const Reference< XMultiServiceFactory >& _rxORB ) + :ComposerDialog( _rxORB ) + { + } + + //--------------------------------------------------------------------- + IMPLEMENT_SERVICE_INFO1_STATIC( RowsetFilterDialog, "com.sun.star.uno.comp.sdb.RowsetFilterDialog", "com.sun.star.sdb.FilterDialog" ) + + //--------------------------------------------------------------------- + Dialog* RowsetFilterDialog::createComposerDialog( Window* _pParent, const Reference< XConnection >& _rxConnection, const Reference< XNameAccess >& _rxColumns ) + { + return new DlgFilterCrit( _pParent, m_aContext.getLegacyServiceFactory(), _rxConnection, m_xComposer, _rxColumns ); + } + + //--------------------------------------------------------------------- + void RowsetFilterDialog::executedDialog( sal_Int16 _nExecutionResult ) + { + ComposerDialog::executedDialog( _nExecutionResult ); + + if ( _nExecutionResult && m_pDialog ) + static_cast< DlgFilterCrit* >( m_pDialog )->BuildWherePart(); + } + + //===================================================================== + //= RowsetOrderDialog + //===================================================================== + //--------------------------------------------------------------------- + RowsetOrderDialog::RowsetOrderDialog( const Reference< XMultiServiceFactory >& _rxORB ) + :ComposerDialog( _rxORB ) + { + } + + //--------------------------------------------------------------------- + IMPLEMENT_SERVICE_INFO1_STATIC( RowsetOrderDialog, "com.sun.star.uno.comp.sdb.RowsetOrderDialog", "com.sun.star.sdb.OrderDialog" ) + + //--------------------------------------------------------------------- + Dialog* RowsetOrderDialog::createComposerDialog( Window* _pParent, const Reference< XConnection >& _rxConnection, const Reference< XNameAccess >& _rxColumns ) + { + return new DlgOrderCrit( _pParent, _rxConnection, m_xComposer, _rxColumns ); + } + + //--------------------------------------------------------------------- + void RowsetOrderDialog::executedDialog( sal_Int16 _nExecutionResult ) + { + ComposerDialog::executedDialog( _nExecutionResult ); + + if ( !m_pDialog ) + return; + + if ( _nExecutionResult ) + static_cast< DlgOrderCrit* >( m_pDialog )->BuildOrderPart(); + else if ( m_xComposer.is() ) + m_xComposer->setOrder( static_cast< DlgOrderCrit* >( m_pDialog )->GetOrignalOrder() ); + } + +//......................................................................... +} // namespace dbaui +//......................................................................... + + diff --git a/dbaccess/source/ui/uno/composerdialogs.hxx b/dbaccess/source/ui/uno/composerdialogs.hxx new file mode 100644 index 000000000000..3a38880819b4 --- /dev/null +++ b/dbaccess/source/ui/uno/composerdialogs.hxx @@ -0,0 +1,160 @@ +/************************************************************************* + * + * 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_SOURCE_UI_UNO_COMPOSERDIALOGS_HXX +#define DBACCESS_SOURCE_UI_UNO_COMPOSERDIALOGS_HXX + +/** === begin UNO includes === **/ +#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ +#include <com/sun/star/sdbc/XConnection.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_ +#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROWSET_HPP_ +#include <com/sun/star/sdbc/XRowSet.hpp> +#endif +/** === end UNO includes === **/ + +#ifndef _SVT_GENERICUNODIALOG_HXX_ +#include <svtools/genericunodialog.hxx> +#endif +#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "moduledbu.hxx" +#endif +#ifndef _DBASHARED_APITOOLS_HXX_ +#include "apitools.hxx" +#endif + +//......................................................................... +namespace dbaui +{ +//......................................................................... + + //===================================================================== + //= ComposerDialog + //===================================================================== + class ComposerDialog; + typedef ::svt::OGenericUnoDialog ComposerDialog_BASE; + typedef ::comphelper::OPropertyArrayUsageHelper< ComposerDialog > ComposerDialog_PBASE; + + class ComposerDialog + :public ComposerDialog_BASE + ,public ComposerDialog_PBASE + { + OModuleClient m_aModuleClient; + protected: + // <properties> + ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > + m_xComposer; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > + m_xRowSet; + // </properties> + + protected: + ComposerDialog(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB); + ~ComposerDialog(); + + public: + DECLARE_IMPLEMENTATION_ID( ); + + DECLARE_PROPERTYCONTAINER_DEFAULTS( ); + + protected: + // own overridables + virtual Dialog* createComposerDialog( + Window* _pParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxColumns + ) = 0; + + private: + // OGenericUnoDialog overridables + virtual Dialog* createDialog(Window* _pParent); + }; + + //===================================================================== + //= RowsetFilterDialog + //===================================================================== + class RowsetFilterDialog : public ComposerDialog + { + public: + RowsetFilterDialog( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB + ); + + DECLARE_SERVICE_INFO_STATIC( ); + + protected: + // own overridables + virtual Dialog* createComposerDialog( + Window* _pParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxColumns + ); + + // OGenericUnoDialog overridables + virtual void executedDialog( sal_Int16 _nExecutionResult ); + }; + + //===================================================================== + //= RowsetOrderDialog + //===================================================================== + class RowsetOrderDialog : public ComposerDialog + { + public: + RowsetOrderDialog( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB + ); + + DECLARE_SERVICE_INFO_STATIC( ); + + protected: + // own overridables + virtual Dialog* createComposerDialog( + Window* _pParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxColumns + ); + + // OGenericUnoDialog overridables + virtual void executedDialog( sal_Int16 _nExecutionResult ); + }; + +//......................................................................... +} // namespace dbaui +//......................................................................... + +#endif // DBACCESS_SOURCE_UI_UNO_COMPOSERDIALOGS_HXX + + diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx new file mode 100644 index 000000000000..578b8fa55350 --- /dev/null +++ b/dbaccess/source/ui/uno/copytablewizard.cxx @@ -0,0 +1,1606 @@ +/************************************************************************* + * + * 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_reghelper.hxx" +#include "dbu_resource.hrc" +#include "dbu_uno.hrc" +#include "dbustrings.hrc" +#include "moduledbu.hxx" +#include "sqlmessage.hxx" +#include "WCopyTable.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/sdb/application/XCopyTableWizard.hpp> +#include <com/sun/star/sdb/application/CopyTableContinuation.hpp> +#include <com/sun/star/sdb/application/CopyTableOperation.hpp> +#include <com/sun/star/ucb/AlreadyInitializedException.hpp> +#include <com/sun/star/lang/NotInitializedException.hpp> +#include <com/sun/star/sdbc/XDataSource.hpp> +#include <com/sun/star/sdbc/DataType.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/container/XChild.hpp> +#include <com/sun/star/task/XInteractionHandler.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/sdb/XDocumentDataSource.hpp> +#include <com/sun/star/sdb/XCompletedConnection.hpp> +#include <com/sun/star/sdb/CommandType.hpp> +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#include <com/sun/star/sdb/XQueriesSupplier.hpp> +#include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> +#include <com/sun/star/sdbc/XParameters.hpp> +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/sdbc/XBlob.hpp> +#include <com/sun/star/sdbc/XClob.hpp> +#include <com/sun/star/sdbcx/XRowLocate.hpp> +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> +#include <com/sun/star/sdb/SQLContext.hpp> +#include <com/sun/star/sdbc/XDriverManager.hpp> +/** === end UNO includes === **/ + +#include <comphelper/componentcontext.hxx> +#include <comphelper/interaction.hxx> +#include <comphelper/namedvaluecollection.hxx> +#include <comphelper/proparrhlp.hxx> +#include <comphelper/string.hxx> +#include <connectivity/dbexception.hxx> +#include <connectivity/dbtools.hxx> +#include <cppuhelper/exc_hlp.hxx> +#include <cppuhelper/implbase1.hxx> +#include <rtl/ustrbuf.hxx> +#include <rtl/logfile.hxx> +#include <svtools/genericunodialog.hxx> +#include <tools/diagnose_ex.h> +#include <unotools/sharedunocomponent.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/waitobj.hxx> + +//........................................................................ +namespace dbaui +{ +//........................................................................ + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::beans::XPropertySetInfo; + using ::com::sun::star::lang::XMultiServiceFactory; + using ::com::sun::star::beans::Property; + using ::com::sun::star::sdb::application::XCopyTableWizard; + using ::com::sun::star::sdb::application::XCopyTableListener; + using ::com::sun::star::sdb::application::CopyTableRowEvent; + using ::com::sun::star::beans::Optional; + using ::com::sun::star::lang::IllegalArgumentException; + using ::com::sun::star::ucb::AlreadyInitializedException; + using ::com::sun::star::beans::XPropertySet; + using ::com::sun::star::lang::NotInitializedException; + using ::com::sun::star::lang::XServiceInfo; + using ::com::sun::star::sdbc::XConnection; + using ::com::sun::star::sdbc::XDataSource; + using ::com::sun::star::container::XNameAccess; + using ::com::sun::star::container::XChild; + using ::com::sun::star::task::XInteractionHandler; + using ::com::sun::star::frame::XModel; + using ::com::sun::star::sdb::XDocumentDataSource; + using ::com::sun::star::sdb::XCompletedConnection; + using ::com::sun::star::lang::WrappedTargetException; + using ::com::sun::star::sdbcx::XTablesSupplier; + using ::com::sun::star::sdb::XQueriesSupplier; + using ::com::sun::star::lang::DisposedException; + using ::com::sun::star::sdbc::XPreparedStatement; + using ::com::sun::star::sdb::XSingleSelectQueryComposer; + using ::com::sun::star::sdbc::XDatabaseMetaData; + using ::com::sun::star::sdbcx::XColumnsSupplier; + using ::com::sun::star::sdbc::XParameters; + using ::com::sun::star::sdbc::XResultSet; + using ::com::sun::star::sdbc::XRow; + using ::com::sun::star::sdbc::XBlob; + using ::com::sun::star::sdbc::XClob; + using ::com::sun::star::sdbcx::XRowLocate; + using ::com::sun::star::sdbc::XResultSetMetaDataSupplier; + using ::com::sun::star::sdbc::XResultSetMetaData; + using ::com::sun::star::sdbc::SQLException; + using ::com::sun::star::sdb::SQLContext; + using ::com::sun::star::sdbc::XDriverManager; + using ::com::sun::star::beans::PropertyValue; + /** === end UNO using === **/ + namespace CopyTableOperation = ::com::sun::star::sdb::application::CopyTableOperation; + namespace CopyTableContinuation = ::com::sun::star::sdb::application::CopyTableContinuation; + namespace CommandType = ::com::sun::star::sdb::CommandType; + namespace DataType = ::com::sun::star::sdbc::DataType; + + typedef ::utl::SharedUNOComponent< XConnection > SharedConnection; + typedef Reference< XInteractionHandler > InteractionHandler; + + //========================================================================= + //= CopyTableWizard + //========================================================================= + typedef ::svt::OGenericUnoDialog CopyTableWizard_DialogBase; + typedef ::cppu::ImplInheritanceHelper1 < CopyTableWizard_DialogBase + , XCopyTableWizard + > CopyTableWizard_Base; + class CopyTableWizard + :public CopyTableWizard_Base + ,public ::comphelper::OPropertyArrayUsageHelper< CopyTableWizard > + { + public: + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw(RuntimeException); + virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(RuntimeException); + + // XServiceInfo - static methods + static Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( RuntimeException ); + static ::rtl::OUString getImplementationName_Static(void) throw( RuntimeException ); + static Reference< XInterface > Create( const Reference< XMultiServiceFactory >& ); + + // XCopyTableWizard + virtual ::sal_Int16 SAL_CALL getOperation() throw (RuntimeException); + virtual void SAL_CALL setOperation( ::sal_Int16 _operation ) throw (IllegalArgumentException, RuntimeException); + virtual ::rtl::OUString SAL_CALL getDestinationTableName() throw (RuntimeException); + virtual void SAL_CALL setDestinationTableName( const ::rtl::OUString& _destinationTableName ) throw (RuntimeException); + virtual Optional< ::rtl::OUString > SAL_CALL getCreatePrimaryKey() throw (RuntimeException); + virtual void SAL_CALL setCreatePrimaryKey( const Optional< ::rtl::OUString >& _newPrimaryKey ) throw (IllegalArgumentException, RuntimeException); + virtual sal_Bool SAL_CALL getUseHeaderLineAsColumnNames() throw (RuntimeException); + virtual void SAL_CALL setUseHeaderLineAsColumnNames( sal_Bool _bUseHeaderLineAsColumnNames ) throw (RuntimeException); + virtual void SAL_CALL addCopyTableListener( const Reference< XCopyTableListener >& Listener ) throw (RuntimeException); + virtual void SAL_CALL removeCopyTableListener( const Reference< XCopyTableListener >& Listener ) throw (RuntimeException); + + // XCopyTableWizard::XExecutableDialog + virtual void SAL_CALL setTitle( const ::rtl::OUString& aTitle ) throw (RuntimeException); + virtual ::sal_Int16 SAL_CALL execute( ) throw (RuntimeException); + + // XInitialization + virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException); + + // XPropertySet + virtual Reference< XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(RuntimeException); + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; + + public: + ::osl::Mutex& getMutex() { return m_aMutex; } + bool isInitialized() const { return m_xSourceConnection.is() && m_pSourceObject.get() && m_xDestConnection.is(); } + + protected: + CopyTableWizard( const Reference< XMultiServiceFactory >& _rxORB ); + ~CopyTableWizard(); + + // OGenericUnoDialog overridables + virtual Dialog* createDialog( Window* _pParent ); + virtual void executedDialog( sal_Int16 _nExecutionResult ); + + private: + /// ensures our current attribute values are reflected in the dialog + void impl_attributesToDialog_nothrow( OCopyTableWizard& _rDialog ) const; + + /// ensures the current dialog settings are reflected in our attributes + void impl_dialogToAttributes_nothrow( const OCopyTableWizard& _rDialog ); + + /** returns our typed dialog + + @throws ::com::sun::star::uno::RuntimeException + if we don't have a dialog at the moment the method is called + */ + OCopyTableWizard& + impl_getDialog_throw(); + + /** returns our typed dialog + + @throws ::com::sun::star::uno::RuntimeException + if we don't have a dialog at the moment the method is called + */ + const OCopyTableWizard& + impl_getDialog_throw() const; + + /** ensures the given argument sequence contains a valid data access descriptor at the given position + @param _rAllArgs + the arguments as passed to ->initialize + @param _nArgPos + the position within ->_rAllArgs which contains the data access descriptor + @param _out_rxConnection + will, upon successful return, contain the connection for the data source + @param _out_rxDocInteractionHandler + will, upon successful return, contain the interaction handler which could + be deduced from database document described by the descriptor, if any. + (It is possible that the descriptor does not allow to deduce a database document, + in which case <code>_out_rxDocInteractionHandler</code> will be <NULL/>.) + @return the data access descriptor + */ + Reference< XPropertySet > + impl_ensureDataAccessDescriptor_throw( + const Sequence< Any >& _rAllArgs, + const sal_Int16 _nArgPos, + SharedConnection& _out_rxConnection, + InteractionHandler& _out_rxDocInteractionHandler + ) const; + + /** extracts the source object (table or query) described by the given descriptor, + relative to m_xSourceConnection + */ + ::std::auto_ptr< ICopyTableSourceObject > + impl_extractSourceObject_throw( + const Reference< XPropertySet >& _rxDescriptor, + sal_Int32& _out_rCommandType + ) const; + + /** checks whether the given copy source descriptor contains settings which are not + supported (yet) + + Throws an IllegalArgumentException if the descriptor contains a valid setting, which is + not yet supported. + */ + void impl_checkForUnsupportedSettings_throw( + const Reference< XPropertySet >& _rxSourceDescriptor ) const; + + /** obtaines the connection described by the given data access descriptor + + If needed and possible, the method will ask the user, using the interaction + handler associated with the database described by the descriptor. + + All errors are handled with the InteractionHandler associated with the data source, + if there is one. Else, they will be silenced (but asserted in non-product builds). + + @param _rxDataSourceDescriptor + the data access descriptor describing the data source whose connection + should be obtained. Must not be <NULL/>. + @param _out_rxDocInteractionHandler + the interaction handler which could be deduced from the descriptor + + @throws RuntimeException + if anything goes seriously wrong. + */ + SharedConnection + impl_extractConnection_throw( + const Reference< XPropertySet >& _rxDataSourceDescriptor, + InteractionHandler& _out_rxDocInteractionHandler + ) const; + + /** actually copies the table + + This method is called after the dialog has been successfully executed. + */ + void impl_doCopy_nothrow(); + + /** creates the INSERT INTO statement + @param _xTable The destination table. + */ + ::rtl::OUString impl_getSelectStatement_nothrow(const Reference< XPropertySet >& _xTable); + + /** creates the statement which, when executed, will produce the source data to copy + + If the source object refers to a query which contains parameters, those parameters + are filled in, using an interaction handler. + */ + ::utl::SharedUNOComponent< XPreparedStatement > + impl_createSourceStatement_throw() const; + + /** copies the data rows from the given source result set to the given destination table + */ + void impl_copyRows_throw( + const Reference< XResultSet >& _rxSourceResultSet, + const Reference< XPropertySet >& _rxDestTable + ); + + /** processes an error which occured during copying + + First, all listeners are ask. If a listener tells to cancel or continue copying, this is reported to the + method's caller. If a listener tells to ask the user, this is done, and the user's decision is + reported to the method's caller. + + @return + <TRUE/> if and only if copying should be continued. + */ + bool impl_processCopyError_nothrow( + const CopyTableRowEvent& _rEvent ); + +private: + ::comphelper::ComponentContext m_aContext; + + // attributes + sal_Int16 m_nOperation; + ::rtl::OUString m_sDestinationTable; + Optional< ::rtl::OUString > m_aPrimaryKeyName; + sal_Bool m_bUseHeaderLineAsColumnNames; + + // source + SharedConnection m_xSourceConnection; + sal_Int32 m_nCommandType; + ::std::auto_ptr< ICopyTableSourceObject > + m_pSourceObject; + Sequence< Any > m_aSourceSelection; + bool m_bSourceSelectionBookmarks; + + // destination + SharedConnection m_xDestConnection; + + // other + InteractionHandler m_xInteractionHandler; + ::cppu::OInterfaceContainerHelper + m_aCopyTableListeners; + sal_Int16 m_nOverrideExecutionResult; + }; + +//========================================================================= +//= MethodGuard +//========================================================================= +class CopyTableAccessGuard +{ +public: + CopyTableAccessGuard( CopyTableWizard& _rWizard ) + :m_rWizard( _rWizard ) + { + m_rWizard.getMutex().acquire(); + if ( !m_rWizard.isInitialized() ) + throw NotInitializedException(); + } + + ~CopyTableAccessGuard() + { + m_rWizard.getMutex().release(); + } + +private: + CopyTableWizard& m_rWizard; +}; + +//========================================================================= +//------------------------------------------------------------------------- +CopyTableWizard::CopyTableWizard( const Reference< XMultiServiceFactory >& _rxORB ) + :CopyTableWizard_Base( _rxORB ) + ,m_aContext( _rxORB ) + ,m_nOperation( CopyTableOperation::CopyDefinitionAndData ) + ,m_sDestinationTable() + ,m_aPrimaryKeyName( sal_False, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ID" ) )) + ,m_bUseHeaderLineAsColumnNames( sal_True ) + ,m_xSourceConnection() + ,m_nCommandType( CommandType::COMMAND ) + ,m_pSourceObject() + ,m_aSourceSelection() + ,m_bSourceSelectionBookmarks( true ) + ,m_xDestConnection() + ,m_aCopyTableListeners( m_aMutex ) + ,m_nOverrideExecutionResult( -1 ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::CopyTableWizard" ); +} + +//------------------------------------------------------------------------- +CopyTableWizard::~CopyTableWizard() +{ + acquire(); + + // protect some members whose dtor might potentially throw + try { m_xSourceConnection.clear(); } + catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } + try { m_xDestConnection.clear(); } + catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } + + // TODO: shouldn't we have explicit disposal support? If a listener is registered + // at our instance, and perhaps holds this our instance by a hard ref, then we'll never + // destroyed. + // However, adding XComponent support to the GenericUNODialog probably requires + // some thinking - would it break existing clients which do not call a dispose, then? +} + +//------------------------------------------------------------------------- +Reference< XInterface > CopyTableWizard::Create( const Reference< XMultiServiceFactory >& _rxFactory ) +{ + return *( new CopyTableWizard( _rxFactory ) ); +} + +//------------------------------------------------------------------------- +::rtl::OUString SAL_CALL CopyTableWizard::getImplementationName() throw(RuntimeException) +{ + return getImplementationName_Static(); +} + +//------------------------------------------------------------------------- +::rtl::OUString CopyTableWizard::getImplementationName_Static() throw(RuntimeException) +{ + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.dbu.CopyTableWizard" ) ); +} + +//------------------------------------------------------------------------- +::comphelper::StringSequence SAL_CALL CopyTableWizard::getSupportedServiceNames() throw(RuntimeException) +{ + return getSupportedServiceNames_Static(); +} + +//------------------------------------------------------------------------- +::comphelper::StringSequence CopyTableWizard::getSupportedServiceNames_Static() throw(RuntimeException) +{ + ::comphelper::StringSequence aSupported(1); + aSupported.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.application.CopyTableWizard" ) ); + return aSupported; +} + +//------------------------------------------------------------------------- +Reference< XPropertySetInfo > SAL_CALL CopyTableWizard::getPropertySetInfo() throw(RuntimeException) +{ + Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; +} + +//-------------------------------------------------------------------- +::sal_Int16 SAL_CALL CopyTableWizard::getOperation() throw (RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::getOperation" ); + CopyTableAccessGuard aGuard( *this ); + return m_nOperation; +} + +//-------------------------------------------------------------------- +void SAL_CALL CopyTableWizard::setOperation( ::sal_Int16 _operation ) throw (IllegalArgumentException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::setOperation" ); + CopyTableAccessGuard aGuard( *this ); + + if ( ( _operation != CopyTableOperation::CopyDefinitionAndData ) + && ( _operation != CopyTableOperation::CopyDefinitionOnly ) + && ( _operation != CopyTableOperation::CreateAsView ) + && ( _operation != CopyTableOperation::AppendData ) + ) + throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); + + if ( ( _operation == CopyTableOperation::CreateAsView ) + && !OCopyTableWizard::supportsViews( m_xDestConnection ) + ) + throw IllegalArgumentException( + String( ModuleRes( STR_CTW_NO_VIEWS_SUPPORT ) ), + *this, + 1 + ); + + m_nOperation = _operation; +} + +//-------------------------------------------------------------------- +::rtl::OUString SAL_CALL CopyTableWizard::getDestinationTableName() throw (RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::getDestinationTableName" ); + CopyTableAccessGuard aGuard( *this ); + return m_sDestinationTable; +} + +//-------------------------------------------------------------------- +void SAL_CALL CopyTableWizard::setDestinationTableName( const ::rtl::OUString& _destinationTableName ) throw (RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::setDestinationTableName" ); + CopyTableAccessGuard aGuard( *this ); + m_sDestinationTable = _destinationTableName; +} + +//-------------------------------------------------------------------- +Optional< ::rtl::OUString > SAL_CALL CopyTableWizard::getCreatePrimaryKey() throw (RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::getCreatePrimaryKey" ); + CopyTableAccessGuard aGuard( *this ); + return m_aPrimaryKeyName; +} + +//-------------------------------------------------------------------- +void SAL_CALL CopyTableWizard::setCreatePrimaryKey( const Optional< ::rtl::OUString >& _newPrimaryKey ) throw (IllegalArgumentException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::setCreatePrimaryKey" ); + CopyTableAccessGuard aGuard( *this ); + + if ( _newPrimaryKey.IsPresent && !OCopyTableWizard::supportsPrimaryKey( m_xDestConnection ) ) + throw IllegalArgumentException( + String( ModuleRes( STR_CTW_NO_PRIMARY_KEY_SUPPORT ) ), + *this, + 1 + ); + + m_aPrimaryKeyName = _newPrimaryKey; +} +// ----------------------------------------------------------------------------- +sal_Bool SAL_CALL CopyTableWizard::getUseHeaderLineAsColumnNames() throw (RuntimeException) +{ + CopyTableAccessGuard aGuard( *this ); + return m_bUseHeaderLineAsColumnNames; +} +// ----------------------------------------------------------------------------- +void SAL_CALL CopyTableWizard::setUseHeaderLineAsColumnNames( sal_Bool _bUseHeaderLineAsColumnNames ) throw (RuntimeException) +{ + CopyTableAccessGuard aGuard( *this ); + m_bUseHeaderLineAsColumnNames = _bUseHeaderLineAsColumnNames; +} +//-------------------------------------------------------------------- +void SAL_CALL CopyTableWizard::addCopyTableListener( const Reference< XCopyTableListener >& _rxListener ) throw (RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::addCopyTableListener" ); + CopyTableAccessGuard aGuard( *this ); + if ( _rxListener.is() ) + m_aCopyTableListeners.addInterface( _rxListener ); +} + +//-------------------------------------------------------------------- +void SAL_CALL CopyTableWizard::removeCopyTableListener( const Reference< XCopyTableListener >& _rxListener ) throw (RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::removeCopyTableListener" ); + CopyTableAccessGuard aGuard( *this ); + if ( _rxListener.is() ) + m_aCopyTableListeners.removeInterface( _rxListener ); +} + +//-------------------------------------------------------------------- +void SAL_CALL CopyTableWizard::setTitle( const ::rtl::OUString& _rTitle ) throw (RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::setTitle" ); + CopyTableAccessGuard aGuard( *this ); + CopyTableWizard_DialogBase::setTitle( _rTitle ); +} + +//-------------------------------------------------------------------- +::sal_Int16 SAL_CALL CopyTableWizard::execute( ) throw (RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::execute" ); + CopyTableAccessGuard aGuard( *this ); + + m_nOverrideExecutionResult = -1; + sal_Int16 nExecutionResult = CopyTableWizard_DialogBase::execute(); + if ( m_nOverrideExecutionResult ) + nExecutionResult = m_nOverrideExecutionResult; + + return nExecutionResult; +} + +//------------------------------------------------------------------------- +OCopyTableWizard& CopyTableWizard::impl_getDialog_throw() +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_getDialog_throw" ); + OCopyTableWizard* pWizard = dynamic_cast< OCopyTableWizard* >( m_pDialog ); + if ( !pWizard ) + throw DisposedException( ::rtl::OUString(), *this ); + return *pWizard; +} + +//------------------------------------------------------------------------- +const OCopyTableWizard& CopyTableWizard::impl_getDialog_throw() const +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_getDialog_throw" ); + const OCopyTableWizard* pWizard = dynamic_cast< const OCopyTableWizard* >( m_pDialog ); + if ( !pWizard ) + throw DisposedException( ::rtl::OUString(), *const_cast< CopyTableWizard* >( this ) ); + return *pWizard; +} + +//------------------------------------------------------------------------- +void CopyTableWizard::impl_attributesToDialog_nothrow( OCopyTableWizard& _rDialog ) const +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_attributesToDialog_nothrow" ); + // primary key column + _rDialog.setCreatePrimaryKey( m_aPrimaryKeyName.IsPresent, m_aPrimaryKeyName.Value ); + _rDialog.setUseHeaderLine(m_bUseHeaderLineAsColumnNames); + + // everything else was passed at construction time already +} + +//------------------------------------------------------------------------- +void CopyTableWizard::impl_dialogToAttributes_nothrow( const OCopyTableWizard& _rDialog ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_dialogToAttributes_nothrow" ); + m_aPrimaryKeyName.IsPresent = _rDialog.shouldCreatePrimaryKey(); + if ( m_aPrimaryKeyName.IsPresent ) + m_aPrimaryKeyName.Value = _rDialog.getPrimaryKeyName(); + else + m_aPrimaryKeyName.Value = ::rtl::OUString(); + + m_sDestinationTable = _rDialog.getName(); + + m_nOperation = _rDialog.getOperation(); + m_bUseHeaderLineAsColumnNames = _rDialog.UseHeaderLine(); +} + +//------------------------------------------------------------------------- +namespace +{ + //..................................................................... + /** tries to obtain the InteractionHandler associated with a given data source + + If the data source is a sdb-level data source, it will have a DatabaseDocument associated + with it. This doocument may have an InteractionHandler used while loading it. + + @throws RuntimeException + if it occures during invoking any of the data source's methods, or if any of the involved + components violates its contract by not providing the required interfaces + */ + InteractionHandler lcl_getInteractionHandler_throw( const Reference< XDataSource >& _rxDataSource, const InteractionHandler& _rFallback ) + { + InteractionHandler xHandler( _rFallback ); + + // try to obtain the document model + Reference< XModel > xDocumentModel; + Reference< XDocumentDataSource > xDocDataSource( _rxDataSource, UNO_QUERY ); + if ( xDocDataSource.is() ) + xDocumentModel.set( xDocDataSource->getDatabaseDocument(), UNO_QUERY_THROW ); + + // see whether the document model can provide a handler + if ( xDocumentModel.is() ) + { + ::comphelper::NamedValueCollection aModelArgs( xDocumentModel->getArgs() ); + xHandler = aModelArgs.getOrDefault( "InteractionHandler", xHandler ); + } + + return xHandler; + } + //..................................................................... + /** tries to obtain the InteractionHandler associated with a given connection + + If the connection belongs to a sdb-level data source, then this data source + is examined for an interaction handler. Else, <NULL/> is returned. + + @throws RuntimeException + if it occures during invoking any of the data source's methods, or if any of the involved + components violates its contract by not providing the required interfaces + */ + InteractionHandler lcl_getInteractionHandler_throw( const Reference< XConnection >& _rxConnection, const InteractionHandler& _rFallback ) + { + // try whether there is a data source which the connection belongs to + Reference< XDataSource > xDataSource; + Reference< XChild > xAsChild( _rxConnection, UNO_QUERY ); + if ( xAsChild.is() ) + xDataSource = xDataSource.query( xAsChild->getParent() ); + + if ( xDataSource.is() ) + return lcl_getInteractionHandler_throw( xDataSource, _rFallback ); + + return _rFallback; + } +} + +//------------------------------------------------------------------------- +Reference< XPropertySet > CopyTableWizard::impl_ensureDataAccessDescriptor_throw( + const Sequence< Any >& _rAllArgs, const sal_Int16 _nArgPos, SharedConnection& _out_rxConnection, + InteractionHandler& _out_rxDocInteractionHandler ) const +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_ensureDataAccessDescriptor_throw" ); + Reference< XPropertySet > xDescriptor; + _rAllArgs[ _nArgPos ] >>= xDescriptor; + + // the descriptor must be non-NULL, of course + bool bIsValid = xDescriptor.is(); + + // it must support the proper service + if ( bIsValid ) + { + Reference< XServiceInfo > xSI( xDescriptor, UNO_QUERY ); + bIsValid = ( xSI.is() + && xSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.DataAccessDescriptor" ) ) ) + ); + } + + // it must be able to provide a connection + if ( bIsValid ) + { + _out_rxConnection = impl_extractConnection_throw( xDescriptor, _out_rxDocInteractionHandler ); + bIsValid = _out_rxConnection.is(); + } + + if ( !bIsValid ) + { + throw IllegalArgumentException( + String( ModuleRes( STR_CTW_INVALID_DATA_ACCESS_DESCRIPTOR ) ), + *const_cast< CopyTableWizard* >( this ), + _nArgPos + 1 + ); + } + + return xDescriptor; +} + +//------------------------------------------------------------------------- +namespace +{ + bool lcl_hasNonEmptyStringValue_throw( const Reference< XPropertySet >& _rxDescriptor, + const Reference< XPropertySetInfo > _rxPSI, const ::rtl::OUString& _rPropertyName ) + { + ::rtl::OUString sValue; + if ( _rxPSI->hasPropertyByName( _rPropertyName ) ) + { + OSL_VERIFY( _rxDescriptor->getPropertyValue( _rPropertyName ) >>= sValue ); + } + return sValue.getLength() > 0; + } +} + +//------------------------------------------------------------------------- +void CopyTableWizard::impl_checkForUnsupportedSettings_throw( const Reference< XPropertySet >& _rxSourceDescriptor ) const +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_checkForUnsupportedSettings_throw" ); + OSL_PRECOND( _rxSourceDescriptor.is(), "CopyTableWizard::impl_checkForUnsupportedSettings_throw: illegal argument!" ); + Reference< XPropertySetInfo > xPSI( _rxSourceDescriptor->getPropertySetInfo(), UNO_SET_THROW ); + ::rtl::OUString sUnsupportedSetting; + + // in theory, we could allow to use a mere result set as copy source. However, since this is currently + // not implemented at all, we report this in the initialization phase already + if ( xPSI->hasPropertyByName( PROPERTY_RESULT_SET ) ) + { + Reference< XResultSet > xSource( _rxSourceDescriptor->getPropertyValue( PROPERTY_RESULT_SET ), UNO_QUERY ); + if ( xSource.is() ) + sUnsupportedSetting = PROPERTY_RESULT_SET; + } + + if ( sUnsupportedSetting.getLength() == 0 ) + { + const ::rtl::OUString aSettings[] = { + PROPERTY_FILTER, PROPERTY_ORDER, PROPERTY_HAVING_CLAUSE, PROPERTY_GROUP_BY + }; + for ( size_t i=0; i < sizeof( aSettings ) / sizeof( aSettings[0] ); ++i ) + { + if ( lcl_hasNonEmptyStringValue_throw( _rxSourceDescriptor, xPSI, aSettings[i] ) ) + { + sUnsupportedSetting = aSettings[i]; + break; + } + } + } + + if ( sUnsupportedSetting.getLength() != 0 ) + { + ::rtl::OUString sMessage( String(ModuleRes( STR_CTW_ERROR_UNSUPPORTED_SETTING )) ); + ::comphelper::string::searchAndReplaceAsciiI( sMessage, "$name$", sUnsupportedSetting ); + throw IllegalArgumentException( + sMessage, + *const_cast< CopyTableWizard* >( this ), + 1 + ); + } + +} + +//------------------------------------------------------------------------- +::std::auto_ptr< ICopyTableSourceObject > CopyTableWizard::impl_extractSourceObject_throw( const Reference< XPropertySet >& _rxDescriptor, sal_Int32& _out_rCommandType ) const +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_extractSourceObject_throw" ); + OSL_PRECOND( _rxDescriptor.is() && m_xSourceConnection.is(), "CopyTableWizard::impl_extractSourceObject_throw: illegal arguments!" ); + + impl_checkForUnsupportedSettings_throw( _rxDescriptor ); + + Reference< XPropertySetInfo > xPSI( _rxDescriptor->getPropertySetInfo(), UNO_SET_THROW ); + if ( !xPSI->hasPropertyByName( PROPERTY_COMMAND ) + || !xPSI->hasPropertyByName( PROPERTY_COMMAND_TYPE ) + ) + throw IllegalArgumentException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Expecting a table or query specification." ) ), + *const_cast< CopyTableWizard* >( this ), + 1 + ); + + ::rtl::OUString sCommand; + _out_rCommandType = CommandType::COMMAND; + OSL_VERIFY( _rxDescriptor->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand ); + OSL_VERIFY( _rxDescriptor->getPropertyValue( PROPERTY_COMMAND_TYPE ) >>= _out_rCommandType ); + + ::std::auto_ptr< ICopyTableSourceObject > pSourceObject; + Reference< XNameAccess > xContainer; + switch ( _out_rCommandType ) + { + case CommandType::TABLE: + { + Reference< XTablesSupplier > xSuppTables( m_xSourceConnection.getTyped(), UNO_QUERY ); + if ( xSuppTables.is() ) + xContainer.set( xSuppTables->getTables(), UNO_SET_THROW ); + } + break; + case CommandType::QUERY: + { + Reference< XQueriesSupplier > xSuppQueries( m_xSourceConnection.getTyped(), UNO_QUERY ); + if ( xSuppQueries.is() ) + xContainer.set( xSuppQueries->getQueries(), UNO_SET_THROW ); + } + break; + default: + throw IllegalArgumentException( + String( ModuleRes( STR_CTW_ONLY_TABLES_AND_QUERIES_SUPPORT ) ), + *const_cast< CopyTableWizard* >( this ), + 1 + ); + } + + if ( xContainer.is() ) + { + pSourceObject.reset( new ObjectCopySource( m_xSourceConnection, + Reference< XPropertySet >( xContainer->getByName( sCommand ), UNO_QUERY_THROW ) ) ); + } + else + { + // our source connection is an SDBC level connection only, not a SDBCX level one + // Which means it cannot provide the to-be-copied object as component. + + if ( _out_rCommandType == CommandType::QUERY ) + // we cannot copy a query if the connection cannot provide it ... + throw IllegalArgumentException( + String(ModuleRes( STR_CTW_ERROR_NO_QUERY )), + *const_cast< CopyTableWizard* >( this ), + 1 + ); + pSourceObject.reset( new NamedTableCopySource( m_xSourceConnection, sCommand ) ); + } + + return pSourceObject; +} + +//------------------------------------------------------------------------- +SharedConnection CopyTableWizard::impl_extractConnection_throw( const Reference< XPropertySet >& _rxDataSourceDescriptor, + InteractionHandler& _out_rxDocInteractionHandler ) const +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_extractConnection_throw" ); + SharedConnection xConnection; + + OSL_PRECOND( _rxDataSourceDescriptor.is(), "CopyTableWizard::impl_extractConnection_throw: no descriptor!" ); + if ( !_rxDataSourceDescriptor.is() ) + return xConnection; + + InteractionHandler xInteractionHandler; + + do + { + Reference< XPropertySetInfo > xPSI( _rxDataSourceDescriptor->getPropertySetInfo(), UNO_SET_THROW ); + + // if there's an ActiveConnection, use it + if ( xPSI->hasPropertyByName( PROPERTY_ACTIVE_CONNECTION ) ) + { + Reference< XConnection > xPure; + OSL_VERIFY( _rxDataSourceDescriptor->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xPure ); + xConnection.reset( xPure, SharedConnection::NoTakeOwnership ); + } + if ( xConnection.is() ) + { + xInteractionHandler = lcl_getInteractionHandler_throw( xConnection.getTyped(), m_xInteractionHandler ); + OSL_POSTCOND( xInteractionHandler.is(), "CopyTableWizard::impl_extractConnection_throw: lcl_getInteractionHandler_throw returned nonsense!" ); + break; + } + + // there could be a DataSourceName or a DatabaseLocation, describing the css.sdb.DataSource + ::rtl::OUString sDataSource, sDatabaseLocation; + if ( xPSI->hasPropertyByName( PROPERTY_DATASOURCENAME ) ) + OSL_VERIFY( _rxDataSourceDescriptor->getPropertyValue( PROPERTY_DATASOURCENAME ) >>= sDataSource ); + if ( xPSI->hasPropertyByName( PROPERTY_DATABASE_LOCATION ) ) + OSL_VERIFY( _rxDataSourceDescriptor->getPropertyValue( PROPERTY_DATABASE_LOCATION ) >>= sDatabaseLocation ); + + // need a DatabaseContext for loading the data source + Reference< XNameAccess > xDatabaseContext( m_aContext.createComponent( "com.sun.star.sdb.DatabaseContext" ), UNO_QUERY_THROW ); + Reference< XDataSource > xDataSource; + if ( sDataSource.getLength() ) + xDataSource.set( xDatabaseContext->getByName( sDataSource ), UNO_QUERY_THROW ); + if ( !xDataSource.is() && sDatabaseLocation.getLength() ) + xDataSource.set( xDatabaseContext->getByName( sDatabaseLocation ), UNO_QUERY_THROW ); + + if ( xDataSource.is() ) + { + // first, try connecting with completion + xInteractionHandler = lcl_getInteractionHandler_throw( xDataSource, m_xInteractionHandler ); + OSL_POSTCOND( xInteractionHandler.is(), "CopyTableWizard::impl_extractConnection_throw: lcl_getInteractionHandler_throw returned nonsense!" ); + if ( xInteractionHandler.is() ) + { + Reference< XCompletedConnection > xInteractiveConnection( xDataSource, UNO_QUERY ); + if ( xInteractiveConnection.is() ) + xConnection.reset( xInteractiveConnection->connectWithCompletion( xInteractionHandler ), SharedConnection::TakeOwnership ); + } + + // interactively connecting was not successful or possible -> connect without interaction + if ( !xConnection.is() ) + { + xConnection.reset( xDataSource->getConnection( ::rtl::OUString(), ::rtl::OUString() ), SharedConnection::TakeOwnership ); + } + } + + if ( xConnection.is() ) + break; + + // finally, there could be a ConnectionResource/ConnectionInfo + ::rtl::OUString sConnectionResource; + Sequence< PropertyValue > aConnectionInfo; + if ( xPSI->hasPropertyByName( PROPERTY_CONNECTION_RESOURCE ) ) + OSL_VERIFY( _rxDataSourceDescriptor->getPropertyValue( PROPERTY_CONNECTION_RESOURCE ) >>= sConnectionResource ); + if ( xPSI->hasPropertyByName( PROPERTY_CONNECTION_INFO ) ) + OSL_VERIFY( _rxDataSourceDescriptor->getPropertyValue( PROPERTY_CONNECTION_INFO ) >>= aConnectionInfo ); + + Reference< XDriverManager > xDriverManager; + xDriverManager.set( m_aContext.createComponent( "com.sun.star.sdbc.ConnectionPool" ), UNO_QUERY ); + if ( !xDriverManager.is() ) + // no connection pool installed + xDriverManager.set( m_aContext.createComponent( "com.sun.star.sdbc.DriverManager" ), UNO_QUERY_THROW ); + + if ( aConnectionInfo.getLength() ) + xConnection.set( xDriverManager->getConnectionWithInfo( sConnectionResource, aConnectionInfo ), UNO_SET_THROW ); + else + xConnection.set( xDriverManager->getConnection( sConnectionResource ), UNO_SET_THROW ); + } + while ( false ); + + if ( xInteractionHandler != m_xInteractionHandler ) + _out_rxDocInteractionHandler = xInteractionHandler; + + return xConnection; +} + +//------------------------------------------------------------------------- +::utl::SharedUNOComponent< XPreparedStatement > CopyTableWizard::impl_createSourceStatement_throw() const +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_createSourceStatement_throw" ); + OSL_PRECOND( m_xSourceConnection.is(), "CopyTableWizard::impl_createSourceStatement_throw: illegal call!" ); + if ( !m_xSourceConnection.is() ) + throw RuntimeException( ::rtl::OUString(), *const_cast< CopyTableWizard* >( this ) ); + + ::utl::SharedUNOComponent< XPreparedStatement > xStatement; + switch ( m_nCommandType ) + { + case CommandType::TABLE: + xStatement.set( m_pSourceObject->getPreparedSelectStatement(), UNO_SET_THROW ); + break; + + case CommandType::QUERY: + { + ::rtl::OUString sQueryCommand( m_pSourceObject->getSelectStatement() ); + xStatement.set( m_pSourceObject->getPreparedSelectStatement(), UNO_SET_THROW ); + + // check whether we have to fill in parameter values + // create and fill a composer + + Reference< XMultiServiceFactory > xFactory( m_xSourceConnection, UNO_QUERY ); + ::utl::SharedUNOComponent< XSingleSelectQueryComposer > xComposer; + if ( xFactory.is() ) + // note: connections below the sdb-level are allowed to not support the XMultiServiceFactory interface + xComposer.set( xFactory->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY ); + + if ( xComposer.is() ) + { + xComposer->setQuery( sQueryCommand ); + + Reference< XParameters > xStatementParams( xStatement, UNO_QUERY ); + OSL_ENSURE( xStatementParams.is(), "CopyTableWizard::impl_createSourceStatement_throw: no access to the statement's parameters!" ); + // the statement should be a css.sdbc.PreparedStatement (this is what + // we created), and a prepared statement is required to support XParameters + if ( xStatementParams.is() ) + { + OSL_ENSURE( m_xInteractionHandler.is(), + "CopyTableWizard::impl_createSourceStatement_throw: no interaction handler for the parameters request!" ); + // we should always have an interaction handler - as last fallback, we create an own one in ::initialize + + if ( m_xInteractionHandler.is() ) + ::dbtools::askForParameters( xComposer, xStatementParams, m_xSourceConnection, m_xInteractionHandler ); + } + } + } + break; + + default: + // this should not have survived initialization phase + throw RuntimeException( ::rtl::OUString(), *const_cast< CopyTableWizard* >( this ) ); + } + + return xStatement; +} + +//------------------------------------------------------------------------- +namespace +{ + class ValueTransfer + { + public: + ValueTransfer( const sal_Int32& _rSourcePos, const sal_Int32& _rDestPos, const ::std::vector< sal_Int32 >& _rColTypes, + const Reference< XRow >& _rxSource, const Reference< XParameters >& _rxDest ) + :m_rSourcePos( _rSourcePos ) + ,m_rDestPos( _rDestPos ) + ,m_rColTypes( _rColTypes ) + ,m_xSource( _rxSource ) + ,m_xDest( _rxDest ) + { + } + + template< typename VALUE_TYPE > + void transferValue( VALUE_TYPE ( SAL_CALL XRow::*_pGetter )( sal_Int32 ), + void (SAL_CALL XParameters::*_pSetter)( sal_Int32, VALUE_TYPE ) ) + { + VALUE_TYPE value( (m_xSource.get()->*_pGetter)( m_rSourcePos ) ); + if ( m_xSource->wasNull() ) + m_xDest->setNull( m_rDestPos, m_rColTypes[ m_rSourcePos ] ); + else + (m_xDest.get()->*_pSetter)( m_rDestPos, value ); + } + template< typename VALUE_TYPE > + void transferComplexValue( VALUE_TYPE ( SAL_CALL XRow::*_pGetter )( sal_Int32 ), + void (SAL_CALL XParameters::*_pSetter)( sal_Int32, const VALUE_TYPE& ) ) + { + const VALUE_TYPE value( (m_xSource.get()->*_pGetter)( m_rSourcePos ) ); + { + if ( m_xSource->wasNull() ) + m_xDest->setNull( m_rDestPos, m_rColTypes[ m_rSourcePos ] ); + else + (m_xDest.get()->*_pSetter)( m_rDestPos, value ); + } + } + private: + const sal_Int32& m_rSourcePos; + const sal_Int32& m_rDestPos; + const ::std::vector< sal_Int32 > m_rColTypes; + const Reference< XRow > m_xSource; + const Reference< XParameters > m_xDest; + }; +} + +//------------------------------------------------------------------------- +bool CopyTableWizard::impl_processCopyError_nothrow( const CopyTableRowEvent& _rEvent ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_processCopyError_nothrow" ); + Reference< XCopyTableListener > xListener; + try + { + ::cppu::OInterfaceIteratorHelper aIter( m_aCopyTableListeners ); + while ( aIter.hasMoreElements() ) + { + xListener.set( aIter.next(), UNO_QUERY_THROW ); + sal_Int16 nListenerChoice = xListener->copyRowError( _rEvent ); + switch ( nListenerChoice ) + { + case CopyTableContinuation::Proceed: return true; // continue copying + case CopyTableContinuation::CallNextHandler: continue; // continue the loop, ask next listener + case CopyTableContinuation::Cancel: return false; // cancel copying + case CopyTableContinuation::AskUser: break; // stop asking the listeners, ask the user + + default: + OSL_ENSURE( false, "CopyTableWizard::impl_processCopyError_nothrow: invalid listener response!" ); + // ask next listener + continue; + } + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + // no listener felt responsible for the error, or a listener told to ask the user + + try + { + SQLContext aError; + aError.Context = *this; + aError.Message = String( ModuleRes( STR_ERROR_OCCURED_WHILE_COPYING ) ); + + ::dbtools::SQLExceptionInfo aInfo( _rEvent.Error ); + if ( aInfo.isValid() ) + aError.NextException = _rEvent.Error; + else + { + // a non-SQL exception happend + Exception aException; + OSL_VERIFY( _rEvent.Error >>= aException ); + SQLContext aContext; + aContext.Context = aException.Context; + aContext.Message = aException.Message; + aContext.Details = _rEvent.Error.getValueTypeName(); + aError.NextException <<= aContext; + } + + ::rtl::Reference< ::comphelper::OInteractionRequest > xRequest( new ::comphelper::OInteractionRequest( makeAny( aError ) ) ); + + ::rtl::Reference< ::comphelper::OInteractionApprove > xYes = new ::comphelper::OInteractionApprove; + xRequest->addContinuation( xYes.get() ); + xRequest->addContinuation( new ::comphelper::OInteractionDisapprove ); + + OSL_ENSURE( m_xInteractionHandler.is(), + "CopyTableWizard::impl_processCopyError_nothrow: we always should have an interaction handler!" ); + if ( m_xInteractionHandler.is() ) + m_xInteractionHandler->handle( xRequest.get() ); + + if ( xYes->wasSelected() ) + // continue copying + return true; + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + // cancel copying + return false; +} + +//------------------------------------------------------------------------- +void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSourceResultSet, + const Reference< XPropertySet >& _rxDestTable ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_copyRows_throw" ); + OSL_PRECOND( m_xDestConnection.is(), "CopyTableWizard::impl_copyRows_throw: illegal call!" ); + if ( !m_xDestConnection.is() ) + throw RuntimeException( ::rtl::OUString(), *this ); + + Reference< XDatabaseMetaData > xDestMetaData( m_xDestConnection->getMetaData(), UNO_QUERY_THROW ); + + const OCopyTableWizard& rWizard = impl_getDialog_throw(); + ODatabaseExport::TPositions aColumnMapping = rWizard.GetColumnPositions(); + bool bAutoIncrement = rWizard.shouldCreatePrimaryKey(); + + Reference< XRow > xRow ( _rxSourceResultSet, UNO_QUERY_THROW ); + Reference< XRowLocate > xRowLocate ( _rxSourceResultSet, UNO_QUERY ); + + bool bSelectedRecordsOnly = m_aSourceSelection.getLength() > 0; + if ( bSelectedRecordsOnly && m_bSourceSelectionBookmarks && !xRowLocate.is() ) + { + ::dbtools::throwGenericSQLException( + String( ModuleRes( STR_CTW_COPY_SOURCE_NEEDS_BOOKMARKS ) ), + *this + ); + } + + Reference< XResultSetMetaDataSupplier > xSuppResMeta( _rxSourceResultSet, UNO_QUERY_THROW ); + Reference< XResultSetMetaData> xMeta( xSuppResMeta->getMetaData() ); + + // we need a vector which all types + sal_Int32 nCount = xMeta->getColumnCount(); + ::std::vector< sal_Int32 > aSourceColTypes; + aSourceColTypes.reserve( nCount + 1 ); + aSourceColTypes.push_back( -1 ); // just to avoid a everytime i-1 call + + for ( sal_Int32 k=1; k <= nCount; ++k ) + aSourceColTypes.push_back( xMeta->getColumnType( k ) ); + + // now create, fill and execute the prepared statement + Reference< XPreparedStatement > xStatement( ODatabaseExport::createPreparedStatment( xDestMetaData, _rxDestTable, aColumnMapping ), UNO_SET_THROW ); + Reference< XParameters > xStatementParams( xStatement, UNO_QUERY_THROW ); + + sal_Int32 nRowCount = 0; + const Any* pSelectedRow = m_aSourceSelection.getConstArray(); + const Any* pSelEnd = pSelectedRow + m_aSourceSelection.getLength(); + bool bContinue = false; + + CopyTableRowEvent aCopyEvent; + aCopyEvent.Source = *this; + aCopyEvent.SourceData = _rxSourceResultSet; + + do // loop as long as there are more rows or the selection ends + { + bContinue = false; + if ( bSelectedRecordsOnly ) + { + if ( pSelectedRow != pSelEnd ) + { + if ( m_bSourceSelectionBookmarks ) + { + xRowLocate->moveToBookmark( *pSelectedRow ); + } + else + { + sal_Int32 nPos = 0; + OSL_VERIFY( *pSelectedRow >>= nPos ); + bContinue = _rxSourceResultSet->absolute( nPos ); + } + ++pSelectedRow; + } + } + else + bContinue = _rxSourceResultSet->next(); + + if ( !bContinue ) + { + break; + } + + ++nRowCount; + sal_Bool bInsertAutoIncrement = sal_True; + ODatabaseExport::TPositions::const_iterator aPosIter = aColumnMapping.begin(); + ODatabaseExport::TPositions::const_iterator aPosEnd = aColumnMapping.end(); + + aCopyEvent.Error.clear(); + try + { + // notify listeners + m_aCopyTableListeners.notifyEach( &XCopyTableListener::copyingRow, aCopyEvent ); + + sal_Int32 nDestColumn( 0 ); + sal_Int32 nSourceColumn( 1 ); + ValueTransfer aTransfer( nSourceColumn, nDestColumn, aSourceColTypes, xRow, xStatementParams ); + + for ( ; aPosIter != aPosEnd; ++aPosIter ) + { + nDestColumn = aPosIter->first; + if ( nDestColumn == COLUMN_POSITION_NOT_FOUND ) + { + ++nSourceColumn; + // otherwise we don't get the correct value when only the 2nd source column was selected + continue; + } + + if ( bAutoIncrement && bInsertAutoIncrement ) + { + xStatementParams->setInt( 1, nRowCount ); + bInsertAutoIncrement = sal_False; + continue; + } + + if ( ( nSourceColumn < 1 ) || ( nSourceColumn >= (sal_Int32)aSourceColTypes.size() ) ) + { // ( we have to check here against 1 because the parameters are 1 based) + ::dbtools::throwSQLException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Internal error: invalid column type index." ) ), + ::dbtools::SQL_INVALID_DESCRIPTOR_INDEX, + *this + ); + } + + switch ( aSourceColTypes[ nSourceColumn ] ) + { + case DataType::DOUBLE: + case DataType::REAL: + aTransfer.transferValue( &XRow::getDouble, &XParameters::setDouble ); + break; + + case DataType::CHAR: + case DataType::VARCHAR: + case DataType::LONGVARCHAR: + case DataType::DECIMAL: + case DataType::NUMERIC: + aTransfer.transferComplexValue( &XRow::getString, &XParameters::setString ); + break; + + case DataType::BIGINT: + aTransfer.transferValue( &XRow::getLong, &XParameters::setLong ); + break; + + case DataType::FLOAT: + aTransfer.transferValue( &XRow::getFloat, &XParameters::setFloat ); + break; + + case DataType::LONGVARBINARY: + case DataType::BINARY: + case DataType::VARBINARY: + case DataType::BIT: + aTransfer.transferComplexValue( &XRow::getBytes, &XParameters::setBytes ); + break; + + case DataType::DATE: + aTransfer.transferComplexValue( &XRow::getDate, &XParameters::setDate ); + break; + + case DataType::TIME: + aTransfer.transferComplexValue( &XRow::getTime, &XParameters::setTime ); + break; + + case DataType::TIMESTAMP: + aTransfer.transferComplexValue( &XRow::getTimestamp, &XParameters::setTimestamp ); + break; + + case DataType::BOOLEAN: + aTransfer.transferValue( &XRow::getBoolean, &XParameters::setBoolean ); + break; + + case DataType::TINYINT: + aTransfer.transferValue( &XRow::getByte, &XParameters::setByte ); + break; + + case DataType::SMALLINT: + aTransfer.transferValue( &XRow::getShort, &XParameters::setShort ); + break; + + case DataType::INTEGER: + aTransfer.transferValue( &XRow::getInt, &XParameters::setInt ); + break; + + case DataType::BLOB: + aTransfer.transferComplexValue( &XRow::getBlob, &XParameters::setBlob ); + break; + + case DataType::CLOB: + aTransfer.transferComplexValue( &XRow::getClob, &XParameters::setClob ); + break; + + default: + { + ::rtl::OUString aMessage( String( ModuleRes( STR_CTW_UNSUPPORTED_COLUMN_TYPE ) ) ); + + aMessage.replaceAt( aMessage.indexOfAsciiL( "$type$", 6 ), 6, ::rtl::OUString::valueOf( aSourceColTypes[ nSourceColumn ] ) ); + aMessage.replaceAt( aMessage.indexOfAsciiL( "$pos$", 5 ), 5, ::rtl::OUString::valueOf( nSourceColumn ) ); + + ::dbtools::throwSQLException( + aMessage, + ::dbtools::SQL_INVALID_SQL_DATA_TYPE, + *this + ); + } + } + ++nSourceColumn; + } + xStatement->executeUpdate(); + + // notify listeners + m_aCopyTableListeners.notifyEach( &XCopyTableListener::copiedRow, aCopyEvent ); + } + catch( const Exception& ) + { + aCopyEvent.Error = ::cppu::getCaughtException(); + } + + if ( aCopyEvent.Error.hasValue() ) + bContinue = impl_processCopyError_nothrow( aCopyEvent ); + } + while( bContinue ); +} +//------------------------------------------------------------------------- +void CopyTableWizard::impl_doCopy_nothrow() +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_doCopy_nothrow" ); + Any aError; + + try + { + OCopyTableWizard& rWizard( impl_getDialog_throw() ); + + WaitObject aWO( rWizard.GetParent() ); + Reference< XPropertySet > xTable; + + switch ( rWizard.getOperation() ) + { + case CopyTableOperation::CopyDefinitionOnly: + case CopyTableOperation::CopyDefinitionAndData: + { + xTable = rWizard.createTable(); + + if( !xTable.is() ) + { + OSL_ENSURE( false, "CopyTableWizard::impl_doCopy_nothrow: createTable should throw here, shouldn't it?" ); + break; + } + + if( CopyTableOperation::CopyDefinitionOnly == rWizard.getOperation() ) + break; + } + // run through + + case CopyTableOperation::AppendData: + { + + if ( !xTable.is() ) + { + xTable = rWizard.createTable(); + if ( !xTable.is() ) + { + OSL_ENSURE( false, "CopyTableWizard::impl_doCopy_nothrow: createTable should throw here, shouldn't it?" ); + break; + } + } + + bool bServerCopy = CommandType::TABLE == m_nCommandType && m_xSourceConnection.getTyped() == m_xDestConnection.getTyped() && !m_aSourceSelection.getLength(); + try + { + if ( bServerCopy ) + { + m_xDestConnection->createStatement()->executeUpdate( impl_getSelectStatement_nothrow(xTable) ); + } + } + catch( const Exception& e ) + { + (void)e; + bServerCopy = false; + } + + if ( !bServerCopy ) + { + ::utl::SharedUNOComponent< XPreparedStatement > xStatement( impl_createSourceStatement_throw(), UNO_SET_THROW ); + Reference< XResultSet > xSourceResultSet( xStatement->executeQuery() ); + impl_copyRows_throw( xSourceResultSet, xTable ); + } + } + break; + + case CopyTableOperation::CreateAsView: + rWizard.createView(); + break; + + default: + OSL_ENSURE( false, "CopyTableWizard::impl_doCopy_nothrow: What operation, please?" ); + break; + } + } + catch( const Exception& ) + { + aError = ::cppu::getCaughtException(); + + // silence the error of the user cancelling the parameter's dialog + SQLException aSQLError; + if ( ( aError >>= aSQLError ) && ( aSQLError.ErrorCode == ::dbtools::ParameterInteractionCancelled ) ) + { + aError.clear(); + m_nOverrideExecutionResult = RET_CANCEL; + } + } + + if ( aError.hasValue() && m_xInteractionHandler.is() ) + { + try + { + ::rtl::Reference< ::comphelper::OInteractionRequest > xRequest( new ::comphelper::OInteractionRequest( aError ) ); + m_xInteractionHandler->handle( xRequest.get() ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } +} +// ----------------------------------------------------------------------------- +::rtl::OUString CopyTableWizard::impl_getSelectStatement_nothrow(const Reference< XPropertySet >& _xTable) +{ + const Reference<XColumnsSupplier> xDestColsSup(_xTable,UNO_QUERY_THROW); + const Sequence< ::rtl::OUString> aDestColumnNames = xDestColsSup->getColumns()->getElementNames(); + const Sequence< ::rtl::OUString > aColumnNames = m_pSourceObject->getColumnNames(); + const Reference< XDatabaseMetaData > xDestMetaData( m_xDestConnection->getMetaData(), UNO_QUERY_THROW ); + const ::rtl::OUString sQuote = xDestMetaData->getIdentifierQuoteString(); + ::rtl::OUStringBuffer sColumns; + // 1st check if the columns matching + const OCopyTableWizard& rWizard = impl_getDialog_throw(); + ODatabaseExport::TPositions aColumnMapping = rWizard.GetColumnPositions(); + ODatabaseExport::TPositions::const_iterator aPosIter = aColumnMapping.begin(); + for ( sal_Int32 i = 0; aPosIter != aColumnMapping.end() ; ++aPosIter,++i ) + { + if ( COLUMN_POSITION_NOT_FOUND != aPosIter->second ) + { + if ( sColumns.getLength() ) + sColumns.appendAscii(","); + sColumns.append(sQuote); + sColumns.append(aDestColumnNames[aPosIter->second - 1]); + sColumns.append(sQuote); + } + } // for ( ; aPosIter != aColumnMapping.end() ; ++aPosIter ) + ::rtl::OUStringBuffer sSql; + sSql.appendAscii("INSERT INTO "); + const ::rtl::OUString sComposedTableName = ::dbtools::composeTableName( xDestMetaData, _xTable, ::dbtools::eInDataManipulation, false, false, true ); + sSql.append( sComposedTableName ); + sSql.appendAscii(" ( "); + sSql.append( sColumns ); + sSql.appendAscii(" ) ( "); + sSql.append( m_pSourceObject->getSelectStatement()); + sSql.appendAscii(" )"); + + return sSql.makeStringAndClear(); +} +//------------------------------------------------------------------------- +void SAL_CALL CopyTableWizard::initialize( const Sequence< Any >& _rArguments ) throw (Exception, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::initialize" ); + ::osl::MutexGuard aGuard( m_aMutex ); + if ( isInitialized() ) + throw AlreadyInitializedException( ::rtl::OUString(), *this ); + + sal_Int32 nArgCount( _rArguments.getLength() ); + if ( ( nArgCount != 2 ) && ( nArgCount != 3 ) ) + throw IllegalArgumentException( + String( ModuleRes( STR_CTW_ILLEGAL_PARAMETER_COUNT ) ), + *this, + 1 + ); + + try + { + if ( nArgCount == 3 ) + { // ->createWithInteractionHandler + if ( !( _rArguments[2] >>= m_xInteractionHandler ) ) + throw IllegalArgumentException( + String(ModuleRes( STR_CTW_ERROR_INVALID_INTERACTIONHANDLER )), + *this, + 3 + ); + } + if ( !m_xInteractionHandler.is() ) + m_xInteractionHandler.set( m_aContext.createComponent( "com.sun.star.task.InteractionHandler" ), UNO_QUERY_THROW ); + + InteractionHandler xSourceDocHandler; + Reference< XPropertySet > xSourceDescriptor( impl_ensureDataAccessDescriptor_throw( _rArguments, 0, m_xSourceConnection, xSourceDocHandler ) ); + m_pSourceObject = impl_extractSourceObject_throw( xSourceDescriptor, m_nCommandType ); + + InteractionHandler xDestDocHandler; + impl_ensureDataAccessDescriptor_throw( _rArguments, 1, m_xDestConnection, xDestDocHandler ); + + if ( xDestDocHandler.is() && !m_xInteractionHandler.is() ) + m_xInteractionHandler = xDestDocHandler; + } + catch( const RuntimeException& ) { throw; } + catch( const IllegalArgumentException& ) { throw; } + catch( const SQLException& ) { throw; } + catch( const Exception& ) + { + throw WrappedTargetException( + String( ModuleRes( STR_CTW_ERROR_DURING_INITIALIZATION ) ), + *this, + ::cppu::getCaughtException() + ); + } +} + +//------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper& CopyTableWizard::getInfoHelper() +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::getInfoHelper" ); + return *getArrayHelper(); +} + +//------------------------------------------------------------------------------ +::cppu::IPropertyArrayHelper* CopyTableWizard::createArrayHelper( ) const +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::createArrayHelper" ); + Sequence< Property > aProps; + describeProperties( aProps ); + return new ::cppu::OPropertyArrayHelper( aProps ); +} + +//------------------------------------------------------------------------------ +Dialog* CopyTableWizard::createDialog( Window* _pParent ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::createDialog" ); + OSL_PRECOND( isInitialized(), "CopyTableWizard::createDialog: not initialized!" ); + // this should have been prevented in ::execute already + + OCopyTableWizard* pWizard = new OCopyTableWizard( + _pParent, + m_sDestinationTable, + m_nOperation, + *m_pSourceObject, + m_xSourceConnection.getTyped(), + m_xDestConnection.getTyped(), + m_aContext.getLegacyServiceFactory(), + m_xInteractionHandler + ); + + impl_attributesToDialog_nothrow( *pWizard ); + + return pWizard; +} + +//------------------------------------------------------------------------------ +void CopyTableWizard::executedDialog( sal_Int16 _nExecutionResult ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::executedDialog" ); + CopyTableWizard_DialogBase::executedDialog( _nExecutionResult ); + + if ( _nExecutionResult == RET_OK ) + impl_doCopy_nothrow(); + + // do this after impl_doCopy_nothrow: The attributes may change during copying, for instance + // if the user entered an unqualified table name + impl_dialogToAttributes_nothrow( impl_getDialog_throw() ); +} + +//........................................................................ +} // namespace dbaui +//........................................................................ + +extern "C" void SAL_CALL createRegistryInfo_CopyTableWizard() +{ + static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::CopyTableWizard > aAutoRegistration; +} diff --git a/dbaccess/source/ui/uno/copytablewizard.src b/dbaccess/source/ui/uno/copytablewizard.src new file mode 100644 index 000000000000..fc6d00804607 --- /dev/null +++ b/dbaccess/source/ui/uno/copytablewizard.src @@ -0,0 +1,80 @@ +/************************************************************************* + * + * 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_uno.hrc" + +String STR_CTW_NO_VIEWS_SUPPORT +{ + Text [ en-US ] = "The destination database does not support views."; +}; + +String STR_CTW_NO_PRIMARY_KEY_SUPPORT +{ + Text [ en-US ] = "The destination database does not support primary keys."; +}; + +String STR_CTW_INVALID_DATA_ACCESS_DESCRIPTOR +{ + Text [ en-US ] = "no data access descriptor found, or no data access descriptor able to provide all necessary information"; +}; + +String STR_CTW_ONLY_TABLES_AND_QUERIES_SUPPORT +{ + Text [ en-US ] = "Only tables and queries are supported at the moment."; +}; + +String STR_CTW_COPY_SOURCE_NEEDS_BOOKMARKS +{ + Text [ en-US ] = "The copy source's result set must support bookmarks."; +}; + +String STR_CTW_UNSUPPORTED_COLUMN_TYPE +{ + Text [ en-US ] = "Unsupported source column type ($type$) at column position $pos$."; +}; + +String STR_CTW_ILLEGAL_PARAMETER_COUNT +{ + Text [ en-US ] = "Illegal number of initialization parameters."; +}; + +String STR_CTW_ERROR_DURING_INITIALIZATION +{ + Text [ en-US ] = "An error occurred during initialization."; +}; +String STR_CTW_ERROR_UNSUPPORTED_SETTING +{ + Text [ en-US ] = "Unsupported setting in the copy source descriptor: $name$."; +}; +String STR_CTW_ERROR_NO_QUERY +{ + Text [ en-US ] = "To copy a query, your connection must be able to provide queries."; +}; +String STR_CTW_ERROR_INVALID_INTERACTIONHANDLER +{ + Text [ en-US ] = "The given interaction handler is invalid."; +}; diff --git a/dbaccess/source/ui/uno/dbinteraction.cxx b/dbaccess/source/ui/uno/dbinteraction.cxx new file mode 100644 index 000000000000..0707f49d522b --- /dev/null +++ b/dbaccess/source/ui/uno/dbinteraction.cxx @@ -0,0 +1,430 @@ +/************************************************************************* + * + * 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_INTERACTION_HXX_ +#include "dbinteraction.hxx" +#endif +#ifndef _DBU_REGHELPER_HXX_ +#include "dbu_reghelper.hxx" +#endif +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif +#ifndef TOOLS_DIAGNOSE_EX_H +#include <tools/diagnose_ex.h> +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif +#ifndef _DBHELPER_DBEXCEPTION_HXX_ +#include <connectivity/dbexception.hxx> +#endif +#ifndef _DBAUI_SQLMESSAGE_HXX_ +#include "sqlmessage.hxx" +#endif +#ifndef _COM_SUN_STAR_TASK_XINTERACTIONAPPROVE_HPP_ +#include <com/sun/star/task/XInteractionApprove.hpp> +#endif +#ifndef _COM_SUN_STAR_TASK_XINTERACTIONDISAPPROVE_HPP_ +#include <com/sun/star/task/XInteractionDisapprove.hpp> +#endif +#ifndef _COM_SUN_STAR_TASK_XINTERACTIONRETRY_HPP_ +#include <com/sun/star/task/XInteractionRetry.hpp> +#endif +#ifndef _COM_SUN_STAR_TASK_XINTERACTIONABORT_HPP_ +#include <com/sun/star/task/XInteractionAbort.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_XINTERACTIONSUPPLYPARAMETERS_HPP_ +#include <com/sun/star/sdb/XInteractionSupplyParameters.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_XINTERACTIONDOCUMENTSAVE_HPP_ +#include <com/sun/star/sdb/XInteractionDocumentSave.hpp> +#endif +#ifndef _SVTOOLS_LOGINDLG_HXX_ +#include <svtools/logindlg.hxx> +#endif +#ifndef SFX_QUERYSAVEDOCUMENT_HXX +#include <sfx2/QuerySaveDocument.hxx> +#endif +#ifndef _DBU_UNO_HRC_ +#include "dbu_uno.hrc" +#endif +#ifndef _DBAUI_PARAMDIALOG_HXX_ +#include "paramdialog.hxx" +#endif +#ifndef _SV_SVAPP_HXX +#include <vcl/svapp.hxx> +#endif +#ifndef _VOS_MUTEX_HXX_ +#include <vos/mutex.hxx> +#endif +#ifndef DBAUI_COLLECTIONVIEW_HXX +#include "CollectionView.hxx" +#endif +#ifndef DBAUI_TOOLS_HXX +#include "UITools.hxx" +#endif + + +//========================================================================== + +extern "C" void SAL_CALL createRegistryInfo_OInteractionHandler() +{ + static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::SQLExceptionInteractionHandler > aSQLExceptionInteractionHandler_AutoRegistration; + static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::LegacyInteractionHandler > aLegacyInteractionHandler_AutoRegistration; +} + +//......................................................................... +namespace dbaui +{ +//......................................................................... + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::ucb; + using namespace ::com::sun::star::sdb; + using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::task; + using namespace ::com::sun::star::beans; + using namespace ::dbtools; + + //========================================================================= + //= BasicInteractionHandler + //========================================================================= + //------------------------------------------------------------------------- + BasicInteractionHandler::BasicInteractionHandler( const Reference< XMultiServiceFactory >& _rxORB, const bool i_bFallbackToGeneric ) + :m_xORB( _rxORB ) + ,m_bFallbackToGeneric( i_bFallbackToGeneric ) + { + OSL_ENSURE( !m_bFallbackToGeneric, + "BasicInteractionHandler::BasicInteractionHandler: enabling legacy behavior, there should be no clients of this anymore!" ); + } + + //------------------------------------------------------------------------- + ::sal_Bool SAL_CALL BasicInteractionHandler::handleInteractionRequest( const Reference< XInteractionRequest >& i_rRequest ) throw (RuntimeException) + { + return impl_handle_throw( i_rRequest ); + } + + //------------------------------------------------------------------------- + void SAL_CALL BasicInteractionHandler::handle( const Reference< XInteractionRequest >& i_rRequest ) throw(RuntimeException) + { + impl_handle_throw( i_rRequest ); + } + + //------------------------------------------------------------------------- + sal_Bool BasicInteractionHandler::impl_handle_throw( const Reference< XInteractionRequest >& i_Request ) + { + Any aRequest( i_Request->getRequest() ); + DBG_ASSERT(aRequest.hasValue(), "BasicInteractionHandler::handle: invalid request!"); + if ( !aRequest.hasValue() ) + // no request -> no handling + return sal_False; + + Sequence< Reference< XInteractionContinuation > > aContinuations( i_Request->getContinuations() ); + + // try to extract an SQLException (or one of it's derived members + SQLExceptionInfo aInfo( aRequest ); + if ( aInfo.isValid() ) + { + implHandle( aInfo, aContinuations ); + return sal_True; + } + + ParametersRequest aParamRequest; + if ( aRequest >>= aParamRequest ) + { + implHandle( aParamRequest, aContinuations ); + return sal_True; + } + + DocumentSaveRequest aDocuRequest; + if ( aRequest >>= aDocuRequest ) + { + implHandle( aDocuRequest, aContinuations ); + return sal_True; + } + + if ( m_bFallbackToGeneric ) + return implHandleUnknown( i_Request ); + + return sal_False; + } + + //------------------------------------------------------------------------- + void BasicInteractionHandler::implHandle(const ParametersRequest& _rParamRequest, const Sequence< Reference< XInteractionContinuation > >& _rContinuations) + { + ::vos::OGuard aGuard(Application::GetSolarMutex()); + // want to open a dialog .... + + sal_Int32 nAbortPos = getContinuation(ABORT, _rContinuations); + sal_Int32 nParamPos = getContinuation(SUPPLY_PARAMETERS, _rContinuations); + + Reference< XInteractionSupplyParameters > xParamCallback; + if (-1 != nParamPos) + xParamCallback = Reference< XInteractionSupplyParameters >(_rContinuations[nParamPos], UNO_QUERY); + DBG_ASSERT(xParamCallback.is(), "BasicInteractionHandler::implHandle(ParametersRequest): can't set the parameters without an appropriate interaction handler!s"); + + // determine the style of the dialog, dependent on the present continuation types + WinBits nDialogStyle = WB_OK | WB_DEF_OK; + if (-1 != nAbortPos) + nDialogStyle = WB_OK_CANCEL; + + OParameterDialog aDlg(NULL, _rParamRequest.Parameters, _rParamRequest.Connection, m_xORB); + sal_Int16 nResult = aDlg.Execute(); + try + { + switch (nResult) + { + case RET_OK: + if (xParamCallback.is()) + { + xParamCallback->setParameters(aDlg.getValues()); + xParamCallback->select(); + } + break; + default: + if (-1 != nAbortPos) + _rContinuations[nAbortPos]->select(); + break; + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + //------------------------------------------------------------------------- + void BasicInteractionHandler::implHandle(const SQLExceptionInfo& _rSqlInfo, const Sequence< Reference< XInteractionContinuation > >& _rContinuations) + { + ::vos::OGuard aGuard(Application::GetSolarMutex()); + // want to open a dialog .... + + sal_Int32 nApprovePos = getContinuation(APPROVE, _rContinuations); + sal_Int32 nDisapprovePos = getContinuation(DISAPPROVE, _rContinuations); + sal_Int32 nAbortPos = getContinuation(ABORT, _rContinuations); + sal_Int32 nRetryPos = getContinuation(RETRY, _rContinuations); + + // determine the style of the dialog, dependent on the present continuation types + WinBits nDialogStyle = 0; + bool bHaveCancel = nAbortPos != -1; + // "approve" means "Yes", "disapprove" means "No" + // VCL only supports having both (which makes sense ...) + if ( ( nApprovePos != -1 ) || ( nDisapprovePos != -1 ) ) + nDialogStyle = ( bHaveCancel ? WB_YES_NO_CANCEL : WB_YES_NO ) | WB_DEF_YES; + else + { + // if there's no yes/no, then use a default OK button + nDialogStyle = ( bHaveCancel ? WB_OK_CANCEL : WB_OK ) | WB_DEF_OK; + } + + // If there's a "Retry" continuation, have a "Retry" button + if ( nRetryPos != -1 ) + { + nDialogStyle = WB_RETRY_CANCEL | WB_DEF_RETRY; + } + + // excute the dialog + OSQLMessageBox aDialog(NULL, _rSqlInfo, nDialogStyle); + // TODO: need a way to specify the parent window + sal_Int16 nResult = aDialog.Execute(); + try + { + switch (nResult) + { + case RET_YES: + case RET_OK: + if ( nApprovePos != -1 ) + _rContinuations[ nApprovePos ]->select(); + else + OSL_ENSURE( nResult != RET_YES, "BasicInteractionHandler::implHandle: no handler for YES!" ); + break; + + case RET_NO: + if ( nDisapprovePos != -1 ) + _rContinuations[ nDisapprovePos ]->select(); + else + OSL_ENSURE( false, "BasicInteractionHandler::implHandle: no handler for NO!" ); + break; + + case RET_CANCEL: + if ( nAbortPos != -1 ) + _rContinuations[ nAbortPos ]->select(); + else if ( nDisapprovePos != -1 ) + _rContinuations[ nDisapprovePos ]->select(); + else + OSL_ENSURE( false, "BasicInteractionHandler::implHandle: no handler for CANCEL!" ); + break; + case RET_RETRY: + if ( nRetryPos != -1 ) + _rContinuations[ nRetryPos ]->select(); + else + OSL_ENSURE( false, "BasicInteractionHandler::implHandle: where does the RETRY come from?" ); + break; + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + //------------------------------------------------------------------------- + void BasicInteractionHandler::implHandle(const DocumentSaveRequest& _rDocuRequest, const Sequence< Reference< XInteractionContinuation > >& _rContinuations) + { + ::vos::OGuard aGuard(Application::GetSolarMutex()); + // want to open a dialog .... + + sal_Int32 nApprovePos = getContinuation(APPROVE, _rContinuations); + sal_Int32 nDisApprovePos = getContinuation(DISAPPROVE, _rContinuations); + sal_Int32 nAbortPos = getContinuation(ABORT, _rContinuations); + + short nRet = RET_YES; + if ( -1 != nApprovePos ) + { + // fragen, ob gespeichert werden soll + nRet = ExecuteQuerySaveDocument(NULL,_rDocuRequest.Name); + } + + if ( RET_CANCEL == nRet ) + { + if (-1 != nAbortPos) + _rContinuations[nAbortPos]->select(); + return; + } + else if ( RET_YES == nRet ) + { + sal_Int32 nDocuPos = getContinuation(SUPPLY_DOCUMENTSAVE, _rContinuations); + + if (-1 != nDocuPos) + { + Reference< XInteractionDocumentSave > xCallback(_rContinuations[nDocuPos], UNO_QUERY); + DBG_ASSERT(xCallback.is(), "BasicInteractionHandler::implHandle(DocumentSaveRequest): can't save document without an appropriate interaction handler!s"); + + // determine the style of the dialog, dependent on the present continuation types + WinBits nDialogStyle = WB_OK | WB_DEF_OK; + if (-1 != nAbortPos) + nDialogStyle = WB_OK_CANCEL; + + OCollectionView aDlg(NULL,_rDocuRequest.Content,_rDocuRequest.Name,m_xORB); + sal_Int16 nResult = aDlg.Execute(); + try + { + switch (nResult) + { + case RET_OK: + if (xCallback.is()) + { + xCallback->setName(aDlg.getName(),aDlg.getSelectedFolder()); + xCallback->select(); + } + break; + default: + if (-1 != nAbortPos) + _rContinuations[nAbortPos]->select(); + break; + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + else if ( -1 != nApprovePos ) + _rContinuations[nApprovePos]->select(); + } + else if ( -1 != nDisApprovePos ) + _rContinuations[nDisApprovePos]->select(); + } + + //------------------------------------------------------------------------- + bool BasicInteractionHandler::implHandleUnknown( const Reference< XInteractionRequest >& _rxRequest ) + { + Reference< XInteractionHandler > xFallbackHandler; + if ( m_xORB.is() ) + xFallbackHandler = xFallbackHandler.query( m_xORB->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.task.InteractionHandler" ) ) ) ); + if ( xFallbackHandler.is() ) + { + xFallbackHandler->handle( _rxRequest ); + return true; + } + return false; + } + + //------------------------------------------------------------------------- + sal_Int32 BasicInteractionHandler::getContinuation(Continuation _eCont, const Sequence< Reference< XInteractionContinuation > >& _rContinuations) + { + const Reference< XInteractionContinuation >* pContinuations = _rContinuations.getConstArray(); + for (sal_Int32 i=0; i<_rContinuations.getLength(); ++i, ++pContinuations) + { + switch (_eCont) + { + case APPROVE: + if (Reference< XInteractionApprove >(*pContinuations, UNO_QUERY).is()) + return i; + break; + case DISAPPROVE: + if (Reference< XInteractionDisapprove >(*pContinuations, UNO_QUERY).is()) + return i; + break; + case RETRY: + if (Reference< XInteractionRetry >(*pContinuations, UNO_QUERY).is()) + return i; + break; + case ABORT: + if (Reference< XInteractionAbort >(*pContinuations, UNO_QUERY).is()) + return i; + break; + case SUPPLY_PARAMETERS: + if (Reference< XInteractionSupplyParameters >(*pContinuations, UNO_QUERY).is()) + return i; + break; + case SUPPLY_DOCUMENTSAVE: + if (Reference< XInteractionDocumentSave >(*pContinuations, UNO_QUERY).is()) + return i; + break; + } + } + + return -1; + } + + //========================================================================== + //= SQLExceptionInteractionHandler + //========================================================================== + IMPLEMENT_SERVICE_INFO1_STATIC( SQLExceptionInteractionHandler, "com.sun.star.comp.dbaccess.DatabaseInteractionHandler", "com.sun.star.sdb.DatabaseInteractionHandler" ); + + //========================================================================== + //= LegacyInteractionHandler + //========================================================================== + IMPLEMENT_SERVICE_INFO1_STATIC( LegacyInteractionHandler, "com.sun.star.comp.dbaccess.LegacyInteractionHandler", "com.sun.star.sdb.InteractionHandler" ); + +//......................................................................... +} // namespace dbaui +//......................................................................... + diff --git a/dbaccess/source/ui/uno/dbinteraction.hxx b/dbaccess/source/ui/uno/dbinteraction.hxx new file mode 100644 index 000000000000..f9a84ef935bc --- /dev/null +++ b/dbaccess/source/ui/uno/dbinteraction.hxx @@ -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 _DBAUI_INTERACTION_HXX_ +#define _DBAUI_INTERACTION_HXX_ + +#ifndef _CPPUHELPER_IMPLBASE2_HXX_ +#include <cppuhelper/implbase2.hxx> +#endif + +#include "moduledbu.hxx" +#include "apitools.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/task/XInteractionHandler2.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/ucb/AuthenticationRequest.hpp> +#include <com/sun/star/sdb/ParametersRequest.hpp> +#include <com/sun/star/sdb/DocumentSaveRequest.hpp> +/** === end UNO includes === **/ + +namespace dbtools +{ + class SQLExceptionInfo; +} + +//......................................................................... +namespace dbaui +{ +//......................................................................... + + //========================================================================= + //= BasicInteractionHandler + //========================================================================= + typedef ::cppu::WeakImplHelper2 < ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::task::XInteractionHandler2 + > BasicInteractionHandler_Base; + /** implements an <type scope="com.sun.star.task">XInteractionHandler</type> for + database related interaction requests. + <p/> + Supported interaction requests by now (specified by an exception: The appropriate exception + has to be returned by the getRequest method of the object implementing the + <type scope="com.sun.star.task">XInteractionRequest</type> interface. + <ul> + <li><b><type scope="com.sun.star.sdbc">SQLException</type></b>: requests to display a + standard error dialog for the (maybe chained) exception given</li> + </ul> + */ + class BasicInteractionHandler + :public BasicInteractionHandler_Base + { + const OModuleClient m_aModuleClient; + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > + m_xORB; + const bool m_bFallbackToGeneric; + + public: + BasicInteractionHandler( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_rORB, + const bool i_bFallbackToGeneric + ); + + // XInteractionHandler2 + virtual ::sal_Bool SAL_CALL handleInteractionRequest( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& Request ) throw (::com::sun::star::uno::RuntimeException); + + // XInteractionHandler + virtual void SAL_CALL handle( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& Request ) throw(::com::sun::star::uno::RuntimeException); + + protected: + sal_Bool + impl_handle_throw( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& i_Request ); + + /// handle SQLExceptions (and derived classes) + void implHandle( + const ::dbtools::SQLExceptionInfo& _rSqlInfo, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >& _rContinuations); + + /// handle parameter requests + void implHandle( + const ::com::sun::star::sdb::ParametersRequest& _rParamRequest, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >& _rContinuations); + + /// handle document save requests + void implHandle( + const ::com::sun::star::sdb::DocumentSaveRequest& _rParamRequest, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >& _rContinuations); + + /// handles requests which are not SDB-specific + bool implHandleUnknown( + const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& _rxRequest ); + + /// known continuation types + enum Continuation + { + APPROVE, + DISAPPROVE, + RETRY, + ABORT, + SUPPLY_PARAMETERS, + SUPPLY_DOCUMENTSAVE + }; + /** check if a given continuation sequence contains a given continuation type<p/> + @return the index within <arg>_rContinuations</arg> of the first occurence of a continuation + of the requested type, -1 of no such continuation exists + */ + sal_Int32 getContinuation( + Continuation _eCont, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >& _rContinuations); + }; + + //========================================================================= + //= SQLExceptionInteractionHandler + //========================================================================= + class SQLExceptionInteractionHandler : public BasicInteractionHandler + { + public: + SQLExceptionInteractionHandler( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_rORB + ) + :BasicInteractionHandler( i_rORB, false ) + { + } + + // XServiceInfo + DECLARE_SERVICE_INFO_STATIC(); + }; + + //========================================================================= + //= SQLExceptionInteractionHandler + //========================================================================= + /** an implementation for the legacy css.sdb.InteractionHandler + + css.sdb.InteractionHandler is deprecated, as it does not only handle database related interactions, + but also delegates all kind of unknown requests to a css.task.InteractionHandler. + + In today's architecture, there's only one central css.task.InteractionHandler, which is to be used + for all requests. Depending on configuration information, it decides which handler implementation + to delegate a request to. + + SQLExceptionInteractionHandler is the delegatee which handles only database related interactions. + LegacyInteractionHandler is the version which first checks for a database related interaction, and + forwards everything else to the css.task.InteractionHandler. + */ + class LegacyInteractionHandler : public BasicInteractionHandler + { + public: + LegacyInteractionHandler( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_rORB + ) + :BasicInteractionHandler( i_rORB, true ) + { + } + + // XServiceInfo + DECLARE_SERVICE_INFO_STATIC(); + }; + +//......................................................................... +} // namespace dbaui +//......................................................................... + +#endif // _DBAUI_INTERACTION_HXX_ + diff --git a/dbaccess/source/ui/uno/dbinteraction.src b/dbaccess/source/ui/uno/dbinteraction.src new file mode 100644 index 000000000000..3d4c33d8a06d --- /dev/null +++ b/dbaccess/source/ui/uno/dbinteraction.src @@ -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 _DBU_UNO_HRC_ +#include "dbu_uno.hrc" +#endif + +String STR_REMEMBERPASSWORD_SESSION +{ + Text [ en-US ] = "~Remember password until end of session"; +}; + +String STR_REMEMBERPASSWORD_PERSISTENT +{ + Text [ en-US ] = "~Remember password"; +}; + diff --git a/dbaccess/source/ui/uno/makefile.mk b/dbaccess/source/ui/uno/makefile.mk new file mode 100644 index 000000000000..987e67241d43 --- /dev/null +++ b/dbaccess/source/ui/uno/makefile.mk @@ -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. +# +#************************************************************************ + +PRJ=..$/..$/.. +PRJINC=$(PRJ)$/source +PRJNAME=dbaccess +TARGET=uiuno + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ---------------------------------- + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files ------------------------------------- + +# ... resource files ............................ + +SRS1NAME=$(TARGET) +SRC1FILES = \ + dbinteraction.src \ + copytablewizard.src + +# ... object files ............................ +# workaround for issue http://qa.openoffice.org/issues/show_bug.cgi?id=102305 Linux specific +.IF "$(COM)" == "GCC" +NOOPTFILES=\ + $(SLO)$/copytablewizard.obj +.ENDIF + +SLOFILES= \ + $(SLO)$/copytablewizard.obj \ + $(SLO)$/composerdialogs.obj \ + $(SLO)$/unosqlmessage.obj \ + $(SLO)$/unoadmin.obj \ + $(SLO)$/admindlg.obj \ + $(SLO)$/TableFilterDlg.obj \ + $(SLO)$/AdvancedSettingsDlg.obj \ + $(SLO)$/unoDirectSql.obj \ + $(SLO)$/DBTypeWizDlg.obj \ + $(SLO)$/DBTypeWizDlgSetup.obj \ + $(SLO)$/UserSettingsDlg.obj \ + $(SLO)$/ColumnModel.obj \ + $(SLO)$/ColumnControl.obj \ + $(SLO)$/ColumnPeer.obj \ + $(SLO)$/dbinteraction.obj \ + $(SLO)$/textconnectionsettings_uno.obj + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk diff --git a/dbaccess/source/ui/uno/textconnectionsettings_uno.cxx b/dbaccess/source/ui/uno/textconnectionsettings_uno.cxx new file mode 100644 index 000000000000..af0e020d069b --- /dev/null +++ b/dbaccess/source/ui/uno/textconnectionsettings_uno.cxx @@ -0,0 +1,263 @@ +/************************************************************************* + * + * 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 "dbu_reghelper.hxx" +#include "moduledbu.hxx" +#include "apitools.hxx" +#include "unoadmin.hxx" +#include "dbustrings.hrc" +#include "propertystorage.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/beans/XPropertySetInfo.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> +/** === end UNO includes === **/ + +#include <comphelper/componentcontext.hxx> +#include <svtools/genericunodialog.hxx> + +//........................................................................ +namespace dbaui +{ +//........................................................................ + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::beans::XPropertySetInfo; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::beans::Property; + using ::com::sun::star::lang::IllegalArgumentException; + /** === end UNO using === **/ + namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute; + + //==================================================================== + //= OTextConnectionSettingsDialog + //==================================================================== + + class OTextConnectionSettingsDialog; + typedef ODatabaseAdministrationDialog OTextConnectionSettingsDialog_BASE; + typedef ::comphelper::OPropertyArrayUsageHelper< OTextConnectionSettingsDialog > OTextConnectionSettingsDialog_PBASE; + + class OTextConnectionSettingsDialog + :public OTextConnectionSettingsDialog_BASE + ,public OTextConnectionSettingsDialog_PBASE + { + OModuleClient m_aModuleClient; + PropertyValues m_aPropertyValues; + + protected: + OTextConnectionSettingsDialog( const ::comphelper::ComponentContext& _rContext ); + virtual ~OTextConnectionSettingsDialog(); + + public: + DECLARE_IMPLEMENTATION_ID( ); + DECLARE_SERVICE_INFO_STATIC( ); + DECLARE_PROPERTYCONTAINER_DEFAULTS( ); + + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw(Exception); + virtual sal_Bool SAL_CALL convertFastPropertyValue( Any& rConvertedValue, Any& rOldValue, sal_Int32 nHandle, const Any& rValue) throw(IllegalArgumentException); + virtual void SAL_CALL getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const; + + protected: + // OGenericUnoDialog overridables + virtual Dialog* createDialog( Window* _pParent ); + virtual void implInitialize( const com::sun::star::uno::Any& _rValue ); + protected: + using OTextConnectionSettingsDialog_BASE::getFastPropertyValue; + }; + + //==================================================================== + //= OTextConnectionSettingsDialog + //==================================================================== + //-------------------------------------------------------------------- + OTextConnectionSettingsDialog::OTextConnectionSettingsDialog( const ::comphelper::ComponentContext& _rContext ) + :OTextConnectionSettingsDialog_BASE( _rContext.getLegacyServiceFactory() ) + { + TextConnectionSettingsDialog::bindItemStorages( *m_pDatasourceItems, m_aPropertyValues ); + } + + //--------------------------------------------------------------------- + OTextConnectionSettingsDialog::~OTextConnectionSettingsDialog() + { + } + + //--------------------------------------------------------------------- + IMPLEMENT_IMPLEMENTATION_ID( OTextConnectionSettingsDialog ) + + //--------------------------------------------------------------------- + IMPLEMENT_SERVICE_INFO1_STATIC( OTextConnectionSettingsDialog, "com.sun.star.comp.dbaccess.OTextConnectionSettingsDialog", "com.sun.star.sdb.TextConnectionSettings" ) + + //--------------------------------------------------------------------- + Reference< XPropertySetInfo > SAL_CALL OTextConnectionSettingsDialog::getPropertySetInfo() throw(RuntimeException) + { + return createPropertySetInfo( getInfoHelper() ); + } + + //--------------------------------------------------------------------- + ::cppu::IPropertyArrayHelper& OTextConnectionSettingsDialog::getInfoHelper() + { + return *getArrayHelper(); + } + + //--------------------------------------------------------------------- + ::cppu::IPropertyArrayHelper* OTextConnectionSettingsDialog::createArrayHelper( ) const + { + Sequence< Property > aProps; + describeProperties( aProps ); + + // in addition to the properties registered by the base class, we have + // more properties which are not even handled by the PropertyContainer implementation, + // but whose values are stored in our item set + sal_Int32 nProp = aProps.getLength(); + aProps.realloc( nProp + 6 ); + + aProps[ nProp++ ] = Property( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HeaderLine" ) ), + PROPERTY_ID_HEADER_LINE, + ::cppu::UnoType< sal_Bool >::get(), + PropertyAttribute::TRANSIENT + ); + + aProps[ nProp++ ] = Property( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FieldDelimiter" ) ), + PROPERTY_ID_FIELD_DELIMITER, + ::cppu::UnoType< ::rtl::OUString >::get(), + PropertyAttribute::TRANSIENT + ); + + aProps[ nProp++ ] = Property( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StringDelimiter" ) ), + PROPERTY_ID_STRING_DELIMITER, + ::cppu::UnoType< ::rtl::OUString >::get(), + PropertyAttribute::TRANSIENT + ); + + aProps[ nProp++ ] = Property( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DecimalDelimiter" ) ), + PROPERTY_ID_DECIMAL_DELIMITER, + ::cppu::UnoType< ::rtl::OUString >::get(), + PropertyAttribute::TRANSIENT + ); + + aProps[ nProp++ ] = Property( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ThousandDelimiter" ) ), + PROPERTY_ID_THOUSAND_DELIMITER, + ::cppu::UnoType< ::rtl::OUString >::get(), + PropertyAttribute::TRANSIENT + ); + + aProps[ nProp++ ] = Property( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharSet" ) ), + PROPERTY_ID_ENCODING, + ::cppu::UnoType< ::rtl::OUString >::get(), + PropertyAttribute::TRANSIENT + ); + + return new ::cppu::OPropertyArrayHelper( aProps ); + } + + //--------------------------------------------------------------------- + Dialog* OTextConnectionSettingsDialog::createDialog(Window* _pParent) + { + return new TextConnectionSettingsDialog( _pParent, *m_pDatasourceItems ); + } + + //--------------------------------------------------------------------- + void OTextConnectionSettingsDialog::implInitialize(const Any& _rValue) + { + OTextConnectionSettingsDialog_BASE::implInitialize( _rValue ); + } + + //-------------------------------------------------------------------- + void SAL_CALL OTextConnectionSettingsDialog::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const Any& _rValue ) throw(Exception) + { + PropertyValues::const_iterator pos = m_aPropertyValues.find( _nHandle ); + if ( pos != m_aPropertyValues.end() ) + { + pos->second->setPropertyValue( _rValue ); + } + else + { + OTextConnectionSettingsDialog::setFastPropertyValue_NoBroadcast( _nHandle, _rValue ); + } + } + + //-------------------------------------------------------------------- + sal_Bool SAL_CALL OTextConnectionSettingsDialog::convertFastPropertyValue( Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue) throw(IllegalArgumentException) + { + sal_Bool bModified = sal_False; + + PropertyValues::const_iterator pos = m_aPropertyValues.find( _nHandle ); + if ( pos != m_aPropertyValues.end() ) + { + // we're lazy here ... + _rConvertedValue = _rValue; + pos->second->getPropertyValue( _rOldValue ); + bModified = sal_True; + } + else + { + bModified = OTextConnectionSettingsDialog::convertFastPropertyValue( _rConvertedValue, _rOldValue, _nHandle, _rValue ); + } + + return bModified; + } + + //-------------------------------------------------------------------- + void SAL_CALL OTextConnectionSettingsDialog::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const + { + PropertyValues::const_iterator pos = m_aPropertyValues.find( _nHandle ); + if ( pos != m_aPropertyValues.end() ) + { + pos->second->getPropertyValue( _rValue ); + } + else + { + OTextConnectionSettingsDialog::getFastPropertyValue( _rValue, _nHandle ); + } + } + +//........................................................................ +} // namespace dbaui +//........................................................................ + +extern "C" void SAL_CALL createRegistryInfo_OTextConnectionSettingsDialog() +{ + static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OTextConnectionSettingsDialog > aAutoRegistration; +} + diff --git a/dbaccess/source/ui/uno/unoDirectSql.cxx b/dbaccess/source/ui/uno/unoDirectSql.cxx new file mode 100644 index 000000000000..243f39179d04 --- /dev/null +++ b/dbaccess/source/ui/uno/unoDirectSql.cxx @@ -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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#ifndef DBAUI_UNODIRECTSQL_HXX +#include "unoDirectSql.hxx" +#endif +#ifndef _DBU_REGHELPER_HXX_ +#include "dbu_reghelper.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_CONNECTION_XCONNECTION_HPP_ +#include <com/sun/star/connection/XConnection.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_ +#include <com/sun/star/container/XNamed.hpp> +#endif +#ifndef _DBACCESS_UI_DIRECTSQL_HXX_ +#include "directsql.hxx" +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef _DBAUI_DATASOURCECONNECTOR_HXX_ +#include "datasourceconnector.hxx" +#endif +#ifndef TOOLS_DIAGNOSE_EX_H +#include <tools/diagnose_ex.h> +#endif + + +extern "C" void SAL_CALL createRegistryInfo_ODirectSQLDialog() +{ + static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::ODirectSQLDialog > aAutoRegistration; +} + +//......................................................................... +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::sdbcx; + using namespace ::com::sun::star::sdbc; + using namespace ::com::sun::star::sdb; + + //===================================================================== + //= ODirectSQLDialog + //===================================================================== +DBG_NAME(ODirectSQLDialog) +//--------------------------------------------------------------------- + ODirectSQLDialog::ODirectSQLDialog(const Reference< XMultiServiceFactory >& _rxORB) + :ODirectSQLDialog_BASE( _rxORB ) + { + DBG_CTOR(ODirectSQLDialog,NULL); + + } + + //--------------------------------------------------------------------- + ODirectSQLDialog::~ODirectSQLDialog() + { + + DBG_DTOR(ODirectSQLDialog,NULL); + } + + //--------------------------------------------------------------------- + IMPLEMENT_IMPLEMENTATION_ID( ODirectSQLDialog ) + + //--------------------------------------------------------------------- + IMPLEMENT_SERVICE_INFO1_STATIC( ODirectSQLDialog, "com.sun.star.comp.sdb.DirectSQLDialog", SERVICE_SDB_DIRECTSQLDIALOG ) + + //--------------------------------------------------------------------- + IMPLEMENT_PROPERTYCONTAINER_DEFAULTS( ODirectSQLDialog ) + + //--------------------------------------------------------------------- + Dialog* ODirectSQLDialog::createDialog(Window* _pParent) + { + // obtain all the objects needed for the dialog + Reference< XConnection > xConnection = m_xActiveConnection; + if ( !xConnection.is() ) + { + try + { + // the connection the row set is working with + ODatasourceConnector aDSConnector(m_aContext.getLegacyServiceFactory(),_pParent); + xConnection = aDSConnector.connect( m_sInitialSelection, NULL ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + if ( !xConnection.is() ) + // can't create the dialog if I have improper settings + return NULL; + + return new DirectSQLDialog( _pParent, xConnection); + } + //--------------------------------------------------------------------- + void ODirectSQLDialog::implInitialize(const Any& _rValue) + { + PropertyValue aProperty; + if (_rValue >>= aProperty) + { + if (0 == aProperty.Name.compareToAscii("InitialSelection")) + { + OSL_VERIFY( aProperty.Value >>= m_sInitialSelection ); + return; + } + else if (0 == aProperty.Name.compareToAscii("ActiveConnection")) + { + m_xActiveConnection.set( aProperty.Value, UNO_QUERY ); + OSL_ENSURE( m_xActiveConnection.is(), "ODirectSQLDialog::implInitialize: invalid connection!" ); + return; + } + } + ODirectSQLDialog_BASE::implInitialize(_rValue); + } +//......................................................................... +} // namespace dbaui +//......................................................................... + diff --git a/dbaccess/source/ui/uno/unoDirectSql.hxx b/dbaccess/source/ui/uno/unoDirectSql.hxx new file mode 100644 index 000000000000..e8837de3aca8 --- /dev/null +++ b/dbaccess/source/ui/uno/unoDirectSql.hxx @@ -0,0 +1,94 @@ +/************************************************************************* + * + * 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_UNODIRECTSQL_HXX +#define DBAUI_UNODIRECTSQL_HXX + +#ifndef _SVT_GENERICUNODIALOG_HXX_ +#include <svtools/genericunodialog.hxx> +#endif +#ifndef _DBASHARED_APITOOLS_HXX_ +#include "apitools.hxx" +#endif +#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSER_HPP_ +#include <com/sun/star/sdb/XSQLQueryComposer.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROWSET_HPP_ +#include <com/sun/star/sdbc/XRowSet.hpp> +#endif +#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "moduledbu.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ +#include <com/sun/star/sdbc/XConnection.hpp> +#endif + +//......................................................................... +namespace dbaui +{ +//......................................................................... + + //===================================================================== + //= ODirectSQLDialog + //===================================================================== + class ODirectSQLDialog; + typedef ::svt::OGenericUnoDialog ODirectSQLDialog_BASE; + typedef ::comphelper::OPropertyArrayUsageHelper< ODirectSQLDialog > ODirectSQLDialog_PBASE; + + class ODirectSQLDialog + :public ODirectSQLDialog_BASE + ,public ODirectSQLDialog_PBASE + { + OModuleClient m_aModuleClient; + ::rtl::OUString m_sInitialSelection; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xActiveConnection; + protected: + ODirectSQLDialog(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB); + virtual ~ODirectSQLDialog(); + + public: + DECLARE_IMPLEMENTATION_ID( ); + + DECLARE_SERVICE_INFO_STATIC( ); + + DECLARE_PROPERTYCONTAINER_DEFAULTS( ); + + protected: + // OGenericUnoDialog overridables + virtual Dialog* createDialog(Window* _pParent); + virtual void implInitialize(const com::sun::star::uno::Any& _rValue); + }; + +//......................................................................... +} // namespace dbaui +//......................................................................... + +#endif // DBAUI_UNODIRECTSQL_HXX + diff --git a/dbaccess/source/ui/uno/unoadmin.cxx b/dbaccess/source/ui/uno/unoadmin.cxx new file mode 100644 index 000000000000..798a92ba5e7e --- /dev/null +++ b/dbaccess/source/ui/uno/unoadmin.cxx @@ -0,0 +1,145 @@ +/************************************************************************* + * + * 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_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef _TOOLKIT_AWT_VCLXWINDOW_HXX_ +#include <toolkit/awt/vclxwindow.hxx> +#endif +#ifndef _DBU_REGHELPER_HXX_ +#include "dbu_reghelper.hxx" +#endif +#ifndef _DBAUI_UNOADMIN_ +#include "unoadmin.hxx" +#endif +#ifndef _DBAUI_DBADMIN_HXX_ +#include "dbadmin.hxx" +#endif +#ifndef _COMPHELPER_EXTRACT_HXX_ +#include <comphelper/extract.hxx> +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _COMPHELPER_PROPERTY_HXX_ +#include <comphelper/property.hxx> +#endif +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif + +// --- needed because of the solar mutex +#ifndef _VOS_MUTEX_HXX_ +#include <vos/mutex.hxx> +#endif +#ifndef _SV_SVAPP_HXX +#include <vcl/svapp.hxx> +#endif +// --- + +#define THISREF() static_cast< XServiceInfo* >(this) + +//......................................................................... +namespace dbaui +{ +//......................................................................... + + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::beans; + +//========================================================================= +DBG_NAME(ODatabaseAdministrationDialog) +//------------------------------------------------------------------------- +ODatabaseAdministrationDialog::ODatabaseAdministrationDialog(const Reference< XMultiServiceFactory >& _rxORB) + :ODatabaseAdministrationDialogBase(_rxORB) + ,m_pDatasourceItems(NULL) + ,m_pItemPool(NULL) + ,m_pItemPoolDefaults(NULL) + ,m_pCollection(NULL) +{ + DBG_CTOR(ODatabaseAdministrationDialog,NULL); + + m_pCollection = new ::dbaccess::ODsnTypeCollection(_rxORB); + ODbAdminDialog::createItemSet(m_pDatasourceItems, m_pItemPool, m_pItemPoolDefaults, m_pCollection); +} + +//------------------------------------------------------------------------- +ODatabaseAdministrationDialog::~ODatabaseAdministrationDialog() +{ + // we do this here cause the base class' call to destroyDialog won't reach us anymore : we're within an dtor, + // so this virtual-method-call the base class does does not work, we're already dead then ... + if (m_pDialog) + { + ::osl::MutexGuard aGuard(m_aMutex); + if (m_pDialog) + destroyDialog(); + } + + delete m_pCollection; + m_pCollection = NULL; + + DBG_DTOR(ODatabaseAdministrationDialog,NULL); +} +//------------------------------------------------------------------------- +void ODatabaseAdministrationDialog::destroyDialog() +{ + ODatabaseAdministrationDialogBase::destroyDialog(); + ODbAdminDialog::destroyItemSet(m_pDatasourceItems, m_pItemPool, m_pItemPoolDefaults); +} +//------------------------------------------------------------------------------ +void ODatabaseAdministrationDialog::implInitialize(const Any& _rValue) +{ + PropertyValue aProperty; + if (_rValue >>= aProperty) + { + if (0 == aProperty.Name.compareToAscii("InitialSelection")) + { + m_aInitialSelection = aProperty.Value; + } + else if (0 == aProperty.Name.compareToAscii("ActiveConnection")) + { + m_xActiveConnection.set(aProperty.Value,UNO_QUERY); + } + else + ODatabaseAdministrationDialogBase::implInitialize(_rValue); + } + else + ODatabaseAdministrationDialogBase::implInitialize(_rValue); +} + +//......................................................................... +} // namespace dbaui +//......................................................................... + diff --git a/dbaccess/source/ui/uno/unosqlmessage.cxx b/dbaccess/source/ui/uno/unosqlmessage.cxx new file mode 100644 index 000000000000..838534e0f7de --- /dev/null +++ b/dbaccess/source/ui/uno/unosqlmessage.cxx @@ -0,0 +1,176 @@ +/************************************************************************* + * + * 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 _DBAUI_UNOSQLMESSAGE_HXX_ +#include "unosqlmessage.hxx" +#endif +#ifndef _DBU_REGHELPER_HXX_ +#include "dbu_reghelper.hxx" +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _DBHELPER_DBEXCEPTION_HXX_ +#include <connectivity/dbexception.hxx> +#endif + +using namespace dbaui; +using namespace dbtools; + +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::sdb; + +extern "C" void SAL_CALL createRegistryInfo_OSQLMessageDialog() +{ + static OMultiInstanceAutoRegistration< OSQLMessageDialog > aAutoRegistration; +} + +//......................................................................... +namespace dbaui +{ +//......................................................................... + + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::beans; + +//========================================================================= +//------------------------------------------------------------------------- +OSQLMessageDialog::OSQLMessageDialog(const Reference< XMultiServiceFactory >& _rxORB) + :OSQLMessageDialogBase(_rxORB) +{ + registerMayBeVoidProperty(PROPERTY_SQLEXCEPTION, PROPERTY_ID_SQLEXCEPTION, PropertyAttribute::TRANSIENT | PropertyAttribute::MAYBEVOID, + &m_aException, ::getCppuType(static_cast<SQLException*>(NULL))); + registerProperty( PROPERTY_HELP_URL, PROPERTY_ID_HELP_URL, PropertyAttribute::TRANSIENT, + &m_sHelpURL, ::getCppuType( &m_sHelpURL ) ); +} + +//------------------------------------------------------------------------- +Sequence<sal_Int8> SAL_CALL OSQLMessageDialog::getImplementationId( ) throw(RuntimeException) +{ + static ::cppu::OImplementationId aId; + return aId.getImplementationId(); +} + +//------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL OSQLMessageDialog::Create(const Reference< XMultiServiceFactory >& _rxFactory) +{ + return *(new OSQLMessageDialog(_rxFactory)); +} + +//------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OSQLMessageDialog::getImplementationName() throw(RuntimeException) +{ + return getImplementationName_Static(); +} + +//------------------------------------------------------------------------- +::rtl::OUString OSQLMessageDialog::getImplementationName_Static() throw(RuntimeException) +{ + return ::rtl::OUString::createFromAscii("org.openoffice.comp.dbu.OSQLMessageDialog"); +} + +//------------------------------------------------------------------------- +::comphelper::StringSequence SAL_CALL OSQLMessageDialog::getSupportedServiceNames() throw(RuntimeException) +{ + return getSupportedServiceNames_Static(); +} + +//------------------------------------------------------------------------- +::comphelper::StringSequence OSQLMessageDialog::getSupportedServiceNames_Static() throw(RuntimeException) +{ + ::comphelper::StringSequence aSupported(1); + aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.ErrorMessageDialog"); + return aSupported; +} + +//------------------------------------------------------------------------- +sal_Bool SAL_CALL OSQLMessageDialog::convertFastPropertyValue( Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue) throw(IllegalArgumentException) +{ + switch (_nHandle) + { + case PROPERTY_ID_SQLEXCEPTION: + { + SQLExceptionInfo aInfo(_rValue); + if (!aInfo.isValid()) + throw IllegalArgumentException(); + + _rOldValue = m_aException; + _rConvertedValue = aInfo.get(); + + return sal_True; + // always assume "modified", don't bother with with comparing the two values + } + default: + return OSQLMessageDialogBase::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue); + } +} + +//------------------------------------------------------------------------- +Reference<XPropertySetInfo> SAL_CALL OSQLMessageDialog::getPropertySetInfo() throw(RuntimeException) +{ + Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; +} + +//------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper& OSQLMessageDialog::getInfoHelper() +{ + return *const_cast<OSQLMessageDialog*>(this)->getArrayHelper(); +} + +//------------------------------------------------------------------------------ +::cppu::IPropertyArrayHelper* OSQLMessageDialog::createArrayHelper( ) const +{ + Sequence< Property > aProps; + describeProperties(aProps); + return new ::cppu::OPropertyArrayHelper(aProps); +} + +//------------------------------------------------------------------------------ +Dialog* OSQLMessageDialog::createDialog(Window* _pParent) +{ + if ( m_aException.hasValue() ) + return new OSQLMessageBox( _pParent, SQLExceptionInfo( m_aException ), WB_OK | WB_DEF_OK, m_sHelpURL ); + + OSL_ENSURE(sal_False, "OSQLMessageDialog::createDialog : You should use the SQLException property to specify the error to display!"); + return new OSQLMessageBox(_pParent, SQLException()); +} + +//......................................................................... +} // namespace dbaui +//......................................................................... + |