diff options
Diffstat (limited to 'dbaccess/source/ui/browser')
-rw-r--r-- | dbaccess/source/ui/browser/bcommon.src | 117 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/brwctrlr.cxx | 2818 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/brwview.cxx | 297 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/dbloader.cxx | 270 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/dbtreemodel.cxx | 290 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/dbtreemodel.hxx | 103 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/dbtreeview.cxx | 128 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/dbtreeview.hxx | 96 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/exsrcbrw.cxx | 765 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/formadapter.cxx | 1908 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/makefile.mk | 99 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/sbabrw.src | 982 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/sbagrid.cxx | 2313 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/sbagrid.src | 290 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/sbamultiplex.cxx | 168 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/unodatbr.cxx | 1128 |
16 files changed, 11772 insertions, 0 deletions
diff --git a/dbaccess/source/ui/browser/bcommon.src b/dbaccess/source/ui/browser/bcommon.src new file mode 100644 index 000000000..5c7e70b34 --- /dev/null +++ b/dbaccess/source/ui/browser/bcommon.src @@ -0,0 +1,117 @@ +/************************************************************************* + * + * $RCSfile: bcommon.src,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2000-10-26 14:40:39 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the License); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an AS IS basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _DBU_RESOURCE_HRC_ +#include "dbu_resource.hrc" +#endif + + +String RID_STR_QRY_TITLE +{ + Text = "Abfrage #" ; + Text [ ENGLISH ] = "Query #" ; + Text [ english_us ] = "Query #" ; + Text [ portuguese ] = "Consulta #" ; + Text [ portuguese_brazilian ] = "Abfrage #" ; + Text [ swedish ] = "Sökning #" ; + Text [ danish ] = "Forespørgsel #" ; + Text [ italian ] = "Ricerca #" ; + Text [ spanish ] = "Consulta #" ; + Text [ french ] = "Requête #" ; + Text [ dutch ] = "Query #" ; + Text[ chinese_simplified ] = "²éѯ #"; + Text[ russian ] = "Çàïðîñ #"; + Text[ polish ] = "Kwerenda #"; + Text[ japanese ] = "¸´Ø° #"; + Text[ dutch ] = "Query #"; + Text[ chinese_simplified ] = "²éѯ #"; + Text[ greek ] = "Åñþôçìá #"; + Text[ korean ] = "ÁúÀÇ #"; + Text[ chinese_traditional ] = "¬d¸ß #"; + Text[ arabic ] = "ÇáÇÓÊÝÓÇÑ #"; + Text[ turkish ] = "Sorgu #"; + Text[ language_user1 ] = " "; +}; +String RID_STR_TBL_TITLE +{ + Text = "Tabelle #" ; + Text [ ENGLISH ] = "Table #" ; + Text [ english_us ] = "Table #" ; + Text [ portuguese ] = "Tabela #" ; + Text [ portuguese_brazilian ] = "Tabelle #" ; + Text [ swedish ] = "Tabell #" ; + Text [ danish ] = "Tabel #" ; + Text [ italian ] = "Tabella #" ; + Text [ spanish ] = "Tabla #" ; + Text [ french ] = "Table #" ; + Text [ dutch ] = "Tabel #" ; + Text[ chinese_simplified ] = "±í¸ñ #"; + Text[ russian ] = "Òàáëèöà #"; + Text[ polish ] = "Tabela #"; + Text[ japanese ] = "ðÌÞÙ #"; + Text[ dutch ] = "Tabel #"; + Text[ chinese_simplified ] = "±í¸ñ #"; + Text[ greek ] = "Ðßíáêáò #"; + Text[ korean ] = "Å×À̺í #"; + Text[ chinese_traditional ] = "ªí®æ #"; + Text[ arabic ] = "ÌÏæá #"; + Text[ turkish ] = "Tablo #"; + Text[ language_user1 ] = " "; +}; diff --git a/dbaccess/source/ui/browser/brwctrlr.cxx b/dbaccess/source/ui/browser/brwctrlr.cxx new file mode 100644 index 000000000..ad83bd2c9 --- /dev/null +++ b/dbaccess/source/ui/browser/brwctrlr.cxx @@ -0,0 +1,2818 @@ +/************************************************************************* + * + * $RCSfile: brwctrlr.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2000-10-26 14:40:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_ +#include <com/sun/star/sdbcx/Privilege.hpp> +#endif +#ifndef _SBA_BWRCTRLR_HXX +#include "brwctrlr.hxx" +#endif +#ifndef _SBX_BRWVIEW_HXX +#include "brwview.hxx" +#endif +//#ifndef _SBA_SBADBCOM_HXX +//#include "sbadbcom.hxx" +//#endif +// +//#ifndef _ModuleRes_HRC +//#include "ModuleRes.hrc" +//#endif +//#ifndef _SBA_SBARES_HXX +//#include "sbares.hxx" +//#endif +// +//#ifndef _SBA_DLGERR_HXX +//#include "dlgerr.hxx" +//#endif +//#ifndef _SBA_SBASTAT_HXX +//#include "dbstat.hxx" +//#endif +// +#ifndef _SVX_QRYPARAM_HXX //autogen wg. FmEnterParamDlg +#include <svx/qryparam.hxx> +#endif + +#ifndef _OSL_MUTEX_HXX_ //autogen wg. MutexGuard +#include <osl/mutex.hxx> +#endif + +#ifndef _SFXAPP_HXX //autogen wg. SFX_APP +#include <sfx2/app.hxx> +#endif +#ifndef _COM_SUN_STAR_UNO_TYPECLASS_HPP_ +#include <com/sun/star/uno/TypeClass.hpp> +#endif +//#ifndef _SBA_API_HRC +//#include "api.hrc" +//#endif +#ifndef _SVX_DBERRBOX_HXX +#include <svx/dbmsgbox.hxx> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ +#include <com/sun/star/sdb/CommandType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROWSETLISTENER_HPP_ +#include <com/sun/star/sdbc/XRowSetListener.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSERFACTORY_HPP_ +#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ +#include <com/sun/star/sdbc/XConnection.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XROWLOCATE_HPP_ +#include <com/sun/star/sdbcx/XRowLocate.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETUPDATE_HPP_ +#include <com/sun/star/sdbc/XResultSetUpdate.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_XSQLERRORBROADCASTER_HPP_ +#include <com/sun/star/sdb/XSQLErrorBroadcaster.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_XLOADABLE_HPP_ +#include <com/sun/star/form/XLoadable.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_ +#include <com/sun/star/sdb/SQLContext.hpp> +#endif + +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ +#include <com/sun/star/beans/PropertyAttribute.hpp> +#endif + +#ifndef _COM_SUN_STAR_DATA_XDATABASEDIALOGS_HPP_ +#include <com/sun/star/data/XDatabaseDialogs.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_FORMBUTTONTYPE_HPP_ +#include <com/sun/star/form/FormButtonType.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_XCHANGELISTENER_HPP_ +#include <com/sun/star/form/XChangeListener.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_FORMSUBMITENCODING_HPP_ +#include <com/sun/star/form/FormSubmitEncoding.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_FORMSUBMITMETHOD_HPP_ +#include <com/sun/star/form/FormSubmitMethod.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_XSUBMITLISTENER_HPP_ +#include <com/sun/star/form/XSubmitListener.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_XRESET_HPP_ +#include <com/sun/star/form/XReset.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_XSUBMIT_HPP_ +#include <com/sun/star/form/XSubmit.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_XAPPROVEACTIONBROADCASTER_HPP_ +#include <com/sun/star/form/XApproveActionBroadcaster.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_XCHANGEBROADCASTER_HPP_ +#include <com/sun/star/form/XChangeBroadcaster.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_XRESETLISTENER_HPP_ +#include <com/sun/star/form/XResetListener.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XCANCELLABLE_HPP_ +#include <com/sun/star/util/XCancellable.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_XDATABASEPARAMETERBROADCASTER_HPP_ +#include <com/sun/star/form/XDatabaseParameterBroadcaster.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_XBOUNDCONTROL_HPP_ +#include <com/sun/star/form/XBoundControl.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ +#include <com/sun/star/container/XNameContainer.hpp> +#endif +#ifndef _SV_MSGBOX_HXX //autogen +#include <vcl/msgbox.hxx> +#endif + +#ifndef _FMSEARCH_HXX +#include <svx/fmsearch.hxx> +#endif + +#ifndef _SV_CLIP_HXX //autogen +#include <vcl/clip.hxx> +#endif + +#ifndef _SV_TOOLBOX_HXX //autogen wg. ToolBox +#include <vcl/toolbox.hxx> +#endif +#ifndef _SV_WAITOBJ_HXX +#include <vcl/waitobj.hxx> +#endif +#ifndef _TOOLS_COLOR_HXX +#include <tools/color.hxx> +#endif +#ifndef _COMPHELPER_PROCESSFACTORY_HXX_ +#include <comphelper/processfactory.hxx> +#endif +#ifndef _CONNECTIVITY_DBTOOLS_HXX_ +#include <connectivity/dbtools.hxx> +#endif +#ifndef _CPPUHELPER_IMPLBASE2_HXX_ +#include <cppuhelper/implbase2.hxx> +#endif +#ifndef _DBU_RESOURCE_HRC_ +#include "dbu_resource.hrc" +#endif +#ifndef _SFX_HRC +#include <sfx2/sfx.hrc> +#endif +#ifndef DBACCESS_UI_BROWSER_ID_HXX +#include "browserids.hxx" +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif + +#define GRID_NAME "MyOneAndOnlyGrid" + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::sdb; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace dbaui; + +::rtl::OUString URL_CONFIRM_DELETION(::rtl::OUString::createFromAscii(".uno:FormSlots/ConfirmDeletion")); + +#define HANDLE_SQL_ERRORS( action, successflag, context, message ) \ + try \ + { \ + successflag = sal_False; \ + action; \ + successflag = sal_True; \ + } \ + catch(SQLException& e) \ + { \ + ::com::sun::star::sdb::SQLContext eExtendedInfo = \ + ::dbtools::prependContextInfo(e, Reference< XInterface > (), context); \ + ::com::sun::star::sdb::SQLErrorEvent aEvent; \ + aEvent.Reason <<= eExtendedInfo; \ + errorOccured(aEvent); \ + } \ + catch(...) \ + { \ + DBG_ERROR(message); \ + } \ + +#define DO_SAFE( action, message ) try { action; } catch(...) { DBG_ERROR(message); } ; + +//================================================================== +//= OAsyncronousLink +//================================================================== +//------------------------------------------------------------------ +OAsyncronousLink::OAsyncronousLink(const Link& _rHandler, NAMESPACE_VOS(OMutex)* _pEventSafety, NAMESPACE_VOS(OMutex)* _pDestructionSafety) + :m_aHandler(_rHandler) + ,m_pEventSafety(NULL) + ,m_pDestructionSafety(NULL) + ,m_bOwnMutexes(FALSE) + ,m_nEventId(0) +{ + if (_pEventSafety && _pDestructionSafety) + { + m_pEventSafety = _pEventSafety; + m_pDestructionSafety = _pDestructionSafety; + m_bOwnMutexes = FALSE; + } + else + { + m_pEventSafety = new ::vos::OMutex; + m_pDestructionSafety = new ::vos::OMutex; + m_bOwnMutexes = TRUE; + } +} + +//------------------------------------------------------------------ +OAsyncronousLink::~OAsyncronousLink() +{ + { + ::vos::OGuard aEventGuard(*m_pEventSafety); + if (m_nEventId) + Application::RemoveUserEvent(m_nEventId); + m_nEventId = 0; + } + + { + ::vos::OGuard aDestructionGuard(*m_pDestructionSafety); + // this is just for the case we're deleted while another thread just handled the event : + // if this other thread called our link while we were deleting the event here, the + // link handler blocked. With leaving the above block it continued, but now we are prevented + // to leave this destructor 'til the link handler recognizes that nEvent == 0 and leaves. + } + if (m_bOwnMutexes) + { + delete m_pEventSafety; + delete m_pDestructionSafety; + } + m_pEventSafety = NULL; + m_pDestructionSafety = NULL; +} + + +//------------------------------------------------------------------ +void OAsyncronousLink::Call(void* _pArgument) +{ + ::vos::OGuard aEventGuard(*m_pEventSafety); + if (m_nEventId) + Application::RemoveUserEvent(m_nEventId); + m_nEventId = Application::PostUserEvent(LINK(this, OAsyncronousLink, OnAsyncCall)); +} + +//------------------------------------------------------------------ +void OAsyncronousLink::CancelCall() +{ + ::vos::OGuard aEventGuard(*m_pEventSafety); + if (m_nEventId) + Application::RemoveUserEvent(m_nEventId); + m_nEventId = 0; +} + +//------------------------------------------------------------------ +IMPL_LINK(OAsyncronousLink, OnAsyncCall, void*, _pArg) +{ + { + ::vos::OGuard aDestructionGuard(*m_pDestructionSafety); + { + ::vos::OGuard aEventGuard(*m_pEventSafety); + if (!m_nEventId) + // our destructor deleted the event just while we we're waiting for m_pEventSafety + // -> get outta here + return 0; + m_nEventId = 0; + } + } + if (m_aHandler.IsSet()) + return m_aHandler.Call(_pArg); + + return 0L; +} + +//================================================================== +//= SbaXDataBrowserController +//================================================================== +Any SAL_CALL SbaXDataBrowserController::queryInterface(const Type& _rType) throw (RuntimeException) +{ + Any aRet = SbaXDataBrowserController_Base::queryInterface(_rType); + if(aRet.hasValue()) + return aRet; + aRet = SbaXDataBrowserController_Base2::queryInterface(_rType); + if(aRet.hasValue()) + return aRet; + return OPropertySetHelper::queryInterface(_rType); +} + +//------------------------------------------------------------------------------ +SbaXDataBrowserController::SbaXDataBrowserController(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM) +: ::comphelper::OPropertyContainer(m_aPropertyBroadcastHelper) + ,m_aPropertyBroadcastHelper(m_aPropertyMutex) + ,m_pContent(NULL) + ,m_bCurrentlyModified(sal_False) + ,m_pLoadThread(NULL) + ,m_bClosingKillOpen(sal_False) + ,m_nPendingLoadFinished(0) + ,m_sLoadStopperCaption(ModuleRes(RID_STR_LOADING_DATASOURCE)) + ,m_nFormActionNestingLevel(0) + ,m_bErrorOccured(false) + ,m_bFrameUiActive(sal_False) + ,m_sStateSaveRecord(ModuleRes(RID_STR_SAVE_CURRENT_RECORD)) + ,m_sStateUndoRecord(ModuleRes(RID_STR_UNDO_MODIFY_RECORD)) + ,m_aDisposeListeners(m_aPropertyMutex) + ,m_xMultiServiceFacatory(_rM) + ,m_aAsynClose(LINK(this, SbaXDataBrowserController, OnAsyncClose)) + ,m_aAsyncGetCellFocus(LINK(this, SbaXDataBrowserController, OnAsyncGetCellFocus)) + ,m_aAsyncInvalidateAll(LINK(this, SbaXDataBrowserController, OnAsyncInvalidateAll)) +{ + try + { + m_xUrlTransformer = Reference< ::com::sun::star::util::XURLTransformer > (_rM->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer")), UNO_QUERY); + } + catch(Exception&) + { + } + static ::rtl::OUString s_sHelpFileName(::rtl::OUString::createFromAscii("database.hlp")); + sal_Int32 nAttrib = PropertyAttribute::READONLY | PropertyAttribute::TRANSIENT; + registerProperty(PROPERTY_HELPFILENAME, PROPERTY_ID_HELPFILENAME,nAttrib,&s_sHelpFileName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); + + DBG_ASSERT(m_xUrlTransformer.is(), "SbaXDataBrowserController::SbaXDataBrowserController : could not create the url transformer !"); +} + +//------------------------------------------------------------------------------ +SbaXDataBrowserController::~SbaXDataBrowserController() +{ + m_pContent = NULL; +} + +//------------------------------------------------------------------------------ +sal_Bool SbaXDataBrowserController::Construct(Window* pParent) +{ + // --------------------------------------------- + // create/initialize the form and the grid model + m_xRowSet = CreateForm(); + if (!m_xRowSet.is()) + return sal_False; + + if (!InitializeForm(m_xRowSet)) + return sal_False; + + m_xGridModel = CreateGridModel(); + if (!m_xGridModel.is()) + return sal_False; + + // --------------------------------------------------------------- + // create a formatter working with the connections format supplier + Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier(::dbtools::getNumberFormats(::dbtools::getConnection(m_xRowSet), sal_True,m_xMultiServiceFacatory)); + + // create a new formatter + m_xFormatter = Reference< ::com::sun::star::util::XNumberFormatter > ( + ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")), UNO_QUERY); + if (m_xFormatter.is()) + m_xFormatter->attachNumberFormatsSupplier(xSupplier); + // formatter is used by InitializeGridModel + // --------------------------------------------------------------- + + // we want to have a grid with a "flat" border + Reference< XPropertySet > xGridSet(m_xGridModel, UNO_QUERY); + if (xGridSet.is()) + xGridSet->setPropertyValue(PROPERTY_BORDER, makeAny((sal_Int16)2)); + // if (!InitializeGridModel(m_xGridModel)) + // return sal_False; + + // ---------- + // marry them + Reference< ::com::sun::star::container::XNameContainer > xNameCont(m_xRowSet, UNO_QUERY); + xNameCont->insertByName(::rtl::OUString::createFromAscii(GRID_NAME), makeAny(m_xGridModel)); + + + + // --------------- + // create the view + m_pContent = new UnoDataBrowserView(pParent,m_xMultiServiceFacatory); + if (!m_pContent) + return sal_False; + + // late construction + sal_Bool bSuccess = sal_False; + try + { + m_pContent->Construct(getControlModel()); + bSuccess = sal_True; + } + catch(SQLException&) + { + } + catch(...) + { + DBG_ERROR("SbaXDataBrowserController::Construct : the construction of UnoDataBrowserView failed !"); + } + + if (!bSuccess) + { + delete m_pContent; + m_pContent = NULL; + return sal_False; + } + + AddSupportedFeatures(); + + // want to have a toolbox ? + ToolBox* pTB = CreateToolBox(m_pContent); + m_pContent->setToolBox(pTB); + if (pTB) + // we want to handle the select + pTB->SetSelectHdl(LINK(this, SbaXDataBrowserController, OnToolBoxSelected)); + + // set the callbacks for the grid control + SbaGridControl* pVclGrid = m_pContent->getVclControl(); + DBG_ASSERT(pVclGrid, "SbaXDataBrowserController::Construct : have no VCL control !"); + pVclGrid->SetMasterListener(this); + + // -------------------------- + // add listeners ... + + // ... to the form model + Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); + if (xFormSet.is()) + { + xFormSet->addPropertyChangeListener(PROPERTY_ISNEW, (XPropertyChangeListener*)this); + xFormSet->addPropertyChangeListener(PROPERTY_ISMODIFIED, (XPropertyChangeListener*)this); + xFormSet->addPropertyChangeListener(PROPERTY_ROWCOUNT, (XPropertyChangeListener*)this); + xFormSet->addPropertyChangeListener(PROPERTY_ACTIVECOMMAND, (XPropertyChangeListener*)this); + xFormSet->addPropertyChangeListener(PROPERTY_ORDER, (XPropertyChangeListener*)this); + xFormSet->addPropertyChangeListener(PROPERTY_FILTER, (XPropertyChangeListener*)this); + xFormSet->addPropertyChangeListener(PROPERTY_APPLYFILTER, (XPropertyChangeListener*)this); + } + Reference< ::com::sun::star::sdb::XSQLErrorBroadcaster > xFormError(getRowSet(), UNO_QUERY); + if (xFormError.is()) + xFormError->addSQLErrorListener((::com::sun::star::sdb::XSQLErrorListener*)this); + + Reference< ::com::sun::star::form::XLoadable > xLoadable(getRowSet(), UNO_QUERY); + if (xLoadable.is()) + xLoadable->addLoadListener(this); + + Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xFormParameter(getRowSet(), UNO_QUERY); + if (xFormParameter.is()) + xFormParameter->addParameterListener((::com::sun::star::form::XDatabaseParameterListener*)this); + + addModelListeners(getControlModel()); + addControlListeners(m_pContent->getGridControl()); + + // ------------- + // load the form + return LoadForm(); +} + +//------------------------------------------------------------------------------ +sal_Bool SbaXDataBrowserController::LoadForm() +{ + Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); + sal_Bool bThreadSafe(sal_False); + try + { + bThreadSafe = ::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_THREADSAFE)); + } + catch(...) + { + } + + + m_bLoadCanceled = sal_False; + if (bThreadSafe) + { // load in an own thread so the office doesn't block meanwhile + m_pLoadThread = new LoadFormThread(getRowSet(), m_sLoadStopperCaption); + ((LoadFormThread*)m_pLoadThread)->SetTerminationHdl(LINK(this, SbaXDataBrowserController, OnOpenFinished)); + m_pLoadThread->create(); + + InvalidateAll(); + } + else + { + Reference< ::com::sun::star::form::XLoadable > xLoadable(getRowSet(),UNO_QUERY); + xLoadable->load(); + FormLoaded(sal_True); + } + return sal_True; +} +//------------------------------------------------------------------------------ +void SbaXDataBrowserController::AddColumnListener(const Reference< XPropertySet > & xCol) +{ + // we're not interested in any column properties ... +} + +//------------------------------------------------------------------------------ +void SbaXDataBrowserController::RemoveColumnListener(const Reference< XPropertySet > & xCol) +{ +} +//------------------------------------------------------------------------- +sal_Bool SAL_CALL SbaXDataBrowserController::supportsService(const ::rtl::OUString& ServiceName) throw(RuntimeException) +{ + Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); + const ::rtl::OUString* pArray = aSupported.getConstArray(); + for (sal_Int32 i = 0; i < aSupported.getLength(); ++i, ++pArray) + if (pArray->equals(ServiceName)) + return sal_True; + return sal_False; +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXDataBrowserController::initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException) +{ + Reference< ::com::sun::star::awt::XWindow > xParent; + Reference< ::com::sun::star::frame::XFrame > xFrame; + + const Any* pBegin = aArguments.getConstArray(); + const Any* pEnd = pBegin + aArguments.getLength(); + for(;pBegin != pEnd;++pBegin) + { + if((*pBegin >>= xFrame) && xFrame.is()) + { + xParent = xFrame->getContainerWindow(); + VCLXWindow* pParentComponent = VCLXWindow::GetImplementation(xParent); + Window* pParentWin = pParentComponent ? pParentComponent->GetWindow() : NULL; + if (!pParentWin) + { + throw Exception(::rtl::OUString::createFromAscii("Parent window is null"),*this); + } + + if(xFrame.is() && Construct(pParentWin)) + { + xFrame->setComponent(getContent()->GetWindowPeer(), this); + attachFrame(xFrame); + pParentComponent->setVisible(sal_True); + } + } + } +} +//------------------------------------------------------------------------------ +Reference< XRowSet > SbaXDataBrowserController::CreateForm() +{ + return Reference< XRowSet > (::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.form.component.Form")), UNO_QUERY); +} + +//------------------------------------------------------------------------------ +Reference< ::com::sun::star::form::XFormComponent > SbaXDataBrowserController::CreateGridModel() +{ + return Reference< ::com::sun::star::form::XFormComponent > (::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.form.component.GridControl")), UNO_QUERY); +} + +// ------------------------------------------------------------------------- +void SbaXDataBrowserController::addModelListeners(const Reference< ::com::sun::star::awt::XControlModel > & _xGridControlModel) +{ + // ... all the grid columns + Reference< ::com::sun::star::container::XIndexContainer > xColumns(getControlModel(), UNO_QUERY); + if (xColumns.is()) + { + for (sal_uInt16 i=0; i<xColumns->getCount(); ++i) + { + Reference< XPropertySet > xCol = *(Reference< XPropertySet > *)xColumns->getByIndex(i).getValue(); + AddColumnListener(xCol); + } + } + + // (we are interested in all columns the grid has (and only in these) so we have to listen to the container, too) + Reference< ::com::sun::star::container::XContainer > xColContainer(_xGridControlModel, UNO_QUERY); + if (xColContainer.is()) + xColContainer->addContainerListener((::com::sun::star::container::XContainerListener*)this); + + Reference< ::com::sun::star::form::XReset > xReset(_xGridControlModel, UNO_QUERY); + if (xReset.is()) + xReset->addResetListener((::com::sun::star::form::XResetListener*)this); +} + +// ------------------------------------------------------------------------- +void SbaXDataBrowserController::removeModelListeners(const Reference< ::com::sun::star::awt::XControlModel > & _xGridControlModel) +{ + // every single column model + Reference< ::com::sun::star::container::XIndexContainer > xColumns(getControlModel(), UNO_QUERY); + if (xColumns.is()) + { + for (sal_uInt16 i=0; i<xColumns->getCount(); ++i) + { + Reference< XPropertySet > xCol = *(Reference< XPropertySet > *)xColumns->getByIndex(i).getValue(); + RemoveColumnListener(xCol); + } + } + + Reference< ::com::sun::star::container::XContainer > xColContainer(getControlModel(), UNO_QUERY); + if (xColContainer.is()) + xColContainer->removeContainerListener((::com::sun::star::container::XContainerListener*)this); + + Reference< ::com::sun::star::form::XReset > xReset(getControlModel(), UNO_QUERY); + if (xReset.is()) + xReset->removeResetListener((::com::sun::star::form::XResetListener*)this); +} + +// ------------------------------------------------------------------------- +void SbaXDataBrowserController::addControlListeners(const Reference< ::com::sun::star::awt::XControl > & _xGridControl) +{ + // to ge the 'modified' for the current cell + Reference< ::com::sun::star::util::XModifyBroadcaster > xBroadcaster(m_pContent->getGridControl(), UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->addModifyListener((::com::sun::star::util::XModifyListener*)this); + + // introduce ourself as dispatch provider for the grid + Reference< ::com::sun::star::frame::XDispatchProviderInterception > xInterception(m_pContent->getGridControl(), UNO_QUERY); + if (xInterception.is()) + xInterception->registerDispatchProviderInterceptor((::com::sun::star::frame::XDispatchProviderInterceptor*)this); +} + +// ------------------------------------------------------------------------- +void SbaXDataBrowserController::removeControlListeners(const Reference< ::com::sun::star::awt::XControl > & _xGridControl) +{ + Reference< ::com::sun::star::util::XModifyBroadcaster > xBroadcaster(_xGridControl, UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->removeModifyListener((::com::sun::star::util::XModifyListener*)this); + + Reference< ::com::sun::star::frame::XDispatchProviderInterception > xInterception(_xGridControl, UNO_QUERY); + if (xInterception.is()) + xInterception->releaseDispatchProviderInterceptor((::com::sun::star::frame::XDispatchProviderInterceptor*)this); +} + +// ------------------------------------------------------------------------- +void SbaXDataBrowserController::disposingGridControl(const ::com::sun::star::lang::EventObject& Source) +{ + removeControlListeners(m_pContent->getGridControl()); +} + +// ------------------------------------------------------------------------- +void SbaXDataBrowserController::disposingGridModel(const ::com::sun::star::lang::EventObject& Source) +{ + removeModelListeners(getControlModel()); +} + +// ------------------------------------------------------------------------- +void SbaXDataBrowserController::disposingFormModel(const ::com::sun::star::lang::EventObject& Source) +{ + Reference< XPropertySet > xSourceSet(Source.Source, UNO_QUERY); + if (xSourceSet.is()) + { + xSourceSet->removePropertyChangeListener(PROPERTY_ISNEW, (XPropertyChangeListener*)this); + xSourceSet->removePropertyChangeListener(PROPERTY_ISMODIFIED, (XPropertyChangeListener*)this); + xSourceSet->removePropertyChangeListener(PROPERTY_ROWCOUNT, (XPropertyChangeListener*)this); + xSourceSet->removePropertyChangeListener(PROPERTY_ACTIVECOMMAND, (XPropertyChangeListener*)this); + xSourceSet->removePropertyChangeListener(PROPERTY_ORDER, (XPropertyChangeListener*)this); + xSourceSet->removePropertyChangeListener(PROPERTY_FILTER, (XPropertyChangeListener*)this); + xSourceSet->removePropertyChangeListener(PROPERTY_APPLYFILTER, (XPropertyChangeListener*)this); + } + + Reference< ::com::sun::star::sdb::XSQLErrorBroadcaster > xFormError(Source.Source, UNO_QUERY); + if (xFormError.is()) + xFormError->removeSQLErrorListener((::com::sun::star::sdb::XSQLErrorListener*)this); + + Reference< ::com::sun::star::form::XLoadable > xLoadable(getRowSet(), UNO_QUERY); + if (xLoadable.is()) + xLoadable->removeLoadListener(this); + + Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xFormParameter(Source.Source, UNO_QUERY); + if (xFormParameter.is()) + xFormParameter->removeParameterListener((::com::sun::star::form::XDatabaseParameterListener*)this); +} + +// ------------------------------------------------------------------------- +void SbaXDataBrowserController::disposingColumnModel(const ::com::sun::star::lang::EventObject& Source) +{ + RemoveColumnListener(Reference< XPropertySet > (Source.Source, UNO_QUERY)); +} + +// ------------------------------------------------------------------------- +void SbaXDataBrowserController::disposing(const ::com::sun::star::lang::EventObject& Source) throw( RuntimeException ) +{ + // is it the grid control ? + if (m_pContent) + { + Reference< ::com::sun::star::awt::XControl > xSourceControl(Source.Source, UNO_QUERY); + if (xSourceControl == m_pContent->getGridControl()) + disposingGridControl(Source); + } + + // it's model (the container of the columns) ? + if (getControlModel() == Source.Source) + disposingGridModel(Source); + + // the form's model ? + if ((getRowSet() == Source.Source)) + disposingFormModel(Source); + + // from a single column model ? + Reference< XPropertySet > xSourceSet(Source.Source, UNO_QUERY); + if (xSourceSet.is()) + { + Reference< XPropertySetInfo > xInfo = xSourceSet->getPropertySetInfo(); + // we assume that columns have a Width property and all other sets we are listening to don't have + if (xInfo->hasPropertyByName(PROPERTY_WIDTH)) + disposingColumnModel(Source); + } + + // our frame ? + Reference< ::com::sun::star::frame::XFrame > xSourceFrame(Source.Source, UNO_QUERY); + if (((::com::sun::star::frame::XFrame*)xSourceFrame.get() == (::com::sun::star::frame::XFrame*)m_xCurrentFrame.get()) && m_xCurrentFrame.is()) + m_xCurrentFrame->removeFrameActionListener((::com::sun::star::frame::XFrameActionListener*)this); +} + +// ----------------------------------------------------------------------- +void SbaXDataBrowserController::propertyChange(const PropertyChangeEvent& evt) +{ + Reference< XPropertySet > xSource(evt.Source, UNO_QUERY); + if (!xSource.is()) + return; + + ::vos::OGuard aGuard(Application::GetSolarMutex()); + // the IsModified changed to sal_False ? + if ( (evt.PropertyName.equals(PROPERTY_ISMODIFIED)) + && (::comphelper::getBOOL(evt.NewValue) == sal_False) + ) + { // -> the current field isn't modified anymore, too + m_bCurrentlyModified = sal_False; + InvalidateFeature(::rtl::OUString::createFromAscii(".uno:Save")); + InvalidateFeature(ID_BROWSER_UNDO); + } + + // switching to a new record ? + if ( (evt.PropertyName.equals(PROPERTY_ISNEW)) + && (::comphelper::getBOOL(evt.NewValue) == sal_True) + ) + { + if (::comphelper::getINT32(xSource->getPropertyValue(PROPERTY_ROWCOUNT)) == 0) + // if we're switching to a new record and didn't have any records before we need to invalidate + // all slots (as the cursor was invalid before the mode change and so the slots were disabled) + InvalidateAll(); + } + + // the filter or the sort criterias have changed ? -> update our parser + if (m_xParser.is()) + { + if (evt.PropertyName.equals(PROPERTY_ACTIVECOMMAND)) + { + DO_SAFE( m_xParser->setQuery(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new query to my parser !" ); + } + else if (evt.PropertyName.equals(PROPERTY_FILTER)) + { + if (m_xParser->getFilter() != ::comphelper::getString(evt.NewValue)) + { + DO_SAFE( m_xParser->setFilter(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new filter to my parser !" ); + } + InvalidateFeature(ID_BROWSER_REMOVEFILTER); + } + else if (evt.PropertyName.equals(PROPERTY_ORDER)) + { + if (m_xParser->getOrder() != ::comphelper::getString(evt.NewValue)) + { + DO_SAFE( m_xParser->setOrder(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new order to my parser !" ); + } + InvalidateFeature(ID_BROWSER_REMOVEFILTER); + } + } + + // a new record count ? -> may be our search availability has changed + if (evt.PropertyName.equals(PROPERTY_ROWCOUNT)) + InvalidateFeature(ID_BROWSER_SEARCH); +} + +//------------------------------------------------------------------------ +void SbaXDataBrowserController::modified(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException ) +{ + m_bCurrentlyModified = sal_True; + // das muss vom ::com::sun::star::form::GridControl kommen + InvalidateFeature(::rtl::OUString::createFromAscii(".uno:Save")); + InvalidateFeature(ID_BROWSER_UNDO); +} + +// ----------------------------------------------------------------------- +void SbaXDataBrowserController::elementInserted(const ::com::sun::star::container::ContainerEvent& evt) throw( RuntimeException ) +{ + Reference< XPropertySet > xNewColumn(*(Reference< XPropertySet > *)evt.Element.getValue()); + AddColumnListener(xNewColumn); +} + +// ----------------------------------------------------------------------- +void SbaXDataBrowserController::elementRemoved(const ::com::sun::star::container::ContainerEvent& evt) throw( RuntimeException ) +{ + Reference< XPropertySet > xOldColumn(*(Reference< XPropertySet > *)evt.Element.getValue()); + RemoveColumnListener(xOldColumn); +} + +// ----------------------------------------------------------------------- +void SbaXDataBrowserController::elementReplaced(const ::com::sun::star::container::ContainerEvent& evt) throw( RuntimeException ) +{ + Reference< XPropertySet > xOldColumn(*(Reference< XPropertySet > *)evt.ReplacedElement.getValue()); + RemoveColumnListener(xOldColumn); + + Reference< XPropertySet > xNewColumn(*(Reference< XPropertySet > *)evt.Element.getValue()); + AddColumnListener(xNewColumn); +} + +// ----------------------------------------------------------------------- +void SbaXDataBrowserController::attachFrame(const Reference< ::com::sun::star::frame::XFrame > & xFrame) throw( RuntimeException ) +{ + if (m_xCurrentFrame.is()) + m_xCurrentFrame->removeFrameActionListener((::com::sun::star::frame::XFrameActionListener*)this); + + m_xCurrentFrame = xFrame; + if (m_xCurrentFrame.is()) + { + m_xCurrentFrame->addFrameActionListener((::com::sun::star::frame::XFrameActionListener*)this); + m_bFrameUiActive = m_xCurrentFrame->isActive(); + } +} + +// ----------------------------------------------------------------------- +sal_Bool SbaXDataBrowserController::suspend(sal_Bool bSuspend) throw( RuntimeException ) +{ + m_bSuspending = sal_True; + + // have a pending open operation ? + if (PendingLoad()) + { + ::vos::OGuard aGuard(Application::GetSolarMutex()); + if (m_nPendingLoadFinished != 0) + { // clean up directly. Otherwise there may be a pending asynchronous call + // to OnOpenFinishedMainThread, which won't be executed before we leave + // this method. Sounds like a classic infinite loop. + Application::RemoveUserEvent(m_nPendingLoadFinished); + LINK(this, SbaXDataBrowserController, OnOpenFinishedMainThread).Call(NULL); + } + else + { // set m_bClosingKillOpen to ensure that the our termination handler reacts according + // it's context + m_bClosingKillOpen = sal_True; + + // normally we would now just wait for termination of the load thread, but there is a small problem : + // In the current thread the global solar mutex is locked (that's for sure). If the loading of the + // form tries to acquire (blocking) the solar mutex, too, and we loop waiting for the other thread + // we have a classic deadlock. And bet your ass that ANYBODY in the foreign thread tries to lock + // the solar mutex. Almost all the UNO-capsules around normal C++ classes use the solar mutex for + // "thread safety" (which doesn't deserve that name anymore ;), e.g. the ::com::sun::star::util::XNumberFormatter-implementation + // does. + // So we have to do a fake : we tell the loading thread that we aren't interested in the results anymore + // and the thread deletes itself (and the data source) as soon as it is done. As it holds the last + // references to the form (and thus, indirectly, to the grid) they will be cleared as soon as the thread dies. + // So all is fine. Except the small flaw that the form is still loading in the background while the + // window that should display it is already dead. + // If we could release the solar mutex in this thread and block it 'til the loader is finished we could + // solve it in a less dirty way, but uinfortunatelly we don't know how often this thread acquired the mutex. + // With high effort we could reach this with releasing the mutex until a third thread - which has to be + // created - can acquire it.Then we block, the third thread releases the mutex (and dies) and the loader + // thread would be able to finish. But that sounds difficult and fault-prone, so I think it's not worth it ... + ((LoadFormThread*)m_pLoadThread)->SetTerminationHdl(Link()); + // and of course we tell the thread to stop .... + ((LoadFormThread*)m_pLoadThread)->StopIt(); + } + + } + DBG_ASSERT(m_nPendingLoadFinished == 0, "SbaXDataBrowserController::suspend : there shouldn't be a pending load !"); + + m_aAsynClose.CancelCall(); + m_aAsyncGetCellFocus.CancelCall(); + m_aAsyncInvalidateAll.CancelCall(); + + sal_Bool bReturn = SaveData(sal_True, sal_False); + + m_bSuspending = sal_False; + return bReturn; +} +// ----------------------------------------------------------------------- +sal_Bool SbaXDataBrowserController::ImplInvalidateTBItem(sal_uInt16 nId, const FeatureState& rState) +{ + ToolBox* pTB = m_pContent ? m_pContent->getToolBox() : NULL; + if (!pTB || (pTB->GetItemPos(nId) == TOOLBOX_ITEM_NOTFOUND)) + return sal_False; + + pTB->EnableItem(nId, rState.bEnabled); + switch (rState.aState.getValueTypeClass()) + { + case TypeClass_BOOLEAN: + pTB->CheckItem(nId, ::comphelper::getBOOL(rState.aState)); + break; + + case TypeClass_STRING: + if (pTB->GetItemWindow(nId)) + pTB->GetItemWindow(nId)->SetText(::comphelper::getString(rState.aState)); + break; + + case TypeClass_VOID: + break; + + default: + DBG_WARNING("SbaXDataBrowserController::ImplInvalidateTBItem : don't know what to do with the item state !"); + } + return sal_True; +} + +// ----------------------------------------------------------------------- +void SbaXDataBrowserController::ImplBroadcastFeatureState(const ::rtl::OUString& _rFeature, const Reference< ::com::sun::star::frame::XStatusListener > & xListener, sal_Bool _bIgnoreCache) +{ + sal_Int32 nFeat = m_aSupportedFeatures[_rFeature]; + ::com::sun::star::frame::FeatureStateEvent aEvent; + FeatureState aFeatState( GetState(nFeat)); + + // check if we really need to notify the listeners : this method may be called much more often than needed, so check + // the cached state of the feature + sal_Bool bAlreadyCached = (m_aStateCache.find(nFeat) != m_aStateCache.end()); + FeatureState& rCachedState = m_aStateCache[nFeat]; // creates if neccessary + if (bAlreadyCached && !_bIgnoreCache && (rCachedState.bEnabled == aFeatState.bEnabled)) + { // the enabled flag hasn't changed, maybe the state ? + if (rCachedState.aState.getValueTypeClass() == aFeatState.aState.getValueTypeClass()) + { // at least the type of the state hasn't + sal_Bool bEqualValue = sal_False; + switch (rCachedState.aState.getValueTypeClass()) + { + case TypeClass_VOID: + bEqualValue = !aFeatState.aState.hasValue(); + break; + case TypeClass_BOOLEAN: + bEqualValue = ::comphelper::getBOOL(rCachedState.aState) == ::comphelper::getBOOL(aFeatState.aState); + break; + case TypeClass_SHORT: + bEqualValue = ::comphelper::getINT16(rCachedState.aState) == ::comphelper::getINT16(aFeatState.aState); + break; + case TypeClass_LONG: + bEqualValue = ::comphelper::getINT32(rCachedState.aState) == ::comphelper::getINT32(aFeatState.aState); + break; + case TypeClass_STRING: + bEqualValue = ::comphelper::getString(rCachedState.aState).equals(::comphelper::getString(aFeatState.aState)); + break; + default: + DBG_ERROR("SbaXDataBrowserController::ImplBroadcastFeatureState : unknown state type (not implemented yet) !"); + break; + } + if (bEqualValue) + return; + } + } + rCachedState = aFeatState; + + aEvent.FeatureURL.Complete = _rFeature; + if (m_xUrlTransformer.is()) + m_xUrlTransformer->parseStrict(aEvent.FeatureURL); + aEvent.Source = (::com::sun::star::frame::XDispatch*)this; + aEvent.IsEnabled = aFeatState.bEnabled; + aEvent.Requery = aFeatState.bRequery; + aEvent.State = aFeatState.aState; + + // a special listener ? + if (xListener.is()) + xListener->statusChanged(aEvent); + else + { // no -> iterate through all listeners responsible for the ::com::sun::star::util::URL + DispatchIterator iterSearch = m_arrStatusListener.begin(); + DispatchIterator iterEnd = m_arrStatusListener.end(); + + while (iterSearch != iterEnd) + { + DispatchTarget& rCurrent = *iterSearch; + if (rCurrent.aURL.Complete.equals(_rFeature)) + rCurrent.xListener->statusChanged(aEvent); + ++iterSearch; + } + } + + // give the TB a chance + ImplInvalidateTBItem(nFeat, aFeatState); +} + +// ----------------------------------------------------------------------- +void SbaXDataBrowserController::InvalidateFeature(const ::rtl::OUString& rURLPath, const Reference< ::com::sun::star::frame::XStatusListener > & xListener, sal_Bool _bForceBroadcast) +{ + ImplBroadcastFeatureState(rURLPath, xListener, _bForceBroadcast); +} + +// ----------------------------------------------------------------------- +void SbaXDataBrowserController::InvalidateFeature(sal_uInt16 _nId, const Reference< ::com::sun::star::frame::XStatusListener > & _xListener, sal_Bool _bForceBroadcast) +{ + sal_Bool bFound = sal_False; + SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.begin(); + for(;aIter != m_aSupportedFeatures.end();++aIter) + { + if(aIter->second == _nId) + { + ImplBroadcastFeatureState(aIter->first,_xListener, _bForceBroadcast); + bFound = sal_True; + } + } + if(!bFound) + ImplInvalidateTBItem(_nId, GetState(_nId)); +} + +// ----------------------------------------------------------------------- +void SbaXDataBrowserController::InvalidateAll(sal_Bool bAsync) +{ + if (bAsync) + { + m_aAsyncInvalidateAll.Call(); + return; + } + + sal_uInt16 i; + // --------------------------------- + // invalidate all aupported features + SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.begin(); + for(;aIter != m_aSupportedFeatures.end();++aIter) + { + ImplBroadcastFeatureState(aIter->first, Reference< ::com::sun::star::frame::XStatusListener > (), sal_True); + } + + // ------------------------------ + // invalidate all slots in the TB (if any) + ToolBox* pTB = getContent() ? getContent()->getToolBox() : NULL; + if (pTB) + { + for (i=0; i<pTB->GetItemCount(); ++i) + if (pTB->GetItemId(i)) + InvalidateFeature(pTB->GetItemId(i)); + } +} + +// ----------------------------------------------------------------------- +Reference< ::com::sun::star::frame::XDispatch > SbaXDataBrowserController::queryDispatch(const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw( RuntimeException ) +{ + if (aURL.Complete.equals(URL_CONFIRM_DELETION)) + return (::com::sun::star::frame::XDispatch*)this; + + if (m_aSupportedFeatures.find(aURL.Complete) != m_aSupportedFeatures.end()) + return (::com::sun::star::frame::XDispatch*)this; + + return Reference< ::com::sun::star::frame::XDispatch > (); +} + +// ----------------------------------------------------------------------- +Sequence< Reference< ::com::sun::star::frame::XDispatch > > SbaXDataBrowserController::queryDispatches(const Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts) throw( RuntimeException ) +{ + Sequence< Reference< ::com::sun::star::frame::XDispatch > > aReturn; + if (!aDescripts.getLength()) + return aReturn; + + aReturn.realloc(aDescripts.getLength()); + Reference< ::com::sun::star::frame::XDispatch > * pReturn = aReturn.getArray(); + + const ::com::sun::star::frame::DispatchDescriptor* pDescripts = aDescripts.getConstArray(); + for (sal_uInt16 i=0; i<aDescripts.getLength(); ++i, ++pDescripts, ++pReturn) + *pReturn = queryDispatch(pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags); + + return aReturn; +} + +// ----------------------------------------------------------------------- +Reference< ::com::sun::star::frame::XDispatchProvider > SbaXDataBrowserController::getSlaveDispatchProvider(void) throw( RuntimeException ) +{ + return m_xSlaveDispatcher; +} + +// ----------------------------------------------------------------------- +void SbaXDataBrowserController::setSlaveDispatchProvider(const Reference< ::com::sun::star::frame::XDispatchProvider > & _xNewProvider) throw( RuntimeException ) +{ + m_xSlaveDispatcher = _xNewProvider; +} + +// ----------------------------------------------------------------------- +Reference< ::com::sun::star::frame::XDispatchProvider > SbaXDataBrowserController::getMasterDispatchProvider(void) throw( RuntimeException ) +{ + return m_xMasterDispatcher; +} + +// ----------------------------------------------------------------------- +void SbaXDataBrowserController::setMasterDispatchProvider(const Reference< ::com::sun::star::frame::XDispatchProvider > & _xNewProvider) throw( RuntimeException ) +{ + m_xMasterDispatcher = _xNewProvider; +} + +// ----------------------------------------------------------------------- +void SbaXDataBrowserController::dispatch(const ::com::sun::star::util::URL& aURL, const Sequence< PropertyValue >& aArgs) +{ + SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find(aURL.Complete); + if (aIter != m_aSupportedFeatures.end()) + Execute(aIter->second); +} + +// ----------------------------------------------------------------------- +void SbaXDataBrowserController::addStatusListener(const Reference< ::com::sun::star::frame::XStatusListener > & aListener, const ::com::sun::star::util::URL& aURL) +{ + // remeber the listener together with the ::com::sun::star::util::URL + m_arrStatusListener.insert(m_arrStatusListener.end(), DispatchTarget(aURL, aListener)); + + // initially broadcast the state + InvalidateFeature(aURL.Complete, aListener, sal_True); + // force the new state to be broadcasted to the new listener +} + +// ----------------------------------------------------------------------- +void SbaXDataBrowserController::removeStatusListener(const Reference< ::com::sun::star::frame::XStatusListener > & aListener, const ::com::sun::star::util::URL& aURL) +{ + DispatchIterator iterSearch = m_arrStatusListener.begin(); + DispatchIterator iterEnd = m_arrStatusListener.end(); + + sal_Bool bRemoveForAll = (aURL.Complete.getLength() == 0); + while (iterSearch != iterEnd) + { + DispatchTarget& rCurrent = *iterSearch; + if ( (rCurrent.xListener == aListener) + && ( bRemoveForAll + || (rCurrent.aURL.Complete.equals(aURL.Complete)) + ) + ) + { + if (!bRemoveForAll) + { // remove the listener only for the given ::com::sun::star::util::URL, so we can exit the loop after deletion + m_arrStatusListener.erase(iterSearch); + break; + } + else + { // we have to remove the listener for all URLs, so a simple erase isn't sufficient (as the iterator may be invalid then) + sal_Int32 nOffset = iterSearch - m_arrStatusListener.begin(); + m_arrStatusListener.erase(iterSearch); + iterSearch = m_arrStatusListener.begin() + nOffset; + iterEnd = m_arrStatusListener.end(); + } + } + else + ++iterSearch; + } + + SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find(aURL.Complete); + if (aIter != m_aSupportedFeatures.end()) + { // clear the cache for that feature + StateCacheIterator aCachePos = m_aStateCache.find(aIter->second); + if (aCachePos != m_aStateCache.end()) + m_aStateCache.erase(aCachePos); + } +} + +// ----------------------------------------------------------------------- +void SbaXDataBrowserController::dispose() +{ + // say our dispose listeners goodbye + ::com::sun::star::lang::EventObject aEvt; + aEvt.Source = (XWeak*)(::cppu::OWeakObject*)this; + m_aDisposeListeners.disposeAndClear(aEvt); + + // our status listeners, too + while (m_arrStatusListener.size() > 0) + { + DispatchIterator iterCurrent = m_arrStatusListener.begin(); + + DispatchTarget& rCurrent = *iterCurrent; + ::com::sun::star::lang::EventObject aDisposeEvent; + aDisposeEvent.Source = (::com::sun::star::lang::XComponent*)this; + +#ifdef DEBUG + sal_Int32 nSize = m_arrStatusListener.size(); +#endif + rCurrent.xListener->disposing(aDisposeEvent); + DBG_ASSERT(nSize > m_arrStatusListener.size(), "SbaXDataBrowserController::dispose : the listener did not call removeStatusListener !"); + // in disposing the status listener should remove itself via removeStatusListener, therein we remove it from + // m_arrStatusListener, so the size should have decreased. + } + + // check out from all the objects we are listening + // the frame + if (m_xCurrentFrame.is()) + m_xCurrentFrame->removeFrameActionListener((::com::sun::star::frame::XFrameActionListener*)this); + + if (!PendingLoad()) + { + // don't do the removeXxxListener calls if there is a pending load, this may lead to a deadlock : + // as in this thread the SolarMutex is locked (that's for sure) and removeXxxListener locks + // the form's mutex. But in the loading thread both mutexes are acquired in reverse order. + // That's no problem that we don't remove ourself here, as the load thread is responsible for the form + // at the moment. So if the loading is finished, the form will be disposed (by the load thread), and + // we get the "disposing" event where we can do the removeXxxListener calls. + // The alternative for this handling would be that the form has two mutexes : one for handling it's + // listeners and properties and so on, on for it's pure cursor actions + + // the data source + Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); + if (xFormSet.is()) + { + xFormSet->removePropertyChangeListener(PROPERTY_ISNEW, (XPropertyChangeListener*)this); + xFormSet->removePropertyChangeListener(PROPERTY_ISMODIFIED, (XPropertyChangeListener*)this); + xFormSet->removePropertyChangeListener(PROPERTY_ROWCOUNT, (XPropertyChangeListener*)this); + xFormSet->removePropertyChangeListener(PROPERTY_ACTIVECOMMAND, (XPropertyChangeListener*)this); + xFormSet->removePropertyChangeListener(PROPERTY_ORDER, (XPropertyChangeListener*)this); + xFormSet->removePropertyChangeListener(PROPERTY_FILTER, (XPropertyChangeListener*)this); + xFormSet->removePropertyChangeListener(PROPERTY_APPLYFILTER, (XPropertyChangeListener*)this); + } + + Reference< ::com::sun::star::sdb::XSQLErrorBroadcaster > xFormError(getRowSet(), UNO_QUERY); + if (xFormError.is()) + xFormError->removeSQLErrorListener((::com::sun::star::sdb::XSQLErrorListener*)this); + + Reference< ::com::sun::star::form::XLoadable > xLoadable(getRowSet(), UNO_QUERY); + if (xLoadable.is()) + xLoadable->removeLoadListener(this); + + Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xFormParameter(getRowSet(), UNO_QUERY); + if (xFormParameter.is()) + xFormParameter->removeParameterListener((::com::sun::star::form::XDatabaseParameterListener*)this); + } + + removeModelListeners(getControlModel()); + + if (m_pContent) + { + removeControlListeners(m_pContent->getGridControl()); + // don't delete explicitly, this is done by the owner (and user) of this controller (me hopes ...) + m_pContent = NULL; + } + + if(m_aInvalidateClipboard.IsActive()) + m_aInvalidateClipboard.Stop(); + + // dispose the data source + // if there is a pending load we decided to give the responsibility for the data source to the open thread + // (see ::suspend) + if (!PendingLoad()) + { + Reference< ::com::sun::star::lang::XComponent > xDataSourceComponent(m_xRowSet, UNO_QUERY); + if (xDataSourceComponent.is()) + xDataSourceComponent->dispose(); + } +} + +// ----------------------------------------------------------------------- +void SbaXDataBrowserController::addEventListener(const Reference< ::com::sun::star::lang::XEventListener > & aListener) +{ + m_aDisposeListeners.addInterface(aListener); +} + +// ----------------------------------------------------------------------- +void SbaXDataBrowserController::removeEventListener(const Reference< ::com::sun::star::lang::XEventListener > & aListener) +{ + m_aDisposeListeners.removeInterface(aListener); +} + +//------------------------------------------------------------------------------ +void SbaXDataBrowserController::frameAction(const ::com::sun::star::frame::FrameActionEvent& aEvent) throw( RuntimeException ) +{ + if ((::com::sun::star::frame::XFrame*)aEvent.Frame.get() == (::com::sun::star::frame::XFrame*)m_xCurrentFrame.get()) + switch (aEvent.Action) + { + case ::com::sun::star::frame::FrameAction_FRAME_UI_ACTIVATED: + m_bFrameUiActive = sal_True; + // ensure that the active cell (if any) has the focus + m_aAsyncGetCellFocus.Call(); + // start the clipboard timer + if (m_pContent && m_pContent->getVclControl() && !m_aInvalidateClipboard.IsActive()) + { + m_aInvalidateClipboard.SetTimeout(300); + m_aInvalidateClipboard.Start(); + } + break; + case ::com::sun::star::frame::FrameAction_FRAME_UI_DEACTIVATING: + m_bFrameUiActive = sal_False; + // stop the clipboard invalidator + if (m_pContent && m_pContent->getVclControl() && m_aInvalidateClipboard.IsActive()) + { + m_aInvalidateClipboard.Stop(); + LINK(this, SbaXDataBrowserController, OnInvalidateClipboard).Call(NULL); + } + // remove the "get cell focus"-event + m_aAsyncGetCellFocus.CancelCall(); + break; + } +} + +//------------------------------------------------------------------------------ +void SbaXDataBrowserController::errorOccured(const ::com::sun::star::sdb::SQLErrorEvent& aEvent) throw( RuntimeException ) +{ + ::vos::OGuard aGuard(Application::GetSolarMutex()); + if (::comphelper::isAssignableFrom(aEvent.Reason.getValueType(),::getCppuType((const SQLException*)0))) + { + ::vos::OGuard aGuard(Application::GetSolarMutex()); + SvxDBMsgBox aDlg(NULL, *(SQLException*)aEvent.Reason.getValue()); + aDlg.Execute(); + } + if (m_nFormActionNestingLevel) + m_bErrorOccured = true; +} + +//------------------------------------------------------------------------------ +sal_Bool SbaXDataBrowserController::approveParameter(const ::com::sun::star::form::DatabaseParameterEvent& aEvent) throw( RuntimeException ) +{ + if (aEvent.Source != getRowSet()) + { + // not my data source -> allow anything + DBG_ERROR("SbaXDataBrowserController::approveParameter : invalid event source !"); + return sal_True; + } + + Reference< ::com::sun::star::container::XIndexAccess > xParameters = aEvent.Parameters; + ::vos::OClearableGuard aGuard(Application::GetSolarMutex()); + // this may be executed in a non-main thread and we want to use vcl ... + Window* pParent = Application::GetDefDialogParent(); + // don't use the content as parent if it isn't visible + // (and don't use NULL as parent : this may be displayed in the beamer and really shouldn't be task-local) + // 69297 - FS - 25.10.99 + if (m_pContent && m_pContent->IsVisible()) + pParent = m_pContent; + + Reference< XConnection > xConn; + Reference< XRowSet > xForm(aEvent.Source, UNO_QUERY); + if (xForm.is()) + xConn = ::dbtools::getConnection(xForm); + FmEnterParamDlg aDlg(pParent, xParameters, xConn); + if (aDlg.Execute() != RET_OK) + { + m_bLoadCanceled = sal_True; + return sal_False; + } + + return sal_True; +} + +//------------------------------------------------------------------------------ +void SbaXDataBrowserController::loaded(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException ) +{ + // not interested in + // we're loading within an separate thread and have a handling for it's "finished event" +} + +//------------------------------------------------------------------------------ +void SbaXDataBrowserController::unloading(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException ) +{ + // not interested in +} + +//------------------------------------------------------------------------------ +void SbaXDataBrowserController::unloaded(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException ) +{ + InvalidateAll(sal_True); + // do this asynchron, there are other listeners reacting on this message ... + // (it's a little hack : the grid columns are listening to this event, too, and their bound field may + // change as a reaction on that event. as we have no chance to be notified of this change (which is + // the one we're interested in) we give them time to do what they want to before invalidating our + // bound-field-dependent slots .... +} + +//------------------------------------------------------------------------------ +void SbaXDataBrowserController::reloading(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException ) +{ + // not interested in +} + +//------------------------------------------------------------------------------ +void SbaXDataBrowserController::reloaded(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException ) +{ + InvalidateAll(sal_True); + // do this asynchron, there are other listeners reacting on this message ... + // (it's a little hack : the grid columns are listening to this event, too, and their bound field may + // change as a reaction on that event. as we have no chance to be notified of this change (which is + // the one we're interested in) we give them time to do what they want to before invalidating our + // bound-field-dependent slots .... +} + +//------------------------------------------------------------------------------ +sal_Bool SbaXDataBrowserController::approveReset(const ::com::sun::star::lang::EventObject& rEvent) throw( RuntimeException ) +{ + return sal_True; +} + +//------------------------------------------------------------------------------ +void SbaXDataBrowserController::resetted(const ::com::sun::star::lang::EventObject& rEvent) throw( RuntimeException ) +{ + DBG_ASSERT(rEvent.Source == getControlModel(), "SbaXDataBrowserController::resetted : where did this come from ?"); + m_bCurrentlyModified = sal_False; +} + +//------------------------------------------------------------------------------ +sal_Bool SbaXDataBrowserController::confirmDelete(const ::com::sun::star::sdb::RowChangeEvent& aEvent) throw( RuntimeException ) +{ + if (QueryBox(m_pContent, ModuleRes(QUERY_BRW_DELETE_ROWS)).Execute() != RET_YES) + return sal_False; + + return sal_True; +} + +//------------------------------------------------------------------------------ +void SbaXDataBrowserController::EmptyWindow() +{ + // dispatch en empty ::com::sun::star::util::URL so we will be cleaned up + Reference< ::com::sun::star::frame::XDispatchProvider > xProvider(m_xCurrentFrame, UNO_QUERY); + if (xProvider.is()) + { + Reference< ::com::sun::star::frame::XDispatch > xDispatcher = xProvider->queryDispatch(::com::sun::star::util::URL(), m_xCurrentFrame->getName(), 0); + if (xDispatcher.is()) + xDispatcher->dispatch(::com::sun::star::util::URL(), Sequence< PropertyValue >()); + } +} + +//------------------------------------------------------------------------------ +void SbaXDataBrowserController::AddSupportedFeatures() +{ + // add all supported features + m_aSupportedFeatures[ ::rtl::OUString::createFromAscii(".uno:Copy")] = ID_BROWSER_COPY; + m_aSupportedFeatures[ ::rtl::OUString::createFromAscii(".uno:Cut")] = ID_BROWSER_CUT; + m_aSupportedFeatures[ ::rtl::OUString::createFromAscii(".uno:EditDoc")] = ID_BROWSER_EDITDOC; + m_aSupportedFeatures[ ::rtl::OUString::createFromAscii(".uno:FormSlots/undoRecord")] = ID_BROWSER_UNDORECORD; + m_aSupportedFeatures[ ::rtl::OUString::createFromAscii(".uno:Paste")] = ID_BROWSER_PASTE; + m_aSupportedFeatures[ ::rtl::OUString::createFromAscii(".uno:Redo")] = ID_BROWSER_REDO; + m_aSupportedFeatures[ ::rtl::OUString::createFromAscii(".uno:Save")] = ID_BROWSER_SAVEDOC; + m_aSupportedFeatures[ ::rtl::OUString::createFromAscii(".uno:Undo")] = ID_BROWSER_UNDO; +} + +//------------------------------------------------------------------------------ +FeatureState SbaXDataBrowserController::GetState(sal_uInt16 nId) +{ + FeatureState aReturn; + // (disabled automatically) + + try + { + // no chance without a view + if (!m_pContent || !m_pContent->getVclControl()) + return aReturn; + // no chance without valid models + if (isValid() && !isValidCursor()) + return aReturn; + // no chance while loading the form + if (PendingLoad()) + return aReturn; + + switch (nId) + { + case ID_BROWSER_SEARCH: + { + Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); + sal_Int32 nCount = ::comphelper::getINT32(xFormSet->getPropertyValue(PROPERTY_ROWCOUNT)); + aReturn.bEnabled = nCount != 0; + } + break; + + case ID_BROWSER_COPY: + case ID_BROWSER_CUT: + case ID_BROWSER_PASTE: + { + DbCellControllerRef xCurrentController = m_pContent->getVclControl()->Controller(); + if (xCurrentController.Is() && xCurrentController->ISA(DbEditCellController)) + { + Edit& rEdit = (Edit&)xCurrentController->GetWindow(); + sal_Bool bHasLen = (rEdit.GetSelection().Len() != 0); + sal_Bool bIsReadOnly = rEdit.IsReadOnly(); + switch (nId) + { + case ID_BROWSER_CUT : aReturn.bEnabled = m_bFrameUiActive && bHasLen && !bIsReadOnly; break; + case SID_COPY : aReturn.bEnabled = m_bFrameUiActive && bHasLen; break; + case ID_BROWSER_PASTE : aReturn.bEnabled = m_bFrameUiActive && !bIsReadOnly && Clipboard::HasFormat(FORMAT_STRING); break; + } + } + } + break; + + case ID_BROWSER_SORTUP: + case ID_BROWSER_SORTDOWN: + case ID_BROWSER_AUTOFILTER: + { + // a native statement can't be filtered or sorted + if (!m_xParser.is()) + break; + + Reference< XPropertySet > xCurrentField = getBoundField(); + if (!xCurrentField.is()) + break; + + aReturn.bEnabled = ::comphelper::getBOOL(xCurrentField->getPropertyValue(PROPERTY_ISSEARCHABLE)); + } + break; + + case ID_BROWSER_ORDERCRIT: + case ID_BROWSER_FILTERCRIT: + // we are not in the handle column + aReturn.bEnabled = m_pContent->getVclControl()->GetCurColumnId() != 0; + // a native statement can't be filtered or sorted + aReturn.bEnabled &= m_xParser.is(); + break; + + case ID_BROWSER_REMOVEFILTER: + if (!m_xParser.is()) + break; + // any filter or sort order set ? + aReturn.bEnabled = m_xParser->getFilter().len() || m_xParser->getOrder().len(); + break; + + case ID_BROWSER_REFRESH: + aReturn.bEnabled = isValidCursor(); + break; + + case ID_BROWSER_REDO: + aReturn.bEnabled = sal_False; // simply forget it ;). no redo possible. + break; + + case ID_BROWSER_UNDO: + case ID_BROWSER_SAVEDOC: + { + if (!m_bCurrentlyModified) + { + Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); + if (xFormSet.is()) + aReturn.bEnabled = ::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ISMODIFIED)); + } + else + aReturn.bEnabled = sal_True; + + aReturn.aState <<= ::rtl::OUString((ID_BROWSER_UNDO == nId) ? m_sStateUndoRecord : m_sStateSaveRecord); + } + break; + case ID_BROWSER_EDITDOC: + { + // check if it is available + Reference< XPropertySet > xDataSourceSet(getRowSet(), UNO_QUERY); + if (!xDataSourceSet.is()) + break; // no datasource -> no edit mode + + sal_Int32 nDataSourcePrivileges = ::comphelper::getINT32(xDataSourceSet->getPropertyValue(PROPERTY_PRIVILEGES)); + sal_Bool bInsertAllowedAndPossible = ((nDataSourcePrivileges & ::com::sun::star::sdbcx::Privilege::INSERT) != 0) && ::comphelper::getBOOL(xDataSourceSet->getPropertyValue(::rtl::OUString::createFromAscii("AllowInserts"))); + sal_Bool bUpdateAllowedAndPossible = ((nDataSourcePrivileges & ::com::sun::star::sdbcx::Privilege::UPDATE) != 0) && ::comphelper::getBOOL(xDataSourceSet->getPropertyValue(::rtl::OUString::createFromAscii("AllowUpdates"))); + sal_Bool bDeleteAllowedAndPossible = ((nDataSourcePrivileges & ::com::sun::star::sdbcx::Privilege::DELETE) != 0) && ::comphelper::getBOOL(xDataSourceSet->getPropertyValue(::rtl::OUString::createFromAscii("AllowDeletes"))); + if (!bInsertAllowedAndPossible && !bUpdateAllowedAndPossible && !bDeleteAllowedAndPossible) + break; // no insert/update/delete -> no edit mode + + if (!isValidCursor()) + break; // no cursor -> no edit mode + + aReturn.bEnabled = sal_True; + + sal_Int16 nGridMode = m_pContent->getVclControl()->GetOptions(); + aReturn.aState = ::comphelper::makeBoolAny(nGridMode > DbGridControl::OPT_READONLY); + } + break; + case ID_BROWSER_FILTERED: + { + aReturn.bEnabled = sal_False; + Reference< XPropertySet > xActiveSet(getRowSet(), UNO_QUERY); + ::rtl::OUString aFilter = ::comphelper::getString(xActiveSet->getPropertyValue(PROPERTY_FILTER)); + if (aFilter.len()) + { + aReturn.aState = xActiveSet->getPropertyValue(PROPERTY_APPLYFILTER); + aReturn.bEnabled = sal_True; + } + else + { + aReturn.aState = ::comphelper::makeBoolAny(sal_False); + aReturn.bEnabled = sal_False; + } + } + break; + } + } + catch(Exception& e) + { +#if DBG_UTIL + String sMessage("SbaXDataBrowserController::GetState(", RTL_TEXTENCODING_ASCII_US); + sMessage += String::CreateFromInt32(nId); + sMessage.AppendAscii(") : catched an exception ! message : "); + sMessage += (const sal_Unicode*)e.Message; + DBG_ERROR(ByteString(sMessage, gsl_getSystemTextEncoding()).GetBuffer()); +#else + e; // make compiler happy +#endif + } + + return aReturn; +} + +//------------------------------------------------------------------------------ +void SbaXDataBrowserController::ExecuteFilterSortCrit(sal_Bool bFilter) +{ + if (!SaveModified()) + return; + + // TODO there is no filter dialog yet + Reference< ::com::sun::star::data::XDatabaseDialogs > xDlgs(m_xParser, UNO_QUERY); + if (!xDlgs.is()) + return; + + Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); + + // no condition for searching + if (getRowSet()->isBeforeFirst() || getRowSet()->isAfterLast() || + getRowSet()->rowDeleted()) + return; + + Reference< ::com::sun::star::container::XNamed > xField; + Reference< XPropertySet > xColSet = getBoundField(); + xField = Reference< ::com::sun::star::container::XNamed > (xColSet, UNO_QUERY); + + // auslesen der Searchflags + if (xColSet.is() && !::comphelper::getBOOL(xColSet->getPropertyValue(PROPERTY_ISSEARCHABLE))) + xField = NULL; + + ::rtl::OUString sOldVal = bFilter ? m_xParser->getFilter() : m_xParser->getOrder(); + try + { + if (bFilter) + xDlgs->executeFilter(xField); + else + xDlgs->executeSort(xField); + } + catch(...) + { + return; + } + ; + + ::rtl::OUString sNewVal = bFilter ? m_xParser->getFilter() : m_xParser->getOrder(); + sal_Bool bOldFilterApplied(sal_False); + if (bFilter) + { + try { bOldFilterApplied = ::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_APPLYFILTER)); } catch(...) { } ; + } + + if (sOldVal.equals(sNewVal)) + // nothing to be done + return; + + { + WaitObject aWO(getContent()); + try + { + if (bFilter) + { + xFormSet->setPropertyValue(PROPERTY_FILTER, makeAny(m_xParser->getFilter())); + xFormSet->setPropertyValue(PROPERTY_APPLYFILTER, ::comphelper::makeBoolAny(sal_Bool(sal_True))); + } + else + xFormSet->setPropertyValue(PROPERTY_ORDER,makeAny( m_xParser->getOrder())); + + Reference< ::com::sun::star::form::XLoadable > xReload(xFormSet, UNO_QUERY); + FormErrorHelper aReportError(this); + xReload->reload(); + } + catch(...) + { + } + ; + } + + if (errorOccured()) + { + // synchronize the parser with the form + Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); + if (bFilter) + { + xFormSet->setPropertyValue(PROPERTY_FILTER, makeAny(sOldVal)); + xFormSet->setPropertyValue(PROPERTY_APPLYFILTER, ::comphelper::makeBoolAny(bOldFilterApplied)); + DO_SAFE( m_xParser->setFilter(sOldVal), "SbaXDataBrowserController::ExecuteFilterSortCrit : could not restore the old filter of my parser !" ); + } + else + { + xFormSet->setPropertyValue(PROPERTY_ORDER, makeAny(sOldVal)); + DO_SAFE( m_xParser->setOrder(sOldVal), "SbaXDataBrowserController::ExecuteFilterSortCrit : could not restore the old order of my parser !" ); + } + + try + { + Reference< ::com::sun::star::form::XLoadable > xReload(xFormSet, UNO_QUERY); + xReload->reload(); + } + catch(...) + { + } + ; + } + InvalidateFeature(ID_BROWSER_REMOVEFILTER); +} + +//------------------------------------------------------------------------------ +void SbaXDataBrowserController::ExecuteSearch() +{ + // calculate the control source of the active field + Reference< ::com::sun::star::form::XGrid > xGrid(m_pContent->getGridControl(), UNO_QUERY); + DBG_ASSERT(xGrid.is(), "SbaXDataBrowserController::ExecuteSearch : the control should have an ::com::sun::star::form::XGrid interface !"); + + Reference< ::com::sun::star::form::XGridPeer > xGridPeer(m_pContent->getGridControl()->getPeer(), UNO_QUERY); + Reference< ::com::sun::star::container::XIndexContainer > xColumns = xGridPeer->getColumns(); + DBG_ASSERT(xGridPeer.is() && xColumns.is(), "SbaXDataBrowserController::ExecuteSearch : invalid peer !"); + + sal_Int16 nViewCol = xGrid->getCurrentColumnPosition(); + sal_Int16 nModelCol = m_pContent->View2ModelPos(nViewCol); + + Reference< XPropertySet > xCurrentCol = *(Reference< XPropertySet > *)xColumns->getByIndex(nModelCol).getValue(); + String sActiveField = ::comphelper::getString(xCurrentCol->getPropertyValue(PROPERTY_CONTROLSOURCE)); + + // the text within the current cell + String sInitialText; + Reference< ::com::sun::star::container::XIndexAccess > xColControls(xGridPeer, UNO_QUERY); + Reference< XInterface > xCurControl(*(Reference< XInterface > *)xColControls->getByIndex(nViewCol).getValue(), UNO_QUERY); + ::rtl::OUString aInitialText; + if (IsSearchableControl(xCurControl, &aInitialText)) + sInitialText = (const sal_Unicode*)aInitialText; + + // prohibit the synchronization of the grid's display with the cursor's position + Reference< XPropertySet > xModelSet(getControlModel(), UNO_QUERY); + DBG_ASSERT(xModelSet.is(), "SbaXDataBrowserController::ExecuteSearch : no model set ?!"); + xModelSet->setPropertyValue(::rtl::OUString::createFromAscii("DisplayIsSynchron"), ::comphelper::makeBoolAny(sal_Bool(sal_False))); + xModelSet->setPropertyValue(::rtl::OUString::createFromAscii("AlwaysShowCursor"), ::comphelper::makeBoolAny(sal_Bool(sal_True))); + xModelSet->setPropertyValue(::rtl::OUString::createFromAscii("CursorColor"), makeAny(sal_Int32(COL_LIGHTRED))); + + Reference< ::com::sun::star::util::XNumberFormatsSupplier > xNFS(::dbtools::getNumberFormats(::dbtools::getConnection(m_xRowSet), sal_True,m_xMultiServiceFacatory)); + + FmSearchDialog dlg(getContent(), sInitialText, String::CreateFromAscii("Standard"), 0, LINK(this, SbaXDataBrowserController, OnSearchContextRequest), + FmSearchDialog::SM_ALLOWSCHEDULE); + dlg.SetActiveField(sActiveField); + + dlg.SetFoundHandler(LINK(this, SbaXDataBrowserController, OnFoundData)); + dlg.SetCanceledNotFoundHdl(LINK(this, SbaXDataBrowserController, OnCanceledNotFound)); + dlg.Execute(); + + // restore the grid's normal operating state + xModelSet->setPropertyValue(::rtl::OUString::createFromAscii("DisplayIsSynchron"), ::comphelper::makeBoolAny(sal_Bool(sal_True))); + xModelSet->setPropertyValue(::rtl::OUString::createFromAscii("AlwaysShowCursor"), ::comphelper::makeBoolAny(sal_Bool(sal_False))); + xModelSet->setPropertyValue(::rtl::OUString::createFromAscii("CursorColor"), Any()); +} + +//------------------------------------------------------------------------------ +void SbaXDataBrowserController::Execute(sal_uInt16 nId) +{ + sal_Bool bSortUp = sal_True; + + switch (nId) + { + case ID_BROWSER_FILTERED: + if (SaveModified()) + { + Reference< XPropertySet > xActiveSet(getRowSet(), UNO_QUERY); + sal_Bool bApplied = ::comphelper::getBOOL(xActiveSet->getPropertyValue(PROPERTY_APPLYFILTER)); + xActiveSet->setPropertyValue(PROPERTY_APPLYFILTER, ::comphelper::makeBoolAny(sal_Bool(!bApplied))); + Reference< ::com::sun::star::form::XLoadable > xReload(xActiveSet, UNO_QUERY); + { + WaitObject aWO(getContent()); + xReload->reload(); + } + } + InvalidateFeature(ID_BROWSER_FILTERED); + break; + case ID_BROWSER_EDITDOC: + { + sal_Int16 nGridMode = m_pContent->getVclControl()->GetOptions(); + if (nGridMode == DbGridControl::OPT_READONLY) + m_pContent->getVclControl()->SetOptions(DbGridControl::OPT_UPDATE | DbGridControl::OPT_INSERT | DbGridControl::OPT_DELETE); + // the options not supported by the data source will be removed automatically + else + { + if (!SaveData(sal_True, sal_False)) + // give the user a chance to save the current record (if neccessary) + break; + + // maybe the user wanted to reject the modified record ? + if (GetState(ID_BROWSER_UNDO).bEnabled) + Execute(ID_BROWSER_UNDO); + + m_pContent->getVclControl()->SetOptions(DbGridControl::OPT_READONLY); + } + InvalidateFeature(ID_BROWSER_EDITDOC); + } + break; + + case ID_BROWSER_SEARCH: + if (SaveData(sal_True, sal_False)) + ExecuteSearch(); + break; + + case ID_BROWSER_COPY: + case ID_BROWSER_CUT: + case ID_BROWSER_PASTE: + { + DbCellControllerRef xCurrentController = m_pContent->getVclControl()->Controller(); + if (!xCurrentController.Is()) + // should be intercepted by GetState. Normally. + // Unfortunately ID_BROWSER_PASTE is a 'fast call' slot, which means it may be executed without checking if it is + // enabled. This would be really deadly herein if the current cell has no controller ... + // (FS - 13.04.99 - #64694#) + return; + + Edit& rEdit = (Edit&)xCurrentController->GetWindow(); + switch (nId) + { + case ID_BROWSER_CUT : rEdit.Cut(); break; + case SID_COPY : rEdit.Copy(); break; + case ID_BROWSER_PASTE : rEdit.Paste(); break; + } + if (ID_BROWSER_CUT == nId || ID_BROWSER_PASTE == nId) + { + xCurrentController->SetModified(); + rEdit.Modify(); + } + } + break; + + case ID_BROWSER_SORTDOWN: + bSortUp = sal_False; + // DON'T break + case ID_BROWSER_SORTUP: + { + if (!SaveModified()) + break; + + if (!isValidCursor()) + break; + + // only one sort order + Reference< XPropertySet > xField(getBoundField(), UNO_QUERY); + if (!xField.is()) + break; + + ::rtl::OUString sOldSort = m_xParser->getOrder(); + sal_Bool bParserSuccess; + HANDLE_SQL_ERRORS( + m_xParser->setOrder(::rtl::OUString()); m_xParser->appendOrderByColumn(xField, bSortUp), + bParserSuccess, + UniString(ModuleRes(SBA_BROWSER_SETTING_ORDER)), + "SbaXDataBrowserController::Execute : catched an exception while composing the new filter !" + ) + + if (bParserSuccess) + { + WaitObject aWO(getContent()); + try + { + Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); + xFormSet->setPropertyValue(PROPERTY_ORDER, makeAny(m_xParser->getOrder())); + + Reference< ::com::sun::star::form::XLoadable > xReload(xFormSet, UNO_QUERY); + FormErrorHelper aReportError(this); + xReload->reload(); + } + catch(...) + { + } + ; + } + if (errorOccured()) + { + // synchronize the parser with the form + Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); + xFormSet->setPropertyValue(PROPERTY_ORDER, makeAny(sOldSort)); + m_xParser->setOrder(sOldSort); + + try + { + Reference< ::com::sun::star::form::XLoadable > xReload(xFormSet, UNO_QUERY); + xReload->reload(); + } + catch(...) + { + } + ; + } + InvalidateFeature(ID_BROWSER_REMOVEFILTER); + } + break; + + case ID_BROWSER_AUTOFILTER: + { + if (!SaveModified()) + break; + + if (!isValidCursor()) + break; + + Reference< XPropertySet > xField(getBoundField(), UNO_QUERY); + if (!xField.is()) + break; + + ::rtl::OUString sOldFilter = m_xParser->getFilter(); + + Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); + sal_Bool bApplied = ::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_APPLYFILTER)); + // do we have a filter but it's not applied ? + // -> completely overwrite it, else append one + if (!bApplied) + { + DO_SAFE( m_xParser->setFilter(::rtl::OUString()), "SbaXDataBrowserController::Execute : catched an exception while resetting the new filter !" ); + } + + sal_Bool bParserSuccess; + HANDLE_SQL_ERRORS( + m_xParser->appendFilterByColumn(xField), + bParserSuccess, + UniString(ModuleRes(SBA_BROWSER_SETTING_FILTER)), + "SbaXDataBrowserController::Execute : catched an exception while composing the new filter !" + ) + + if (bParserSuccess) + { + WaitObject aWO(getContent()); + try + { + Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); + xFormSet->setPropertyValue(PROPERTY_FILTER, makeAny(m_xParser->getFilter())); + xFormSet->setPropertyValue(PROPERTY_APPLYFILTER, ::comphelper::makeBoolAny(sal_Bool(sal_True))); + + Reference< ::com::sun::star::form::XLoadable > xReload(xFormSet, UNO_QUERY); + FormErrorHelper aReportError(this); + xReload->reload(); + } + catch(...) + { + } + ; + } + if (errorOccured()) + { + // synchronize the parser with the form + Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); + xFormSet->setPropertyValue(PROPERTY_FILTER, makeAny(sOldFilter)); + xFormSet->setPropertyValue(PROPERTY_APPLYFILTER, makeAny(bApplied)); + m_xParser->setFilter(sOldFilter); + + try + { + Reference< ::com::sun::star::form::XLoadable > xReload(xFormSet, UNO_QUERY); + xReload->reload(); + } + catch(...) + { + } + ; + } + InvalidateFeature(ID_BROWSER_REMOVEFILTER); + InvalidateFeature(ID_BROWSER_FILTERED); + } + break; + + case ID_BROWSER_ORDERCRIT: + ExecuteFilterSortCrit(sal_False); + break; + + case ID_BROWSER_FILTERCRIT: + ExecuteFilterSortCrit(sal_True); + InvalidateFeature(ID_BROWSER_FILTERED); + break; + + case ID_BROWSER_REMOVEFILTER: + { + if (!SaveModified()) + break; + + // reset the filter and the sort property simutaneously so only _one_ new statement has to be + // sent + Reference< XPropertySet > xSet(getRowSet(), UNO_QUERY); + xSet->setPropertyValue(PROPERTY_FILTER,makeAny(::rtl::OUString())); + xSet->setPropertyValue(PROPERTY_ORDER,makeAny(::rtl::OUString())); + { + WaitObject aWO(getContent()); + try + { + Reference< ::com::sun::star::form::XLoadable > xReload(getRowSet(), UNO_QUERY); + xReload->reload(); + } + catch(...) + { + } + ; + } + InvalidateFeature(ID_BROWSER_REMOVEFILTER); + InvalidateFeature(ID_BROWSER_FILTERED); + } + break; + + case ID_BROWSER_REFRESH: + if (SaveData(sal_True, sal_False)) + { + Reference< ::com::sun::star::form::XLoadable > xReload(getRowSet(), UNO_QUERY); + WaitObject aWO(getContent()); + xReload->reload(); + } + break; + + case ID_BROWSER_SAVEDOC: + { + SaveModified(sal_True); + } + break; + + case ID_BROWSER_UNDO: + { + // restore the cursor state + Reference< XResultSetUpdate > xCursor(getRowSet(), UNO_QUERY); + Reference< XPropertySet > xSet(xCursor, UNO_QUERY); + if (::comphelper::getBOOL(xSet->getPropertyValue(PROPERTY_ISNEW))) + { + xCursor->moveToInsertRow(); + // no need to reset the grid model after we moved to the insert row, this is done implicitly by the + // form + // (and in some cases it may be deadly to do the reset explicitly after the form did it implicitly, + // cause the form's reset may be async, and this leads to some nice deadlock scenarios ....) + } + else + { + xCursor->cancelRowUpdates(); + + // restore the grids state + Reference< ::com::sun::star::form::XReset > xReset(getControlModel(), UNO_QUERY); + if (xReset.is()) + xReset->reset(); + } + + m_bCurrentlyModified = sal_False; + InvalidateFeature(::rtl::OUString::createFromAscii(".uno:Save")); + InvalidateFeature(ID_BROWSER_UNDO); + } + } +} + +//------------------------------------------------------------------------------ +sal_Bool SbaXDataBrowserController::SaveModified(sal_Bool bCommit) +{ + if (bCommit && !CommitCurrent()) // das aktuelle Control committen lassen + return sal_False; + + Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); + sal_Bool bResult = sal_False; + try + { + if (::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ISMODIFIED))) + { + Reference< XResultSetUpdate > xCursor(getRowSet(), UNO_QUERY); + if (::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ISNEW))) + xCursor->insertRow(); + else + xCursor->updateRow(); + } + bResult = sal_True; + } + catch(SQLException&) + { + } + catch(...) + { + DBG_ERROR("SbaXDataBrowserController::SaveModified : could not save the current record !"); + bResult = sal_False; + } + + + + InvalidateFeature(::rtl::OUString::createFromAscii(".uno:Save")); + InvalidateFeature(ID_BROWSER_UNDO); + + return bResult; +} + +//------------------------------------------------------------------------------ +sal_Bool SbaXDataBrowserController::CommitCurrent() +{ + if (!m_pContent) + return sal_True; + + Reference< ::com::sun::star::awt::XControl > xActiveControl(m_pContent->getGridControl()); + Reference< ::com::sun::star::form::XBoundControl > xLockingTest(xActiveControl, UNO_QUERY); + sal_Bool bControlIsLocked = xLockingTest.is() && xLockingTest->getLock(); + sal_Bool bResult = sal_True; + if (xActiveControl.is() && !bControlIsLocked) + { + // zunaechst das Control fragen ob es das IFace unterstuetzt + Reference< ::com::sun::star::form::XBoundComponent > xBoundControl(xActiveControl, UNO_QUERY); + if (!xBoundControl.is()) + xBoundControl = Reference< ::com::sun::star::form::XBoundComponent > (xActiveControl->getModel(), UNO_QUERY); + if (xBoundControl.is() && !xBoundControl->commit()) + return sal_False; + } + return sal_True; +} + +//------------------------------------------------------------------------------ +IMPL_LINK(SbaXDataBrowserController, OnToolBoxSelected, ToolBox*, pToolBox) +{ + Execute(pToolBox->GetCurItemId()); + return 0L; +} + +//------------------------------------------------------------------------------ +void SbaXDataBrowserController::ColumnChanged() +{ + InvalidateFeature(ID_BROWSER_SORTUP); + InvalidateFeature(ID_BROWSER_SORTDOWN); + InvalidateFeature(ID_BROWSER_ORDERCRIT); + InvalidateFeature(ID_BROWSER_FILTERCRIT); + InvalidateFeature(ID_BROWSER_AUTOFILTER); + InvalidateFeature(ID_BROWSER_REMOVEFILTER); +} + +//------------------------------------------------------------------------------ +void SbaXDataBrowserController::SelectionChanged() +{ + InvalidateFeature(ID_BROWSER_INSERT); + InvalidateFeature(ID_BROWSER_UPDATE); + InvalidateFeature(ID_BROWSER_MERGE); +} + +//------------------------------------------------------------------------------ +void SbaXDataBrowserController::CellActivated() +{ + m_aInvalidateClipboard.SetTimeout(300); + m_aInvalidateClipboard.Start(); +} + +//------------------------------------------------------------------------------ +void SbaXDataBrowserController::CellDeactivated() +{ + m_aInvalidateClipboard.Stop(); + LINK(this, SbaXDataBrowserController, OnInvalidateClipboard).Call(NULL); +} + +//------------------------------------------------------------------------------ +IMPL_LINK(SbaXDataBrowserController, OnInvalidateClipboard, void*, EMPTYARG) +{ + InvalidateFeature(ID_BROWSER_CUT); + InvalidateFeature(ID_BROWSER_COPY); + InvalidateFeature(ID_BROWSER_PASTE); + return 0L; +} + +//------------------------------------------------------------------ +sal_uInt16 SbaXDataBrowserController::SaveData(sal_Bool bUI, sal_Bool bForBrowsing) +{ + if (!m_pContent) + return sal_True; + + if (!isValidCursor()) + return sal_True; + + if (bUI && GetState(ID_BROWSER_SAVEDOC).bEnabled) + { + m_pContent->getVclControl()->GrabFocus(); + + QueryBox aQry(m_pContent->getVclControl(), ModuleRes(QUERY_BRW_SAVEMODIFIED)); + if (bForBrowsing) + aQry.AddButton(ResId(RID_STR_NEW_TASK), RET_NEWTASK, + BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON); + + switch (aQry.Execute()) + { + case RET_NO: + Execute(ID_BROWSER_UNDO); + return sal_True; + case RET_CANCEL: + return sal_False; + case RET_NEWTASK: + return RET_NEWTASK; + } + } + + return (sal_uInt16)SaveModified(); +} + +// ------------------------------------------------------------------------- +Reference< XPropertySet > SbaXDataBrowserController::getBoundField(sal_uInt16 nViewPos) const +{ + Reference< XPropertySet > xEmptyReturn; + + // get the current column from the grid + if (nViewPos == (sal_uInt16)-1) + { + Reference< ::com::sun::star::form::XGrid > xGrid(m_pContent->getGridControl(), UNO_QUERY); + if (!xGrid.is()) + return xEmptyReturn; + nViewPos = xGrid->getCurrentColumnPosition(); + } + sal_uInt16 nCurrentCol = m_pContent->View2ModelPos(nViewPos); + if (nCurrentCol == (sal_uInt16)-1) + return xEmptyReturn; + + // get the according column from the model + Reference< ::com::sun::star::container::XIndexContainer > xCols(getControlModel(), UNO_QUERY); + Reference< XPropertySet > xCurrentCol(*(Reference< XInterface > *)xCols->getByIndex(nCurrentCol).getValue(), UNO_QUERY); + if (!xCurrentCol.is()) + return xEmptyReturn; + + Any aBoundField = xCurrentCol->getPropertyValue(PROPERTY_BOUNDFIELD); + if (!aBoundField.hasValue()) + return xEmptyReturn; + + return Reference< XPropertySet > (*(Reference< XInterface > *)aBoundField.getValue(), UNO_QUERY); +} + +//------------------------------------------------------------------------------ +IMPL_LINK(SbaXDataBrowserController, OnSearchContextRequest, FmSearchContext*, pContext) +{ + Reference< ::com::sun::star::container::XIndexAccess > xPeerContainer(getContent()->getGridControl(), UNO_QUERY); + + // check all grid columns for their control source + Reference< ::com::sun::star::container::XIndexAccess > xModelColumns(getFormComponent(), UNO_QUERY); + DBG_ASSERT(xModelColumns.is(), "SbaXDataBrowserController::OnSearchContextRequest : there is a grid control without columns !"); + // the case 'no columns' should be indicated with an empty container, I think ... + DBG_ASSERT(xModelColumns->getCount() >= xPeerContainer->getCount(), "SbaXDataBrowserController::OnSearchContextRequest : impossible : have more view than model columns !"); + + String sFieldList; + for (sal_Int32 nViewPos=0; nViewPos<xPeerContainer->getCount(); ++nViewPos) + { + Reference< XInterface > xCurrentColumn(*(Reference< XInterface > *)xPeerContainer->getByIndex(nViewPos).getValue(), UNO_QUERY); + if (!xCurrentColumn.is()) + continue; + + // can we use this column control fo searching ? + if (!IsSearchableControl(xCurrentColumn)) + continue; + + sal_uInt16 nModelPos = m_pContent->View2ModelPos(nViewPos); + Reference< XPropertySet > xCurrentColModel = *(Reference< XPropertySet > *)xModelColumns->getByIndex(nModelPos).getValue(); + ::rtl::OUString aName = ::comphelper::getString(xCurrentColModel->getPropertyValue(PROPERTY_CONTROLSOURCE)); + + sFieldList += (const sal_Unicode*)aName; + sFieldList += ';'; + + pContext->arrFields.push_back(xCurrentColumn); + } + sFieldList.EraseTrailingChars(';'); + + pContext->xCursor = Reference< XResultSet>(getRowSet(),UNO_QUERY); + pContext->strUsedFields = sFieldList; + + // if the cursor is in a mode other than STANDARD -> reset + Reference< XPropertySet > xCursorSet(pContext->xCursor, UNO_QUERY); + DBG_ASSERT(xCursorSet.is() && !::comphelper::getBOOL(xCursorSet->getPropertyValue(PROPERTY_ISMODIFIED)), + "SbaXDataBrowserController::OnSearchContextRequest : please do not call for cursors with modified rows !"); + if (xCursorSet.is() && ::comphelper::getBOOL(xCursorSet->getPropertyValue(PROPERTY_ISNEW))) + { + Reference< XResultSetUpdate > xUpdateCursor(pContext->xCursor, UNO_QUERY); + xUpdateCursor->moveToCurrentRow(); + } + return pContext->arrFields.size(); +} + +//------------------------------------------------------------------------------ +IMPL_LINK(SbaXDataBrowserController, OnFoundData, FmFoundRecordInformation*, pInfo) +{ + Reference< ::com::sun::star::sdbcx::XRowLocate > xCursor(getRowSet(), UNO_QUERY); + DBG_ASSERT(xCursor.is(), "SbaXDataBrowserController::OnFoundData : shit happens. sometimes. but this is simply impossible !"); + + // move the cursor + xCursor->moveToBookmark(pInfo->aPosition); + + // let the grid snyc it's display with the cursor + Reference< XPropertySet > xModelSet(getControlModel(), UNO_QUERY); + DBG_ASSERT(xModelSet.is(), "SbaXDataBrowserController::OnFoundData : no model set ?!"); + Any aOld = xModelSet->getPropertyValue(::rtl::OUString::createFromAscii("DisplayIsSynchron")); + xModelSet->setPropertyValue(::rtl::OUString::createFromAscii("DisplayIsSynchron"), ::comphelper::makeBoolAny(sal_Bool(sal_True))); + xModelSet->setPropertyValue(::rtl::OUString::createFromAscii("DisplayIsSynchron"), aOld); + + // and move to the field + Reference< ::com::sun::star::container::XIndexAccess > aColumnControls(m_pContent->getGridControl()->getPeer(), UNO_QUERY); + for (sal_uInt16 nViewPos=0; nViewPos<aColumnControls->getCount(); ++nViewPos) + { + Reference< XInterface > xCurrent(*(Reference< XInterface > *)aColumnControls->getByIndex(nViewPos).getValue(), UNO_QUERY); + if (IsSearchableControl(xCurrent)) + if (!pInfo->nFieldPos) + break; + else + --pInfo->nFieldPos; + } + + Reference< ::com::sun::star::form::XGrid > xGrid(m_pContent->getGridControl(), UNO_QUERY); + xGrid->setCurrentColumnPosition(nViewPos); + + return 0; +} + +//------------------------------------------------------------------------------ +IMPL_LINK(SbaXDataBrowserController, OnCanceledNotFound, FmFoundRecordInformation*, pInfo) +{ + Reference< ::com::sun::star::sdbcx::XRowLocate > xCursor(getRowSet(), UNO_QUERY); + + DBG_ASSERT(xCursor.is(), "SbaXDataBrowserController::OnCanceledNotFound : shit happens. sometimes. but this is simply impossible !"); // move the cursor + xCursor->moveToBookmark(pInfo->aPosition); + + // let the grid snyc it's display with the cursor + Reference< XPropertySet > xModelSet(getControlModel(), UNO_QUERY); + DBG_ASSERT(xModelSet.is(), "SbaXDataBrowserController::OnCanceledNotFound : no model set ?!"); + Any aOld = xModelSet->getPropertyValue(::rtl::OUString::createFromAscii("DisplayIsSynchron")); + xModelSet->setPropertyValue(::rtl::OUString::createFromAscii("DisplayIsSynchron"), ::comphelper::makeBoolAny(sal_Bool(sal_True))); + xModelSet->setPropertyValue(::rtl::OUString::createFromAscii("DisplayIsSynchron"), aOld); + + return 0L; +} + +//------------------------------------------------------------------------------ +IMPL_LINK(SbaXDataBrowserController, OnOpenFinishedMainThread, void*, EMPTYARG) +{ + ::vos::OGuard aGuard(Application::GetSolarMutex()); + if (!m_nPendingLoadFinished) + // it's possible that the direct call of this link from within suspend caused this method to be executed + // in another thread while we were waiting for the mutex in this thread + return 0; + m_nPendingLoadFinished = 0; + + m_bLoadCanceled |= ((LoadFormThread*)m_pLoadThread)->WasCanceled(); + delete m_pLoadThread; + m_pLoadThread = NULL; + + FormLoaded(sal_False); + + return 0L; +} + +//------------------------------------------------------------------------------ +IMPL_LINK(SbaXDataBrowserController, OnOpenFinished, void*, EMPTYARG) +{ + ::osl::MutexGuard aCheckGuard(m_aAsyncLoadSafety); + + if (m_bClosingKillOpen) + { + delete m_pLoadThread; + m_pLoadThread = NULL; + } + else + // all cleaning has to run in the main thread, not here (this is called synchronously from the LoadThread) + // so we use an user event + m_nPendingLoadFinished = Application::PostUserEvent(LINK(this, SbaXDataBrowserController, OnOpenFinishedMainThread)); + + return 0L; +} + +//------------------------------------------------------------------------------ +IMPL_LINK(SbaXDataBrowserController, OnAsyncClose, void*, EMPTYARG) +{ + EmptyWindow(); + return 0L; +} + +//------------------------------------------------------------------------------ +IMPL_LINK(SbaXDataBrowserController, OnAsyncGetCellFocus, void*, EMPTYARG) +{ + SbaGridControl* pVclGrid = m_pContent ? m_pContent->getVclControl() : NULL; + // if we have a controller, but the window for the controller doesn't have the focus, we correct this + if (!pVclGrid->IsEditing()) + return 0L; + + if (pVclGrid->HasChildPathFocus()) + pVclGrid->Controller()->GetWindow().GrabFocus(); + + return 0L; +} + +//------------------------------------------------------------------------------ +IMPL_LINK(SbaXDataBrowserController, OnAsyncInvalidateAll, void*, EMPTYARG) +{ + InvalidateAll(sal_False); + return 0L; +} + +//------------------------------------------------------------------------------ +void SbaXDataBrowserController::FormLoaded(sal_Bool /*bWasSynch*/) +{ + if (isValid() && !m_bLoadCanceled) + { + // -------------------------------- + // switch the control to alive mode + m_pContent->getGridControl()->setDesignMode(sal_False); + + // ---------------------------------------------- + // create a parser (needed for filtering/sorting) + try + { + Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); + if (::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_USE_ESCAPE_PROCESSING))) + { // (only if the statement isn't native) + // (it is allowed to use the PROPERTY_ISPASSTHROUGH : _after_ loading a form it is valid) + Reference< ::com::sun::star::sdb::XSQLQueryComposerFactory > xFactory(::dbtools::getConnection(getRowSet()), UNO_QUERY); + if (xFactory.is()) + m_xParser = xFactory->createQueryComposer(); + } + + // initialize the parser with the current sql-statement of the form + if (m_xParser.is()) + { + m_xParser->setQuery(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_ACTIVECOMMAND))); + m_xParser->setFilter(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_FILTER))); + m_xParser->setOrder(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_ORDER))); + } + } + catch(...) + { + DBG_WARNING("SbaXDataBrowserController::Construct : something went wrong while creating the parser !"); + m_xParser = NULL; + // no further handling, we ignore the error + } + ; + + InvalidateAll(); + // ------------------------------- + // start the clipboard invalidator + m_aInvalidateClipboard.SetTimeoutHdl(LINK(this, SbaXDataBrowserController, OnInvalidateClipboard)); + + m_aAsyncGetCellFocus.Call(); + } + else + { + m_aAsynClose.Call(); + } +} + +//------------------------------------------------------------------------------ +void SbaXDataBrowserController::enterFormAction() +{ + if (!m_nFormActionNestingLevel) + // first action -> reset flag + m_bErrorOccured = false; + + ++m_nFormActionNestingLevel; +} + +//------------------------------------------------------------------------------ +void SbaXDataBrowserController::leaveFormAction() +{ + DBG_ASSERT(m_nFormActionNestingLevel > 0, "SbaXDataBrowserController::leaveFormAction : invalid call !"); + --m_nFormActionNestingLevel; +} + +// ------------------------------------------------------------------------- +sal_Bool SbaXDataBrowserController::isValidCursor() const +{ + Reference< ::com::sun::star::sdbcx::XColumnsSupplier > xSupplyCols(m_xRowSet, UNO_QUERY); + if (!xSupplyCols.is()) + return sal_False; + Reference< ::com::sun::star::container::XIndexAccess > xCols(xSupplyCols->getColumns(), UNO_QUERY); + if (!xCols.is() || (xCols->getCount() == 0)) + return sal_False; + return !(m_xRowSet->isBeforeFirst() || m_xRowSet->isAfterLast()) ; +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper* SbaXDataBrowserController::createArrayHelper( ) const +{ + Sequence< Property > aProps; + describeProperties(aProps); + return new cppu::OPropertyArrayHelper(aProps); +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper & SbaXDataBrowserController::getInfoHelper() +{ + return *const_cast<SbaXDataBrowserController*>(this)->getArrayHelper(); +} +//================================================================== +// LoadFormHelper +//================================================================== + +class LoadFormHelper :public ::cppu::WeakImplHelper2< ::com::sun::star::form::XLoadListener, + XRowSetListener> +{ + enum STATE { STARTED, LOADED, POSITIONED, DISPOSED }; + STATE m_eState; + + Reference< XRowSet > m_xForm; + + ::osl::Mutex m_aAccessSafety; + +public: + LoadFormHelper(const Reference< XRowSet > & _rxForm); + + // ::com::sun::star::form::XLoadListener + virtual void SAL_CALL loaded(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException ); + virtual void SAL_CALL unloaded(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException ); + virtual void SAL_CALL unloading(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException ); + virtual void SAL_CALL reloading(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException ); + virtual void SAL_CALL reloaded(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException ); + + // XRowSetListener + virtual void SAL_CALL cursorMoved(const ::com::sun::star::lang::EventObject& event) throw( RuntimeException ); + virtual void SAL_CALL rowChanged(const ::com::sun::star::lang::EventObject& event) throw( RuntimeException ){}; + virtual void SAL_CALL rowSetChanged(const ::com::sun::star::lang::EventObject& event) throw( RuntimeException ){}; + + // ::com::sun::star::lang::XEventListener + virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( RuntimeException ); + + + bool WaitUntilReallyLoaded(bool _bOnlyIfLoaded); + // waits 'til the first positioned event after the loaded event. returns true if successfull, + // false if the form was disposed or unloaded before or while waiting + // if _bOnlyIfLoaded is false and the form isn't loaded already loaded, false will be returned + // (without any wating) + + void cancel(); + +protected: + ~LoadFormHelper(); + + void implDispose(); +}; + +//------------------------------------------------------------------------------ +LoadFormHelper::LoadFormHelper(const Reference< XRowSet > & _rxForm) + :m_xForm(_rxForm) + ,m_eState(STARTED) +{ + Reference< ::com::sun::star::form::XLoadable > (m_xForm, UNO_QUERY)->addLoadListener(this); + m_xForm->addRowSetListener(this); +} + +//------------------------------------------------------------------------------ +LoadFormHelper::~LoadFormHelper() +{ + ::osl::MutexGuard aGuard(m_aAccessSafety); + implDispose(); +} + +//------------------------------------------------------------------------------ +void LoadFormHelper::implDispose() +{ + if (DISPOSED != m_eState) + { + + Reference< ::com::sun::star::form::XLoadable > (m_xForm, UNO_QUERY)->removeLoadListener(this); + m_xForm->removeRowSetListener(this); + m_xForm = NULL; + m_eState = DISPOSED; + } +} + +//------------------------------------------------------------------------------ +void SAL_CALL LoadFormHelper::loaded(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard(m_aAccessSafety); + DBG_ASSERT(m_eState == STARTED || m_eState == DISPOSED, "LoadFormHelper::loaded : wrong call !"); + if (m_eState == STARTED) + m_eState = LOADED; +} + +//------------------------------------------------------------------------------ +void SAL_CALL LoadFormHelper::unloaded(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard(m_aAccessSafety); + DBG_ERROR("LoadFormHelper::unloaded : shouldn't be called !"); + implDispose(); +} + +//------------------------------------------------------------------------------ +void SAL_CALL LoadFormHelper::unloading(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException ) +{ +} + +//------------------------------------------------------------------------------ +void SAL_CALL LoadFormHelper::reloading(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException ) +{ +} + +//------------------------------------------------------------------------------ +void SAL_CALL LoadFormHelper::reloaded(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException ) +{ +} + +//------------------------------------------------------------------------------ +void SAL_CALL LoadFormHelper::cursorMoved(const ::com::sun::star::lang::EventObject& event) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard(m_aAccessSafety); + if (m_eState == LOADED) + m_eState = POSITIONED; +} + +//------------------------------------------------------------------------------ +void SAL_CALL LoadFormHelper::disposing(const ::com::sun::star::lang::EventObject& Source) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard(m_aAccessSafety); + implDispose(); +} + +//------------------------------------------------------------------------------ +void LoadFormHelper::cancel() +{ + implDispose(); +} + +//------------------------------------------------------------------------------ +bool LoadFormHelper::WaitUntilReallyLoaded(bool _bOnlyIfLoaded) +{ + ::osl::ClearableMutexGuard aGuard(m_aAccessSafety); + if (DISPOSED == m_eState) + return false; + + if (_bOnlyIfLoaded && (STARTED == m_eState)) + // we did't get a "loaded" event .... + return false; + + sal_Bool bDone = (POSITIONED == m_eState); + aGuard.clear(); + + while (!bDone) + { + ::osl::MutexGuard aGuard(m_aAccessSafety); + bDone = (POSITIONED == m_eState); + } + + ::osl::MutexGuard aGuard2(m_aAccessSafety); + implDispose(); + + return true; +} + +//================================================================== +// LoadFormThread - a thread for asynchronously loading a form +//================================================================== +//------------------------------------------------------------------------------ +void LoadFormThread::run() +{ + // On instantiation of a SfxCancellable the application is notified and 'switches on' the red stop button. + // Unfortunally this is conditioned with the acquirement of the solar mutex, and the application tries + // only once and ignores the notification if it fails. + // To prevent that we get the solar mutex and _block_ 'til we got it. + // As we are in the 'top level execution' of this thread (with a rather small stack and no other mutexes locked) + // we shouldn't experience problems with deadlocks ... + ::vos::OClearableGuard aSolarGuard(Application::GetSolarMutex()); + ThreadStopper* pStopper = new ThreadStopper(this, m_sStopperCaption); + aSolarGuard.clear(); + + // we're not canceled yet + ::osl::ClearableMutexGuard aResetGuard(m_aAccessSafety); + m_bCanceled = sal_False; + aResetGuard.clear(); + + LoadFormHelper* pHelper = new LoadFormHelper(m_xRowSet); + pHelper->acquire(); + + // start it + bool bErrorOccured = false; + try + { + Reference< ::com::sun::star::form::XLoadable > xLoad(m_xRowSet, UNO_QUERY); + Reference< XRowSet > xMove(m_xRowSet, UNO_QUERY); + DBG_ASSERT(xLoad.is() && xMove.is(), "LoadFormThread::run : invalid cursor !"); + xLoad->load(); + // go to the first record if the load was successfull. + Reference< ::com::sun::star::sdbcx::XColumnsSupplier > xSupplyCols(m_xRowSet, UNO_QUERY); + Reference< ::com::sun::star::container::XNameAccess > xCols = xSupplyCols.is() ? xSupplyCols->getColumns() : Reference< ::com::sun::star::container::XNameAccess > (); + if (xCols.is() && xCols->getElementNames().getLength()) + xMove->first(); + else + bErrorOccured = true; + } + catch(...) + { + bErrorOccured = true; + } + ; + + // check if we were canceled + ::osl::ClearableMutexGuard aTestGuard(m_aAccessSafety); + bool bReallyCanceled = (bool)m_bCanceled; + aTestGuard.clear(); + + bReallyCanceled |= bErrorOccured; + + // the load on the form is "slightly asyncronous" (which isn't covered by it's specification, anyway), so wait + // some time .... + // (though me thinks that the load of the new api is synchronous, so we won't need this LoadFormHelper anymore ...) + if (!bReallyCanceled) + pHelper->WaitUntilReallyLoaded(true); + + pHelper->cancel(); + pHelper->release(); + + // yes, we were, but eventually the cancel request didn't reach the data source in time + Reference< ::com::sun::star::form::XLoadable > xLoadable(m_xRowSet, UNO_QUERY); + if (bReallyCanceled && xLoadable.is() && xLoadable->isLoaded()) + xLoadable->unload(); + + pStopper->OwnerTerminated(); + // this will cause the stopper to delete itself (in the main thread) so we don't have to take care of the + // solar mutex +} + +//------------------------------------------------------------------------------ +void LoadFormThread::onTerminated() +{ + ::osl::ClearableMutexGuard aGuard(m_aAccessSafety); + if (m_aTerminationHandler.IsSet()) + { + // within the call of our termination handler we may be deleted, so do anything which is a member + // access before the call ... + // FS - #69801# - 02.12.99 + Link aHandler(m_aTerminationHandler); + aGuard.clear(); + aHandler.Call(this); + } + else + { + // we are fully responsible for the data source and for ourself, so dispose the former ... + Reference< ::com::sun::star::lang::XComponent > xDataSourceComponent(m_xRowSet, UNO_QUERY); + if (xDataSourceComponent.is()) + xDataSourceComponent->dispose(); + // ... and delete the latter + aGuard.clear(); // like above - releasing the mutex is a member access ... + delete this; + } +} + +//------------------------------------------------------------------------------ +void LoadFormThread::StopIt() +{ + ::osl::ClearableMutexGuard aResetGuard(m_aAccessSafety); + m_bCanceled = sal_True; + aResetGuard.clear(); + + Reference< ::com::sun::star::sdbcx::XColumnsSupplier > xSupplyCols(m_xRowSet, UNO_QUERY); + if (!xSupplyCols.is()) + { + DBG_ERROR("LoadFormThread::StopIt : invalid data source !"); + return; + } + Reference< ::com::sun::star::container::XIndexAccess > xCols(xSupplyCols->getColumns(), UNO_QUERY); + if (!xCols.is() || (xCols->getCount() == 0)) + // the cursor isn't alive, don't need to cancel + return; + + Reference< ::com::sun::star::util::XCancellable > xCancel(m_xRowSet, UNO_QUERY); + if (xCancel.is()) + { + try { xCancel->cancel(); } catch(SQLException&) {} + // with this the cursor returns from it's load call, this terminates our run, this get's our termination handler to + // be called + // (the try-catch is just in case the cancel wasn't neccessary anymore) + } +} + +//------------------------------------------------------------------------------ +LoadFormThread::ThreadStopper::ThreadStopper(LoadFormThread* pOwner, const String& rTitle) + :SfxCancellable(SFX_APP()->GetCancelManager(), rTitle) + ,m_pOwner(pOwner) +{ +} + +//------------------------------------------------------------------------------ +void LoadFormThread::ThreadStopper::Cancel() +{ + if (!m_pOwner) + return; + + ::osl::MutexGuard aGuard(m_pOwner->m_aAccessSafety); + if (IsCancelled()) + // we already did pass this to our owner + return; + + SfxCancellable::Cancel(); + m_pOwner->StopIt(); +} + +//------------------------------------------------------------------------------ +void LoadFormThread::ThreadStopper::OwnerTerminated() +{ + m_pOwner = NULL; + Application::PostUserEvent(LINK(this, LoadFormThread::ThreadStopper, OnDeleteInMainThread), this); +} + +//------------------------------------------------------------------------------ +IMPL_LINK(LoadFormThread::ThreadStopper, OnDeleteInMainThread, LoadFormThread::ThreadStopper*, pThis) +{ + delete pThis; + return 0L; +} + diff --git a/dbaccess/source/ui/browser/brwview.cxx b/dbaccess/source/ui/browser/brwview.cxx new file mode 100644 index 000000000..073448af8 --- /dev/null +++ b/dbaccess/source/ui/browser/brwview.cxx @@ -0,0 +1,297 @@ +/************************************************************************* + * + * $RCSfile: brwview.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2000-10-26 14:42:27 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SBX_BRWVIEW_HXX +#include "brwview.hxx" +#endif +#ifndef _SBA_GRID_HXX +#include "sbagrid.hxx" +#endif +#ifndef _SFXAPP_HXX //autogen wg. SFX_APP +#include <sfx2/app.hxx> +#endif +#ifndef _SFXIMGMGR_HXX //autogen wg. SFX_IMAGEMANAGER +#include <sfx2/imgmgr.hxx> +#endif +#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ +#include <toolkit/helper/vclunohelper.hxx> +#endif +#ifndef _COMPHELPER_TYPES_HXX_ +#include <comphelper/types.hxx> +#endif +#ifndef _SV_SPLIT_HXX +#include <vcl/split.hxx> +#endif +#ifndef DBACCESS_UI_DBTREEVIEW_HXX +#include "dbtreeview.hxx" +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "moduledbu.hxx" +#endif +#ifndef _DBU_RESOURCE_HRC_ +#include "dbu_resource.hrc" +#endif + + +using namespace dbaui; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::sdb; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; + +//================================================================== +//= UnoDataBrowserView +//================================================================== + +// ------------------------------------------------------------------------- +UnoDataBrowserView::UnoDataBrowserView(Window* pParent, const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rFactory) +:Window(pParent,WB_BORDER) + ,m_pToolBox(NULL) + ,m_pVclControl(NULL) + ,m_xServiceFactory(_rFactory) + ,m_pSplitter(NULL) + ,m_pTreeView(NULL) +{ +} +// ------------------------------------------------------------------------- +void UnoDataBrowserView::Construct(const Reference< ::com::sun::star::awt::XControlModel >& xModel) +{ + try + { + // our UNO representation + m_xMe = VCLUnoHelper::CreateControlContainer(this); + DBG_ASSERT(m_xMe.is(), "UnoDataBrowserView::Construct : no UNO representation"); + + // create the (UNO-) control + m_xGrid = new SbaXGridControl(m_xServiceFactory); + DBG_ASSERT(m_xGrid.is(), "UnoDataBrowserView::Construct : could not create a grid control !"); + // in design mode (for the moment) + m_xGrid->setDesignMode(sal_True); + + Reference< ::com::sun::star::awt::XWindow > xGridWindow(m_xGrid, UNO_QUERY); + xGridWindow->setVisible(sal_True); + xGridWindow->setEnable(sal_True); + + // introduce the model to the grid + m_xGrid->setModel(xModel); + // introduce the container (me) to the grid + Reference< ::com::sun::star::beans::XPropertySet > xModelSet(xModel, UNO_QUERY); + m_xMe->addControl(::comphelper::getString(xModelSet->getPropertyValue(PROPERTY_NAME)), m_xGrid); + + // get the VCL-control + m_pVclControl = NULL; + Reference< ::com::sun::star::awt::XWindowPeer > xPeer = m_xGrid->getPeer(); + if (xPeer.is()) + { + SbaXGridPeer* pPeer = SbaXGridPeer::getImplementation(xPeer); + if (pPeer) + m_pVclControl = static_cast<SbaGridControl*>(pPeer->GetWindow()); + } + + DBG_ASSERT(m_pVclControl != NULL, "UnoDataBrowserView::Construct : no real grid control !"); + } + catch(...) + { + ::comphelper::disposeComponent(m_xGrid); + ::comphelper::disposeComponent(m_xMe); + throw; + } +} +// ------------------------------------------------------------------------- +UnoDataBrowserView::~UnoDataBrowserView() +{ + setToolBox(NULL); + + m_pVclControl = NULL; + + delete m_pSplitter; + m_pSplitter = NULL; + if(m_pTreeView) + { + delete m_pTreeView; + m_pTreeView = NULL; + } + ::comphelper::disposeComponent(m_xMe); + ::comphelper::disposeComponent(m_xGrid); +} +// ----------------------------------------------------------------------------- +IMPL_LINK( UnoDataBrowserView, SplitHdl, void*, p ) +{ + m_pSplitter->SetPosPixel( Point( m_pSplitter->GetSplitPosPixel(), m_pSplitter->GetPosPixel().Y() ) ); + Resize(); + + return 0L; +} +// ------------------------------------------------------------------------- +void UnoDataBrowserView::setToolBox(ToolBox* pTB) +{ + if (pTB == m_pToolBox) + return; + + if (m_pToolBox) + { + SFX_IMAGEMANAGER()->ReleaseToolBox(m_pToolBox); + delete m_pToolBox; + } + + m_pToolBox = pTB; + if (m_pToolBox) + { + SFX_IMAGEMANAGER()->RegisterToolBox(m_pToolBox, SFX_TOOLBOX_CHANGEOUTSTYLE); + + m_pToolBox->SetParent(this); + m_pToolBox->Show(); + } + + // rearrange the grid and the TB + Resize(); +} +// ------------------------------------------------------------------------- +void UnoDataBrowserView::setSplitter(Splitter* _pSplitter) +{ + m_pSplitter = _pSplitter; + m_pSplitter->SetSplitHdl( LINK( this, UnoDataBrowserView, SplitHdl ) ); +} +// ------------------------------------------------------------------------- +void UnoDataBrowserView::setTreeView(DBTreeView* _pTreeView) +{ + m_pTreeView = _pTreeView; +} +// ------------------------------------------------------------------------- + +// ------------------------------------------------------------------------- +void UnoDataBrowserView::Resize() +{ + Window::Resize(); + Point aSplitPos(0,0); + Size aSplitSize(0,0); + Size aNewSize( GetOutputSizePixel() ); + + if(m_pTreeView && m_pSplitter) + { + + aSplitPos = m_pSplitter->GetPosPixel(); + aSplitSize = m_pSplitter->GetOutputSizePixel(); + + if( ( aSplitPos.X() + aSplitSize.Width() ) > ( aNewSize.Width() )) + aSplitPos.X() = aNewSize.Width() - aSplitSize.Width(); + + if( aSplitPos.X() <= 0) + aSplitPos.X() = LogicToPixel( Size(sal_Int32(aNewSize.Width() * 0.2), 0 ), MAP_APPFONT ).Width(); + // set the size of treelistbox + m_pTreeView->SetPosSizePixel( Point( 0, 0 ), + Size( aSplitPos.X(), aNewSize.Height() ) ); + //set the size of the splitter + m_pSplitter->SetPosSizePixel( aSplitPos, Size( aSplitSize.Width(), aNewSize.Height() ) ); + m_pSplitter->SetDragRectPixel( Rectangle( Point( 0, 0 ), + Size( aNewSize.Width(), aNewSize.Height() ) ) ); + } + + // set the size of the toolbox + Size aToolBoxSize(0,0); + if (m_pToolBox) + { + aToolBoxSize = m_pToolBox->GetSizePixel(); + m_pToolBox->SetPosSizePixel(Point(aSplitPos.X() + aSplitSize.Width(), 0), + Size(aNewSize.Width() - aSplitSize.Width() - aSplitPos.X(), aToolBoxSize.Height())); + } + // set the size of grid control + Reference< ::com::sun::star::awt::XWindow > xGridAsWindow(m_xGrid, UNO_QUERY); + if (xGridAsWindow.is()) + xGridAsWindow->setPosSize( aSplitPos.X() + aSplitSize.Width(), aToolBoxSize.Height() , + aNewSize.Width() - aSplitSize.Width() - aSplitPos.X(), aNewSize.Height() - aToolBoxSize.Height(), ::com::sun::star::awt::PosSize::POSSIZE); + + +} + +//------------------------------------------------------------------ +sal_uInt16 UnoDataBrowserView::Model2ViewPos(sal_uInt16 nPos) const +{ + return m_pVclControl ? m_pVclControl->GetViewColumnPos(m_pVclControl->GetColumnIdFromModelPos(nPos)) : -1; +} + +//------------------------------------------------------------------ +sal_uInt16 UnoDataBrowserView::View2ModelPos(sal_uInt16 nPos) const +{ + return m_pVclControl ? m_pVclControl->GetModelColumnPos(m_pVclControl->GetColumnIdFromViewPos(nPos)) : -1; +} + +//------------------------------------------------------------------ +sal_uInt16 UnoDataBrowserView::ViewColumnCount() const +{ + return m_pVclControl ? m_pVclControl->GetViewColCount() : 0; +} + +//------------------------------------------------------------------ +void UnoDataBrowserView::GetFocus() +{ + Window::GetFocus(); + if (m_pVclControl) + m_pVclControl->GrabFocus(); +} +// ------------------------------------------------------------------------- + + + diff --git a/dbaccess/source/ui/browser/dbloader.cxx b/dbaccess/source/ui/browser/dbloader.cxx new file mode 100644 index 000000000..553e426de --- /dev/null +++ b/dbaccess/source/ui/browser/dbloader.cxx @@ -0,0 +1,270 @@ +/************************************************************************* + * + * $RCSfile: dbloader.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2000-10-26 14:40:46 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the License); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an AS IS basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +//#ifndef _SFXFRAME_HXX +//#include <sfx2/frame.hxx> +//#endif +#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ +#include <toolkit/helper/vclunohelper.hxx> +#endif +#ifndef _URLOBJ_HXX //autogen +#include <tools/urlobj.hxx> +#endif +#ifndef _TOOLKIT_AWT_VCLXWINDOW_HXX_ +#include <toolkit/awt/vclxwindow.hxx> +#endif +#ifndef _COM_SUN_STAR_FRAME_XCONTROLLER_HPP_ +#include <com/sun/star/frame/XController.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XFRAME_HPP_ +#include <com/sun/star/frame/XFrame.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XFRAMELOADER_HPP_ +#include <com/sun/star/frame/XFrameLoader.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XLOADEVENTLISTENER_HPP_ +#include <com/sun/star/frame/XLoadEventListener.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XSET_HPP_ +#include <com/sun/star/container/XSet.hpp> +#endif +#ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP_ +#include <com/sun/star/registry/XRegistryKey.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE2_HXX_ +#include <cppuhelper/implbase2.hxx> +#endif +#ifndef _DBA_REGISTRATION_HELPER_HXX_ +#include "registrationhelper.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include <com/sun/star/lang/XInitialization.hpp> +#endif + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::registry; + +class DBContentLoader : public ::cppu::WeakImplHelper2< XFrameLoader, XServiceInfo> +{ +private: + ::rtl::OUString m_aURL; + Sequence< PropertyValue> m_aArgs; + Reference< XLoadEventListener > m_xListener; + Reference< XFrame > m_xFrame; + Reference< XMultiServiceFactory > m_xServiceFactory; +public: + DBContentLoader(const Reference< XMultiServiceFactory >&); + ~DBContentLoader(); + + // XServiceInfo + ::rtl::OUString SAL_CALL getImplementationName() throw( ); + sal_Bool SAL_CALL supportsService(const ::rtl::OUString& ServiceName) throw( ); + Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ); + + // static methods + static ::rtl::OUString getImplementationName_Static() throw( ) + { + return ::rtl::OUString::createFromAscii("openoffice.org.DBContentLoader"); + } + static Sequence< ::rtl::OUString> getSupportedServiceNames_Static(void) throw( ); + 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 >&); + + // XLoader + virtual void SAL_CALL load( const Reference< XFrame > & _rFrame, const ::rtl::OUString& _rURL, + const Sequence< PropertyValue >& _rArgs, + const Reference< XLoadEventListener > & _rListener); + virtual void SAL_CALL cancel(void); +}; + +DBContentLoader::DBContentLoader(const Reference< XMultiServiceFactory >& _rxFactory) + :m_xServiceFactory(_rxFactory) +{ +} +// ------------------------------------------------------------------------- + +DBContentLoader::~DBContentLoader() +{ +} +// ------------------------------------------------------------------------- +// ------------------------------------------------------------------------- +extern "C" void SAL_CALL createRegistryInfo_DBContentLoader() +{ + static OMultiInstanceAutoRegistration< DBContentLoader > aAutoRegistration; +} +// ------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL DBContentLoader::Create( const Reference< XMultiServiceFactory > & rSMgr ) throw( Exception ) +{ + return *(new DBContentLoader(rSMgr)); +} +// ------------------------------------------------------------------------- +// XServiceInfo +::rtl::OUString SAL_CALL DBContentLoader::getImplementationName() throw( ) +{ + return getImplementationName_Static(); +} +// ------------------------------------------------------------------------- + +// XServiceInfo +sal_Bool SAL_CALL DBContentLoader::supportsService(const ::rtl::OUString& ServiceName) throw( ) +{ + Sequence< ::rtl::OUString > aSNL = getSupportedServiceNames(); + const ::rtl::OUString * pBegin = aSNL.getConstArray(); + const ::rtl::OUString * pEnd = pBegin + aSNL.getLength(); + for( ; pBegin != pEnd; ++pBegin) + if( *pBegin == ServiceName ) + return sal_True; + return sal_False; +} +// ------------------------------------------------------------------------- +// XServiceInfo +Sequence< ::rtl::OUString > SAL_CALL DBContentLoader::getSupportedServiceNames(void) throw( ) +{ + return getSupportedServiceNames_Static(); +} +// ------------------------------------------------------------------------- +// ORegistryServiceManager_Static +Sequence< ::rtl::OUString > DBContentLoader::getSupportedServiceNames_Static(void) throw( ) +{ + Sequence< ::rtl::OUString > aSNS( 2 ); + aSNS.getArray()[0] = ::rtl::OUString::createFromAscii("stardiv.one.frame.FrameLoader"); + aSNS.getArray()[1] = ::rtl::OUString::createFromAscii("stardiv.one.frame.DBContentLoader"); + return aSNS; +} +// ------------------------------------------------------------------------- +extern "C" void SAL_CALL writeDBLoaderInfo(void* pRegistryKey) +{ + Reference< XRegistryKey> xKey(reinterpret_cast< XRegistryKey*>(pRegistryKey)); + + // register content loader for dispatch + ::rtl::OUString aImpl = ::rtl::OUString::createFromAscii("/"); + aImpl += DBContentLoader::getImplementationName_Static(); + + ::rtl::OUString aImpltwo = aImpl; + aImpltwo += ::rtl::OUString::createFromAscii("/UNO/Loader"); + Reference< XRegistryKey> xNewKey = xKey->createKey( aImpltwo ); + aImpltwo = aImpl; + aImpltwo += ::rtl::OUString::createFromAscii("/Loader"); + Reference< XRegistryKey > xLoaderKey = xKey->createKey( aImpltwo ); + xNewKey = xLoaderKey->createKey( ::rtl::OUString::createFromAscii("Pattern") ); + xNewKey->setAsciiValue( ::rtl::OUString::createFromAscii(".component:DB*") ); +} + +// ----------------------------------------------------------------------- +void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const ::rtl::OUString& rURL, + const Sequence< PropertyValue >& rArgs, + const Reference< XLoadEventListener > & rListener) +{ + m_xFrame = rFrame; + m_xListener = rListener; + m_aURL = rURL; + m_aArgs = rArgs; + + INetURLObject aParser(rURL); + // ich benutze nicht maURL, sondern rURL, denn zwischen dem Constructor und diesem Load hier kann sich die ::com::sun::star::util::URL des Objektes + // schon geaendert haben (zum Beispiel durch Umbenennen) + Reference< XController > xController; + sal_Bool bSuccess = sal_True; + if(aParser.GetMainURL().EqualsAscii(".component:DB/FormGridView")) + xController = Reference< XController >(m_xServiceFactory->createInstance(::rtl::OUString::createFromAscii("org.openoffice.dbaccess.OFormGridView")),UNO_QUERY); + else // construct the control + xController = Reference< XController >(m_xServiceFactory->createInstance(::rtl::OUString::createFromAscii("org.openoffice.dbaccess.ODatabaseBrowser")),UNO_QUERY); + + if(bSuccess = xController.is()) + { + // and initialize + try + { + Reference<XInitialization > xIni(xController,UNO_QUERY); + Sequence< Any> aArgs(1); + aArgs[0] <<= rFrame; + xIni->initialize(aArgs); + } + catch(Exception&) + { + bSuccess = sal_False; + } + + } + + if (bSuccess && rListener.is()) + rListener->loadFinished(this); + else if (!bSuccess && rListener.is()) + rListener->loadCancelled(this); +} + +// ----------------------------------------------------------------------- +void DBContentLoader::cancel(void) +{ +} diff --git a/dbaccess/source/ui/browser/dbtreemodel.cxx b/dbaccess/source/ui/browser/dbtreemodel.cxx new file mode 100644 index 000000000..73c33af61 --- /dev/null +++ b/dbaccess/source/ui/browser/dbtreemodel.cxx @@ -0,0 +1,290 @@ +/************************************************************************* + * + * $RCSfile: dbtreemodel.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2000-10-26 14:41:05 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the License); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an AS IS basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _COM_SUN_STAR_UTIL_XFLUSHABLE_HPP_ +#include <com/sun/star/util/XFlushable.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_ +#include <com/sun/star/sdbc/XDataSource.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ +#include <com/sun/star/sdbc/XConnection.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XViewsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_XCOMPLETEDCONNECTION_HPP_ +#include <com/sun/star/sdb/XCompletedConnection.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_XQUERYDEFINITIONSSUPPLIER_HPP_ +#include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp> +#endif +#ifndef _CPPUHELPER_EXTRACT_HXX_ +#include <cppuhelper/extract.hxx> +#endif +#ifndef _DBU_RESOURCE_HRC_ +#include "dbu_resource.hrc" +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef DBAUI_DBTREEMODEL_HXX +#include "dbtreemodel.hxx" +#endif +#ifndef _SVLBOXITM_HXX +#include <svtools/svlbitm.hxx> +#endif +#ifndef _COMPHELPER_TYPES_HXX_ +#include <comphelper/types.hxx> +#endif + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::sdb; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::beans; +using namespace dbaui; +// ------------------------------------------------------------------------- + +DBTreeListModel::DBTreeListModel(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xMultiServiceFacatory) +{ + DBG_ASSERT(_xMultiServiceFacatory.is(), "DBTreeListModel::DBTreeListModel : need a service factory !"); + try + { + m_xDatabaseContext = Reference< XNameAccess >(_xMultiServiceFacatory->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY); + } + catch(Exception&) + { + } + if (m_xDatabaseContext.is()) + { + String aNames[2]; + aNames[0] = String(ModuleRes(STR_QRY_TITLE)).GetToken(0,' '); + aNames[1] = String(ModuleRes(STR_TBL_TITLE)).GetToken(0,' '); + + // images for the table and query folders + Image aFolderImage[2] = { + Image(ModuleRes(QUERYFOLDER_TREE_ICON)), + Image(ModuleRes(TABLEFOLDER_TREE_ICON)) + }; + + Image aDBImage(ModuleRes(IMG_DATABASE)); + // fill the model with the names of the registered datasources + Sequence< ::rtl::OUString > aDatasources = m_xDatabaseContext->getElementNames(); + const ::rtl::OUString* pBegin = aDatasources.getConstArray(); + const ::rtl::OUString* pEnd = pBegin + aDatasources.getLength(); + for (; pBegin != pEnd;++pBegin) + { + SvLBoxEntry* pEntry = new SvLBoxEntry(); + // add items + { // just for reuse of the names + SvLBoxContextBmp* pContextBmp = new SvLBoxContextBmp( pEntry, 0,aDBImage,aDBImage,0 ); + pEntry->AddItem( pContextBmp ); + + SvLBoxString* pString = new SvLBoxString( pEntry, 0, *pBegin ); + pEntry->AddItem( pString ); + + // here we safe the connection + DBTreeListUserData* pData = new DBTreeListUserData; + pEntry->SetUserData(pData); + } + Insert(pEntry); + + + + for(sal_Int32 i=0;i<2;++i) + { + SvLBoxEntry* pChild = new SvLBoxEntry(); + pChild->EnableChildsOnDemand(); + + SvLBoxContextBmp* pContextBmp = new SvLBoxContextBmp( pChild, 0,aFolderImage[i],aFolderImage[i],0 ); + pChild->AddItem( pContextBmp ); + + SvLBoxString* pString = new SvLBoxString( pChild, 0, aNames[i] ); + pChild->AddItem( pString ); + + DBTreeListUserData* pData = new DBTreeListUserData; + pData->bTable = i; + pChild->SetUserData(pData); + Insert(pChild,pEntry); + } + } + } +} +// ------------------------------------------------------------------------- +DBTreeListModel::~DBTreeListModel() +{ + SvLBoxEntry* pNext = (SvLBoxEntry*)First(); + while(pNext) + { + DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pNext->GetUserData()); + if(pData) + { + pData->xInterface = NULL; + delete pData; + } + pNext = (SvLBoxEntry*)Next(pNext); + } + m_xDatabaseContext = NULL; +} +// ------------------------------------------------------------------------- +void DBTreeListModel::fillEntry(SvLBoxEntry* _pParent) +{ + if(!_pParent->HasChilds()) + { + SvLBoxEntry* pFirstParent = (SvLBoxEntry*)GetRootLevelParent(_pParent); + OSL_ENSHURE(pFirstParent,"DBTreeListModel::fillEntry: No rootlevelparent!"); + + DBTreeListUserData* pData = (DBTreeListUserData*)_pParent->GetUserData(); + OSL_ENSHURE(pData,"DBTreeListModel::fillEntry: No user data!"); + SvLBoxString* pString = (SvLBoxString*)pFirstParent->GetFirstItem(SV_ITEM_ID_LBOXSTRING); + OSL_ENSHURE(pString,"DBTreeListModel::fillEntry: No string item!"); + String aName(pString->GetText()); + Any aValue(m_xDatabaseContext->getByName(aName)); + if(pData->bTable) + { + sal_Bool bComplete = sal_False; + Reference<XPropertySet> xProp; + aValue >>= xProp; + Any aPwd = xProp->getPropertyValue(::rtl::OUString::createFromAscii("Password")); + Any aPwdReq = xProp->getPropertyValue(::rtl::OUString::createFromAscii("IsPasswordRequired")); + Any aUser = xProp->getPropertyValue(::rtl::OUString::createFromAscii("User")); + // only complete when password is requiered and password is empty + if(cppu::any2bool(aPwdReq) && !comphelper::getString(aPwd).getLength()) + bComplete = sal_True; + + Reference<XConnection> xConnection; // supports the service sdb::connection + if(bComplete) + { + Reference<XCompletedConnection> xCompletedConnection; + aValue >>= xCompletedConnection; + // xConnection->connectWithCompletion(); + } + else + { + Reference<XDataSource> xDataSource(xProp,UNO_QUERY); + xConnection = xDataSource->getConnection(comphelper::getString(aUser),comphelper::getString(aPwd)); + } + if(xConnection.is()) + { + DBTreeListUserData* pFirstData = (DBTreeListUserData*)pFirstParent->GetUserData(); + if(!pFirstData->xInterface.is()) + pFirstData->xInterface = xConnection; + + Reference<XTablesSupplier> xTabSup(xConnection,UNO_QUERY); + if(xTabSup.is()) + { + Image aImage(ModuleRes(TABLE_TREE_ICON)); + insertEntries(xTabSup->getTables(),_pParent,aImage); + } + + Reference<XViewsSupplier> xViewSup(xConnection,UNO_QUERY); + if(xViewSup.is()) + { + Image aImage(ModuleRes(VIEW_TREE_ICON)); + insertEntries(xViewSup->getViews(),_pParent,aImage); + } + } + } + else // we have to expand the queries + { + Reference<XQueryDefinitionsSupplier> xQuerySup; + if(aValue >>= xQuerySup) + { + Image aImage(ModuleRes(QUERY_TREE_ICON)); + insertEntries(xQuerySup->getQueryDefinitions(),_pParent,aImage); + } + } + } +} +// ------------------------------------------------------------------------- +void DBTreeListModel::insertEntries(const Reference<XNameAccess>& _xNameAccess,SvLBoxEntry* _pParent,const Image& _rImage) +{ + DBTreeListUserData* pData = (DBTreeListUserData*)_pParent->GetUserData(); + if(pData) + pData->xInterface = _xNameAccess; + + Sequence< ::rtl::OUString > aNames = _xNameAccess->getElementNames(); + const ::rtl::OUString* pBegin = aNames.getConstArray(); + const ::rtl::OUString* pEnd = pBegin + aNames.getLength(); + for (; pBegin != pEnd;++pBegin) + { + SvLBoxEntry* pEntry = new SvLBoxEntry(); + // add items + SvLBoxContextBmp* pContextBmp = new SvLBoxContextBmp(pEntry, 0,_rImage,_rImage,0); + pEntry->AddItem( pContextBmp ); + + SvLBoxString* pString = new SvLBoxString( pEntry, 0, *pBegin ); + pEntry->AddItem( pString ); + + Insert(pEntry,_pParent); + } +} diff --git a/dbaccess/source/ui/browser/dbtreemodel.hxx b/dbaccess/source/ui/browser/dbtreemodel.hxx new file mode 100644 index 000000000..92e5ff367 --- /dev/null +++ b/dbaccess/source/ui/browser/dbtreemodel.hxx @@ -0,0 +1,103 @@ +/************************************************************************* + * + * $RCSfile: dbtreemodel.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2000-10-26 14:43:36 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the License); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an AS IS basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef DBAUI_DBTREEMODEL_HXX +#define DBAUI_DBTREEMODEL_HXX + +#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#endif +#ifndef _SVLBOX_HXX +#include <svtools/svlbox.hxx> +#endif +#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "moduledbu.hxx" +#endif + + +namespace com { namespace sun { namespace star { namespace lang { class XMultiServiceFactory; } } } } + +namespace dbaui +{ + // ------------------ + // - DBTreeListModel - + // ------------------ + class DBTreeListModel : public SvLBoxTreeList, + public dbaui::OModuleClient + { + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xDatabaseContext; /// database context we're working in + + void insertEntries(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xNameAccess,SvLBoxEntry* _pParent,const Image& _rImage); + public: + struct DBTreeListUserData + { + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xInterface; + sal_Bool bTable; + }; + + DBTreeListModel(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xMultiServiceFacatory); + ~DBTreeListModel(); + + void fillEntry(SvLBoxEntry* _pParent); + }; +} + +#endif // DBAUI_DBTREEMODEL_HXX diff --git a/dbaccess/source/ui/browser/dbtreeview.cxx b/dbaccess/source/ui/browser/dbtreeview.cxx new file mode 100644 index 000000000..e3dc6c807 --- /dev/null +++ b/dbaccess/source/ui/browser/dbtreeview.cxx @@ -0,0 +1,128 @@ +/************************************************************************* + * + * $RCSfile: dbtreeview.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2000-10-26 14:40:54 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the License); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an AS IS basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef DBACCESS_UI_DBTREEVIEW_HXX +#include "DBTreeView.hxx" +#endif +#ifndef _SVTREEBOX_HXX +#include <svtools/svtreebx.hxx> +#endif +#ifndef DBAUI_DBTREELISTBOX_HXX +#include "dbtreelistbox.hxx" +#endif +#ifndef DBAUI_DBTREEMODEL_HXX +#include "dbtreemodel.hxx" +#endif + +using namespace dbaui; +// ------------------ +// - DBTreeView - +// ------------------ + +DBTreeView::DBTreeView( Window* pParent, WinBits nBits) + : Window( pParent, nBits ) + , m_pTreeListBox(NULL) +{ + m_pTreeListBox = new DBTreeListBox(this,WB_BORDER | WB_HASLINES | WB_HASLINESATROOT | WB_SORT | WB_HASBUTTONS | WB_HSCROLL |WB_HASBUTTONSATROOT); + m_pTreeListBox->EnableCheckButton(NULL); + m_pTreeListBox->SetDragDropMode( 0 ); + m_pTreeListBox->EnableInplaceEditing( sal_False ); + m_pTreeListBox->Show(); +} + +// ----------------------------------------------------------------------------- + +DBTreeView::~DBTreeView() +{ + if( m_pTreeListBox) + { + m_pTreeListBox->GetModel()->RemoveView(m_pTreeListBox); + m_pTreeListBox->DisconnectFromModel(); + delete m_pTreeListBox; + } +} + +// ----------------------------------------------------------------------------- + +void DBTreeView::Resize() +{ + Window::Resize(); + + m_pTreeListBox->SetPosSizePixel(Point(0,0),GetOutputSizePixel()); +} +// ------------------------------------------------------------------------- +DBTreeListModel* DBTreeView::getModel() +{ + return (DBTreeListModel*)m_pTreeListBox->GetModel(); +} +// ------------------------------------------------------------------------- +void DBTreeView::setModel(DBTreeListModel* _pTreeModel) +{ + _pTreeModel->InsertView(m_pTreeListBox); + m_pTreeListBox->SetModel(_pTreeModel); +} +// ------------------------------------------------------------------------- +void DBTreeView::setSelectHdl(const Link& _rHdl) +{ + m_pTreeListBox->SetSelectHdl(_rHdl); +} +// ------------------------------------------------------------------------- + diff --git a/dbaccess/source/ui/browser/dbtreeview.hxx b/dbaccess/source/ui/browser/dbtreeview.hxx new file mode 100644 index 000000000..f38c18a37 --- /dev/null +++ b/dbaccess/source/ui/browser/dbtreeview.hxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * $RCSfile: dbtreeview.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2000-10-26 14:41:11 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the License); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an AS IS basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef DBACCESS_UI_DBTREEVIEW_HXX +#define DBACCESS_UI_DBTREEVIEW_HXX + +#ifndef _SV_WINDOW_HXX //autogen +#include <vcl/window.hxx> +#endif + +namespace dbaui +{ + class DBTreeListBox; + class DBTreeListModel; + // ------------------ + // - DBTreeView - + // ------------------ + + class DBTreeView : public Window + { + private: + DBTreeListBox* m_pTreeListBox; + protected: + // window overridables + virtual void Resize(); + public: + + DBTreeView( Window* pParent, WinBits nBits ); + ~DBTreeView(); + + DBTreeListModel* getModel(); + void setModel(DBTreeListModel* _pTreeModel); + void setSelectHdl(const Link& _rHdl); + }; +} + +#endif // DBACCESS_UI_DBTREEVIEW_HXX + diff --git a/dbaccess/source/ui/browser/exsrcbrw.cxx b/dbaccess/source/ui/browser/exsrcbrw.cxx new file mode 100644 index 000000000..d0da13050 --- /dev/null +++ b/dbaccess/source/ui/browser/exsrcbrw.cxx @@ -0,0 +1,765 @@ +/************************************************************************* + * + * $RCSfile: exsrcbrw.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2000-10-26 14:41:26 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SBA_EXTCTRLR_HXX +#include "exsrcbrw.hxx" +#endif +#ifndef _COM_SUN_STAR_FORM_FORMCOMPONENTTYPE_HPP_ +#include <com/sun/star/form/FormComponentType.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XURLTRANSFORMER_HPP_ +#include <com/sun/star/util/XURLTransformer.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_XGRIDCOLUMNFACTORY_HPP_ +#include <com/sun/star/form/XGridColumnFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_XFORMCONTROLLER_HPP_ +#include <com/sun/star/form/XFormController.hpp> +#endif +#ifndef _SBA_FORMADAPTER_HXX +#include "formadapter.hxx" +#endif +#ifndef _COMPHELPER_PROCESSFACTORY_HXX_ +#include <comphelper/processfactory.hxx> +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef _DBA_REGISTRATION_HELPER_HXX_ +#include "registrationhelper.hxx" +#endif + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::sdb; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +using namespace dbaui; + +//============================================================================== +//= SbaExternalSourceBrowser +//============================================================================== +extern "C" void SAL_CALL createRegistryInfo_OFormGridView() +{ + static OMultiInstanceAutoRegistration< SbaExternalSourceBrowser > aAutoRegistration; +} +//------------------------------------------------------------------------------ +Any SAL_CALL SbaExternalSourceBrowser::queryInterface(const Type& _rType) throw (RuntimeException) +{ + Any aRet = SbaXDataBrowserController::queryInterface(_rType); + if(!aRet.hasValue()) + { + aRet = ::cppu::queryInterface(_rType, + (::com::sun::star::util::XModifyBroadcaster*)this, + (::com::sun::star::form::XLoadListener*)this); + if(!aRet.hasValue()) + aRet = m_xFormControllerImpl->queryAggregation(_rType); + } + + return aRet; +} +//------------------------------------------------------------------------------ +SbaExternalSourceBrowser::SbaExternalSourceBrowser(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM) + :SbaXDataBrowserController(_rM) + ,m_pDataSourceImpl(NULL) + ,m_aModifyListeners(m_aPropertyMutex) + ,m_bInQueryDispatch(NULL) +{ + // create the aggregated object + ::comphelper::increment(m_refCount); + { + m_pFormControllerImpl = new FormControllerImpl(this); + m_xFormControllerImpl = m_pFormControllerImpl; + m_xFormControllerImpl->setDelegator(*this); + } + ::comphelper::decrement(m_refCount); +} + +//------------------------------------------------------------------------------ +SbaExternalSourceBrowser::~SbaExternalSourceBrowser() +{ + // Freigeben der Aggregation + if (m_xFormControllerImpl.is()) + { + Reference< XInterface > xEmpty; + m_xFormControllerImpl->setDelegator(xEmpty); + } +} +//------------------------------------------------------------------------- +::comphelper::StringSequence SAL_CALL SbaExternalSourceBrowser::getSupportedServiceNames() throw(RuntimeException) +{ + return getSupportedServiceNames_Static(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SbaExternalSourceBrowser::getImplementationName_Static() throw(RuntimeException) +{ + return ::rtl::OUString::createFromAscii("org.openoffice.dbaccess.OFormGridView"); +} +//------------------------------------------------------------------------- +::comphelper::StringSequence SbaExternalSourceBrowser::getSupportedServiceNames_Static() throw(RuntimeException) +{ + ::comphelper::StringSequence aSupported(1); + aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.dialogs.FormGridView"); + return aSupported; +} +//------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL SbaExternalSourceBrowser::Create(const Reference<XMultiServiceFactory >& _rxFactory) +{ + return *(new SbaExternalSourceBrowser(_rxFactory)); +} +//------------------------------------------------------------------------- +::rtl::OUString SAL_CALL SbaExternalSourceBrowser::getImplementationName() throw(RuntimeException) +{ + return getImplementationName_Static(); +} +//------------------------------------------------------------------------------ +Reference< XRowSet > SbaExternalSourceBrowser::CreateForm() +{ + m_pDataSourceImpl = new SbaXFormAdapter(); + return m_pDataSourceImpl; +} + +//------------------------------------------------------------------------------ +sal_Bool SbaExternalSourceBrowser::InitializeForm(const Reference< XRowSet > & xForm) +{ + return sal_True; +} + +//------------------------------------------------------------------ +sal_Bool SbaExternalSourceBrowser::InitializeGridModel(const Reference< ::com::sun::star::form::XFormComponent > & xGrid) +{ + return sal_True; +} + +//------------------------------------------------------------------ +sal_Bool SbaExternalSourceBrowser::LoadForm() +{ + // as we don't have a main form (yet), we have nothing to do + // we don't call FormLoaded, because this expects a working data source + return sal_True; +} + + +//------------------------------------------------------------------ +void SbaExternalSourceBrowser::modified(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException ) +{ + SbaXDataBrowserController::modified(aEvent); + + // multiplex this event to all my listeners + ::com::sun::star::lang::EventObject aEvt(*this); + ::cppu::OInterfaceIteratorHelper aIt(m_aModifyListeners); + while (aIt.hasMoreElements()) + ((::com::sun::star::util::XModifyListener*)aIt.next())->modified(aEvt); +} + +// ----------------------------------------------------------------------- +void SAL_CALL SbaExternalSourceBrowser::attachFrame(const Reference< ::com::sun::star::frame::XFrame > & xFrame) throw( RuntimeException ) +{ + Reference< ::com::sun::star::frame::XFrameActionListener > xAggListener; + if (m_xFormControllerImpl.is()) + m_xFormControllerImpl->queryAggregation(::getCppuType((const Reference< ::com::sun::star::frame::XFrameActionListener>*)0)) >>= xAggListener; + + // log off my aggregated object + if (m_xCurrentFrame.is() && xAggListener.is()) + m_xCurrentFrame->removeFrameActionListener(xAggListener); + + SbaXDataBrowserController::attachFrame(xFrame); + + // and log on to the new frame + if (m_xCurrentFrame.is() && xAggListener.is()) + m_xCurrentFrame->addFrameActionListener(xAggListener); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaExternalSourceBrowser::dispatch(const ::com::sun::star::util::URL& aURL, const Sequence< ::com::sun::star::beans::PropertyValue>& aArgs) +{ + const ::com::sun::star::beans::PropertyValue* pArguments = aArgs.getConstArray(); + if (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/AddGridColumn"))) + { + // search the argument describing the column to create + ::rtl::OUString sControlType; + sal_Int16 nControlPos = -1; + Sequence< ::com::sun::star::beans::PropertyValue> aControlProps; + for (sal_uInt16 i=0; i<aArgs.getLength(); ++i, ++pArguments) + { + if (pArguments->Name.equals(::rtl::OUString::createFromAscii("ColumnType"))) + { + sal_Bool bCorrectType = pArguments->Value.getValueType().equals(::getCppuType((const ::rtl::OUString*)0)); + OSL_ENSHURE(bCorrectType, "invalid type for argument \"ColumnType\" !"); + if (bCorrectType) + sControlType = ::comphelper::getString(pArguments->Value); + } + else if (pArguments->Name.equals(::rtl::OUString::createFromAscii("ColumnPosition"))) + { + sal_Bool bCorrectType = pArguments->Value.getValueType().equals(::getCppuType((const sal_Int16*)0)); + OSL_ENSHURE(bCorrectType, "invalid type for argument \"ColumnPosition\" !"); + if (bCorrectType) + nControlPos = ::comphelper::getINT16(pArguments->Value); + } + else if (pArguments->Name.equals(::rtl::OUString::createFromAscii("ColumnProperties"))) + { + sal_Bool bCorrectType = pArguments->Value.getValueType().equals(::getCppuType((const Sequence< ::com::sun::star::beans::PropertyValue>*)0)); + OSL_ENSHURE(bCorrectType, "invalid type for argument \"ColumnProperties\" !"); + if (bCorrectType) + aControlProps = *(Sequence< ::com::sun::star::beans::PropertyValue>*)pArguments->Value.getValue(); + } + else + OSL_ASSERT(((ByteString("SbaExternalSourceBrowser::dispatch(AddGridColumn) : unknown argument (") += ByteString((const sal_Unicode*)pArguments->Name, gsl_getSystemTextEncoding()).GetBuffer()) += ") !").GetBuffer()); + } + if (!sControlType.getLength()) + { + OSL_ASSERT("SbaExternalSourceBrowser::dispatch(AddGridColumn) : missing argument (ColumnType) !"); + sControlType = ::rtl::OUString::createFromAscii("TextField"); + } + OSL_ENSHURE(aControlProps.getLength(), "SbaExternalSourceBrowser::dispatch(AddGridColumn) : missing argument (ColumnProperties) !"); + + // create the col + Reference< ::com::sun::star::form::XGridColumnFactory > xColFactory(getControlModel(), UNO_QUERY); + Reference< ::com::sun::star::beans::XPropertySet > xNewCol = xColFactory->createColumn(sControlType); + // set it's properties + const ::com::sun::star::beans::PropertyValue* pControlProps = aControlProps.getConstArray(); + for (i=0; i<aControlProps.getLength(); ++i, ++pControlProps) + { + try + { + xNewCol->setPropertyValue(pControlProps->Name, pControlProps->Value); + } + catch(...) + { + OSL_ASSERT("SbaExternalSourceBrowser::dispatch : could not set a column property (maybe you forgot a READONLY attribute for a dispatch-argument ?) !"); + } + ; + } + + // correct the position + Reference< ::com::sun::star::container::XIndexContainer > xColContainer(getControlModel(), UNO_QUERY); + + if (nControlPos > xColContainer->getCount()) + nControlPos = xColContainer->getCount(); + if (nControlPos < 0) + nControlPos = 0; + + // append the column + xColContainer->insertByIndex(nControlPos, makeAny(xNewCol)); + } + else if (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/ClearView"))) + { + ClearView(); + } + else if (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/AttachToForm"))) + { + if (!m_pDataSourceImpl) + return; + + Reference< XRowSet > xMasterForm; + // search the arguments for he master form + for (sal_uInt16 i=0; i<aArgs.getLength(); ++i, ++pArguments) + { + if ((pArguments->Name.equals(::rtl::OUString::createFromAscii("MasterForm"))) && (pArguments->Value.getValueTypeClass() == TypeClass_INTERFACE)) + { + xMasterForm = Reference< XRowSet > (*(Reference< XInterface > *)pArguments->Value.getValue(), UNO_QUERY); + break; + } + } + if (!xMasterForm.is()) + { + OSL_ASSERT("SbaExternalSourceBrowser::dispatch(FormSlots/AttachToForm) : please specify a form to attach to as argument !"); + return; + } + + Attach(xMasterForm); + } + else + SbaXDataBrowserController::dispatch(aURL, aArgs); +} + +//------------------------------------------------------------------ +Reference< ::com::sun::star::frame::XDispatch > SAL_CALL SbaExternalSourceBrowser::queryDispatch(const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw( RuntimeException ) +{ + Reference< ::com::sun::star::frame::XDispatch > xReturn; + if (m_bInQueryDispatch) + return xReturn; + + m_bInQueryDispatch = sal_True; + + if ( (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/AttachToForm"))) + // attach a new external form + || (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/AddGridColumn"))) + // add a column to the grid + || (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/ClearView"))) + // clear the grid + ) + xReturn = (::com::sun::star::frame::XDispatch*)this; + + if ( !xReturn.is() + && ( (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/moveToFirst"))) + || (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/moveToPrev"))) + || (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/moveToNext"))) + || (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/moveToLast"))) + || (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/moveToNew"))) + || (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/undoRecord"))) + ) + ) + { + OSL_ENSHURE(aURL.Mark.len() == 0, "SbaExternalSourceBrowser::queryDispatch : the ::com::sun::star::util::URL shouldn't have a mark !"); + ::com::sun::star::util::URL aNewUrl = aURL; + + // split the ::com::sun::star::util::URL + Reference< ::com::sun::star::util::XURLTransformer > xTransformer(::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.URLTransformer")), UNO_QUERY); + if (xTransformer.is()) + xTransformer->parseStrict(aNewUrl); + + // set a new mark + aNewUrl.Mark = ::rtl::OUString::createFromAscii("DB/FormGridView"); + // this controller is instantiated when somebody dispatches the ".component:DB/FormGridView" in any + // frame, so we use "FormGridView" as mark that a dispatch request came from this view + + if (xTransformer.is()) + xTransformer->assemble(aNewUrl); + + Reference< ::com::sun::star::frame::XDispatchProvider > xFrameDispatcher(m_xCurrentFrame, UNO_QUERY); + if (xFrameDispatcher.is()) + xReturn = xFrameDispatcher->queryDispatch(aNewUrl, aTargetFrameName, nSearchFlags); + +#if SUPD<=548 && !PRIV_DEBUG + xReturn = NULL; + // in version 548 the dispatch interception and the task-local beamer will work ... me hopes +#endif + } + + if (!xReturn.is()) + xReturn = SbaXDataBrowserController::queryDispatch(aURL, aTargetFrameName, nSearchFlags); + + m_bInQueryDispatch = sal_False; + return xReturn; +} + +//------------------------------------------------------------------ +void SAL_CALL SbaExternalSourceBrowser::dispose() +{ + // say our modify listeners goodbye + ::com::sun::star::lang::EventObject aEvt; + aEvt.Source = (XWeak*) this; + m_aModifyListeners.disposeAndClear(aEvt); + + stopListening(); + + if (m_xFormControllerImpl.is()) + { + Reference< ::com::sun::star::lang::XComponent > xAggComp; + m_xFormControllerImpl->queryAggregation(::getCppuType((const Reference< ::com::sun::star::lang::XComponent>*)0)) >>= xAggComp; + if (xAggComp.is()) + xAggComp->dispose(); + } + + // our aggregated object doesn't handle its frame action listening itself, so we have to log it off + Reference< ::com::sun::star::frame::XFrameActionListener > xAggListener; + if (m_xFormControllerImpl.is()) + { + m_xFormControllerImpl->queryAggregation( ::getCppuType((const Reference< ::com::sun::star::frame::XFrameActionListener >*)0)) >>= xAggListener; + m_xCurrentFrame->removeFrameActionListener(xAggListener); + } + + SbaXDataBrowserController::dispose(); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaExternalSourceBrowser::addModifyListener(const Reference< ::com::sun::star::util::XModifyListener > & aListener) throw( RuntimeException ) +{ + m_aModifyListeners.addInterface(aListener); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaExternalSourceBrowser::removeModifyListener(const Reference< ::com::sun::star::util::XModifyListener > & aListener) throw( RuntimeException ) +{ + m_aModifyListeners.removeInterface(aListener); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaExternalSourceBrowser::unloading(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException ) +{ + if (m_pDataSourceImpl && (m_pDataSourceImpl->getAttachedForm() == aEvent.Source)) + { + ClearView(); + } + + SbaXDataBrowserController::unloading(aEvent); +} + +//------------------------------------------------------------------ +void SbaExternalSourceBrowser::Attach(const Reference< XRowSet > & xMaster) +{ + // switch the control to design mode + if (getContent() && getContent()->getGridControl().is()) + getContent()->getGridControl()->setDesignMode(sal_True); + + // the grid will move the form's cursor to the first record, but we want the form to remain unchanged + Any aOldPos; + Reference< ::com::sun::star::sdbcx::XRowLocate > xCursor(xMaster, UNO_QUERY); + if (xCursor.is()) + aOldPos = xCursor->getBookmark(); + sal_Bool bWasInsertRow = sal_False; + Reference< ::com::sun::star::beans::XPropertySet > xMasterProps(xMaster, UNO_QUERY); + if (xMasterProps.is()) + { + try { bWasInsertRow = ::comphelper::getBOOL(xMasterProps->getPropertyValue(PROPERTY_ISNEW)); } + catch(...) { } ; + } + + stopListening(); + m_pDataSourceImpl->AttachForm(xMaster); + startListening(); + + if (xMaster.is()) + { + // assume that the master form is already loaded, we have no chance to check this + m_bLoadCanceled = sal_False; + FormLoaded(sal_True); + + Reference< XResultSetUpdate > xUpdate(xMaster, UNO_QUERY); + try + { + if (bWasInsertRow && xUpdate.is()) + xUpdate->moveToInsertRow(); + else if (xCursor.is() && aOldPos.hasValue()) + xCursor->moveToBookmark(aOldPos); + } + catch(...) + { + OSL_ASSERT("SbaExternalSourceBrowser::Attach : couldn't restore the cursor position !"); + } + + } +} + +//------------------------------------------------------------------ +void SbaExternalSourceBrowser::ClearView() +{ + // set a new (empty) datasource + Attach(Reference< XRowSet > ()); + + + // clear all cols in the grid + Reference< ::com::sun::star::container::XIndexContainer > xColContainer(getControlModel(), UNO_QUERY); + while (xColContainer->getCount() > 0) + xColContainer->removeByIndex(0); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaExternalSourceBrowser::disposing(const ::com::sun::star::lang::EventObject& Source) throw( RuntimeException ) +{ + if (m_pDataSourceImpl && (m_pDataSourceImpl->getAttachedForm() == Source.Source)) + { + ClearView(); + } + + if (m_xFormControllerImpl != Source.Source) + { // forward the event to my aggregate (if it isn't the source itself) + Reference< ::com::sun::star::lang::XEventListener > xAggListener; + m_xFormControllerImpl->queryAggregation(::getCppuType((const Reference< ::com::sun::star::lang::XEventListener >*)0)) >>= xAggListener; + if (xAggListener.is()) + xAggListener->disposing(Source); + } + + // the frame + if (Source.Source == m_xCurrentFrame) + { + // our aggregated object doesn't handle its frame action listening itself, so we have to log it off + Reference< ::com::sun::star::frame::XFrameActionListener > xAggListener; + if (m_xFormControllerImpl.is()) + { + m_xFormControllerImpl->queryAggregation(::getCppuType((const Reference< ::com::sun::star::frame::XFrameActionListener >*)0)) >>= xAggListener; + m_xCurrentFrame->removeFrameActionListener(xAggListener); + } + } +} +//------------------------------------------------------------------ +void SbaExternalSourceBrowser::addControlListeners(const Reference< ::com::sun::star::awt::XControl > & _xGridControl) +{ + SbaXDataBrowserController::addControlListeners(_xGridControl); + + Reference< ::com::sun::star::awt::XWindow > xWindow(_xGridControl, UNO_QUERY); + if (xWindow.is()) + xWindow->addFocusListener(this); +} + +//------------------------------------------------------------------ +void SbaExternalSourceBrowser::removeControlListeners(const Reference< ::com::sun::star::awt::XControl > & _xGridControl) +{ + SbaXDataBrowserController::removeControlListeners(_xGridControl); + + Reference< ::com::sun::star::awt::XWindow > xWindow(_xGridControl, UNO_QUERY); + if (xWindow.is()) + xWindow->removeFocusListener(this); +} + +//------------------------------------------------------------------ +void SbaExternalSourceBrowser::startListening() +{ + if (m_pDataSourceImpl && m_pDataSourceImpl->getAttachedForm().is()) + { + Reference< ::com::sun::star::form::XLoadable > xLoadable(m_pDataSourceImpl->getAttachedForm(), UNO_QUERY); + xLoadable->addLoadListener((::com::sun::star::form::XLoadListener*)this); + } +} + +//------------------------------------------------------------------ +void SbaExternalSourceBrowser::stopListening() +{ + if (m_pDataSourceImpl && m_pDataSourceImpl->getAttachedForm().is()) + { + Reference< ::com::sun::star::form::XLoadable > xLoadable(m_pDataSourceImpl->getAttachedForm(), UNO_QUERY); + xLoadable->removeLoadListener((::com::sun::star::form::XLoadListener*)this); + } +} + +//------------------------------------------------------------------ +void SAL_CALL SbaExternalSourceBrowser::focusGained(const ::com::sun::star::awt::FocusEvent& e) throw( RuntimeException ) +{ + ::com::sun::star::lang::EventObject aEvt(*this); + ::cppu::OInterfaceIteratorHelper aIter(m_pFormControllerImpl->m_aActivateListeners); + while (aIter.hasMoreElements()) + ((::com::sun::star::form::XFormControllerListener*)aIter.next())->formActivated(aEvt); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaExternalSourceBrowser::focusLost(const ::com::sun::star::awt::FocusEvent& e) throw( RuntimeException ) +{ + if (!getContent() || !getContent()->getGridControl().is()) + return; + Reference< ::com::sun::star::awt::XVclWindowPeer > xMyGridPeer(getContent()->getGridControl()->getPeer(), UNO_QUERY); + if (!xMyGridPeer.is()) + return; + Reference< ::com::sun::star::awt::XWindowPeer > xNextControlPeer(e.NextFocus, UNO_QUERY); + if (!xNextControlPeer.is()) + return; + + if (xMyGridPeer->isChild(xNextControlPeer)) + return; + + if (xMyGridPeer == xNextControlPeer) + return; + + ::com::sun::star::lang::EventObject aEvt(*this); + ::cppu::OInterfaceIteratorHelper aIter(m_pFormControllerImpl->m_aActivateListeners); + while (aIter.hasMoreElements()) + ((::com::sun::star::form::XFormControllerListener*)aIter.next())->formDeactivated(aEvt); + + // commit the changes of the grid control (as we're deactivated) + Reference< ::com::sun::star::form::XBoundComponent > xCommitable(getContent()->getGridControl(), UNO_QUERY); + if (xCommitable.is()) + xCommitable->commit(); + else + OSL_ASSERT("SbaExternalSourceBrowser::focusLost : why is my control not commitable ?"); +} + +//------------------------------------------------------------------ +sal_uInt16 SbaExternalSourceBrowser::SaveData(sal_Bool bUI, sal_Bool bForBrowsing) +{ + if (m_bSuspending) + // don't ask the user if we're beeing suspended currently + // this is the responsibility of our owner, as we are only an external view to an existing form + // 73384 - 22.02.00 - FS + return (sal_uInt16)sal_True; + + return SbaXDataBrowserController::SaveData(bUI, bForBrowsing); +} + +//================================================================== +//================================================================== + +//------------------------------------------------------------------ +SbaExternalSourceBrowser::FormControllerImpl::FormControllerImpl(SbaExternalSourceBrowser* m_pOwner) + :m_pOwner(m_pOwner) + ,m_bActive(sal_False) + ,m_aActivateListeners(m_pOwner->m_aPropertyMutex) +{ + OSL_ENSHURE(m_pOwner, "SbaExternalSourceBrowser::FormControllerImpl::FormControllerImpl : invalid Owner !"); +} + +//------------------------------------------------------------------ +SbaExternalSourceBrowser::FormControllerImpl::~FormControllerImpl() +{ +} + +//------------------------------------------------------------------ +Reference< ::com::sun::star::awt::XControl > SbaExternalSourceBrowser::FormControllerImpl::getCurrentControl(void) throw( RuntimeException ) +{ + return m_pOwner->getContent() ? m_pOwner->getContent()->getGridControl() : Reference< ::com::sun::star::awt::XControl > (); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaExternalSourceBrowser::FormControllerImpl::addActivateListener(const Reference< ::com::sun::star::form::XFormControllerListener > & l) throw( RuntimeException ) +{ + m_aActivateListeners.addInterface(l); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaExternalSourceBrowser::FormControllerImpl::removeActivateListener(const Reference< ::com::sun::star::form::XFormControllerListener > & l) throw( RuntimeException ) +{ + m_aActivateListeners.removeInterface(l); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaExternalSourceBrowser::FormControllerImpl::setModel(const Reference< ::com::sun::star::awt::XTabControllerModel > & Model) throw( RuntimeException ) +{ + OSL_ASSERT("SbaExternalSourceBrowser::FormControllerImpl::setModel : invalid call, can't change my model !"); +} + +//------------------------------------------------------------------ +Reference< ::com::sun::star::awt::XTabControllerModel > SAL_CALL SbaExternalSourceBrowser::FormControllerImpl::getModel(void) throw( RuntimeException ) +{ + OSL_ASSERT("SbaExternalSourceBrowser::FormControllerImpl::getModel : don't (and won't) have a model !"); + if (m_pOwner->m_pDataSourceImpl) + return Reference< ::com::sun::star::awt::XTabControllerModel > ((Reference< XInterface > )*m_pOwner->m_pDataSourceImpl, UNO_QUERY); + + return Reference< ::com::sun::star::awt::XTabControllerModel > (); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaExternalSourceBrowser::FormControllerImpl::setContainer(const Reference< ::com::sun::star::awt::XControlContainer > & _Container) throw( RuntimeException ) +{ + OSL_ASSERT("SbaExternalSourceBrowser::FormControllerImpl::setContainer : invalid call, can't change my container !"); +} + +//------------------------------------------------------------------ +Reference< ::com::sun::star::awt::XControlContainer > SAL_CALL SbaExternalSourceBrowser::FormControllerImpl::getContainer(void) throw( RuntimeException ) +{ + if (m_pOwner->getContent()) + return m_pOwner->getContent()->getContainer(); + return Reference< ::com::sun::star::awt::XControlContainer > (); +} + +//------------------------------------------------------------------ +Sequence< Reference< ::com::sun::star::awt::XControl > > SAL_CALL SbaExternalSourceBrowser::FormControllerImpl::getControls(void) throw( RuntimeException ) +{ + if (m_pOwner->getContent()) + { + Reference< ::com::sun::star::awt::XControl > xGrid = m_pOwner->getContent()->getGridControl(); + return Sequence< Reference< ::com::sun::star::awt::XControl > >(&xGrid, 1); + } + return Sequence< Reference< ::com::sun::star::awt::XControl > >(); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaExternalSourceBrowser::FormControllerImpl::autoTabOrder(void) throw( RuntimeException ) +{ + OSL_ASSERT("SbaExternalSourceBrowser::FormControllerImpl::autoTabOrder : nothing to do (always have only one control) !"); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaExternalSourceBrowser::FormControllerImpl::activateTabOrder(void) throw( RuntimeException ) +{ + OSL_ASSERT("SbaExternalSourceBrowser::FormControllerImpl::activateTabOrder : nothing to do (always have only one control) !"); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaExternalSourceBrowser::FormControllerImpl::activateFirst(void) throw( RuntimeException ) +{ + if (m_pOwner->getContent()) + m_pOwner->getContent()->getVclControl()->ActivateCell(); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaExternalSourceBrowser::FormControllerImpl::activateLast(void) throw( RuntimeException ) +{ + if (m_pOwner->getContent()) + m_pOwner->getContent()->getVclControl()->ActivateCell(); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaExternalSourceBrowser::FormControllerImpl::frameAction(const ::com::sun::star::frame::FrameActionEvent& aEvent) throw( RuntimeException ) +{ + OSL_ENSHURE(aEvent.Source == m_pOwner->m_xCurrentFrame, "SbaExternalSourceBrowser::FormControllerImpl::frameAction : where did this come frome ?"); + + ::com::sun::star::lang::EventObject aEvt(*m_pOwner); + ::cppu::OInterfaceIteratorHelper aIter(m_aActivateListeners); + switch (aEvent.Action) + { + case ::com::sun::star::frame::FrameAction_FRAME_ACTIVATED: + // as the frame sends more ACTIVATED than DEACTIVATING events we check this with our own flag, so the listeners + // will be notified only when the first activation occurs +// if (!m_bActive) + // TODO : when de DEACTIVATED-event is implemented (MBA) reinsert this line +// { +// while (aIter.hasMoreElements()) +// ((::com::sun::star::form::XFormControllerListener*)aIter.next())->formActivated(aEvt); +// } +// m_bActive = sal_True; + break; + + case ::com::sun::star::frame::FrameAction_FRAME_DEACTIVATING: +// while (aIter.hasMoreElements()) +// ((::com::sun::star::form::XFormControllerListener*)aIter.next())->formDeactivated(aEvt); +// m_bActive = sal_False; + break; + } +} + +//------------------------------------------------------------------ +void SAL_CALL SbaExternalSourceBrowser::FormControllerImpl::disposing(const ::com::sun::star::lang::EventObject& Source) throw( RuntimeException ) +{ + // nothing to do + // we don't add ourself as listener to any broadcasters, so we are not resposible for removing us +} + diff --git a/dbaccess/source/ui/browser/formadapter.cxx b/dbaccess/source/ui/browser/formadapter.cxx new file mode 100644 index 000000000..27f75bc78 --- /dev/null +++ b/dbaccess/source/ui/browser/formadapter.cxx @@ -0,0 +1,1908 @@ +/************************************************************************* + * + * $RCSfile: formadapter.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2000-10-26 14:42:13 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SBA_FORMADAPTER_HXX +#include "formadapter.hxx" +#endif +//#ifndef _ModuleRes_HRC +//#include "ModuleRes.hrc" +//#endif +//#ifndef _SBA_SBARES_HXX +//#include "sbares.hxx" +//#endif +#ifndef _TOOLS_DEBUG_HXX //autogen +#include <tools/debug.hxx> +#endif +#ifndef _COMPHELPER_TYPES_HXX_ +#include <comphelper/types.hxx> +#endif +#ifndef _COMPHELPER_ENUMHELPER_HXX_ +#include <comphelper/enumhelper.hxx> +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif +#ifndef _STRING_HXX +#include <tools/string.hxx> +#endif +#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "moduledbu.hxx" +#endif +#ifndef _DBU_RESOURCE_HRC_ +#include "dbu_resource.hrc" +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif + +using namespace dbaui; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::sdb; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; + +//================================================================== +// SbaXFormAdapter +//================================================================== + +//------------------------------------------------------------------ +Reference< XInterface > SbaXFormAdapter_CreateInstance(const Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory) +{ + return *(new SbaXFormAdapter()); +} +// ------------------------------------------------------------------------- +SbaXFormAdapter::SbaXFormAdapter() + :m_aLoadListeners(*this, m_aMutex) + ,m_aRowSetListeners(*this, m_aMutex) + ,m_aRowSetApproveListeners(*this, m_aMutex) + ,m_aErrorListeners(*this, m_aMutex) + ,m_aParameterListeners(*this, m_aMutex) + ,m_aSubmitListeners(*this, m_aMutex) + ,m_aPropertiesChangeListeners(*this, m_aMutex) + ,m_aPropertyChangeListeners(*this, m_aMutex) + ,m_aVetoablePropertyChangeListeners(*this, m_aMutex) + ,m_aResetListeners(*this, m_aMutex) + ,m_aDisposeListeners(m_aMutex) + ,m_aContainerListeners(m_aMutex) + ,m_nNamePropHandle(-1) +{ +} + +// ------------------------------------------------------------------------- +SbaXFormAdapter::~SbaXFormAdapter() +{ +} + +// ------------------------------------------------------------------------- +Any SAL_CALL SbaXFormAdapter::queryInterface(const Type& _rType) throw (RuntimeException) +{ + Any aReturn; + + aReturn = ::cppu::queryInterface(_rType, + static_cast< ::com::sun::star::sdbc::XResultSetMetaDataSupplier* >(this), + static_cast< ::com::sun::star::sdb::XResultSetAccess* >(this), + static_cast< ::com::sun::star::sdbc::XResultSetUpdate* >(this), + static_cast< ::com::sun::star::sdbc::XRowSet* >(this), + static_cast< ::com::sun::star::sdbc::XResultSet* >(this), + static_cast< ::com::sun::star::sdb::XRowSetApproveBroadcaster* >(this), + static_cast< ::com::sun::star::sdbcx::XRowLocate* >(this), + static_cast< ::com::sun::star::sdbc::XRowUpdate* >(this), + static_cast< ::com::sun::star::sdbc::XRow* >(this), + static_cast< ::com::sun::star::sdbcx::XColumnsSupplier* >(this), + static_cast< ::com::sun::star::sdbc::XColumnLocate* >(this), + static_cast< ::com::sun::star::sdbc::XParameters* >(this) + ); + + if (!aReturn.hasValue()) + aReturn = ::cppu::queryInterface(_rType, + static_cast< ::com::sun::star::sdbcx::XDeleteRows* >(this), + static_cast< ::com::sun::star::sdbc::XWarningsSupplier* >(this), + static_cast< ::com::sun::star::sdbc::XCloseable* >(this), + static_cast< ::com::sun::star::form::XLoadable* >(this), + static_cast< ::com::sun::star::sdb::XSQLErrorBroadcaster* >(this), + static_cast< ::com::sun::star::form::XDatabaseParameterBroadcaster* >(this), + static_cast< ::com::sun::star::form::XForm* >(this), + static_cast< ::com::sun::star::form::XFormComponent* >(this), + static_cast< ::com::sun::star::container::XChild* >(this), + static_cast< ::com::sun::star::form::XSubmit* >(this), + static_cast< ::com::sun::star::awt::XTabControllerModel* >(this), + static_cast< ::com::sun::star::lang::XComponent* >(this) + ); + + if (!aReturn.hasValue()) + aReturn = ::cppu::queryInterface(_rType, + static_cast< ::com::sun::star::beans::XFastPropertySet* >(this), + static_cast< ::com::sun::star::beans::XMultiPropertySet* >(this), + static_cast< ::com::sun::star::container::XNamed* >(this), + static_cast< ::com::sun::star::io::XPersistObject* >(this), + static_cast< ::com::sun::star::beans::XPropertySet* >(this), + static_cast< ::com::sun::star::util::XCancellable* >(this), + static_cast< ::com::sun::star::beans::XPropertyState* >(this), + static_cast< ::com::sun::star::form::XReset* >(this), + static_cast< ::com::sun::star::container::XNameContainer* >(this), + static_cast< ::com::sun::star::container::XNameReplace* >(this), + static_cast< ::com::sun::star::container::XNameAccess* >(this), + static_cast< ::com::sun::star::container::XElementAccess* >(static_cast< ::com::sun::star::container::XNameAccess* >(this)) + ); + + if (!aReturn.hasValue()) + aReturn = ::cppu::queryInterface(_rType, + static_cast< ::com::sun::star::container::XIndexContainer* >(this), + static_cast< ::com::sun::star::container::XIndexReplace* >(this), + static_cast< ::com::sun::star::container::XIndexAccess* >(this), + static_cast< ::com::sun::star::container::XContainer* >(this), + static_cast< ::com::sun::star::container::XEnumerationAccess* >(this), + static_cast< ::com::sun::star::beans::XPropertyChangeListener* >(this), + static_cast< ::com::sun::star::lang::XEventListener* >(this) + ); + + if (!aReturn.hasValue()) + OWeakObject::queryInterface(_rType); + + return aReturn; +} + +// ------------------------------------------------------------------------- +void SbaXFormAdapter::StopListening() +{ + // log off all our multiplexers + STOP_MULTIPLEXER_LISTENING(LoadListener, m_aLoadListeners, ::com::sun::star::form::XLoadable, m_xMainForm); + STOP_MULTIPLEXER_LISTENING(RowSetListener, m_aRowSetListeners, ::com::sun::star::sdbc::XRowSet, m_xMainForm); + STOP_MULTIPLEXER_LISTENING(RowSetApproveListener, m_aRowSetApproveListeners, ::com::sun::star::sdb::XRowSetApproveBroadcaster, m_xMainForm); + STOP_MULTIPLEXER_LISTENING(SQLErrorListener, m_aErrorListeners, ::com::sun::star::sdb::XSQLErrorBroadcaster, m_xMainForm); + STOP_MULTIPLEXER_LISTENING(SubmitListener, m_aSubmitListeners, ::com::sun::star::form::XSubmit, m_xMainForm); + STOP_MULTIPLEXER_LISTENING(ResetListener, m_aResetListeners, ::com::sun::star::form::XReset, m_xMainForm); + + if (m_aParameterListeners.getLength()) + { + Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->removeParameterListener(&m_aParameterListeners); + } + + STOP_PROPERTY_MULTIPLEXER_LISTENING(PropertyChangeListener, m_aPropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm); + STOP_PROPERTY_MULTIPLEXER_LISTENING(VetoableChangeListener, m_aVetoablePropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm); + if (m_aPropertiesChangeListeners.getLength()) + { + Reference< ::com::sun::star::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->removePropertiesChangeListener(&m_aPropertiesChangeListeners); + } + + // log off ourself + Reference< ::com::sun::star::lang::XComponent > xComp(m_xMainForm, UNO_QUERY); + if (xComp.is()) + xComp->removeEventListener((::com::sun::star::lang::XEventListener*)(::com::sun::star::beans::XPropertyChangeListener*)this); +} + +// ------------------------------------------------------------------------- +void SbaXFormAdapter::StartListening() +{ + // log off all our multiplexers + START_MULTIPLEXER_LISTENING(LoadListener, m_aLoadListeners, ::com::sun::star::form::XLoadable, m_xMainForm); + START_MULTIPLEXER_LISTENING(RowSetListener, m_aRowSetListeners, ::com::sun::star::sdbc::XRowSet, m_xMainForm); + START_MULTIPLEXER_LISTENING(RowSetApproveListener, m_aRowSetApproveListeners, ::com::sun::star::sdb::XRowSetApproveBroadcaster, m_xMainForm); + START_MULTIPLEXER_LISTENING(SQLErrorListener, m_aErrorListeners, ::com::sun::star::sdb::XSQLErrorBroadcaster, m_xMainForm); + START_MULTIPLEXER_LISTENING(SubmitListener, m_aSubmitListeners, ::com::sun::star::form::XSubmit, m_xMainForm); + START_MULTIPLEXER_LISTENING(ResetListener, m_aResetListeners, ::com::sun::star::form::XReset, m_xMainForm); + + if (m_aParameterListeners.getLength()) + { + Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->addParameterListener(&m_aParameterListeners); + } + + START_PROPERTY_MULTIPLEXER_LISTENING(PropertyChangeListener, m_aPropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm); + START_PROPERTY_MULTIPLEXER_LISTENING(VetoableChangeListener, m_aVetoablePropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm); + if (m_aPropertiesChangeListeners.getLength()) + { + Reference< ::com::sun::star::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY); + ::rtl::OUString sEmpty; + if (xBroadcaster.is()) + xBroadcaster->addPropertiesChangeListener(::comphelper::StringSequence(&sEmpty, 1), &m_aPropertiesChangeListeners); + } + + // log off ourself + Reference< ::com::sun::star::lang::XComponent > xComp(m_xMainForm, UNO_QUERY); + if (xComp.is()) + xComp->addEventListener((::com::sun::star::lang::XEventListener*)(::com::sun::star::beans::XPropertyChangeListener*)this); +} + +// ------------------------------------------------------------------------- +void SbaXFormAdapter::AttachForm(const Reference< ::com::sun::star::sdbc::XRowSet >& xNewMaster) +{ + if (xNewMaster == m_xMainForm) + return; + + DBG_ASSERT(xNewMaster.get() != static_cast< ::com::sun::star::sdbc::XRowSet* >(this), "SbaXFormAdapter::AttachForm : invalid argument !"); + + if (m_xMainForm.is()) + { + StopListening(); + + // if our old master is loaded we have to send an 'unloaded' event + Reference< ::com::sun::star::form::XLoadable > xLoadable(m_xMainForm, UNO_QUERY); + if (xLoadable->isLoaded()) + { + ::com::sun::star::lang::EventObject aEvt(*this); + ::cppu::OInterfaceIteratorHelper aIt(m_aLoadListeners); + while (aIt.hasMoreElements()) + ((::com::sun::star::form::XLoadListener*)aIt.next())->unloaded(aEvt); + } + } + + m_xMainForm = xNewMaster; + + if (m_xMainForm.is()) + { + StartListening(); + + // if our new master is loaded we have to send an 'loaded' event + Reference< ::com::sun::star::form::XLoadable > xLoadable(m_xMainForm, UNO_QUERY); + if (xLoadable->isLoaded()) + { + ::com::sun::star::lang::EventObject aEvt(*this); + ::cppu::OInterfaceIteratorHelper aIt(m_aLoadListeners); + while (aIt.hasMoreElements()) + ((::com::sun::star::form::XLoadListener*)aIt.next())->loaded(aEvt); + } + } + + // TODO : perhaps _all_ of our listeners should be notified about our new state + // (nearly every aspect of us may have changed with new master form) +} + +// ::com::sun::star::sdbc::XCloseable +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::close() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XCloseable > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->close(); +} + +// ::com::sun::star::sdbc::XResultSetMetaDataSupplier +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL SbaXFormAdapter::getMetaData() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XResultSetMetaDataSupplier > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->getMetaData(); + return Reference< ::com::sun::star::sdbc::XResultSetMetaData > (); +} + +// ::com::sun::star::sdbc::XColumnLocate +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL SbaXFormAdapter::findColumn(const ::rtl::OUString& columnName) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XColumnLocate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->findColumn(columnName); + return 0; +} + +// ::com::sun::star::sdbcx::XColumnsSupplier +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::container::XNameAccess > SAL_CALL SbaXFormAdapter::getColumns() throw( RuntimeException ) +{ + Reference< ::com::sun::star::sdbcx::XColumnsSupplier > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->getColumns(); + return Reference< ::com::sun::star::container::XNameAccess > (); +} + +// ::com::sun::star::sdbc::XRow +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL SbaXFormAdapter::wasNull() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->wasNull(); + return sal_True; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL SbaXFormAdapter::getString(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->getString(columnIndex); + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL SbaXFormAdapter::getBoolean(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->getBoolean(columnIndex); + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Int8 SAL_CALL SbaXFormAdapter::getByte(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->getByte(columnIndex); + return 0; +} +// ------------------------------------------------------------------------- +sal_Int16 SAL_CALL SbaXFormAdapter::getShort(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->getShort(columnIndex); + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL SbaXFormAdapter::getInt(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->getInt(columnIndex); + return 0; +} +// ------------------------------------------------------------------------- +Hyper SAL_CALL SbaXFormAdapter::getLong(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->getLong(columnIndex); + return 0; +} +// ------------------------------------------------------------------------- +float SAL_CALL SbaXFormAdapter::getFloat(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->getFloat(columnIndex); + return 0.0; +} +// ------------------------------------------------------------------------- +double SAL_CALL SbaXFormAdapter::getDouble(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->getDouble(columnIndex); + return 0.0; +} +// ------------------------------------------------------------------------- +Sequence< sal_Int8 > SAL_CALL SbaXFormAdapter::getBytes(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->getBytes(columnIndex); + return Sequence <sal_Int8> (); +} +// ------------------------------------------------------------------------- +::com::sun::star::util::Date SAL_CALL SbaXFormAdapter::getDate(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->getDate(columnIndex); + return ::com::sun::star::util::Date(); +} +// ------------------------------------------------------------------------- +::com::sun::star::util::Time SAL_CALL SbaXFormAdapter::getTime(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->getTime(columnIndex); + return ::com::sun::star::util::Time(); +} +// ------------------------------------------------------------------------- +::com::sun::star::util::DateTime SAL_CALL SbaXFormAdapter::getTimestamp(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->getTimestamp(columnIndex); + return ::com::sun::star::util::DateTime(); +} +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::io::XInputStream > SAL_CALL SbaXFormAdapter::getBinaryStream(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->getBinaryStream(columnIndex); + return Reference< ::com::sun::star::io::XInputStream > (); +} +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::io::XInputStream > SAL_CALL SbaXFormAdapter::getCharacterStream(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->getCharacterStream(columnIndex); + return Reference< ::com::sun::star::io::XInputStream > (); +} +// ------------------------------------------------------------------------- +Any SAL_CALL SbaXFormAdapter::getObject(sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->getObject(columnIndex, typeMap); + return Any(); +} +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::sdbc::XRef > SAL_CALL SbaXFormAdapter::getRef(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->getRef(columnIndex); + return Reference< ::com::sun::star::sdbc::XRef > (); +} +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL SbaXFormAdapter::getBlob(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->getBlob(columnIndex); + return Reference< ::com::sun::star::sdbc::XBlob > (); +} +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::sdbc::XClob > SAL_CALL SbaXFormAdapter::getClob(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->getClob(columnIndex); + return Reference< ::com::sun::star::sdbc::XClob > (); +} +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::sdbc::XArray > SAL_CALL SbaXFormAdapter::getArray(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->getArray(columnIndex); + return Reference< ::com::sun::star::sdbc::XArray > (); +} + +// ::com::sun::star::sdbcx::XRowLocate +// ------------------------------------------------------------------------- +Any SAL_CALL SbaXFormAdapter::getBookmark() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->getBookmark(); + return Any(); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL SbaXFormAdapter::moveToBookmark(const Any& bookmark) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->moveToBookmark(bookmark); + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL SbaXFormAdapter::moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->moveRelativeToBookmark(bookmark,rows); + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL SbaXFormAdapter::compareBookmarks(const Any& first, const Any& second) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->compareBookmarks(first, second); + return 0; +} + +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL SbaXFormAdapter::hasOrderedBookmarks() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->hasOrderedBookmarks(); + return sal_False; +} + +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL SbaXFormAdapter::hashBookmark(const Any& bookmark) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->hashBookmark(bookmark); + return 0; +} + +// ::com::sun::star::sdbc::XRowUpdate +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::updateNull(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->updateNull(columnIndex); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::updateBoolean(sal_Int32 columnIndex, sal_Bool x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->updateBoolean(columnIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::updateByte(sal_Int32 columnIndex, sal_Int8 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->updateByte(columnIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::updateShort(sal_Int32 columnIndex, sal_Int16 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->updateShort(columnIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::updateInt(sal_Int32 columnIndex, sal_Int32 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->updateInt(columnIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::updateLong(sal_Int32 columnIndex, Hyper x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->updateLong(columnIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::updateFloat(sal_Int32 columnIndex, float x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->updateFloat(columnIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::updateDouble(sal_Int32 columnIndex, double x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->updateDouble(columnIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::updateString(sal_Int32 columnIndex, const ::rtl::OUString& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->updateString(columnIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::updateBytes(sal_Int32 columnIndex, const Sequence< sal_Int8 >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->updateBytes(columnIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::updateDate(sal_Int32 columnIndex, const ::com::sun::star::util::Date& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->updateDate(columnIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::updateTime(sal_Int32 columnIndex, const ::com::sun::star::util::Time& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->updateTime(columnIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::updateTimestamp(sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->updateTimestamp(columnIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::updateBinaryStream(sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->updateBinaryStream(columnIndex, x, length); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::updateCharacterStream(sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->updateCharacterStream(columnIndex, x, length); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::updateObject(sal_Int32 columnIndex, const Any& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->updateObject(columnIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::updateNumericObject(sal_Int32 columnIndex, const Any& x, sal_Int32 scale) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->updateNumericObject(columnIndex, x, scale); +} + +// ::com::sun::star::sdbc::XResultSet +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL SbaXFormAdapter::next() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + if (m_xMainForm.is()) + return m_xMainForm->next(); + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL SbaXFormAdapter::isBeforeFirst() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + if (m_xMainForm.is()) + return m_xMainForm->isBeforeFirst(); + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL SbaXFormAdapter::isAfterLast() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + if (m_xMainForm.is()) + return m_xMainForm->isAfterLast(); + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL SbaXFormAdapter::isFirst() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + if (m_xMainForm.is()) + return m_xMainForm->isFirst(); + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL SbaXFormAdapter::isLast() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + if (m_xMainForm.is()) + return m_xMainForm->isLast(); + return sal_False; +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::beforeFirst() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + if (m_xMainForm.is()) + m_xMainForm->beforeFirst(); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::afterLast() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + if (m_xMainForm.is()) + m_xMainForm->afterLast(); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL SbaXFormAdapter::first() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + if (m_xMainForm.is()) + return m_xMainForm->first(); + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL SbaXFormAdapter::last() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + if (m_xMainForm.is()) + return m_xMainForm->last(); + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL SbaXFormAdapter::getRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + if (m_xMainForm.is()) + return m_xMainForm->getRow(); + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL SbaXFormAdapter::absolute(sal_Int32 row) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + if (m_xMainForm.is()) + return m_xMainForm->absolute(row); + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL SbaXFormAdapter::relative(sal_Int32 rows) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + if (m_xMainForm.is()) + return m_xMainForm->relative(rows); + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL SbaXFormAdapter::previous() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + if (m_xMainForm.is()) + return m_xMainForm->previous(); + return sal_False; +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::refreshRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + if (m_xMainForm.is()) + m_xMainForm->refreshRow(); +} + +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL SbaXFormAdapter::rowUpdated() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + if (m_xMainForm.is()) + return m_xMainForm->rowUpdated(); + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL SbaXFormAdapter::rowInserted() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + if (m_xMainForm.is()) + return m_xMainForm->rowInserted(); + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL SbaXFormAdapter::rowDeleted() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + if (m_xMainForm.is()) + return m_xMainForm->rowDeleted(); + return sal_False; +} +// ------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL SbaXFormAdapter::getStatement() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + if (m_xMainForm.is()) + return m_xMainForm->getStatement(); + return NULL; +} + +// ::com::sun::star::sdbc::XResultSetUpdate +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::insertRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->insertRow(); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::updateRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->updateRow(); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::deleteRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->deleteRow(); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::cancelRowUpdates() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->cancelRowUpdates(); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::moveToInsertRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->moveToInsertRow(); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::moveToCurrentRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->moveToCurrentRow(); +} + +// ::com::sun::star::sdbc::XRowSet +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::execute() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + if (m_xMainForm.is()) + m_xMainForm->execute(); +} +// ------------------------------------------------------------------------- +IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, sdbc, RowSetListener, m_aRowSetListeners, ::com::sun::star::sdbc::XRowSet, m_xMainForm) + +// ::com::sun::star::sdbcx::XDeleteRows +// ------------------------------------------------------------------------- +Sequence<sal_Int32> SAL_CALL SbaXFormAdapter::deleteRows(const Sequence< Any >& rows) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbcx::XDeleteRows > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->deleteRows(rows); + return Sequence<sal_Int32>(); +} + +// ::com::sun::star::sdbc::XWarningsSupplier +// ------------------------------------------------------------------------- +Any SAL_CALL SbaXFormAdapter::getWarnings() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XWarningsSupplier > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->getWarnings(); + return Any(); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::clearWarnings() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XWarningsSupplier > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->clearWarnings(); +} + +// ::com::sun::star::sdb::XRowSetApproveBroadcaster +// ------------------------------------------------------------------------- +IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, sdb, RowSetApproveListener, m_aRowSetApproveListeners, ::com::sun::star::sdb::XRowSetApproveBroadcaster, m_xMainForm) + +// com::sun::star::sdbc::XSQLErrorBroadcaster +// ------------------------------------------------------------------------- +IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, sdb, SQLErrorListener, m_aErrorListeners, ::com::sun::star::sdb::XSQLErrorBroadcaster, m_xMainForm) + +// ::com::sun::star::sdb::XResultSetAccess +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL SbaXFormAdapter::createResultSet() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdb::XResultSetAccess > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->createResultSet(); + return Reference< ::com::sun::star::sdbc::XResultSet > (); +} + +// com::sun::star::form::XLoadable +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::load() throw( RuntimeException ) +{ + Reference< ::com::sun::star::form::XLoadable > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->load(); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::unload() throw( RuntimeException ) +{ + Reference< ::com::sun::star::form::XLoadable > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->unload(); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::reload() throw( RuntimeException ) +{ + Reference< ::com::sun::star::form::XLoadable > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->reload(); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL SbaXFormAdapter::isLoaded() throw( RuntimeException ) +{ + Reference< ::com::sun::star::form::XLoadable > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + return xIface->isLoaded(); + return sal_False; +} +// ------------------------------------------------------------------------- +IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, form, LoadListener, m_aLoadListeners, ::com::sun::star::form::XLoadable, m_xMainForm) + +// ::com::sun::star::sdbc::XParameters +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setNull(sal_Int32 parameterIndex, sal_Int32 sqlType) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->setNull(parameterIndex, sqlType); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setObjectNull(sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->setObjectNull(parameterIndex, sqlType, typeName); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setBoolean(sal_Int32 parameterIndex, sal_Bool x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->setBoolean(parameterIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setByte(sal_Int32 parameterIndex, sal_Int8 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->setByte(parameterIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setShort(sal_Int32 parameterIndex, sal_Int16 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->setShort(parameterIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setInt(sal_Int32 parameterIndex, sal_Int32 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->setInt(parameterIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setLong(sal_Int32 parameterIndex, Hyper x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->setLong(parameterIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setFloat(sal_Int32 parameterIndex, float x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->setFloat(parameterIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setDouble(sal_Int32 parameterIndex, double x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->setDouble(parameterIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setString(sal_Int32 parameterIndex, const ::rtl::OUString& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->setString(parameterIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setBytes(sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->setBytes(parameterIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setDate(sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->setDate(parameterIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setTime(sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->setTime(parameterIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setTimestamp(sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->setTimestamp(parameterIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setBinaryStream(sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->setBinaryStream(parameterIndex, x, length); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setCharacterStream(sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->setCharacterStream(parameterIndex, x, length); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setObject(sal_Int32 parameterIndex, const Any& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->setObject(parameterIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setObjectWithInfo(sal_Int32 parameterIndex, const Any& x, sal_Int32 targetSqlType, sal_Int32 scale) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->setObjectWithInfo(parameterIndex, x, targetSqlType, scale); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setRef(sal_Int32 parameterIndex, const Reference< ::com::sun::star::sdbc::XRef >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->setRef(parameterIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setBlob(sal_Int32 parameterIndex, const Reference< ::com::sun::star::sdbc::XBlob >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->setBlob(parameterIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setClob(sal_Int32 parameterIndex, const Reference< ::com::sun::star::sdbc::XClob >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->setClob(parameterIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setArray(sal_Int32 parameterIndex, const Reference< ::com::sun::star::sdbc::XArray >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->setArray(parameterIndex, x); +} +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::clearParameters() throw( ::com::sun::star::sdbc::SQLException, RuntimeException ) +{ + Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY); + if (xIface.is()) + xIface->clearParameters(); +} + +// ::com::sun::star::form::XDatabaseParameterBroadcaster +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::addParameterListener(const Reference< ::com::sun::star::form::XDatabaseParameterListener >& aListener) throw( RuntimeException ) +{ + m_aParameterListeners.addInterface(aListener); + if (m_aParameterListeners.getLength() == 1) + { + Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->addParameterListener(&m_aParameterListeners); + } +} + +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::removeParameterListener(const Reference< ::com::sun::star::form::XDatabaseParameterListener >& aListener) throw( RuntimeException ) +{ + if (m_aParameterListeners.getLength() == 1) + { + Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->removeParameterListener(&m_aParameterListeners); + } + m_aParameterListeners.removeInterface(aListener); +} + +// ::com::sun::star::container::XChild +// ------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL SbaXFormAdapter::getParent() throw( RuntimeException ) +{ + return m_xParent; +} + +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setParent(const Reference< XInterface >& Parent) throw( ::com::sun::star::lang::NoSupportException, RuntimeException ) +{ + m_xParent = Parent; +} + +// ::com::sun::star::form::XSubmit +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::submit(const Reference< ::com::sun::star::awt::XControl >& aControl, const ::com::sun::star::awt::MouseEvent& aMouseEvt) throw( RuntimeException ) +{ + Reference< ::com::sun::star::form::XSubmit > xSubmit(m_xMainForm, UNO_QUERY); + if (xSubmit.is()) + xSubmit->submit(aControl, aMouseEvt); +} + +IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, form, SubmitListener, m_aSubmitListeners, ::com::sun::star::form::XSubmit, m_xMainForm) + +// ::com::sun::star::awt::XTabControllerModel +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL SbaXFormAdapter::getGroupControl() throw( RuntimeException ) +{ + DBG_ERROR("SAL_CALL SbaXFormAdapter::getGroupControl : not supported !"); + return sal_False; +} + +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setGroupControl(sal_Bool GroupControl) throw( RuntimeException ) +{ + DBG_ERROR("SAL_CALL SbaXFormAdapter::setGroupControl : not supported !"); +} + +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setControlModels(const Sequence< Reference< ::com::sun::star::awt::XControlModel > >& Controls) throw( RuntimeException ) +{ + DBG_ERROR("SAL_CALL SbaXFormAdapter::setControlModels : not supported !"); +} + +// ------------------------------------------------------------------------- +Sequence< Reference< ::com::sun::star::awt::XControlModel > > SAL_CALL SbaXFormAdapter::getControlModels() throw( RuntimeException ) +{ + DBG_ERROR("SAL_CALL SbaXFormAdapter::getControlModels : not supported !"); + return Sequence< Reference< ::com::sun::star::awt::XControlModel > >(); +} + +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setGroup(const Sequence< Reference< ::com::sun::star::awt::XControlModel > >& _rGroup, const ::rtl::OUString& GroupName) throw( RuntimeException ) +{ + DBG_ERROR("SAL_CALL SbaXFormAdapter::setGroup : not supported !"); +} + +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL SbaXFormAdapter::getGroupCount() throw( RuntimeException ) +{ + DBG_ERROR("SAL_CALL SbaXFormAdapter::getGroupCount : not supported !"); + return 0; +} + +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::getGroup(sal_Int32 nGroup, Sequence< Reference< ::com::sun::star::awt::XControlModel > >& _rGroup, ::rtl::OUString& Name) throw( RuntimeException ) +{ + DBG_ERROR("SAL_CALL SbaXFormAdapter::getGroup : not supported !"); +} + +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::getGroupByName(const ::rtl::OUString& Name, Sequence< Reference< ::com::sun::star::awt::XControlModel > >& _rGroup) throw( RuntimeException ) +{ + DBG_ERROR("SAL_CALL SbaXFormAdapter::getGroupByName : not supported !"); +} + +// ::com::sun::star::lang::XComponent +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::dispose() throw( RuntimeException ) +{ + // log off all multiplexers + if (m_xMainForm.is()) + StopListening(); + + ::com::sun::star::lang::EventObject aEvt(*this); + m_aLoadListeners.disposeAndClear(aEvt); + m_aRowSetListeners.disposeAndClear(aEvt); + m_aRowSetApproveListeners.disposeAndClear(aEvt); + m_aErrorListeners.disposeAndClear(aEvt); + m_aParameterListeners.disposeAndClear(aEvt); + m_aSubmitListeners.disposeAndClear(aEvt); + m_aResetListeners.disposeAndClear(aEvt); + + m_aVetoablePropertyChangeListeners.disposeAndClear(); + m_aPropertyChangeListeners.disposeAndClear(); + m_aPropertiesChangeListeners.disposeAndClear(aEvt); + + m_aDisposeListeners.disposeAndClear(aEvt); + m_aContainerListeners.disposeAndClear(aEvt); + + // dispose all childs + for ( vector< Reference< ::com::sun::star::form::XFormComponent > >::iterator aIter = m_aChildren.begin(); + aIter != m_aChildren.end(); + ++aIter + ) + { + Reference< ::com::sun::star::beans::XPropertySet > xSet(*aIter, UNO_QUERY); + if (xSet.is()) + xSet->removePropertyChangeListener(PROPERTY_NAME, (::com::sun::star::beans::XPropertyChangeListener*)this); + + Reference< ::com::sun::star::container::XChild > xChild(*aIter, UNO_QUERY); + if (xChild.is()) + xChild->setParent(Reference< XInterface > ()); + + Reference< ::com::sun::star::lang::XComponent > xComp(*aIter, UNO_QUERY); + if (xComp.is()) + xComp->dispose(); + } + m_aChildren.clear(); +} + +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::addEventListener(const Reference< ::com::sun::star::lang::XEventListener >& xListener) throw( RuntimeException ) +{ + m_aDisposeListeners.addInterface(xListener); +} + +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::removeEventListener(const Reference< ::com::sun::star::lang::XEventListener >& aListener) throw( RuntimeException ) +{ + m_aDisposeListeners.removeInterface(aListener); +} + +// ::com::sun::star::beans::XFastPropertySet +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setFastPropertyValue(sal_Int32 nHandle, const Any& aValue) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, RuntimeException ) +{ + Reference< ::com::sun::star::beans::XFastPropertySet > xSet(m_xMainForm, UNO_QUERY); + DBG_ASSERT(xSet.is(), "SAL_CALL SbaXFormAdapter::setFastPropertyValue : have no master form !"); + + if (m_nNamePropHandle == nHandle) + { + if (aValue.getValueType().getTypeClass() != TypeClass_STRING) + { + throw ::com::sun::star::lang::IllegalArgumentException(); + } + + // for notifying property listeners + ::com::sun::star::beans::PropertyChangeEvent aEvt; + aEvt.Source = *this; + aEvt.PropertyName = PROPERTY_NAME; + aEvt.PropertyHandle = m_nNamePropHandle; + aEvt.OldValue <<= m_sName; + aEvt.NewValue = aValue; + + aValue >>= m_sName; + + ::cppu::OInterfaceIteratorHelper aIt(*m_aPropertyChangeListeners.getContainer(PROPERTY_NAME)); + while (aIt.hasMoreElements()) + ((::com::sun::star::beans::XPropertyChangeListener*)aIt.next())->propertyChange(aEvt); + + return; + } + + xSet->setFastPropertyValue(nHandle, aValue); +} + +// ------------------------------------------------------------------------- +Any SAL_CALL SbaXFormAdapter::getFastPropertyValue(sal_Int32 nHandle) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, RuntimeException ) +{ + Reference< ::com::sun::star::beans::XFastPropertySet > xSet(m_xMainForm, UNO_QUERY); + DBG_ASSERT(xSet.is(), "SAL_CALL SbaXFormAdapter::getFastPropertyValue : have no master form !"); + + if (m_nNamePropHandle == nHandle) + return makeAny(m_sName); + + return xSet->getFastPropertyValue(nHandle); +} + +// ::com::sun::star::container::XNamed +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL SbaXFormAdapter::getName() throw( RuntimeException ) +{ + return ::comphelper::getString(getPropertyValue(PROPERTY_NAME)); +} + +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setName(const ::rtl::OUString& aName) throw( RuntimeException ) +{ + setPropertyValue(PROPERTY_NAME, makeAny(aName)); +} + +// ::com::sun::star::io::XPersistObject +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL SbaXFormAdapter::getServiceName() throw( RuntimeException ) +{ + Reference< ::com::sun::star::io::XPersistObject > xPersist(m_xMainForm, UNO_QUERY); + if (xPersist.is()) + return xPersist->getServiceName(); + return ::rtl::OUString(); +} + +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::write(const Reference< ::com::sun::star::io::XObjectOutputStream >& _rxOutStream) throw( ::com::sun::star::io::IOException, RuntimeException ) +{ + Reference< ::com::sun::star::io::XPersistObject > xPersist(m_xMainForm, UNO_QUERY); + if (xPersist.is()) + xPersist->write(_rxOutStream); +} + +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::read(const Reference< ::com::sun::star::io::XObjectInputStream >& _rxInStream) throw( ::com::sun::star::io::IOException, RuntimeException ) +{ + Reference< ::com::sun::star::io::XPersistObject > xPersist(m_xMainForm, UNO_QUERY); + if (xPersist.is()) + xPersist->read(_rxInStream); +} + +// ::com::sun::star::beans::XMultiPropertySet +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL SbaXFormAdapter::getPropertySetInfo() throw( RuntimeException ) +{ + Reference< ::com::sun::star::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY); + if (!xSet.is()) + return Reference< ::com::sun::star::beans::XPropertySetInfo > (); + + Reference< ::com::sun::star::beans::XPropertySetInfo > xReturn = xSet->getPropertySetInfo(); + if (-1 == m_nNamePropHandle) + { + // we need to determine the handle for the NAME property + Sequence< ::com::sun::star::beans::Property> aProps = xReturn->getProperties(); + const ::com::sun::star::beans::Property* pProps = aProps.getConstArray(); + + for (sal_Int32 i=0; i<aProps.getLength(); ++i, ++pProps) + { + if (pProps->Name.equals(PROPERTY_NAME)) + { + ((SbaXFormAdapter*)this)->m_nNamePropHandle = pProps->Handle; + break; + } + } + } + return xReturn; +} + +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setPropertyValues(const Sequence< ::rtl::OUString >& PropertyNames, const Sequence< Any >& Values) throw( ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, RuntimeException ) +{ + Reference< ::com::sun::star::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY); + if (xSet.is()) + xSet->setPropertyValues(PropertyNames, Values); +} + +// ------------------------------------------------------------------------- +Sequence< Any > SAL_CALL SbaXFormAdapter::getPropertyValues(const Sequence< ::rtl::OUString >& aPropertyNames) throw( RuntimeException ) +{ + Reference< ::com::sun::star::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY); + if (!xSet.is()) + return Sequence< Any>(aPropertyNames.getLength()); + + Sequence< Any> aReturn = xSet->getPropertyValues(aPropertyNames); + + // search for (and fake) the NAME property + const ::rtl::OUString* pNames = aPropertyNames.getConstArray(); + Any* pValues = aReturn.getArray(); + DBG_ASSERT(aReturn.getLength() == aPropertyNames.getLength(), "SAL_CALL SbaXFormAdapter::getPropertyValues : the main form returned an invalid-length sequence !"); + for (sal_Int32 i=0; i<aPropertyNames.getLength(); ++i, ++pNames, ++pValues) + if (pNames->equals(PROPERTY_NAME)) + { + (*pValues) <<= m_sName; + break; + } + + return aReturn; +} + +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::addPropertiesChangeListener(const Sequence< ::rtl::OUString>& aPropertyNames, const Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener) throw( RuntimeException ) +{ + // we completely ignore the property names, _all_ changes of _all_ properties will be forwarded to _all_ listeners + m_aPropertiesChangeListeners.addInterface(xListener); + if (m_aPropertiesChangeListeners.getLength() == 1) + { + Reference< ::com::sun::star::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY); + ::rtl::OUString sEmpty; + if (xBroadcaster.is()) + xBroadcaster->addPropertiesChangeListener(Sequence< ::rtl::OUString>(&sEmpty, 1), &m_aPropertiesChangeListeners); + } +} + +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::removePropertiesChangeListener(const Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener) throw( RuntimeException ) +{ + if (m_aPropertiesChangeListeners.getLength() == 1) + { + Reference< ::com::sun::star::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->removePropertiesChangeListener(&m_aPropertiesChangeListeners); + } + m_aPropertiesChangeListeners.removeInterface(Listener); +} + +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::firePropertiesChangeEvent(const Sequence< ::rtl::OUString >& aPropertyNames, const Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener) throw( RuntimeException ) +{ + Reference< ::com::sun::star::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY); + if (xSet.is()) + xSet->firePropertiesChangeEvent(aPropertyNames, xListener); +} + + +// ::com::sun::star::beans::XPropertySet +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setPropertyValue(const ::rtl::OUString& aPropertyName, const Any& aValue) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, RuntimeException ) +{ + Reference< ::com::sun::star::beans::XPropertySet > xSet(m_xMainForm, UNO_QUERY); + if (!xSet.is()) + return; + + // special handling for the "name" property + if (aPropertyName.equals(PROPERTY_NAME)) + setFastPropertyValue(m_nNamePropHandle, aValue); + + xSet->setPropertyValue(aPropertyName, aValue); +} + +// ------------------------------------------------------------------------- +Any SAL_CALL SbaXFormAdapter::getPropertyValue(const ::rtl::OUString& PropertyName) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, RuntimeException ) +{ + Reference< ::com::sun::star::beans::XPropertySet > xSet(m_xMainForm, UNO_QUERY); + if (!xSet.is()) + return Any(); + + // special handling for the "name" property + if (PropertyName.equals(PROPERTY_NAME)) + return getFastPropertyValue(m_nNamePropHandle); + + return xSet->getPropertyValue(PropertyName); +} + +IMPLEMENT_PROPERTY_LISTENER_ADMINISTRATION(SbaXFormAdapter, PropertyChangeListener, m_aPropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm); +IMPLEMENT_PROPERTY_LISTENER_ADMINISTRATION(SbaXFormAdapter, VetoableChangeListener, m_aVetoablePropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm); + +// ::com::sun::star::util::XCancellable +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::cancel() throw( RuntimeException ) +{ + Reference< ::com::sun::star::util::XCancellable > xCancel(m_xMainForm, UNO_QUERY); + if (xCancel.is()) + return; + xCancel->cancel(); +} + +// Helper +//------------------------------------------------------------------------------ +void SbaXFormAdapter::onError(::com::sun::star::sdbc::SQLException& rException) +{ + // just notify all listeners + if (m_aErrorListeners.getLength()) + { + rException.Context = *this; + + Any aVal; + aVal <<= rException; + ::com::sun::star::sdb::SQLErrorEvent aEvt(*this, aVal); + + ::cppu::OInterfaceIteratorHelper aIt((::cppu::OInterfaceContainerHelper&)m_aErrorListeners); + while (aIt.hasMoreElements()) + ((::com::sun::star::sdb::XSQLErrorListener*)aIt.next())->errorOccured(aEvt); + } +} + +// ------------------------------------------------------------------------- +sal_Bool SbaXFormAdapter::checkMainForm() +{ + if (m_xMainForm.is()) + return sal_True; + + ::com::sun::star::sdbc::SQLException aException; + aException.Message = String(ModuleRes(RID_STR_CONNECTION_LOST)); + onError(aException); + return sal_False; +} + +// ::com::sun::star::beans::XPropertyState +// ------------------------------------------------------------------------- +::com::sun::star::beans::PropertyState SAL_CALL SbaXFormAdapter::getPropertyState(const ::rtl::OUString& PropertyName) throw( ::com::sun::star::beans::UnknownPropertyException, RuntimeException ) +{ + Reference< ::com::sun::star::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY); + if (xState.is()) + return xState->getPropertyState(PropertyName); + return ::com::sun::star::beans::PropertyState_DEFAULT_VALUE; +} + +// ------------------------------------------------------------------------- +Sequence< ::com::sun::star::beans::PropertyState> SAL_CALL SbaXFormAdapter::getPropertyStates(const Sequence< ::rtl::OUString >& aPropertyName) throw( ::com::sun::star::beans::UnknownPropertyException, RuntimeException ) +{ + Reference< ::com::sun::star::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY); + if (xState.is()) + return xState->getPropertyStates(aPropertyName); + + // set them all to DEFAULT + Sequence< ::com::sun::star::beans::PropertyState> aReturn(aPropertyName.getLength()); + ::com::sun::star::beans::PropertyState* pStates = aReturn.getArray(); + for (sal_uInt16 i=0; i<aPropertyName.getLength(); ++i, ++pStates) + *pStates = ::com::sun::star::beans::PropertyState_DEFAULT_VALUE; + return aReturn; +} + +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::setPropertyToDefault(const ::rtl::OUString& PropertyName) throw( ::com::sun::star::beans::UnknownPropertyException, RuntimeException ) +{ + Reference< ::com::sun::star::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY); + if (xState.is()) + xState->setPropertyToDefault(PropertyName); +} + +// ------------------------------------------------------------------------- +Any SAL_CALL SbaXFormAdapter::getPropertyDefault(const ::rtl::OUString& aPropertyName) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, RuntimeException ) +{ + Reference< ::com::sun::star::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY); + if (xState.is()) + return xState->getPropertyDefault(aPropertyName); + return Any(); +} + +// ::com::sun::star::form::XReset +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::reset() throw( RuntimeException ) +{ + Reference< ::com::sun::star::form::XReset > xReset(m_xMainForm, UNO_QUERY); + if (xReset.is()) + xReset->reset(); +} + +IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, form, ResetListener, m_aResetListeners, ::com::sun::star::form::XReset, m_xMainForm) + +// ::com::sun::star::container::XNameContainer +// ------------------------------------------------------------------------- +void SbaXFormAdapter::implInsert(const Any& aElement, sal_uInt16 nIndex, const ::rtl::OUString* pNewElName) throw( ::com::sun::star::lang::IllegalArgumentException ) +{ + // extract the form component + if (aElement.getValueType().getTypeClass() != TypeClass_INTERFACE) + { + throw ::com::sun::star::lang::IllegalArgumentException(); + } + + Reference< ::com::sun::star::form::XFormComponent > xElement(*(Reference< XInterface > *)aElement.getValue(), UNO_QUERY); + if (!xElement.is()) + { + throw ::com::sun::star::lang::IllegalArgumentException(); + } + + // for the name we need the propset + Reference< ::com::sun::star::beans::XPropertySet > xElementSet(xElement, UNO_QUERY); + if (!xElementSet.is()) + { + throw ::com::sun::star::lang::IllegalArgumentException(); + } + ::rtl::OUString sName; + try + { + if (pNewElName) + xElementSet->setPropertyValue(PROPERTY_NAME, makeAny(*pNewElName)); + + xElementSet->getPropertyValue(PROPERTY_NAME) >>= sName; + } + catch(...) + { + // the set didn't support the name prop + throw ::com::sun::star::lang::IllegalArgumentException(); + } + + // check the index + if (nIndex > m_aChildren.size()) + nIndex = m_aChildren.size(); + + DBG_ASSERT(m_aChildren.size() == m_aChildNames.size(), "SAL_CALL SbaXFormAdapter::implInsert : inconsistent container state !"); + m_aChildren.insert(m_aChildren.begin() + nIndex, xElement); + m_aChildNames.insert(m_aChildNames.begin() + nIndex, sName); + + // listen for a changes of the name + xElementSet->addPropertyChangeListener(PROPERTY_NAME, (::com::sun::star::beans::XPropertyChangeListener*)this); + + // we are now the parent of the new element + xElement->setParent((::com::sun::star::container::XContainer*)this); + + // notify the container listeners + ::com::sun::star::container::ContainerEvent aEvt; + aEvt.Source = *this; + aEvt.Accessor <<= (sal_Int32)nIndex; + aEvt.Element <<= xElement; + ::cppu::OInterfaceIteratorHelper aIt(m_aContainerListeners); + while (aIt.hasMoreElements()) + ((::com::sun::star::container::XContainerListener*)aIt.next())->elementInserted(aEvt); +} + +// ------------------------------------------------------------------------- +sal_Int32 SbaXFormAdapter::implGetPos(const ::rtl::OUString& rName) const +{ + for ( vector< ::rtl::OUString>::const_iterator aIter = m_aChildNames.begin(); + aIter != m_aChildNames.end(); + ++aIter + ) + { + if ((*aIter).equals(rName)) + return aIter - m_aChildNames.begin(); + } + return -1; +} + +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::insertByName(const ::rtl::OUString& aName, const Any& aElement) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, RuntimeException ) +{ + implInsert(aElement, m_aChildren.size(), &aName); +} + +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::removeByName(const ::rtl::OUString& Name) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, RuntimeException ) +{ + sal_Int32 nPos = implGetPos(Name); + if (-1 == nPos) + { + throw ::com::sun::star::container::NoSuchElementException(); + } + removeByIndex(nPos); +} + +// ::com::sun::star::container::XNameReplace +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::replaceByName(const ::rtl::OUString& aName, const Any& aElement) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, RuntimeException ) +{ + sal_Int32 nPos = implGetPos(aName); + if (-1 == nPos) + { + throw ::com::sun::star::container::NoSuchElementException(); + } + replaceByIndex(nPos, aElement); +} + +// ::com::sun::star::container::XNameAccess +// ------------------------------------------------------------------------- +Any SAL_CALL SbaXFormAdapter::getByName(const ::rtl::OUString& aName) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, RuntimeException ) +{ + sal_Int32 nPos = implGetPos(aName); + if (-1 == nPos) + { + throw ::com::sun::star::container::NoSuchElementException(); + } + return makeAny(m_aChildren[nPos]); +} + +// ------------------------------------------------------------------------- +Sequence< ::rtl::OUString > SAL_CALL SbaXFormAdapter::getElementNames() throw( RuntimeException ) +{ + Sequence< ::rtl::OUString > aReturn(m_aChildNames.size()); + ::rtl::OUString* pReturn = aReturn.getArray(); + for ( vector< ::rtl::OUString>::const_iterator aIter = m_aChildNames.begin(); + aIter != m_aChildNames.end(); + ++aIter, ++pReturn + ) + { + *pReturn = *aIter; + } + return aReturn; +} + +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL SbaXFormAdapter::hasByName(const ::rtl::OUString& aName) throw( RuntimeException ) +{ + return (-1 != implGetPos(aName)); +} + +// ::com::sun::star::container::XElementAccess +// ------------------------------------------------------------------------- +Type SAL_CALL SbaXFormAdapter::getElementType() throw(RuntimeException) +{ + return ::getCppuType( + static_cast< Reference< ::com::sun::star::form::XFormComponent >* >(NULL)); +} + +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL SbaXFormAdapter::hasElements() throw(RuntimeException) +{ + return m_aChildren.size() > 0; +} + + +// ::com::sun::star::container::XIndexContainer +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::insertByIndex(sal_Int32 _rIndex, const Any& Element) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, RuntimeException ) +{ + if ((_rIndex < 0) || (_rIndex >= m_aChildren.size())) + { + throw ::com::sun::star::lang::IndexOutOfBoundsException(); + } + implInsert(Element, _rIndex); +} + +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::removeByIndex(sal_Int32 _rIndex) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, RuntimeException ) +{ + if ((_rIndex < 0) || (_rIndex >= m_aChildren.size())) + { + throw ::com::sun::star::lang::IndexOutOfBoundsException(); + } + + Reference< ::com::sun::star::form::XFormComponent > xAffected = *(m_aChildren.begin() + _rIndex); + + DBG_ASSERT(m_aChildren.size() == m_aChildNames.size(), "SAL_CALL SbaXFormAdapter::removeByIndex : inconsistent container state !"); + m_aChildren.erase(m_aChildren.begin() + _rIndex); + m_aChildNames.erase(m_aChildNames.begin() + _rIndex); + + // no need to listen anymore + Reference< ::com::sun::star::beans::XPropertySet > xAffectedSet(xAffected, UNO_QUERY); + xAffectedSet->removePropertyChangeListener(PROPERTY_NAME, (::com::sun::star::beans::XPropertyChangeListener*)this); + + // we are no longer the parent + xAffected->setParent(Reference< XInterface > ()); + + // notify container listeners + ::com::sun::star::container::ContainerEvent aEvt; + aEvt.Source = *this; + aEvt.Element <<= xAffected; + ::cppu::OInterfaceIteratorHelper aIt(m_aContainerListeners); + while (aIt.hasMoreElements()) + ((::com::sun::star::container::XContainerListener*)aIt.next())->elementRemoved(aEvt); + +} + +// ::com::sun::star::container::XIndexReplace +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::replaceByIndex(sal_Int32 _rIndex, const Any& Element) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, RuntimeException ) +{ + if ((_rIndex < 0) || (_rIndex >= m_aChildren.size())) + { + throw ::com::sun::star::lang::IndexOutOfBoundsException(); + } + + // extract the form component + if (Element.getValueType().getTypeClass() != TypeClass_INTERFACE) + { + throw ::com::sun::star::lang::IllegalArgumentException(); + } + + Reference< ::com::sun::star::form::XFormComponent > xElement(*(Reference< XInterface > *)Element.getValue(), UNO_QUERY); + if (!xElement.is()) + { + throw ::com::sun::star::lang::IllegalArgumentException(); + } + + // for the name we need the propset + Reference< ::com::sun::star::beans::XPropertySet > xElementSet(xElement, UNO_QUERY); + if (!xElementSet.is()) + { + throw ::com::sun::star::lang::IllegalArgumentException(); + } + ::rtl::OUString sName; + try + { + xElementSet->getPropertyValue(PROPERTY_NAME) >>= sName; + } + catch(...) + { + // the set didn't support the name prop + throw ::com::sun::star::lang::IllegalArgumentException(); + } + + Reference< ::com::sun::star::form::XFormComponent > xOld = *(m_aChildren.begin() + _rIndex); + + DBG_ASSERT(m_aChildren.size() == m_aChildNames.size(), "SAL_CALL SbaXFormAdapter::replaceByIndex : inconsistent container state !"); + *(m_aChildren.begin() + _rIndex) = xElement; + *(m_aChildNames.begin() + _rIndex) = sName; + + // correct property change listening + Reference< ::com::sun::star::beans::XPropertySet > xOldSet(xOld, UNO_QUERY); + xOldSet->removePropertyChangeListener(PROPERTY_NAME, (::com::sun::star::beans::XPropertyChangeListener*)this); + xElementSet->addPropertyChangeListener(PROPERTY_NAME, (::com::sun::star::beans::XPropertyChangeListener*)this); + + // parent reset + xOld->setParent(Reference< XInterface > ()); + xElement->setParent((::com::sun::star::container::XContainer*)this); + + // notify container listeners + ::com::sun::star::container::ContainerEvent aEvt; + aEvt.Source = *this; + aEvt.Accessor <<= (sal_Int32)_rIndex; + aEvt.Element <<= xElement; + aEvt.ReplacedElement <<= xOld; + + ::cppu::OInterfaceIteratorHelper aIt(m_aContainerListeners); + while (aIt.hasMoreElements()) + ((::com::sun::star::container::XContainerListener*)aIt.next())->elementReplaced(aEvt); +} + +// ::com::sun::star::container::XIndexAccess +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL SbaXFormAdapter::getCount() throw( RuntimeException ) +{ + return m_aChildren.size(); +} + +// ------------------------------------------------------------------------- +Any SAL_CALL SbaXFormAdapter::getByIndex(sal_Int32 _rIndex) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, RuntimeException ) +{ + if ((_rIndex < 0) || (_rIndex >= m_aChildren.size())) + { + throw ::com::sun::star::lang::IndexOutOfBoundsException(); + } + Reference< ::com::sun::star::form::XFormComponent > xElement = *(m_aChildren.begin() + _rIndex); + return makeAny(xElement); +} + +// ::com::sun::star::container::XContainer +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::addContainerListener(const Reference< ::com::sun::star::container::XContainerListener >& xListener) throw( RuntimeException ) +{ + m_aContainerListeners.addInterface(xListener); +} + +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::removeContainerListener(const Reference< ::com::sun::star::container::XContainerListener >& xListener) throw( RuntimeException ) +{ + m_aContainerListeners.removeInterface(xListener); +} + +// ::com::sun::star::container::XEnumerationAccess +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::container::XEnumeration > SAL_CALL SbaXFormAdapter::createEnumeration() throw( RuntimeException ) +{ + return new ::comphelper::OEnumerationByName(this); +} + +// ::com::sun::star::beans::XPropertyChangeListener +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw( RuntimeException ) +{ + if (evt.PropertyName.equals(PROPERTY_NAME)) + { + for ( vector< Reference< ::com::sun::star::form::XFormComponent > >::const_iterator aIter = m_aChildren.begin(); + aIter != m_aChildren.end(); + ++aIter + ) + { + if (*aIter == evt.Source) + { + sal_Int32 nPos = aIter - m_aChildren.begin(); + DBG_ASSERT(*(m_aChildNames.begin() + nPos) == ::comphelper::getString(evt.OldValue), "SAL_CALL SbaXFormAdapter::propertyChange : object has a wrong name !"); + *(m_aChildNames.begin() + nPos) = ::comphelper::getString(evt.NewValue); + break; + } + } + } +} + +// ::com::sun::star::lang::XEventListener +// ------------------------------------------------------------------------- +void SAL_CALL SbaXFormAdapter::disposing(const ::com::sun::star::lang::EventObject& Source) throw( RuntimeException ) +{ + // was it our main form ? + if (Source.Source == m_xMainForm) + dispose(); + + // was it one of our childs ? + for ( vector< Reference< ::com::sun::star::form::XFormComponent > >::const_iterator aIter = m_aChildren.begin(); + aIter != m_aChildren.end(); + ++aIter + ) + { + if (*aIter == Source.Source) + removeByIndex(aIter - m_aChildren.begin()); + } +} + diff --git a/dbaccess/source/ui/browser/makefile.mk b/dbaccess/source/ui/browser/makefile.mk new file mode 100644 index 000000000..9057e999f --- /dev/null +++ b/dbaccess/source/ui/browser/makefile.mk @@ -0,0 +1,99 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: oj $ $Date: 2000-10-26 14:42:21 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library 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 for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/.. +PRJINC=$(PRJ)$/source +PRJNAME=dbaccess +TARGET=browser + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +IMGLST_SRS=$(SRS)$/$(TARGET).srs +# --- Files -------------------------------------------------------- + +SLOFILES =\ + $(SLO)$/dbloader.obj \ + $(SLO)$/dbtreemodel.obj \ + $(SLO)$/dbtreelistbox.obj \ + $(SLO)$/dbtreeview.obj \ + $(SLO)$/sbagrid.obj \ + $(SLO)$/formadapter.obj \ + $(SLO)$/brwview.obj \ + $(SLO)$/brwctrlr.obj \ + $(SLO)$/unodatbr.obj \ + $(SLO)$/sbamultiplex.obj \ + $(SLO)$/exsrcbrw.obj + +SRCFILES = sbabrw.src \ + sbagrid.src + +# --- Targets ------------------------------------------------------- + + +.INCLUDE : target.mk + +$(SRS)$/$(TARGET).srs: $(SOLARINCDIR)$/svx$/globlmn.hrc + + diff --git a/dbaccess/source/ui/browser/sbabrw.src b/dbaccess/source/ui/browser/sbabrw.src new file mode 100644 index 000000000..e0ceec0be --- /dev/null +++ b/dbaccess/source/ui/browser/sbabrw.src @@ -0,0 +1,982 @@ +/************************************************************************* + * + * $RCSfile: sbabrw.src,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2000-10-26 14:41:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _DBU_RESOURCE_HRC_ +#include "dbu_resource.hrc" +#endif +#ifndef DBACCESS_UI_BROWSER_ID_HXX +#include "browserids.hxx" +#endif +// #include <sfx2/sfx.hrc> +#include <svx/globlmn.hrc> + +#define IL_TOOL \ + MaskColor = Color {\ + Red = 0xC000;\ + Green = 0xC000;\ + Blue = 0xC000;\ + };\ +\ + IdList = {\ + ID_BROWSER_SEARCH;\ + ID_BROWSER_REFRESH;\ + ID_BROWSER_SORTUP;\ + ID_BROWSER_SORTDOWN;\ + ID_BROWSER_ORDERCRIT;\ + ID_BROWSER_FILTERCRIT;\ + ID_BROWSER_AUTOFILTER;\ + ID_BROWSER_COUNTALL;\ + ID_BROWSER_INSERT;\ + ID_BROWSER_UPDATE;\ + ID_BROWSER_MERGE;\ + ID_BROWSER_SQL;\ + ID_BROWSER_ADDTABLE;\ + ID_BROWSER_DESIGN;\ + ID_BROWSER_REMOVEFILTER;\ + ID_BROWSER_UNDO;\ + ID_BROWSER_SAVEDOC;\ + ID_BROWSER_EDITDOC;\ + ID_BROWSER_CUT;\ + ID_BROWSER_COPY;\ + ID_BROWSER_PASTE;\ + ID_BROWSER_FILTERED;\ + };\ + IdCount = {\ + 22;\ + } + + // Default Image-Liste ---------------------------------------------------------------- + +ImageList RID_DEFAULTIMAGELIST_SC +{ + ImageBitmap = Bitmap + { + File = "scqrtl.bmp"; + }; + IL_TOOL ; +}; + +ImageList RID_DEFAULTIMAGELIST_LC +{ + ImageBitmap = Bitmap + { + File = "lcqrtl.bmp" ; + }; + IL_TOOL ; +}; + + + // Toolbox---------------------------------------------------------------------------- + +#define CUR_ITEM ToolBoxItem +#define CUR_SEPARATOR CUR_ITEM {Type = TOOLBOXITEM_SEPARATOR;} + +#define MID_SBA_QRY_SAVE \ + Identifier = ID_BROWSER_SAVEDOC ; \ + Text = "aktuellen Datensatz speichern" ; \ + Text [ ENGLISH ] = "aktuellen Datensatz speichern" ; \ + Hide = FALSE ; \ + Text[ english_us ] = "Save current record"; \ + Text[ portuguese ] = "Guardar registo de dados activo"; \ + Text[ russian ] = "Ñîõðàíèòü òåêóùóþ çàïèñü"; \ + Text[ dutch ] = "Actuele record opslaan"; \ + Text[ french ] = "enregistrer l'enregistrement actif"; \ + Text[ spanish ] = "guardar registro actual"; \ + Text[ italian ] = "Salva record di dati attuale"; \ + Text[ danish ] = "Gem aktuel datapost"; \ + Text[ swedish ] = "Spara den aktuella dataposten"; \ + Text[ polish ] = "Zapisz bie¿¹cy rekord"; \ + Text[ portuguese_brazilian ] = "aktuellen Datensatz speichern"; \ + Text[ japanese ] = "Œ»Ý‚ÌÚº°ÄÞ‚Ì•Û‘¶"; \ + Text[ chinese_simplified ] = "´æÅ̵±Ç°µÄÊý¾ÝÌõÄ¿"; \ + Text[ chinese_traditional ] = "«O¦s·í«eªº¸ê®Æ¶µ¥Ø"; \ + Text[ arabic ] = "ÍÝÙ ÇáÓÌá ÇáÍÇáí"; \ + Text[ dutch ] = "Actuele record opslaan"; \ + Text[ chinese_simplified ] = "´æÅ̵±Ç°µÄÊý¾ÝÌõÄ¿"; \ + Text[ greek ] = "ÁðïèÞêåõóç ôñÝ÷ïõóáò åããñáöÞò äåäïìÝíùí"; \ + Text[ korean ] = "ÇöÀç ·¹ÄÚµå ÀúÀå"; \ + Text[ turkish ] = "Güncel veri kümesini kaydet"; \ + Text[ language_user1 ] = " "; + +#define MID_SBA_QRY_UNDO \ + ITEM_EDIT_UNDO \ + Text = "Rückgängig : Dateneingabe" ; \ + Text [ ENGLISH ] = "Rückgängig : Dateneingabe" ; \ + Hide = FALSE ; \ + Text[ english_us ] = "Undo: Entry"; \ + Text[ portuguese ] = "Anular: entrada de dados"; \ + Text[ russian ] = "Îòìåíèòü : ââîä äàííûõ"; \ + Text[ dutch ] = "Ongedaan maken: Gegevensinvoer"; \ + Text[ french ] = "Annuler : saisie des données"; \ + Text[ spanish ] = "Deshacer: Entrada"; \ + Text[ italian ] = "Annulla: Immissione dati"; \ + Text[ danish ] = "Fortryd : Datainput"; \ + Text[ swedish ] = "Ångra : inmatning av data"; \ + Text[ polish ] = "Cofnij : Wprowadzanie danych"; \ + Text[ portuguese_brazilian ] = "Rückgängig : Dateneingabe"; \ + Text[ japanese ] = "Œ³‚É–ß‚·:ÃÞ°À“ü—Í"; \ + Text[ chinese_simplified ] = "³·ÏûÃüÁÊäÈëÊý¾Ý"; \ + Text[ chinese_traditional ] = "ºM®ø©R¥O¡G¿é¤J¸ê®Æ"; \ + Text[ arabic ] = "ÊÑÇÌÚ: ÅÏÎÇá ÇáÈíÇäÇÊ"; \ + Text[ dutch ] = "Ongedaan maken: Gegevensinvoer"; \ + Text[ chinese_simplified ] = "³·ÏûÃüÁÊäÈëÊý¾Ý"; \ + Text[ greek ] = "Áíáßñåóç: ÅéóáãùãÞ äåäïìÝíùí"; \ + Text[ korean ] = "½ÇÇàÃë¼Ò: ÀÔ·Â"; \ + Text[ turkish ] = "Geri al: Veri giriþi"; \ + Text[ language_user1 ] = " "; + +#define MID_SBA_QRY_CUT \ + Identifier = ID_BROWSER_CUT ; \ + Text = "Ausschneiden" ; \ + Text [ ENGLISH ] = "Ausschneiden" ; \ + Hide = FALSE ; \ + Text[ english_us ] = "Cut"; \ + Text[ portuguese ] = "Cortar"; \ + Text[ russian ] = "Âûðåçàòü"; \ + Text[ dutch ] = "Knippen"; \ + Text[ french ] = "Couper"; \ + Text[ spanish ] = "Cortar"; \ + Text[ italian ] = "Taglia"; \ + Text[ danish ] = "Klip"; \ + Text[ swedish ] = "Klipp ut"; \ + Text[ polish ] = "Wytnij"; \ + Text[ portuguese_brazilian ] = "Ausschneiden"; \ + Text[ japanese ] = "Ø‚èŽæ‚è"; \ + Text[ chinese_simplified ] = "¼ô³ý"; \ + Text[ chinese_traditional ] = "°Å¤U"; \ + Text[ arabic ] = "ÞÕ"; \ + Text[ dutch ] = "Knippen"; \ + Text[ chinese_simplified ] = "¼ô³ý"; \ + Text[ greek ] = "ÁðïêïðÞ"; \ + Text[ korean ] = "À߶󳻱â"; \ + Text[ turkish ] = "Kes"; \ + Text[ language_user1 ] = " "; + +#define MID_SBA_QRY_COPY \ + Identifier = ID_BROWSER_COPY ; \ + Text = "Kopieren" ; \ + Text [ ENGLISH ] = "Kopieren" ; \ + Hide = FALSE ; \ + Text[ english_us ] = "Copy"; \ + Text[ portuguese ] = "Copiar"; \ + Text[ russian ] = "Êîïèðîâàòü"; \ + Text[ dutch ] = "Kopiëren"; \ + Text[ french ] = "Copier"; \ + Text[ spanish ] = "Copiar"; \ + Text[ italian ] = "Copia"; \ + Text[ danish ] = "Kopier"; \ + Text[ swedish ] = "Kopiera"; \ + Text[ polish ] = "Kopiuj"; \ + Text[ portuguese_brazilian ] = "Kopieren"; \ + Text[ japanese ] = "ºËß°"; \ + Text[ chinese_simplified ] = "¸´ÖÆ"; \ + Text[ chinese_traditional ] = "½Æ»s"; \ + Text[ arabic ] = "äÓÎ"; \ + Text[ dutch ] = "Kopiëren"; \ + Text[ chinese_simplified ] = "¸´ÖÆ"; \ + Text[ greek ] = "ÁíôéãñáöÞ"; \ + Text[ korean ] = "º¹»ç"; \ + Text[ turkish ] = "Kopyala"; \ + Text[ language_user1 ] = " "; + +#define MID_SBA_QRY_PASTE \ + Identifier = ID_BROWSER_PASTE ; \ + Text = "Einfügen" ; \ + Text [ ENGLISH ] = "Einfügen" ; \ + Hide = FALSE ; \ + Text[ english_us ] = "Paste"; \ + Text[ portuguese ] = "Colar"; \ + Text[ russian ] = "Âñòàâèòü"; \ + Text[ dutch ] = "Plakken"; \ + Text[ french ] = "Coller"; \ + Text[ spanish ] = "Pegar"; \ + Text[ italian ] = "Incolla"; \ + Text[ danish ] = "Indsæt"; \ + Text[ swedish ] = "Klistra in"; \ + Text[ polish ] = "Wstaw"; \ + Text[ portuguese_brazilian ] = "Einfügen"; \ + Text[ japanese ] = "“\\‚è•t‚¯"; \ + Text[ chinese_simplified ] = "²åÈë"; \ + Text[ chinese_traditional ] = "´¡¤J"; \ + Text[ arabic ] = "áÕÞ"; \ + Text[ dutch ] = "Plakken"; \ + Text[ chinese_simplified ] = "²åÈë"; \ + Text[ greek ] = "Åðéêüëëçóç"; \ + Text[ korean ] = "ºÙ¿©³Ö±â"; \ + Text[ turkish ] = "Yapýþtýr"; \ + Text[ language_user1 ] = " "; + +#define MID_SBA_QRY_EDIT \ + Identifier = ID_BROWSER_EDITDOC ; \ + Text = "Daten bearbeiten" ; \ + Text [ ENGLISH ] = "Daten bearbeiten" ; \ + Hide = FALSE ; \ + Text[ english_us ] = "Edit data"; \ + Text[ portuguese ] = "Editar dados"; \ + Text[ russian ] = "Ïðàâêà äàííûõ"; \ + Text[ dutch ] = "Gegegens bewerken"; \ + Text[ french ] = "Édition de données"; \ + Text[ spanish ] = "Editar datos"; \ + Text[ italian ] = "Modifica dati"; \ + Text[ danish ] = "Rediger data"; \ + Text[ swedish ] = "Redigera data"; \ + Text[ polish ] = "Edytuj dane"; \ + Text[ portuguese_brazilian ] = "Bearbeiten"; \ + Text[ japanese ] = "ÃÞ°À‚Ì•ÒW"; \ + Text[ chinese_simplified ] = "±à¼Êý¾Ý"; \ + Text[ chinese_traditional ] = "½s¿è¸ê®Æ"; \ + Text[ arabic ] = "ÊÍÑíÑ ÇáÈíÇäÇÊ"; \ + Text[ dutch ] = "Gegegens bewerken"; \ + Text[ chinese_simplified ] = "±à¼Êý¾Ý"; \ + Text[ greek ] = "Åðåîåñãáóßá äåäïìÝíùí"; \ + Text[ korean ] = "µ¥ÀÌÅÍ ÆíÁý"; \ + Text[ turkish ] = "Verileri iþle"; \ + Text[ language_user1 ] = " "; + +#define MID_SBA_QRY_ORDERCRIT \ + Identifier = ID_BROWSER_ORDERCRIT ; \ + Text = "Sortieren ..." ; \ + Text [ ENGLISH ] = "Sortieren ..." ; \ + Text[ english_us ] = "Sort..."; \ + Text[ portuguese ] = "Ordenar..."; \ + Text[ russian ] = "Ñîðòèðîâàòü..."; \ + Text[ dutch ] = "Sorteren ..."; \ + Text[ french ] = "Trier ..."; \ + Text[ spanish ] = "Ordenar ..."; \ + Text[ italian ] = "Ordina..."; \ + Text[ danish ] = "Sorter ..."; \ + Text[ swedish ] = "Sortera ..."; \ + Text[ polish ] = "Sortuj..."; \ + Text[ portuguese_brazilian ] = "Ordenar..."; \ + Text[ japanese ] = "•À‚בւ¦..."; \ + Text[ chinese_simplified ] = "ÅÅÐò..."; \ + Text[ chinese_traditional ] = "±Æ§Ç..."; \ + Text[ arabic ] = "ÝÑÒ..."; \ + Text[ dutch ] = "Sorteren ..."; \ + Text[ chinese_simplified ] = "ÅÅÐò..."; \ + Text[ greek ] = "Ôáîéíüìçóç ..."; \ + Text[ korean ] = "Á¤·Ä..."; \ + Text[ turkish ] = "Sýrala ..."; \ + Text[ language_user1 ] = " "; + +#define MID_SBA_QRY_FILTERCRIT \ + Identifier = ID_BROWSER_FILTERCRIT ; \ + Text = "Standardfilter ..." ; \ + Text [ ENGLISH ] = "Standardfilter ..." ; \ + Text[ english_us ] = "Default Filter..."; \ + Text[ portuguese ] = "Filtro padrão..."; \ + Text[ russian ] = "Ñòàíäàðòíûé ôèëüòð..."; \ + Text[ dutch ] = "Standaardfilter ..."; \ + Text[ french ] = "Filtre standard..."; \ + Text[ spanish ] = "Filtro estándar..."; \ + Text[ italian ] = "Filtro standard..."; \ + Text[ danish ] = "Standardfilter ..."; \ + Text[ swedish ] = "Standardfilter ..."; \ + Text[ polish ] = "Filtr standardowy..."; \ + Text[ portuguese_brazilian ] = "Filter..."; \ + Text[ japanese ] = "•W€Ì¨ÙÀ..."; \ + Text[ chinese_simplified ] = "±ê׼ɸѡ..."; \ + Text[ chinese_traditional ] = "¼Ð·Ç¿z¿ï..."; \ + Text[ arabic ] = "ÝáÊÑ ÞíÇÓí..."; \ + Text[ dutch ] = "Standaardfilter ..."; \ + Text[ chinese_simplified ] = "±ê׼ɸѡ..."; \ + Text[ greek ] = "Ößëôñï ðñïåðéëïãÞò..."; \ + Text[ korean ] = "±âº» ÇÊÅÍ..."; \ + Text[ turkish ] = "Standart filtre ..."; \ + Text[ language_user1 ] = " "; + +#define MID_SBA_BRW_UPDATE \ + Hide = TRUE ; \ + Identifier = ID_BROWSER_UPDATE ; \ + Text = "Daten in Felder"; \ + Text [ ENGLISH ] = "Daten in Felder"; \ + Text[ english_us ] = "Data to Fields"; \ + Text[ portuguese ] = "Dados em campos"; \ + Text[ russian ] = "Äàííûå â ïîëÿ"; \ + Text[ dutch ] = "Gegevens in velden"; \ + Text[ french ] = "Données dans les champs"; \ + Text[ spanish ] = "Datos en campos"; \ + Text[ italian ] = "Dati in campi"; \ + Text[ danish ] = "Data i felter"; \ + Text[ swedish ] = "Data i fält"; \ + Text[ polish ] = "Dane w polach"; \ + Text[ portuguese_brazilian ] = "Daten in Felder"; \ + Text[ japanese ] = "ÃÞ°À‚ð̨°ÙÄÞ‚É‘}“ü"; \ + Text[ chinese_simplified ] = "²åÈëÊý¾Ý"; \ + Text[ chinese_traditional ] = "¸ê®Æ´¡¤JÄæ¦ì"; \ + Text[ arabic ] = "ÈíÇäÇÊ Åáì ÍÞæá"; \ + Text[ dutch ] = "Gegevens in velden"; \ + Text[ chinese_simplified ] = "²åÈëÊý¾Ý"; \ + Text[ greek ] = "ÄåäïìÝíá óå ðåäßá"; \ + Text[ korean ] = "µ¥ÀÌÅ͸¦ Çʵ忡"; \ + Text[ turkish ] = "Alan verileri"; \ + Text[ language_user1 ] = " "; + +#define MID_SBA_BRW_INSERT \ + Identifier = ID_BROWSER_INSERT ; \ + Hide = TRUE ; \ + Text = "Daten in Text ..."; \ + Text [ ENGLISH ] = "Daten in Text ..."; \ + Text[ english_us ] = "Data to Text..."; \ + Text[ portuguese ] = "Dados em texto..."; \ + Text[ russian ] = "Äàííûå â òåêñò"; \ + Text[ dutch ] = "Gegevens in tekst ..."; \ + Text[ french ] = "Données dans le texte ..."; \ + Text[ spanish ] = "Datos en texto ..."; \ + Text[ italian ] = "Dati nel testo ..."; \ + Text[ danish ] = "Data i tekst ..."; \ + Text[ swedish ] = "Data i text ..."; \ + Text[ polish ] = "Dane do tekstu..."; \ + Text[ portuguese_brazilian ] = "Daten in Text"; \ + Text[ japanese ] = "ÃÞ°À‚ð÷½Ä‚É‘}“ü..."; \ + Text[ chinese_simplified ] = "Êý¾Ýת»»³ÉÎÄ×Ö..."; \ + Text[ chinese_traditional ] = "¸ê®ÆÂà´«¦¨¤å¦r..."; \ + Text[ arabic ] = "ÈíÇäÇÊ Åáì äÕ"; \ + Text[ dutch ] = "Gegevens in tekst ..."; \ + Text[ chinese_simplified ] = "Êý¾Ýת»»³ÉÎÄ×Ö..."; \ + Text[ greek ] = "ÄåäïìÝíá óå êåßìåíï ..."; \ + Text[ korean ] = "µ¥ÀÌÅ͸¦ ÅؽºÆ®·Î..."; \ + Text[ turkish ] = "Metin verileri ..."; \ + Text[ language_user1 ] = " "; + +#define MID_SBA_BRW_MERGE \ + Identifier = ID_BROWSER_MERGE ; \ + Hide = TRUE ; \ + Text = "Serienbrief ..."; \ + Text [ ENGLISH ] = "Serienbrief ..."; \ + Text[ english_us ] = "Form Letter..."; \ + Text[ portuguese ] = "Carta em série..."; \ + Text[ russian ] = "Ñëèÿíèå"; \ + Text[ dutch ] = "Standaardbrief ..."; \ + Text[ french ] = "Mailing ..."; \ + Text[ spanish ] = "Carta en serie ..."; \ + Text[ italian ] = "Stampa in serie..."; \ + Text[ danish ] = "Brevfletning ..."; \ + Text[ swedish ] = "Kopplad utskrift ..."; \ + Text[ polish ] = "Korespondencja seryjna"; \ + Text[ portuguese_brazilian ] = "Serienbrief"; \ + Text[ japanese ] = "·‚µž‚݈óü"; \ + Text[ chinese_simplified ] = "ÓʼþºÏ²¢..."; \ + Text[ chinese_traditional ] = "¦X¨Ö¦C¦L..."; \ + Text[ arabic ] = "ÎØÇÈ ãÓáÓá ..."; \ + Text[ dutch ] = "Standaardbrief ..."; \ + Text[ chinese_simplified ] = "ÓʼþºÏ²¢..."; \ + Text[ greek ] = "Åãêýêëéïò åðéóôïëÞ ..."; \ + Text[ korean ] = "ÆíÁö ¾ç½Ä..."; \ + Text[ turkish ] = "Mektup formu ..."; \ + Text[ language_user1 ] = " "; + +#define MID_SBA_QRY_SORTUP \ + Identifier = ID_BROWSER_SORTUP ; \ + Text = "Aufsteigend sortieren" ; \ + Text [ ENGLISH ] = "Aufsteigend sortieren" ; \ + Text[ english_us ] = "Sort Ascending"; \ + Text[ portuguese ] = "Ordem ascendente"; \ + Text[ russian ] = "Ñîðòèðîâêà ïî âîçðàñòàíèþ"; \ + Text[ dutch ] = "Oplopend sorteren"; \ + Text[ french ] = "Tri croissant"; \ + Text[ spanish ] = "Orden ascendente"; \ + Text[ italian ] = "Ordina in modo crescente"; \ + Text[ danish ] = "Sorter stigende"; \ + Text[ swedish ] = "Sortera stigande"; \ + Text[ polish ] = "Sortuj rosn¹co"; \ + Text[ portuguese_brazilian ] = "Sort ascending"; \ + Text[ japanese ] = "¸‡‚Å•À‚בւ¦"; \ + Text[ chinese_simplified ] = "ÏòÉÏÅÅÐò"; \ + Text[ chinese_traditional ] = "¦V¤W±Æ§Ç"; \ + Text[ arabic ] = "ÝÑÒ ÊÕÇÚÏí"; \ + Text[ dutch ] = "Oplopend sorteren"; \ + Text[ chinese_simplified ] = "ÏòÉÏÅÅÐò"; \ + Text[ greek ] = "Ôáîéíüìçóç êáôÜ áýîïõóá"; \ + Text[ korean ] = "¿À¸§Â÷¼øÀ¸·Î Á¤·Ä"; \ + Text[ turkish ] = "Artan sýralama"; \ + Text[ language_user1 ] = " "; + +#define MID_EXPLORER_PREVLEVEL \ + Identifier = ID_BROWSER_EXPL_PREVLEVEL; \ + Text = "Übergeordnete Ebene";\ + Text [ english_us] = "parent level"; \ + Text[ portuguese ] = "Nível superior"; \ + Text[ greek ] = "áíþôåñï ðåäßï"; \ + Text[ dutch ] = "Hoger niveau"; \ + Text[ french ] = "Niveau supérieur"; \ + Text[ spanish ] = "Nivel superior"; \ + Text[ swedish ] = "Överordnad nivå"; \ + Text[ russian ] = "Íà óðîâåíü âûøå";\ + Text[ italian ] = "Livello superiore";\ + Text[ danish ] = "Overordnet niveau";\ + Text[ polish ] = "poziom nadrzêdny";\ + Text[ portuguese_brazilian ] = "previous level";\ + Text[ japanese ] = "ˆê‚Âã‚ÌÚÍÞÙ";\ + Text[ korean ] = "»óÀ§ ·¹º§";\ + Text[ chinese_simplified ] = "ÉÏÒ»²ã";\ + Text[ chinese_traditional ] = "¤W¤@¼h";\ + Text[ arabic ] = "ãÓÊæì æÇÍÏ áÃÚáì"; \ + Text[ turkish ] = "Üst düzey"; + +#define MID_FM_SEARCH \ + Identifier = ID_BROWSER_SEARCH ; \ + Text = "Datensatz suchen" ; \ + Text [ ENGLISH ] = "Datensatz suchen" ; \ + Text[ english_us ] = "Find Record"; \ + Text[ portuguese ] = "Localizar registo de dados"; \ + Text[ russian ] = "Íàéòè çàïèñü"; \ + Text[ dutch ] = "Record zoeken"; \ + Text[ french ] = "Rechercher un enregistrement"; \ + Text[ spanish ] = "Buscar registro"; \ + Text[ italian ] = "Cerca record di dati"; \ + Text[ danish ] = "Søg datapost"; \ + Text[ swedish ] = "Sök datapost"; \ + Text[ polish ] = "Szukaj rekordu"; \ + Text[ portuguese_brazilian ] = "Datensatz suchen"; \ + Text[ japanese ] = "Úº°ÄÞ‚ÌŒŸõ"; \ + Text[ chinese_simplified ] = "ËÑÑ°Êý¾ÝÌõÄ¿"; \ + Text[ chinese_traditional ] = "´M§ä¸ê®Æ¶µ¥Ø"; \ + Text[ arabic ] = "ÇáÈÍË Úä ÓÌá"; \ + Text[ dutch ] = "Record zoeken"; \ + Text[ chinese_simplified ] = "ËÑÑ°Êý¾ÝÌõÄ¿"; \ + Text[ greek ] = "ÁíáæÞôçóç åããñáöÞò"; \ + Text[ korean ] = "·¹ÄÚµå ã±â"; \ + Text[ turkish ] = "Kayýt ara"; \ + Text[ language_user1 ] = " "; + +#define MID_SBA_QRY_SORTDOWN \ + Identifier = ID_BROWSER_SORTDOWN ; \ + Text = "Absteigend sortieren" ; \ + Text [ ENGLISH ] = "Absteigend sortieren" ; \ + Text[ english_us ] = "Sort Descending"; \ + Text[ portuguese ] = "Ordem descendente"; \ + Text[ russian ] = "Ñîðòèðîâêà ïî óáûâàíèþ"; \ + Text[ dutch ] = "Aflopend sorteren"; \ + Text[ french ] = "Tri décroissant"; \ + Text[ spanish ] = "Orden descendente"; \ + Text[ italian ] = "Ordina in modo decrescente"; \ + Text[ danish ] = "Sorter faldende"; \ + Text[ swedish ] = "Sortera fallande"; \ + Text[ polish ] = "Sortuj malej¹co"; \ + Text[ portuguese_brazilian ] = "Sort descending"; \ + Text[ japanese ] = "~‡‚Å•À‚בւ¦"; \ + Text[ chinese_simplified ] = "ÏòÏÂÅÅÐò"; \ + Text[ chinese_traditional ] = "¦V¤U±Æ§Ç"; \ + Text[ arabic ] = "ÝÑÒ ÊäÇÒáí"; \ + Text[ dutch ] = "Aflopend sorteren"; \ + Text[ chinese_simplified ] = "ÏòÏÂÅÅÐò"; \ + Text[ greek ] = "Ôáîéíüìçóç êáôÜ öèßíïõóá"; \ + Text[ korean ] = "³»¸²Â÷¼øÀ¸·Î Á¤·Ä"; \ + Text[ turkish ] = "Azalan sýralama"; \ + Text[ language_user1 ] = " "; + +#define MID_SBA_QRY_AUTOFILTER \ + Identifier = ID_BROWSER_AUTOFILTER ; \ + Text = "Autofilter" ; \ + Text [ ENGLISH ] = "Autofilter" ; \ + Text[ english_us ] = "AutoFilter"; \ + Text[ portuguese ] = "AutoFiltro"; \ + Text[ russian ] = "Àâòîôèëüòð"; \ + Text[ dutch ] = "AutoFilter"; \ + Text[ french ] = "AutoFiltre"; \ + Text[ spanish ] = "AutoFiltro"; \ + Text[ italian ] = "Filtro automatico"; \ + Text[ danish ] = "AutoFilter"; \ + Text[ swedish ] = "AutoFilter"; \ + Text[ polish ] = "Autofiltr"; \ + Text[ portuguese_brazilian ] = "Auto filter"; \ + Text[ japanese ] = "µ°Ą̈ÙÀ"; \ + Text[ chinese_simplified ] = "×Ô¶¯É¸Ñ¡"; \ + Text[ chinese_traditional ] = "¦Û°Ê¿z¿ï"; \ + Text[ arabic ] = "ÝáÊÑ Âáí"; \ + Text[ dutch ] = "AutoFilter"; \ + Text[ chinese_simplified ] = "×Ô¶¯É¸Ñ¡"; \ + Text[ greek ] = "ÁõôïÖßëôñï"; \ + Text[ korean ] = "ÀÚµ¿ÇÊÅÍ"; \ + Text[ turkish ] = "OtomatikFiltre"; \ + Text[ language_user1 ] = " "; + +#define MID_SBA_QRY_COUNTALL \ + Identifier = ID_BROWSER_COUNTALL ; \ + Text = "Anzahl Datensätze" ; \ + Text [ ENGLISH ] = "Anzahl Datensätze" ; \ + Text[ english_us ] = "Records Count"; \ + Text[ portuguese ] = "Contar registos"; \ + Text[ russian ] = "Êîëè÷åñòâî çàïèñåé"; \ + Text[ dutch ] = "Aantal records"; \ + Text[ french ] = "Nombre d'enregistrements "; \ + Text[ spanish ] = "Cantidad de registros"; \ + Text[ italian ] = "Numero dei record di dati"; \ + Text[ danish ] = "Antal dataposter"; \ + Text[ swedish ] = "Antal dataposter"; \ + Text[ polish ] = "Iloœæ rekordów"; \ + Text[ portuguese_brazilian ] = "Anzahl Datensätze"; \ + Text[ japanese ] = "Úº°ÄÞ”"; \ + Text[ chinese_simplified ] = "Êý¾Ý¼Ç¼µÄÊýÄ¿"; \ + Text[ chinese_traditional ] = "¸ê®Æ¶µ¥Øªº¼Æ¥Ø"; \ + Text[ arabic ] = "ÚÏÏ ÇáÓÌáÇÊ"; \ + Text[ dutch ] = "Aantal records"; \ + Text[ chinese_simplified ] = "Êý¾Ý¼Ç¼µÄÊýÄ¿"; \ + Text[ greek ] = "Áñéèìüò åããñáöþí"; \ + Text[ korean ] = "·¹ÄÚµå ¼ö"; \ + Text[ turkish ] = "Veri kümeleri sayýsý"; \ + Text[ language_user1 ] = " "; + + +#define MID_SBA_QRY_REFRESH \ + Identifier = ID_BROWSER_REFRESH ; \ + Text = "Aktualisieren" ; \ + Text [ ENGLISH ] = "Aktualisieren" ; \ + Text[ english_us ] = "Refresh"; \ + Text[ portuguese ] = "Actualizar"; \ + Text[ russian ] = "Îáíîâèòü"; \ + Text[ dutch ] = "Actualiseren"; \ + Text[ french ] = "Actualiser"; \ + Text[ spanish ] = "Actualizar"; \ + Text[ italian ] = "Aggiorna"; \ + Text[ danish ] = "Opdater"; \ + Text[ swedish ] = "Uppdatera"; \ + Text[ polish ] = "Aktualizuj"; \ + Text[ portuguese_brazilian ] = "Aktualisieren"; \ + Text[ japanese ] = "XV"; \ + Text[ chinese_simplified ] = "¸üÐÂ"; \ + Text[ chinese_traditional ] = "§ó·s"; \ + Text[ arabic ] = "ÊÍÏíË"; \ + Text[ dutch ] = "Actualiseren"; \ + Text[ chinese_simplified ] = "¸üÐÂ"; \ + Text[ greek ] = "ÅíçìÝñùóç"; \ + Text[ korean ] = "»õ·Î °íħ"; \ + Text[ turkish ] = "Yenile"; \ + Text[ language_user1 ] = " "; + +#define MID_SBA_QRY_REMOVEFILTER \ + Identifier = ID_BROWSER_REMOVEFILTER ; \ + Text = "Filter/Sortierung entfernen" ; \ + Text [ ENGLISH ] = "Filter/Sortierung entfernen" ; \ + Text[ english_us ] = "Remove Filter/Sort"; \ + Text[ portuguese ] = "Remover filtro/ordem"; \ + Text[ russian ] = "Óáðàòü ôèëüòð/ñîðòèðîâêó"; \ + Text[ dutch ] = "Filter/sortering verwijderen"; \ + Text[ french ] = "Supprimer le filtre/tri"; \ + Text[ spanish ] = "Eliminar Filtro/Orden"; \ + Text[ italian ] = "Elimina filtro/ordine"; \ + Text[ danish ] = "Fjern filter/sortering"; \ + Text[ swedish ] = "Ta bort filter/sortering"; \ + Text[ polish ] = "Usuñ filtr/sortowanie"; \ + Text[ portuguese_brazilian ] = "Filter/Sortierung entfernen"; \ + Text[ japanese ] = "̨ÙÀ‚Æ•À‚בւ¦‚Ìíœ"; \ + Text[ chinese_simplified ] = "ɾ³ýɸѡ/ÅÅÐò"; \ + Text[ chinese_traditional ] = "§R°£¿z¿ï/±Æ§Ç"; \ + Text[ arabic ] = "ÅÒÇáÉ ÇáÝáÊÑ/ÇáÝÑÒ"; \ + Text[ dutch ] = "Filter/sortering verwijderen"; \ + Text[ chinese_simplified ] = "ɾ³ýɸѡ/ÅÅÐò"; \ + Text[ greek ] = "ÊáôÜñãçóç ößëôñïõ/ôáîéíüìçóçò"; \ + Text[ korean ] = "ÇÊÅÍ/Á¤·Ä Á¦°Å"; \ + Text[ turkish ] = "Filtre/sýralamayý kaldýr"; \ + Text[ language_user1 ] = " "; + + +#define MID_SBA_BROWSER_FILTERED \ + Identifier = ID_BROWSER_FILTERED ; \ + Text = "Filter anwenden" ; \ + Text [ english ] = "Apply filter" ; \ + Text [ english_us ] = "Apply Filter" ; \ + Text [ portuguese ] = "Aplicar filtro" ; \ + Text [ russian ] = "Ïðèìåíèòü ôèëüòð" ; \ + Text [ greek ] = "ÅöáñìïãÞ ößëôñïõ" ; \ + Text [ dutch ] = "Filter toepassen" ; \ + Text [ french ] = "Appliquer le filtre" ; \ + Text [ spanish ] = "Usar filtro" ; \ + Text [ italian ] = "Usa filtro" ; \ + Text [ danish ] = "Anvend filter" ; \ + Text [ swedish ] = "Använd filter" ; \ + Text [ polish ] = "U¿yj filtru" ; \ + Text [ portuguese_brazilian ] = "FormFiltered" ; \ + Text [ japanese ] = "̨ÙÀ‚ÌŽg—p" ; \ + Text [ korean ] = "ÇÊÅÍ Àû¿ë" ; \ + Text [ chinese_simplified ] = "ʹÓùýÂËÆ÷" ; \ + Text [ chinese_traditional ] = "¨Ï¥Î¿z¿ï" ; \ + Text [ arabic ] = "ÇÓÊÎÏÇã ÝáÊÑ" ; \ + Text[ turkish ] = "Filtre kullan"; + + + // HelpIds duerfen nur in dieser Form angegeben werden, + // ansonsten können keine langnamen erzeugt werden +ToolBox RID_BRW_QRY_TOOLBOX +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 3 , 1 ) ; + Size = MAP_APPFONT ( 200 , 14 ) ; + OutputSize = TRUE ; + Align = BOXALIGN_TOP ; + HideWhenDeactivate = TRUE ; + ItemImageList = RID_DEFAULTIMAGELIST_SC ; + // HelpId = HID_TLB_TABBROWSER ; + ItemList = + { + CUR_ITEM + { + MID_FM_SEARCH + HelpId = ID_BROWSER_SEARCH ; + }; + CUR_SEPARATOR ; + CUR_ITEM + { + MID_SBA_QRY_SORTUP + HelpId = ID_BROWSER_SORTUP ; + }; + CUR_ITEM + { + MID_SBA_QRY_SORTDOWN + HelpId = ID_BROWSER_SORTDOWN ; + }; + CUR_ITEM + { + MID_SBA_QRY_AUTOFILTER + HelpId = ID_BROWSER_AUTOFILTER ; + }; + CUR_SEPARATOR ; + CUR_ITEM + { + MID_SBA_QRY_FILTERCRIT + HelpId = ID_BROWSER_FILTERCRIT ; + }; + CUR_ITEM + { + MID_SBA_QRY_ORDERCRIT + HelpId = ID_BROWSER_ORDERCRIT ; + }; + CUR_ITEM + { + MID_SBA_QRY_REMOVEFILTER + HelpId = ID_BROWSER_REMOVEFILTER ; + }; + CUR_ITEM + { + MID_SBA_BROWSER_FILTERED + HelpId = ID_BROWSER_FILTERED ; + }; + CUR_SEPARATOR ; + CUR_ITEM + { + MID_SBA_QRY_REFRESH + HelpId = ID_BROWSER_REFRESH ; + }; + CUR_SEPARATOR ; + CUR_ITEM + { + MID_SBA_BRW_INSERT + HelpId = ID_BROWSER_INSERT ; + }; + CUR_ITEM + { + MID_SBA_BRW_UPDATE + HelpId = ID_BROWSER_UPDATE ; + }; + CUR_ITEM + { + MID_SBA_BRW_MERGE + HelpId = ID_BROWSER_MERGE ; + }; + }; +}; + + +ToolBox RID_BRW_TAB_TOOLBOX +{ + SVLook = TRUE ; + Pos = MAP_APPFONT ( 3 , 1 ) ; + Size = MAP_APPFONT ( 200 , 14 ) ; + OutputSize = TRUE ; + Align = BOXALIGN_TOP ; + ItemImageList = RID_DEFAULTIMAGELIST_SC ; + HideWhenDeactivate = TRUE ; + // HelpId = HID_TLB_TABBROWSER ; + ItemList = + { + CUR_ITEM + { + MID_FM_SEARCH + HelpId = ID_BROWSER_SEARCH ; + }; + CUR_SEPARATOR ; + CUR_ITEM + { + MID_SBA_QRY_SORTUP + HelpId = ID_BROWSER_SORTUP ; + }; + CUR_ITEM + { + MID_SBA_QRY_SORTDOWN + HelpId = ID_BROWSER_SORTDOWN ; + }; + CUR_ITEM + { + MID_SBA_QRY_AUTOFILTER + HelpId = ID_BROWSER_AUTOFILTER ; + }; + CUR_SEPARATOR ; + CUR_ITEM + { + MID_SBA_QRY_FILTERCRIT + HelpId = ID_BROWSER_FILTERCRIT ; + }; + CUR_ITEM + { + MID_SBA_QRY_ORDERCRIT + HelpId = ID_BROWSER_ORDERCRIT ; + }; + CUR_ITEM + { + MID_SBA_QRY_REMOVEFILTER + HelpId = ID_BROWSER_REMOVEFILTER ; + }; + CUR_ITEM + { + MID_SBA_BROWSER_FILTERED + HelpId = ID_BROWSER_FILTERED ; + }; + CUR_SEPARATOR ; + CUR_ITEM + { + MID_SBA_QRY_REFRESH + HelpId = ID_BROWSER_REFRESH ; + }; + CUR_SEPARATOR ; + CUR_ITEM + { + MID_SBA_BRW_INSERT + HelpId = ID_BROWSER_INSERT ; + }; + CUR_ITEM + { + MID_SBA_BRW_UPDATE + HelpId = ID_BROWSER_UPDATE ; + }; + CUR_ITEM + { + MID_SBA_BRW_MERGE + HelpId = ID_BROWSER_MERGE ; + }; + }; +}; + +String RID_STR_LOADING_DATASOURCE +{ + Text = "Daten laden"; + Text [ ENGLISH ] = "load data"; + Text[ english_us ] = "Load data"; + Text[ portuguese ] = "Carregar dados"; + Text[ greek ] = "Öüñôùóç äåäïìÝíùí"; + Text[ dutch ] = "Gegevens laden"; + Text[ french ] = "Charger les données"; + Text[ spanish ] = "Cargar datos"; + Text[ swedish ] = "Ladda data"; + Text[ russian ] = "Çàãðóçèòü äàííûå"; + Text[ italian ] = "Carica dati"; + Text[ danish ] = "Indlæs data"; + Text[ polish ] = "³adowaæ dane"; + Text[ portuguese_brazilian ] = "load data"; + Text[ japanese ] = "ÃÞ°À‚Ì“Ç‚Ýž‚Ý"; + Text[ korean ] = "µ¥ÀÌÅÍ ·Îµå"; + Text[ chinese_simplified ] = "ÏÂÔØÊý¾Ý"; + Text[ chinese_traditional ] = "¤U¸ü¼ÆÕu"; + Text[ arabic ] = "ÊÍãíá ÇáÈíÇäÇÊ"; + Text[ turkish ] = "Verileri yükle"; +}; + +QueryBox QUERY_BRW_SAVEMODIFIED +{ + Buttons = WB_YES_NO_CANCEL ; + DefButton = WB_DEF_YES ; + /* ### ACHTUNG: Neuer Text in Resource? Soll der geänderte Datensatz gespeichert werden? : Soll der geänderte Datensatz gespeichert werden? */ + Message = "Der aktuelle Datensatz wurde geändert.\nSollen die Änderungen gespeichert werden?" ; + Message [ English ] = "The current row has been modified.\nDo you want to save your changes?" ; + Message [ english_us ] = "The current record has been changed.\nDo you want to save the changes?" ; + Message[ portuguese ] = "O registo de dados activo foi modificado.\nGuardar as modificações?"; + Message[ russian ] = "Òåêóùàÿ çàïèñü äàííûõ áûëà èçìåíåíà. Ñîõðàíèòü ýòè èçìåíåíèÿ?"; + Message[ dutch ] = "De actuele record werd gewijzigd.\nWilt u de wijzigingen opslaan?"; + Message[ french ] = "L'enregistrement actif a été modifié. Souhaitez-vous enregistrer les modifications ?"; + Message[ spanish ] = "El registro actual ha sido modificado.\n¿Desea guardar las modificaciones?"; + Message[ italian ] = "Il record di dati attuale è stato modificato.\nVolete salvare le modifiche?"; + Message[ danish ] = "Den aktuelle datapost er blevet ændret.\nSkal ændringerne gemmes?"; + Message[ swedish ] = "Den aktuella dataposten har ändrats.\nSkall ändringarna sparas?"; + Message[ polish ] = "Aktualny rekord zosta³ zmodyfikowany.\nCzy chcesz zapisaæ zmodyfikowane dane?"; + Message[ portuguese_brazilian ] = "Soll der geänderter Datensatz gespeichert werden?"; + Message[ japanese ] = "Œ»Ý‚ÌÚº°ÄÞ‚ª•ÏX‚³‚ê‚Ä‚¢‚Ü‚·B•ÏX‚ð•Û‘¶‚µ‚Ü‚·‚©B"; + Message[ chinese_simplified ] = "Êý¾ÝÌõÄ¿ÒѾ±»¸ü¸Ä¡£\nÄúÒª´æÅ̸ü¸ÄºóµÄÊý¾Ý¼Ç¼Âð£¿"; + Message[ chinese_traditional ] = "·í«eªº¸ê®Æ¤w¸gÅܧó¡CnÀx¦sÅܧ󪺸ê®Æ¶µ¥Ø¡H"; + Message[ arabic ] = "Êã ÊÛííÑ ÇáÓÌá ÇáÍÇáí.\nåá ÊÑíÏ ÍÝÙ ÇáÊÛííÑÇÊý¿"; + Message[ dutch ] = "De actuele record werd gewijzigd.\nWilt u de wijzigingen opslaan?"; + Message[ chinese_simplified ] = "Êý¾ÝÌõÄ¿ÒѾ±»¸ü¸Ä¡£\nÄúÒª´æÅ̸ü¸ÄºóµÄÊý¾Ý¼Ç¼Âð£¿"; + Message[ greek ] = "Ç ôñÝ÷ïõóá åããñáöÞ ôñïðïðïéÞèçêå.\nÍá áðïèçêåõôïýí ïé áëëáãÝò;"; + Message[ korean ] = "ÇöÀç µ¥ÀÌÅÍ ·¹Äڵ尡 º¯°æµÇ¾ú½À´Ï´Ù. º¯°æµÈ »çÇ×À» ÀúÀåÇϽðڽÀ´Ï±î?"; + Message[ turkish ] = "Güncel veri kümesi deðiþtirildi.\nDeðiþiklikler saklansýn mý?"; + Message[ language_user1 ] = " "; +}; + + +String RID_STR_DATABROWSER_FILTERED +{ + Text = "(gefiltert)" ; + Text [ English ] = "(filtered)" ; + Text [ english_us ] = "(filtered)" ; + Text[ italian ] = "(filtrato)"; + Text[ portuguese_brazilian ] = "(filtered)"; + Text[ portuguese ] = "(filtrado)"; + Text[ danish ] = "(filtreret)"; + Text[ french ] = "(filtré)"; + Text[ swedish ] = "(filtrerad)"; + Text[ dutch ] = "(gefilterd)"; + Text[ spanish ] = "(filtrado)"; + Text[ chinese_simplified ] = "(ÒѾɸѡ)"; + Text[ russian ] = "(îòôèëüòðîâàíî)"; + Text[ polish ] = "(przefiltrowany)"; + Text[ japanese ] = "(̨ÙÀÏ‚Ý)"; + Text[ chinese_traditional ] = "(¤w¸g¿z¿ï)"; + Text[ arabic ] = "(ãõÕÝøì)"; + Text[ dutch ] = "(gefilterd)"; + Text[ chinese_simplified ] = "(ÒѾɸѡ)"; + Text[ greek ] = "(öéëôñáñéóìÝíá)"; + Text[ korean ] = "(ÇÊÅ͵Ê)"; + Text[ turkish ] = "(filtrelenmiþ)"; + Text[ language_user1 ] = " "; +}; + +String SBA_BROWSER_SETTING_ORDER +{ + Text = "Fehler beim Setzen der Sortier-Kriterien"; + Text [ english ] = "error setting the sort criteria"; + Text [ english_us ] = "Error setting the sort criteria"; + Text[ portuguese ] = "Erro ao definir critérios de ordem"; + Text[ russian ] = "Îøèáêà ïðè óñòàíîâëåíèè óñëîâèé ñîðòèðîâêè"; + Text[ greek ] = "ÓöÜëìá êáôÜ ôïí ïñéóìü ôùí êñéôçñßùí ôáîéíüìçóçò"; + Text[ dutch ] = "fout bij vastleggen van sorteercriteria"; + Text[ french ] = "Erreur de définition des critères de tri"; + Text[ spanish ] = "Error al definir los criterios de ordenación"; + Text[ italian ] = "Errore nell'impostare i criteri"; + Text[ danish ] = "Fejl ved definition af sorteringskriterierne"; + Text[ swedish ] = "fel vid definition av sorteringskriterier"; + Text[ polish ] = "B³¹d podczas osadzania kryteriów sortowania"; + Text[ portuguese_brazilian ] = "error setting the sort criteria"; + Text[ japanese ] = "•À‚בւ¦ðŒ‚Ìݒ莞‚Ì´×°"; + Text[ korean ] = "Á¤·Ä±âÁØ ¼³Á¤¿¡ ¿À·ù"; + Text[ chinese_simplified ] = "ÔÚÉ趨ÅÅÐòÌõ¼þʱ·¢Éú´íÎó"; + Text[ chinese_traditional ] = "¦b³]©w½s±Æ©w¸q®Éµo¥Í¿ù»~"; + Text[ arabic ] = "ÍÏË ÎØà ÃËäÇÁ ÊÚííä ãÚÇííÑ ÇáÝÑÒ"; + Text[ turkish ] = "Sýralama ölçütlerinin ayarlanmasýnda hata"; +}; +String SBA_BROWSER_SETTING_FILTER +{ + Text = "Fehler beim Setzen der Filter-Kriterien"; + Text [ english ] = "error setting the filter criteria"; + Text [ english_us ] = "Error setting the filter criteria"; + Text[ portuguese ] = "Erro ao definir critérios dos filtros"; + Text[ russian ] = "Îøèáêà ïðè óñòàíîâëåíèè óñëîâèé ôèëüòðà"; + Text[ greek ] = "ÓöÜëìá êáôÜ ôïí ïñéóìü ôùí êñéôçñßùí ößëôñïõ"; + Text[ dutch ] = "fout bij vastleggen van filtercriteria"; + Text[ french ] = "Erreur de définition des critères de filtre"; + Text[ spanish ] = "Error al definir los criterios de filtro"; + Text[ italian ] = "Errore nell'impostare i criteri"; + Text[ danish ] = "Fejl ved definition af filterkriterierne"; + Text[ swedish ] = "fel vid definition av filterkriterier"; + Text[ polish ] = "B³¹d podczas osadzania kryteriów filtra"; + Text[ portuguese_brazilian ] = "error setting the filter criteria"; + Text[ japanese ] = "̨ÙÀðŒ‚Ìݒ莞‚Ì´×°"; + Text[ korean ] = "ÇÊÅͱâÁØ ¼³Á¤¿¡ ¿À·ù"; + Text[ chinese_simplified ] = "ÔÚÉ趨ɸѡÌõ¼þʱ·¢Éú´íÎó"; + Text[ chinese_traditional ] = "¦b³]©w¿z¿ï©w¸qªºµo¥Í¿ù»~"; + Text[ arabic ] = "ÍÏË ÎØà ÃËäÇÁ ÊÚííä ãÚÇííÑ ÇáÊÕÝíÉ"; + Text[ turkish ] = "Filtre ölçütlerinin ayarlanmasýnda hata"; +}; + +String RID_STR_CONNECTION_LOST +{ + Text = "Vebindung verloren"; + Text [ english ] = "connection lost"; + Text [ english_us ] = "Connection lost"; + Text[ portuguese ] = "Ligação perdida"; + Text[ russian ] = "Ïîäêëþ÷åíèå óòåðÿíî"; + Text[ greek ] = "Óýíäåóç ÷Üèçêå"; + Text[ dutch ] = "Verbinding verbroken"; + Text[ french ] = "La connexion a éte perdue"; + Text[ spanish ] = "Se perdió la conexión"; + Text[ italian ] = "Il collegamento è stato interrotto"; + Text[ danish ] = "Tabt forbindelse"; + Text[ swedish ] = "Bruten förbindelse"; + Text[ polish ] = "Brak po³¹czenia"; + Text[ portuguese_brazilian ] = "connection lost"; + Text[ japanese ] = "Ú‘±‚Ì’†’f"; + Text[ korean ] = "¿¬°áÀ» ÀÒÀ½"; + Text[ chinese_simplified ] = "Á¬½Óʧ°Ü"; + Text[ chinese_traditional ] = "³s½u¤w¸g¤¤Â_"; + Text[ arabic ] = "Êã ÝÞÏÇä ÇáÇÊÕÇá"; + Text[ turkish ] = "Baðlantý koptu"; +}; + +Image QUERYFOLDER_TREE_ICON +{ + ImageBitmap = Bitmap { File = "sx03201.bmp"; }; + MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; }; +}; + +Image QUERY_TREE_ICON +{ + ImageBitmap = Bitmap { File = "sx03202.bmp"; }; + MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; }; +}; + + diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx new file mode 100644 index 000000000..ce5e3b01e --- /dev/null +++ b/dbaccess/source/ui/browser/sbagrid.cxx @@ -0,0 +1,2313 @@ +/************************************************************************* + * + * $RCSfile: sbagrid.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2000-10-26 14:41:54 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SBA_GRID_HXX +#include "sbagrid.hxx" +#endif +//#ifndef _SBA_SBATTRDLG_HXX +//#include "dlgattr.hxx" +//#endif +//#ifndef _DLGSIZE_HXX +//#include "dlgsize.hxx" +//#endif +//#ifndef _SBA_API_HRC +//#include "api.hrc" +//#endif +#ifndef _COM_SUN_STAR_FORM_XLOADABLE_HPP_ +#include <com/sun/star/form/XLoadable.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ +#include <com/sun/star/sdb/CommandType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSERFACTORY_HPP_ +#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_XFORM_HPP_ +#include <com/sun/star/form/XForm.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XINDEXCONTAINER_HPP_ +#include <com/sun/star/container/XIndexContainer.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_ +#include <com/sun/star/util/NumberFormat.hpp> +#endif + +#ifndef _COM_SUN_STAR_VIEW_XSELECTIONSUPPLIER_HPP_ +#include <com/sun/star/view/XSelectionSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_DATASELECTIONTYPE_HPP_ +#include <com/sun/star/form/DataSelectionType.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_TEXTALIGN_HPP_ +#include <com/sun/star/awt/TextAlign.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XTEXTCOMPONENT_HPP_ +#include <com/sun/star/awt/XTextComponent.hpp> +#endif + +#ifndef _URLOBJ_HXX +#include <tools/urlobj.hxx> +#endif + +#ifndef _SFXINIMGR_HXX +#include <svtools/iniman.hxx> +#endif + +#ifndef _SFXINIPROP_HXX +#include <svtools/iniprop.hxx> +#endif + +#ifndef _SFXINTITEM_HXX //autogen +#include <svtools/intitem.hxx> +#endif + +//#ifndef _SVX_COLRITEM_HXX //autogen +//#include <svx/colritem.hxx> +//#endif +// +//#ifndef _SVX_ALGITEM_HXX //autogen +//#include <svx/algitem.hxx> +//#endif + +#ifndef _SV_MULTISEL_HXX //autogen +#include <tools/multisel.hxx> +#endif + +#ifndef _SVX_SVXIDS_HRC +#include <svx/svxids.hrc> +#endif + +#ifndef _SV_DRAG_HXX //autogen +#include <vcl/drag.hxx> +#endif + +#ifndef _NUMUNO_HXX +#include <svtools/numuno.hxx> +#endif + +#ifndef _SFXITEMPOOL_HXX //autogen wg. SfxItemInfo +#include <svtools/itempool.hxx> +#endif + +#ifndef _SFXITEMSET_HXX //autogen wg. SfxItemSet +#include <svtools/itemset.hxx> +#endif + +#ifndef _SV_SYSTEM_HXX //autogen wg. ::com::sun::star::chaos::System +#include <vcl/system.hxx> +#endif + +//#ifndef _SVX_FONTITEM_HXX //autogen wg. SvxFontItem +//#include <svx/fontitem.hxx> +//#endif +// +//#ifndef _SVX_FHGTITEM_HXX //autogen wg. SvxFontHeightItem +//#include <svx/fhgtitem.hxx> +//#endif +// +//#ifndef _SVX_WGHTITEM_HXX //autogen wg. SvxWeightItem +//#include <svx/wghtitem.hxx> +//#endif + +#ifndef SBA_VCARDEXCHANGE_FORMAT +#define SBA_VCARDEXCHANGE_FORMAT "+//ISBN 1-887687-00-9::versit::PDI//vCard" +#endif + +//#ifndef _SVX_POSTITEM_HXX //autogen wg. SvxPostureItem +//#include <svx/postitem.hxx> +//#endif +// +//#ifndef _SVX_SHDDITEM_HXX //autogen wg. SvxShadowedItem +//#include <svx/shdditem.hxx> +//#endif +// +//#ifndef _SVX_ITEM_HXX //autogen wg. SvxContourItem +//#include <svx/cntritem.hxx> +//#endif +// +//#ifndef _SVX_CRSDITEM_HXX //autogen wg. SvxCrossedOutItem +//#include <svx/crsditem.hxx> +//#endif +// +//#ifndef _SVX_UDLNITEM_HXX //autogen wg. SvxUnderlineItem +//#include <svx/udlnitem.hxx> +//#endif + +#ifndef _SFXRNGITEM_HXX +#include <svtools/rngitem.hxx> +#endif + +#ifndef _EXCHOBJ_HXX +#include <sfx2/exchobj.hxx> +#endif + +#ifndef _SV_WAITOBJ_HXX +#include <vcl/waitobj.hxx> +#endif +#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ +#include <toolkit/helper/vclunohelper.hxx> +#endif + +#ifndef _ZFORLIST_HXX +#include <svtools/zforlist.hxx> +#endif +#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_ +#include <cppuhelper/queryinterface.hxx> +#endif +#ifndef _COMPHELPER_PROCESSFACTORY_HXX_ +#include <comphelper/processfactory.hxx> +#endif +#ifndef _CONNECTIVITY_DBTOOLS_HXX_ +#include <connectivity/dbtools.hxx> +#endif +#ifndef _CONNECTIVITY_DATECONVERSION_HXX_ +#include <connectivity/DateConversion.hxx> +#endif +#ifndef _RTL_UUID_H_ +#include <rtl/uuid.h> +#endif +#ifndef _RTL_MEMORY_H_ +#include <rtl/memory.h> +#endif +#ifndef _CPPUHELPER_EXTRACT_HXX_ +#include <cppuhelper/extract.hxx> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#endif +#ifndef _SV_CLIP_HXX +#include <vcl/clip.hxx> +#endif +#ifndef _SVX_DBEXCH_HRC +#include <svx/dbexch.hrc> +#endif +#ifndef _DBU_RESOURCE_HRC_ +#include "dbu_resource.hrc" +#endif +#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "moduledbu.hxx" +#endif +#ifndef DBACCESS_UI_BROWSER_ID_HXX +#include "browserids.hxx" +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif + + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::sdb; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace dbaui; + +/// collect the SBA_DEF_...-items and use them to create a new font based on the given one +::com::sun::star::awt::FontDescriptor BuildFontFromItems(const SfxItemSet* pAttr, const Font& rBase); + +/// translate the given font into SBA_DEF_...-items, put them into the set +void BuildItemsFromFont(SfxItemSet* pAttr, const ::com::sun::star::awt::FontDescriptor& rFont); + +//------------------------------------------------------------------------------ +sal_uInt32 RegisterRowExchangeFormatName() +{ + static sal_uInt32 nFormat = 0; + if (!nFormat) + nFormat = Clipboard::RegisterFormatName(String::CreateFromAscii(SBA_DATAEXCHANGE_FORMAT)); + + return nFormat; +} + +//------------------------------------------------------------------------------ +sal_uInt32 RegisterColumnExchangeFormatName() +{ + static sal_uInt32 nFormat = 0; + if (!nFormat) + nFormat = Clipboard::RegisterFormatName(String::CreateFromAscii(SBA_FIELDEXCHANGE_FORMAT)); + + return nFormat; +} + +//------------------------------------------------------------------------------ +sal_uInt32 RegisterFieldExchangeFormatName() +{ + static sal_uInt32 nFormat = 0; + if (!nFormat) + nFormat = Clipboard::RegisterFormatName(String::CreateFromAscii(SBA_FIELDDATAEXCHANGE_FORMAT)); + + return nFormat; +} + +//------------------------------------------------------------------ +String Any2String(const ::com::sun::star::uno::Any& rValue) +{ + String aString; + if (rValue.hasValue()) + { + switch (rValue.getValueTypeClass()) + { + case ::com::sun::star::uno::TypeClass_BOOLEAN: + aString = (char)::comphelper::getBOOL(rValue); + break; + case ::com::sun::star::uno::TypeClass_CHAR: + aString = ::comphelper::getINT16(rValue); + break; + case ::com::sun::star::uno::TypeClass_STRING: + aString = (const sal_Unicode*)::comphelper::getString(rValue); + break; + case ::com::sun::star::uno::TypeClass_BYTE: + aString = (char)::comphelper::getBOOL(rValue); + break; + case ::com::sun::star::uno::TypeClass_LONG: + aString = ::comphelper::getINT32(rValue); + break; + case ::com::sun::star::uno::TypeClass_SHORT: + aString = (short)::comphelper::getINT16(rValue); + break; + case ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT: + aString = (short)::comphelper::getINT16(rValue); + break; + case ::com::sun::star::uno::TypeClass_UNSIGNED_LONG: + aString = (int)::comphelper::getINT32(rValue); + break; + case ::com::sun::star::uno::TypeClass_VOID: + default: + ; // leerstring + } + } + return aString; +} + +//------------------------------------------------------------------ +double Any2Double(const ::com::sun::star::uno::Any& rValue) +{ + double aRet = 0; + if (rValue.hasValue()) + { + switch (rValue.getValueTypeClass()) + { + case ::com::sun::star::uno::TypeClass_BOOLEAN: + aRet = ::comphelper::getBOOL(rValue); + break; + case ::com::sun::star::uno::TypeClass_CHAR: + aRet = ::comphelper::getBOOL(rValue); + break; + case ::com::sun::star::uno::TypeClass_FLOAT: + aRet = ::comphelper::getFloat(rValue); + break; + case ::com::sun::star::uno::TypeClass_DOUBLE: + aRet = ::comphelper::getDouble(rValue); + break; + case ::com::sun::star::uno::TypeClass_LONG: + aRet = ::comphelper::getINT32(rValue); + break; + case ::com::sun::star::uno::TypeClass_SHORT: + aRet = ::comphelper::getINT16(rValue); + break; + case ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT: + aRet = ::comphelper::getINT16(rValue); + break; + case ::com::sun::star::uno::TypeClass_BYTE: + aRet = ::comphelper::getBOOL(rValue); + break; + case ::com::sun::star::uno::TypeClass_UNSIGNED_LONG: + aRet = ::comphelper::getINT32(rValue); + break; + + case ::com::sun::star::uno::TypeClass_VOID: + default: + // ripped these three routines somewhere .... + if (::comphelper::isA(rValue,(const ::com::sun::star::util::Date*)0)) + { + aRet = connectivity::DateConversion::toDouble(*static_cast< const ::com::sun::star::util::Date*>(rValue.getValue())); + } + else if (::comphelper::isA(rValue,(const ::com::sun::star::util::Time*)0)) + { + aRet = connectivity::DateConversion::toDouble(*static_cast< const ::com::sun::star::util::Time*>(rValue.getValue())); + } + else if (::comphelper::isA(rValue,(const ::com::sun::star::util::DateTime*)0)) + { + aRet = connectivity::DateConversion::toDouble(*static_cast< const ::com::sun::star::util::DateTime*>(rValue.getValue())); + } + break; + } + } + return aRet; +} + +//======================================================================================= +// SbaXGridControl +//======================================================================================= + +//------------------------------------------------------------------ +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SbaXGridControl_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception ) +{ + return *(new SbaXGridControl(_rxFactory)); +} + +//------------------------------------------------------------------------------ +::rtl::OUString SAL_CALL SbaXGridControl::getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) +{ + return getImplementationName_Static(); +} + +//------------------------------------------------------------------------------ +::rtl::OUString SbaXGridControl::getImplementationName_Static() throw( ::com::sun::star::uno::RuntimeException ) +{ + return ::rtl::OUString::createFromAscii("com.sun.star.form.SbaXGridControl"); +} + +//------------------------------------------------------------------------------ +::com::sun::star::uno::Sequence< ::rtl::OUString> SbaXGridControl::getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ) +{ + ::com::sun::star::uno::Sequence< ::rtl::OUString> aSupported(1); + aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.form.control.ExtendedGridControl"); + return aSupported; +} + +//--------------------------------------------------------------------------------------- +SbaXGridControl::SbaXGridControl(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM) + : FmXGridControl(_rM) +{ +} + +//--------------------------------------------------------------------------------------- +SbaXGridControl::~SbaXGridControl() +{ +} + +//--------------------------------------------------------------------------------------- +FmXGridPeer* SbaXGridControl::imp_CreatePeer(Window* pParent) +{ + FmXGridPeer* pReturn = new SbaXGridPeer(m_xServiceFactory); + + // translate properties into WinBits + WinBits nStyle = WB_TABSTOP; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xModelSet(getModel(), ::com::sun::star::uno::UNO_QUERY); + if (xModelSet.is()) + { + try + { + if (::comphelper::getINT16(xModelSet->getPropertyValue(::rtl::OUString::createFromAscii("Border")))) + nStyle |= WB_BORDER; + } + catch(...) + { + } + + } + + pReturn->Create(pParent, nStyle); + return pReturn; +} + +//------------------------------------------------------------------------------ +::com::sun::star::uno::Any SAL_CALL SbaXGridControl::queryInterface(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface(_rType,(::com::sun::star::frame::XDispatch*)this); + if(aRet.hasValue()) + return aRet; + return UnoControl::queryInterface(_rType); +} + +//--------------------------------------------------------------------------------------- +void SAL_CALL SbaXGridControl::createPeer(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > & rToolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > & rParentPeer) throw( ::com::sun::star::uno::RuntimeException ) +{ + FmXGridControl::createPeer(rToolkit, rParentPeer); + if (0 == m_nPeerCreationLevel) + { + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDisp(mxPeer, ::com::sun::star::uno::UNO_QUERY); + for ( StatusMultiplexerArray::iterator aIter = m_aStatusMultiplexer.begin(); + aIter != m_aStatusMultiplexer.end(); + ++aIter) + { + if ((*aIter).second && (*aIter).second->getLength()) + xDisp->addStatusListener((*aIter).second, (*aIter).first); + } + } +} + +//--------------------------------------------------------------------------------------- +void SAL_CALL SbaXGridControl::dispatch(const ::com::sun::star::util::URL& aURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs) throw( ::com::sun::star::uno::RuntimeException ) +{ + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDisp(mxPeer, ::com::sun::star::uno::UNO_QUERY); + if (xDisp.is()) + xDisp->dispatch(aURL, aArgs); +} +//--------------------------------------------------------------------------------------- +void SAL_CALL SbaXGridControl::addStatusListener(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL) throw( ::com::sun::star::uno::RuntimeException ) +{ + SbaXStatusMultiplexer*& pMultiplexer = m_aStatusMultiplexer[aURL]; + if (!pMultiplexer) + { + pMultiplexer = new SbaXStatusMultiplexer(*this,GetMutex()); + pMultiplexer->acquire(); + } + + pMultiplexer->addInterface(xControl); + if (mxPeer.is() && pMultiplexer->getLength() == 1) + { + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDisp(mxPeer, ::com::sun::star::uno::UNO_QUERY); + xDisp->addStatusListener(pMultiplexer, aURL); + } +} + +//--------------------------------------------------------------------------------------- +void SAL_CALL SbaXGridControl::removeStatusListener(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL) throw( ::com::sun::star::uno::RuntimeException ) +{ + SbaXStatusMultiplexer*& pMultiplexer = m_aStatusMultiplexer[aURL]; + if (!pMultiplexer) + { + pMultiplexer = new SbaXStatusMultiplexer(*this,GetMutex()); + pMultiplexer->acquire(); + } + + if (mxPeer.is() && pMultiplexer->getLength() == 1) + { + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDisp(mxPeer, ::com::sun::star::uno::UNO_QUERY); + xDisp->removeStatusListener(pMultiplexer, aURL); + } + pMultiplexer->removeInterface(xControl); +} + +//--------------------------------------------------------------------------------------- +void SAL_CALL SbaXGridControl::dispose(void) throw( ::com::sun::star::uno::RuntimeException ) +{ + ::com::sun::star::lang::EventObject aEvt; + aEvt.Source = *this; + + for ( StatusMultiplexerArray::iterator aIter = m_aStatusMultiplexer.begin(); + aIter != m_aStatusMultiplexer.end(); + ++aIter) + { + if ((*aIter).second) + { + (*aIter).second->disposeAndClear(aEvt); + (*aIter).second->release(); + (*aIter).second = NULL; + } + } + + FmXGridControl::dispose(); +} + +//======================================================================================= +// SbaXGridPeer +//======================================================================================= + +//--------------------------------------------------------------------------------------- +SbaXGridPeer::SbaXGridPeer(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM) +: FmXGridPeer(_rM) +,m_aStatusListeners(m_aMutex) +{ +} + +//--------------------------------------------------------------------------------------- +SbaXGridPeer::~SbaXGridPeer() +{ +} + +//--------------------------------------------------------------------------------------- +void SAL_CALL SbaXGridPeer::dispose(void) throw( ::com::sun::star::uno::RuntimeException ) +{ + ::com::sun::star::lang::EventObject aEvt(*this); + + m_aStatusListeners.disposeAndClear(aEvt); + + FmXGridPeer::dispose(); +} + +//--------------------------------------------------------------------------------------- +void SbaXGridPeer::NotifyStatusChanged(const ::com::sun::star::util::URL& aUrl, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl) +{ + SbaGridControl* pGrid = (SbaGridControl*) GetWindow(); + if (!pGrid) + return; + + ::com::sun::star::frame::FeatureStateEvent aEvt; + aEvt.Source = *this; + aEvt.IsEnabled = !pGrid->IsReadOnlyDB(); + + if (xControl.is()) + xControl->statusChanged(aEvt); + else + { + ::cppu::OInterfaceContainerHelper * pIter = m_aStatusListeners.getContainer(aUrl); + + if (pIter) + { + ::cppu::OInterfaceIteratorHelper aListIter(*pIter); + while (aListIter.hasMoreElements()) + ((::com::sun::star::frame::XStatusListener*)aListIter.next())->statusChanged(aEvt); + } + } +} + +//------------------------------------------------------------------------------ +::com::sun::star::uno::Any SAL_CALL SbaXGridPeer::queryInterface(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface(_rType,(::com::sun::star::frame::XDispatch*)this); + if(aRet.hasValue()) + return aRet; + return FmXGridPeer::queryInterface(_rType); +} + +//--------------------------------------------------------------------------------------- +::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL SbaXGridPeer::queryDispatch(const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw( ::com::sun::star::uno::RuntimeException ) +{ + if ( (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:GridSlots/BrowserAttribs"))) + || (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:GridSlots/RowHeight"))) + || (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:GridSlots/ColumnAttribs"))) + || (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:GridSlots/ColumnWidth"))) + ) + { + return (::com::sun::star::frame::XDispatch*)this; + } + + return FmXGridPeer::queryDispatch(aURL, aTargetFrameName, nSearchFlags); +} + +//--------------------------------------------------------------------------------------- +void SAL_CALL SbaXGridPeer::dispatch(const ::com::sun::star::util::URL& aURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs) throw( ::com::sun::star::uno::RuntimeException ) +{ + SbaGridControl* pGrid = (SbaGridControl*)GetWindow(); + if (!pGrid) + return; + + sal_Int16 nColId = -1; + const ::com::sun::star::beans::PropertyValue* pArgs = aArgs.getConstArray(); + for (sal_uInt16 i=0; i<aArgs.getLength(); ++i, ++pArgs) + { + if (pArgs->Name == ::rtl::OUString::createFromAscii("ColumnViewPos")) + { + nColId = pGrid->GetColumnIdFromViewPos(::comphelper::getINT16(pArgs->Value)); + break; + } + if (pArgs->Name == ::rtl::OUString::createFromAscii("ColumnModelPos")) + { + nColId = pGrid->GetColumnIdFromModelPos(::comphelper::getINT16(pArgs->Value)); + break; + } + if (pArgs->Name == ::rtl::OUString::createFromAscii("ColumnId")) + { + nColId = ::comphelper::getINT16(pArgs->Value); + break; + } + } + + if (aURL.Complete == ::rtl::OUString::createFromAscii(".uno:GridSlots/BrowserAttribs")) + pGrid->SetBrowserAttrs(); + else if (aURL.Complete == ::rtl::OUString::createFromAscii(".uno:GridSlots/RowHeight")) + pGrid->SetRowHeight(); + else if (aURL.Complete == ::rtl::OUString::createFromAscii(".uno:GridSlots/ColumnAttribs")) + { + DBG_ASSERT(nColId != -1, "SbaXGridPeer::dispatch : invalid parameter !"); + if (nColId != -1) + return; + pGrid->SetColAttrs(nColId); + } + else if (aURL.Complete == ::rtl::OUString::createFromAscii(".uno:GridSlots/ColumnWidth")) + { + DBG_ASSERT(nColId != -1, "SbaXGridPeer::dispatch : invalid parameter !"); + if (nColId != -1) + return; + pGrid->SetColWidth(nColId); + } +} + +//--------------------------------------------------------------------------------------- +void SAL_CALL SbaXGridPeer::addStatusListener(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL) throw( ::com::sun::star::uno::RuntimeException ) +{ + ::cppu::OInterfaceContainerHelper* pCont = m_aStatusListeners.getContainer(aURL); + if (!pCont) + m_aStatusListeners.addInterface(aURL,xControl); + else + pCont->addInterface(xControl); + NotifyStatusChanged(aURL, xControl); +} + +//--------------------------------------------------------------------------------------- +void SAL_CALL SbaXGridPeer::removeStatusListener(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL) throw( ::com::sun::star::uno::RuntimeException ) +{ + ::cppu::OInterfaceContainerHelper* pCont = m_aStatusListeners.getContainer(aURL); + if (!pCont) + + pCont->removeInterface(xControl); +} + +//--------------------------------------------------------------------------------------- +void SAL_CALL SbaXGridPeer::selectionChanged(const ::com::sun::star::lang::EventObject& aEvent) +{ + FmXGridPeer::selectionChanged(aEvent); + + SbaGridControl* pGrid = (SbaGridControl*) GetWindow(); + if (pGrid) + { + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > xColumns = getColumns(); + ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionSupplier > xSelSupplier(aEvent.Source, ::com::sun::star::uno::UNO_QUERY); + ::com::sun::star::uno::Any aSelection = xSelSupplier->getSelection(); + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xSelection; + if (aSelection.getValueTypeClass() == ::com::sun::star::uno::TypeClass_INTERFACE) + xSelection = ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > (*(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > *)aSelection.getValue(), ::com::sun::star::uno::UNO_QUERY); + sal_uInt16 nSelectedCol = (sal_uInt16)-1; + if (xSelection.is()) + { + for (sal_uInt16 i = 0; i < xColumns->getCount(); i++) + { + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xCol(*(::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > *)xColumns->getByIndex(i).getValue()); + if (xCol == xSelection) + { + nSelectedCol = i; + break; + } + } + } + + // fuer das VCL-Control muessen die Columns 1-basiert sein + // die Selektion an das VCL-Control weiterreichen, wenn noetig + if (nSelectedCol != pGrid->GetSelectedColumn()) + { // (wenn das nicht greift, wurde das selectionChanged implizit von dem Control selber ausgeloest + if (nSelectedCol != (sal_uInt16)-1) + { + pGrid->SelectColumnPos(pGrid->GetViewColumnPos(pGrid->GetColumnIdFromModelPos(nSelectedCol)) + 1, sal_True); + // SelectColumnPos hat wieder zu einem impliziten ActivateCell gefuehrt + if (pGrid->IsEditing()) + pGrid->DeactivateCell(); + } + else + pGrid->SetNoSelection(); + } + } +} +//--------------------------------------------------------------------------------------- +const ::com::sun::star::uno::Sequence< sal_Int8 > & SbaXGridPeer::getUnoTunnelId() +{ + static ::com::sun::star::uno::Sequence< sal_Int8 > * pSeq = 0; + if( !pSeq ) + { + ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ); + if( !pSeq ) + { + static ::com::sun::star::uno::Sequence< sal_Int8 > aSeq( 16 ); + rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0,sal_True ); + pSeq = &aSeq; + } + } + return *pSeq; +} + +//--------------------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL SbaXGridPeer::getTypes() throw (::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypes = FmXGridPeer::getTypes(); + sal_Int32 nOldLen = aTypes.getLength(); + aTypes.realloc(nOldLen + 1); + aTypes.getArray()[nOldLen] = ::getCppuType( reinterpret_cast< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >* >(NULL) ); + + return aTypes; +} + +// return implementation specific data +//------------------------------------------------------------------ +sal_Int64 SAL_CALL SbaXGridPeer::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 > & rId ) +{ + if( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) + return (sal_Int64)this; + + return FmXGridPeer::getSomething(rId); +} + +//--------------------------------------------------------------------------------------- +SbaXGridPeer* SbaXGridPeer::getImplementation(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxIFace) +{ + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xTunnel( + _rxIFace, ::com::sun::star::uno::UNO_QUERY); + if (xTunnel.is()) + return reinterpret_cast<SbaXGridPeer*>(xTunnel->getSomething(getUnoTunnelId())); + return NULL; +} + +//--------------------------------------------------------------------------------------- +void SAL_CALL SbaXGridPeer::propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) +{ + FmXGridPeer::propertyChange(evt); +} + +//--------------------------------------------------------------------------------------- +void SbaXGridPeer::addColumnListeners(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & xCol) +{ + FmXGridPeer::addColumnListeners(xCol); +} + +//--------------------------------------------------------------------------------------- +void SbaXGridPeer::removeColumnListeners(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & xCol) +{ + FmXGridPeer::removeColumnListeners(xCol); +} + +//--------------------------------------------------------------------------------------- +FmGridControl* SbaXGridPeer::imp_CreateControl(::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rM,Window* pParent, WinBits nStyle) +{ + return new SbaGridControl(_rM,pParent, this, nStyle); +} + +//================================================================== +// SbaGridHeader +//================================================================== + +//--------------------------------------------------------------------------------------- +SbaGridHeader::SbaGridHeader(BrowseBox* pParent, WinBits nWinBits) + :FmGridHeader(pParent, nWinBits) +{ +} + +//--------------------------------------------------------------------------------------- +void SbaGridHeader::ImplSelect(sal_uInt16 nId) +{ + sal_uInt16 nPos = GetModelColumnPos(nId); + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > xColumns(((SbaGridControl*)GetParent())->GetPeer()->getColumns(), ::com::sun::star::uno::UNO_QUERY); + if (nPos < xColumns->getCount()) + { + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xColumn(*(::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > *)xColumns->getByIndex(nPos).getValue()); + ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionSupplier > xSelSupplier(xColumns, ::com::sun::star::uno::UNO_QUERY); + if (xSelSupplier.is()) + xSelSupplier->select(::com::sun::star::uno::makeAny(xColumn)); + } +} + +//--------------------------------------------------------------------------------------- +void SbaGridHeader::Command( const CommandEvent& rEvt ) +{ + sal_Bool bHandled = sal_False; + if (COMMAND_STARTDRAG == rEvt.GetCommand()) + { + Point aPos( rEvt.GetMousePosPixel() ); + + sal_uInt16 nId = GetItemId(aPos); + sal_Bool bResizingCol = sal_False; + if (HEADERBAR_ITEM_NOTFOUND != nId) + { + Rectangle aColRect = GetItemRect(nId); + aColRect.Left() += nId ? 3 : 0; // the handle col (nId == 0) doens not have a left margin for resizing + aColRect.Right() -= 3; + bResizingCol = !aColRect.IsInside(aPos); + } + if (!bResizingCol) + { + // because we have 3d-buttons the select handler is called from MouseButtonUp, but StartDrag + // occures earlier (while the mouse button is down) + // so for optical reasons we select the column before really starting the drag operation. + ImplSelect(nId); + + ((SbaGridControl*)GetParent())->GetDataWindow().Command( + CommandEvent( + Point( + aPos.X() + GetPosPixel().X(), // we aren't left-justified with our parent, in contrast to the data window + aPos.Y() - GetSizePixel().Height() + ), + COMMAND_STARTDRAG, + rEvt.IsMouseEvent() + ) + ); + bHandled = sal_True; + } + } + + if (!bHandled) + FmGridHeader::Command(rEvt); +} + +//--------------------------------------------------------------------------------------- +void SbaGridHeader::Select() +{ + DbBrowseHeader::Select(); + if (!((FmGridControl*)GetParent())->IsDesignMode()) + { // in design mode the base class does the same ... + ImplSelect(GetCurItemId()); + } +} + +//--------------------------------------------------------------------------------------- +void SbaGridHeader::PreExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMenu) +{ + FmGridHeader::PreExecuteColumnContextMenu(nColId, rMenu); + + // some items are valid only if the db isn't readonly + sal_Bool bDBIsReadOnly = ((SbaGridControl*)GetParent())->IsReadOnlyDB(); + + if (bDBIsReadOnly) + { + rMenu.EnableItem(SID_FM_HIDECOL, sal_False); + PopupMenu* pShowColsMenu = rMenu.GetPopupMenu(SID_FM_SHOWCOLS); + if (pShowColsMenu) + { + // at most 16 items which mean "show column <name>" + for (sal_uInt16 i=1; i<16; ++i) + pShowColsMenu->EnableItem(i, sal_False); + // "show cols/more..." and "show cols/all" + pShowColsMenu->EnableItem(SID_FM_SHOWCOLS_MORE, sal_False); + pShowColsMenu->EnableItem(SID_FM_SHOWALLCOLS, sal_False); + } + } + + // prepend some new items + sal_Bool bColAttrs = (nColId != (sal_uInt16)-1); + if (bColAttrs) + { + sal_uInt16 nPos = 0; + PopupMenu aNewItems(ModuleRes(RID_SBA_GRID_COLCTXMENU)); + if (!bDBIsReadOnly) + { + rMenu.InsertItem(ID_BROWSER_COLATTRSET, aNewItems.GetItemText(ID_BROWSER_COLATTRSET), 0, nPos++); + rMenu.SetHelpId(ID_BROWSER_COLATTRSET, aNewItems.GetHelpId(ID_BROWSER_COLATTRSET)); + rMenu.InsertSeparator(nPos++); + + rMenu.InsertItem(ID_BROWSER_COLWIDTH, aNewItems.GetItemText(ID_BROWSER_COLWIDTH), 0, nPos++); + rMenu.SetHelpId(ID_BROWSER_COLWIDTH, aNewItems.GetHelpId(ID_BROWSER_COLWIDTH)); + rMenu.InsertSeparator(nPos++); + } + } +} + +//--------------------------------------------------------------------------------------- +void SbaGridHeader::PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMenu& rMenu, sal_uInt16 nExecutionResult) +{ + switch (nExecutionResult) + { + case ID_BROWSER_COLWIDTH: + ((SbaGridControl*)GetParent())->SetColWidth(nColId); + break; + + case ID_BROWSER_COLATTRSET: + ((SbaGridControl*)GetParent())->SetColAttrs(nColId); + break; + + default: FmGridHeader::PostExecuteColumnContextMenu(nColId, rMenu, nExecutionResult); + } +} + +//================================================================== +// SbaGridControl +//================================================================== + +//--------------------------------------------------------------------------------------- +SbaGridControl::SbaGridControl(::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rM, + Window* pParent, FmXGridPeer* _pPeer, WinBits nBits) + :FmGridControl(_rM,pParent, _pPeer, nBits) + ,m_nLastColId(-1) + ,m_nLastRowId(-1) + ,m_nCurrentSelectedColumn(-1) + ,m_nCurrentActionColId(-1) + ,m_bSelecting(sal_False) + ,m_pMasterListener(NULL) + ,m_bActivatingForDrop(sal_False) +{ +} + +//--------------------------------------------------------------------------------------- +SbaGridControl::~SbaGridControl() +{ +} + +//--------------------------------------------------------------------------------------- +BrowserHeader* SbaGridControl::imp_CreateHeaderBar(BrowseBox* pParent) +{ + return new SbaGridHeader(pParent); +} + +//--------------------------------------------------------------------------------------- +DbCellController* SbaGridControl::GetController(long nRow, sal_uInt16 nCol) +{ + DbCellControllerRef aController; + if (m_bActivatingForDrop) + return &aController; + + return FmGridControl::GetController(nRow, nCol); +} + +//--------------------------------------------------------------------------------------- +void SbaGridControl::PreExecuteRowContextMenu(sal_uInt16 nRow, PopupMenu& rMenu) +{ + FmGridControl::PreExecuteRowContextMenu(nRow, rMenu); + + PopupMenu aNewItems(ModuleRes(RID_SBA_GRID_ROWCTXMENU)); + sal_uInt16 nPos = 0; + + if (!IsReadOnlyDB()) + { + rMenu.InsertItem(ID_BROWSER_TABLEATTR, aNewItems.GetItemText(ID_BROWSER_TABLEATTR), 0, nPos++); + rMenu.SetHelpId(ID_BROWSER_TABLEATTR, aNewItems.GetHelpId(ID_BROWSER_TABLEATTR)); + + rMenu.InsertItem(ID_BROWSER_ROWHEIGHT, aNewItems.GetItemText(ID_BROWSER_ROWHEIGHT), 0, nPos++); + rMenu.SetHelpId(ID_BROWSER_ROWHEIGHT, aNewItems.GetHelpId(ID_BROWSER_ROWHEIGHT)); + } + if (nPos) + rMenu.InsertSeparator(nPos); +} + +//------------------------------------------------------------------------------ +SvNumberFormatter* SbaGridControl::GetDatasourceFormatter() +{ + ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier = ::dbtools::getNumberFormats(::dbtools::getConnection(::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > (getDataSource(),::com::sun::star::uno::UNO_QUERY)), sal_True,getServiceManager()); + + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xTunnel(xSupplier,::com::sun::star::uno::UNO_QUERY); + SvNumberFormatsSupplierObj* pSupplierImpl = (SvNumberFormatsSupplierObj*)xTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()); + + if (!pSupplierImpl) + return NULL; + + SvNumberFormatter* pFormatter = pSupplierImpl->GetNumberFormatter(); + return pFormatter; +} + +//------------------------------------------------------------------------------ +void SbaGridControl::SetColWidth(sal_uInt16 nColId) +{ + // get the (UNO) column model + sal_uInt16 nModelPos = GetModelColumnPos(nColId); + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > xCols(GetPeer()->getColumns(), ::com::sun::star::uno::UNO_QUERY); + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xAffectedCol; + if (xCols.is() && (nModelPos != (sal_uInt16)-1)) + xAffectedCol = ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > (*(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > *)xCols->getByIndex(nModelPos).getValue(), ::com::sun::star::uno::UNO_QUERY); + + if (xAffectedCol.is()) + { + ::com::sun::star::uno::Any aWidth = xAffectedCol->getPropertyValue(PROPERTY_WIDTH); + sal_Int32 nCurWidth = aWidth.hasValue() ? ::comphelper::getINT32(aWidth) : -1; + +// DlgSize aDlgColWidth(NULL, nCurWidth, sal_False); +// if (aDlgColWidth.Execute()) +// { +// sal_uInt16 nValue = aDlgColWidth.GetValue(); +// ::com::sun::star::uno::Any aNewWidth; +// if ((sal_uInt16)-1 == nValue) +// { // set to default +// ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState > xPropState(xAffectedCol, ::com::sun::star::uno::UNO_QUERY); +// if (xPropState.is()) +// { +// try { aNewWidth = xPropState->getPropertyDefault(PROPERTY_WIDTH); } catch(...) { } ; +// } +// } +// else +// aNewWidth <<= nValue; +// try { xAffectedCol->setPropertyValue(PROPERTY_WIDTH, aNewWidth); } catch(...) { } ; +// } + } +} + +//------------------------------------------------------------------------------ +void SbaGridControl::SetRowHeight() +{ + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xCols(GetPeer()->getColumns(), ::com::sun::star::uno::UNO_QUERY); + if (!xCols.is()) + return; + + ::com::sun::star::uno::Any aHeight = xCols->getPropertyValue(PROPERTY_ROW_HEIGHT); + sal_Int32 nCurHeight = aHeight.hasValue() ? ::comphelper::getINT32(aHeight) : -1; + + // TODO +// DlgSize aDlgRowHeight(NULL, nCurHeight, sal_True); +// if (aDlgRowHeight.Execute()) +// { +// sal_uInt16 nValue = aDlgRowHeight.GetValue(); +// ::com::sun::star::uno::Any aNewHeight; +// if ((sal_uInt16)-1 == nValue) +// { // set to default +// ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState > xPropState(xCols, ::com::sun::star::uno::UNO_QUERY); +// if (xPropState.is()) +// { +// try { aNewHeight = xPropState->getPropertyDefault(PROPERTY_ROW_HEIGHT); } catch(...) { } ; +// } +// } +// else +// aNewHeight <<= nValue; +// try { xCols->setPropertyValue(PROPERTY_ROW_HEIGHT, aNewHeight); } catch(...) { } ; +// } +} + +//------------------------------------------------------------------------------ +void SbaGridControl::SetColAttrs(sal_uInt16 nColId) +{ +// SvNumberFormatter* pFormatter = GetDatasourceFormatter(); +// if (!pFormatter) +// return; +// +// sal_uInt16 nModelPos = GetModelColumnPos(nColId); +// +// // get the (UNO) column model +// ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > xCols(GetPeer()->getColumns(), ::com::sun::star::uno::UNO_QUERY); +// ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xAffectedCol; +// if (xCols.is() && (nModelPos != (sal_uInt16)-1)) +// xAffectedCol = ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > (*(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > *)xCols->getByIndex(nModelPos).getValue(), ::com::sun::star::uno::UNO_QUERY); +// +// // get the field the column is bound to +// ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xField = getField(nModelPos); +// +// if (xAffectedCol.is() && xField.is()) +// { +// // the allowed format changes depend of the type of the field ... +// XubString sColName = ::comphelper::getString(xField->getPropertyValue(PROPERTY_NAME)); +// +// sal_uInt16 nFlags = TP_ATTR_ALIGN; +// ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > xInfo = xAffectedCol->getPropertySetInfo(); +// sal_Bool bHasFormat = xInfo->hasPropertyByName(PROPERTY_FORMATKEY); +// if (bHasFormat) +// nFlags |= TP_ATTR_NUMBER; +// +// // ------------ +// // UNO->ItemSet +// static SfxItemInfo aItemInfos[] = +// { +// { 0, 0 }, +// { SID_ATTR_NUMBERFORMAT_VALUE, SFX_ITEM_POOLABLE }, +// { SID_ATTR_ALIGN_HOR_JUSTIFY, SFX_ITEM_POOLABLE }, +// { SID_ATTR_NUMBERFORMAT_ONE_AREA, SFX_ITEM_POOLABLE } +// }; +// static sal_uInt16 aAttrMap[] = +// { +// SBA_DEF_RANGEFORMAT, SBA_ATTR_ALIGN_HOR_JUSTIFY, +// SID_ATTR_NUMBERFORMAT_ONE_AREA, SID_ATTR_NUMBERFORMAT_ONE_AREA, +// 0 +// }; +// +// SfxPoolItem* pDefaults[] = +// { +// new SfxRangeItem(SBA_DEF_RANGEFORMAT, SBA_DEF_FMTVALUE, SBA_ATTR_ALIGN_HOR_JUSTIFY), +// new SfxUInt32Item(SBA_DEF_FMTVALUE), +// new SvxHorJustifyItem(SVX_HOR_JUSTIFY_STANDARD, SBA_ATTR_ALIGN_HOR_JUSTIFY), +// new SfxBoolItem(SID_ATTR_NUMBERFORMAT_ONE_AREA, sal_False) +// }; +// +// SfxItemPool* pPool = new SfxItemPool(String::CreateFromAscii("GridBrowserProperties"), SBA_DEF_RANGEFORMAT, SBA_ATTR_ALIGN_HOR_JUSTIFY, aItemInfos, pDefaults); +// pPool->SetDefaultMetric( SFX_MAPUNIT_TWIP ); // ripped, don't understand why +// pPool->FreezeIdRanges(); // the same +// +// SfxItemSet* pFormatDescriptor = new SfxItemSet(*pPool, aAttrMap); +// // fill it +// SvxCellHorJustify eJustify(SVX_HOR_JUSTIFY_STANDARD); +// ::com::sun::star::uno::Any aAlignment = xAffectedCol->getPropertyValue(PROPERTY_ALIGN); +// if (aAlignment.hasValue()) +// switch (::comphelper::getINT16(aAlignment)) +// { +// case ::com::sun::star::awt::TextAlign::LEFT : eJustify = SVX_HOR_JUSTIFY_LEFT; break; +// case ::com::sun::star::awt::TextAlign::CENTER : eJustify = SVX_HOR_JUSTIFY_CENTER; break; +// case ::com::sun::star::awt::TextAlign::RIGHT : eJustify = SVX_HOR_JUSTIFY_RIGHT; break; +// } +// pFormatDescriptor->Put(SvxHorJustifyItem(eJustify, SBA_ATTR_ALIGN_HOR_JUSTIFY)); +// if (bHasFormat) +// { +// sal_Int32 nFormatKey = ::comphelper::getINT32(xAffectedCol->getPropertyValue(PROPERTY_FORMATKEY)); +// // if the col is bound to a text field we have to disallow all non-text formats +// sal_Int16 nFieldType = ::comphelper::getINT16(xField->getPropertyValue(PROPERTY_TYPE)); +// if ((::com::sun::star::data::DatabaseFieldType::CHAR == nFieldType) || (::com::sun::star::data::DatabaseFieldType::VARCHAR == nFieldType) || (::com::sun::star::data::DatabaseFieldType::LONGVARCHAR == nFieldType)) +// { +// pFormatDescriptor->Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_ONE_AREA, sal_True)); +// if (!pFormatter->IsTextFormat(nFormatKey)) +// // text fields can only have text formats +// nFormatKey = pFormatter->GetStandardFormat(NUMBERFORMAT_TEXT, Application::GetAppInternational().GetLanguage()); +// } +// +// pFormatDescriptor->Put(SfxUInt32Item(SBA_DEF_FMTVALUE, nFormatKey)); +// } +// +// { // want the dialog to be destroyed before our set +// SbaSbAttrDlg aDlg(NULL, pFormatDescriptor, pFormatter, nFlags); +// if (aDlg.Execute()) +// { +// // ------------ +// // ItemSet->UNO +// // UNO-properties +// const SfxItemSet* pSet = aDlg.GetExampleSet(); +// // (of course we could put the modified items directly into the column, but then the UNO-model +// // won't reflect these changes, and why do we have a model, then ?) +// +// // horizontal justify +// SFX_ITEMSET_GET(*pSet, pHorJustify, SvxHorJustifyItem, SBA_ATTR_ALIGN_HOR_JUSTIFY, sal_True); +// +// SvxCellHorJustify eHorJustify = (SvxCellHorJustify)pHorJustify->GetValue(); +// ::com::sun::star::uno::Any aTextAlign; +// switch (eHorJustify) +// { +// case SVX_HOR_JUSTIFY_LEFT: +// aTextAlign <<= ::com::sun::star::awt::TextAlign::LEFT; +// break; +// case SVX_HOR_JUSTIFY_CENTER: +// aTextAlign <<= ::com::sun::star::awt::TextAlign::CENTER; +// break; +// case SVX_HOR_JUSTIFY_RIGHT: +// aTextAlign <<= ::com::sun::star::awt::TextAlign::RIGHT; +// break; +// } +// xAffectedCol->setPropertyValue(PROPERTY_ALIGN, aTextAlign); +// +// // format key +// if (nFlags & TP_ATTR_NUMBER) +// { +// SFX_ITEMSET_GET(*pSet, pFormat, SfxUInt32Item, SBA_DEF_FMTVALUE, sal_True); +// xAffectedCol->setPropertyValue(PROPERTY_FORMATKEY, ::com::sun::star::uno::makeAny((sal_Int32)pFormat->GetValue())); +// } +// } +// } +// +// delete pFormatDescriptor; +// delete pPool; +// for (sal_uInt16 i=0; i<sizeof(pDefaults)/sizeof(pDefaults[0]); ++i) +// delete pDefaults[i]; +// } +} + + +//------------------------------------------------------------------------------ +void SbaGridControl::SetBrowserAttrs() +{ +// ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xGridModel(GetPeer()->getColumns(), ::com::sun::star::uno::UNO_QUERY); +// if (!xGridModel.is()) +// return; +// +// SvNumberFormatter* pFormatter = GetDatasourceFormatter(); +// if (!pFormatter) +// return; +// +// // build an itemset describing the current font +// static SfxItemInfo aItemInfos[] = +// { +// { 0, 0 }, +// { SID_ATTR_CHAR_FONT, SFX_ITEM_POOLABLE }, +// { SID_ATTR_CHAR_FONTHEIGHT, SFX_ITEM_POOLABLE }, +// { SID_ATTR_CHAR_COLOR, SFX_ITEM_POOLABLE }, +// { SID_ATTR_CHAR_WEIGHT, SFX_ITEM_POOLABLE }, +// { SID_ATTR_CHAR_POSTURE, SFX_ITEM_POOLABLE }, +// { 0, 0 }, +// { 0, 0 }, +// { SID_ATTR_CHAR_STRIKEOUT, SFX_ITEM_POOLABLE }, +// { SID_ATTR_CHAR_UNDERLINE, SFX_ITEM_POOLABLE } +// }; +// static sal_uInt16 aAttrMap[] = +// { +// SBA_DEF_FONT, SBA_DEF_UNDERLINE, +// 0 +// }; +// +// Font aFont = System::GetStandardFont(STDFONT_APP); +// aFont.SetSize(Size(aFont.GetSize().Width(), 10)); +// sal_uInt32 nFontHeight = (sal_uInt32)PixelToLogic(aFont.GetSize(), MAP_TWIP).Height(); +// +// SfxPoolItem* pDefaults[] = +// { +// new SfxRangeItem( SBA_DEF_RANGEFONT, SBA_DEF_FONT, SBA_DEF_UNDERLINE ), +// new SvxFontItem(aFont.GetFamily(), aFont.GetName(), String(), PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, SBA_DEF_FONT), +// new SvxFontHeightItem(nFontHeight, 100, SBA_DEF_FONTHEIGHT ), +// new SvxColorItem(aFont.GetColor(), SBA_DEF_FONTCOLOR ), +// new SvxWeightItem(WEIGHT_LIGHT, SBA_DEF_FONTWEIGHT), +// new SvxPostureItem( ITALIC_NONE, SBA_DEF_POSTURE ), +// new SvxShadowedItem( sal_False, SBA_DEF_SHADOWED ), +// new SvxContourItem( sal_False, SBA_DEF_CONTOUR ), +// new SvxCrossedOutItem( STRIKEOUT_NONE, SBA_DEF_CROSSEDOUT ), +// new SvxUnderlineItem( UNDERLINE_NONE, SBA_DEF_UNDERLINE ) +// }; +// +// SfxItemPool* pPool = new SfxItemPool(String::CreateFromAscii("GridBrowserProperties"), SBA_DEF_RANGEFONT, SBA_DEF_UNDERLINE, aItemInfos, pDefaults); +// pPool->SetDefaultMetric( SFX_MAPUNIT_TWIP ); +// pPool->FreezeIdRanges(); +// +// SfxItemSet* pFontDescriptor = new SfxItemSet(*pPool, aAttrMap); +// +// // initialize it with the current settings (font/color) +// ::com::sun::star::awt::FontDescriptor aCurrentFont; +// xGridModel->getPropertyValue(PROPERTY_FONT) >>= aCurrentFont; +// BuildItemsFromFont(pFontDescriptor, aCurrentFont); +// ::com::sun::star::uno::Any aColor = xGridModel->getPropertyValue(PROPERTY_TEXTCOLOR); +// if (aColor.hasValue()) +// pFontDescriptor->Put(SvxColorItem((Color)::comphelper::getINT32(aColor), SBA_DEF_FONTCOLOR)); +// +// { // want the dialog to be destroyed before our set +// SbaSbAttrDlg aDlg(GetParent(), pFontDescriptor, pFormatter, TP_ATTR_CHAR, sal_True); +// if (aDlg.Execute()) +// { +// ::com::sun::star::awt::FontDescriptor aNewFont = BuildFontFromItems(aDlg.GetExampleSet(), GetFont()); +// xGridModel->setPropertyValue(PROPERTY_FONT, ::com::sun::star::uno::Any(&aNewFont, ::getCppuType((const ::com::sun::star::awt::FontDescriptor*)0))); +// +// SFX_ITEMSET_GET(*aDlg.GetOutputItemSet(), pColor, SvxColorItem, SBA_DEF_FONTCOLOR, sal_True); +// xGridModel->setPropertyValue(PROPERTY_TEXTCOLOR, ::com::sun::star::uno::makeAny((sal_Int32)pColor->GetValue().GetColor())); +// } +// } +// +// delete pFontDescriptor; +// delete pPool; +// for (sal_uInt16 i=0; i<sizeof(pDefaults)/sizeof(pDefaults[0]); ++i) +// delete pDefaults[i]; +} + +//--------------------------------------------------------------------------------------- +void SbaGridControl::PostExecuteRowContextMenu(sal_uInt16 nRow, const PopupMenu& rMenu, sal_uInt16 nExecutionResult) +{ + switch (nExecutionResult) + { + case ID_BROWSER_TABLEATTR: + SetBrowserAttrs(); + break; + case ID_BROWSER_ROWHEIGHT: + SetRowHeight(); + break; + + default: + FmGridControl::PostExecuteRowContextMenu(nRow, rMenu, nExecutionResult); + break; + } +} + +//--------------------------------------------------------------------------------------- +void SbaGridControl::Select() +{ + // irgendeine Selektion hat sich geaendert .... + FmGridControl::Select(); + + // ... betrifft das unsere Spalten ? + const MultiSelection* pColumnSelection = GetColumnSelection(); + + long nSelectedColumn = + pColumnSelection && pColumnSelection->GetSelectCount() + ? ((MultiSelection*)pColumnSelection)->FirstSelected() + : -1L; + // die HandleColumn wird nicht selektiert + switch (nSelectedColumn) + { + case -1 : break; // no selection + case 0 : nSelectedColumn = -1; break; // handle col can't be seledted + default : + // get the model col pos instead of the view col pos + nSelectedColumn = GetModelColumnPos(GetColumnIdFromViewPos(nSelectedColumn - 1)); + break; + } + + if (nSelectedColumn != m_nCurrentSelectedColumn) + { + // VOR dem Aufruf des select am SelectionSupplier ! + m_nCurrentSelectedColumn = nSelectedColumn; + + if (!m_bSelecting) + { + m_bSelecting = sal_True; + + try + { + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > xColumns(GetPeer()->getColumns(), ::com::sun::star::uno::UNO_QUERY); + ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionSupplier > xSelSupplier(xColumns, ::com::sun::star::uno::UNO_QUERY); + if (xSelSupplier.is()) + if (nSelectedColumn != -1) + { + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xColumn(*(::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > *)xColumns->getByIndex(nSelectedColumn).getValue()); + xSelSupplier->select(::com::sun::star::uno::makeAny(xColumn)); + } + else + { + xSelSupplier->select(::com::sun::star::uno::Any()); + } + } + catch(...) + { + } + + + m_bSelecting = sal_False; + } + } + + if (m_pMasterListener) + m_pMasterListener->SelectionChanged(); +} + +//--------------------------------------------------------------------------------------- +void SbaGridControl::CursorMoved() +{ + FmGridControl::CursorMoved(); + if (m_nLastRowId != GetCurRow()) + RowChanged(); + if (m_nLastColId != GetCurColumnId()) + ColChanged(); + + m_nLastColId = GetCurColumnId(); + m_nLastRowId = GetCurRow(); +} + +//--------------------------------------------------------------------------------------- +void SbaGridControl::ActivateCell(long nRow, sal_uInt16 nCol, sal_Bool bSetCellFocus /*= sal_True*/ ) +{ + FmGridControl::ActivateCell(nRow, nCol, bSetCellFocus); + if (m_pMasterListener) + m_pMasterListener->CellActivated(); +} + +//--------------------------------------------------------------------------------------- +void SbaGridControl::DeactivateCell(sal_Bool bUpdate /*= sal_True*/) +{ + FmGridControl::DeactivateCell(bUpdate); + if (m_pMasterListener) + m_pMasterListener->CellDeactivated(); +} + +//--------------------------------------------------------------------------------------- +void SbaGridControl::RowChanged() +{ + if (m_pMasterListener) + m_pMasterListener->RowChanged(); +} + +//--------------------------------------------------------------------------------------- +void SbaGridControl::ColChanged() +{ + if (m_pMasterListener) + m_pMasterListener->ColumnChanged(); +} + + +//------------------------------------------------------------------------------ +void SbaGridControl::setDataSource(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > & rCursor, sal_uInt16 nOpts) +{ + FmGridControl::setDataSource(rCursor, nOpts); + + // for DnD we need a query composer + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xFormSet = getDataSource(); + ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > xForm(xFormSet, ::com::sun::star::uno::UNO_QUERY); + if (xForm.is() && xFormSet.is() && ::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_USE_ESCAPE_PROCESSING))) + { // (only if the statement isn't native) + ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLQueryComposerFactory > xFactory(::dbtools::getConnection(::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > (xFormSet,::com::sun::star::uno::UNO_QUERY)), ::com::sun::star::uno::UNO_QUERY); + if (xFactory.is()) + m_xComposer = xFactory->createQueryComposer(); + } + else + m_xComposer = NULL; +} + +//------------------------------------------------------------------------------ +::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SbaGridControl::getField(sal_uInt16 nModelPos) +{ + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xEmptyReturn; + try + { + // first get the name of the column + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > xCols(GetPeer()->getColumns(), ::com::sun::star::uno::UNO_QUERY); + if (!xCols.is()) + return xEmptyReturn; + + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xCol(*(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > *)xCols->getByIndex(nModelPos).getValue(), ::com::sun::star::uno::UNO_QUERY); + if (!xCol.is()) + return xEmptyReturn; + + ::com::sun::star::uno::Any aBoundField = xCol->getPropertyValue(PROPERTY_BOUNDFIELD); + if (aBoundField.hasValue()) + return ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > (*(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > *)aBoundField.getValue(), ::com::sun::star::uno::UNO_QUERY); + } + catch(...) + { + } + + return xEmptyReturn; +} + +//--------------------------------------------------------------------------------------- +sal_Bool SbaGridControl::IsReadOnlyDB() const +{ + // assume yes if anything fails + sal_Bool bDBIsReadOnly = sal_True; + + // the db is the implemented by the parent of the grid control's model ... + ::com::sun::star::uno::Reference< ::com::sun::star::container::XChild > xColumns(GetPeer()->getColumns(), ::com::sun::star::uno::UNO_QUERY); + if (xColumns.is()) + { + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > xDataSource(xColumns->getParent(), ::com::sun::star::uno::UNO_QUERY); + ::com::sun::star::uno::Reference< ::com::sun::star::container::XChild > xConn(::dbtools::getConnection(xDataSource),::com::sun::star::uno::UNO_QUERY); + if (xConn.is()) + { + // ... and the RO-flag simply is implemented by a property + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xDbProps(xConn->getParent(), ::com::sun::star::uno::UNO_QUERY); + if (xDbProps.is()) + { + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > xInfo = xDbProps->getPropertySetInfo(); + if (xInfo->hasPropertyByName(PROPERTY_ISREADONLY)) + bDBIsReadOnly = ::comphelper::getBOOL(xDbProps->getPropertyValue(PROPERTY_ISREADONLY)); + } + } + } + return bDBIsReadOnly; +} + +//--------------------------------------------------------------------------------------- +void SbaGridControl::MouseButtonDown( const BrowserMouseEvent& rMEvt) +{ + long nRow = GetRowAtYPosPixel(rMEvt.GetPosPixel().Y()); + sal_uInt16 nColPos = GetColumnAtXPosPixel(rMEvt.GetPosPixel().X()); + sal_uInt16 nViewPos = (nColPos == BROWSER_INVALIDID) ? (sal_uInt16)-1 : nColPos-1; + // 'the handle column' and 'no valid column' will both result in a view position of -1 ! + + sal_Bool bHitEmptySpace = (nRow > GetRowCount()) || (nViewPos == (sal_uInt16)-1); + + if (bHitEmptySpace && (rMEvt.GetClicks() == 2) && rMEvt.IsMod1()) + Control::MouseButtonDown(rMEvt); + else + FmGridControl::MouseButtonDown(rMEvt); +} + +//------------------------------------------------------------------------------ +void SbaGridControl::Command(const CommandEvent& rEvt) +{ + sal_Bool bHandled = sal_False; + switch (rEvt.GetCommand()) + { + case COMMAND_STARTDRAG: + // determine if dragging is allowed + // (Yes, this is controller (not view) functionality. But collecting and evaluating all the + // informations necessary via UNO would be quite difficult (if not impossible) so + // my laziness says 'do it here' ...) + long nRow = GetRowAtYPosPixel(rEvt.GetMousePosPixel().Y()); + sal_uInt16 nColPos = GetColumnAtXPosPixel(rEvt.GetMousePosPixel().X()); + sal_uInt16 nViewPos = (nColPos == BROWSER_INVALIDID) ? (sal_uInt16)-1 : nColPos-1; + // 'the handle column' and 'no valid column' will both result in a view position of -1 ! + + sal_Bool bCurrentRowVirtual = IsCurrentAppending() && IsModified(); + // the current row doesn't really exist : the user's appendign a new one and already has entered some data, + // so the row contains data which has no counter part within the data source + + long nCorrectRowCount = GetRowCount(); + if (GetOptions() & OPT_INSERT) + --nCorrectRowCount; // there is a empty row for inserting records + if (bCurrentRowVirtual) + --nCorrectRowCount; + + if ((nColPos == BROWSER_INVALIDID) || (nRow >= nCorrectRowCount)) + break; + + sal_Bool bHitHandle = (nColPos == 0); + + // check which kind of dragging has to be initiated + if ( bHitHandle // the handle column + && ( GetSelectRowCount() // at least one row is selected + || ( (nRow >= 0) // a row below the header + && !bCurrentRowVirtual // we aren't appending a new record + && (nRow != GetCurrentPos()) // a row which is not the current one + ) + ) + ) + { // => start dragging the row + if (GetDataWindow().IsMouseCaptured()) + GetDataWindow().ReleaseMouse(); + + getMouseEvent().Clear(); + DoRowDrag(nRow); + + bHandled = sal_True; + } + else if ( (nRow < 0) // the header + && (!bHitHandle) // non-handle column + && (nViewPos < GetViewColCount()) // valid (existing) column + ) + { // => start dragging the column + if (GetDataWindow().IsMouseCaptured()) + GetDataWindow().ReleaseMouse(); + + getMouseEvent().Clear(); + DoColumnDrag(nViewPos); + + bHandled = sal_True; + } + else if ( !bHitHandle // non-handle column + && (nRow >= 0) // non-header row + ) + { // => start dragging the field content + if (GetDataWindow().IsMouseCaptured()) + GetDataWindow().ReleaseMouse(); + + getMouseEvent().Clear(); + DoFieldDrag(nViewPos, nRow); + + bHandled = sal_True; + } + break; + } + + if (!bHandled) + FmGridControl::Command(rEvt); +} + +// ----------------------------------------------------------------------- +void SbaGridControl::DoColumnDrag(sal_uInt16 nColumnPos) +{ + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xDataSource(getDataSource(), ::com::sun::star::uno::UNO_QUERY); + DBG_ASSERT(xDataSource.is(), "SbaGridControl::DoColumnDrag : invalid data source !"); + // collect some properties from our data source + sal_Int32 nDataType; + XubString sDataSource; + XubString sDBAlias; + try + { + nDataType = ::comphelper::getINT32(xDataSource->getPropertyValue(PROPERTY_COMMANDTYPE)); + sDataSource = (const sal_Unicode*)::comphelper::getString(xDataSource->getPropertyValue(PROPERTY_COMMAND)); + sDBAlias = (const sal_Unicode*)::comphelper::getString(xDataSource->getPropertyValue(::rtl::OUString::createFromAscii("DataSource"))); + } + catch(...) + { + DBG_ERROR("SbaGridControl::DoColumnDrag : could not collect essential data source attributes !"); + return; + } + + +// XubString sDBAlias = EnsureDBLink(m_aDbEnv, GetFormDatabase(xDataSource), sal_True /* allow ui */, sal_True /* really need an alias */ ); +// if (!sDBAlias.Len()) +// // the user did not allow us to create an alias +// return; + + XubString sObjectKind = (nDataType == ::com::sun::star::sdb::CommandType::TABLE) ? XubString('0') : XubString('1'); + + // If the data source is an SQL-statement and simple enough (means "select <field list> from <table> where ....") + // we are able to fake the drag information we are about to create. + sal_Bool bTryToParse = sal_False; + if (nDataType == ::com::sun::star::sdb::CommandType::COMMAND) + { + try + { + bTryToParse = ::comphelper::getBOOL(xDataSource->getPropertyValue(PROPERTY_USE_ESCAPE_PROCESSING)); + } + catch(...) + { + DBG_ERROR("SbaGridControl::DoColumnDrag : could not ask for the escape processing property ! ignoring this ..."); + } + ; + } + if (bTryToParse) + { + try + { + ::rtl::OUString sFilter; + if (::comphelper::getBOOL(xDataSource->getPropertyValue(PROPERTY_APPLYFILTER))) + sFilter = ::comphelper::getString(xDataSource->getPropertyValue(PROPERTY_FILTER)); + ::rtl::OUString sSort = ::comphelper::getString(xDataSource->getPropertyValue(PROPERTY_ORDER)); + + if (m_xComposer.is()) + { + m_xComposer->setQuery(::comphelper::getString(xDataSource->getPropertyValue(PROPERTY_ACTIVECOMMAND))); + m_xComposer->setFilter(sFilter); + m_xComposer->setOrder(sSort); + Reference<XTablesSupplier> xSupTab(m_xComposer,UNO_QUERY); + if(xSupTab.is()) + { + Reference<XNameAccess> xNames = xSupTab->getTables(); + sDataSource = xNames->getElementNames()[0]; + sObjectKind = '0'; // means type 'table' + } + } + } + catch(...) + { + DBG_ERROR("SbaGridControl::DoColumnDrag : could not collect essential data source attributes (part two) !"); + return; + } + } + + XubString aCopyData = sDBAlias; + aCopyData += char(11); + aCopyData += sDataSource; + aCopyData += char(11); + aCopyData += sObjectKind; + aCopyData += char(11); + + XubString sField; + try + { + sal_uInt16 nModelPos = GetModelColumnPos(GetColumnIdFromViewPos(nColumnPos)); + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > xCols(GetPeer()->getColumns(), ::com::sun::star::uno::UNO_QUERY); + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xAffectedCol = *(::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > *)xCols->getByIndex(nModelPos).getValue(); + sField = (const sal_Unicode*)::comphelper::getString(xAffectedCol->getPropertyValue(PROPERTY_CONTROLSOURCE)); + } + catch(...) + { + DBG_ERROR("SbaGridControl::DoColumnDrag : something went wrong while getting the column"); + return; + } + + aCopyData += sField; + + DragServer::Clear(); + if (!DragServer::CopyData(aCopyData.GetBuffer(), aCopyData.Len() + 1, RegisterColumnExchangeFormatName())) + return; + + Pointer aMovePtr(POINTER_MOVEDATA), + aCopyPtr(POINTER_COPYDATA), + aLinkPtr(POINTER_LINKDATA); + ExecuteDrag(aMovePtr, aCopyPtr, aLinkPtr, DRAG_COPYABLE | DRAG_LINKABLE); +} + +// ----------------------------------------------------------------------- +void SbaGridControl::DoRowDrag(sal_uInt16 nRowPos) +{ + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xDataSource(getDataSource(), ::com::sun::star::uno::UNO_QUERY); + DBG_ASSERT(xDataSource.is(), "SbaGridControl::DoRowDrag : invalid data source !"); + // collect some data source properties + sal_Int32 nDataType; + XubString sDataSource; + XubString sDBAlias; + + try + { + nDataType = ::comphelper::getINT32(xDataSource->getPropertyValue(PROPERTY_COMMANDTYPE)); + sDataSource = (const sal_Unicode*)::comphelper::getString(xDataSource->getPropertyValue(PROPERTY_COMMAND)); + sDBAlias = (const sal_Unicode*)::comphelper::getString(xDataSource->getPropertyValue(::rtl::OUString::createFromAscii("DataSource"))); + } + catch(...) + { + DBG_ERROR("SbaGridControl::DoRowDrag : could not collect essential data source attributes !"); + return; + } + + sal_Bool bIsStatement = ::com::sun::star::sdb::CommandType::COMMAND == nDataType; + XubString sObjectKind = (::com::sun::star::sdb::CommandType::TABLE == nDataType) ? XubString('1') : XubString('0'); + +// XubString sDBAlias = EnsureDBLink(m_aDbEnv, GetFormDatabase(xDataSource), sal_True /* allow ui */, sal_True /* really need an alias */ ); +// if (!sDBAlias.Len()) +// // the user did not allow us to create an alias +// return; + + // check if the SQL-statement is modified + sal_Bool bHasFilterOrSort(sal_False); + XubString sCompleteStatement; + try + { + ::rtl::OUString sFilter; + if (::comphelper::getBOOL(xDataSource->getPropertyValue(PROPERTY_APPLYFILTER))) + sFilter = ::comphelper::getString(xDataSource->getPropertyValue(PROPERTY_FILTER)); + ::rtl::OUString sSort = ::comphelper::getString(xDataSource->getPropertyValue(PROPERTY_ORDER)); + bHasFilterOrSort = (sFilter.len()>0) || (sSort.len()>0); + + if (m_xComposer.is()) + { + m_xComposer->setQuery(::comphelper::getString(xDataSource->getPropertyValue(PROPERTY_ACTIVECOMMAND))); + m_xComposer->setFilter(sFilter); + m_xComposer->setOrder(sSort); + sCompleteStatement = (const sal_Unicode*)m_xComposer->getComposedQuery(); + } + else + sCompleteStatement = (const sal_Unicode*)::comphelper::getString(xDataSource->getPropertyValue(PROPERTY_ACTIVECOMMAND)); + } + catch(...) + { + DBG_ERROR("SbaGridControl::DoRowDrag : could not collect essential data source attributes (part two) !"); + return; + } + + + XubString aCopyData = sDBAlias; + aCopyData += char(11); + aCopyData += bIsStatement ? XubString() : sDataSource; + aCopyData += char(11); + aCopyData += sObjectKind; + aCopyData += char(11); + aCopyData += (::com::sun::star::sdb::CommandType::QUERY == nDataType) && !bHasFilterOrSort + ? XubString() + : sCompleteStatement; + // compatibility says : always add the statement, but don't if it is a "pure" query + aCopyData += char(11); + + // collect the affected rows + if ((GetSelectRowCount() == 0) && (nRowPos >= 0)) + { + aCopyData += String::CreateFromInt32(nRowPos + 1); + aCopyData += char(11); + } + else if (!IsAllSelected()) + { + for (long nIdx = FirstSelectedRow(); + nIdx >= 0; + nIdx = NextSelectedRow()) + { + aCopyData += String::CreateFromInt32(nIdx + 1); + aCopyData += char(11); + } + } + + aCopyData.EraseTrailingChars(char(11)); + + Pointer aMovePtr(POINTER_COPYDATA), + aCopyPtr(POINTER_COPYDATA), + aLinkPtr(POINTER_LINKDATA); + + // for the SbaExplorerExchObj we need a SBA-descrition of the data source +// DBObject dbType = (::com::sun::star::sdb::CommandType::TABLE == nDataType) ? dbTable : dbQuery; +// SbaDatabase* pDB = SBA_MOD()->GetDatabase(sDBAlias); +// if (!pDB) +// { +// DBG_ERROR("SbaGridControl::DoRowDrag : could not get an SBA-database !"); +// return; +// } +// +// SbaExplorerExchObjRef xExchange = new SbaExplorerExchObj( pDB, dbType, sDataSource, aCopyData ); +// xExchange->ExecuteDrag( this, aMovePtr, aCopyPtr, aLinkPtr, DRAG_COPYABLE | DRAG_LINKABLE ); + + return; +} + +// ----------------------------------------------------------------------- +void SbaGridControl::DoFieldDrag(sal_uInt16 nColumnPos, sal_uInt16 nRowPos) +{ + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xDataSource(getDataSource(), ::com::sun::star::uno::UNO_QUERY); + DBG_ASSERT(xDataSource.is(), "SbaGridControl::DoFieldDrag : invalid data source !"); + // collect some properties from our data source + sal_Int32 nDataType; + XubString sDataSource; + XubString sDBAlias; + try + { + nDataType = ::comphelper::getINT32(xDataSource->getPropertyValue(PROPERTY_COMMANDTYPE)); + sDataSource = (const sal_Unicode*)::comphelper::getString(xDataSource->getPropertyValue(PROPERTY_COMMAND)); + sDBAlias = (const sal_Unicode*)::comphelper::getString(xDataSource->getPropertyValue(::rtl::OUString::createFromAscii("DataSource"))); + } + catch(...) + { + DBG_ERROR("SbaGridControl::DoFieldDrag : could not collect essential data source attributes !"); + return; + } + + + sal_Bool bIsStatement = ::com::sun::star::sdb::CommandType::COMMAND == nDataType; + XubString sObjectKind = (::com::sun::star::sdb::CommandType::TABLE == nDataType) ? XubString('1') : XubString('0'); + +// XubString sDBAlias = EnsureDBLink(m_aDbEnv, GetFormDatabase(xDataSource), sal_True /* allow ui */, sal_True /* really need an alias */ ); +// if (!sDBAlias.Len()) +// // the user did not allow us to create an alias +// return; + + // build the SBA_FIELDDATAEXCHANGE_FORMAT + XubString aCopyData = sDBAlias; + aCopyData += char(11); + aCopyData += bIsStatement ? XubString() : sDataSource; + aCopyData += char(11); + aCopyData += sObjectKind; + aCopyData += char(11); + + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xAffectedCol; + // append the control source of the column + XubString sField; + try + { + sal_uInt16 nModelPos = GetModelColumnPos(GetColumnIdFromViewPos(nColumnPos)); + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > xCols(GetPeer()->getColumns(), ::com::sun::star::uno::UNO_QUERY); + xAffectedCol = *(::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > *)xCols->getByIndex(nModelPos).getValue(); + sField = (const sal_Unicode*)::comphelper::getString(xAffectedCol->getPropertyValue(PROPERTY_CONTROLSOURCE)); + } + catch(...) + { + DBG_ERROR("SbaGridControl::DoFieldDrag : something went wrong while retrieving the column's control source !"); + return; + } + + aCopyData += sField; + aCopyData += char(11); + + // append the field contents formatted as input string + XubString sInputFormatted; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > xInfo = xAffectedCol->getPropertySetInfo(); + if (xInfo->hasPropertyByName(PROPERTY_FORMATKEY)) // no chance if the column model doesn't know a format key + { + try + { + // the number formatter of the connection + ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > xFormatter = getNumberFormatter(); + DBG_ASSERT(xFormatter.is(), "SbaGridControl::DoFieldDrag : have no number formatter !"); + + // the field the affected col is bound to + ::com::sun::star::uno::Reference< ::com::sun::star::form::XGridFieldDataSupplier > xFieldData((::com::sun::star::form::XGridPeer*)GetPeer(), ::com::sun::star::uno::UNO_QUERY); +#ifdef DBG_UTIL + ::com::sun::star::uno::Sequence<sal_Bool> aSupportingAny = xFieldData->queryFieldDataType(::getCppuType((const ::com::sun::star::uno::Any*)0)); + DBG_ASSERT(aSupportingAny.getConstArray()[nColumnPos], + "SbaGridControl::DoFieldDrag : the GridFieldDataSupplier should supply UsrAnys !"); +#endif + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any> aCellContents = xFieldData->queryFieldData(nRowPos, ::getCppuType((const ::com::sun::star::uno::Any*)0)); + ::com::sun::star::uno::Any aFieldValue = aCellContents.getConstArray()[nColumnPos]; + + // the format key of the column (we don't use the one supplied by the bound field because it may be out-of-date : + // modifying a column format is propagated only to the column's model, not to the database field) + sal_Int32 nKey = ::comphelper::getINT32(xAffectedCol->getPropertyValue(PROPERTY_FORMATKEY)); + + // check if the key indicates a text format + sal_Int16 nType = ::com::sun::star::util::NumberFormat::UNDEFINED; + ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats > xFormats = xFormatter->getNumberFormatsSupplier()->getNumberFormats(); + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xFormat = xFormats->getByKey(nKey); + if (xFormat.is()) + { + try { nType = ::comphelper::getINT16(xFormat->getPropertyValue(PROPERTY_TYPE)); } catch(...) { } ; + } + + // if it is a text format we can ask for the string + if ((nType & ~::com::sun::star::util::NumberFormat::DEFINED) == ::com::sun::star::util::NumberFormat::TEXT) // mask the 'user defined' flag + sInputFormatted = Any2String(aFieldValue); + else + { // else we have to make one distinction more : a currency field always needs an output string + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xFieldSet; + ::cppu::extractInterface(xFieldSet, xAffectedCol->getPropertyValue(PROPERTY_BOUNDFIELD)); + if (xFieldSet.is()) + { + sal_Int32 nFieldType = ::comphelper::getINT32(xFieldSet->getPropertyValue(PROPERTY_TYPE)); + if (::comphelper::getBOOL(xFieldSet->getPropertyValue(::rtl::OUString::createFromAscii("IsCurrency")))) + sInputFormatted = (const sal_Unicode*)xFormatter->convertNumberToString(nKey, Any2Double(aFieldValue)); + else + sInputFormatted = (const sal_Unicode*)xFormatter->getInputString(nKey, Any2Double(aFieldValue)); + } + else + sInputFormatted.Erase(); + } + } + catch(...) + { + DBG_ERROR("SbaGridControl::DoFieldDrag : could not retrieve the cell's input string !"); + return; + } + + } + aCopyData += sInputFormatted; + + // feed the drag server with the format just built + DragServer::Clear(); + if (!DragServer::CopyData(aCopyData.GetBuffer(), aCopyData.Len() + 1, RegisterFieldExchangeFormatName())) + return; + + // and supply - as an additional pure-text format - the cell contents + try + { + ::com::sun::star::uno::Reference< ::com::sun::star::form::XGridFieldDataSupplier > xFieldData((::com::sun::star::form::XGridPeer*)GetPeer(), ::com::sun::star::uno::UNO_QUERY); + ::com::sun::star::uno::Sequence<sal_Bool> aSupportingText = xFieldData->queryFieldDataType(::getCppuType((const ::rtl::OUString*)0)); + if (aSupportingText.getConstArray()[nColumnPos]) + { + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any> aCellContents = xFieldData->queryFieldData(nRowPos, ::getCppuType((const ::rtl::OUString*)0)); + ::rtl::OUString aText = ::comphelper::getString(aCellContents.getConstArray()[nColumnPos]); + DragServer::CopyString(aText); + } + } + catch(...) + { + DBG_ERROR("SbaGridControl::DoFieldDrag : could not retrieve the cell's contents !"); + return; + } + + + + Pointer aMovePtr(POINTER_MOVEDATA), + aCopyPtr(POINTER_COPYDATA), + aLinkPtr(POINTER_LINKDATA); + ExecuteDrag(aMovePtr, aCopyPtr, aLinkPtr, DRAG_COPYABLE); +} + +//------------------------------------------------------------------------------ +sal_Bool SbaGridControl::QueryDrop(const BrowserDropEvent& rEvt) +{ + // we need a valid connection + if (!::dbtools::getConnection(::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > (getDataSource(),::com::sun::star::uno::UNO_QUERY)).is()) + return sal_False; + + sal_Bool bAllow = sal_False; + + // check formats + SvDataObjectRef xDataObj = SvDataObject::PasteDragServer( rEvt ); + if (!xDataObj.Is()) + return sal_False; + + const SvDataTypeList& rTypeList = xDataObj->GetTypeList(); + if ((rTypeList.Get(Exchange::RegisterFormatName(String::CreateFromAscii(SBA_VCARDEXCHANGE_FORMAT)))) || + (rTypeList.Get(Exchange::RegisterFormatName(String::CreateFromAscii(SBA_DATAEXCHANGE_FORMAT)))) ) + { + bAllow = (GetOptions() & OPT_INSERT) && rEvt.GetColumnId() > 0 && rEvt.GetRow() >= 0; + ((BrowserDropEvent&)rEvt).SetAction(DROP_COPY); + } + + if (rTypeList.Get(FORMAT_STRING)) do + { // odd construction, but spares us a lot of (explicit ;) goto's + + if (!GetEmptyRow().Is()) + // without an empty row we're not in update mode + break; + + long nRow = GetRowAtYPosPixel(rEvt.GetPosPixel().Y(), sal_False); + sal_uInt16 nCol = GetColumnAtXPosPixel(rEvt.GetPosPixel().X(), sal_False); + + long nCorrectRowCount = GetRowCount(); + if (GetOptions() & OPT_INSERT) + --nCorrectRowCount; // there is a empty row for inserting records + if (IsCurrentAppending()) + --nCorrectRowCount; // the current data record doesn't really exist, we are appending a new one + + if ((nCol == BROWSER_INVALIDID) || (nRow >= nCorrectRowCount)) + // no valid cell under the mouse cursor + break; + + // from now we work with ids instead of positions + nCol = GetColumnId(nCol); + + Rectangle aRect = GetCellRect(nRow, nCol, sal_False); + if (!aRect.IsInside(rEvt.GetPosPixel())) + // not dropped within a cell (a cell isn't as wide as the column - the are small spaces) + break; + + if ((IsModified() || (GetCurrentRow().Is() && GetCurrentRow()->IsModified())) && (GetCurrentPos() != nRow)) + // there is a current and modified row or cell and he text is to be dropped into another one + break; + + DbCellControllerRef xCurrentController = Controller(); + if (xCurrentController.Is() && xCurrentController->IsModified() && ((nRow != GetCurRow()) || (nCol != GetCurColumnId()))) + // the current controller is modified and the user wants to drop in another cell -> no chance + // (when leaving the modified cell a error may occur - this is deadly while dragging) + break; + + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xField = getField(GetModelColumnPos(nCol)); + if (!xField.is()) + // the column is not valid bound (for instance a binary field) + break; + + try + { + if (::comphelper::getBOOL(xField->getPropertyValue(PROPERTY_ISREADONLY))) + break; + } + catch(...) + { + // assume RO + break; + } + + + // assume that text can be dropped into a field if the column has a ::com::sun::star::awt::XTextComponent interface + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > xColumnControls((::com::sun::star::form::XGridPeer*)GetPeer(), ::com::sun::star::uno::UNO_QUERY); + if (!xColumnControls.is()) + break; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent > xColControl(*(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > *)xColumnControls->getByIndex(GetViewColumnPos(nCol)).getValue(), ::com::sun::star::uno::UNO_QUERY); + if (!xColControl.is()) + break; + + m_bActivatingForDrop = sal_True; + GoToRowColumnId(nRow, nCol); + m_bActivatingForDrop = sal_False; + + bAllow = sal_True; + + ((BrowserDropEvent&)rEvt).SetAction(DROP_COPY); + // see below. as we don't have a m_bDraggingOwnText we have to be more restrictive. text can't be moved into a grid control. + + } while (sal_False); + + return (bAllow) ? bAllow : FmGridControl::QueryDrop(rEvt); +} + +//------------------------------------------------------------------------------ +sal_Bool SbaGridControl::Drop(const BrowserDropEvent& rEvt) +{ + // we need some properties of our data source + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xDataSource = getDataSource(); + if (!xDataSource.is()) + return sal_False; + + // we need a valid connection + if (!::dbtools::getConnection(::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > (xDataSource,::com::sun::star::uno::UNO_QUERY)).is()) + return sal_False; + + ////////////////////////////////////////////////////////////////////// + // DataExch-XubString holen + SotDataObjectRef xDataObj = ((DropEvent&)rEvt).GetData(); + const SvDataTypeList& rTypeList = xDataObj->GetTypeList(); + + if (rTypeList.Get(FORMAT_STRING)) + { + long nRow = GetRowAtYPosPixel(rEvt.GetPosPixel().Y(), sal_False); + sal_uInt16 nCol = GetColumnAtXPosPixel(rEvt.GetPosPixel().X(), sal_False); + + long nCorrectRowCount = GetRowCount(); + if (GetOptions() & OPT_INSERT) + --nCorrectRowCount; // there is a empty row for inserting records + if (IsCurrentAppending()) + --nCorrectRowCount; // the current data record doesn't really exist, we are appending a new one + + DBG_ASSERT((nCol != BROWSER_INVALIDID) && (nRow < nCorrectRowCount), "SbaGridControl::Drop : dropped on an invalid position !"); + // QueryDrop should have catched this + + // from now we work with ids instead of positions + nCol = GetColumnId(nCol); + + GoToRowColumnId(nRow, nCol); + if (!IsEditing()) + ActivateCell(); + + DbCellControllerRef xCurrentController = Controller(); + if (!xCurrentController.Is() || !xCurrentController->ISA(DbEditCellController)) + return sal_False; + Edit& rEdit = (Edit&)xCurrentController->GetWindow(); + + // Daten aus + SvData aData(FORMAT_STRING); + if (!xDataObj->GetData(&aData)) + return sal_False; + + XubString sDropped; + aData.GetData(sDropped); + rEdit.SetText(sDropped); + xCurrentController->SetModified(); + rEdit.Modify(); + // SetText itself doesn't call a Modify as it isn't a user interaction + + return sal_True; + } + + // the last known format + sal_uInt32 nSbaDataExchangeFormat = Exchange::RegisterFormatName(String::CreateFromAscii(SBA_DATAEXCHANGE_FORMAT)); + if( !rTypeList.Get(nSbaDataExchangeFormat) ) + return sal_False; + + SvData aData(nSbaDataExchangeFormat); + xDataObj->GetData(&aData); + XubString sDataExchStr; + if (!aData.GetData(sDataExchStr)) + return sal_False; + + if (!sDataExchStr.Len()) + return sal_False; + + // Formerly we just casted the xDataObj-ptr to SbaExplorerExchObj*. Unfortunally this isn't + // valid anymore (it also seems to be very bad style to me) + // Now xDataObj is an SfxExchangeObject, so we have to try other approches .... + // FS - 69292 - 20.10.99 + +// SbaExplorerExchObj* pDataExchObj = NULL; +// // so first we try our new internal format which we created for this situation +// SvData aExplorerExchangeTransfer(Exchange::RegisterFormatName(String::CreateFromAscii(SBA_DATATYPE_INTERNAL_EXPLOREREXCHANGE))); +// if (xDataObj->GetData(&aExplorerExchangeTransfer)) +// { +// DBG_ASSERT(aExplorerExchangeTransfer.GetMemorySize() == sizeof(pDataExchObj), "SbaGridControl::Drop : somebody gave me invalida data !"); +// void* pDestination = &pDataExchObj; +// aExplorerExchangeTransfer.GetData(&pDestination); +// } +// +// // next try for a SfxExchangeObject +// // (this is already somewhat dirty : we need a hard cast below ...) +// if (!pDataExchObj) +// { +// SfxExchangeObjectRef aSfxExchange = SfxExchangeObject::PasteDragServer((DropEvent&)rEvt); +// if (&aSfxExchange == &xDataObj) +// { +// // loop through all objects +// for (sal_uInt32 i=0; i<aSfxExchange->Count(); ++i) +// { +// if (aSfxExchange->GetObject(i)->HasFormat(SvDataType(nSbaDataExchangeFormat))) +// { +// pDataExchObj = (SbaExplorerExchObj*)aSfxExchange->GetObject(i); +// break; +// } +// } +// DBG_ASSERT(pDataExchObj, "SbaGridControl::Drop : invalid SfxExchangeObject !?"); +// // if the SfxExchangeObject itself has the format, at least one of it children should, too +// } +// } +// +// // last : the (real dirty :) old behaviuor : a hard cast +// if (!pDataExchObj) +// pDataExchObj = (SbaExplorerExchObj*)&xDataObj; +// +// // first we need to translate the ::com::sun::star::form::DataSelectionType into a DBObject +// sal_Int32 nDataType; +// try +// { +// nDataType = ::comphelper::getINT32(xDataSource->getPropertyValue(PROPERTY_COMMANDTYPE)); +// } +// catch(...) +// { +// DBG_ERROR("SbaGridControl::Drop : could not collect essential data source attributes !"); +// return sal_False; +// } + + +// if (pDataExchObj->QueryInsertObject(eObj)) +// { +// if (pDataExchObj->GetData(getDataSource())) +// refresh(); +// // if the GetData would work with our own cursor, not with a newly created one, UpdateDataSource(sal_True) would be +// // suffient (me thinks) +// return sal_True; +// } + return sal_False; +} + +//------------------------------------------------------------------------------ +void SbaGridControl::refresh() +{ + // aktualisieren + ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadable > xLoadable(getDataSource(), ::com::sun::star::uno::UNO_QUERY); + DBG_ASSERT(xLoadable.is(), "SbaGridControl::Drop : invalid data source !"); + if (xLoadable.is()) + { + WaitObject aWO(this); + xLoadable->reload(); + } +} + +//------------------------------------------------------------------------------ +::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SbaGridControl::getDataSource() const +{ + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xReturn; + + ::com::sun::star::uno::Reference< ::com::sun::star::container::XChild > xColumns(GetPeer()->getColumns(), ::com::sun::star::uno::UNO_QUERY); + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xDataSource; + if (xColumns.is()) + xReturn = ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > (xColumns->getParent(), ::com::sun::star::uno::UNO_QUERY); + + return xReturn; +} + + + +//------------------------------------------------------------------------------ +::com::sun::star::awt::FontDescriptor BuildFontFromItems(const SfxItemSet* pAttr, const Font& rBase) +{ + Font aReturn(rBase); + +// const SfxPoolItem* pAnyItem; +// +// pAnyItem = &pAttr->Get( SBA_DEF_FONT ); +// const SvxFontItem* pFontItem = (SvxFontItem*)pAnyItem; +// +// pAnyItem = &pAttr->Get( SBA_DEF_FONTWEIGHT ); +// const SvxWeightItem* pWeightItem = (SvxWeightItem*)pAnyItem; +// +// pAnyItem = &pAttr->Get( SBA_DEF_FONTHEIGHT ); +// const SvxFontHeightItem* pFontHeightItem = (SvxFontHeightItem*)pAnyItem; +// +// pAnyItem = &pAttr->Get( SBA_DEF_POSTURE ); +// const SvxPostureItem* pFontItalicItem = (SvxPostureItem*)pAnyItem; +// +// pAnyItem = &pAttr->Get( SBA_DEF_SHADOWED ); +// const SvxShadowedItem* pFontShadowItem = (SvxShadowedItem*)pAnyItem; +// +// pAnyItem = &pAttr->Get( SBA_DEF_CONTOUR ); +// const SvxContourItem* pFontContourItem = (SvxContourItem*)pAnyItem; +// +// pAnyItem = &pAttr->Get( SBA_DEF_UNDERLINE ); +// const SvxUnderlineItem* pFontUnderlineItem = (SvxUnderlineItem*)pAnyItem; +// +// pAnyItem = &pAttr->Get( SBA_DEF_CROSSEDOUT ); +// const SvxCrossedOutItem* pFontCrossedOutItem = (SvxCrossedOutItem*)pAnyItem; +// +// // build the returned font +// aReturn.SetFamily( pFontItem->GetFamily() ); +// aReturn.SetName( pFontItem->GetFamilyName() ); +// aReturn.SetStyleName( pFontItem->GetStyleName() ); +// aReturn.SetCharSet( pFontItem->GetCharSet() ); +// +// aReturn.SetWeight( pWeightItem->GetWeight() ); +// aReturn.SetItalic( pFontItalicItem->GetPosture() ); +// aReturn.SetUnderline( pFontUnderlineItem->GetUnderline() ); +// +// aReturn.SetShadow( pFontShadowItem->GetValue() ); +// aReturn.SetOutline( pFontContourItem->GetValue() ); +// aReturn.SetStrikeout( pFontCrossedOutItem->GetStrikeout() ); +// +// sal_uInt32 nHeight = pFontHeightItem->GetHeight(); +// +// Size aSize(Size(0, nHeight)); +// aSize = OutputDevice::LogicToLogic(aSize, MAP_TWIP, MAP_POINT); +// aReturn.SetSize(aSize); +// +// // now create a font descriptor + ::com::sun::star::awt::FontDescriptor aRealReturn; +// aRealReturn.Name = aReturn.GetName(); +// aRealReturn.StyleName = aReturn.GetStyleName(); +// aRealReturn.Height = aReturn.GetSize().Height(); +// aRealReturn.Width = aReturn.GetSize().Width(); +// aRealReturn.Family = aReturn.GetFamily(); +// aRealReturn.CharSet = aReturn.GetCharSet(); +// aRealReturn.Pitch = aReturn.GetPitch(); +// aRealReturn.CharacterWidth = VCLUnoHelper::ConvertFontWidth(aReturn.GetWidthType()); +// aRealReturn.Weight= VCLUnoHelper::ConvertFontWeight(aReturn.GetWeight()); +// aRealReturn.Slant = (::com::sun::star::awt::FontSlant)aReturn.GetItalic(); +// aRealReturn.Underline = aReturn.GetUnderline(); +// aRealReturn.Strikeout = aReturn.GetStrikeout(); +// aRealReturn.Orientation = aReturn.GetOrientation(); +// aRealReturn.Kerning = aReturn.IsKerning(); +// aRealReturn.WordLineMode = aReturn.IsWordLineMode(); +// aRealReturn.Type = 0; + return aRealReturn; +} + +//------------------------------------------------------------------------------ +void BuildItemsFromFont(SfxItemSet* pAttr, const ::com::sun::star::awt::FontDescriptor& rFont) +{ + // the following items are not aupported by the FontDescriptor structure +// pAttr->Put(SvxContourItem(rFont.IsOutline(), SBA_DEF_CONTOUR)); +// pAttr->Put(SvxShadowedItem(rFont.IsShadow(), SBA_DEF_SHADOWED)); + +// pAttr->Put(SvxWeightItem(VCLUnoHelper::ConvertFontWeight(rFont.Weight), SBA_DEF_FONTWEIGHT)); +// pAttr->Put(SvxPostureItem((FontItalic)rFont.Slant, SBA_DEF_POSTURE)); +// pAttr->Put(SvxUnderlineItem((FontUnderline)rFont.Underline, SBA_DEF_UNDERLINE)); +// pAttr->Put(SvxCrossedOutItem((FontStrikeout)rFont.Strikeout, SBA_DEF_CROSSEDOUT)); +// +// Size aSize(0, rFont.Height); +// aSize = OutputDevice::LogicToLogic(aSize, MAP_POINT, MAP_TWIP); +// pAttr->Put(SvxFontHeightItem(aSize.Height(), 100, SBA_DEF_FONTHEIGHT)); +// +// pAttr->Put(SvxFontItem((FontFamily)rFont.Family, rFont.Name, rFont.StyleName, +// PITCH_DONTKNOW, (CharSet)rFont.CharSet, SBA_DEF_FONT)); +} +// ------------------------------------------------------------------------- + + + + diff --git a/dbaccess/source/ui/browser/sbagrid.src b/dbaccess/source/ui/browser/sbagrid.src new file mode 100644 index 000000000..b47632777 --- /dev/null +++ b/dbaccess/source/ui/browser/sbagrid.src @@ -0,0 +1,290 @@ +/************************************************************************* + * + * $RCSfile: sbagrid.src,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2000-10-26 14:42:03 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _DBU_RESOURCE_HRC_ +#include "dbu_resource.hrc" +#endif +#ifndef DBACCESS_UI_BROWSER_ID_HXX +#include "browserids.hxx" +#endif +#include <svx/globlmn.hrc> + +Menu RID_SBA_GRID_COLCTXMENU +{ + ItemList = + { + MenuItem + { + Identifier = ID_BROWSER_COLATTRSET ; + HelpID = ID_BROWSER_COLATTRSET ; + Text = "Spalten~formatierung..." ; + Text [ ENGLISH ] = "Column ~format..." ; + Text [ norwegian ] = "Kolonne format..." ; + Text [ italian ] = "Formattazione ~colonna..." ; + Text [ portuguese_brazilian ] = "Formatar coluna..." ; + Text [ portuguese ] = "~Formatar colunas..." ; + Text [ finnish ] = "Sarakkeen muoto..." ; + Text [ danish ] = "Kolonneformatering..." ; + Text [ french ] = "Formatage de colonne..." ; + Text [ swedish ] = "Kolumnformatering..." ; + Text [ dutch ] = "~Kolomopmaak..." ; + Text [ spanish ] = "Formateado de ~columnas..." ; + Text [ english_us ] = "Column Format..." ; + Text[ chinese_simplified ] = "Áиñʽ..."; + Text[ russian ] = "Ôîðìàò êîëîíîê..."; + Text[ polish ] = "Formatowanie kolumn..."; + Text[ japanese ] = "—ñ‚Ì‘Ž®..."; + Text[ chinese_traditional ] = "Äæ®æ¦¡..."; + Text[ arabic ] = "ÊäÓíÞ ÇáÃÚãÏÉ..."; + Text[ greek ] = "Ìïñ~öïðïßçóç óôÞëçò..."; + Text[ korean ] = "¿ ¼½Ä..."; + Text[ turkish ] = "Sütun formatý..."; + }; + MenuItem + { + Identifier = ID_BROWSER_COLWIDTH ; + HelpID = ID_BROWSER_COLWIDTH ; + Text = "Spalten~breite..." ; + Text [ ENGLISH ] = "Column ~width..." ; + Text [ finnish ] = "Sarakkeen leveyden..." ; + Text [ danish ] = "Kolonnebredde..." ; + Text [ french ] = "Largeur de colonne..." ; + Text [ swedish ] = "Kolumnbredd..." ; + Text [ dutch ] = "K~olombreedte..." ; + Text [ spanish ] = "Anc~ho de columna..." ; + Text [ english_us ] = "Column Width..." ; + Text [ italian ] = "~Larghezza colonna..." ; + Text [ portuguese_brazilian ] = "Spaltenbreite..." ; + Text [ portuguese ] = "~Largura de coluna..." ; + Text[ chinese_simplified ] = "Áпí..."; + Text[ russian ] = "Øèðèíà êîëîíîê..."; + Text[ polish ] = "Szerokoœæ kolumn..."; + Text[ japanese ] = "—ñ•..."; + Text[ chinese_traditional ] = "Äæ¼e..."; + Text[ arabic ] = "ÚÑÖ ÇáÃÚãÏÉ..."; + Text[ greek ] = "~ÐëÜôïò óôÞëçò..."; + Text[ korean ] = "¿ ³Êºñ..."; + Text[ turkish ] = "Sütun geniþliði..."; + }; + }; +}; + +Menu RID_SBA_GRID_ROWCTXMENU +{ + ItemList = + { + MenuItem + { + Identifier = ID_BROWSER_TABLEATTR ; + HelpID = ID_BROWSER_TABLEATTR ; + Text = "Tabellenformatierung..." ; + Text [ ENGLISH ] = "Table format..." ; + Text [ dutch ] = "Tabelopmaak..." ; + Text [ english_us ] = "Table Format..." ; + Text [ italian ] = "Formattazione tabella..." ; + Text [ spanish ] = "Formateado de tabla..." ; + Text [ french ] = "Formatage de table..." ; + Text [ swedish ] = "Tabellformatering..." ; + Text [ danish ] = "Tabelformatering..." ; + Text [ portuguese_brazilian ] = "Tabellenformatierung..." ; + Text [ portuguese ] = "Formatar tabelas..." ; + Text[ chinese_simplified ] = "±í¸ñ¸ñʽ..."; + Text[ russian ] = "Ôîðìàò òàáëèöû..."; + Text[ polish ] = "Formatowanie tabeli..."; + Text[ japanese ] = "ðÌÞÙ‚Ì‘Ž®..."; + Text[ chinese_traditional ] = "¤u§@ªí®æ¦¡..."; + Text[ arabic ] = "ÊäÓíÞ ÇáÃÚãÏÉ..."; + Text[ greek ] = "Ìïñöïðïßçóç ðßíáêá..."; + Text[ korean ] = "Å×ÀÌºí ¼½Ä..."; + Text[ turkish ] = "Tablo formatý..."; + }; + MenuItem + { + Identifier = ID_BROWSER_ROWHEIGHT ; + HelpID = ID_BROWSER_ROWHEIGHT ; + Text = "Zeilenhöhe..." ; + Text [ ENGLISH ] = "Row height..." ; + Text [ norwegian ] = "Radhøyde..." ; + Text [ italian ] = "Altezza riga..." ; + Text [ portuguese_brazilian ] = "Altura da fileira..." ; + Text [ portuguese ] = "Altura da linha..." ; + Text [ finnish ] = "Rivin korkeus..." ; + Text [ danish ] = "Rækkehøjde..." ; + Text [ french ] = "Hauteur de ligne..." ; + Text [ swedish ] = "Radhöjd..." ; + Text [ dutch ] = "Rijhoogte..." ; + Text [ spanish ] = "Altura de fila..." ; + Text [ english_us ] = "Row Height..." ; + Text[ chinese_simplified ] = "Ðиß..."; + Text[ russian ] = "Âûñîòà ñòðîê..."; + Text[ polish ] = "Wysokoœæ wierszy..."; + Text[ japanese ] = "s‚Ì‚‚³..."; + Text[ chinese_traditional ] = "¦C°ª..."; + Text[ arabic ] = "ÇÑÊÝÇÚ ÇáÕÝæÝ..."; + Text[ greek ] = "¾øïò ãñáììÞò..."; + Text[ korean ] = "Çà ³ôÀÌ..."; + Text[ turkish ] = "Satýr yüksekliði..."; + }; + }; +}; + +String RID_STR_UNDO_MODIFY_RECORD +{ + Text = "Rückgängig: Dateneingabe" ; + Text [ ENGLISH ] = "Undo: input data"; + Text [ english_us ] = "Undo: Data input"; + Text[ portuguese ] = "Anular: entrada de dados"; + Text[ russian ] = "Îòìåíèòü: ââîä äàííûõ"; + Text[ greek ] = "Áíáßñåóç: ÅéóáãùãÞ äåäïìÝíùí"; + Text[ dutch ] = "Ongedaan maken: gegevens invoeren"; + Text[ french ] = "Annuler : saisie des données"; + Text[ spanish ] = "Deshacer: Entrada de datos"; + Text[ italian ] = "Annulla: Immissione dati"; + Text[ danish ] = "Fortryd: Datainput"; + Text[ swedish ] = "Ångra: Datainmatning"; + Text[ polish ] = "Cofniêcie: Wpisywanie danych"; + Text[ portuguese_brazilian ] = "Undo: input data"; + Text[ japanese ] = "Œ³‚É–ß‚·: ÃÞ°À“ü—Í"; + Text[ korean ] = "½ÇÇàÃë¼Ò: µ¥ÀÌÅÍ ÀÔ·Â"; + Text[ chinese_simplified ] = "³·ÏúÃüÁÊäÈëÊý¾Ý"; + Text[ chinese_traditional ] = "´_ì¡G¼ÆÕu¿é¤J"; + Text[ arabic ] = "ÊÑÇÌÚ: ÅÏÎÇá ÈíÇäÇÊ"; + Text[ turkish ] = "Geri al: Veri giriþi"; +}; + +String RID_STR_SAVE_CURRENT_RECORD +{ + Text = "aktuellen Datensatz speichern" ; + Text [ ENGLISH ] = "aktuellen Datensatz speichern" ; + Text[ english_us ] = "Save current record"; + Text[ portuguese ] = "Guardar registo de dados activo"; + Text[ russian ] = "Ñîõðàíèòü òåêóùóþ çàïèñü"; + Text[ dutch ] = "actuele record opslaan"; + Text[ french ] = "enregistrer l'enregistrement actif"; + Text[ spanish ] = "guardar registro actual"; + Text[ italian ] = "Salva record di dati attuale"; + Text[ danish ] = "Gem aktuel datapost"; + Text[ swedish ] = "spara aktuell datapost"; + Text[ polish ] = "Zapisz bie¿¹cy rekord"; + Text[ portuguese_brazilian ] = "aktuellen Datensatz speichern"; + Text[ japanese ] = "Œ»Ý‚ÌÚº°ÄÞ‚Ì•Û‘¶"; + Text[ chinese_simplified ] = "´æÅ̵±Ç°µÄÊý¾ÝÌõÄ¿"; + Text[ chinese_traditional ] = "«O¦s·í«eªº¸ê®Æ±ø¥Ø"; + Text[ arabic ] = "ÍÝÙ ÇáÓÌá ÇáÍÇáí"; + Text[ dutch ] = "actuele record opslaan"; + Text[ chinese_simplified ] = "´æÅ̵±Ç°µÄÊý¾ÝÌõÄ¿"; + Text[ greek ] = "ÁðïèÞêåõóç ôñÝ÷ïõóáò åããñáöÞò äåäïìÝíùí"; + Text[ korean ] = "ÇöÀç ·¹ÄÚµå ÀúÀå"; + Text[ turkish ] = "Yürürlükteki verileri kaydet"; +}; + +String STR_QRY_TITLE +{ + Text = "Abfrage #" ; + Text [ ENGLISH ] = "Query #" ; + Text [ english_us ] = "Query #" ; + Text [ portuguese ] = "Consulta #" ; + Text [ portuguese_brazilian ] = "Abfrage #" ; + Text [ swedish ] = "Sökning #" ; + Text [ danish ] = "Forespørgsel #" ; + Text [ italian ] = "Ricerca #" ; + Text [ spanish ] = "Consulta #" ; + Text [ french ] = "Requête #" ; + Text [ dutch ] = "Query #" ; + Text[ chinese_simplified ] = "²éѯ #"; + Text[ russian ] = "Çàïðîñ #"; + Text[ polish ] = "Kwerenda #"; + Text[ japanese ] = "¸´Ø° #"; + Text[ dutch ] = "Query #"; + Text[ chinese_simplified ] = "²éѯ #"; + Text[ greek ] = "Åñþôçìá #"; + Text[ korean ] = "ÁúÀÇ #"; + Text[ chinese_traditional ] = "¬d¸ß #"; + Text[ arabic ] = "ÇáÇÓÊÝÓÇÑ #"; + Text[ turkish ] = "Sorgu #"; + Text[ language_user1 ] = " "; +}; +String STR_TBL_TITLE +{ + Text = "Tabelle #" ; + Text [ ENGLISH ] = "Table #" ; + Text [ english_us ] = "Table #" ; + Text [ portuguese ] = "Tabela #" ; + Text [ portuguese_brazilian ] = "Tabelle #" ; + Text [ swedish ] = "Tabell #" ; + Text [ danish ] = "Tabel #" ; + Text [ italian ] = "Tabella #" ; + Text [ spanish ] = "Tabla #" ; + Text [ french ] = "Table #" ; + Text [ dutch ] = "Tabel #" ; + Text[ chinese_simplified ] = "±í¸ñ #"; + Text[ russian ] = "Òàáëèöà #"; + Text[ polish ] = "Tabela #"; + Text[ japanese ] = "ðÌÞÙ #"; + Text[ dutch ] = "Tabel #"; + Text[ chinese_simplified ] = "±í¸ñ #"; + Text[ greek ] = "Ðßíáêáò #"; + Text[ korean ] = "Å×À̺í #"; + Text[ chinese_traditional ] = "ªí®æ #"; + Text[ arabic ] = "ÌÏæá #"; + Text[ turkish ] = "Tablo #"; + Text[ language_user1 ] = " "; +}; + diff --git a/dbaccess/source/ui/browser/sbamultiplex.cxx b/dbaccess/source/ui/browser/sbamultiplex.cxx new file mode 100644 index 000000000..2b671d0ec --- /dev/null +++ b/dbaccess/source/ui/browser/sbamultiplex.cxx @@ -0,0 +1,168 @@ +/************************************************************************* + * + * $RCSfile: sbamultiplex.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2000-10-26 14:44:13 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SBA_MULTIPLEX_HXX +#include "sbamultiplex.hxx" +#endif +using namespace dbaui; + +//================================================================== +// the listener multiplexers +//================================================================== + +// XStatusListener +IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXStatusMultiplexer, ::com::sun::star::frame::XStatusListener) +IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXStatusMultiplexer, ::com::sun::star::frame::XStatusListener, statusChanged, ::com::sun::star::frame::FeatureStateEvent) + +// LoadListener +IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXLoadMultiplexer, ::com::sun::star::form::XLoadListener) +IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXLoadMultiplexer, ::com::sun::star::form::XLoadListener, loaded, ::com::sun::star::lang::EventObject) +IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXLoadMultiplexer, ::com::sun::star::form::XLoadListener, unloaded, ::com::sun::star::lang::EventObject) +IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXLoadMultiplexer, ::com::sun::star::form::XLoadListener, unloading, ::com::sun::star::lang::EventObject) +IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXLoadMultiplexer, ::com::sun::star::form::XLoadListener, reloading, ::com::sun::star::lang::EventObject) +IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXLoadMultiplexer, ::com::sun::star::form::XLoadListener, reloaded, ::com::sun::star::lang::EventObject) + +// ::com::sun::star::sdbc::XRowSetListener +IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXRowSetMultiplexer, ::com::sun::star::sdbc::XRowSetListener) +IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXRowSetMultiplexer, ::com::sun::star::sdbc::XRowSetListener, cursorMoved, ::com::sun::star::lang::EventObject) +IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXRowSetMultiplexer, ::com::sun::star::sdbc::XRowSetListener, rowChanged, ::com::sun::star::lang::EventObject) +IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXRowSetMultiplexer, ::com::sun::star::sdbc::XRowSetListener, rowSetChanged, ::com::sun::star::lang::EventObject) + +// ::com::sun::star::sdb::XRowSetApproveListener +IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXRowSetApproveMultiplexer, ::com::sun::star::sdb::XRowSetApproveListener) +IMPLEMENT_LISTENER_MULTIPLEXER_BOOL_METHOD(SbaXRowSetApproveMultiplexer, ::com::sun::star::sdb::XRowSetApproveListener, approveCursorMove, ::com::sun::star::lang::EventObject) +IMPLEMENT_LISTENER_MULTIPLEXER_BOOL_METHOD(SbaXRowSetApproveMultiplexer, ::com::sun::star::sdb::XRowSetApproveListener, approveRowChange, ::com::sun::star::sdb::RowChangeEvent) +IMPLEMENT_LISTENER_MULTIPLEXER_BOOL_METHOD(SbaXRowSetApproveMultiplexer, ::com::sun::star::sdb::XRowSetApproveListener, approveRowSetChange, ::com::sun::star::lang::EventObject) + +// ::com::sun::star::sdb::XSQLErrorListener +IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXSQLErrorMultiplexer, ::com::sun::star::sdb::XSQLErrorListener) +IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXSQLErrorMultiplexer, ::com::sun::star::sdb::XSQLErrorListener, errorOccured, ::com::sun::star::sdb::SQLErrorEvent) + +// ::com::sun::star::form::XPositioningListener +IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXPositioningMultiplexer, ::com::sun::star::form::XPositioningListener) +IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXPositioningMultiplexer, ::com::sun::star::form::XPositioningListener, positioned, ::com::sun::star::lang::EventObject) + +// ::com::sun::star::form::XInsertListener +IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXInsertMultiplexer, ::com::sun::star::form::XInsertListener) +IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXInsertMultiplexer, ::com::sun::star::form::XInsertListener, inserting, ::com::sun::star::lang::EventObject) +IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXInsertMultiplexer, ::com::sun::star::form::XInsertListener, inserted, ::com::sun::star::lang::EventObject) + +// ::com::sun::star::form::XRestoreListener +IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXRestoreMultiplexer, ::com::sun::star::form::XRestoreListener) +IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXRestoreMultiplexer, ::com::sun::star::form::XRestoreListener, restored, ::com::sun::star::lang::EventObject) + +// ::com::sun::star::form::XDeleteListener +IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXDeleteMultiplexer, ::com::sun::star::form::XDeleteListener) +IMPLEMENT_LISTENER_MULTIPLEXER_BOOL_METHOD(SbaXDeleteMultiplexer, ::com::sun::star::form::XDeleteListener, approveDelete, ::com::sun::star::lang::EventObject) +IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXDeleteMultiplexer, ::com::sun::star::form::XDeleteListener, deleted, ::com::sun::star::lang::EventObject) + +// ::com::sun::star::form::XUpdateListener +IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXUpdateMultiplexer, ::com::sun::star::form::XUpdateListener) +IMPLEMENT_LISTENER_MULTIPLEXER_BOOL_METHOD(SbaXUpdateMultiplexer, ::com::sun::star::form::XUpdateListener, approveUpdate, ::com::sun::star::lang::EventObject) +IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXUpdateMultiplexer, ::com::sun::star::form::XUpdateListener, updated, ::com::sun::star::lang::EventObject) + +// ::com::sun::star::form::XErrorListener +IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXErrorMultiplexer, ::com::sun::star::form::XErrorListener) +IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXErrorMultiplexer, ::com::sun::star::form::XErrorListener, errorOccured, ::com::sun::star::form::ErrorEvent) + +// ::com::sun::star::form::XDatabaseParameterListener +IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXParameterMultiplexer, ::com::sun::star::form::XDatabaseParameterListener) +IMPLEMENT_LISTENER_MULTIPLEXER_BOOL_METHOD(SbaXParameterMultiplexer, ::com::sun::star::form::XDatabaseParameterListener, approveParameter, ::com::sun::star::form::DatabaseParameterEvent) + +// ::com::sun::star::util::XRefreshListener +IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXRefreshMultiplexer, ::com::sun::star::util::XRefreshListener) +IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXRefreshMultiplexer, ::com::sun::star::util::XRefreshListener, refreshed, ::com::sun::star::lang::EventObject) + +// ::com::sun::star::form::XSubmitListener +IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXSubmitMultiplexer, ::com::sun::star::form::XSubmitListener) +IMPLEMENT_LISTENER_MULTIPLEXER_BOOL_METHOD(SbaXSubmitMultiplexer, ::com::sun::star::form::XSubmitListener, approveSubmit, ::com::sun::star::lang::EventObject) + +// ::com::sun::star::form::XResetListener +IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXResetMultiplexer, ::com::sun::star::form::XResetListener) +IMPLEMENT_LISTENER_MULTIPLEXER_BOOL_METHOD(SbaXResetMultiplexer, ::com::sun::star::form::XResetListener, approveReset, ::com::sun::star::lang::EventObject) +IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXResetMultiplexer, ::com::sun::star::form::XResetListener, resetted, ::com::sun::star::lang::EventObject) + +// ::com::sun::star::beans::XPropertyChangeListener +IMPLEMENT_PROPERTY_MULTIPLEXER(SbaXPropertyChangeMultiplexer, ::com::sun::star::beans::XPropertyChangeListener, propertyChange, ::com::sun::star::beans::PropertyChangeEvent) + +// ::com::sun::star::beans::XVetoableChangeListener +IMPLEMENT_PROPERTY_MULTIPLEXER(SbaXVetoableChangeMultiplexer, ::com::sun::star::beans::XVetoableChangeListener, vetoableChange, ::com::sun::star::beans::PropertyChangeEvent) + +// ::com::sun::star::beans::XPropertyStateChangeListener +IMPLEMENT_PROPERTY_MULTIPLEXER(SbaXPropertyStateChangeMultiplexer, ::com::sun::star::beans::XPropertyStateChangeListener, propertyStateChange, ::com::sun::star::beans::PropertyStateChangeEvent) + +// ::com::sun::star::beans::XPropertiesChangeListener + IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXPropertiesChangeMultiplexer, ::com::sun::star::beans::XPropertiesChangeListener); +void SbaXPropertiesChangeMultiplexer::propertiesChange(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent>& aEvts) +{ + // the SbaXPropertiesChangeMultiplexer doesn't care about the property names a listener logs on for, it simply + // forwards _all_ changes to _all_ listeners + + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent> aMulti(aEvts); + ::com::sun::star::beans::PropertyChangeEvent* pMulti = aMulti.getArray(); + for (sal_uInt16 i=0; i<aMulti.getLength(); ++i, ++pMulti) + pMulti->Source = &m_rParent; + + ::cppu::OInterfaceIteratorHelper aIt(*this); + while (aIt.hasMoreElements()) + ((::com::sun::star::beans::XPropertiesChangeListener*)aIt.next())->propertiesChange(aMulti); +} + diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx new file mode 100644 index 000000000..0a7b55c63 --- /dev/null +++ b/dbaccess/source/ui/browser/unodatbr.cxx @@ -0,0 +1,1128 @@ +/************************************************************************* + * + * $RCSfile: unodatbr.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2000-10-26 14:41:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SVX_GRIDCTRL_HXX +#include <svx/gridctrl.hxx> +#endif +#ifndef _SBA_UNODATBR_HXX_ +#include "unodatbr.hxx" +#endif +#ifndef _SBA_GRID_HXX +#include "sbagrid.hxx" +#endif + +//#ifndef _DLGSIZE_HXX +//#include "dlgsize.hxx" +//#endif +//#ifndef _SBA_SBATTRDLG_HXX +//#include "dlgattr.hxx" +//#endif +#ifndef _COM_SUN_STAR_FORM_XLOADABLE_HPP_ +#include <com/sun/star/form/XLoadable.hpp> +#endif +#ifndef _SV_MSGBOX_HXX //autogen +#include <vcl/msgbox.hxx> +#endif + +#ifndef _SFXDISPATCH_HXX //autogen +#include <sfx2/dispatch.hxx> +#endif + +#ifndef _SV_MULTISEL_HXX //autogen +#include <tools/multisel.hxx> +#endif + +#ifndef _URLOBJ_HXX //autogen +#include <tools/urlobj.hxx> +#endif + +#ifndef _SFXINTITEM_HXX //autogen +#include <svtools/intitem.hxx> +#endif + +#ifndef _SV_SVAPP_HXX //autogen +#include <vcl/svapp.hxx> +#endif + +#ifndef _SFXAPP_HXX //autogen +#include <sfx2/app.hxx> +#endif + +#ifndef _SV_WRKWIN_HXX //autogen +#include <vcl/wrkwin.hxx> +#endif + +#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ +#include <com/sun/star/sdb/CommandType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ +#include <com/sun/star/sdbc/XConnection.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_XGRIDCOLUMNFACTORY_HPP_ +#include <com/sun/star/form/XGridColumnFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_XFORM_HPP_ +#include <com/sun/star/form/XForm.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_TEXTALIGN_HPP_ +#include <com/sun/star/awt/TextAlign.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ +#include <com/sun/star/container/XNameContainer.hpp> +#endif +#ifndef _SVX_ALGITEM_HXX //autogen +#include <svx/algitem.hxx> +#endif +#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ +#include <com/sun/star/sdb/CommandType.hpp> +#endif +#ifndef _COMPHELPER_TYPES_HXX_ +#include <comphelper/types.hxx> +#endif +#include "dbtreemodel.hxx" +#include "dbtreeview.hxx" +#ifndef _SVLBOXITM_HXX +#include <svtools/svlbitm.hxx> +#endif +#ifndef _SV_SPLIT_HXX +#include <vcl/split.hxx> +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef _DBU_RESOURCE_HRC_ +#include "dbu_resource.hrc" +#endif +#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "moduledbu.hxx" +#endif +#ifndef DBACCESS_SBA_GRID_HRC +#include "sbagrid.hrc" +#endif +#ifndef DBACCESS_UI_BROWSER_ID_HXX +#include "browserids.hxx" +#endif +#ifndef _DBA_REGISTRATION_HELPER_HXX_ +#include "registrationhelper.hxx" +#endif +#ifndef _CPPUHELPER_EXTRACT_HXX_ +#include <cppuhelper/extract.hxx> +#endif + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::sdb; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +using namespace dbaui; +//================================================================== +//= SbaTableQueryBrowser +//================================================================== +// ------------------------------------------------------------------------- +extern "C" void SAL_CALL createRegistryInfo_OBrowser() +{ + static OMultiInstanceAutoRegistration< SbaTableQueryBrowser > aAutoRegistration; +} + +// ------------------------------------------------------------------------- +void SafeAddPropertyListener(const Reference< XPropertySet > & xSet, const ::rtl::OUString& rPropName, XPropertyChangeListener* pListener) +{ + Reference< XPropertySetInfo > xInfo = xSet->getPropertySetInfo(); + if (xInfo->hasPropertyByName(rPropName)) + xSet->addPropertyChangeListener(rPropName, pListener); +} + +// ------------------------------------------------------------------------- +void SafeRemovePropertyListener(const Reference< XPropertySet > & xSet, const ::rtl::OUString& rPropName, XPropertyChangeListener* pListener) +{ + Reference< XPropertySetInfo > xInfo = xSet->getPropertySetInfo(); + if (xInfo->hasPropertyByName(rPropName)) + xSet->removePropertyChangeListener(rPropName, pListener); +} +//------------------------------------------------------------------------- +::rtl::OUString SAL_CALL SbaTableQueryBrowser::getImplementationName() throw(RuntimeException) +{ + return getImplementationName_Static(); +} +//------------------------------------------------------------------------- +::comphelper::StringSequence SAL_CALL SbaTableQueryBrowser::getSupportedServiceNames() throw(RuntimeException) +{ + return getSupportedServiceNames_Static(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SbaTableQueryBrowser::getImplementationName_Static() throw(RuntimeException) +{ + return ::rtl::OUString::createFromAscii("org.openoffice.dbaccess.ODatabaseBrowser"); +} +//------------------------------------------------------------------------- +::comphelper::StringSequence SbaTableQueryBrowser::getSupportedServiceNames_Static() throw(RuntimeException) +{ + ::comphelper::StringSequence aSupported(1); + aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.dialogs.DatabaseBrowser"); + return aSupported; +} +//------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL SbaTableQueryBrowser::Create(const Reference<XMultiServiceFactory >& _rxFactory) +{ + return *(new SbaTableQueryBrowser(_rxFactory)); +} +//------------------------------------------------------------------------------ +SbaTableQueryBrowser::SbaTableQueryBrowser(const Reference< XMultiServiceFactory >& _rM) + :SbaXDataBrowserController(_rM) + ,m_pTreeModel(NULL) + ,m_pTreeView(NULL) + ,m_pSplitter(NULL) +{ + // calc the title for the load stopper +// sal_uInt32 nTitleResId; +// switch (m_xDefinition->GetKind()) +// { +// case dbTable : nTitleResId = STR_TBL_TITLE; break; +// case dbQuery : nTitleResId = STR_QRY_TITLE; break; +// default : DBG_ERROR("OpenDataObjectThread::run : invalid object !"); +// } +// String sTemp = String(ModuleRes(nTitleResId)); +// sTemp.SearchAndReplace('#', m_xDefinition->Name()); +// m_sLoadStopperCaption = String(ModuleRes(RID_STR_OPEN_OBJECT)); +// m_sLoadStopperCaption += ' '; +// m_sLoadStopperCaption += sTemp; +} + +//------------------------------------------------------------------------------ +SbaTableQueryBrowser::~SbaTableQueryBrowser() +{ + delete m_pTreeModel; +} +//------------------------------------------------------------------------------ +sal_Bool SbaTableQueryBrowser::Construct(Window* pParent) +{ + if (!SbaXDataBrowserController::Construct(pParent)) + return sal_False; + + // some help ids + if (getContent() && getContent()->getVclControl()) + { + + // create controls and set sizes + const long nFrameWidth = getContent()->LogicToPixel( Size( 3, 0 ), MAP_APPFONT ).Width(); + + m_pSplitter = new Splitter(getContent(),WB_HSCROLL); + m_pSplitter->SetPosSizePixel( Point(0,0), Size(nFrameWidth,0) ); + m_pSplitter->SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetDialogColor() ) ); + m_pSplitter->Show(); + + m_pTreeView = new DBTreeView(getContent(), WB_TABSTOP); + m_pTreeView->Show(); + + getContent()->setSplitter(m_pSplitter); + getContent()->setTreeView(m_pTreeView); + + // fill view with data + m_pTreeModel = new DBTreeListModel(m_xMultiServiceFacatory); + m_pTreeView->setModel(m_pTreeModel); + m_pTreeView->setSelectHdl(LINK(this, SbaTableQueryBrowser, OnSelectEntry)); + + // TODO + // getContent()->getVclControl()->GetDataWindow().SetUniqueId(UID_DATABROWSE_DATAWINDOW); + // getContent()->getVclControl()->SetHelpId(HID_CTL_TABBROWSER); + // if (getContent()->getVclControl()->GetHeaderBar()) + // getContent()->getVclControl()->GetHeaderBar()->SetHelpId(HID_DATABROWSE_HEADER); + } + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SbaTableQueryBrowser::InitializeForm(const Reference< ::com::sun::star::sdbc::XRowSet > & _rxForm) +{ + try + { + // set the parent of the ::com::sun::star::form::Form + Reference< ::com::sun::star::form::XForm > xForm(_rxForm, UNO_QUERY); +// { +// DbEnvironmentAccess aEnv; +// if (aEnv.getEnv().is()) +// { +// Reference< ::com::sun::star::sdb::XDatabaseAccess > xDatabase = aEnv.getEnv()->getDatabaseAccess(m_xDatabase->Name()); +// if (xDatabase.is()) +// xForm->setParent(xDatabase->getConnection(::rtl::OUString(),::rtl::OUString())); +// } +// } + + // we send all properties at once, maybe the implementation is clever enough to handle one big PropertiesChanged + // more effective than many small PropertyChanged ;) + Sequence< ::rtl::OUString> aProperties(6); + Sequence< Any> aValues(6); + + // is the filter intially applied ? +// const SfxBoolItem* pFilterApplied = (const SfxBoolItem*)getDefinition()->GetObjAttrs()->GetItem(SBA_DEF_FILTERAPPLIED); +// aProperties.getArray()[0] = PROPERTY_APPLYFILTER; +// aValues.getArray()[0] = ::utl::makeBoolAny((sal_Bool)(pFilterApplied ? pFilterApplied->GetValue() : sal_False)); +// +// // cursor source +// aProperties.getArray()[1] = PROPERTY_COMMAND; +// aValues.getArray()[1] <<= ::rtl::OUString(m_xDefinition->Name()); +// // may be replaced with a sql statement below +// +// // cursor source type +// aProperties.getArray()[2] = PROPERTY_COMMANDTYPE; +// +// sal_Int32 nType = ::com::sun::star::sdb::CommandType::COMMAND; +// sal_Bool bEscapeProcessing = sal_True; +// switch (m_xDefinition->GetKind()) +// { +// case dbTable : nType = ::com::sun::star::sdb::CommandType::TABLE; break; +// case dbQuery : +// if (m_xDefinition->Name().Len()) +// nType = ::com::sun::star::sdb::CommandType::QUERY; +// else +// { // it is a temporary query object +// SbaQueryDef* pQuery = PTR_CAST(SbaQueryDef, &m_xDefinition); +// DBG_ASSERT(pQuery, "SbaTableQueryBrowser::InitializeForm : the object is of kind dbQuery but no query def ?"); +// +// if (pQuery->IsNative()) +// bEscapeProcessing = sal_False; +// +// aValues.getArray()[1] <<= ::rtl::OUString(pQuery->Statement()); +// } +// break; +// +// default : DBG_ERROR("SbaTableQueryBrowser::InitializeForm : the definition has to be a table or a query !"); +// } +// aValues.getArray()[2] <<= nType; +// +// // escape processing ? +// aProperties.getArray()[3] = PROPERTY_USE_ESCAPE_PROCESSING; +// aValues.getArray()[3].setValue(&bEscapeProcessing,::getBooleanCppuType()); +// +// // the initial filter +// const SfxStringItem* pFilterSort = (const SfxStringItem*)getDefinition()->GetObjAttrs()->GetItem(SBA_DEF_FILTER); +// aProperties.getArray()[4] = PROPERTY_FILTER; +// aValues.getArray()[4] <<= ::rtl::OUString(pFilterSort ? ::rtl::OUString(pFilterSort->GetValue()) : ::rtl::OUString()); +// +// // the initial ordering +// pFilterSort = (const SfxStringItem*)getDefinition()->GetObjAttrs()->GetItem(SBA_DEF_SORT); +// aProperties.getArray()[5] = PROPERTY_ORDER; +// aValues.getArray()[5] <<= ::rtl::OUString(pFilterSort ? ::rtl::OUString(pFilterSort->GetValue()) : ::rtl::OUString()); +// +// Reference< XMultiPropertySet > xFormMultiSet(_rxForm, UNO_QUERY); +// xFormMultiSet->setPropertyValues(aProperties, aValues); + } + catch(...) + { + DBG_ERROR("SbaTableQueryBrowser::InitializeForm : something went wrong !"); + return sal_False; + } + + + return sal_True; +} + +//------------------------------------------------------------------------------ +sal_Bool SbaTableQueryBrowser::InitializeGridModel(const Reference< ::com::sun::star::form::XFormComponent > & xGrid) +{ + try + { + + Reference< ::com::sun::star::form::XGridColumnFactory > xColFactory(xGrid, UNO_QUERY); + Reference< XNameContainer > xColContainer(xGrid, UNO_QUERY); + // first we have to clear the grid + { + Sequence< ::rtl::OUString > aNames = xColContainer->getElementNames(); + const ::rtl::OUString* pBegin = aNames.getConstArray(); + const ::rtl::OUString* pEnd = pBegin + aNames.getLength(); + for (; pBegin != pEnd;++pBegin) + xColContainer->removeByName(*pBegin); + } + + // get the formats supplier of the database we're working with + Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier = getNumberFormatter()->getNumberFormatsSupplier(); + + + + // insert the column into the gridcontrol so that we see something :-) + ::rtl::OUString aCurrentModelType; + Reference<XColumnsSupplier> xSupCols(getRowSet(),UNO_QUERY); + Reference<XNameAccess> xColumns = xSupCols->getColumns(); + Sequence< ::rtl::OUString> aNames = xColumns->getElementNames(); + const ::rtl::OUString* pBegin = aNames.getConstArray(); + const ::rtl::OUString* pEnd = pBegin + aNames.getLength(); + + Reference<XPropertySet> xColumn; + for (sal_uInt16 i=0; pBegin != pEnd; ++i,++pBegin) + { + // Typ + // first get type to determine wich control we need + xColumns->getByName(*pBegin) >>= xColumn; + + sal_Bool bIsFormatted = sal_False; + sal_Bool bFormattedIsNumeric = sal_True; + sal_Int32 nType = comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_TYPE)); + switch(nType) + { + // TODO : die Strings fuer die Column-Typen irgendwo richtig platzieren + case DataType::BIT: + aCurrentModelType = ::rtl::OUString::createFromAscii("CheckBox"); + break; + + case DataType::BINARY: + case DataType::VARBINARY: + case DataType::LONGVARBINARY: + aCurrentModelType = ::rtl::OUString::createFromAscii("TextField"); + break; + + case DataType::VARCHAR: + case DataType::LONGVARCHAR: + case DataType::CHAR: + bFormattedIsNumeric = sal_False; + // _NO_ break ! + default: + aCurrentModelType = ::rtl::OUString::createFromAscii("FormattedField"); + bIsFormatted = sal_True; + break; + } + + Reference< XPropertySet > xCurrentCol = xColFactory->createColumn(aCurrentModelType); + xCurrentCol->setPropertyValue(PROPERTY_CONTROLSOURCE, makeAny(*pBegin)); + xCurrentCol->setPropertyValue(PROPERTY_LABEL, makeAny(*pBegin)); + if (bIsFormatted) + { + if (xSupplier.is()) + xCurrentCol->setPropertyValue(::rtl::OUString::createFromAscii("FormatsSupplier"), makeAny(xSupplier)); + xCurrentCol->setPropertyValue(PROPERTY_FORMATKEY, xColumn->getPropertyValue(PROPERTY_FORMATKEY)); + xCurrentCol->setPropertyValue(::rtl::OUString::createFromAscii("TreatAsNumber"), ::cppu::bool2any(bFormattedIsNumeric)); + } + + // default value + if (nType == DataType::BIT) + { + Any aDefault; aDefault <<= ((sal_Int16)STATE_DONTKNOW); + if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_DEFAULTVALUE)) + aDefault <<= (comphelper::getString(xColumn->getPropertyValue(PROPERTY_DEFAULTVALUE)).toInt32() == 0) ? (sal_Int16)STATE_NOCHECK : (sal_Int16)STATE_CHECK; + xCurrentCol->setPropertyValue(PROPERTY_DEFAULTSTATE, aDefault); + } + + // transfer properties from the definition to the UNO-model : + // ... the hidden flag + xCurrentCol->setPropertyValue(PROPERTY_HIDDEN, xColumn->getPropertyValue(PROPERTY_HIDDEN)); + + // ... the initial colum width + xCurrentCol->setPropertyValue(PROPERTY_WIDTH, xColumn->getPropertyValue(PROPERTY_WIDTH)); + + // ... horizontal justify + xCurrentCol->setPropertyValue(PROPERTY_ALIGN, xColumn->getPropertyValue(PROPERTY_ALIGN)); + + // ... the 'comment' property as helptext (will usually be shown as header-tooltip) + + Any aDescription; aDescription <<= ::rtl::OUString(); + if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_DESCRIPTION)) + aDescription <<= comphelper::getString(xColumn->getPropertyValue(PROPERTY_DESCRIPTION)); + xCurrentCol->setPropertyValue(PROPERTY_HELPTEXT, xColumn->getPropertyValue(PROPERTY_DESCRIPTION)); + + xColContainer->insertByName(*pBegin, makeAny(xCurrentCol)); + } + +// SFX_ITEMSET_GET(*pDef->GetObjAttrs(), pRowHeight, SbaColRowSizeItem, SBA_DEF_ROWHEIGHT, sal_True); +// SFX_ITEMSET_GET(*pDef->GetObjAttrs(), pRowHeightDefault, SfxBoolItem, SBA_DEF_ROWHEIGHT_DEFAULT, sal_True); +// if (xGridSet.is() && pRowHeight && pRowHeightDefault) +// { +// Any aHeight; +// if (pRowHeightDefault->GetValue()) +// { +// Reference< XPropertyState > xPropState(xGridSet, UNO_QUERY); +// if (xPropState.is()) +// { +// try { aHeight = xPropState->getPropertyDefault(PROPERTY_ROW_HEIGHT); } catch(...) { } ; +// } +// } +// else +// aHeight <<= pRowHeight->GetLogicValue(); +// xGridSet->setPropertyValue(PROPERTY_ROW_HEIGHT, aHeight); +// } +// +// if (xGridSet.is()) +// { +// ::com::sun::star::awt::FontDescriptor aFont = BuildFontFromItems(pDef->GetObjAttrs(), Application::GetDefaultDevice()->GetFont()); +// xGridSet->setPropertyValue(PROPERTY_FONT, Any(&aFont, ::getCppuType((const ::com::sun::star::awt::FontDescriptor*)0))); +// +// SFX_ITEMSET_GET(*pDef->GetObjAttrs(), pColor, SvxColorItem, SBA_DEF_FONTCOLOR, sal_True); +// xGridSet->setPropertyValue(PROPERTY_TEXTCOLOR, makeAny((sal_Int32)pColor->GetValue().GetColor())); +// } +// + } + catch(...) + { + DBG_ERROR("SbaTableQueryBrowser::InitializeGridModel : something went wrong !"); + return sal_False; + } + + + return sal_True; +} + +//------------------------------------------------------------------------------ +ToolBox* SbaTableQueryBrowser::CreateToolBox(Window* _pParent) +{ + ToolBox* pTB = NULL; + Reference<XPropertySet> xProp(getRowSet(),UNO_QUERY); + if(xProp.is()) + { + sal_Int32 nType; + xProp->getPropertyValue(::rtl::OUString::createFromAscii("CommandType")) >>= nType; + + sal_uInt16 nResId = 0; + switch (nType) + { + case CommandType::TABLE : nResId = RID_BRW_TAB_TOOLBOX; break; + case CommandType::QUERY : nResId = RID_BRW_QRY_TOOLBOX; break; + case CommandType::COMMAND: nResId = RID_BRW_QRY_TOOLBOX; break; + default : return NULL; + } + + pTB = new ToolBox(_pParent, ModuleRes(nResId)); + if (!pTB) + return NULL; + + if (pTB->GetItemPos(ID_BROWSER_EXPL_PREVLEVEL) != TOOLBOX_ITEM_NOTFOUND) + { // if we display the grid in the beamer we don't want a "prev level" button + // if (getFrame().is() && (getFrame()->getName().equals(::rtl::OUString::createFromAscii("_beamer")))) + pTB->HideItem(ID_BROWSER_EXPL_PREVLEVEL); + } + } + return pTB; +} + +// ----------------------------------------------------------------------- +void SbaTableQueryBrowser::propertyChange(const PropertyChangeEvent& evt) +{ + SbaXDataBrowserController::propertyChange(evt); + +// Reference< XPropertySet > xSource(evt.Source, UNO_QUERY); +// if (!xSource.is()) +// return; +// +// // one of the many properties which require us to update the definition ? +// // a column's width ? +// if (evt.PropertyName.equals(PROPERTY_WIDTH)) +// { // a column width has changed -> update the model +// // (the update of the view is done elsewhere) +// SbaColumn* pAffectedCol = GetDefinitionCol(xSource); +// if (pAffectedCol) +// { +// SbaColRowSizeItem aNewWidth(SBA_DEF_FLTCOLWIDTH); +// sal_Bool bDefault = !evt.NewValue.hasValue(); +// SfxBoolItem aDefault(SBA_DEF_FLTCOLWIDTH_DEFAULT, bDefault); +// if (bDefault) +// // this is for older versions which don't know the default flag +// aNewWidth.PutLogicValue((sal_uInt16)227); +// else +// aNewWidth.PutLogicValue((sal_uInt16)::utl::getINT32(evt.NewValue)); +// +// pAffectedCol->Put(aNewWidth); +// pAffectedCol->Put(aDefault); +// } +// } +// +// // a column's 'visible' state ? +// if (evt.PropertyName.equals(PROPERTY_HIDDEN)) +// { +// SbaColumn* pAffectedCol = GetDefinitionCol(xSource); +// if (pAffectedCol) +// pAffectedCol->Put(SfxBoolItem(SBA_DEF_FLTHIDE, ::utl::getBOOL(evt.NewValue))); +// } +// +// // a columns alignment ? +// if (evt.PropertyName.equals(PROPERTY_ALIGN)) +// { +// SbaColumn* pAffectedCol = GetDefinitionCol(xSource); +// if (pAffectedCol) +// { +// SvxCellHorJustify eHorJustify = SVX_HOR_JUSTIFY_STANDARD; +// if (evt.NewValue.hasValue()) +// switch (::utl::getINT16(evt.NewValue)) +// { +// case ::com::sun::star::awt::TextAlign::LEFT: +// eHorJustify = SVX_HOR_JUSTIFY_LEFT; +// break; +// case ::com::sun::star::awt::TextAlign::CENTER: +// eHorJustify = SVX_HOR_JUSTIFY_CENTER; +// break; +// case ::com::sun::star::awt::TextAlign::RIGHT: +// eHorJustify = SVX_HOR_JUSTIFY_RIGHT; +// break; +// } +// +// pAffectedCol->Put(SvxHorJustifyItem(eHorJustify, SBA_ATTR_ALIGN_HOR_JUSTIFY)); +// } +// } +// +// // a column's format ? +// if ( (evt.PropertyName.equals(PROPERTY_FORMATKEY)) +// && (TypeClass_LONG == evt.NewValue.getValueTypeClass()) +// ) +// { +// // update the model (means the definition object) +// SbaColumn* pAffectedCol = GetDefinitionCol(xSource); +// if (pAffectedCol) +// pAffectedCol->Put(SfxUInt32Item(SBA_DEF_FMTVALUE, ::utl::getINT32(evt.NewValue))); +// } +// +// // some table definition properties ? +// // the height of the rows in the grid ? +// if (evt.PropertyName.equals(PROPERTY_ROW_HEIGHT)) +// { +// if (getDefinition()) +// { +// SbaColRowSizeItem aNewHeight(SBA_DEF_ROWHEIGHT); +// sal_Bool bDefault = !evt.NewValue.hasValue(); +// SfxBoolItem aDefault(SBA_DEF_FLTCOLWIDTH_DEFAULT, bDefault); +// +// if (bDefault) +// aNewHeight.PutLogicValue((sal_uInt16)45); +// else +// aNewHeight.PutLogicValue((sal_uInt16)::utl::getINT32(evt.NewValue)); +// +// getDefinition()->GetObjAttrs()->Put(aNewHeight); +// getDefinition()->GetObjAttrs()->Put(aDefault); +// getDefinition()->PutObjAttrs(*(getDefinition()->GetObjAttrs())); +// // this sets the modified flagd +// } +// } +// +// // the font of the grid ? +// if (evt.PropertyName.equals(PROPERTY_FONT)) +// { +// if (getDefinition()) +// { +// BuildItemsFromFont(getDefinition()->GetObjAttrs(), *(::com::sun::star::awt::FontDescriptor*)evt.NewValue.getValue()); +// getDefinition()->PutObjAttrs(*(getDefinition()->GetObjAttrs())); +// // this sets the modified flagd +// } +// } +// +// // the text color of the grid ? +// if (evt.PropertyName.equals(PROPERTY_TEXTCOLOR)) +// { +// if (getDefinition()) +// { +// SvxColorItem aColor(Color(::utl::getINT32(evt.NewValue)), SBA_DEF_FONTCOLOR); +// getDefinition()->GetObjAttrs()->Put(aColor); +// getDefinition()->PutObjAttrs(*(getDefinition()->GetObjAttrs())); +// // this sets the modified flagd +// } +// } +// +// // the filter ? +// if (evt.PropertyName.equals(PROPERTY_FILTER)) +// { +// if (getDefinition()) +// { +// SfxStringItem aFilter(SBA_DEF_FILTER, ::utl::getString(evt.NewValue)); +// getDefinition()->GetObjAttrs()->Put(aFilter); +// getDefinition()->PutObjAttrs(*(getDefinition()->GetObjAttrs())); +// // this sets the modified flagd +// } +// } +// +// // the sort ? +// if (evt.PropertyName.equals(PROPERTY_ORDER)) +// { +// if (getDefinition()) +// { +// SfxStringItem aSort(SBA_DEF_SORT, ::utl::getString(evt.NewValue)); +// getDefinition()->GetObjAttrs()->Put(aSort); +// getDefinition()->PutObjAttrs(*(getDefinition()->GetObjAttrs())); +// // this sets the modified flagd +// } +// } +// +// // the appliance of the filter ? +// if (evt.PropertyName.equals(PROPERTY_APPLYFILTER)) +// { +// if (getDefinition()) +// { +// SfxBoolItem aApplied(SBA_DEF_FILTERAPPLIED, ::utl::getBOOL(evt.NewValue)); +// getDefinition()->GetObjAttrs()->Put(aApplied); +// getDefinition()->PutObjAttrs(*(getDefinition()->GetObjAttrs())); +// // this sets the modified flagd +// } +// } +} + +// ----------------------------------------------------------------------- +sal_Bool SbaTableQueryBrowser::suspend(sal_Bool bSuspend) throw( RuntimeException ) +{ + if (!SbaXDataBrowserController::suspend(bSuspend)) + return sal_False; + +// if (getDefinition()) +// { +// // let the definition save its UI settings +// SbaDBDataDef* pDef = getDefinition(); +// if (pDef && !pDef->GetDatabase()->IsReadOnly() && pDef->IsModified()) +// pDef->Update(); +// +// // we aren't using the definition anymore +// if (m_bUsingDefinition) +// { +// pDef->ReleaseUsage(); +// m_xDefinition = NULL; +// m_bUsingDefinition = false; +// } +// +// } +// +// // we don't need to listen at the definition and its database anymore + // EndListening(*SBA_MOD()); + + return sal_True; +} + +// ------------------------------------------------------------------------- +void SbaTableQueryBrowser::attachFrame(const Reference< ::com::sun::star::frame::XFrame > & _xFrame) throw( RuntimeException ) +{ + SbaXDataBrowserController::attachFrame(_xFrame); + + sal_Bool bIsBeamer = (getFrame().is() && (getFrame()->getName().equals(::rtl::OUString::createFromAscii("_beamer")))); + Reference< XPropertySet > xGridSet(getFormComponent(), UNO_QUERY); + ToolBox* pTB = getContent() ? getContent()->getToolBox() : NULL; + + if (bIsBeamer) + { + // hide the "move a level up"-button + sal_uInt16 nPos = pTB ? pTB->GetItemPos(ID_BROWSER_EXPL_PREVLEVEL) : TOOLBOX_ITEM_NOTFOUND; + if ((nPos != TOOLBOX_ITEM_NOTFOUND) && pTB->IsItemVisible(ID_BROWSER_EXPL_PREVLEVEL)) + { + DBG_ASSERT(nPos == 0, "SbaTableQueryBrowser::attachFrame : can't handle a prev-level-slot which isn't the first one within the TB !"); + // we check all slots behind the prev-level slot and don't deal with the ones before + pTB->HideItem(ID_BROWSER_EXPL_PREVLEVEL); + ++nPos; + if (pTB->GetItemType(nPos) == TOOLBOXITEM_SEPARATOR) + pTB->RemoveItem(nPos); + } + } + else + { + // show the "move a level up"-button + sal_uInt16 nPos = pTB ? pTB->GetItemPos(ID_BROWSER_EXPL_PREVLEVEL) : TOOLBOX_ITEM_NOTFOUND; + if ((nPos != TOOLBOX_ITEM_NOTFOUND) && !pTB->IsItemVisible(ID_BROWSER_EXPL_PREVLEVEL)) + { + DBG_ASSERT(nPos == 0, "SbaTableQueryBrowser::attachFrame : can't handle a prev-level-slot which isn't the first one within the TB !"); + // we check all slots behind the prev-level slot and don't deal with the ones before + pTB->ShowItem(ID_BROWSER_EXPL_PREVLEVEL); + ++nPos; + if (pTB->GetItemType(nPos) != TOOLBOXITEM_SEPARATOR) + pTB->InsertSeparator(nPos); + } + } +} + +// ------------------------------------------------------------------------- +void SbaTableQueryBrowser::addModelListeners(const Reference< ::com::sun::star::awt::XControlModel > & _xGridControlModel) +{ + SbaXDataBrowserController::addModelListeners(_xGridControlModel); + Reference< XPropertySet > xCols(_xGridControlModel, UNO_QUERY); + if (xCols.is()) + { + xCols->addPropertyChangeListener(PROPERTY_ROW_HEIGHT, (XPropertyChangeListener*)this); + xCols->addPropertyChangeListener(PROPERTY_FONT, (XPropertyChangeListener*)this); + xCols->addPropertyChangeListener(PROPERTY_TEXTCOLOR, (XPropertyChangeListener*)this); + } + +} + +// ------------------------------------------------------------------------- +void SbaTableQueryBrowser::removeModelListeners(const Reference< ::com::sun::star::awt::XControlModel > & _xGridControlModel) +{ + SbaXDataBrowserController::removeModelListeners(_xGridControlModel); + Reference< XPropertySet > xSourceSet(_xGridControlModel, UNO_QUERY); + if (xSourceSet.is()) + { + xSourceSet->removePropertyChangeListener(PROPERTY_ROW_HEIGHT, (XPropertyChangeListener*)this); + xSourceSet->removePropertyChangeListener(PROPERTY_FONT, (XPropertyChangeListener*)this); + xSourceSet->removePropertyChangeListener(PROPERTY_TEXTCOLOR, (XPropertyChangeListener*)this); + } +} +// ------------------------------------------------------------------------- +String SbaTableQueryBrowser::getURL() const +{ + return String(); +} +// ----------------------------------------------------------------------- +void SbaTableQueryBrowser::InvalidateFeature(sal_uInt16 nId, const Reference< ::com::sun::star::frame::XStatusListener > & xListener) +{ + SbaXDataBrowserController::InvalidateFeature(nId, xListener); +// switch (nId) +// { +// case ID_BROWSER_INSERT: +// case ID_BROWSER_UPDATE: +// case ID_BROWSER_MERGE: +// GetBindings().Invalidate(nId, sal_True, sal_False); +// break; +// default: +// SbaXDataBrowserController::InvalidateFeature(nId, xListener); +// } +} + +//------------------------------------------------------------------------------ +void SbaTableQueryBrowser::AddColumnListener(const Reference< XPropertySet > & xCol) +{ + SbaXDataBrowserController::AddColumnListener(xCol); + SafeAddPropertyListener(xCol, PROPERTY_WIDTH, (XPropertyChangeListener*)this); + SafeAddPropertyListener(xCol, PROPERTY_HIDDEN, (XPropertyChangeListener*)this); + SafeAddPropertyListener(xCol, PROPERTY_ALIGN, (XPropertyChangeListener*)this); + SafeAddPropertyListener(xCol, PROPERTY_FORMATKEY, (XPropertyChangeListener*)this); +} + +//------------------------------------------------------------------------------ +void SbaTableQueryBrowser::RemoveColumnListener(const Reference< XPropertySet > & xCol) +{ + SbaXDataBrowserController::RemoveColumnListener(xCol); + SafeRemovePropertyListener(xCol, PROPERTY_WIDTH, (XPropertyChangeListener*)this); + SafeRemovePropertyListener(xCol, PROPERTY_HIDDEN, (XPropertyChangeListener*)this); + SafeRemovePropertyListener(xCol, PROPERTY_ALIGN, (XPropertyChangeListener*)this); + SafeRemovePropertyListener(xCol, PROPERTY_FORMATKEY, (XPropertyChangeListener*)this); +} +//------------------------------------------------------------------------------ +void SbaTableQueryBrowser::AddSupportedFeatures() +{ + SbaXDataBrowserController::AddSupportedFeatures(); + + m_aSupportedFeatures[ ::rtl::OUString::createFromAscii(".uno:Title")] = ID_BROWSER_TITLE; + m_aSupportedFeatures[ ::rtl::OUString::createFromAscii(".uno:WriterDB/MailInsert")] = ID_BROWSER_INSERT; + m_aSupportedFeatures[ ::rtl::OUString::createFromAscii(".uno:WriterDB/MailMerge")] = ID_BROWSER_MERGE; + m_aSupportedFeatures[ ::rtl::OUString::createFromAscii(".uno:WriterDB/MailUpdate")] = ID_BROWSER_UPDATE; + + // TODO reenable our own code if we really have a handling for the formslots +// ControllerFeature( ::rtl::OUString::createFromAscii("private:FormSlot/moveToFirst"), SID_FM_RECORD_FIRST ), +// ControllerFeature( ::rtl::OUString::createFromAscii("private:FormSlot/moveToLast"), SID_FM_RECORD_LAST ), +// ControllerFeature( ::rtl::OUString::createFromAscii("private:FormSlot/moveToNew"), SID_FM_RECORD_NEW ), +// ControllerFeature( ::rtl::OUString::createFromAscii("private:FormSlot/moveToNext"), SID_FM_RECORD_NEXT ), +// ControllerFeature( ::rtl::OUString::createFromAscii("private:FormSlot/moveToPrev"), SID_FM_RECORD_PREV ) + +} + +//------------------------------------------------------------------------------ +FeatureState SbaTableQueryBrowser::GetState(sal_uInt16 nId) +{ + FeatureState aReturn; + // (disabled automatically) + + try + { + // no chance without a view + if (!getContent() || !getContent()->getVclControl()) + return aReturn; + // no chance without valid models + if (isValid() && !isValidCursor()) + return aReturn; + // no chance while loading the form + if (PendingLoad()) + return aReturn; + + switch (nId) + { + case ID_BROWSER_INSERT: + case ID_BROWSER_UPDATE: + case ID_BROWSER_MERGE: + { + // TODO +// SfxPoolItem* pState = NULL; +// SfxItemState eState = GetBindings().QueryState(nId, pState); +// if (pState) +// delete pState; // not interested in +// aReturn.bEnabled = (eState >= SFX_ITEM_AVAILABLE); + + if (ID_BROWSER_MERGE != nId) + aReturn.bEnabled = aReturn.bEnabled && getContent()->getVclControl()->GetSelectRowCount(); + + Reference< XPropertySet > xDataSource(getRowSet(), UNO_QUERY); + try + { + aReturn.bEnabled = aReturn.bEnabled && xDataSource.is(); + + // disable them for native queries which are not saved within the database + // 67706 - 23.08.99 - FS + if (xDataSource.is()) + { + sal_Int32 nType = ::comphelper::getINT32(xDataSource->getPropertyValue(PROPERTY_COMMANDTYPE)); + aReturn.bEnabled = aReturn.bEnabled && ((::comphelper::getBOOL(xDataSource->getPropertyValue(PROPERTY_USE_ESCAPE_PROCESSING)) || (nType == ::com::sun::star::sdb::CommandType::QUERY))); + } + } + catch(...) + { + } + + } + break; + case ID_BROWSER_TITLE: + { + Reference<XPropertySet> xProp(getRowSet(),UNO_QUERY); + sal_Int32 nCommandType = CommandType::TABLE; + xProp->getPropertyValue(PROPERTY_COMMANDTYPE) >>= nCommandType; + String sTitle; + switch (nCommandType) + { + case CommandType::TABLE: + sTitle = String(ModuleRes(STR_TBL_TITLE)); break; + case CommandType::QUERY: + sTitle = String(ModuleRes(STR_QRY_TITLE)); break; + default: + DBG_ASSERT(0,"Unbekannte DBDef Art"); + } + ::rtl::OUString aName; + xProp->getPropertyValue(PROPERTY_COMMAND) >>= aName; + String sObject(aName.getStr()); + + sTitle.SearchAndReplace('#',sObject); + aReturn.aState <<= ::rtl::OUString(sTitle); + aReturn.bEnabled = sal_True; + } + break; + case ID_BROWSER_TABLEATTR: + case ID_BROWSER_ROWHEIGHT: + case ID_BROWSER_COLATTRSET: + case ID_BROWSER_COLWIDTH: + aReturn.bEnabled = getContent() && getContent()->getVclControl() && isValid() && isValidCursor(); + // aReturn.bEnabled &= getDefinition() && !getDefinition()->GetDatabase()->IsReadOnly(); + break; + + case ID_BROWSER_EXPL_PREVLEVEL: + aReturn.bEnabled = sal_True; + break; + + case ID_BROWSER_EDITDOC: + aReturn = SbaXDataBrowserController::GetState(nId); + // aReturn.bEnabled &= !getDefinition()->IsLocked(); + // somebody is modifying the definition -> no edit mode + break; + + default: + return SbaXDataBrowserController::GetState(nId); + } + } + catch(Exception& e) + { +#if DBG_UTIL + String sMessage("SbaXDataBrowserController::GetState(", RTL_TEXTENCODING_ASCII_US); + sMessage += String::CreateFromInt32(nId); + sMessage.AppendAscii(") : catched an exception ! message : "); + sMessage += (const sal_Unicode*)e.Message; + DBG_ERROR(ByteString(sMessage, gsl_getSystemTextEncoding()).GetBuffer()); +#else + e; // make compiler happy +#endif + } + ; + + return aReturn; + +} + +//------------------------------------------------------------------------------ +void SbaTableQueryBrowser::Execute(sal_uInt16 nId) +{ + switch (nId) + { + case ID_BROWSER_EDITDOC: + SbaXDataBrowserController::Execute(nId); + break; + + case ID_BROWSER_INSERT: + case ID_BROWSER_UPDATE: + case ID_BROWSER_MERGE: + // TODO use dispatch + if (getContent() && isValidCursor()) + { + ::com::sun::star::util::URL aParentUrl; + // is faster as to search in the map + switch(nId) + { + case ID_BROWSER_INSERT: + aParentUrl.Complete = ::rtl::OUString::createFromAscii(".uno:WriterDB/MailInsert"); + break; + case ID_BROWSER_UPDATE: + aParentUrl.Complete = ::rtl::OUString::createFromAscii(".uno:WriterDB/MailUpdate"); + break; + case ID_BROWSER_MERGE: + aParentUrl.Complete = ::rtl::OUString::createFromAscii(".uno:WriterDB/MailMerge"); + break; + } + + Reference< ::com::sun::star::frame::XDispatchProvider > xProvider(m_xCurrentFrame, UNO_QUERY); + DBG_ASSERT(xProvider.is(), "SbaTableQueryBrowser::Execute(ID_BROWSER_EXPL_PREVLEVEL) : no DispatchPprovider !"); + Reference< ::com::sun::star::frame::XDispatch > xDispatcher = xProvider->queryDispatch(aParentUrl, m_xCurrentFrame->getName(), 0); + if (xDispatcher.is()) + { + // set the properties for the dispatch + + // first fill the selection + SbaGridControl* pGrid = getContent()->getVclControl(); + MultiSelection* pSelection = (MultiSelection*)pGrid->GetSelection(); + Sequence< sal_Int32> aSelection; + if (pSelection != NULL) + { + aSelection.realloc(pSelection->GetSelectCount()); + long nIdx = pSelection->FirstSelected(); + sal_Int32 i = 0; + while (nIdx >= 0) + { + aSelection[i++] = nIdx+1; + nIdx = pSelection->NextSelected(); + } + } + + Reference<XPropertySet> xProp(getRowSet(),UNO_QUERY); + + Sequence< PropertyValue> aProps(4); + aProps[0] = PropertyValue(PROPERTY_DATASOURCENAME,-1,xProp->getPropertyValue(PROPERTY_DATASOURCENAME),PropertyState_DIRECT_VALUE); + aProps[1] = PropertyValue(PROPERTY_COMMAND,-1,xProp->getPropertyValue(PROPERTY_COMMAND),PropertyState_DIRECT_VALUE); + aProps[2] = PropertyValue(PROPERTY_COMMANDTYPE,-1,xProp->getPropertyValue(PROPERTY_COMMANDTYPE),PropertyState_DIRECT_VALUE); + aProps[3] = PropertyValue(PROPERTY_ROWCOUNT,-1,makeAny(aSelection),PropertyState_DIRECT_VALUE); + + xDispatcher->dispatch(aParentUrl, aProps); + } + } + // SendInfo(nId); + break; + + case ID_BROWSER_EXPL_PREVLEVEL: + { + INetURLObject aURL(getURL()); + DBG_ASSERT(aURL.HasMark(), "SbaTableQueryBrowser::Execute : invalid ::com::sun::star::util::URL !"); + String sMark = aURL.GetMark(); + xub_StrLen nSep = sMark.SearchBackward(';'); + DBG_ASSERT(nSep != STRING_NOTFOUND, "SbaTableQueryBrowser::Execute : invalid ::com::sun::star::util::URL !"); + String sParentContainerUrl; sParentContainerUrl.AssignAscii("file:///"); + sParentContainerUrl += aURL.GetURLPath(); + sParentContainerUrl += '#'; + sParentContainerUrl += sMark.Copy(0, nSep); + + ::com::sun::star::util::URL aParentUrl; + aParentUrl.Complete = sParentContainerUrl; + + Reference< ::com::sun::star::frame::XDispatchProvider > xProvider(m_xCurrentFrame, UNO_QUERY); + DBG_ASSERT(xProvider.is(), "SbaTableQueryBrowser::Execute(ID_BROWSER_EXPL_PREVLEVEL) : no DispatchPprovider !"); + Reference< ::com::sun::star::frame::XDispatch > xDispatcher = xProvider->queryDispatch(aParentUrl, m_xCurrentFrame->getName(), 0); + if (xDispatcher.is()) + xDispatcher->dispatch(aParentUrl, Sequence< PropertyValue>()); + } + break; + + default: + SbaXDataBrowserController::Execute(nId); + break; + } +} +//------------------------------------------------------------------------------ +IMPL_LINK(SbaTableQueryBrowser, OnSelectEntry, SvLBoxEntry*, _pEntry) +{ + // reinitialize the rowset + // but first check if it is necessary + Reference<XPropertySet> xProp(getRowSet(),UNO_QUERY); + ::rtl::OUString aOldName; + xProp->getPropertyValue(PROPERTY_COMMAND) >>= aOldName; + sal_Int32 nOldType; + xProp->getPropertyValue(PROPERTY_COMMANDTYPE) >>= nOldType; + Reference<XConnection> xOldConnection; + xProp->getPropertyValue(PROPERTY_ACTIVECONNECTION) >>= xOldConnection; + // the name of the table or query + SvLBoxString* pString = (SvLBoxString*)_pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING); + ::rtl::OUString aName(pString->GetText().GetBuffer()); + + SvLBoxEntry* pTables = m_pTreeModel->GetParent(_pEntry); + DBTreeListModel::DBTreeListUserData* pData = (DBTreeListModel::DBTreeListUserData*)pTables->GetUserData(); + SvLBoxEntry* pConnection = m_pTreeModel->GetParent(pTables); + DBTreeListModel::DBTreeListUserData* pConData = (DBTreeListModel::DBTreeListUserData*)pConnection->GetUserData(); + + Reference<XConnection> xConnection(pConData->xInterface,UNO_QUERY); + sal_Int32 nCommandType = pData->bTable ? CommandType::TABLE : CommandType::QUERY; + + sal_Bool bRebuild = xOldConnection != xConnection || nOldType != nCommandType || aName != aOldName; + + if(bRebuild) + { + xProp->setPropertyValue(PROPERTY_ACTIVECONNECTION,makeAny(xConnection)); + xProp->setPropertyValue(PROPERTY_COMMANDTYPE,makeAny(nCommandType)); + xProp->setPropertyValue(PROPERTY_COMMAND,makeAny(aName)); + + getContent()->getGridControl()->setDesignMode(sal_True); + getRowSet()->execute(); + InitializeGridModel(getFormComponent()); + Reference< ::com::sun::star::form::XLoadable > xLoadable(getRowSet(),UNO_QUERY); + xLoadable->reload(); + FormLoaded(sal_True); + } + return 0L; +} +// ------------------------------------------------------------------------- + + |